1 37 package net.sourceforge.cruisecontrol.bootstrappers; 38 39 import java.io.PrintWriter ; 40 41 import net.sourceforge.cruisecontrol.Bootstrapper; 42 import net.sourceforge.cruisecontrol.CruiseControlException; 43 import net.sourceforge.cruisecontrol.util.Commandline; 44 import net.sourceforge.cruisecontrol.util.StreamPumper; 45 46 import org.apache.log4j.Logger; 47 48 64 public class SnapshotCMBootstrapper implements Bootstrapper { 65 66 67 private static final Logger LOG = Logger.getLogger(SnapshotCMBootstrapper.class); 68 69 72 private String filename; 73 74 75 public void setFile(String name) { 76 filename = name; 77 } 78 79 82 public void bootstrap() { 83 Commandline commandLine = buildUpdateCommand(); 84 85 if (LOG.isDebugEnabled()) { 86 LOG.debug("Executing: " + commandLine.toString()); 87 } 88 try { 89 Process p = Runtime.getRuntime().exec(commandLine.getCommandline()); 90 StreamPumper errorPumper = 91 new StreamPumper(p.getErrorStream(), new PrintWriter (System.err, true)); 92 new Thread (errorPumper).start(); 93 p.waitFor(); 94 p.getInputStream().close(); 95 p.getOutputStream().close(); 96 p.getErrorStream().close(); 97 } catch (Exception e) { 98 LOG.error("Error executing SnapshotCM update command", e); 99 } 100 } 101 102 public void validate() throws CruiseControlException { 103 if (filename == null) { 104 throw new CruiseControlException("'file' is required for SnapshotCMBootstrapper"); 105 } 106 } 107 108 protected Commandline buildUpdateCommand() { 109 Commandline commandLine = new Commandline(); 110 commandLine.setExecutable("wco"); 111 112 commandLine.createArgument().setValue("-fR"); 113 commandLine.createArgument().setValue(filename); 114 115 return commandLine; 116 } 117 118 } 119 | Popular Tags |