Changeset 31776
- Timestamp:
- 2017-07-05T20:43:44+12:00 (7 years ago)
- Location:
- main/trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/src/org/greenstone/gatherer/greenstone/Plugins.java
r31641 r31776 165 165 // Create the process. 166 166 SafeProcess process = new SafeProcess((String[]) args.toArray(new String[] { })); 167 process.setSplitStdErrorNewLines(true); 167 168 168 169 // run the SafeProcess … … 174 175 // get the result: We expect XML to have come out of the process std error stream. 175 176 pluginfo_xml = process.getStdError(); 177 // make sure to have parsed out any lines preceding the XML content 178 pluginfo_xml = XMLTools.readXMLStream(pluginfo_xml).toString(); 176 179 ///System.err.println("*********\nPluginInfo, got:\n" + pluginfo_xml + "\n**********\n"); 177 180 } … … 236 239 args.add("-listall"); 237 240 args.add("-xml"); 238 241 239 242 // Run the pluginfo.pl process: 240 243 // Create the process. 241 244 SafeProcess process = new SafeProcess((String[]) args.toArray(new String[] { })); 245 process.setSplitStdErrorNewLines(true); 242 246 243 247 // run the SafeProcess … … 249 253 // get the result: We expect XML to have come out of the process std error stream. 250 254 xml = process.getStdError(); 251 255 // make sure to parse out any lines before the XML content, else running "gli -debug" results in an XML error: 252 256 // for pluginfo.pl -listall, we see a "AutoloadConverters" (PDFBox) message 253 // before actual XML output, which breaks XML parsing. Get rid of output before "<?xml" 254 int startIndex = xml.indexOf("<?xml"); 255 if(startIndex != 0) { 256 xml = xml.substring(startIndex); 257 } 257 // before actual XML output, which breaks XML parsing. 258 // This gets rid of output before "<?xml" in the way that the code did before the change to SafeProcess 259 // Then we can call the same from method RemoteGreenstoneServer.java, so that running "client-gli -debug" 260 // will work too. 261 xml = XMLTools.readXMLStream(xml).toString(); 262 258 263 ///System.err.println("*********\nPluginsList, got:\n" + xml + "\n**********\n"); 259 264 } -
main/trunk/gli/src/org/greenstone/gatherer/remote/RemoteGreenstoneServer.java
r22692 r31776 44 44 import org.greenstone.gatherer.util.UnzipTools; 45 45 import org.greenstone.gatherer.util.Utility; 46 import org.greenstone.gatherer.util.XMLTools; 46 47 import org.apache.commons.httpclient.HttpClient; 47 48 import org.apache.commons.httpclient.methods.PostMethod; … … 682 683 gliserver_in.close(); 683 684 685 686 int startIndex = command_output_buffer.indexOf("<?xml"); 687 if(startIndex > 0) { // not -1, so "<?xml" is present, and not 0, so not at start 688 689 // iff dealing with XML, make sure to parse out any lines preceding the XML content 690 command_output_buffer = XMLTools.readXMLStream(command_output_buffer.toString()); 691 /*if(DebugStream.isDebuggingEnabled()) { 692 String prefix = command_output_buffer.substring(0, startIndex); 693 DebugStream.println("Removing the following found before start of XML:"); 694 DebugStream.println("---------------------------------"); 695 DebugStream.println(prefix); 696 DebugStream.println("---------------------------------"); 697 } 698 // remove the prefix 699 return command_output_buffer.substring(startIndex); // remove anything before the start of XML 700 */ 701 } 702 684 703 return command_output_buffer.toString(); 685 704 } -
main/trunk/gli/src/org/greenstone/gatherer/util/XMLTools.java
r30869 r31776 733 733 static public StringBuffer readXMLStream(InputStream input_stream) 734 734 { 735 StringBuffer xml = new StringBuffer(""); 736 try { 737 InputStreamReader isr = new InputStreamReader(input_stream, "UTF-8"); 738 xml = XMLTools.readXMLStream(new InputStreamReader(input_stream, "UTF-8")); 739 } catch (UnsupportedEncodingException error) { 740 System.err.println("Failed when trying to parse XML stream"); 741 error.printStackTrace(); 742 } 743 744 return xml; 745 } 746 747 static public StringBuffer readXMLStream(String s) { 748 return XMLTools.readXMLStream(new StringReader(s)); 749 } 750 751 752 static public StringBuffer readXMLStream(Reader reader) 753 { 735 754 StringBuffer xml = new StringBuffer(""); 736 755 737 756 try 738 757 { 739 InputStreamReader isr = new InputStreamReader(input_stream, "UTF-8"); 740 BufferedReader buffered_in = new BufferedReader(isr); 758 BufferedReader buffered_in = new BufferedReader(reader); 741 759 742 760 String line = "";
Note:
See TracChangeset
for help on using the changeset viewer.