Ignore:
Timestamp:
2012-08-10T20:31:34+12:00 (12 years ago)
Author:
ak19
Message:

Now the dc:identifier is set for OAI to either gs.OAIResourceURL if this was set by the user, else to srclinkFile if this exists, else a url to the Greenstone version of a document. This is the logic that GS2 used (in the output_custom_metadata function of dublincore.cpp of runtime-src's oaiservr). Having made this change, doing get-document over OAI works, as is required for the Downloading Over OAI tutorial. Get-document was previously not implemented during the updates to get GS3's OAI server to validate, since the OAI validator never checked for this. This is an optional operation that Greenstone 2 provided, and which GS3 now also allows.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/OAIPMH.java

    r25635 r26096  
    483483        String[] metadata_names = getMetadataNameMapping(metadata_format);
    484484        HashMap meta_map = getInfoByNames(info, metadata_names);
     485       
     486        // if there's no dc:identifier already after the mapping, we'll add it in
     487        if(!meta_map.containsKey(OAIXML.DC+":identifier")) { // dc:identifier OAIXML.IDENTIFIER
     488            outputCustomMetadata(meta_map, info, OAIXML.DC+":identifier");
     489        }
     490   
     491       
    485492    if (meta_map == null) {
    486493      return metadata;
     
    701708    return (empty_map == true) ? null : map;
    702709  }
     710 
     711  // GS3 version of GS2's runtime-src/src/oaiservr/dublincore.cpp function output_custom_metadata
     712  protected void outputCustomMetadata(HashMap meta_map, DBInfo info, String dc_identifier) {
     713       
     714    // try gs.OAIResourceURL, else srclinkFile, else the GS version of the document
     715    String identifier_value = info.getInfo(OAIXML.GS_OAI_RESOURCE_URL);
     716   
     717    if(identifier_value.equals("")) {
     718        String url = OAIXML.getBaseURL(); // e.g. e.g. http://host:port/greenstone3/library/oaiserver
     719   
     720        identifier_value = info.getInfo("srclinkFile");
     721        if(identifier_value.equals(""))
     722        {
     723            // no source file to link to, so link to the GS version of the document (need to use URL-style slashes)
     724            // e.g. http://host:port/greenstone3/library/collection/lucene-jdbm-demo/document/HASH014602ec89e16b7d431c7627
     725           
     726            identifier_value = url.replace("oaiserver", "library") + "collection/" + this.coll_name + "/document/" + info.getInfo("identifier"); // OID
     727        }
     728        else // use srclinkFile
     729        {       
     730            // e.g. http://host:port/greenstone3/sites/localsite/collect/backdrop/index/assoc/D0.dir/Cat.jpg
     731            identifier_value = url.replace("oaiserver", "") + "sites/" + this.site_name
     732                + "/collect/" + this.coll_name + "/index/assoc/"
     733                + info.getInfo("assocfilepath") + "/" + identifier_value; // srclinkFile
     734        }
     735    } // else use gs.OAIResourceURL as-is
     736   
     737    //logger.info("**** dc:identifier: " + identifier_value);
     738   
     739    meta_map.put(dc_identifier, identifier_value);
     740  }
    703741}
    704742
Note: See TracChangeset for help on using the changeset viewer.