- Timestamp:
- 2008-05-01T13:59:09+12:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
greenstone3/trunk/src/java/org/greenstone/gsdl3/service/OAIPMH.java
r14209 r15326 27 27 import org.greenstone.gsdl3.util.XMLConverter; 28 28 29 import org.greenstone.gsdl3.util. GDBMWrapper;29 import org.greenstone.gsdl3.util.SimpleCollectionDatabase; 30 30 import org.greenstone.gsdl3.util.DBInfo; 31 31 // XML classes … … 45 45 import java.util.Map.Entry; 46 46 47 import org.apache.log4j. *;47 import org.apache.log4j.Logger; 48 48 49 49 /** Implements the oai metadata retrieval service for GS3 collections. 50 * Dig into each collection's gdbmdatabase and retrieve the metadata50 * Dig into each collection's database and retrieve the metadata 51 51 * 52 52 * @author <a href="mailto:[email protected]">Xiao</a> … … 57 57 static Logger logger = Logger.getLogger(org.greenstone.gsdl3.service.OAIPMH.class.getName()); 58 58 59 protected GDBMWrapper gdbm_src= null;59 protected SimpleCollectionDatabase coll_db = null; 60 60 61 61 protected String site_name = ""; … … 65 65 /** constructor */ 66 66 public OAIPMH() { 67 this.gdbm_src = new GDBMWrapper(); 67 68 68 } 69 69 70 70 public void cleanUp() { 71 71 super.cleanUp();//?? 72 this. gdbm_src.closeDatabase();72 this.coll_db.closeDatabase(); 73 73 } 74 74 /** configure this service */ … … 89 89 this.config_info = info; 90 90 91 92 93 94 95 96 97 98 99 91 // the index stem is either specified in the buildConfig.xml file or uses the collection name 92 Element index_stem_elem = (Element) GSXML.getChildByTagName(info, GSXML.INDEX_STEM_ELEM); 93 String index_stem = null; 94 if (index_stem_elem != null) { 95 index_stem = index_stem_elem.getAttribute(GSXML.NAME_ATT); 96 } 97 if (index_stem == null || index_stem.equals("")) { 98 index_stem = this.cluster_name; 99 } 100 100 101 // Open GDBM database for querying 102 String gdbm_db_file = GSFile.GDBMDatabaseFile(this.site_home, this.cluster_name, index_stem); 103 if (!this.gdbm_src.openDatabase(gdbm_db_file, GDBMWrapper.READER)) { 104 logger.error("Could not open GDBM database!"); 101 // find out what kind of database we have 102 Element database_type_elem = (Element) GSXML.getChildByTagName(info, GSXML.DATABASE_TYPE_ELEM); 103 String database_type = null; 104 if (database_type_elem != null) { 105 database_type = database_type_elem.getAttribute(GSXML.NAME_ATT); 106 } 107 if (database_type == null || database_type.equals("")) { 108 database_type = "gdbm"; // the default 109 } 110 coll_db = new SimpleCollectionDatabase(database_type); 111 if (coll_db == null) { 112 logger.error("Couldn't create the collection database of type "+database_type); 105 113 return false; 106 114 } 107 115 116 // Open database for querying 117 String coll_db_file = GSFile.collectionDatabaseFile(this.site_home, this.cluster_name, index_stem, database_type); 118 if (!this.coll_db.openDatabase(coll_db_file, SimpleCollectionDatabase.READ)) { 119 logger.error("Could not open collection database!"); 120 return false; 121 } 122 108 123 // the short_service_info is used by the message router to find the method names, 109 124 //so we just use the doc variable in class ServiceRack to create the xml; but … … 214 229 //get a DBInfo object of the identifier; if this identifier is not present in the database, 215 230 // null is returned. 216 DBInfo info = this. gdbm_src.getInfo(oid);231 DBInfo info = this.coll_db.getInfo(oid); 217 232 if (info == null) { 218 233 logger.error("OID: " + oid + " is not present in the database."); … … 294 309 for(int i=0; i<oid_list.size(); i++) { 295 310 String oid = (String)oid_list.get(i); 296 DBInfo info = this. gdbm_src.getInfo(oid);311 DBInfo info = this.coll_db.getInfo(oid); 297 312 if (info == null) { 298 313 logger.error("Database does not contains information about oid: " +oid); … … 386 401 for(int i=0; i<oid_list.size(); i++) { 387 402 String oid = (String)oid_list.get(i); 388 DBInfo info = this. gdbm_src.getInfo(oid);403 DBInfo info = this.coll_db.getInfo(oid); 389 404 if (info == null) { 390 405 logger.error("Database does not contains information about oid: " +oid); … … 506 521 507 522 DBInfo info = null; 508 info = this. gdbm_src.getInfo(oid);523 info = this.coll_db.getInfo(oid); 509 524 if (info == null) { //just double check 510 525 return OAIXML.getResponse(OAIXML.createErrorElement(OAIXML.OAI_SERVICE_UNAVAILABLE, "")); … … 577 592 /** returns a list of the child ids in order, null if no children */ 578 593 protected ArrayList getChildrenIds(String node_id) { 579 DBInfo info = this. gdbm_src.getInfo(node_id);594 DBInfo info = this.coll_db.getInfo(node_id); 580 595 if (info == null) { 581 596 return null; … … 614 629 } 615 630 /** @param keys - contains a list of keys in string format. 616 * Here is a typical record in the gdbmdatabase, 'keys' contains the values in <...>:631 * Here is a typical record in the collection database, 'keys' contains the values in <...>: 617 632 *---------------------------------------------------------------------- 618 633 [HASH01a84acb0f1aad2380493b3a]
Note:
See TracChangeset
for help on using the changeset viewer.