Revision 4594
Added by walbridge about 16 years ago
src/perl/register-dataset.cgi | ||
---|---|---|
1850 | 1850 |
|
1851 | 1851 |
################################################################################ |
1852 | 1852 |
# |
1853 |
# transform the EML document if necessary, otherwise leave unadultered |
|
1854 |
# |
|
1855 |
################################################################################ |
|
1856 |
sub transformEml { |
|
1857 |
my $doc = shift; |
|
1858 |
|
|
1859 |
# get the document namespace |
|
1860 |
my $root = $doc->getDocumentElement(); |
|
1861 |
my $emlns = $root->lookupNamespaceURI("eml"); |
|
1862 |
|
|
1863 |
if ($emlns =~ 'eml-2.0') { |
|
1864 |
debug("Registry: Translation: Upgrading a 2.0.x doc to 2.1.0"); |
|
1865 |
$doc = transformEmlTo210($doc); |
|
1866 |
} |
|
1867 |
elsif ($emlns =~ 'eml-2.1') { |
|
1868 |
debug("Registry: Translation: Found a 2.1.x doc."); |
|
1869 |
} |
|
1870 |
else { |
|
1871 |
$error = "Unrecognized document type!"; |
|
1872 |
debug("Registry: Translation: $error"); |
|
1873 |
push(@errorMessages, $error."\n"); |
|
1874 |
} |
|
1875 |
return $doc; |
|
1876 |
} |
|
1877 |
|
|
1878 |
################################################################################ |
|
1879 |
# |
|
1853 | 1880 |
# Parse an EML 2.x file and extract the metadata into perl variables for |
1854 | 1881 |
# processing and returning to the template processor |
1855 | 1882 |
# |
... | ... | |
1871 | 1898 |
$$templateVars{'show'} = $show; |
1872 | 1899 |
$$templateVars{'site'} = $config->{'site'}; |
1873 | 1900 |
|
1874 |
# get the document namespace |
|
1875 |
my $root = $doc->getDocumentElement(); |
|
1876 |
my $emlns = $root->lookupNamespaceURI("eml"); |
|
1877 |
if ($emlns =~ 'eml-2.0') { |
|
1878 |
$doc = transformEmlTo210($doc); |
|
1879 |
} |
|
1880 |
elsif ($emlns =~ 'eml-2.1') { |
|
1881 |
debug("Registry: Translation: Found a 2.1.x doc."); |
|
1882 |
} |
|
1883 |
else { |
|
1884 |
$error = "Unrecognized document type!"; |
|
1885 |
debug("Registry: Translation: $error"); |
|
1886 |
push(@errorMessages, $error."\n"); |
|
1887 |
} |
|
1901 |
# perform any required transformation |
|
1902 |
$doc = transformEml($doc); |
|
1888 | 1903 |
|
1889 | 1904 |
# find out the tag <alternateIdentifier>. |
1890 | 1905 |
$results = $doc->findnodes('//dataset/alternateIdentifier'); |
... | ... | |
2906 | 2921 |
if (!$response) { |
2907 | 2922 |
# Could not login |
2908 | 2923 |
$errorMessage = $errorMessage." Failed during moderator login."; |
2909 |
|
|
2910 | 2924 |
} else { |
2911 | 2925 |
# read the document and get the contact name and address |
2912 | 2926 |
my $docid = $FORM::docid; |
... | ... | |
2918 | 2932 |
# not able to parse |
2919 | 2933 |
$errorMessage = $errorMessage." Error in reading the following docid:".$docid; |
2920 | 2934 |
} else { |
2935 |
$xmldoc = transformEml($xmldoc); |
|
2936 |
|
|
2937 |
$results = $xmldoc->findnodes('//dataset'); |
|
2938 |
|
|
2921 | 2939 |
my ($emldoc, $temp) = split('<access authSystem=', $docFromMetacat); |
2922 | 2940 |
$emldoc .= $accessblock; |
2923 | 2941 |
$emldoc .= "</dataset>\n</eml:eml>\n"; |
... | ... | |
3313 | 3331 |
} |
3314 | 3332 |
} else { |
3315 | 3333 |
#insert a new document |
3316 |
my $id = $metacat->getLastId('esa_reviews'); |
|
3317 |
if ($id eq "null") { |
|
3318 |
$id = 'esa_reviews.1.1'; |
|
3319 |
} else { |
|
3320 |
($x, $y, $z) = split(/\./, $id); |
|
3321 |
$y++; |
|
3322 |
$id = "$x.$y.1"; |
|
3323 |
} |
|
3324 |
|
|
3334 |
my $id = newAccessionNumber('esa_reviews'); |
|
3325 | 3335 |
my $reviewDoc = ''; |
3326 | 3336 |
$reviewDoc .= "<?xml version=\"1.0\"?>"; |
3327 | 3337 |
$reviewDoc .= "<reviewHistory registryName=\"".$skinName."\">"; |
Also available in: Unified diff
Add wrapper function for transforming XML documents to current EML, change ESA skin to use newAssessionNumber, parse EML document with query instead of split()