Changeset 32874 for gs3-extensions/iiif-servlet/trunk/src/gsdl-src/java/org/greenstone/gsdl3/util/IIIFXML.java
- Timestamp:
- 2019-03-07T22:47:07+13:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-extensions/iiif-servlet/trunk/src/gsdl-src/java/org/greenstone/gsdl3/util/IIIFXML.java
r32860 r32874 37 37 static Logger logger = Logger.getLogger(org.greenstone.gsdl3.util.IIIFXML.class.getName()); 38 38 39 // the leading keyword of oai protocol39 // the leading keyword of IIIF protocol // **** 40 40 public static final String VERB = "verb"; 41 41 … … 67 67 68 68 // record response data 69 // SET_SPEC70 69 public static final String RECORD = "record"; 71 72 public static final String OAIPMH = "OAIPMH"; // **** 70 public static final String HEADER = "header"; 71 public static final String METADATA = "metadata"; 72 73 //public static final String OAIPMH = "OAIPMH"; // **** 73 74 74 75 //public static final String OAI_SET_LIST = "oaiSetList"; // **** … … 80 81 //public static final String FILE_SEPARATOR = File.separator; 81 82 //public static final String OAI_VERSION1 = "1.0"; 82 public static final String IIIF_VERSION2 = "2.1"; // ****83 //public static final String IIIF_VERSION2 = "2.1"; // **** 83 84 /*************************above are final values****************************/ 84 85 … … 143 144 144 145 145 /** TODO: returns a basic response for appropriate oai version146 /** TODO: returns a basic response (loosely based on OAI XML message) 146 147 * 147 148 */ … … 161 162 String[] strs = pairs[i].split("="); 162 163 if(strs != null && strs.length == 2) { 163 request_elem.setAttribute(strs[0], oaiDecode(strs[1]));164 request_elem.setAttribute(strs[0], iiifDecode(strs[1])); 164 165 } 165 166 } … … 168 169 GSXML.setNodeText(request_elem, baseURL); 169 170 170 Node resp_date = GSXML.getChildByTagName(response, RESPONSE_DATE); // ****171 //Node resp_date = GSXML.getChildByTagName(response, RESPONSE_DATE); // **** 171 172 172 173 return response; … … 265 266 * original form (eg, ':'). 266 267 */ 267 public static String oaiDecode(String escaped_str) {268 logger.info(" oaiDecode() " +escaped_str);268 public static String iiifDecode(String escaped_str) { 269 logger.info("iiifDecode() " +escaped_str); 269 270 for (int i=0; i<special_char.length; i++) { 270 271 if (escaped_str.indexOf(escape_sequence[i]) != -1) { … … 277 278 * escaped sequences (eg, '%3A'). 278 279 */ 279 public static String oaiEncode(String original_str) { // ****280 logger.info(" oaiEncode() " + original_str);280 public static String iiifEncode(String original_str) { // **** 281 logger.info("iiifEncode() " + original_str); 281 282 for (int i=0; i<special_char.length; i++) { 282 283 if (original_str.indexOf(special_char[i]) != -1) { … … 288 289 289 290 public static Element createResponseHeader(Document response_doc, String verb) { 290 String tag_name = (iiif_version.equals(IIIF_VERSION2))? IIIF_PMH : verb; // **** 291 Element oai = response_doc.createElement(tag_name); 292 Element resp_date = response_doc.createElement(RESPONSE_DATE); // **** 291 //String tag_name = (iiif_version.equals(IIIF_VERSION2))? IIIF_PMH : verb; // **** 292 String tag_name = IIIF_PMH; 293 Element iiif = response_doc.createElement(tag_name); 294 //Element resp_date = response_doc.createElement(RESPONSE_DATE); // **** 293 295 Element req = response_doc.createElement(REQUEST); 294 oai.appendChild(resp_date); 295 oai.appendChild(req); 296 297 if(iiif_version.equals(IIIF_VERSION2)) { // **** 298 oai.setAttribute("xmlns", "http://www.openarchives.org/OAI/2.0/"); 299 oai.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); 300 oai.setAttribute("xsi:schemaLocation", "http://www.openarchives.org/OAI/2.0/ \n http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd"); 301 } else { 302 oai.setAttribute("xmlns", "http://www.openarchives.com/OAI/1.1/OAI_" + verb); 303 oai.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); 304 oai.setAttribute("xsi:schemaLocation", "http://www.openarchives.org/OAI/1.1/OAI_" + verb + "\n http://www.openarchives.org/OAI/1.1/OAI_" + verb + ".xsd"); 305 } 306 return oai; 307 } 308 309 296 //oai.appendChild(resp_date); 297 iiif.appendChild(req); 298 299 return iiif; 300 } 301 302 /* 310 303 public static Element createOAIIdentifierXML(Document doc, String repository_id, String sample_collection, String sample_doc_id) { 311 304 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>"; … … 316 309 317 310 } 318 311 */ 312 313 /* 319 314 public static Element createGSDLElement(Document doc) { 320 315 String xml = "<gsdl xmlns=\"http://www.greenstone.org/namespace/gsdl_oaiinfo/1.0/gsdl_oaiinfo\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://www.greenstone.org/namespace/gsdl_oaiinfo/1.0/gsdl_oaiinfo\n http://www.greenstone.org/namespace/gsdl_oaiinfo/1.0/gsdl_oaiinfo.xsd\"></gsdl>"; … … 322 317 return (Element)doc.importNode(xml_doc.getDocumentElement(), true); 323 318 } 319 */ 320 324 321 } 325 322
Note:
See TracChangeset
for help on using the changeset viewer.