1 37 package net.sourceforge.cruisecontrol.bootstrappers; 38 39 import java.util.Date ; 40 import java.io.File ; 41 import java.io.IOException ; 42 43 import net.sourceforge.cruisecontrol.Bootstrapper; 44 import net.sourceforge.cruisecontrol.util.AbstractFTPClass; 45 import net.sourceforge.cruisecontrol.util.ValidationHelper; 46 import net.sourceforge.cruisecontrol.CruiseControlException; 47 import net.sourceforge.cruisecontrol.util.CurrentBuildFileWriter; 48 import net.sourceforge.cruisecontrol.util.Util; 49 import org.apache.log4j.Logger; 50 51 52 57 public class CurrentBuildStatusFTPBootstrapper extends AbstractFTPClass 58 implements Bootstrapper { 59 private static final Logger LOG = Logger.getLogger(CurrentBuildStatusFTPBootstrapper.class); 60 61 private String fileName; 62 private String destdir; 63 64 public CurrentBuildStatusFTPBootstrapper() { 65 LOG.warn("CurrentBuildStatusFTPBootstrapper was obsoleted by CurrentBuildStatusFTPListener"); 66 } 67 68 public void setFile(String fileName) { 69 this.fileName = fileName; 70 } 71 72 73 public void setDestDir(String dir) { 74 this.destdir = dir; 75 } 76 77 78 public void bootstrap() throws CruiseControlException { 79 String out = makeFile(); 80 String fname = destdir + File.separator + fileName; 81 82 sendFileToFTPPath(out, fname); 83 } 84 85 86 protected String makeFile() 87 throws CruiseControlException { 88 CurrentBuildFileWriter.writefile( 89 "Current Build Started At:\n", 90 new Date (), 91 fileName); 92 93 try { 94 return Util.readFileToString(fileName); 95 } catch (IOException ioe) { 96 throw new CruiseControlException(ioe.getMessage()); 97 } 98 } 99 100 124 125 126 public void validate() throws CruiseControlException { 127 ValidationHelper.assertIsSet(fileName, "file", this.getClass()); 128 ValidationHelper.assertIsSet(destdir, "destdir", this.getClass()); 129 super.validate(); 130 } 131 132 } 133 | Popular Tags |