Changeset 18558


Ignore:
Timestamp:
2009-02-20T13:21:39+13:00 (14 years ago)
Author:
davidb
Message:

Restructuring of code to support a web server version for Greenstone2 and well as Greenstone3

Location:
greenstone3/trunk/src/java/org/greenstone/server
Files:
14 added
4 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • greenstone3/trunk/src/java/org/greenstone/server/BrowserLauncher.java

    r13602 r18558  
    4141        // we use cmd and start
    4242        if (Misc.isWindows9x()) {
    43         this.command = StaticStrings.WIN_9X_OPEN_COMMAND;//"command.com /c start \""+url+"\"";
     43        this.command = BaseServer.Property.WIN_9X_OPEN_COMMAND;//"command.com /c start \""+url+"\"";
    4444        } else {
    45         this.command = StaticStrings.WIN_OPEN_COMMAND;//"cmd.exe /c start \"\" \""+url+"\"";
     45        this.command = BaseServer.Property.WIN_OPEN_COMMAND;//"cmd.exe /c start \"\" \""+url+"\"";
    4646        }
    4747    } else if (Misc.isMac()) {
    48         this.command = StaticStrings.MAC_OPEN_COMMAND; // "open %1"
     48        this.command = BaseServer.Property.MAC_OPEN_COMMAND; // "open %1"
    4949    } else {
    5050         // we try to look for a browser
  • greenstone3/trunk/src/java/org/greenstone/server/RunAnt.java

    r13602 r18558  
    11package org.greenstone.server;
    22
    3 import java.io.IOException;
    4 import java.io.BufferedReader;
    5 import java.io.InputStream;
    6 import java.io.InputStreamReader;
     3import org.greenstone.server.RunTarget;
    74
    8 import org.greenstone.server.StreamGobbler;
     5public class RunAnt extends RunTarget
     6{
     7    public RunAnt()
     8    {
     9    super();
    910
    10 import org.apache.log4j.*;
    11 
    12 public class RunAnt extends Thread {
    13     private String antCmd = "";
    14     static Logger logger = Logger.getLogger(org.greenstone.server.RunAnt.class.getName());
    15     private int state = -1; //success: 0 error: 1   
    16     public static int SUCCESS = 0;
    17     public static int FAILED = 1;
    18 
    19     private String antSuccess = "BUILD SUCCESSFUL";
    20     private String antFailed = "BUILD FAILED";
    21     private String antFinished = "Total time";
    22 
    23     public void run() {
    24      
    25      try {
    26          state = -1;
    27          Runtime run = Runtime.getRuntime();
    28              Process process = run.exec(getAntCmd());
    29          BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
    30          String line = null;
    31              while (!(line = br.readLine()).startsWith(antFinished)){
    32                  
    33          if (line.equals(antSuccess)){
    34              state = 0;
    35          }
    36      
    37          if (line.equals(antFailed)){
    38              state = 1;
    39                   }
    40          logger.info(line);
    41          }   
    42      } catch (Exception e) {
    43          logger.error(e);
    44          state = 1;
    45      }
    46     }
    47  
    48     public int getAntState(){
    49     return state;     
     11    targetSuccess  = "BUILD SUCCESSFUL";
     12    targetFailed   = "BUILD FAILED";
     13    targetFinished = "Total time";
    5014    }
    5115   
    52     public void setAntCmd(String cmd) {
     16    public void setTargetCmd(String target)
     17    {
    5318    String osName = System.getProperty("os.name");
    5419        if (osName.startsWith("Windows")) {
    55         this.antCmd = "ant.bat " + cmd;
     20        targetCmd = "ant.bat " + target;
    5621    } else {
    57         this.antCmd = "ant " + cmd;
     22        targetCmd = "ant " + target;
    5823    }
    5924    }
    60 
    61     public String getAntCmd() {
    62     return this.antCmd;
    63     }
    6425}
Note: See TracChangeset for help on using the changeset viewer.