Project

General

Profile

Revision 4601

Added by walbridge about 12 years ago

updated handleModAccept to be EML 2.1.0 compliant, streamlined document generation to use EML creation functions.

View differences:

src/perl/register-dataset.cgi
2892 2892
    if ($isMod < 0) {
2893 2893
        return;
2894 2894
    }
2895
    # change the access rules
2896
    ## create the access block
2897
    my $accessblock = '';
2898
    $accessblock .= "<access authSystem=\"knb\" order=\"denyFirst\">\n";
2899
    $accessblock .= "<allow>\n";
2900
    $accessblock .= "<principal>$username</principal>\n";
2901
    $accessblock .= "<permission>all</permission>\n";
2902
    $accessblock .= "</allow>\n";
2903 2895

  
2904
    foreach (split(":",$moderators)) {
2905
        $accessblock .= "<allow>\n";
2906
        $accessblock .= "<principal>".$_."</principal>\n";
2907
        $accessblock .= "<permission>all</permission>\n";
2908
        $accessblock .= "</allow>\n";
2909
    }
2910

  
2911
    $accessblock .= "<allow>\n";
2912
    $accessblock .= "<principal>public</principal>\n";
2913
    $accessblock .= "<permission>read</permission>\n";
2914
    $accessblock .= "</allow>\n";
2915
    $accessblock .= "</access>\n";
2916

  
2917
    ## read the document from 
2896
    # read the document from 
2918 2897
    my $parser = XML::LibXML->new();
2919 2898
    my $title = '';
2920 2899
    my $contactEmailAddress = '';
......
2932 2911
        $response = $metacat->read($docid);
2933 2912
        my $docFromMetacat = $response->content();
2934 2913
        my $xmldoc = $parser->parse_string($docFromMetacat);
2914
        my $dataElem = '';
2935 2915

  
2936 2916
        if ($xmldoc eq "" || $docFromMetacat=~ /<error/) {
2937 2917
            # not able to parse
2938 2918
            $errorMessage = $errorMessage." Error in reading the following docid:".$docid;
2939 2919
        } else {
2920
            my $emldoc = '';
2940 2921
            $xmldoc = transformEml($xmldoc);
2922
          
2923
            # pull out existing dataset entry 
2924
            $results = $xmldoc->findnodes('//dataset');
2925
            foreach my $r ($results->get_nodelist) {
2926
                $dataElem .= $r->toString();
2927
            }
2941 2928
            
2942
            $results = $xmldoc->findnodes('//dataset');
2929
            $emldoc .= EMLStart();
2930
            # TODO SCW: make sure this replacement works as expected
2931
            $emldoc .= accessElement("true");
2932
            $emldoc .= $dataElem;
2933
            $emldoc .= EMLEnd();
2943 2934

  
2944
            my ($emldoc, $temp) = split('<access authSystem=', $docFromMetacat);
2945
            $emldoc .= $accessblock;
2946
            $emldoc .= "</dataset>\n</eml:eml>\n";
2947

  
2948 2935
            #debug("Document created by handleModAccept is " . $emldoc);
2949 2936
            # update the document
2950 2937
            my $newDocid = incrementRevision($docid);
......
2995 2982
                    $title = '';
2996 2983
                }
2997 2984

  
2998
                $findNodes = $xmldoc->findnodes('//dataset/access/allow');
2985
                $findNodes = $xmldoc->findnodes('//access/allow');
2999 2986
                if ($findNodes->size() > 0) {
3000 2987
                    # found title
3001 2988
                    my $node = '';

Also available in: Unified diff