Changeset 35225
- Timestamp:
- 2021-07-06T14:32:20+12:00 (3 years ago)
- 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 945 945 946 946 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> 948 948 // so it must contain at least one ':' characters 949 949 // (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); 953 953 return OAIXML.createErrorMessage(OAIXML.ID_DOES_NOT_EXIST, ""); 954 954 } … … 956 956 // send request to message router 957 957 // 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]; 960 960 961 961 Document msg_doc = XMLConverter.newDOM(); … … 1098 1098 1099 1099 // 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); 1103 1103 return OAIXML.createErrorMessage(OAIXML.ID_DOES_NOT_EXIST, ""); 1104 1104 } 1105 1105 //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]; 1108 1108 1109 1109 //re-organize the request element -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/OAIPMH.java
r33972 r35225 59 59 protected SimpleCollectionDatabase coll_db = null; 60 60 protected SimpleCollectionDatabase oaiinf_db = null; 61 61 62 protected String repository_id = ""; 62 63 protected String site_name = ""; 63 64 protected String coll_name = ""; … … 174 175 this.format_elements_map = new HashMap<String, HashSet<String>>(); 175 176 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 } 176 185 177 186 // for now, all we want is the metadata prefix description and the mapping list … … 774 783 775 784 Element identifier = doc.createElement(OAIXML.IDENTIFIER); 776 GSXML.setNodeText(identifier, coll_name + ":" + oid);785 GSXML.setNodeText(identifier, OAIXML.createOAIIdentifier(repository_id,coll_name,oid)); 777 786 header.appendChild(identifier); 778 787 Element set_spec = doc.createElement(OAIXML.SET_SPEC); -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/OAIXML.java
r33970 r35225 647 647 return map; 648 648 } 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 650 654 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>"; 652 657 653 658 Document xml_doc = converter.getDOM(xml);
Note:
See TracChangeset
for help on using the changeset viewer.