Project

General

Profile

« Previous | Next » 

Revision 4517

Added by walbridge about 16 years ago

Partial fix for #3496, making the registry create EML 2.1.0 documents. The documents are internally valid 2.1.0 (they run against the validator correctly) but aren't inserting into Metacat correctly as of yet.

View differences:

register-dataset.cgi
381 381
    my $xmldoc = createXMLDocument();
382 382
    
383 383
    # Write out the XML file for debugging purposes
384
    #my $testFile = $tempDir . "/test-file.xml";
385
    #open (TFILE,">$testFile") || die ("Cant open xml file...\n");
386
    #print TFILE $xmldoc;
387
    #close(TFILE);
384
    my $testFile = $tempDir . "/registry-eml-upload.xml";
385
    open (TFILE,">$testFile") || die ("Cant open xml file...\n");
386
    print TFILE $xmldoc;
387
    close(TFILE);
388 388

  
389 389
    my $xmldocWithDocID = $xmldoc;
390 390
    my $errorMessage = "";
......
1084 1084

  
1085 1085
sub createProjectDocument {
1086 1086
    my $doc = EMLStart();
1087

  
1087
    $doc .= accessElement();
1088
    $doc .= datasetStart();
1088 1089
    $doc .= titleElement();
1089 1090
    $doc .= creatorNameElement();
1090 1091
    $doc .= creatorElement();
......
1105 1106
    $doc .= "</studyAreaDescription>\n";
1106 1107

  
1107 1108
    $doc .= "</project>";
1108
    $doc .= accessElement();
1109 1109
    $doc .= datasetEnd();
1110 1110
    $doc .= EMLEnd();
1111 1111
    return $doc;
......
1113 1113

  
1114 1114
sub createDatasetDocument {
1115 1115
    my $doc = EMLStart();
1116
    $doc .= accessElement();
1117
    $doc .= datasetStart();
1116 1118
    $doc .= titleElement();
1117 1119
    $doc .= creatorElement();
1118 1120
    $doc .= contactElement('creator');
......
1127 1129
    $doc .= coverageElement();
1128 1130
    $doc .= contactElement();
1129 1131
    $doc .= methodsElement();
1130
    $doc .= accessElement();
1131 1132
    my %fileData = allFileData();
1132 1133
    $doc .= entityElement(\%fileData);
1133 1134
    $doc .= datasetEnd();
1134
    $doc .= addMetaElement(\%fileData);
1135 1135
    $doc .= EMLEnd();
1136 1136
}
1137 1137

  
......
1213 1213
    my %entityObjects = %$entityObjects;
1214 1214
    my $entityList = "";
1215 1215

  
1216
    my $access = fileAccessElement(\%entityObjects);
1216 1217
    while ( my ($docid, $data) = each(%entityObjects) ) {
1217 1218
        my $entityStub = qq|<otherEntity id="$data->{'entityid'}" scope="document">
1218 1219
            <entityName>$data->{'fileName'}</entityName>
......
1229 1230
                    <online>
1230 1231
                        <url function="download">$data->{'url'}</url>
1231 1232
                    </online>
1233
                    $access
1232 1234
                </distribution>
1233 1235
            </physical>
1234 1236
            <entityType>$data->{'entityType'}</entityType>
......
1240 1242
    return $entityList;
1241 1243
}
1242 1244

  
1243
sub addMetaElement() {
1245
sub fileAccessElement() {
1244 1246
    my $entityObjects = shift;
1245 1247
    my %entityObjects = %$entityObjects;
1246 1248
    my $userAccess = allowElement(getUsername(), 'all');
1247 1249
    my $skinAccess = allowElement($username, 'all');
1250
    my $accessList = "";
1248 1251

  
1249
    my $accessList = "";
1250 1252
    # form name => EML permission; roles akin to Apache model
1251 1253
    my %accessRoles = (
1252 1254
        'public'  => 'allow',
......
1255 1257

  
1256 1258
    while ( my ($docid, $data) = each(%entityObjects) ) {
1257 1259
        my $defaultAccess = $accessRoles{$data->{'filePerm'}};
1258
        my $accessStub = qq|<additionalMetadata>
1259
            <describes>$data->{'distribid'}</describes>
1260
        $accessList = qq|
1260 1261
                <access authSystem="knb" order="denyFirst">
1261 1262
                    $skinAccess
1262 1263
                    $userAccess 
......
1265 1266
                        <permission>read</permission>
1266 1267
                    </$defaultAccess>
1267 1268
                </access>
1268
      </additionalMetadata>
1269 1269
    |;
1270
        $accessList .= $accessStub;
1271 1270
    }
1272 1271

  
1273 1272
  return $accessList;
......
1317 1316
    my $gmt = gmtime($now);
1318 1317
    my $doc =  "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
1319 1318

  
1320
    $doc .= "<eml:eml
1321
                      packageId=\"docid\" system=\"knb\"
1322
                      xmlns:eml=\"eml://ecoinformatics.org/eml-2.0.1\"
1323
                      xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
1324
                      xmlns:ds=\"eml://ecoinformatics.org/dataset-2.0.1\"
1325
                      xmlns:stmml=\"http://www.xml-cml.org/schema/stmml\"
1326
                      xsi:schemaLocation=\"eml://ecoinformatics.org/eml-2.0.1 eml.xsd\">\n";
1319
    $doc .= qq|<eml:eml
1320
      packageId="docid" system="knb"
1321
      xmlns:eml="eml://ecoinformatics.org/eml-2.1.0"
1322
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1323
      xmlns:ds="eml://ecoinformatics.org/dataset-2.1.0"
1324
      xmlns:stmml="http://www.xml-cml.org/schema/stmml"
1325
      xsi:schemaLocation="eml://ecoinformatics.org/eml-2.1.0 eml.xsd">
1326
|;
1327 1327

  
1328 1328
    $doc .= "<!-- Person who filled in the catalog entry form: ";
1329 1329
    $doc .= normalize($FORM::providerGivenName)." ".normalize($FORM::providerSurName)." -->\n";
1330 1330
    $doc .= "<!-- Form filled out at $gmt GMT -->\n";
1331
    $doc .= "<dataset>\n";
1332

  
1333
    if (hasContent($FORM::identifier)) {
1334
        $doc .= "<alternateIdentifier system=\"$FORM::site\">";
1335
        $doc .= normalize($FORM::identifier) . "</alternateIdentifier>\n";
1336
    }
1337 1331
    return $doc;
1338 1332
}
1339 1333

  
......
1341 1335
    return  "</eml:eml>\n";
1342 1336
}
1343 1337

  
1338
sub datasetStart() {
1339
    my $dataset = "<dataset>\n";
1340
        
1341
    if (hasContent($FORM::identifier)) {
1342
        $dataset .= "<alternateIdentifier system=\"$FORM::site\">";
1343
        $dataset .= normalize($FORM::identifier) . "</alternateIdentifier>\n";
1344
    }
1345
    return $dataset;
1346
}
1347
                                   
1344 1348
sub datasetEnd() {
1345 1349
    return "</dataset>\n";
1346 1350
}

Also available in: Unified diff