Changeset 31578

Show
Ignore:
Timestamp:
06.04.2017 15:24:43 (2 years ago)
Author:
ak19
Message:

Removed debugging and other minor cosmetic changes after successful Windows testing of the new SafeProcess? class used by the modified GS2PerlConstructor.runPerlCommand() method.

Location:
main/trunk/greenstone3/src/java/org/greenstone
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/build/CollectionConstructor.java

    r31572 r31578  
    2525    protected EventListenerList listeners = null; 
    2626    /** A flag used to determine if this process has been asked to cancel. */ 
    27     protected boolean cancel = false; 
     27    protected boolean cancel = false; // Not really used (in any way that works) 
    2828    /** Stores the name of the manifest file (if one is needed) */ 
    2929    protected String manifest_file = null; 
    30     /** The URL params constructed as a query string, representing the CGI QUERY_STRING to the process */ 
    31     protected String query_string = null; 
     30    /** The URL params constructed as a query string, representing the CGI QUERY_STRING to the process */ 
     31    protected String query_string = null; 
    3232 
    3333    public CollectionConstructor(String name) 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/build/GS2PerlConstructor.java

    r31574 r31578  
    3636    public static final int BUILD = 2; 
    3737    public static final int ACTIVATE = 3; 
    38     public static final int MODIFY_METADATA_SERVER = 4; 
     38    public static final int MODIFY_METADATA_SERVER = 4; 
    3939 
    4040    /** 
     
    4949    /** the path environment variable */ 
    5050    protected String path = null; 
     51 
    5152 
    5253    public GS2PerlConstructor(String name) 
     
    409410    sendMessage(new ConstructionEvent(this, GSStatus.INFO, "command = " + command_str)); 
    410411     
    411      
    412     logger.info("### Running command = " + command_str); 
     412    //logger.info("### Running command = " + command_str); 
    413413 
    414414    // This is where we create and run our perl process safely 
     
    450450        // std in of java, as before. 
    451451 
    452         logger.info("**** BEFORE runProcess."); 
    453452        perlProcess.runProcess(); 
    454         logger.info("**** AFTER runProcess:"); 
    455453         
    456454    // The original runPerlCommand() code had an ineffective check for whether the cmd had been cancelled 
     
    545543        } 
    546544 
    547 logger.info("### old runPerlCmd, command = " + command_str); 
     545        // logger.info("### old runPerlCmd, command = " + command_str); 
    548546 
    549547        sendMessage(new ConstructionEvent(this, GSStatus.INFO, "command = " + command_str)); 
  • main/trunk/greenstone3/src/java/org/greenstone/util/SafeProcess.java

    r31574 r31578  
    9797//***************** Copied from gli's gui/FormatConversionDialog.java *************// 
    9898    public void runProcess() { 
     99 
    99100    Process prcs = null; 
    100101    SafeProcess.OutputStreamGobbler inputGobbler = null; 
     
    103104 
    104105    try {        
    105          
    106106        Runtime rt = Runtime.getRuntime();       
    107107         
    108          
    109108        // http://stackoverflow.com/questions/5283444/convert-array-of-strings-into-a-string-in-java 
    110         logger.info("Running process: " + Arrays.toString(command_args)); 
     109        //logger.info("Running process: " + Arrays.toString(command_args)); 
    111110 
    112111        if(this.envp == null) { 
     
    115114 
    116115        if(this.dir == null) { 
    117             logger.info("\twith: " + Arrays.toString(this.envp)); 
     116            //logger.info("\twith: " + Arrays.toString(this.envp)); 
    118117            prcs = rt.exec(this.command_args, this.envp); 
    119118        } else { 
    120             logger.info("\tfrom directory: " + this.dir); 
    121             logger.info("\twith: " + Arrays.toString(this.envp)); 
     119            //logger.info("\tfrom directory: " + this.dir); 
     120            //logger.info("\twith: " + Arrays.toString(this.envp)); 
    122121            prcs = rt.exec(this.command_args, this.envp, this.dir); 
    123122        } 
    124123        } 
    125124 
    126         logger.info("### Before creating ProcessInGobbler"); 
    127  
    128         
    129125        // send inputStr to process. The following constructor can handle inputStr being null 
    130126        inputGobbler = // WriterToProcessInputStream 
    131127        new SafeProcess.OutputStreamGobbler(prcs.getOutputStream(), this.inputStr); 
    132128         
    133         logger.info("### Before creating ProcessErrGobbler"); 
    134          
    135129        // monitor for any error messages 
    136130            errorGobbler // ReaderFromProcessOutputStream 
    137131        = new SafeProcess.InputStreamGobbler(prcs.getErrorStream(), splitStdOutputNewLines); 
    138132 
    139         logger.info("### Before creating ProcessOutGobbler"); 
    140  
    141133            // monitor for the expected std output line(s) 
    142134            outputGobbler 
    143135        = new SafeProcess.InputStreamGobbler(prcs.getInputStream(), splitStdErrorNewLines); 
    144  
    145         logger.info("### Before setting handlers on ProcessGobblers"); 
    146136                     
    147137        // register line by line handlers, if any were set, for the process stderr and stdout streams 
     
    156146        }        
    157147 
    158         logger.info("### Before streamgobblers.start()"); 
    159  
    160148            // kick off the stream gobblers 
    161149            inputGobbler.start(); 
    162150            errorGobbler.start(); 
    163151            outputGobbler.start(); 
    164  
    165         logger.info("### After streamgobblers.start() - before waitFor"); 
    166152                                     
    167153            // any error??? 
    168154            this.exitValue = prcs.waitFor(); // can throw an InterruptedException if process did not terminate               
    169             logger.info("ExitValue: " + exitValue);  
    170  
    171         logger.info("### Before streamgobblers.join()"); 
    172  
    173155        // From the comments of  
    174156        // http://www.javaworld.com/article/2071275/core-java/when-runtime-exec---won-t.html?page=2 
     
    180162        inputGobbler.join();  
    181163         
    182         logger.info("### After streamgobblers.join()"); 
    183  
    184164        // set the variables the code that created a SafeProcess object may want to inspect 
    185165        this.outputStr = outputGobbler.getOutput(); 
    186166        this.errorStr = errorGobbler.getOutput(); 
    187167 
    188         // the calling code should handle errorStr, not us, so can leave out the following code 
    189         /* 
    190           if(!this.errorStr.equals("")) { 
    191           logger.info("*** Process errorstream: \n" + this.errorStr + "\n****"); 
    192           //System.err.println("*** Process errorstream: \n" + this.errorStr + "\n****"); 
    193           } 
    194         */ 
    195          
    196168        // Since we didn't have an exception, process should have terminated now (waitFor blocks until then) 
    197169        // Set process to null so we don't forcibly terminate it below with process.destroy()