Changeset 32213


Ignore:
Timestamp:
2018-06-26T13:38:37+12:00 (3 years ago)
Author:
kjdon
Message:

OAI: don't have hardcoded custom outputting for dc.identifier anymore. we do it via mapping in siteConfig, using special keywords gsflink.source, gsflink.document. User can choose to have links to gs.OAIResourceURL, srclink or link, or all or any combination of these. Prompted by diego wanting the srclink and link urls as dc.identifier

File:
1 edited

Legend:

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

    r31966 r32213  
    692692    String[] names = name_list.split(",");
    693693    for (int i=0; i<names.length; i++) {
    694       Vector<String> values = info.getMultiInfo(names[i]);
     694      Vector<String> values;
     695      // some special words
     696      if (names[i].startsWith(OAIXML.GSF_LINK_PREFIX)) {
     697    values = new Vector<String>();
     698    String base_url = OAIXML.getBaseURL(); // e.g. e.g. http://host:port/greenstone3/oaiserver
     699    String link_url = null;
     700    if (names[i].equals(OAIXML.GSF_LINK_PREFIX+OAIXML.LINK_TYPE_DOCUMENT)) {
     701      link_url =  base_url.replace("oaiserver", "library") + "/collection/" + this.coll_name + "/document/" + info.getInfo("Identifier");
     702    } else if (names[i].equals(OAIXML.GSF_LINK_PREFIX+OAIXML.LINK_TYPE_SOURCE)) {
     703      String srcfile = info.getInfo("srclinkFile");
     704      if (!srcfile.equals("")) {
     705        link_url = base_url.replace("oaiserver", "") + "sites/"
     706             + this.site_name
     707             + "/collect/" + this.coll_name + "/index/assoc/"
     708             + info.getInfo("assocfilepath") + "/" + srcfile;
     709      }
     710    }
     711    if (link_url !=null) {
     712      values.add(link_url);
     713    }
     714      } else {
     715    values = info.getMultiInfo(names[i]);
     716      }
    695717      if (values == null || values.size()==0) {
    696718    continue;
     
    710732 
    711733  // specific metadata formats might need to do some custom metadata that is not
    712   //just a standard mapping. eg oai_dc outputting an identifier that is a link
     734  //just a standard mapping.
    713735  protected void addCustomMetadata(Element meta_list_elem, String prefix, DBInfo info) {
    714736   
    715     if (prefix.equals(OAIXML.META_FORMAT_DC)) {
    716       // we want to add in another dc:identifier element with a link to the resource if possible
    717       // try gs.OAIResourceURL first, then srclinkFile, then GS version of documnet
    718       String gsURL = info.getInfo(OAIXML.GS_OAI_RESOURCE_URL);
    719       if (gsURL.equals("")) {
    720     String base_url = OAIXML.getBaseURL(); // e.g. e.g. http://host:port/greenstone3/oaiserver
    721     // try srclinkFile
    722     gsURL = info.getInfo("srclinkFile");
    723     if (!gsURL.equals("")) {
    724       // make up the link to the file
    725       gsURL = base_url.replace("oaiserver", "") + "sites/" + this.site_name
    726         + "/collect/" + this.coll_name + "/index/assoc/"
    727         + info.getInfo("assocfilepath") + "/" + gsURL;
    728     } else {
    729       // no srclink file, lets provide a link to the greenstone doc
    730       gsURL = base_url.replace("oaiserver", "library") + "/collection/" + this.coll_name + "/document/" + info.getInfo("Identifier");
    731     }
    732       }
    733       // now we have the url link, add as metadata
    734       addMetadataElement(meta_list_elem, "dc:identifier", gsURL);
    735     }
    736   }
    737 
     737
     738  }
     739 
    738740  /** create the actual metadata element for the list */
    739741  protected void addMetadataElement(Element meta_list_elem, String name, String value) {
Note: See TracChangeset for help on using the changeset viewer.