Project

General

Profile

Revision 4606

Added by walbridge about 12 years ago

Further ESA fixes: More 2.1.0 compliance, fix security issue

View differences:

register-dataset.cgi
2901 2901
    my $userDN = '';
2902 2902
    # Log into metacat
2903 2903
    my $response = $metacat->login($modUsername, $modPassword);
2904
    my $docid = $FORM::docid;
2904 2905

  
2905 2906
    if (!$response) {
2906 2907
        # Could not login
2907 2908
        $errorMessage = $errorMessage." Failed during moderator login.";
2908 2909
    } else {
2909 2910
        # read the document and get the contact name and address
2910
        my $docid = $FORM::docid;
2911 2911
        $response = $metacat->read($docid);
2912 2912
        my $docFromMetacat = $response->content();
2913 2913
        my $xmldoc = $parser->parse_string($docFromMetacat);
......
3001 3001

  
3002 3002
    # send notification to the user and the moderator
3003 3003
    if ($errorMessage eq '') {
3004
        modSendNotification($title, $contactEmailAddress, $contactName, 'Document '.$FORM::docid.' Accepted');
3004
        modSendNotification($title, $contactEmailAddress, $contactName, "Document $docid Accepted");
3005 3005
        if ($FORM::review ne '') {
3006 3006
            $errorMessage = modStoreReview('accept', $metacat, $userDN);
3007 3007
            if ($errorMessage ne '') {
......
3026 3026
    my $errorMessage = '';
3027 3027
    my $userDN = '';
3028 3028
    my $metacat = Metacat->new($metacatUrl);
3029
    my $docid = $FORM::docid;
3029 3030

  
3030 3031
    print "Content-type: text/html\n\n";
3031 3032

  
......
3050 3051
    } else {
3051 3052
        # read the document and get the contact name and address
3052 3053
        my $parser = XML::LibXML->new();
3053
        my $docid = $FORM::docid;
3054 3054

  
3055 3055
        $response = $metacat->read($docid);
3056 3056
        my $doc = $response->content();
......
3090 3090
                $title = '';
3091 3091
            }
3092 3092

  
3093
            $findNodes = $xmldoc->findnodes('//dataset/access/allow');
3093
            $findNodes = $xmldoc->findnodes('//access/allow');
3094 3094
            if ($findNodes->size() > 0) {
3095
                # found title
3095
                # found allow
3096 3096
                my $node = '';
3097 3097
                foreach $node ($findNodes->get_nodelist) {
3098 3098
                     my $perm = findValue($node,'permission');
......
3116 3116
    }
3117 3117

  
3118 3118
    if ($errorMessage eq '') {
3119
        modSendNotification($title, $contactEmailAddress, $contactName, 'Document '.$FORM::docid.' Rejected');
3119
        modSendNotification($title, $contactEmailAddress, $contactName, "Document $docid Rejected");
3120 3120
        if ($FORM::review ne '') {
3121 3121
            $errorMessage = modStoreReview('decline', $metacat, $userDN);
3122 3122
            if ($errorMessage ne '') {
......
3139 3139
sub handleModRevise(){
3140 3140
    my $errorMessage = '';
3141 3141
    my $metacat = Metacat->new($metacatUrl);
3142
    my $docid = $FORM::docid;
3142 3143

  
3143 3144
    print "Content-type: text/html\n\n";
3144 3145

  
......
3165 3166
    } else {
3166 3167
        # read the document and get the contact name and address
3167 3168
        my $parser = XML::LibXML->new();
3168
        my $docid = $FORM::docid;
3169 3169

  
3170 3170
        $response = $metacat->read($docid);
3171 3171
        my $doc = $response->content();
......
3207 3207
                $title = '';
3208 3208
            }
3209 3209

  
3210
            $findNodes = $xmldoc->findnodes('//dataset/access/allow');
3210
            $findNodes = $xmldoc->findnodes('//access/allow');
3211 3211
            if ($findNodes->size() > 0) {
3212 3212
                # found title
3213 3213
                my $node = '';
......
3221 3221
                $userDN = '';
3222 3222
            }
3223 3223
        }
3224

  
3224
        # SCW TODO FIX THIS
3225 3225
        my ($emldoc, $temp) = split('</dataset>', $doc);
3226 3226
        $emldoc .= "</dataset>\n<additionalMetadata>\n<moderatorComment>Revision Requested</moderatorComment>\n</additionalMetadata>";
3227 3227
        $emldoc .= "\n</eml:eml>\n";
3228 3228
        #debug("Document created by handleModAccept is " . $emldoc);
3229 3229
        # update the document
3230
        my $docid = $FORM::docid;
3231 3230
        my $newDocid = incrementRevision($docid);
3232 3231

  
3233 3232
        $emldoc =~ s/packageId=\"$docid\"/packageId=\"$newDocid\"/;
......
3240 3239

  
3241 3240
    }
3242 3241
    if ($errorMessage eq '') {
3243
        modSendNotification($title, $contactEmailAddress, $contactName, "Revise document: ".$FORM::docid);
3242
        modSendNotification($title, $contactEmailAddress, $contactName, "Revise document: $docid");
3244 3243
        if ($FORM::review ne '') {
3245 3244
            $errorMessage = modStoreReview('revise', $metacat, $userDN);
3246 3245
            if ($errorMessage ne '') {
......
3325 3324
            #insert a new document
3326 3325
            my $id = newAccessionNumber('esa_reviews');
3327 3326
            my $reviewDoc = '';
3327
            my $failMessage = " Unable to insert the review on Metacat for the docid:".$docid;
3328

  
3328 3329
            $reviewDoc .= "<?xml version=\"1.0\"?>";
3329 3330
            $reviewDoc .= "<reviewHistory registryName=\"".$skinName."\">";
3330 3331
            $reviewDoc .= $review;
3331 3332
            $reviewDoc .= "</reviewHistory>";
3332 3333
            $response = $metacat->insert($id, $reviewDoc);
3334

  
3333 3335
            if ($response != '1') {
3334
                return " Unable to insert the review on Metacat for the docid:".$docid;
3336
                return $failMessage;
3335 3337
            } else {
3336 3338
                # set access
3337 3339
                $response = $metacat->setaccess($id, $userDN, "read", "allow", "denyFirst");
3338 3340
                if ($response != '1') {
3339
                    return " Unable to set access for the review document in Metacat for the docid:".$docid;
3341
                    return $failMessage;
3340 3342
                }
3341 3343
                foreach (split(":",$moderators)) {
3342 3344
                    $response = $metacat->setaccess($id, $_, "all", "allow", "denyFirst");
3343 3345
                    if ($response != '1') {
3344
                        return " Unable to set access for the review document in Metacat for the docid:".$docid;
3346
                        return $failMessage;
3345 3347
                    }
3346 3348
                }
3349
                # DENY all public access to these documents
3350
                $response = $metacat->setaccess($id, 'public', "all", "deny", "denyFirst");
3351
                if ($response != '1') {
3352
                    return $failMessage;
3353
                }
3354

  
3347 3355
            }
3348 3356
        }
3349 3357
    }

Also available in: Unified diff