Changeset 13176 for trunk/gli


Ignore:
Timestamp:
2006-10-27T15:07:14+13:00 (18 years ago)
Author:
mdewsnip
Message:

Added NPE fix and an efficiency change to prevent an unnecessary String -> StringBuffer -> String conversion.

Location:
trunk/gli/src/org/greenstone/gatherer/greenstone
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/greenstone/Classifiers.java

    r13175 r13176  
    129129    // Run classifierfo.pl to get the list of classifiers
    130130    try {
    131         StringBuffer xml = null;
     131        String classinfo_xml = null;
    132132        if (Gatherer.isGsdlRemote) {
    133133        String classinfo_options = "&classifier=" + classifier;
     
    135135            classinfo_options += "&collection=" + collection_name;
    136136        }
    137         String classinfo_output = RemoteGreenstoneServer.getScriptOptions("classinfo.pl", classinfo_options);
    138         xml = new StringBuffer(classinfo_output);
     137        classinfo_xml = RemoteGreenstoneServer.getScriptOptions("classinfo.pl", classinfo_options);
    139138        }
    140139        else {
     
    158157        Process process = runtime.exec((String[]) args.toArray(new String[] { }));
    159158        InputStream input_stream = process.getErrorStream();
    160         xml = XMLTools.readXMLStream(input_stream);
     159        StringBuffer classinfo_xml_buffer = XMLTools.readXMLStream(input_stream);
     160        if (classinfo_xml_buffer != null) {
     161            classinfo_xml = classinfo_xml_buffer.toString();
     162        }
    161163        }
    162164
    163165        // Check the XML output was obtained successfully
    164         if (xml == null || xml.length() == 0) {
     166        if (classinfo_xml == null || classinfo_xml.length() == 0) {
    165167        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CDM.ClassifierManager.Classifier_XML_Parse_Failed", classifier.getName()), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
    166168        return;
    167169        }
    168170
    169         parseClassifierInfoXML(classifier, xml.toString());
     171        parseClassifierInfoXML(classifier, classinfo_xml);
    170172    }
    171173    catch (Exception exception) {
  • trunk/gli/src/org/greenstone/gatherer/greenstone/Plugins.java

    r13175 r13176  
    130130    // Run pluginfo.pl to get the list of plugins
    131131    try {
    132         StringBuffer xml = null;
     132        String pluginfo_xml = null;
    133133        if (Gatherer.isGsdlRemote) {
    134134        String pluginfo_options = "&plugin=" + plugin;
     
    136136            pluginfo_options += "&collection=" + collection_name;
    137137        }
    138         String pluginfo_output = RemoteGreenstoneServer.getScriptOptions("pluginfo.pl", pluginfo_options);
    139         xml = new StringBuffer(pluginfo_output);
     138        pluginfo_xml = RemoteGreenstoneServer.getScriptOptions("pluginfo.pl", pluginfo_options);
    140139        }
    141140        else {
     
    159158        Process process = runtime.exec((String[]) args.toArray(new String[] { }));
    160159        InputStream input_stream = process.getErrorStream();
    161         xml = XMLTools.readXMLStream(input_stream);
     160        StringBuffer pluginfo_xml_buffer = XMLTools.readXMLStream(input_stream);
     161        if (pluginfo_xml_buffer != null) {
     162            pluginfo_xml = pluginfo_xml_buffer.toString();
     163        }
    162164        }
    163165
    164166        // Check the XML output was obtained successfully
    165         if (xml == null || xml.length() == 0) {
     167        if (pluginfo_xml == null || pluginfo_xml.length() == 0) {
    166168        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CDM.PlugInManager.PlugIn_XML_Parse_Failed", plugin.getName()), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
    167169        return;
    168170        }
    169171
    170         parsePluginInfoXML(plugin, xml.toString());
     172        parsePluginInfoXML(plugin, pluginfo_xml);
    171173    }
    172174    catch (Exception exception) {
Note: See TracChangeset for help on using the changeset viewer.