Revision 2137
Added by sgarg over 20 years ago
register-dataset.cgi | ||
---|---|---|
515 | 515 |
} |
516 | 516 |
|
517 | 517 |
################################################################################ |
518 |
# |
|
519 |
# Subroutine for generating a new ACL document |
|
520 |
# |
|
521 |
################################################################################ |
|
522 |
sub newAccessDocument { |
|
523 |
my $aclid = shift; |
|
524 |
my $acl = "<?xml version=\"1.0\"?>\n"; |
|
525 |
$acl .= "<!DOCTYPE acl "; |
|
526 |
$acl .= "PUBLIC \"$accesspubid\" \"$accesssysid\">\n"; |
|
527 |
$acl .= "<acl authSystem=\"ldap://ldap.ecoinformatics.org\" "; |
|
528 |
$acl .= "order=\"denyFirst\">\n"; |
|
529 |
$acl .= "<identifier system=\"knb\">$aclid</identifier>\n"; |
|
530 |
#$acl .= "<identifier>$aclid</identifier>\n"; |
|
531 |
$acl .= "<allow><principal>$username</principal>" . |
|
532 |
"<permission>all</permission></allow>\n"; |
|
533 |
#$acl .= "<allow><principal>public</principal>" . |
|
534 |
# "<permission>read</permission></allow>\n"; |
|
535 |
$acl .= "</acl>\n"; |
|
536 |
|
|
537 |
return $acl; |
|
538 |
} |
|
539 |
|
|
540 |
################################################################################ |
|
541 |
# |
|
542 |
# Subroutine for inserting identifers to the metadata document passed to us |
|
543 |
# |
|
544 |
################################################################################ |
|
545 |
sub insertIdentifiers { |
|
546 |
my $docstring = shift; |
|
547 |
my $aclid = shift; |
|
548 |
my $docid = shift; |
|
549 |
|
|
550 |
my $parser = XML::LibXML->new(); |
|
551 |
my $dom = $parser->parse_string($docstring); |
|
552 |
|
|
553 |
my $root = $dom->documentElement; |
|
554 |
my $name = $root->getName(); |
|
555 |
|
|
556 |
my $addedIdentifier = 0; |
|
557 |
my $currentElement = $root->getFirstChild(); |
|
558 |
$name = $currentElement->getName(); |
|
559 |
while ("$name" !~ "triple" && |
|
560 |
"$name" !~ "temporalCov" && |
|
561 |
"$name" !~ "geographicCov" && |
|
562 |
"$name" !~ "taxonomicCov" |
|
563 |
) { |
|
564 |
if ("$name" =~ "identifier" || |
|
565 |
"$name" =~ "title") { |
|
566 |
if (! $addedIdentifier) { |
|
567 |
my $idelement = $dom->createElement( "identifier" ); |
|
568 |
$addedIdentifier = 1; |
|
569 |
$idelement->setAttribute("system", "knb"); |
|
570 |
$idelement->appendTextNode($docid); |
|
571 |
$root->insertBefore($idelement, $currentElement); |
|
572 |
} |
|
573 |
} |
|
574 |
$currentElement = $currentElement->getNextSibling(); |
|
575 |
$name = $currentElement->getName(); |
|
576 |
} |
|
577 |
# Link the document to the access doc |
|
578 |
my $element = $dom->createElement( "triple" ); |
|
579 |
$element->appendTextChild( "subject", $aclid); |
|
580 |
$element->appendTextChild( "relationship", |
|
581 |
"describes access control rules for"); |
|
582 |
$element->appendTextChild( "object", $docid); |
|
583 |
$root->insertBefore($element, $currentElement); |
|
584 |
# Link the access doc to the access doc |
|
585 |
$element = $dom->createElement( "triple" ); |
|
586 |
$element->appendTextChild( "subject", $aclid); |
|
587 |
$element->appendTextChild( "relationship", |
|
588 |
"describes access control rules for"); |
|
589 |
$element->appendTextChild( "object", $aclid); |
|
590 |
$root->insertBefore($element, $currentElement); |
|
591 |
|
|
592 |
return $dom->toString(); |
|
593 |
} |
|
594 |
|
|
595 |
################################################################################ |
|
596 | 518 |
# |
597 | 519 |
# Validate the parameters to make sure that required params are provided |
598 | 520 |
# |
Also available in: Unified diff
Removed beta6 specific code which is no longer being used.