Add servlet for public usage stats display.
authorpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Fri, 1 Jul 2011 10:59:53 +0000 (10:59 +0000)
committerpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Fri, 1 Jul 2011 10:59:53 +0000 (10:59 +0000)
git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@4384 e3abac25-378b-4346-85de-24260fe3988d

TODO.txt
WEB-INF/web.xml
statpages/MonthlySummary.jsp
webservices/compbio/stat/servlet/AnnualStat.java

index 67dc7b9..d502d48 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -1,7 +1,7 @@
 JABA 1 is to keep working, later when 2 is ready replace jabaws mapping to point to \r
 JABA 2 but provide a link to JABA 1.  \r
 \r
-install JABA 1 stat server \r
++install JABA 1 stat server \r
 \r
 +Get path to Java executable from JAVA_HOME ? (for Jronn AACon) \r
 +Describe requirements \r
index 4c01fb9..e9b1b39 100644 (file)
        <servlet-class>compbio.stat.servlet.AnnualStat</servlet-class>\r
     </servlet>\r
     \r
+     <servlet>\r
+       <description>Display monthly summary statistics with no links to details</description>\r
+       <servlet-name>PublicAnnualStat</servlet-name>\r
+       <servlet-class>compbio.stat.servlet.AnnualStat</servlet-class>\r
+    </servlet>\r
+    \r
     <servlet>\r
         <servlet-name>RegistryWS</servlet-name>\r
         <servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>\r
        <url-pattern>/AnnualStat</url-pattern>\r
        </servlet-mapping>  \r
     \r
+     <servlet-mapping>\r
+       <servlet-name>PublicAnnualStat</servlet-name>\r
+       <url-pattern>/PublicAnnualStat</url-pattern>\r
+       </servlet-mapping>  \r
+    \r
+    \r
     <servlet-mapping>\r
        <servlet-name>Joblist</servlet-name>\r
        <url-pattern>/Joblist</url-pattern>\r
index d69db5a..81db03a 100644 (file)
@@ -37,7 +37,17 @@ Date: May 2011
        </c:otherwise>\r
 </c:choose>\r
 \r
-<td><a title="Click to view the detailed statistics for the period" href="DisplayStat?datetime=${monthTotal.key.time}"><fmt:formatDate value="${monthTotal.key}" type="date" pattern="MMM yyyy"/></a></td>\r
+<td>\r
+<c:choose>\r
+<c:when test="${isAdmin}">\r
+  <a title="Click to view the detailed statistics for the period" href="DisplayStat?datetime=${monthTotal.key.time}"><fmt:formatDate value="${monthTotal.key}" type="date" pattern="MMM yyyy"/></a>\r
+</c:when>\r
+<c:otherwise>\r
+   <fmt:formatDate value="${monthTotal.key}" type="date" pattern="MMM yyyy"/>\r
+</c:otherwise>\r
+</c:choose>\r
+\r
+</td>\r
 <td>${monthTotal.value.total}</td>\r
 <td>${monthTotal.value.incomplete}</td>\r
 <td>${monthTotal.value.cancelled}</td>\r
@@ -70,5 +80,9 @@ For each month the table contains the following information.
 </ul>\r
 The summary for each column is displayed in the last row of the table.\r
 </div> <!-- Help text enclosing dev end -->\r
+<c:if test="${!isAdmin}">\r
+<br/><p><a href="AnnualStat">Please login as administrator</a> to view the detailed statistics (<a href=man_usagestats.html#helpUsageStats>help</a>)</p>\r
+</c:if>\r
+\r
 </div> <!-- page enclosing div end -->\r
 <jsp:include page="footer.jsp" />
\ No newline at end of file
index cc3db41..e1baf12 100644 (file)
@@ -40,6 +40,8 @@ public class AnnualStat extends HttpServlet {
 \r
                        RequestDispatcher dispatcher = req\r
                                        .getRequestDispatcher("statpages/MonthlySummary.jsp");\r
+\r
+                       req.setAttribute("isAdmin", isAdmin(req));\r
                        dispatcher.forward(req, resp);\r
 \r
                } catch (SQLException e) {\r
@@ -48,4 +50,8 @@ public class AnnualStat extends HttpServlet {
                }\r
        }\r
 \r
+       static boolean isAdmin(final HttpServletRequest request) {\r
+               return request.isUserInRole("admin");\r
+       }\r
+\r
 }\r