Ignore:
Timestamp:
2017-04-21T21:09:08+12:00 (7 years ago)
Author:
ak19
Message:

First phase of shifting gli code to use SafeProcess instead of Java Process. This phase takes care of all the easy cases.

File:
1 edited

Legend:

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

    r26225 r31636  
    3737import org.greenstone.gatherer.cdm.Plugin;
    3838import org.greenstone.gatherer.remote.RemoteGreenstoneServer;
     39import org.greenstone.gatherer.util.SafeProcess;
    3940import org.greenstone.gatherer.util.StaticStrings;
    4041import org.greenstone.gatherer.util.Utility;
     
    160161        args.add(Configuration.getLanguage());
    161162        args.add(plugin.getName());
    162         // Run the pluginfo.pl process
    163         Runtime runtime = Runtime.getRuntime();
    164         Process process = runtime.exec((String[]) args.toArray(new String[] { }));
    165         InputStream input_stream = process.getErrorStream();
    166         StringBuffer pluginfo_xml_buffer = XMLTools.readXMLStream(input_stream);
    167         if (pluginfo_xml_buffer != null) {
    168             pluginfo_xml = pluginfo_xml_buffer.toString();
    169         }
     163
     164        // Run the pluginfo.pl process:
     165        // Create the process.
     166        SafeProcess process = new SafeProcess((String[]) args.toArray(new String[] { }));
     167
     168        // run the SafeProcess
     169        int exitVal = process.runProcess();
     170        if(exitVal != 0) {
     171            throw new Exception("*** Error running pluginfo.pl loadPlugInfo, process exited with: "
     172                    + exitVal);
     173        }
     174        // get the result: We expect XML to have come out of the process std error stream.
     175        pluginfo_xml = process.getStdError();
     176        ///System.err.println("*********\nPluginInfo, got:\n" + pluginfo_xml + "\n**********\n");
    170177        }
    171178
     
    230237        args.add("-xml");
    231238
    232         // Run the pluginfo.pl process
    233         Runtime runtime = Runtime.getRuntime();
    234         Process process = runtime.exec((String[]) args.toArray(new String[] { }));
    235         InputStream input_stream = process.getErrorStream();
    236         xml = XMLTools.readXMLStream(input_stream);
     239        // Run the pluginfo.pl process:
     240        // Create the process.
     241        SafeProcess process = new SafeProcess((String[]) args.toArray(new String[] { }));
     242
     243        // run the SafeProcess
     244        int exitVal = process.runProcess();
     245        if(exitVal != 0) {
     246            throw new Exception("*** Error running pluginfo.pl loadPluginsList, process exited with: "
     247                    + exitVal);
     248        }
     249        // get the result: We expect XML to have come out of the process std error stream.
     250        xml = new StringBuffer(process.getStdError());
     251        ///System.err.println("*********\nPluginsList, got:\n" + xml + "\n**********\n");
    237252        }
    238253
Note: See TracChangeset for help on using the changeset viewer.