Index: /trunk/PStamp/lib/PStamp/Job.pm
===================================================================
--- /trunk/PStamp/lib/PStamp/Job.pm	(revision 19760)
+++ /trunk/PStamp/lib/PStamp/Job.pm	(revision 19761)
@@ -334,5 +334,5 @@
 
 # splits meta data config input stream into single units to work around the pathalogically
-# slow parser. This is similar to and adapted from code in various of the ippScripts.
+# slow parser. This is similar to and adapted from code in various ippScripts.
 sub parse_md_fast {
     my $mdcParser = shift;
@@ -374,52 +374,40 @@
 # resolve_project()
 # get project specific information
-# This is a placeholder final implementation will use configuration file and database to
-# map from "project" to image database, dvo database, telescope, camera, etc
-#
-# For now just get the database and the class_id that will be used for image lookup
-
 sub resolve_project {
+    my $ipprc = shift;
     my $project_name = shift;
-    my $img_type     = shift;
-    my $class_id     = shift;
+    my $dbname = shift;
     die "project is not defined" if !$project_name;
 
-    # for megacam and simtest since images are at the fpa level, leave out the
-    # class_id at the lookup stage
-    #
-    # TODO: get this information from a database or a configuration file
-
-    my $ret_dbname;
-    my $ret_class_id;
-    my $ret_inst;
-    my $ret_magic;
-    my $ret_camera;
-
-    if ($project_name eq "megacam-mops") {
-        $ret_dbname = "mops";
-        $ret_class_id = "null";
-        $ret_camera = "MEGACAM";
-        $ret_magic = 0;
-    } elsif ($project_name eq "simtest") {
-        $ret_dbname = "ps_simtest";
-        $ret_class_id = "null";
-        $ret_camera = "SIMTEST";
-        $ret_magic = 0;
-    } elsif ($project_name eq "gpc1") {
-        $ret_dbname = "gpc1";
-        $ret_class_id = $class_id;
-        $ret_camera = "GPC1";
-        $ret_magic = 0; # switch this to 1 when we're ready
-    } else {
-        die "unknown project $project_name";
-    }
-
-    if (($img_type ne "raw") and ($img_type ne "chip")) {
-        # don't need class_id
-        $ret_class_id = "";
-    }
-
-    return ($ret_dbname, $ret_class_id, $ret_camera, $ret_magic);
-}
-
+    my $verbose = 1;
+
+    my $missing_tools;
+    my $pstamptool = can_run("pstamptool") or (warn "Can't find pstamptool" and $missing_tools = 1);
+    if ($missing_tools) {
+        warn("Can't find required tools.");
+        exit ($PS_EXIT_CONFIG_ERROR);
+    }
+
+    my $command = "$pstamptool -project -name $project_name";
+    $command .= " -dbname $dbname" if defined $dbname;
+    # run the tool and parse the output
+    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+                run(command => $command, verbose => $verbose);
+    unless ($success) {
+        print STDERR @$stderr_buf;
+        return undef;
+    }
+
+    my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
+
+    my $output = join "", @$stdout_buf;
+    if (!$output) {
+        print STDERR "no output returned from $command\n" if $verbose;
+        return undef;
+    }
+    my $proj_hash = parse_md_fast($mdcParser, $output);
+
+
+    return $proj_hash->[0];
+}
 1;
Index: /trunk/pstamp/scripts/pstamp_finish.pl
===================================================================
--- /trunk/pstamp/scripts/pstamp_finish.pl	(revision 19760)
+++ /trunk/pstamp/scripts/pstamp_finish.pl	(revision 19761)
@@ -163,5 +163,6 @@
         # unless $exp_id is null (e.g. stack images) get the metadata for this exposure
         my ($row, $req_info, $project) = get_request_info($rows, $rownum);
-        my ($image_db) = resolve_project($project);
+        my $proj_hash = resolve_project($project);
+        my $image_db = $proj_hash->{dbname};
         my $exp_info = get_exposure_info($image_db, $exp_id);
 
Index: /trunk/pstamp/scripts/pstampparse.pl
===================================================================
--- /trunk/pstamp/scripts/pstampparse.pl	(revision 19760)
+++ /trunk/pstamp/scripts/pstampparse.pl	(revision 19761)
@@ -143,4 +143,5 @@
 
     $stamp_name = "" if $stamp_name eq "null";
+    $class_id = "" if ($class_id eq "null" or $class_id eq "all");
     
     # XXX: TODO: sanity check all parameters
@@ -151,5 +152,11 @@
     # trash the request.
     die "job_type is list_uri but mode is $mode" if ($job_type eq "list_uri") and ($mode ne "list_uri");
-    my ($image_db, $lookup_class_id, $camera, $magic_required ) = resolve_project($project, $img_type, $class_id);
+
+    my $proj_hash = resolve_project($ipprc, $project, $dbname);
+    die "project $project not found\n" unless $proj_hash;
+
+    my $image_db = $proj_hash->{dbname};
+    my $camera = $proj_hash->{camera};
+    my $need_magic = $proj_hash->{need_magic};
 
     my $roi_string;
@@ -182,5 +189,5 @@
 
     # Call PStamp::Job's locate_images routinte to get the parameters for this request specification
-    my $images = locate_images($ipprc, $image_db, $req_type, $img_type, $id, $lookup_class_id,
+    my $images = locate_images($ipprc, $image_db, $req_type, $img_type, $id, $class_id,
             $x, $y, $mjd_min, $mjd_max, $filter);
 
@@ -217,10 +224,10 @@
     } else {
         my $args = $roi_string ? $roi_string : "";
-        $args .= " -class_id $class_id" if ($class_id and ($class_id ne "null"));
+        $args .= " -class_id $class_id" if $class_id;
 
         # sequence number for the the job for a request spec. Not to be confused with job_id
         my $job_num = 0;
 
-        # XXX for raw and chip level images and class_id "null" if there are multiple images
+        # XXX TODO: for raw and chip level images and class_id "null" if there are multiple images
         # use -list instead of -file
         foreach my $image (@$images) {
@@ -248,5 +255,5 @@
 
             # XXX sounds like magic will be handled outside of the postage stamp server
-            #if ($magic_required) {
+            #if ($need_magic) {
             #    die "no magic mask available" if ! $image->{magic_mask};
             #    $args .= " -magic_mask $image->{magic_mask}" 
