- Timestamp:
- 2016-05-09T16:11:32+12:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note:
See TracChangeset
for help on using the changeset viewer.