Index: trunk/pstamp/scripts/pstamp_get_image_job.pl
===================================================================
--- trunk/pstamp/scripts/pstamp_get_image_job.pl	(revision 18542)
+++ trunk/pstamp/scripts/pstamp_get_image_job.pl	(revision 18543)
@@ -15,4 +15,5 @@
 use File::Copy;
 use File::Basename;
+use Digest::MD5::File qw( file_md5_hex );
 
 use PS::IPP::Config qw($PS_EXIT_SUCCESS
@@ -35,4 +36,7 @@
 my $verbose = 1;
 my $ipprc;
+my $dbname;
+my $job_id;
+my $rownum;
 
 #
@@ -41,16 +45,18 @@
 
 GetOptions(
+        'job_id=s'        =>      \$job_id,
+        'rownum=s'        =>      \$rownum,
         'uri=s'           =>      \$uri,
         'out_dir=s'       =>      \$out_dir,
+        'dbname=s'        =>      \$dbname,
 ) or pod2usage(2);
 
 my $err = "";
+$err .= "--job_id is required\n" if (!$job_id);
+$err .= "--rownum is required\n" if (!$rownum);
+$err .= "--uri is required to specify the file list\n" if (!$uri);
+$err .= "--out_dir is required to specify the output fileset\n" if (!$out_dir);
 
-if (!$uri) {
-    die("--uri is required to specify the file list");
-}
-if (!$out_dir) {
-    die("--out_dir is required to specify the output fileset");
-}
+die $err if $err;
 
 # collapse any multiple slashes in output_dir
@@ -89,15 +95,15 @@
 
 my $reglist = "$out_dir/reglist";
-if (! open(REGLIST, ">$reglist") ) {
+if (! open(REGLIST, ">$reglist$job_id") ) {
     die("failed to open registration list: $reglist");
 }
 
 my @files;
+my $num = 0;
 while (<INPUT>) {
     chomp;
     my @fields = split /\|/;
     my $pathname = shift @fields;
-
-    #my ($volume, $directories, $filename) = File::Spec->splitpath($pathname);
+    my $filetype = shift @fields;
 
     ($pathname , my $filename) = resolvepath($pathname);
@@ -107,9 +113,14 @@
     }
 
-    if (! symlink $pathname, "$out_dir/$filename" ) {
-        die("failed trying to create symlink to $pathname in $out_dir");
+    $num++;
+    $filename = "${rownum}_${num}_$filename";
+    my $dest_path = "$out_dir/$filename";
+    if (! copy $pathname, "$dest_path" ) {
+        die("failed trying to copy $pathname to $out_dir");
     }
 
-    print REGLIST "$filename|";
+    # XXX is pstamp always the right file type, if not where can we get the right one?
+    print REGLIST file_registration_line($filename, $dest_path, $filetype);
+
     foreach my $f (@fields) {
         print REGLIST "$f|";
@@ -120,7 +131,5 @@
 close(REGLIST);
 
-#only thing left to do is register the fileset
-exec "dsreg < $reglist --add --product $product --fileset $fileset --type PSRESULTS";
-
+exit 0;
 
 sub resolvepath {
@@ -139,2 +148,19 @@
     return ($pathname, $file);
 }
+
+# XXX move this to a module so the code can be shared 
+sub file_registration_line {
+    my $filename = shift;
+    my $path     = shift;
+    my $filetype = shift;
+    if (-e $path) {
+        my @finfo = stat($path);
+        die "failed to stat $path" unless (@finfo);    # XXX clean up
+        my $bytes = $finfo[7];
+        my $md5sum = file_md5_hex($path);
+
+        return "$filename|$bytes|$md5sum|$filetype|";
+    } else {
+        die "$filename not found at $path";
+    }
+}
