Changeset 26273 for main/trunk
- Timestamp:
- 2012-09-29T18:57:32+12:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/FedoraServiceProxy.java
r26170 r26273 45 45 import org.xml.sax.InputSource; 46 46 47 import org.apache.commons.lang3.StringUtils; 47 48 48 49 /* … … 87 88 { 88 89 public static class BasicTextMacroResolver extends MacroResolver { 90 private static final Pattern p_back_slash = Pattern.compile("\\\"");// create a pattern "\\\"", but it matches both " and \" 91 89 92 public String resolve(String text, String lang, String scope, String doc_oid) 90 93 { … … 101 104 String new_text = null; 102 105 Macro m = (Macro)macros.get(i); 106 103 107 if(m.type == TYPE_TEXT) { 104 108 // make sure we resolve any macros in the text 105 // the (?s) treats the string as a single line, cos . 106 // doesn't necessarily match line breaks 107 //if (text.matches("(?s).*"+m.macro+".*")) { 108 Pattern p_text = Pattern.compile(".*" + m.macro + ".*",Pattern.DOTALL); 109 Matcher match_text = p_text.matcher(text); 110 if (match_text.matches()) { 109 110 if(text.contains(m.macro)) { 111 111 if (m.resolve) { 112 112 new_text = this.resolve(m.text, lang, scope, doc_oid); … … 114 114 new_text = m.text; 115 115 } 116 text = text.replaceAll(m.macro, new_text); 117 if (m.macro.endsWith("\\\\")){ // to get rid of "\" from the string likes: "src="http://www.greenstone.org:80/.../mw.gif\">" 118 Pattern p_back_slash = Pattern.compile("\\\"");// create a pattern "\\\"", but it matches both " and \" 116 text = StringUtils.replace(text, m.macro, new_text);//text = text.replaceAll(m.macro, new_text); 117 if (m.macro.endsWith("\\\\")) { // to get rid of "\" from the string like: "src="http://www.greenstone.org:80/.../mw.gif\">" 119 118 Matcher m_slash = p_back_slash.matcher(text); 120 119 String clean_str = ""; 121 120 int s=0; 122 while (m_slash.find()) {123 if (!text.substring(m_slash.end()-2, m_slash.end()-1).equals("\\")){121 while (m_slash.find()) { 122 if (!text.substring(m_slash.end()-2, m_slash.end()-1).equals("\\")) { 124 123 clean_str = clean_str + text.substring(s,m_slash.end()-1); // it matches ", so get a substring before " 125 124 }else{ 126 125 clean_str = clean_str + text.substring(s,m_slash.end()-2);// it matches \", so get a substring before \ 127 126 } 128 127 s = m_slash.end();// get the index of the last match 129 128 clean_str = clean_str + "\""; … … 132 131 } 133 132 } 134 } 133 } 135 134 } 136 135 return text; … … 348 347 349 348 //logger.error("### request:"); 350 //logger.error(GSXML. nodeToFormattedString(request));349 //logger.error(GSXML.elementToString(request, true)); 351 350 352 351 if(docIDs == null) { … … 516 515 Element response = getResponseAsDOM(fedoraServicesAPIA.retrieveBrowseMetadata( 517 516 this.cluster_name, "ClassifierBrowseMetadataRetrieve", classIDs, metafields)); 517 //logger.error("**** Response from retrieveBrowseMeta: " + GSXML.elementToString(response, true)); 518 518 return (Element)response.getElementsByTagName(GSXML.RESPONSE_ELEM).item(0); 519 519 } … … 555 555 = getResponseAsDOM(fedoraServicesAPIA.retrieveBrowseStructure(collection, "ClassifierBrowse", classifierIDs, 556 556 new String[] {structure}, new String[] {info})); 557 // /logger.error("**** FedoraServiceProxy - Response from retrieveBrowseStructure: " + GSXML.nodeToFormattedString(response));557 //logger.error("**** FedoraServiceProxy - Response from retrieveBrowseStructure: " + GSXML.elementToString(response, true)); 558 558 559 559 return (Element)response.getElementsByTagName(GSXML.RESPONSE_ELEM).item(0);
Note:
See TracChangeset
for help on using the changeset viewer.