Revision 4625
Added by walbridge about 16 years ago
register-dataset.cgi | ||
---|---|---|
44 | 44 |
use strict; |
45 | 45 |
|
46 | 46 |
# Global configuration paramters |
47 |
my $cgiUrl = $ENV{'SCRIPT_FILENAME'};
|
|
47 |
my $cgiDir = $ENV{'SCRIPT_FILENAME'};
|
|
48 | 48 |
my $workingDirectory = "."; |
49 |
if ($cgiUrl ne "") {
|
|
50 |
my $workingDirectory = dirname($cgiUrl);
|
|
49 |
if ($cgiDir ne "") {
|
|
50 |
my $workingDirectory = dirname($cgiDir);
|
|
51 | 51 |
} |
52 | 52 |
my $metacatProps = "${workingDirectory}/../WEB-INF/metacat.properties"; |
53 | 53 |
my $properties = new Config::Properties(); |
... | ... | |
122 | 122 |
} |
123 | 123 |
|
124 | 124 |
# replacements for appconfig values using properties |
125 |
my $moderators = $properties->getProperty('ldap.moderators');
|
|
125 |
my $moderators = $properties->getProperty('moderators'); |
|
126 | 126 |
my $config = $skinProperties->splitToTree(qr/\./, 'registry.config'); |
127 | 127 |
my $templates = $skinProperties->splitToTree(qr/\./, 'registry.templates'); |
128 | 128 |
my $modules = $skinProperties->splitToTree(qr/\./, 'registry.modules'); |
... | ... | |
439 | 439 |
$docid = incrementRevision($FORM::docid); |
440 | 440 |
|
441 | 441 |
$xmldoc =~ s/docid/$docid/; |
442 |
debugDoc($xmldoc);$
|
|
442 |
debugDoc($xmldoc); |
|
443 | 443 |
|
444 | 444 |
my $response = $metacat->update($docid, $xmldoc); |
445 | 445 |
|
... | ... | |
1844 | 1844 |
|
1845 | 1845 |
my $transform = "$styleCommonPath/conversions/eml201to210.xsl"; |
1846 | 1846 |
$stylesheet = $xslt->parse_stylesheet_file($transform); |
1847 |
$results = $stylesheet->transform($doc); |
|
1848 |
#my $out = "$emldir/test-210.xml"; |
|
1849 |
#open (TFILE,">$out") || die("Can't open xml file...\n"); |
|
1850 |
#print TFILE $stylesheet->output_string($results); |
|
1851 |
#close(TFILE); |
|
1852 |
#print "Output $out.\n"; |
|
1847 |
$results = $stylesheet->transform($xmldoc); |
|
1848 |
# if debugging is enabled, dump the transformed document to disk |
|
1849 |
debugDoc($stylesheet->output_string($results)); |
|
1853 | 1850 |
return $results; |
1854 | 1851 |
} |
1855 | 1852 |
|
... | ... | |
2469 | 2466 |
|
2470 | 2467 |
$results = $doc->findnodes('//access/allow'); |
2471 | 2468 |
my $accessError = 0; |
2469 |
|
|
2472 | 2470 |
foreach $node ($results->get_nodelist) { |
2473 | 2471 |
my @children = $node->childNodes; |
2474 |
my $principal = ""; |
|
2475 | 2472 |
my $permission = ""; |
2476 | 2473 |
for (my $i = 0; $i < scalar(@children); $i++) { |
2477 | 2474 |
my $child = $children[$i]; |
... | ... | |
2484 | 2481 |
|
2485 | 2482 |
if ($principal eq 'public' && $permission ne 'read') { $accessError = 1; } |
2486 | 2483 |
if ($principal eq $username && $permission ne 'all') { $accessError = 2; } |
2487 |
if ($principal ne 'public' && $principal ne $username && $principal ne $moderators && $permission ne 'all') { $accessError = 3; } |
|
2484 |
if ($principal ne 'public' && $principal ne $username && $permission ne 'all') { $accessError = 3; } |
|
2485 |
# TODO: FIXME for 1.9.1 |
|
2486 |
# The ESA skin has a separate concept of 'moderator', which is defined by a property |
|
2487 |
# within the configuration. This should be updated to check the user against the groups. |
|
2488 |
# my $isSkinModerator = 0; |
|
2489 |
# my $userGroups = metacat->getGroups($username'); |
|
2490 |
#foreach my $mod (split(":", $moderators) { |
|
2491 |
# foreach $my $ug (split(":", $userGroups)) { |
|
2492 |
# if ($ug == $mod) { |
|
2493 |
# $isSkinModerator = 1; |
|
2494 |
# } |
|
2495 |
# } |
|
2496 |
#} |
|
2497 |
# if (!$isSkinModerator) { |
|
2498 |
# $accessError = 3; |
|
2499 |
# } |
|
2488 | 2500 |
if ($accessError == 3) { |
2489 | 2501 |
my $session = CGI::Session->load(); |
2490 | 2502 |
if (!$session->is_empty) { |
... | ... | |
2498 | 2510 |
} |
2499 | 2511 |
|
2500 | 2512 |
if ($accessError != 0) { |
2501 |
my $error ="The ACL for this document has been changed outside the registry. Please use Morpho to edit this document";
|
|
2513 |
my $error = "The ACL for this document has been changed outside the registry. Please use Morpho to edit this document (Access Error #$accessError).";
|
|
2502 | 2514 |
push(@errorMessages, $error."\n"); |
2503 | 2515 |
} |
2504 | 2516 |
|
... | ... | |
2567 | 2579 |
my $pushDoc; |
2568 | 2580 |
my $alreadyInArray; |
2569 | 2581 |
my $findType; |
2570 |
my $node; |
|
2571 |
my $response; |
|
2582 |
my $node; |
|
2572 | 2583 |
my $element; |
2573 | 2584 |
|
2574 | 2585 |
push (@fileArray, $docid); |
... | ... | |
2815 | 2826 |
<frameset rows="150,*" cols="*" frameborder="NO" border="0" framespacing="0"> |
2816 | 2827 |
<frame src="$skinsDir/$skinName/header.jsp" marginwidth="40" name="topFrame" scrolling="NO" noresize> |
2817 | 2828 |
<frameset cols="200,*" frameborder="NO" border="0" framespacing="0"> |
2818 |
<body></body><frame src="$cgiUrl?cfg=$skinName&stage=review_frame&docid="$docid"" name="rightFrame" scrolling="NO" noresize></frame>
|
|
2829 |
<body></body><frame src="$cgiPrefix/register-dataset.cgi?cfg=$skinName&stage=review_frame&docid="$docid"" name="rightFrame" scrolling="NO" noresize></frame>
|
|
2819 | 2830 |
<frame src="$metacatUrl?action=read&qformat=$skinName&docid=$docid&insertTemplate=0" name="mainFrame"> |
2820 | 2831 |
</frameset> |
2821 | 2832 |
</frameset> |
... | ... | |
2912 | 2923 |
my $docFromMetacat = $response->content(); |
2913 | 2924 |
my $xmldoc = $parser->parse_string($docFromMetacat); |
2914 | 2925 |
my $dataElem = ''; |
2926 |
my $results; |
|
2915 | 2927 |
|
2916 | 2928 |
if ($xmldoc eq "" || $docFromMetacat=~ /<error/) { |
2917 | 2929 |
# not able to parse |
... | ... | |
3221 | 3233 |
$userDN = ''; |
3222 | 3234 |
} |
3223 | 3235 |
} |
3224 |
# SCW TODO FIX THIS |
|
3225 |
my ($emldoc, $temp) = split('</dataset>', $doc); |
|
3226 |
$emldoc .= "</dataset>\n<additionalMetadata>\n<moderatorComment>Revision Requested</moderatorComment>\n</additionalMetadata>"; |
|
3227 |
$emldoc .= "\n</eml:eml>\n"; |
|
3236 |
|
|
3237 |
my $emldoc = ''; |
|
3238 |
my $dataElem = ''; |
|
3239 |
my $accessElem = ''; |
|
3240 |
|
|
3241 |
# pull out existing dataset entry |
|
3242 |
my $results = $doc->findnodes('//dataset'); |
|
3243 |
foreach my $r ($results->get_nodelist) { |
|
3244 |
$dataElem .= $r->toString(); |
|
3245 |
} |
|
3246 |
# also grab the access element |
|
3247 |
$results = $doc->findnodes('//access'); |
|
3248 |
foreach my $r ($results->get_nodelist) { |
|
3249 |
$accessElem .= $r->toString(); |
|
3250 |
} |
|
3251 |
|
|
3252 |
my $addlMetadata = qq| |
|
3253 |
<additionalMetadata> |
|
3254 |
<moderatorComment>Revision Requested</moderatorComment> |
|
3255 |
</additionalMetadata>|; |
|
3256 |
|
|
3257 |
$emldoc .= EMLStart(); |
|
3258 |
$emldoc .= $accessElem; |
|
3259 |
$emldoc .= $dataElem; |
|
3260 |
$emldoc .= $addlMetadata; |
|
3261 |
$emldoc .= EMLEnd(); |
|
3262 |
|
|
3228 | 3263 |
#debug("Document created by handleModAccept is " . $emldoc); |
3229 | 3264 |
# update the document |
3230 | 3265 |
my $newDocid = incrementRevision($docid); |
... | ... | |
3258 | 3293 |
my $action = shift; |
3259 | 3294 |
my $metacat = shift; |
3260 | 3295 |
my $userDN = shift; |
3261 |
|
|
3296 |
|
|
3262 | 3297 |
my $gmt = gmtime($now); |
3298 |
my $docid = $FORM::docid; |
|
3263 | 3299 |
my $parser = XML::LibXML->new(); |
3264 | 3300 |
|
3265 | 3301 |
# create the xml part that has to be inserted |
3266 |
my $review = '';
|
|
3267 |
$review .= '<review>';
|
|
3268 |
$review .= '<packageId>'.$FORM::docid.'</packageId>';
|
|
3269 |
$review .= '<action>'.$action.'</action>';
|
|
3270 |
$review .= '<datetime>'.$gmt.'</datetime>';
|
|
3271 |
$review .= '<text>'.$FORM::review.'</text>';
|
|
3272 |
$review .= '</review>';
|
|
3302 |
my $review = qq|
|
|
3303 |
<review>
|
|
3304 |
<packageId>$docid</packageId>
|
|
3305 |
<action>$action</action>
|
|
3306 |
<datetime>$gmt</datetime>
|
|
3307 |
<text>$FORM::review</text>
|
|
3308 |
</review>|;
|
|
3273 | 3309 |
|
3274 | 3310 |
# find out if a docid already exists... |
3275 |
my $docid = $FORM::docid; |
|
3276 | 3311 |
my ($x, $y, $z) = split(/\./, $docid); |
3277 | 3312 |
my $docidWithoutRev = $x.$y; |
3278 | 3313 |
my $reviewDocumentId = ''; |
Also available in: Unified diff
Number of ESA-related fixes:
- fix review panel to reference valid URL using cgiPrefix
- update ESA document creation to use XSLT methods instead of split()
- add code for ESA access rules fix (to be used in 1.9.1)
- use moderators in metacat.properties (postpone skin-based configuration till 1.9.1)
- use cgiDir instead of cgiUrl