- 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/GS2Browse.java
r13962 r15326 25 25 import org.greenstone.gsdl3.util.MacroResolver; 26 26 import org.greenstone.gsdl3.util.GS2MacroResolver; 27 import org.greenstone.gsdl3.util. GDBMWrapper;27 import org.greenstone.gsdl3.util.SimpleCollectionDatabase; 28 28 import org.greenstone.gsdl3.util.DBInfo; 29 29 // XML classes … … 52 52 static Logger logger = Logger.getLogger(org.greenstone.gsdl3.service.GS2Browse.class.getName()); 53 53 54 protected GDBMWrapper gdbm_src= null;54 protected SimpleCollectionDatabase coll_db = null; 55 55 56 56 public GS2Browse() 57 57 { 58 this.gdbm_src = new GDBMWrapper();59 this.macro_resolver = new GS2MacroResolver(this.gdbm_src);60 58 } 61 59 62 60 public void cleanUp() { 63 61 super.cleanUp(); 64 this. gdbm_src.closeDatabase();62 this.coll_db.closeDatabase(); 65 63 } 66 64 … … 82 80 } 83 81 84 // Open GDBM database for querying 85 String gdbm_db_file = GSFile.GDBMDatabaseFile(this.site_home, this.cluster_name, index_stem); 86 if (!this.gdbm_src.openDatabase(gdbm_db_file, GDBMWrapper.READER)) { 87 logger.error("Could not open GDBM database!"); 82 // find out what kind of database we have 83 Element database_type_elem = (Element) GSXML.getChildByTagName(info, GSXML.DATABASE_TYPE_ELEM); 84 String database_type = null; 85 if (database_type_elem != null) { 86 database_type = database_type_elem.getAttribute(GSXML.NAME_ATT); 87 } 88 if (database_type == null || database_type.equals("")) { 89 database_type = "gdbm"; // the default 90 } 91 coll_db = new SimpleCollectionDatabase(database_type); 92 if (coll_db == null) { 93 logger.error("Couldn't create the collection database of type "+database_type); 94 return false; 95 } 96 97 // Open database for querying 98 String coll_db_file = GSFile.collectionDatabaseFile(this.site_home, this.cluster_name, index_stem, database_type); 99 if (!this.coll_db.openDatabase(coll_db_file, SimpleCollectionDatabase.READ)) { 100 logger.error("Could not open collection database!"); 88 101 return false; 89 102 } 103 this.macro_resolver = new GS2MacroResolver(this.coll_db); 90 104 return true; 91 105 } … … 93 107 /** if id ends in .fc, .pc etc, then translate it to the correct id */ 94 108 protected String translateId(String node_id) { 95 return this. gdbm_src.translateOID(node_id);109 return this.coll_db.translateOID(node_id); 96 110 } 97 111 … … 103 117 */ 104 118 protected String getDocType(String node_id) { 105 DBInfo info = this. gdbm_src.getInfo(node_id);119 DBInfo info = this.coll_db.getInfo(node_id); 106 120 if (info == null) { 107 121 return GSXML.DOC_TYPE_SIMPLE; … … 124 138 // now we just check the top node 125 139 if (!is_top) { // we need to look at the top info 126 info = this. gdbm_src.getInfo(top_id);140 info = this.coll_db.getInfo(top_id); 127 141 } 128 142 if (info == null) { … … 144 158 /** returns a list of the child ids in order, null if no children */ 145 159 protected ArrayList getChildrenIds(String node_id) { 146 DBInfo info = this. gdbm_src.getInfo(node_id);160 DBInfo info = this.coll_db.getInfo(node_id); 147 161 if (info == null) { 148 162 return null; … … 170 184 171 185 protected String getMetadata(String node_id, String key){ 172 DBInfo info = this. gdbm_src.getInfo(node_id);186 DBInfo info = this.coll_db.getInfo(node_id); 173 187 if (info == null) { 174 188 return ""; … … 200 214 String lang = "en"; 201 215 Element metadata_list = this.doc.createElement(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER); 202 DBInfo info = this. gdbm_src.getInfo(node_id);216 DBInfo info = this.coll_db.getInfo(node_id); 203 217 if (info == null) { 204 218 return null; … … 251 265 } 252 266 253 DBInfo info = this. gdbm_src.getInfo(parent_id);267 DBInfo info = this.coll_db.getInfo(parent_id); 254 268 if (info==null) { 255 269 return "-1"; … … 275 289 276 290 protected int getNumChildren(String node_id) { 277 DBInfo info = this. gdbm_src.getInfo(node_id);291 DBInfo info = this.coll_db.getInfo(node_id); 278 292 if (info == null) { 279 293 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.