1 37 package net.sourceforge.cruisecontrol.publishers; 38 39 import net.sourceforge.cruisecontrol.CruiseControlException; 40 import net.sourceforge.cruisecontrol.Publisher; 41 import net.sourceforge.cruisecontrol.util.CurrentBuildFileWriter; 42 import net.sourceforge.cruisecontrol.util.ValidationHelper; 43 import net.sourceforge.cruisecontrol.util.XMLLogHelper; 44 import org.apache.log4j.Logger; 45 import org.jdom.Element; 46 47 import java.util.Date ; 48 49 58 public class CurrentBuildStatusPublisher implements Publisher { 59 private static final Logger LOG = Logger.getLogger(CurrentBuildStatusPublisher.class); 60 61 private String fileName; 62 63 public CurrentBuildStatusPublisher() { 64 LOG.warn("CurrentBuildStatusPublisher was obsoleted by CurrentBuildStatusListener"); 65 } 66 67 public void setFile(String fileName) { 68 this.fileName = fileName; 69 } 70 71 public void validate() throws CruiseControlException { 72 ValidationHelper.assertIsSet(fileName, "file", this.getClass()); 73 CurrentBuildFileWriter.validate(fileName); 74 } 75 76 public void publish(Element cruisecontrolLog) throws CruiseControlException { 77 XMLLogHelper helper = new XMLLogHelper(cruisecontrolLog); 78 long interval = Long.parseLong(helper.getCruiseControlInfoProperty("interval")); 79 writeFile(new Date (), interval); 80 } 81 82 protected void writeFile(Date date, long interval) throws CruiseControlException { 83 Date datePlusInterval = new Date (date.getTime() + (interval * 1000)); 84 CurrentBuildFileWriter.writefile("Next Build Starts At:\n", datePlusInterval, fileName); 85 } 86 } 87 | Popular Tags |