Ignore:
Timestamp:
2017-07-05T20:43:44+12:00 (7 years ago)
Author:
ak19
Message:

Kathy described a problem on the mailing list about the AutoLoadConverters msg appearing before XML content when connecting with a client-GLI to a remote GS3, which breaks parsing of the XML. (I found it was present in my GS3 installation from 4 May 2016.) I've narrowed it down to running client-gli with the debug flag turned on, which seemed related to the same problem I'd seen when running gli -debug after the change to SafeProcess in Plugins.java, which I fixed by removing lines preceding XML content before parsing the XML. For client-gli, SafeProcess isn't used which is also why the problem with client-gli is much older, but I'm now using a common and existing solution for both: doing what Plugins.java used to do before the change to SafeProcess, which is call XMLTools.readXMLStream(), which would parse out content before XML. The RemoteGreenstoneServer should only call this method if it actually has some XML content it's dealing with. Could have solved this in RemoteGreenstoneServerAction.java's GetScriptOptions, but am solving it in RemoteGreenstoneServer's sendCommandToServerInternal, since there may be many Actions returning XML, not just GetScriptOptions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/remote/RemoteGreenstoneServer.java

    r22692 r31776  
    4444import org.greenstone.gatherer.util.UnzipTools;
    4545import org.greenstone.gatherer.util.Utility;
     46import org.greenstone.gatherer.util.XMLTools;
    4647import org.apache.commons.httpclient.HttpClient;
    4748import org.apache.commons.httpclient.methods.PostMethod;
     
    682683    gliserver_in.close();
    683684
     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   
    684703    return command_output_buffer.toString();
    685704    }
Note: See TracChangeset for help on using the changeset viewer.