Changeset 32842 for gs3-extensions
- Timestamp:
- 2019-03-03T22:50:56+13:00 (5 years ago)
- Location:
- gs3-extensions/iiif-servlet/trunk/src
- Files:
-
- 4 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-extensions/iiif-servlet/trunk/src/PREPARE.sh
r32707 r32842 26 26 /bin/cp ../../web/WEB-INF/classes/OAIConfig.xml packages/cantaloupe-4.0.2/src/main/resources/. 27 27 28 echo "Copying Greenstone's IIIFConfig.xml into Cantaloupe's resources folder" 29 /bin/cp ../../web/WEB-INF/classes/IIIFConfig.xml packages/cantaloupe-4.0.2/src/main/resources/. 30 28 31 29 32 echo -
gs3-extensions/iiif-servlet/trunk/src/gsdl-src/java/org/greenstone/gsdl3/IIIFServerBridge.java
r32720 r32842 39 39 import org.greenstone.gsdl3.util.GSParams; 40 40 import org.greenstone.gsdl3.util.GSXML; 41 import org.greenstone.gsdl3.util. OAIXML;41 import org.greenstone.gsdl3.util.IIIFXML; 42 42 import org.greenstone.gsdl3.util.XMLConverter; 43 43 import org.w3c.dom.Document; … … 53 53 */ 54 54 /** 55 * OAIserver configuration instructions *55 * IIIF server configuration instructions * 56 56 * 57 57 */ … … 71 71 private void configure() throws UnavailableException 72 72 { 73 // Read in OAIConfig.xml (residing web/WEB-INF/classes/) and73 // Read in IIIFConfig.xml (residing web/WEB-INF/classes/) and 74 74 //use it to configure the receptionist. 75 Element oai_config = OAIXML.getOAIConfigXML();76 if ( oai_config == null)77 { 78 logger.error("Fail to parse oai config file OAIConfig.xml.");79 throw new UnavailableException("IIIFServerBridge: Couldn't parse OAIConfig.xml");75 Element iiif_config = IIIFXML.getIIIFConfigXML(); 76 if (iiif_config == null) 77 { 78 logger.error("Fail to parse IIIF config file IIIFConfig.xml."); 79 throw new UnavailableException("IIIFServerBridge: Couldn't parse IIIFConfig.xml"); 80 80 } 81 81 // pass it to the receptionist 82 if (!this.recept.configure( oai_config)) {83 logger.error("Couldn't configure receptionist");82 if (!this.recept.configure(iiif_config)) { 83 logger.error("Couldn't configure IIIF receptionist"); 84 84 throw new UnavailableException("IIIFServerBridge: Couldn't configure receptionist"); 85 85 } … … 147 147 { 148 148 logger.error("IIIFServerBridge.init Error: invalid Communicator type: " + remote_site_type); 149 throw new UnavailableException(" OAIServer: invalid communicator type");149 throw new UnavailableException("IIIFServerBridge: invalid communicator type"); 150 150 } 151 151 … … 153 153 { 154 154 logger.error("IIIFServerBridge.init Error: Couldn't configure communicator"); 155 throw new UnavailableException(" OAIServer: Couldn't configure communicator");155 throw new UnavailableException("IIIFServerBridge: Couldn't configure communicator"); 156 156 } 157 157 this.recept.setSiteName(remote_site_name); … … 175 175 String verb = "GetRecord"; 176 176 Document response_doc = XMLConverter.newDOM(); 177 Element xml_response = OAIXML.createBasicResponse(response_doc, verb, pairs);177 Element xml_response = IIIFXML.createBasicResponse(response_doc, verb, pairs); 178 178 Element verb_elem = null; 179 179 … … 195 195 { 196 196 logger.info("xml_result is null"); 197 verb_elem = OAIXML.createErrorElement(response_doc, "Internal error", "");197 verb_elem = IIIFXML.createErrorElement(response_doc, "Internal error", ""); 198 198 xml_response.appendChild(verb_elem); 199 199 } … … 210 210 { 211 211 logger.info("response element in xml_result is null"); 212 verb_elem = OAIXML.createErrorElement(response_doc, "Internal error", "");212 verb_elem = IIIFXML.createErrorElement(response_doc, "Internal error", ""); 213 213 } 214 214 else … … 217 217 } 218 218 219 if ( verb_elem.getTagName().equals(OAIXML.ERROR)) 219 // ****** 220 xml_response.appendChild(response_doc.importNode(verb_elem, true)); 221 /* 222 if ( verb_elem.getTagName().equals(IIIFXML.ERROR)) 220 223 { 221 224 xml_response.appendChild(response_doc.importNode(verb_elem, true)); 222 225 } 223 else if ( OAIXML.oai_version.equals(OAIXML.OAI_VERSION2)) {226 else if (IIIFXML.iiif_version.equals(IIIFXML.IIIF_VERSION2)) { 224 227 xml_response.appendChild(response_doc.importNode(verb_elem, true)); 225 228 } … … 227 230 { 228 231 GSXML.copyAllChildren(xml_response, verb_elem); 229 }232 }*/ 230 233 } 231 234 /* … … 259 262 if (index != -1) 260 263 { //just a double check 261 Element param = GSXML.createParameter(doc, pairs[i].substring(0, index), OAIXML.oaiDecode(pairs[i].substring(index + 1)));264 Element param = GSXML.createParameter(doc, pairs[i].substring(0, index), IIIFXML.oaiDecode(pairs[i].substring(index + 1))); 262 265 request.appendChild(param); 263 266 } -
gs3-extensions/iiif-servlet/trunk/src/gsdl-src/java/org/greenstone/gsdl3/core/IIIFMessageRouter.java
r32707 r32842 28 28 import org.apache.commons.lang3.StringUtils; 29 29 import org.apache.log4j.Logger; 30 import org.greenstone.gsdl3.collection. OAICollection;30 import org.greenstone.gsdl3.collection.IIIFCollection; 31 31 import org.greenstone.gsdl3.collection.ServiceCluster; 32 32 import org.greenstone.gsdl3.comms.Communicator; … … 36 36 import org.greenstone.gsdl3.util.GSPath; 37 37 import org.greenstone.gsdl3.util.GSXML; 38 import org.greenstone.gsdl3.util. OAIXML;38 import org.greenstone.gsdl3.util.IIIFXML; 39 39 import org.greenstone.gsdl3.util.UserContext; 40 40 import org.greenstone.gsdl3.util.XMLConverter; … … 48 48 * The hub of a Greenstone IIIF image server/bridge. 49 49 * 50 * A simplified version of MessageRouter for OAIServer. Only loads up collections that have OAIservices.50 * A simplified version of MessageRouter for IIIFServerBridge. Only loads up collections that have IIIF services. 51 51 */ 52 52 public class IIIFMessageRouter extends MessageRouter … … 55 55 static Logger logger = Logger.getLogger(org.greenstone.gsdl3.core.IIIFMessageRouter.class.getName()); 56 56 57 public Element oai_config = null;57 public Element iiif_config = null; 58 58 //*************************************************************** 59 59 // public methods … … 74 74 cleanUpModuleMapEntire(); 75 75 76 // for oai, we don't do anything with the site config file. But we'll read it in and keep it in case need it later, eg for replace elements when retrieving metadata - which I don't think has been implemented 76 // **** 77 // for oai, we don't do anything with the site config 78 // file. But we'll read it in and keep it in case need 79 // it later, e.g. for replace elements when retrieving 80 // metadata - which I don't think has been implemented 77 81 File configFile = new File(GSFile.siteConfigFile(this.site_home)); 78 82 … … 92 96 this.config_info = config_doc.getDocumentElement(); 93 97 94 // this is the receptionists OAIConfig.xml. Need to rethink how the MR gets this this if we ever talk to remote site, and whether it should be using it anyway 95 this.oai_config = OAIXML.getOAIConfigXML(); 96 if (this.oai_config == null) 98 // this is the receptionist's IFFFConfig.xml. 99 // Need to rethink how the MR gets this this if we 100 // ever talk to remote site, and whether it should be 101 // using it anyway 102 this.iiif_config = IIIFXML.getIIIFConfigXML(); 103 if (this.iiif_config == null) 97 104 { 98 logger.error("Couldn't load in OAIConfig.xml");105 logger.error("Couldn't load in IIIFConfig.xml"); 99 106 return false; 100 107 } … … 122 129 logger.info("Activating collection: " + col_name + "."); 123 130 Document doc = this.collection_list.getOwnerDocument(); 124 // use our special OAICollection - this will only load in oaiservices125 OAICollection c = new OAICollection();131 // use our special IIIFCollection - this will only load in IIIF services 132 IIIFCollection c = new IIIFCollection(); 126 133 127 134 c.setCollectionName(col_name); … … 135 142 136 143 logger.info("have just configured collection " + col_name); 137 if (!c.has OAI()) {138 logger.info ("collection "+col_name+" has no OAIservices. Not keeping it loaded");144 if (!c.hasIIIF()) { 145 logger.info ("collection "+col_name+" has no IIIF services. Not keeping it loaded"); 139 146 return false; 140 147 } 141 if (!c.configure OAI(this.oai_config)) {142 logger.info("couldn't configure the collection : "+col_name +" with the oaiconfig info");148 if (!c.configureIIIF(this.iiif_config)) { 149 logger.info("couldn't configure the collection : "+col_name +" with the iiif config info"); 143 150 return false; 144 151 } … … 147 154 Element e = doc.createElement(GSXML.COLLECTION_ELEM); 148 155 e.setAttribute(GSXML.NAME_ATT, col_name); 156 /* 149 157 e.setAttribute(OAIXML.LASTMODIFIED, "" + c.getLastmodified()); 150 158 e.setAttribute(OAIXML.EARLIEST_DATESTAMP, "" + c.getEarliestDatestamp()); 151 159 e.setAttribute(OAIXML.EARLIEST_OAI_DATESTAMP, "" + c.getEarliestOAIDatestamp()); 160 */ 152 161 this.collection_list.appendChild(e); 153 162 return true; … … 168 177 * @return the result Element - should be <response> 169 178 */ 179 /* 170 180 protected Element processMessage(Element req) { 171 181 Document doc = XMLConverter.newDOM(); … … 185 195 } 186 196 187 197 */ 188 198 } -
gs3-extensions/iiif-servlet/trunk/src/gsdl-src/java/org/greenstone/gsdl3/core/IIIFReceptionist.java
r32707 r32842 46 46 protected String site_name = null; 47 47 /** The unique repository identifier */ 48 /* 48 49 protected String repository_id = null; 49 50 */ 51 50 52 /** the configure file of this receptionist passed from the iiif restlet. */ 51 protected Element oai_config = null;53 protected Element iiif_config = null; 52 54 53 55 /** the message router that the Receptionist and Actions will talk to */ … … 96 98 } 97 99 /** sets the message router - it should already be created and 98 * configured in the init() of a servlet/restlet ( OAIServer, for example) before being passed to the receptionist*/100 * configured in the init() of a servlet/restlet (IIIFServerBridge, for example) before being passed to the receptionist*/ 99 101 public void setMessageRouter(ModuleInterface mr) { 100 102 this.mr = mr; … … 112 114 return false; 113 115 } 114 oai_config = config; 115 116 iiif_config = config; 117 118 /* 116 119 repository_id = getRepositoryIdentifier(); 117 120 */ 121 122 /* 118 123 if (!configureSetInfo()) { 119 124 // there are no sets … … 121 126 return false; 122 127 } 123 128 */ 129 124 130 return true; 125 131 } 126 132 133 /* 127 134 private boolean configureSetInfo() { 128 135 this.set_set = new HashSet<String>(); … … 235 242 return true; 236 243 } 237 244 */ 245 238 246 protected void resetMessageRouter() { 239 247 // we just need to send a configure request to MR … … 259 267 } 260 268 261 //Compose a message/response element used to send back to the OAIServerservlet.262 //This method is only used within OAIReceptionist269 //Compose a message/response element used to send back to the IIIFServerBridge servlet. 270 //This method is only used within IIIFReceptionist 263 271 private Element getMessage(Document doc, Element e) { 264 272 Element msg = doc.createElement(GSXML.MESSAGE_ELEM); … … 281 289 if (!message.getTagName().equals(GSXML.MESSAGE_ELEM)) { 282 290 logger.error(" Invalid message. GSDL message should start with <"+GSXML.MESSAGE_ELEM+">, instead it starts with:"+message.getTagName()+"."); 283 return OAIXML.createErrorMessage(OAIXML.BAD_ARGUMENT, "Internal messaging error");291 return IIIFXML.createErrorMessage(OAIXML.BAD_ARGUMENT, "Internal messaging error"); 284 292 } 285 293 … … 288 296 if (request == null) { 289 297 logger.error(" message had no request!"); 290 return OAIXML.createErrorMessage(OAIXML.BAD_ARGUMENT, "Internal messaging error");298 return IIIFXML.createErrorMessage(OAIXML.BAD_ARGUMENT, "Internal messaging error"); 291 299 } 292 300 … … 295 303 if (!reset.equals("")) { 296 304 resetMessageRouter(); 297 configureSetInfo();298 return OAIXML.createResetResponse(true);305 // configureSetInfo(); // **** 306 return IIIFXML.createResetResponse(true); 299 307 } 300 308 … … 303 311 //The only thing that the oai receptionist can be sure is that these verbs are valid, nothing else. 304 312 String verb = request.getAttribute(GSXML.TO_ATT); 313 /* 305 314 if (verb.equals(OAIXML.IDENTIFY)) { 306 315 return doIdentify(); 307 } 316 }*/ 317 308 318 if (verb.equals(OAIXML.GET_RECORD)) { 309 319 return doGetRecord(request); 310 320 } 311 321 312 // should never get here as verbs were checked in OAIServer 313 return OAIXML.createErrorMessage(OAIXML.BAD_VERB, "Unexpected things happened"); 314 315 } 316 322 // should never get here as verbs were checked in IIIFServerBridge 323 return IIIFXML.createErrorMessage(OAIXML.BAD_VERB, "Unexpected things happened"); 324 325 } 326 327 /* 317 328 private String getRepositoryIdentifier() { 318 Element ri = (Element)GSXML.getChildByTagName( oai_config, OAIXML.REPOSITORY_IDENTIFIER);329 Element ri = (Element)GSXML.getChildByTagName(iiif_config, OAIXML.REPOSITORY_IDENTIFIER); 319 330 if (ri != null) { 320 331 return GSXML.getNodeText(ri); … … 322 333 return ""; 323 334 } 324 335 */ 325 336 326 337 private void copyNamedElementfromConfig(Element to_elem, String element_name) { 327 Element original_element = (Element)GSXML.getChildByTagName( oai_config, element_name);338 Element original_element = (Element)GSXML.getChildByTagName(iiif_config, element_name); 328 339 if(original_element != null) { 329 340 GSXML.copyNode(to_elem, original_element); … … 331 342 } 332 343 344 /* 333 345 private Element doIdentify() { 334 346 //The validation for this verb has been done in OAIServer.validate(). So no bother here. … … 348 360 349 361 //There can be more than one admin email according to the OAI specification 350 NodeList admin_emails = GSXML.getChildrenByTagName( oai_config, OAIXML.ADMIN_EMAIL);362 NodeList admin_emails = GSXML.getChildrenByTagName(iiif_config, OAIXML.ADMIN_EMAIL); 351 363 int num_admin = 0; 352 364 Element from_admin_email = null; … … 358 370 } 359 371 360 / * IIIF does not have the equivalent of oai earliestDatestamp */372 // IIIF does not have the equivalent of oai earliestDatestamp 361 373 362 374 // output the oai identifier … … 368 380 369 381 // if there are any oaiInfo metadata, add them in too. 370 Element info = (Element)GSXML.getChildByTagName( oai_config, OAIXML.OAI_INFO);382 Element info = (Element)GSXML.getChildByTagName(iiif_config, OAIXML.OAI_INFO); 371 383 if (info != null) { 372 384 NodeList meta = GSXML.getChildrenByTagName(info, OAIXML.METADATA); … … 383 395 return getMessage(doc, identify); 384 396 } 385 397 */ 398 386 399 private Element doGetRecord(Element req){ 387 400 logger.info(""); … … 392 405 */ 393 406 Document doc = XMLConverter.newDOM(); 394 Element get_record = doc.createElement( OAIXML.GET_RECORD);407 Element get_record = doc.createElement(IIIFXML.GET_RECORD); 395 408 396 409 HashSet<String> valid_strs = new HashSet<String>();
Note:
See TracChangeset
for help on using the changeset viewer.