r4594 - trunk/src/perl
walbridge at ecoinformatics.org
walbridge at ecoinformatics.org
Wed Nov 19 16:08:41 PST 2008
Author: walbridge
Date: 2008-11-19 16:08:41 -0800 (Wed, 19 Nov 2008)
New Revision: 4594
Modified:
trunk/src/perl/register-dataset.cgi
Log:
Add wrapper function for transforming XML documents to current EML, change ESA skin to use newAssessionNumber, parse EML document with query instead of split()
Modified: trunk/src/perl/register-dataset.cgi
===================================================================
--- trunk/src/perl/register-dataset.cgi 2008-11-19 23:28:54 UTC (rev 4593)
+++ trunk/src/perl/register-dataset.cgi 2008-11-20 00:08:41 UTC (rev 4594)
@@ -1850,6 +1850,33 @@
################################################################################
#
+# transform the EML document if necessary, otherwise leave unadultered
+#
+################################################################################
+sub transformEml {
+ my $doc = shift;
+
+ # get the document namespace
+ my $root = $doc->getDocumentElement();
+ my $emlns = $root->lookupNamespaceURI("eml");
+
+ if ($emlns =~ 'eml-2.0') {
+ debug("Registry: Translation: Upgrading a 2.0.x doc to 2.1.0");
+ $doc = transformEmlTo210($doc);
+ }
+ elsif ($emlns =~ 'eml-2.1') {
+ debug("Registry: Translation: Found a 2.1.x doc.");
+ }
+ else {
+ $error = "Unrecognized document type!";
+ debug("Registry: Translation: $error");
+ push(@errorMessages, $error."\n");
+ }
+ return $doc;
+}
+
+################################################################################
+#
# Parse an EML 2.x file and extract the metadata into perl variables for
# processing and returning to the template processor
#
@@ -1871,20 +1898,8 @@
$$templateVars{'show'} = $show;
$$templateVars{'site'} = $config->{'site'};
- # get the document namespace
- my $root = $doc->getDocumentElement();
- my $emlns = $root->lookupNamespaceURI("eml");
- if ($emlns =~ 'eml-2.0') {
- $doc = transformEmlTo210($doc);
- }
- elsif ($emlns =~ 'eml-2.1') {
- debug("Registry: Translation: Found a 2.1.x doc.");
- }
- else {
- $error = "Unrecognized document type!";
- debug("Registry: Translation: $error");
- push(@errorMessages, $error."\n");
- }
+ # perform any required transformation
+ $doc = transformEml($doc);
# find out the tag <alternateIdentifier>.
$results = $doc->findnodes('//dataset/alternateIdentifier');
@@ -2906,7 +2921,6 @@
if (!$response) {
# Could not login
$errorMessage = $errorMessage." Failed during moderator login.";
-
} else {
# read the document and get the contact name and address
my $docid = $FORM::docid;
@@ -2918,6 +2932,10 @@
# not able to parse
$errorMessage = $errorMessage." Error in reading the following docid:".$docid;
} else {
+ $xmldoc = transformEml($xmldoc);
+
+ $results = $xmldoc->findnodes('//dataset');
+
my ($emldoc, $temp) = split('<access authSystem=', $docFromMetacat);
$emldoc .= $accessblock;
$emldoc .= "</dataset>\n</eml:eml>\n";
@@ -3313,15 +3331,7 @@
}
} else {
#insert a new document
- my $id = $metacat->getLastId('esa_reviews');
- if ($id eq "null") {
- $id = 'esa_reviews.1.1';
- } else {
- ($x, $y, $z) = split(/\./, $id);
- $y++;
- $id = "$x.$y.1";
- }
-
+ my $id = newAccessionNumber('esa_reviews');
my $reviewDoc = '';
$reviewDoc .= "<?xml version=\"1.0\"?>";
$reviewDoc .= "<reviewHistory registryName=\"".$skinName."\">";
More information about the Metacat-cvs
mailing list