Changeset 24007 for main/branches/64_bit_Greenstone/greenstone3/src/java/org/greenstone/gsdl3/collection/Collection.java
- Timestamp:
- 2011-05-09T14:37:04+12:00 (13 years ago)
- Location:
- main/branches/64_bit_Greenstone/greenstone3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/branches/64_bit_Greenstone/greenstone3
- Property svn:mergeinfo changed
-
main/branches/64_bit_Greenstone/greenstone3/src/java/org/greenstone/gsdl3/collection/Collection.java
r23606 r24007 44 44 import org.apache.log4j.*; 45 45 46 // Apache Commons 47 import org.apache.commons.lang3.*; 48 46 49 /** 47 50 * Represents a collection in Greenstone. A collection is an extension of … … 65 68 /** time when this collection was built */ 66 69 protected long lastmodified = 0; 67 70 /** earliestDatestamp of this collection. Necessary for OAI */ 71 protected long earliestDatestamp = 0; 72 73 68 74 /** An element containing the serviceRackList element of buildConfig.xml, used to determine whether it contains 69 75 * the OAIPMH serviceRack … … 130 136 return is_public; 131 137 } 132 //used by the OAIReceptionist to find out the earliest datestamp amongst all oai collections in the repository 138 // Not used anymore by the OAIReceptionist to find out the earliest datestamp 139 // amongst all oai collections in the repository. May be useful generally. 133 140 public long getLastmodified() { 134 141 return lastmodified; 135 142 } 143 //used by the OAIReceptionist to find out the earliest datestamp amongst all oai collections in the repository 144 public long getEarliestDatestamp() { 145 return earliestDatestamp; 146 } 147 136 148 /** whether the service_map in ServiceCluster.java contains the service 'OAIPMH' 137 149 * 11/06/2007 xiao … … 176 188 build_config_elem = build_config_doc.getDocumentElement(); 177 189 } 178 190 179 191 lastmodified = build_config_file.lastModified(); 180 192 … … 211 223 addPlugins(plugin_list); 212 224 if (plugin_list != null){ 213 Element plugin_elem = (Element)GSXML.getNamedElement(plugin_list, GSXML.PLUGIN_ELEM, GSXML.NAME_ATT, "HTMLPlug ");225 Element plugin_elem = (Element)GSXML.getNamedElement(plugin_list, GSXML.PLUGIN_ELEM, GSXML.NAME_ATT, "HTMLPlugin"); 214 226 if (plugin_elem != null) { 215 227 //get the option 216 Element option_elem = (Element)GSXML.getNamedElement(plugin_elem, GSXML.PARAM_OPTION_ELEM, GSXML.NAME_ATT, "- tidy_html");228 Element option_elem = (Element)GSXML.getNamedElement(plugin_elem, GSXML.PARAM_OPTION_ELEM, GSXML.NAME_ATT, "-use_realistic_book"); 217 229 if (option_elem != null) { 218 230 useBook = true; … … 261 273 } else { 262 274 has_oai = true; 275 276 // extract earliestDatestamp from the buildconfig.xml for OAI 277 Element metadata_list = (Element)GSXML.getChildByTagName(build_config_xml, GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER); 278 279 if(metadata_list != null) { 280 NodeList children = metadata_list.getElementsByTagName(GSXML.METADATA_ELEM); 281 // can't do getChildNodes(), because whitespace, such as newlines, creates Text nodes 282 for (int i = 0; i < children.getLength(); i++) { 283 Element metadata = (Element)children.item(i); 284 if(metadata.getAttribute(GSXML.NAME_ATT).equals(OAIXML.EARLIEST_DATESTAMP)) { 285 String earliestDatestampStr = GSXML.getValue(metadata); 286 if(!earliestDatestampStr.equals("")) { 287 earliestDatestamp = Long.parseLong(earliestDatestampStr); 288 } 289 break; // found a metadata element with name=earliestDatestamp in buildconfig 290 } 291 } 292 } 293 294 // If at the end of this, there is no value for earliestDatestamp, print out a warning 295 logger.warn("No earliestDatestamp in buildConfig.xml for collection: " + this.cluster_name + ". Defaulting to 0."); 296 263 297 } 298 } else { // no list of services (no ServiceRackList), so no oai_service_rack either 299 // explicitly set has_oai to false here, since it's initialised to true by default 300 has_oai = false; 264 301 } 265 302 return true; … … 275 312 Element d = (Element) displaynodes.item(k); 276 313 String text = GSXML.getNodeText(d); 277 text = text.replaceAll("_httpsite_", http_site);278 text = text.replaceAll("_httpcollection_", http_collection);314 text = StringUtils.replace(text, "_httpsite_", http_site); 315 text = StringUtils.replace(text, "_httpcollection_", http_collection); 279 316 GSXML.setNodeText(d, text); 280 317 } … … 338 375 339 376 Element format_element = (Element) GSXML.getChildByTagName(request, GSXML.FORMAT_STRING_ELEM); 340 String format_string = GSXML.getNodeText(format_element);341 //Element format_statement = (Element) format_element.getFirstChild();377 //String format_string = GSXML.getNodeText(format_element); 378 Element format_statement = (Element) format_element.getFirstChild(); 342 379 343 380 //logger.error("Format string: " + format_string); … … 394 431 395 432 // Write format statement 396 //String format_string =GSXML.xmlNodeToString(format_statement);433 String format_string = this.converter.getString(format_statement); //GSXML.xmlNodeToString(format_statement); 397 434 writer = new BufferedWriter(new FileWriter(format_statement_filename)); 398 435 writer.write(format_string); … … 416 453 417 454 // Convert format string to a document 418 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();419 DocumentBuilder builder = factory.newDocumentBuilder();455 //DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 456 //DocumentBuilder builder = factory.newDocumentBuilder(); 420 457 //String input = "<html><head><title></title></head><body>" + format_string + "</body></html>"; 421 String input = format_string.substring(0,format_string.length()-1)+"</xml>";422 logger.error(input);423 InputSource is = new InputSource( new StringReader( input ) );424 logger.error("About to parse format string");425 Document format_statement = (Document) builder.parse( is );426 logger.error("Done parsing format string");458 //String input = format_string.substring(0,format_string.length()-1)+"</xml>"; 459 //logger.error(input); 460 //InputSource is = new InputSource( new StringReader( input ) ); 461 //logger.error("About to parse format string"); 462 //Document format_statement = (Document) builder.parse( is ); 463 //logger.error("Done parsing format string"); 427 464 428 465 // open collectionConfig.xml and read in to w3 Document … … 488 525 489 526 // append new but we have a string! 490 GSXML.setNodeText(elem, format_string); 491 492 //current_node_list = format_statement.getChildNodes(); 493 //for(k=0; k<current_node_list.getLength(); k++) 494 //{ 495 // current_node = elem.appendChild(current_node_list.item(k)); 496 //} 527 //GSXML.setNodeText(elem, "THIS IS A TEST"); 528 //GSXML.setNodeText(elem, format_string); 529 530 current_node_list = format_statement.getChildNodes(); 531 for(k=0; k<current_node_list.getLength(); k++) 532 { 533 //if(transformed.getNodeType() == Node.DOCUMENT_NODE) 534 //transformed = ((Document)transformed).getDocumentElement(); 535 logger.error("Node type: "+current_node_list.item(k).getNodeType()); 536 if(current_node_list.item(k).getNodeType() != Node.PROCESSING_INSTRUCTION_NODE) 537 current_node = elem.appendChild(this.doc.importNode(current_node_list.item(k),true)); 538 } 497 539 498 540 //String text = GSXML.getNodeText(elem); … … 503 545 504 546 // Now convert config document to string for writing to file 505 String new_config = GSXML.xmlNodeToString(config);547 String new_config = this.converter.getString(config); 506 548 507 549 // Write to file (not original! for now)
Note:
See TracChangeset
for help on using the changeset viewer.