Changeset 31592

Show
Ignore:
Timestamp:
07.04.2017 18:20:11 (2 years ago)
Author:
ak19
Message:

Removed unwanted debugging now that Windows testing of the new SafeProcess?.CustomProcessHandler? related changes worked out successfully too.

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

Legend:

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

    r31591 r31592  
    335335        // http://www.cgi101.com/class/ch3/text.html 
    336336        // setenv QUERY_STRING and REQUEST_METHOD = GET. 
    337         // Run the perl command as a simple process: no logging to the collection's build log 
    338337        if (runPerlCommand(command_str, envvars, new File(cgi_directory))) 
    339338                   //new File(GlobalProperties.getGSDL3Home() + File.separator + "WEB-INF" + File.separator + "cgi"))) 
     
    402401    } 
    403402 
    404     // ModifyMetadata operations call runSimplePerlCommand which produces no output in build log 
     403    // If you want to run a Perl command without doing GS2PerlConstructor's custom logging in the build log 
     404    // The use the runSimplePerlCommand() versions, which use the default behaviour of running a SafeProcess 
    405405    protected boolean runSimplePerlCommand(String[] command) {   
    406406    return runSimplePerlCommand(command, null, null); 
     
    417417    sendMessage(new ConstructionEvent(this, GSStatus.INFO, "command = " + command_str)); 
    418418     
    419     logger.info("### Running simple command = " + command_str); 
     419    ///logger.info("### Running simple command = " + command_str); 
    420420 
    421421    // This is where we create and run our perl process safely 
     
    459459    sendMessage(new ConstructionEvent(this, GSStatus.INFO, "command = " + command_str)); 
    460460     
    461     logger.info("### Running logged command = " + command_str); 
     461    ///logger.info("### Running logged command = " + command_str); 
    462462 
    463463    // This is where we create and run our perl process safely 
     
    526526        // Now display final message based on exit value             
    527527         
    528         if (perlProcess.getExitValue() == 0) {   
    529         //status = OK; 
     528        if (perlProcess.getExitValue() == 0) { //status = OK; 
     529         
    530530        sendProcessStatus(new ConstructionEvent(this, GSStatus.CONTINUING, "Success")); 
    531          
    532531        success = true; 
    533         } else { 
    534         //status = ERROR; 
     532 
     533        } else { //status = ERROR; 
    535534        sendProcessStatus(new ConstructionEvent(this, GSStatus.ERROR, "Failure")); 
    536          
    537         //return false; 
    538535        success = false; 
    539536         
    540537        } 
    541     } else { // cancelled 
     538    } else { // cancelled. The code would never come here, including in the old version of runPerlCommand 
     539        // but leaving this here for an exact port of the old runPerlCommand to the new one which 
     540        // uses SafeProcess. Also to allow the cancel functionality in future 
    542541         
    543542        // I need to somehow kill the child process. Unfortunately Thread.stop() and Process.destroy() both fail to do this. But now, thankx to the magic of Michaels 'close the stream suggestion', it works fine. 
    544543        sendProcessStatus(new ConstructionEvent(this, GSStatus.HALTED, "killing the process")); 
    545         //prcs.getOutputStream().close(); 
    546         //prcs.destroy(); 
    547         ////status = ERROR; 
    548          
    549         //return false; 
    550544        success = false; 
    551545    } 
     
    752746            } 
    753747             
    754 ///         System.out.println("@@@ GOT LINE: " + line); 
    755 ///         GS2PerlConstructor.logger.info("@@@ GOT LINE: " + line + " STDOUT=1: " + source); 
     748            ///System.out.println("@@@ GOT LINE: " + line); 
     749 
    756750 
    757751            //if(this.source == STDERR) { 
     
    814808        bwHandle.write(line + "\n");     
    815809         
    816 ///     System.out.println("@@@ WROTE LINE: " + line); 
    817810///     GS2PerlConstructor.logger.info("@@@ WROTE LINE: " + line); 
    818811 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2Construct.java

    r31591 r31592  
    10261026    { 
    10271027    if(allowedMetaFieldsPattern == null) { // null when user has edit permissions, so they can set any meta 
    1028         logger.info("### User has permissions to set any meta."); 
     1028        ///logger.info("### User has permissions to set any meta."); 
    10291029        return true; 
    10301030    } 
    10311031    if(metaname == null) { 
    1032         logger.info("### Can't check null metaname against pattern"); 
     1032        ///logger.info("### Can't check null metaname against pattern"); 
    10331033        return false; 
    10341034    } 
     
    10361036    Matcher m = allowedMetaFieldsPattern.matcher(metaname); 
    10371037    if(!m.matches()) { 
    1038         logger.info("### metaname: " + metaname + " doesn't match allowed allowed fields: " + allowedMetaFieldsPattern.toString()); 
     1038        ///logger.info("### metaname: " + metaname + " doesn't match allowed allowed fields: " + allowedMetaFieldsPattern.toString()); 
    10391039        return false; 
    10401040    } else { 
     
    10651065            docids[index] = docInfo.getString("docid"); // should exist if metatable existed 
    10661066 
    1067             logger.info("@@@ Found docid: " + docids[index]); 
     1067            ///logger.info("@@@ Found docid: " + docids[index]); 
    10681068 
    10691069            JSONArray metatable = docInfo.getJSONArray("metatable"); 
     
    10721072 
    10731073            String metaname = meta.getString("metaname"); 
    1074             logger.info("### metaname: " + metaname); 
     1074            ///logger.info("### metaname: " + metaname); 
    10751075             
    10761076            if(!isAllowedToSetMeta(metaname, filterFields)) { 
     
    11231123    } 
    11241124 
    1125     // START DEBUG 
     1125    /*  
     1126    // FOR DEBUGGING 
    11261127    Set<Map.Entry<String, Serializable>> entries = params.entrySet(); 
    11271128    Iterator<Map.Entry<String, Serializable>> i = entries.iterator(); 
     
    11381139     
    11391140    logger.info("XXXXXXXXXXXXX PARAMETERS:\n" + parametersLine); 
    1140     // END DEBUG 
     1141    */ 
    11411142 
    11421143    for (String group : context.getGroups()) { 
  • main/trunk/greenstone3/src/java/org/greenstone/util/SafeProcess.java

    r31591 r31592  
    123123             
    124124            if(this.dir == null) { 
    125             logger.info("\twith: " + Arrays.toString(this.envp)); 
     125            //logger.info("\twith: " + Arrays.toString(this.envp)); 
    126126            prcs = rt.exec(this.command_args, this.envp); 
    127127            } else { 
    128             logger.info("\tfrom directory: " + this.dir); 
    129             logger.info("\twith: " + Arrays.toString(this.envp)); 
     128            //logger.info("\tfrom directory: " + this.dir); 
     129            //logger.info("\twith: " + Arrays.toString(this.envp)); 
    130130            prcs = rt.exec(this.command_args, this.envp, this.dir); 
    131131            } 
    132132        } 
    133133        } 
    134  
    135         logger.info("### Before creating ProcessInGobbler"); 
    136134 
    137135        // Create the streamgobblers and set any specified handlers on them 
     
    146144        } 
    147145 
    148         logger.info("### Before creating ProcessErrGobbler"); 
    149          
    150146        // PROC ERR STREAM to monitor for any error messages or expected output in the process' stderr 
    151147        if(procErrHandler == null) { 
     
    157153        } 
    158154 
    159         logger.info("### Before creating ProcessOutGobbler"); 
    160  
    161155            // PROC OUT STREAM to monitor for the expected std output line(s) 
    162156        if(procOutHandler == null) { 
     
    169163 
    170164         
    171         logger.info("### Before streamgobblers.start()"); 
    172  
    173165            // kick off the stream gobblers 
    174166            inputGobbler.start(); 
     
    176168            outputGobbler.start(); 
    177169 
    178         logger.info("### After streamgobblers.start() - before waitFor"); 
    179                                      
    180170            // any error??? 
    181171            this.exitValue = prcs.waitFor(); // can throw an InterruptedException if process did not terminate 
    182172 
    183             logger.info("Process exitValue: " + exitValue);  
    184  
    185         logger.info("### Before streamgobblers.join()"); 
     173            ///logger.info("Process exitValue: " + exitValue);  
    186174 
    187175        // From the comments of  
     
    194182        inputGobbler.join();  
    195183         
    196         logger.info("### After streamgobblers.join()"); 
    197184 
    198185        // set the variables the code that created a SafeProcess object may want to inspect