Index: trunk/PStamp/lib/PStamp/Job.pm
===================================================================
--- trunk/PStamp/lib/PStamp/Job.pm	(revision 19437)
+++ 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;
