Changeset 26096

Show
Ignore:
Timestamp:
10.08.2012 20:31:34 (7 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.

Location:
main/trunk/greenstone3/src/java/org/greenstone/gsdl3
Files:
2 modified

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 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/OAIXML.java

    r25635 r26096  
    9999    public static final String GRANULARITY = "granularity"; 
    100100    public static final String GS3OAI = "GS3OAI"; 
     101    public static final String GS_OAI_RESOURCE_URL = "gs.OAIResourceURL"; 
    101102    public static final String HAS_OAI = "hasOAI"; 
    102103    public static final String HEADER = "header"; 
     
    177178     */ 
    178179    public static String oai_version = "2.0"; 
     180    public static String baseURL = ""; 
    179181     
    180182    /**response owner document */ 
     
    194196      return oai_version; 
    195197    } 
     198     
     199    public static String getBaseURL() { 
     200        return baseURL; 
     201    } 
     202     
    196203    public static Element createElement(String tag_name) { 
    197204      return response_doc.createElement(tag_name); 
     
    286293    } 
    287294    /** Read in OAIConfig.xml (residing web/WEB-INF/classes/) and use it to configure the receptionist etc. 
    288      *  the oai_version variable is also set in here.  
     295     *  the oai_version and baseURL variables are also set in here.  
    289296     *  The init() method is also called in here. */  
    290297    public static Element getOAIConfigXML() { 
     
    310317      oai_version = GSXML.getNodeText(protocol_version).trim(); 
    311318 
     319      // initialize baseURL 
     320      Element base_url_elem = (Element)GSXML.getChildByTagName(oai_config_elem, BASE_URL); 
     321      baseURL = GSXML.getNodeText(base_url_elem); 
     322       
    312323      //initialize token_expiration 
    313324      Element expiration = (Element)GSXML.getChildByTagName(oai_config_elem, RESUMPTION_TOKEN_EXPIRATION); 
     
    387398        } 
    388399      }//end of for() 
    389       Element base_url_elem = (Element)GSXML.getChildByTagName(oai_config_elem, BASE_URL); 
    390       String base_url = GSXML.getNodeText(base_url_elem); 
    391       GSXML.setNodeText(request_elem, base_url); 
     400       
     401      GSXML.setNodeText(request_elem, baseURL); 
    392402       
    393403      Node resp_date = GSXML.getChildByTagName(response, RESPONSE_DATE);