Changeset 32828 for main/trunk
- Timestamp:
- 2019-02-28T18:40:10+13:00 (5 years ago)
- Location:
- main/trunk/greenstone3/src/java/org/greenstone/gsdl3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/collection/OAICollection.java
r31916 r32828 114 114 } 115 115 116 // NOTE: 117 // Calling cleanUp() on OAIPMH object oai_service_rack will close any open dbs handles on module deactivation by MESSAGEROUTER (no deactivate yet called by OAIMESSAGEROUTER) 118 // But the OAIPMH object's cleanUp() is already called by superclass ServiceCluster, which goes around calling cleanUp() on all services/ServiceRacks. 116 119 117 120 /** … … 154 157 message.appendChild(request); 155 158 156 this.oai_service_rack = new OAIPMH(); 159 if(this.oai_service_rack == null) { 160 this.oai_service_rack = new OAIPMH(); 161 } 157 162 this.oai_service_rack.setSiteHome(this.site_home); 158 163 this.oai_service_rack.setSiteAddress(this.site_http_address); -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/OAIPMH.java
r32213 r32828 71 71 protected HashMap<String, Element> format_meta_elem_map = null; 72 72 73 protected String index_stem = ""; 74 protected String infodb_type = ""; 75 73 76 /** constructor */ 74 77 public OAIPMH() { … … 78 81 public void cleanUp() { 79 82 super.cleanUp();//?? 80 83 this.coll_db.closeDatabase(); 81 84 if (this.oaiinf_db != null){ 82 85 this.oaiinf_db.closeDatabase(); 83 86 } 84 85 }87 } 88 86 89 /** configure this service 87 90 info is the OAIPMH service rack from collectionConfig.xml, and … … 103 106 // the index stem is either specified in the buildConfig.xml file (extra_info) or uses the collection name 104 107 Element metadata_list = (Element) GSXML.getChildByTagName(extra_info, GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER); 105 String index_stem = ""; 106 String infodb_type = ""; 108 107 109 if (metadata_list != null) { 108 110 … … 110 112 111 113 if (index_stem_elem != null) { 112 index_stem = GSXML.getNodeText(index_stem_elem);114 this.index_stem = GSXML.getNodeText(index_stem_elem); 113 115 } 114 116 115 117 Element infodb_type_elem = (Element) GSXML.getNamedElement(metadata_list, GSXML.METADATA_ELEM, GSXML.NAME_ATT, "infodbType"); 116 118 if (infodb_type_elem != null) { 117 infodb_type = GSXML.getNodeText(infodb_type_elem);119 this.infodb_type = GSXML.getNodeText(infodb_type_elem); 118 120 } 119 121 … … 121 123 122 124 if (index_stem == null || index_stem.equals("")) { 123 index_stem = this.cluster_name; // index_stem is the name of the db in indext/text, it is <colname>.<db>125 this.index_stem = this.cluster_name; // index_stem is the name of the db in indext/text, it is <colname>.<db> 124 126 } 125 127 if (infodb_type == null || infodb_type.equals("")) { 126 infodb_type = "gdbm"; // the default 127 } 128 129 coll_db = new SimpleCollectionDatabase(infodb_type); 130 if (!coll_db.databaseOK()) { 131 logger.error("Couldn't create the collection database of type "+infodb_type); 132 return false; 133 } 134 135 oaiinf_db = new SimpleCollectionDatabase(infodb_type); 136 if (!oaiinf_db.databaseOK()) { 137 logger.error("Couldn't create the oai-inf database of type "+infodb_type); 138 return false; 139 } 140 141 142 // Open databases for querying 143 String coll_db_file = GSFile.collectionDatabaseFile(this.site_home, this.cluster_name, index_stem, infodb_type); 144 if (!this.coll_db.openDatabase(coll_db_file, SimpleCollectionDatabase.READ)) { 145 logger.error("Could not open collection database!"); 146 return false; 147 } 148 // the oaiinf_db is called oai-inf.<infodb_type_extension> 149 String oaiinf_db_file = GSFile.OAIInfoDatabaseFile(this.site_home, this.cluster_name, "oai-inf", infodb_type); 150 File oaiinfFile = new File(oaiinf_db_file); 151 152 if(!oaiinfFile.exists()) { 153 logger.warn("oai-inf database for collection + " + this.cluster_name + " does not exist."); 154 oaiinf_db = null; 155 } else if (!this.oaiinf_db.openDatabase(oaiinf_db_file, SimpleCollectionDatabase.READ)) { 156 logger.warn("Could not open oai-inf database for collection + " + this.cluster_name + "!"); 157 oaiinf_db = null; 158 } 128 this.infodb_type = "gdbm"; // the default 129 } 130 131 // DB OPENING STUFF MOVED TO configureOAI(), because OAIPMH.configure() is called by the regular MessageRouter when this activates collections for the regular "library" servlet 132 // whereas OAIPMH.configureOAI() is only called by OAIMessageRouter when it activates collections for the "oaiserver" servlet (after OAIMessageRouter calls regular configure() first) 133 // We don't want the DBs opened twice: once by MessageRouter's call to OAIPMH.configure() and once by OAIMessageRouter calling OAIPMH.configure(). 159 134 160 135 // work out what sets this collection has. Will usually contain the collection itself, optional super collection, and maybe subcolls if appropriate classifiers are present. … … 235 210 format_meta_elem_map.put(prefix, OAIXML.getMetadataPrefixElement(this.desc_doc, prefix, collection_version_format)); 236 211 237 } 212 } // end for 213 214 // Open the coll db and oai-inf db databases and store handles to them 215 coll_db = new SimpleCollectionDatabase(infodb_type); 216 if (!coll_db.databaseOK()) { 217 logger.error("Couldn't create the collection database of type "+infodb_type); 218 return false; 219 } 220 221 oaiinf_db = new SimpleCollectionDatabase(infodb_type); 222 if (!oaiinf_db.databaseOK()) { 223 logger.error("Couldn't create the oai-inf database of type "+infodb_type); 224 return false; 225 } 226 227 228 // Open databases for querying 229 String coll_db_file = GSFile.collectionDatabaseFile(this.site_home, this.cluster_name, index_stem, infodb_type); 230 if (!this.coll_db.openDatabase(coll_db_file, SimpleCollectionDatabase.READ)) { 231 logger.error("Could not open collection database!"); 232 return false; 233 } 234 // the oaiinf_db is called oai-inf.<infodb_type_extension> 235 String oaiinf_db_file = GSFile.OAIInfoDatabaseFile(this.site_home, this.cluster_name, "oai-inf", infodb_type); 236 File oaiinfFile = new File(oaiinf_db_file); 237 238 if(!oaiinfFile.exists()) { 239 logger.warn("oai-inf database for collection + " + this.cluster_name + " does not exist."); 240 oaiinf_db = null; 241 } else if (!this.oaiinf_db.openDatabase(oaiinf_db_file, SimpleCollectionDatabase.READ)) { 242 logger.warn("Could not open oai-inf database for collection + " + this.cluster_name + "!"); 243 oaiinf_db = null; 244 } 245 238 246 return true; 239 247 }
Note:
See TracChangeset
for help on using the changeset viewer.