Changeset 35225


Ignore:
Timestamp:
2021-07-06T14:32:20+12:00 (3 years ago)
Author:
kjdon
Message:

OAI identifiers should be (I think??) oai:repository_id:coll_name:doc_id. So I have updated the code to use this instead of just coll_name:doc_id

Location:
main/trunk/greenstone3/src/java/org/greenstone/gsdl3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/OAIReceptionist.java

    r32892 r35225  
    945945     
    946946    identifier = param.getAttribute(GSXML.VALUE_ATT);
    947     // the identifier is in the form: <coll_name>:<OID>
     947    // the identifier is in the form: oai:<repository_id>:<coll_name>:<OID>
    948948    // so it must contain at least one ':' characters
    949949    // (the oid itself may contain : chars)
    950     String[] strs = identifier.split(":", 2);
    951     if(strs.length != 2) {
    952       logger.error("identifier is not in the form coll:id" + identifier);
     950    String[] strs = identifier.split(":", 4);
     951    if(strs.length != 4) {
     952      logger.error("identifier is not in the form oai:repository_id:coll:id" + identifier);
    953953      return OAIXML.createErrorMessage(OAIXML.ID_DOES_NOT_EXIST, "");
    954954    }
     
    956956    // send request to message router
    957957    // get the names
    958     String coll_name = strs[0];
    959     String oid = strs[1];
     958    String coll_name = strs[2];
     959    String oid = strs[3];
    960960
    961961    Document msg_doc = XMLConverter.newDOM();
     
    10981098
    10991099    // get the names
    1100     String[] strs = identifier.split(":", 2);
    1101     if(strs == null || strs.length < 2) {
    1102       logger.error("identifier is not in the form coll:id" + identifier);
     1100    String[] strs = identifier.split(":", 4);
     1101    if(strs == null || strs.length < 4) {
     1102      logger.error("identifier is not in the form oai:repository_id:coll:id" + identifier);
    11031103      return OAIXML.createErrorMessage(OAIXML.ID_DOES_NOT_EXIST, "");
    11041104    }   
    11051105    //String name_of_site = strs[0];
    1106     String coll_name = strs[0];
    1107     String oid = strs[1];
     1106    String coll_name = strs[2];
     1107    String oid = strs[3];
    11081108   
    11091109    //re-organize the request element
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/OAIPMH.java

    r33972 r35225  
    5959  protected SimpleCollectionDatabase coll_db = null;
    6060  protected SimpleCollectionDatabase oaiinf_db = null;
    61  
     61
     62  protected String repository_id = "";
    6263  protected String site_name = "";
    6364  protected String coll_name = "";
     
    174175    this.format_elements_map = new HashMap<String, HashSet<String>>();
    175176    this.format_meta_elem_map = new HashMap<String, Element>();
     177
     178    // get the reposityIdentifier
     179    Element ri = (Element)GSXML.getChildByTagName(oai_config_elem, OAIXML.REPOSITORY_IDENTIFIER);
     180    if (ri != null) {
     181      this.repository_id = GSXML.getNodeText(ri);
     182    } else {
     183      this.repository_id = "";
     184    }
    176185
    177186    // for now, all we want is the metadata prefix description and the mapping list
     
    774783   
    775784        Element identifier = doc.createElement(OAIXML.IDENTIFIER);
    776     GSXML.setNodeText(identifier, coll_name + ":" + oid);
     785    GSXML.setNodeText(identifier, OAIXML.createOAIIdentifier(repository_id,coll_name,oid));
    777786        header.appendChild(identifier);
    778787        Element set_spec = doc.createElement(OAIXML.SET_SPEC);
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/OAIXML.java

    r33970 r35225  
    647647    return map;
    648648  }
    649    
     649
     650  public static String createOAIIdentifier(String repository_id, String collection, String doc_id) {
     651    return "oai:"+repository_id+":"+collection+":"+doc_id;
     652  }
     653 
    650654  public static Element createOAIIdentifierXML(Document doc, String repository_id, String sample_collection, String sample_doc_id) {
    651     String xml = "<oai-identifier xmlns=\"http://www.openarchives.org/OAI/2.0/oai-identifier\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://www.openarchives.org/OAI/2.0/oai-identifier\n http://www.openarchives.org/OAI/2.0/oai-identifier.xsd\">\n <scheme>oai</scheme>\n<repositoryIdentifier>" + repository_id + "</repositoryIdentifier>\n<delimiter>:</delimiter>\n<sampleIdentifier>oai:"+repository_id+":"+sample_collection+":"+sample_doc_id+"</sampleIdentifier>\n</oai-identifier>";
     655    String sample_id = createOAIIdentifier(repository_id,sample_collection,sample_doc_id);
     656    String xml = "<oai-identifier xmlns=\"http://www.openarchives.org/OAI/2.0/oai-identifier\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://www.openarchives.org/OAI/2.0/oai-identifier\n http://www.openarchives.org/OAI/2.0/oai-identifier.xsd\">\n <scheme>oai</scheme>\n<repositoryIdentifier>" + repository_id + "</repositoryIdentifier>\n<delimiter>:</delimiter>\n<sampleIdentifier>"+sample_id+"</sampleIdentifier>\n</oai-identifier>";
    652657
    653658    Document xml_doc = converter.getDOM(xml);
Note: See TracChangeset for help on using the changeset viewer.