Changeset 30516
- Timestamp:
- 2016-05-09T16:11:32+12:00 (8 years ago)
- Location:
- main/trunk/greenstone3/src/java/org/greenstone/gsdl3
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/build/GS2PerlConstructor.java
r29947 r30516 203 203 command.add(perlPath + "perl"); 204 204 command.add("-S"); 205 command.add(GlobalProperties.getGS2Build() + File.separator + "bin" + File.separator + "script" + File.separator + "buildcol.pl"); 205 command.add(GlobalProperties.getGS2Build() + File.separator + "bin" + File.separator + "script" + File.separator + "incremental-buildcol.pl"); 206 command.add("-incremental"); 207 command.add("-builddir"); 208 command.add(GSFile.collectDir(this.site_home) + File.separator + this.collection_name + File.separator +"index"); 206 209 command.add("-site"); 207 210 command.add(this.site_name); 208 211 command.add("-collectdir"); 209 212 command.add(GSFile.collectDir(this.site_home)); 210 command.add("-removeold"); // saves some seconds processing time when this flag's added in explicitly213 // command.add("-removeold"); // saves some seconds processing time when this flag's added in explicitly 211 214 command.addAll(extractParameters(this.process_params)); 212 215 command.add(this.collection_name); … … 228 231 // first check that we have a building directory 229 232 // (don't want to bother running activate.pl otherwise) 230 File build_dir = new File(GSFile.collection BuildDir(this.site_home, this.collection_name));233 File build_dir = new File(GSFile.collectionIndexDir(this.site_home, this.collection_name)); 231 234 if (!build_dir.exists()) 232 235 { … … 275 278 command.add("-S"); 276 279 command.add(GlobalProperties.getGS2Build() + File.separator + "bin" + File.separator + "script" + File.separator + "activate.pl"); 280 command.add("-incremental"); 281 command.add("-builddir"); 282 command.add(GSFile.collectDir(this.site_home) + File.separator + this.collection_name + File.separator +"index"); 277 283 command.add("-site"); 278 284 command.add(this.site_name); 279 285 command.add("-collectdir"); 280 286 command.add(GSFile.collectDir(this.site_home)); 281 command.add("-removeold"); // saves some seconds processing time when this flag's added in explicitly287 // command.add("-removeold"); // saves some seconds processing time when this flag's added in explicitly 282 288 command.add("-skipactivation"); // gsdl3/util/GS2Construct does the activation and reactivation 283 289 command.addAll(extractParameters(this.process_params)); -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/DocumentMaker.java
r28966 r30516 36 36 import org.apache.log4j.*; 37 37 38 import org.greenstone.gsdl3.util.UserContext; 39 import org.greenstone.gsdl3.util.SimpleCollectionDatabase; 40 41 38 42 import org.greenstone.gsdl3.util.GSDocumentModel; 43 import org.greenstone.gsdl3.util.GSFile; 39 44 import org.greenstone.gsdl3.util.GSPath; 40 45 import org.greenstone.gsdl3.util.GSXML; … … 91 96 this.short_service_info.appendChild(service); 92 97 } 93 98 94 99 _GSDM = new GSDocumentModel(this.site_home, this.router); 95 100 … … 445 450 446 451 _GSDM.documentXMLSetText(oid, collection, newContent, userContext); 452 453 markDocumentInFlatDatabase("R", collection, oid); 454 447 455 } 448 456 … … 454 462 } 455 463 return result; 464 465 } 466 protected void markDocumentInFlatDatabase(String mark, String collection, String oid) { 467 468 Document msg_doc = XMLConverter.newDOM(); 469 Element message = msg_doc.createElement(GSXML.MESSAGE_ELEM); 470 UserContext userContext = new UserContext(); 471 Element query_request = GSXML.createBasicRequest(msg_doc, GSXML.REQUEST_TYPE_DESCRIBE , collection, userContext); 472 message.appendChild(query_request); 473 Element result = (Element) this.router.process(message); 474 Element resp_elem = (Element) GSXML.getChildByTagName(result, GSXML.RESPONSE_ELEM); 475 Element coll_elem = (Element) GSXML.getChildByTagName(resp_elem, GSXML.COLLECTION_ELEM); 476 String dbtype = coll_elem.getAttribute(GSXML.DB_TYPE_ATT); 477 478 SimpleCollectionDatabase coll_db = new SimpleCollectionDatabase(dbtype); 479 if (!coll_db.databaseOK()) 480 { 481 logger.error("Couldn't create the collection database of type " + dbtype); 482 return; 483 } 484 485 // Open database for reading 486 String coll_db_file = GSFile.archivesDatabaseFile(this.site_home, collection, dbtype); 487 if (!coll_db.openDatabase(coll_db_file, SimpleCollectionDatabase.READ)) 488 { 489 logger.error("Could not open collection archives database. Somebody already using this database!"); 490 } 491 String old_value = coll_db.getValue(oid); 492 String new_value = old_value.replace("<index-status>B", "<index-status>" + mark); 493 // Close database for reading 494 coll_db.closeDatabase(); 495 if (!coll_db.openDatabase(coll_db_file, SimpleCollectionDatabase.WRITE)) 496 { 497 logger.error("Could not open collection archives database. Somebody already using this database!"); 498 } 499 coll_db.setValue(oid, new_value); 500 coll_db.closeDatabase(); 501 456 502 } 457 503 } -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2Construct.java
r29947 r30516 38 38 import org.greenstone.gsdl3.util.GSStatus; 39 39 import org.greenstone.gsdl3.util.GSXML; 40 import org.greenstone.gsdl3.util.SimpleCollectionDatabase; 40 41 import org.greenstone.gsdl3.util.UserContext; 41 42 import org.greenstone.gsdl3.util.XMLConverter; … … 79 80 private static final String BUILDTYPE_MGPP = "mgpp"; 80 81 82 protected static String DATABASE_TYPE = null; 83 protected SimpleCollectionDatabase coll_db = null; 84 81 85 // the list of the collections - store between some method calls 82 86 private String[] collection_list = null; … … 710 714 Set<Map.Entry<String, Serializable>> entries = params.entrySet(); 711 715 Iterator<Map.Entry<String, Serializable>> i = entries.iterator(); 712 while(i.hasNext()) {713 716 714 Map.Entry<String, Serializable> entry = i.next(); 715 String paramname = entry.getKey(); 716 paramname = paramname.replace("s1.", ""); // replaces all occurrences 717 if(paramname.equals("collection")) { 718 paramname = "c"; 719 } 720 String paramvalue = (String)entry.getValue(); 721 722 querystring.append(paramname + "=" + paramvalue); 723 if(i.hasNext()) { 724 querystring.append("&"); 725 } 717 String oid = null; 718 719 while (i.hasNext()) { 720 721 Map.Entry<String, Serializable> entry = i.next(); 722 String paramname = entry.getKey(); 723 paramname = paramname.replace("s1.", ""); // replaces all 724 // occurrences 725 if (paramname.equals("collection")) { 726 paramname = "c"; 727 } 728 if (paramname.equals("d")){ 729 oid = (String) entry.getValue(); 730 } 731 String paramvalue = (String) entry.getValue(); 732 733 querystring.append(paramname + "=" + paramvalue); 734 if (i.hasNext()) { 735 querystring.append("&"); 736 } 726 737 } 738 739 markDocumentInFlatDatabase("R", coll_name, oid); 740 727 741 constructor.setQueryString(querystring.toString()); 728 742 } … … 940 954 941 955 } 956 protected void markDocumentInFlatDatabase(String mark, String collection, String oid) { 957 958 Document msg_doc = XMLConverter.newDOM(); 959 Element message = msg_doc.createElement(GSXML.MESSAGE_ELEM); 960 UserContext userContext = new UserContext(); 961 Element query_request = GSXML.createBasicRequest(msg_doc, GSXML.REQUEST_TYPE_DESCRIBE , collection, userContext); 962 message.appendChild(query_request); 963 Element result = (Element) this.router.process(message); 964 Element resp_elem = (Element) GSXML.getChildByTagName(result, GSXML.RESPONSE_ELEM); 965 Element coll_elem = (Element) GSXML.getChildByTagName(resp_elem, GSXML.COLLECTION_ELEM); 966 String dbtype = coll_elem.getAttribute(GSXML.DB_TYPE_ATT); 967 968 SimpleCollectionDatabase coll_db = new SimpleCollectionDatabase(dbtype); 969 if (!coll_db.databaseOK()) 970 { 971 logger.error("Couldn't create the collection database of type " + dbtype); 972 return; 973 } 974 975 // Open database for reading 976 String coll_db_file = GSFile.archivesDatabaseFile(this.site_home, collection, dbtype); 977 if (!coll_db.openDatabase(coll_db_file, SimpleCollectionDatabase.READ)) 978 { 979 logger.error("Could not open collection archives database. Somebody already using this database!"); 980 } 981 String old_value = coll_db.getValue(oid); 982 String new_value = old_value.replace("<index-status>B", "<index-status>" + mark); 983 // Close database for reading 984 coll_db.closeDatabase(); 985 if (!coll_db.openDatabase(coll_db_file, SimpleCollectionDatabase.WRITE)) 986 { 987 logger.error("Could not open collection archives database. Somebody already using this database!"); 988 } 989 coll_db.setValue(oid, new_value); 990 coll_db.closeDatabase(); 991 992 } 942 993 } -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSFile.java
r30262 r30516 356 356 } 357 357 358 /** the archives database file - */ 359 static public String archivesDatabaseFile(String site_home, String collection_name, String database_type) 360 { 361 String db_ext = DBHelper.getDBExtFromDBType(database_type); 362 if (null == db_ext || db_ext.equals("")) { 363 logger.warn("Could not recognise database type \"" + database_type + "\", defaulting to GDBM and extension \".gdb\""); 364 // assume gdbm 365 db_ext = ".gdb"; 366 } 367 return site_home + File.separatorChar + "collect" + File.separatorChar + collection_name + File.separatorChar + "archives" + File.separatorChar + "archiveinf-doc" + db_ext; 368 } 358 369 // some file utility methods 359 370 -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/JDBMWrapper.java
r30264 r30516 44 44 45 45 RecordManager recman_ = null; 46 HTree hashtable_ ;46 HTree hashtable_ = null; 47 47 48 48 String db_filename_; … … 159 159 public String getValue(String key) 160 160 { 161 161 if (hashtable_ == null) { 162 logger.error("Database was not opened or not exist!"); 163 return null; 164 } 165 162 166 String val; 163 167
Note:
See TracChangeset
for help on using the changeset viewer.