Changeset 15326
- Timestamp:
- 2008-05-01T13:59:09+12:00 (16 years ago)
- Location:
- greenstone3/trunk/src/java/org/greenstone/gsdl3/service
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
greenstone3/trunk/src/java/org/greenstone/gsdl3/service/AbstractBrowse.java
r14526 r15326 725 725 */ 726 726 abstract protected String getStructureInfo(String node_id, String info_type); 727 // /** needs to get info from gdbm database - if the calling code gets it already it may pay to pass it in instead */728 // protected String resolveTextMacros(String doc_content, String doc_id, String lang)729 // {730 // DBInfo info = null;731 // if (doc_content.indexOf("_httpdocimg_")!=-1) {732 // String top_doc_id = OID.getTop(doc_id);733 // info = this.gdbm_src.getInfo(top_doc_id);734 // if (info == null) {735 // // perhaps we had per.iods in the ids - just try the current id736 // top_doc_id = doc_id;737 // info = this.gdbm_src.getInfo(top_doc_id);738 // }739 // if (info != null) {740 // String archivedir = info.getInfo("archivedir");741 // String image_dir = this.site_http_address + "/collect/"+this.cluster_name+"/index/assoc/"+archivedir;742 743 // // Resolve all "_httpdocimg_"s744 // doc_content = doc_content.replaceAll("_httpdocimg_", image_dir);745 // }746 // }747 // // resolve any collection specific macros748 // doc_content = macro_resolver.resolve(doc_content, lang, GS2MacroResolver.SCOPE_TEXT, doc_id, info);749 // return doc_content;750 // }751 752 727 753 728 } -
greenstone3/trunk/src/java/org/greenstone/gsdl3/service/AbstractDocumentRetrieve.java
r14552 r15326 22 22 23 23 // Greenstone classes 24 //import org.greenstone.gdbm.*;25 24 import org.greenstone.gsdl3.core.GSException; 26 25 import org.greenstone.gsdl3.util.GSXML; -
greenstone3/trunk/src/java/org/greenstone/gsdl3/service/AbstractGS2DocumentRetrieve.java
r15208 r15326 27 27 import org.greenstone.gsdl3.util.GS2MacroResolver; 28 28 import org.greenstone.gsdl3.util.GSConstants; 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 … … 59 59 protected String index_stem = null; 60 60 61 protected GDBMWrapper gdbm_src= null;61 protected SimpleCollectionDatabase coll_db = null; 62 62 63 63 … … 65 65 protected AbstractGS2DocumentRetrieve() 66 66 { 67 this.gdbm_src = new GDBMWrapper();68 this.macro_resolver = new GS2MacroResolver(this.gdbm_src);69 67 } 70 68 71 69 public void cleanUp() { 72 73 this.gdbm_src.closeDatabase();70 super.cleanUp(); 71 this.coll_db.closeDatabase(); 74 72 } 75 73 /** configure this service */ … … 93 91 } 94 92 95 // Open GDBM database for querying 96 String gdbm_db_file = GSFile.GDBMDatabaseFile(this.site_home, this.cluster_name, this.index_stem); 97 if (!this.gdbm_src.openDatabase(gdbm_db_file, GDBMWrapper.READER)) { 98 logger.error("Could not open GDBM database!"); 93 // find out what kind of database we have 94 Element database_type_elem = (Element) GSXML.getChildByTagName(info, GSXML.DATABASE_TYPE_ELEM); 95 String database_type = null; 96 if (database_type_elem != null) { 97 database_type = database_type_elem.getAttribute(GSXML.NAME_ATT); 98 } 99 if (database_type == null || database_type.equals("")) { 100 database_type = "gdbm"; // the default 101 } 102 coll_db = new SimpleCollectionDatabase(database_type); 103 if (coll_db == null) { 104 logger.error("Couldn't create the collection database of type "+database_type); 105 return false; 106 } 107 108 // Open database for querying 109 String coll_db_file = GSFile.collectionDatabaseFile(this.site_home, this.cluster_name, this.index_stem, database_type); 110 if (!this.coll_db.openDatabase(coll_db_file, SimpleCollectionDatabase.READ)) { 111 logger.error("Could not open collection database!"); 99 112 return false; 100 113 } 114 this.macro_resolver = new GS2MacroResolver(this.coll_db); 101 115 102 116 return true; … … 105 119 /** if id ends in .fc, .pc etc, then translate it to the correct id */ 106 120 protected String translateId(String node_id) { 107 return this. gdbm_src.translateOID(node_id);121 return this.coll_db.translateOID(node_id); 108 122 } 109 123 … … 111 125 it to a greenstone one*/ 112 126 protected String translateExternalId(String node_id){ 113 return this. gdbm_src.externalId2OID(node_id);127 return this.coll_db.externalId2OID(node_id); 114 128 } 115 129 … … 120 134 /** returns a list of the child ids in order, null if no children */ 121 135 protected ArrayList getChildrenIds(String node_id) { 122 DBInfo info = this. gdbm_src.getInfo(node_id);136 DBInfo info = this.coll_db.getInfo(node_id); 123 137 if (info == null) { 124 138 return null; … … 156 170 throws GSException { 157 171 Element metadata_list = this.doc.createElement(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER); 158 DBInfo info = this. gdbm_src.getInfo(node_id);172 DBInfo info = this.coll_db.getInfo(node_id); 159 173 if (info == null) { 160 174 return null; … … 211 225 } 212 226 213 DBInfo info = this. gdbm_src.getInfo(parent_id);227 DBInfo info = this.coll_db.getInfo(parent_id); 214 228 if (info==null) { 215 229 return "-1"; … … 235 249 236 250 protected int getNumChildren(String node_id) { 237 DBInfo info = this. gdbm_src.getInfo(node_id);251 DBInfo info = this.coll_db.getInfo(node_id); 238 252 if (info == null) { 239 253 return 0; … … 254 268 */ 255 269 protected String getDocType(String node_id) { 256 DBInfo info = this. gdbm_src.getInfo(node_id);270 DBInfo info = this.coll_db.getInfo(node_id); 257 271 if (info == null) { 258 272 return GSXML.DOC_TYPE_SIMPLE; … … 275 289 // now we just check the top node 276 290 if (!is_top) { // we need to look at the top info 277 info = this. gdbm_src.getInfo(top_id);291 info = this.coll_db.getInfo(top_id); 278 292 } 279 293 if (info == null) { … … 370 384 relation_info = info; 371 385 } else { 372 relation_info = this. gdbm_src.getInfo(relation_id);386 relation_info = this.coll_db.getInfo(relation_id); 373 387 } 374 388 if (relation_info == null) { … … 405 419 relation_id = OID.getParent(current_id); 406 420 while (!relation_id.equals(current_id)) { 407 relation_info = this. gdbm_src.getInfo(relation_id);421 relation_info = this.coll_db.getInfo(relation_id); 408 422 if (relation_info == null) return result.toString(); 409 423 if (!multiple) { … … 427 441 428 442 429 /** needs to get info from gdbmdatabase - if the calling code gets it already it may pay to pass it in instead */443 /** needs to get info from collection database - if the calling code gets it already it may pay to pass it in instead */ 430 444 protected String resolveTextMacros(String doc_content, String doc_id, String lang) 431 445 { … … 452 466 value="-1"; 453 467 } else { 454 DBInfo info = this. gdbm_src.getInfo(parent_id);468 DBInfo info = this.coll_db.getInfo(parent_id); 455 469 if (info==null) { 456 470 value ="-1"; … … 478 492 479 493 protected String getHrefOID(String href_url){ 480 return this. gdbm_src.docnum2OID(href_url);494 return this.coll_db.docnum2OID(href_url); 481 495 } 482 496 -
greenstone3/trunk/src/java/org/greenstone/gsdl3/service/AbstractGS2FieldSearch.java
r15041 r15326 75 75 76 76 protected static final String DEFAULT_LEVEL_ELEM = "defaultLevel"; 77 protected static final String DEFAULT_ GDBM_LEVEL_ELEM = "defaultGDBMLevel";77 protected static final String DEFAULT_DB_LEVEL_ELEM = "defaultDBLevel"; 78 78 protected static final String LEVEL_ELEM = "level"; 79 79 protected static final String FIELD_ATT = "field"; … … 90 90 // the default level for searching 91 91 protected String default_level=null; 92 // default level for gdbmdb93 protected String default_ gdbm_level = null;92 // default level for collection db 93 protected String default_db_level = null; 94 94 // which search services will we offer?? 95 95 protected boolean plain_search = false; … … 162 162 } 163 163 164 // Get the default GDBMlevel165 def = (Element) GSXML.getChildByTagName(info, DEFAULT_ GDBM_LEVEL_ELEM);164 // Get the default DB level 165 def = (Element) GSXML.getChildByTagName(info, DEFAULT_DB_LEVEL_ELEM); 166 166 if (def != null) { 167 this.default_ gdbm_level = def.getAttribute(GSXML.SHORTNAME_ATT);168 } 169 if (this.default_ gdbm_level == null || this.default_gdbm_level.equals("")) {170 logger.error("default gdbm levelnot specified!, assuming Sec");171 this.default_ gdbm_level = "Sec";167 this.default_db_level = def.getAttribute(GSXML.SHORTNAME_ATT); 168 } 169 if (this.default_db_level == null || this.default_db_level.equals("")) { 170 logger.error("default database level (defaultDBLevel) not specified!, assuming Sec"); 171 this.default_db_level = "Sec"; 172 172 } 173 173 -
greenstone3/trunk/src/java/org/greenstone/gsdl3/service/AbstractGS2Search.java
r13999 r15326 20 20 21 21 // Greenstone classes 22 import org.greenstone.mg.*; 23 import org.greenstone.gsdl3.util.*; 22 import org.greenstone.gsdl3.util.OID; 23 import org.greenstone.gsdl3.util.DBInfo; 24 import org.greenstone.gsdl3.util.GSXML; 25 import org.greenstone.gsdl3.util.SimpleCollectionDatabase; 26 import org.greenstone.gsdl3.util.GSFile; 24 27 25 28 // XML classes … … 74 77 protected int maxnumeric = 4; 75 78 76 protected GDBMWrapper gdbm_src = null; 77 78 static Logger logger = Logger.getLogger(org.greenstone.gsdl3.service.GS2MGSearch.class.getName()); 79 // collection database 80 protected SimpleCollectionDatabase coll_db = null; 81 82 static Logger logger = Logger.getLogger(org.greenstone.gsdl3.service.AbstractGS2Search.class.getName()); 79 83 80 84 … … 82 86 public AbstractGS2Search() 83 87 { 84 this.gdbm_src = new GDBMWrapper();88 85 89 } 86 90 public void cleanUp() { 87 91 super.cleanUp(); 88 this. gdbm_src.closeDatabase();92 this.coll_db.closeDatabase(); 89 93 } 90 94 … … 93 97 { 94 98 if (!super.configure(info, extra_info)){ 99 return false; 100 } 101 102 // find out what kind of database we have 103 Element database_type_elem = (Element) GSXML.getChildByTagName(info, GSXML.DATABASE_TYPE_ELEM); 104 String database_type = null; 105 if (database_type_elem != null) { 106 database_type = database_type_elem.getAttribute(GSXML.NAME_ATT); 107 } 108 if (database_type == null || database_type.equals("")) { 109 database_type = "gdbm"; // the default 110 } 111 coll_db = new SimpleCollectionDatabase(database_type); 112 if (coll_db == null) { 113 logger.error("Couldn't create the collection database of type "+database_type); 114 return false; 115 } 116 117 // the index stem is either the collection name or is specified in the config file 118 Element index_stem_elem = (Element) GSXML.getChildByTagName(info, INDEX_STEM_ELEM); 119 if (index_stem_elem != null) { 120 this.index_stem = index_stem_elem.getAttribute(GSXML.NAME_ATT); 121 } 122 if (this.index_stem == null || this.index_stem.equals("")) { 123 logger.warn("indexStem element not found, stem will default to collection name"); 124 this.index_stem = this.cluster_name; 125 } 126 127 // Open database for querying 128 String coll_db_file = GSFile.collectionDatabaseFile(this.site_home, this.cluster_name, this.index_stem, database_type); 129 if (!this.coll_db.openDatabase(coll_db_file, SimpleCollectionDatabase.READ)) { 130 logger.error("Could not open collection database!"); 95 131 return false; 96 132 } … … 116 152 this.default_index_language = defLang.getAttribute(GSXML.SHORTNAME_ATT); 117 153 } //concate defaultIndex + defaultIndexSubcollection + defaultIndexLanguage 118 119 120 // the index stem is either the collection name or is specified in the config file 121 Element index_stem_elem = (Element) GSXML.getChildByTagName(info, INDEX_STEM_ELEM); 122 if (index_stem_elem != null) { 123 this.index_stem = index_stem_elem.getAttribute(GSXML.NAME_ATT); 124 } 125 if (this.index_stem == null || this.index_stem.equals("")) { 126 logger.warn("indexStem element not found, stem will default to collection name"); 127 this.index_stem = this.cluster_name; 128 } 129 154 130 155 // get index options 131 156 Element index_option_list = (Element) GSXML.getChildByTagName(info, GSXML.INDEX_OPTION_ELEM + GSXML.LIST_MODIFIER); … … 187 212 } // for each index 188 213 } 189 // Open GDBM database for querying190 String gdbm_db_file = GSFile.GDBMDatabaseFile(this.site_home, this.cluster_name, this.index_stem);191 if (!this.gdbm_src.openDatabase(gdbm_db_file, GDBMWrapper.READER)) {192 logger.error(" Could not open GDBM database!");193 return false;194 }195 214 return true; 196 215 } … … 294 313 */ 295 314 protected String getDocType(String node_id){ 296 DBInfo info = this. gdbm_src.getInfo(node_id);315 DBInfo info = this.coll_db.getInfo(node_id); 297 316 if (info == null) { 298 317 return GSXML.DOC_TYPE_SIMPLE; … … 315 334 // now we just check the top node 316 335 if (!is_top) { // we need to look at the top info 317 info = this. gdbm_src.getInfo(top_id);336 info = this.coll_db.getInfo(top_id); 318 337 } 319 338 if (info == null) { … … 331 350 /** returns true if the node has child nodes */ 332 351 protected boolean hasChildren(String node_id){ 333 DBInfo info = this. gdbm_src.getInfo(node_id);352 DBInfo info = this.coll_db.getInfo(node_id); 334 353 if (info == null) { 335 354 return false; … … 351 370 } 352 371 353 /** convert MGinternal id to Greenstone oid */372 /** convert indexer internal id to Greenstone oid */ 354 373 protected String internalNum2OID(long docnum) 355 374 { 356 return this. gdbm_src.docnum2OID(docnum);375 return this.coll_db.docnum2OID(docnum); 357 376 358 377 } 359 378 protected String internalNum2OID(String docnum) 360 379 { 361 return this. gdbm_src.docnum2OID(docnum);380 return this.coll_db.docnum2OID(docnum); 362 381 363 382 } -
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; -
greenstone3/trunk/src/java/org/greenstone/gsdl3/service/GS2LuceneRetrieve.java
r13916 r15326 23 23 import org.greenstone.gsdl3.util.GSFile; 24 24 import org.greenstone.gsdl3.util.GSXML; 25 import org.greenstone.gsdl3.util.GDBMWrapper;26 25 import org.greenstone.gsdl3.util.DBInfo; 27 26 import org.greenstone.gsdl3.util.GSHTML; … … 109 108 } 110 109 111 long doc_num = this.gdbm_src.OID2Docnum(doc_id);112 if (doc_num == -1) {110 String doc_num = this.coll_db.OID2Docnum(doc_id); 111 if (doc_num == null || doc_num.equals("")) { 113 112 throw new Exception("OID "+doc_id +" couldn't be converted to lucene doc num"); 114 113 } 115 114 116 DBInfo info=this. gdbm_src.getInfo(OID.getTop(doc_id));115 DBInfo info=this.coll_db.getInfo(OID.getTop(doc_id)); 117 116 if (info == null) { 118 throw new Exception("Couldn't get GDBMdatabase entry for "+OID.getTop(doc_id));117 throw new Exception("Couldn't get database entry for "+OID.getTop(doc_id)); 119 118 } 120 119 … … 136 135 current_section = full_document; 137 136 } else { 138 current_section = GSXML.getNamedElement(full_document, SEC_LEVEL, ID_ATT, String.valueOf(doc_num));137 current_section = GSXML.getNamedElement(full_document, SEC_LEVEL, ID_ATT, doc_num); 139 138 } 140 139 if (current_section == null) { -
greenstone3/trunk/src/java/org/greenstone/gsdl3/service/GS2MGPPRetrieve.java
r14441 r15326 93 93 */ 94 94 protected Element getNodeContent(String doc_id, String lang) throws GSException { 95 long doc_num = this. gdbm_src.OID2Docnum(doc_id);95 long doc_num = this.coll_db.OID2DocnumLong(doc_id); 96 96 if (doc_num == -1) { 97 97 logger.error("OID "+doc_id +" couldn't be converted to mgpp num"); -
greenstone3/trunk/src/java/org/greenstone/gsdl3/service/GS2MGPPSearch.java
r14752 r15326 20 20 21 21 // Greenstone classes 22 import org.greenstone.mgpp.*; 23 import org.greenstone.gsdl3.util.*; 22 import org.greenstone.mgpp.MGPPSearchWrapper; 23 import org.greenstone.mgpp.MGPPTermInfo; 24 import org.greenstone.mgpp.MGPPQueryResult; 25 import org.greenstone.mgpp.MGPPDocInfo; 26 27 import org.greenstone.gsdl3.util.GSFile; 28 import org.greenstone.gsdl3.util.GSXML; 29 24 30 25 31 // XML classes … … 66 72 /** process a query */ 67 73 protected Element processAnyQuery(Element request, int query_type) { 68 69 70 74 synchronized (mgpp_src) { 75 return super.processAnyQuery(request, query_type); 76 } 71 77 } 72 78 /** configure this service */ … … 76 82 } 77 83 78 // the default level is also the level which gdbmis expecting84 // the default level is also the level which the database is expecting 79 85 // this must not be overwritten 80 mgpp_src.setReturnLevel(this.default_ gdbm_level);86 mgpp_src.setReturnLevel(this.default_db_level); 81 87 // return term info 82 88 mgpp_src.setReturnTerms(true); -
greenstone3/trunk/src/java/org/greenstone/gsdl3/service/GS2MGRetrieve.java
r14936 r15326 20 20 21 21 // Greenstone classes 22 import org.greenstone.mg. *;22 import org.greenstone.mg.MGRetrieveWrapper; 23 23 import org.greenstone.gsdl3.core.GSException; 24 24 import org.greenstone.gsdl3.util.GSFile; … … 113 113 */ 114 114 protected Element getNodeContent (String doc_id, String lang) throws GSException { 115 long doc_num = this. gdbm_src.OID2Docnum(doc_id);115 long doc_num = this.coll_db.OID2DocnumLong (doc_id); 116 116 if (doc_num == -1) { 117 117 logger.error ("OID "+doc_id +" couldn't be converted to mg num"); -
greenstone3/trunk/src/java/org/greenstone/gsdl3/service/GoogleNgramMGPPSearch.java
r15123 r15326 37 37 extends GS2MGPPSearch { 38 38 static Logger logger = Logger.getLogger(org.greenstone.gsdl3.service.GoogleNgramMGPPSearch.class.getName()); 39 protected GDBMWrapper gdbm_src = null;40 39 41 40 /** constructor */ 42 41 public GoogleNgramMGPPSearch(){ 43 super(); 44 gdbm_src = new GDBMWrapper(); 45 42 super(); 46 43 } 47 44 … … 52 49 } 53 50 54 // Open GDBM database for querying55 String gdbm_db_file = GSFile.GDBMDatabaseFile(this.site_home, this.cluster_name, this.index_stem);56 if (!this.gdbm_src.openDatabase(gdbm_db_file, GDBMWrapper.READER)) {57 logger.error("Could not open GDBM database!");58 return false;59 }60 51 this.default_max_docs = "-1"; 61 52 this.default_hits_per_page = "30"; … … 78 69 String num = Long.toString((((MGPPDocInfo) docs.elementAt(d)).num_)); 79 70 String doc_id = internalNum2OID(num); 80 DBInfo gdbmInfo = this.gdbm_src.getInfo(doc_id);81 String fre = (String) gdbmInfo.getInfo("Frequency");82 String tense = (String) gdbmInfo.getInfo("Tense");71 DBInfo dbInfo = this.coll_db.getInfo(doc_id); 72 String fre = (String)dbInfo.getInfo("Frequency"); 73 String tense = (String)dbInfo.getInfo("Tense"); 83 74 84 75 if(!fre.equals("")){ -
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.