Revert of wrong fix for GROOVY-2138
[groovy.git] / cruise / reporting-app / index.jsp
blobd2caeab1fa13fa16ddfbe6ddd973c3da9d7a6a43
1 <%@ page import="java.io.File,
2 java.util.Arrays,
3 java.util.Calendar"%>
4 <%--********************************************************************************
5 * CruiseControl, a Continuous Integration Toolkit
6 * Copyright (c) 2001, ThoughtWorks, Inc.
7 * 651 W Washington Ave. Suite 600
8 * Chicago, IL 60661 USA
9 * All rights reserved.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
15 * + Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
18 * + Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials provided
21 * with the distribution.
23 * + Neither the name of ThoughtWorks, Inc., CruiseControl, nor the
24 * names of its contributors may be used to endorse or promote
25 * products derived from this software without specific prior
26 * written permission.
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
32 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 ********************************************************************************--%>
40 <jsp:useBean id="statusHelper" scope="page" class="net.sourceforge.cruisecontrol.StatusHelper" />
42 String singleProjectMode = application.getInitParameter("singleProject");
43 if (Boolean.valueOf(singleProjectMode).booleanValue()) {
44 %><jsp:forward page="buildresults" /><%
45 return;
48 StringBuffer reportTime = new StringBuffer();
49 Calendar now = Calendar.getInstance();
50 reportTime.append(now.get(Calendar.HOUR_OF_DAY));
51 reportTime.append(":");
52 String minutes = String.valueOf(now.get(Calendar.MINUTE));
53 if (minutes.length() == 1) {
54 minutes = 0 + minutes;
56 reportTime.append(minutes);
58 boolean autoRefresh = "true".equals(request.getParameter("auto_refresh"));
60 <html>
61 <head>
62 <title>CruiseControl Status Page</title>
63 <base href="<%=request.getScheme()%>://<%=request.getServerName()%>:<%=request.getServerPort()%><%=request.getContextPath()%>/" />
64 <link type="text/css" rel="stylesheet" href="css/cruisecontrol.css"/>
66 if (autoRefresh) {
68 <META HTTP-EQUIV="Refresh" CONTENT="10">
72 </head>
73 <body background="images/bluebg.gif" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
74 <p>&nbsp;</p>
76 <h1 class="white" align="center">CruiseControl Status Page</h1>
78 <table align="center" border="0" cellpadding="0" cellspacing="0" width="70%">
79 <tfoot>
80 <tr><td class="link">listing generated at <%=reportTime.toString()%></td></tr>
81 </tfoot>
82 <tbody>
83 <tr><td align="right">
85 if (autoRefresh) {
87 <a class="white" href="?auto_refresh=false">Turn autorefresh off</a>
89 } else {
91 <a class="white" href="?auto_refresh=true">Turn autorefresh on</a>
95 </td></tr>
96 <tr><td>&nbsp;</td></tr>
97 <tr><td bgcolor="#FFFFFF"><img border="0" src="images/bluestripestop.gif"></td></tr>
98 <tr><td><table class="index" width="100%">
100 String logDirPath = application.getInitParameter("logDir");
101 if (logDirPath == null) {
102 %><tr><td>You need to provide a value for the context parameter <code>&quot;logDir&quot;</code></td></tr><%
103 } else {
104 java.io.File logDir = new java.io.File(logDirPath);
105 if (logDir.isDirectory() == false) {
106 %><tr><td>Context parameter logDir needs to be set to a directory. Currently set to &quot;<%=logDirPath%>&quot;</td></tr><%
107 } else {
108 String[] projectDirs = logDir.list(new java.io.FilenameFilter() {
109 public boolean accept(File dir, String name) {
110 return (new File(dir, name).isDirectory());
114 if (projectDirs.length == 0) {
115 %><tr><td>no project directories found under <%=logDirPath%></td></tr><%
117 else {
118 %> <thead class="index-header">
119 <tr>
120 <td>Project</td>
121 <td align="center">Last build result</td>
122 <td align="center">Last build time</td>
123 <td align="center">Last successful build time</td>
124 <td align="center">Last label</td>
125 </tr>
126 </thead>
127 <tbody>
129 Arrays.sort(projectDirs);
130 for (int i = 0; i < projectDirs.length; i++) {
131 String project = projectDirs[i];
132 File projectDir = new File(logDir, project);
133 statusHelper.setProjectDirectory(projectDir);
134 final String result = statusHelper.getLastBuildResult();
135 %> <tr><td><a href="buildresults/<%=project%>"><%=project%></a></td><%
136 %><td class="index-<%=result%>" align="center"><%=result%></td><%
137 %><td align="center"><%=statusHelper.getLastBuildTimeString(request.getLocale())%></td><%
138 %><td align="center"><%=statusHelper.getLastSuccessfulBuildTimeString(request.getLocale())%></td><%
139 %><td><%=statusHelper.getLastSuccessfulBuildLabel()%></td>
140 </tr>
143 %> </tbody>
148 %></table></td></tr>
149 <tr><td bgcolor="#FFFFFF"><img border="0" src="images/bluestripesbottom.gif"></td></tr>
150 <tr><td>&nbsp;</td></tr>
151 </tbody>
152 </table>
153 </body>
154 </html>