1 37 38 package net.sourceforge.cruisecontrol.taglib; 39 40 import java.io.IOException ; 41 import java.io.Writer ; 42 import javax.servlet.jsp.JspException ; 43 44 import net.sourceforge.cruisecontrol.BuildStatus; 45 import net.sourceforge.cruisecontrol.util.CCTagException; 46 47 53 public class CurrentBuildStatusTag extends CruiseControlTagSupport { 54 55 private boolean insertBreaks = true; 56 57 public int doEndTag() throws JspException { 58 boolean isSingleProject = isSingleProject(); 59 String logDir = getBaseLogDir(); 60 String projectName = getProject(); 61 String currentBuildFileName = getFileName(); 62 63 String status = null; 64 65 if (insertBreaks) { 66 status = BuildStatus.getStatusHtml(isSingleProject, logDir, projectName, currentBuildFileName, 67 BuildStatus.READ_ALL_LINES); 68 } else { 69 status = BuildStatus.getStatusPlain(isSingleProject, logDir, projectName, currentBuildFileName, 70 BuildStatus.READ_ALL_LINES); 71 } 72 73 Writer out = getPageContext().getOut(); 74 75 try { 76 out.write(status); 77 } catch (IOException e) { 78 err(e); 79 throw new CCTagException("Error writing status to JSP out: " + e.getMessage(), e); 80 } 81 82 return EVAL_PAGE; 83 } 84 85 public void setInsertBreaks(boolean insertBreaks) { 86 this.insertBreaks = insertBreaks; 87 } 88 89 private String getFileName() { 90 String currentBuildFileName = getContextParam("currentBuildStatusFile"); 91 if (currentBuildFileName == null || currentBuildFileName.equals("")) { 92 err("CruiseControl: currentBuildStatusFile not defined in the web.xml"); 93 return null; 94 } 95 return currentBuildFileName; 96 } 97 } 98 | Popular Tags |