geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vamsic...@apache.org
Subject svn commit: r490685 - in /geronimo/server: branches/1.1/applications/console-framework/src/webapp/js/ branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/logmanager/ branches/1.1/applications/console-standard/src/webapp/WEB-...
Date Thu, 28 Dec 2006 09:39:56 GMT
Author: vamsic007
Date: Thu Dec 28 01:39:54 2006
New Revision: 490685

URL: http://svn.apache.org/viewvc?view=rev&rev=490685
Log:
GERONIMO-1749 Server Logs portlet - Web Access Log Viewer improvements
  o Improved upon the patch submitted by Rakesh Midha.  Thanks Rakesh.
  o Added PUT and DELETE to request method
  o Date select box does not refresh properly upon changing the year.  Replaced select box with text field.
  o Validate the dates and date range
  o Support max results and start result to enable result browsing

Modified:
    geronimo/server/branches/1.1/applications/console-framework/src/webapp/js/forms.js
    geronimo/server/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java
    geronimo/server/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/webaccesslogmanager/view.jsp
    geronimo/server/branches/1.2/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java
    geronimo/server/branches/1.2/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/webaccesslogmanager/view.jsp
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/webaccesslogmanager/view.jsp

Modified: geronimo/server/branches/1.1/applications/console-framework/src/webapp/js/forms.js
URL: http://svn.apache.org/viewvc/geronimo/server/branches/1.1/applications/console-framework/src/webapp/js/forms.js?view=diff&rev=490685&r1=490684&r2=490685
==============================================================================
--- geronimo/server/branches/1.1/applications/console-framework/src/webapp/js/forms.js (original)
+++ geronimo/server/branches/1.1/applications/console-framework/src/webapp/js/forms.js Thu Dec 28 01:39:54 2006
@@ -31,4 +31,22 @@
     }
     return true;
 }
-    
\ No newline at end of file
+
+function checkDateMMDDYYYY(formName, elementName) {
+    var obj = eval("document.forms['" + formName + "'].elements['"+ elementName +"']");
+    if(validDateMMDDYYYY(obj.value)) return true;
+    else{
+        alert(elementName + " must be a date in MM/DD/YYYY format.");
+        obj.focus();
+        return false;
+    }
+}
+
+function validDateMMDDYYYY(inpDate) {
+    var d0 = new Date(inpDate);
+    var mm = (d0.getMonth() < 9 ? '0' : '') + (d0.getMonth()+1);
+    var dd = (d0.getDate() < 10 ? '0' : '') + d0.getDate();
+    var yyyy = d0.getFullYear();
+    var d1 = mm+'/'+dd+'/'+yyyy;
+    return inpDate == d1;
+}

Modified: geronimo/server/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java?view=diff&rev=490685&r1=490684&r2=490685
==============================================================================
--- geronimo/server/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java (original)
+++ geronimo/server/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java Thu Dec 28 01:39:54 2006
@@ -37,12 +37,20 @@
 import javax.portlet.RenderResponse;
 import javax.portlet.WindowState;
 import java.io.IOException;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.Calendar;
+import java.util.Date;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
+/**
+ * @version $Rev$ $Date$
+ */
 public class WebAccessLogViewerPortlet extends BasePortlet {
     private final static Log log = LogFactory.getLog(WebAccessLogViewerPortlet.class);
+    private static final int DEFAULT_MAX_RESULTS = 10;
 
     protected PortletRequestDispatcher searchView;
 
@@ -121,20 +129,13 @@
             //todo: currently refreshes on every request; that's pretty slow.
         }
 
-
-        //todo: completely revamp this argument processing
-        String startDate = (String) renderRequest.getParameter("startDate");
-        String startMonth = (String) renderRequest.getParameter("startMonth");
-        String startYear = (String) renderRequest.getParameter("startYear");
-        String endDate = (String) renderRequest.getParameter("endDate");
-        String endMonth = (String) renderRequest.getParameter("endMonth");
-        String endYear = (String) renderRequest.getParameter("endYear");
+        String fromDateStr = (String) renderRequest.getParameter("fromDate");
+        String toDateStr = (String) renderRequest.getParameter("toDate");
 
         Calendar cal1 = Calendar.getInstance(), cal2 = Calendar.getInstance();
         // If not all dates were passed we assume than no fields were passed and just
         // filter on the current date.
-        if (startDate == null || startMonth == null || startYear == null
-                || endDate == null || endMonth == null || endYear == null) {
+        if(fromDateStr == null || toDateStr == null) {
             // just keep the month date and year
             cal1.set(Calendar.MILLISECOND, 0);
             cal1.set(Calendar.MINUTE, 0);
@@ -147,38 +148,82 @@
             cal2.set(Calendar.MILLISECOND, cal2.getMaximum(Calendar.MILLISECOND));
 
             WebAccessLog.SearchResults matchingItems = chosenLog.getMatchingItems(logToSearch,
-                                        null, null, null, null, cal1.getTime(), cal2.getTime(), null, null);
+                                        null, null, null, null, cal1.getTime(), cal2.getTime(), null, new Integer(DEFAULT_MAX_RESULTS - 1));
             renderRequest.setAttribute("logs", matchingItems.getResults());
             renderRequest.setAttribute("logLength", new Integer(matchingItems.getLineCount()));
+            renderRequest.setAttribute("maxResult", new Integer(DEFAULT_MAX_RESULTS));
         } else {
-            cal1.clear();
-            cal2.clear();
-            // get the requested start date (defaults to 00:00:00:000 for time
-            cal1.set(Calendar.DATE, Integer.parseInt(startDate));
-            cal1.set(Calendar.MONTH, Integer.parseInt(startMonth));
-            cal1.set(Calendar.YEAR, Integer.parseInt(startYear));
-            // get the requested end date - Note: must set time to end of day
-            cal2.set(Calendar.DATE, Integer.parseInt(endDate));
-            cal2.set(Calendar.MONTH, Integer.parseInt(endMonth));
-            cal2.set(Calendar.YEAR, Integer.parseInt(endYear));
-            cal2.set(Calendar.HOUR_OF_DAY, cal2.getMaximum(Calendar.HOUR_OF_DAY));
-            cal2.set(Calendar.MINUTE, cal2.getMaximum(Calendar.MINUTE));
-            cal2.set(Calendar.SECOND, cal2.getMaximum(Calendar.SECOND));
-            cal2.set(Calendar.MILLISECOND, cal2.getMaximum(Calendar.MILLISECOND));
             // Get other search criteria
             String requestHost = (String) renderRequest.getParameter("requestHost");
             String authUser = (String) renderRequest.getParameter("authUser");
             String requestMethod = (String) renderRequest.getParameter("requestMethod");
             String requestedURI = (String) renderRequest.getParameter("requestedURI");
+            String startResult = (String) renderRequest.getParameter("startResult");
+            String maxResult = (String) renderRequest.getParameter("maxResult");
+            Integer iStartResult = null;
+            Integer iMaxResult = new Integer(DEFAULT_MAX_RESULTS);
+            try{
+                iStartResult = Integer.valueOf(startResult);
+            }catch(NumberFormatException e){
+                //ignore
+            }
+            try{
+                iMaxResult = Integer.valueOf(maxResult);
+            }catch(NumberFormatException e){
+                //ignore
+            }
+            
             boolean ignoreDates = renderRequest.getParameter("ignoreDates") != null;
             if (ignoreDates) {
                 WebAccessLog.SearchResults matchingItems = chosenLog.getMatchingItems(logToSearch,
-                                                requestHost, authUser, requestMethod, requestedURI, null, null, null, null);
+                                                requestHost, authUser, requestMethod, requestedURI, null, null, iStartResult, new Integer(iMaxResult.intValue()-1));
                 renderRequest.setAttribute("logs", matchingItems.getResults());
                 renderRequest.setAttribute("logLength", new Integer(matchingItems.getLineCount()));
             } else {
+                Date fromDate = null, toDate = null;
+                // Check if the from and to date format is MM/DD/YYYY
+                DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
+                try {
+                    fromDate = df.parse(fromDateStr);
+                    // get the requested start date (defaults to 00:00:00:000 for time)
+                    cal1.setTime(fromDate);
+                    String mmddyyyy = (cal1.get(Calendar.MONTH) < 9 ? "0":"") + (cal1.get(Calendar.MONTH)+1);
+                    mmddyyyy += "/"+(cal1.get(Calendar.DAY_OF_MONTH) < 10 ? "0":"") + (cal1.get(Calendar.DAY_OF_MONTH));
+                    mmddyyyy += "/"+cal1.get(Calendar.YEAR);
+                    if(!mmddyyyy.equals(fromDateStr)) {
+                        // This should not arise since date input has been validated using javascript.
+                        // If this does occur, ignore dates in search criteria and log a WARNING
+                        log.warn("From date must be a date in MM/DD/YYYY format, not '"+fromDateStr+"'. Dates will be ignored.");
+                        fromDate = null;
+                    }
+                    toDate = df.parse(toDateStr);
+                    cal2.setTime(toDate);
+                    mmddyyyy = (cal2.get(Calendar.MONTH) < 9 ? "0":"") + (cal2.get(Calendar.MONTH)+1);
+                    mmddyyyy += "/"+(cal2.get(Calendar.DAY_OF_MONTH) < 10 ? "0":"") + (cal2.get(Calendar.DAY_OF_MONTH));
+                    mmddyyyy += "/"+cal2.get(Calendar.YEAR);
+                    if(!mmddyyyy.equals(toDateStr)) {
+                        // This should not arise since date input has been validated using javascript.
+                        // If this does occur, ignore to date in search criteria and log a WARNING
+                        log.warn("To date must be a date in MM/DD/YYYY format, not "+toDateStr+"'. Dates will be ignored.");
+                        toDate = null;
+                    } else {
+                        // get the requested end date - Note: must set time to end of day
+                        cal2.set(Calendar.HOUR_OF_DAY, cal2.getMaximum(Calendar.HOUR_OF_DAY));
+                        cal2.set(Calendar.MINUTE, cal2.getMaximum(Calendar.MINUTE));
+                        cal2.set(Calendar.SECOND, cal2.getMaximum(Calendar.SECOND));
+                        cal2.set(Calendar.MILLISECOND, cal2.getMaximum(Calendar.MILLISECOND));
+                        toDate = cal2.getTime();
+                    }
+                } catch (ParseException e) {
+                    // Should not occur since date input has been validated using javascript.
+                    // If this does occur, ignore from and to dates and log a WARNING
+                    log.warn("Error parsing input dates.  Dates will be ignored.", e);
+                }
+                if(fromDate == null || toDate == null) {
+                    fromDate = toDate = null;
+                }
                 WebAccessLog.SearchResults matchingItems = chosenLog.getMatchingItems(logToSearch,
-                                                requestHost, authUser, requestMethod, requestedURI, cal1.getTime(), cal2.getTime(), null, null);
+                                                requestHost, authUser, requestMethod, requestedURI, fromDate, toDate, iStartResult, new Integer(iMaxResult.intValue()-1));
                 renderRequest.setAttribute("logs", matchingItems.getResults());
                 renderRequest.setAttribute("logLength", new Integer(matchingItems.getLineCount()));
             }
@@ -187,10 +232,11 @@
             renderRequest.setAttribute("authUser", authUser);
             renderRequest.setAttribute("requestMethod", requestMethod);
             renderRequest.setAttribute("requestedURI", requestedURI);
-
+            if(iStartResult != null)renderRequest.setAttribute("startResult", iStartResult);
+            if(iMaxResult != null)renderRequest.setAttribute("maxResult", iMaxResult);
         }
-        renderRequest.setAttribute("toDate", cal2.getTime());
-        renderRequest.setAttribute("fromDate", cal1.getTime());
+        renderRequest.setAttribute("toDate", toDateStr);
+        renderRequest.setAttribute("fromDate", fromDateStr);
         searchView.include(renderRequest, renderRespose);
     }
 

Modified: geronimo/server/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/webaccesslogmanager/view.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/webaccesslogmanager/view.jsp?view=diff&rev=490685&r1=490684&r2=490685
==============================================================================
--- geronimo/server/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/webaccesslogmanager/view.jsp (original)
+++ geronimo/server/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/webaccesslogmanager/view.jsp Thu Dec 28 01:39:54 2006
@@ -1,39 +1,46 @@
+<%--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+--%>
+
+<%-- $Rev$ $Date$ --%>
+
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
 <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
-<%!
-java.util.Calendar cal = java.util.Calendar.getInstance();
-int startYear = 1990;
-int currentYear = cal.get(java.util.Calendar.YEAR);
-%>
 <script language="Javascript">
+var <portlet:namespace/>formName = "<portlet:namespace/>searchForm";
+var <portlet:namespace/>dateFields = new Array("fromDate", "toDate");
 
-function <portlet:namespace/>loadDates(monthElemName,dateElemName,yearElemName){
-    var yearElem = eval("document.<portlet:namespace/>searchForm." + yearElemName);
-    var monthElem = eval("document.<portlet:namespace/>searchForm." + monthElemName);
-    var dateElem = eval("document.<portlet:namespace/>searchForm." + dateElemName);
-    var monthIndex = parseInt(monthElem.options[monthElem.selectedIndex].value);
-    var selectedYear = parseInt(yearElem.options[yearElem.selectedIndex].value);
-    var totalDays = 0;
-    // February
-    if(monthIndex == 1){
-        totalDays = (isLeapYear(selectedYear)? 29 : 28) 
-    }else if(monthIndex == 0 || monthIndex == 2 || monthIndex == 4 || monthIndex == 6 || monthIndex == 7 ||
-            monthIndex == 9 || monthIndex == 11){
-        totalDays = 31;
-    }else{
-        totalDays = 30;
+function <portlet:namespace/>validateForm(){
+    if(document.forms[<portlet:namespace/>formName].ignoreDates.checked)
+        return true;
+    for(i in <portlet:namespace/>dateFields) {
+        if(!checkDateMMDDYYYY(<portlet:namespace/>formName, <portlet:namespace/>dateFields[i]))
+            return false;
     }
-    dateElem.options.length = 0;
-    for(i = 0; i < totalDays; i++){
-        dateElem.options.length += 1; 
-        dateElem.options[i].text = dateElem.options[i].value = i+1;        
-    }            
+    // Check if to date is after from date
+    var fromDate = new Date(document.forms[<portlet:namespace/>formName].fromDate.value);
+    var toDate = new Date(document.forms[<portlet:namespace/>formName].toDate.value);
+    if(fromDate > toDate) {
+        alert('to date must be after from date.');
+        return false;
+    }
+    return true;
 }
 
-function isLeapYear(year) {
-    return (year%4 == 0 && (year % 100 != 0 || year % 400 == 0));
-}
 function <portlet:namespace/>refresh(){
     document.<portlet:namespace/>searchForm.action="<portlet:renderURL><portlet:param name="action" value="refresh"/></portlet:renderURL>";
     document.<portlet:namespace/>searchForm.submit();
@@ -47,7 +54,7 @@
 </tr>
 <tr>
     <td>
-    <form action="<portlet:renderURL/>" name="<portlet:namespace/>searchForm" method="post">
+    <form action="<portlet:renderURL/>" name="<portlet:namespace/>searchForm" method="post" onSubmit="return <portlet:namespace/>validateForm();">
     <b>Filter results:</b>
     <table width="680">
     <c:choose>
@@ -100,50 +107,10 @@
             <td colspan="4" class="DarkBackground"><b>Date:</b></td>
         </tr>
         <tr>
-            <td>From:</td>
-            <td>
-                <select name="startMonth" onchange="<portlet:namespace/>loadDates('startMonth','startDate','startYear');">
-                    <option value="0">January</option><option value="1">February</option>
-                    <option value="2">March</option><option value="3">April</option>
-                    <option value="4">May</option><option value="5">June</option>
-                    <option value="6">July</option><option value="7">August</option>
-                    <option value="8">September</option><option value="9">October</option>
-                    <option value="10">November</option><option value="11">December</option>
-                </select>
-                /
-                <select name="startDate">
-                </select>
-                /
-                <select name="startYear">
-                <%
-                for(int i = startYear;i <= currentYear; i++){
-                %>
-                <option value="<%=i%>"><%=i%></option>
-                <%}%>
-                </select>
-            </td>
-            <td>To:</td>
-            <td>
-                <select name="endMonth" onchange="<portlet:namespace/>loadDates('endMonth','endDate','endYear');">
-                    <option value="0">January</option><option value="1">February</option>
-                    <option value="2">March</option><option value="3">April</option>
-                    <option value="4">May</option><option value="5">June</option>
-                    <option value="6">July</option><option value="7">August</option>
-                    <option value="8">September</option><option value="9">October</option>
-                    <option value="10">November</option><option value="11">December</option>
-                </select>
-                /
-                <select name="endDate">
-                </select>
-                /
-                <select name="endYear">
-                    <%
-                    for(int i = startYear;i <= currentYear; i++){
-                    %>
-                    <option value="<%=i%>"><%=i%></option>
-                    <%}%>
-                </select>
-            </td>
+            <td>From (MM/DD/YYYY):</td>
+            <td><input type="text" name="fromDate" value="${fromDate}"></td>
+            <td>To (MM/DD/YYYY):</td>
+            <td><input type="text" name="toDate" value="${toDate}"></td>
         </tr>
         <tr>
             <td>Ignore Dates:</td>
@@ -170,10 +137,22 @@
                     <option value="" <c:if test="${empty requestMethod or requestMethod eq ''}"> selected</c:if>>ANY</option>
                     <option <c:if test="${requestMethod == 'GET'}"> selected</c:if>>GET</option>
                     <option <c:if test="${requestMethod == 'POST'}"> selected</c:if>>POST</option>
+                    <option <c:if test="${requestMethod == 'PUT'}"> selected</c:if>>PUT</option>
+                    <option <c:if test="${requestMethod == 'DELETE'}"> selected</c:if>>DELETE</option>
                 </select>
             </td>
             <td>Requested URI:</td>
             <td><input type="text" name="requestedURI" value="${requestedURI}"/></td>
+        </tr>
+        <tr>
+            <td colspan="4" class="DarkBackground"><b>Result Size:</b></td>
+        </tr>
+        <tr>
+            <td>Start Result:</td>
+            <td><input type="text" name="startResult" value="${startResult}"/></td>
+            <td>Max Results:</td>
+            <td><input type="text" name="maxResult" value="${maxResult}"/></td>
+        </tr>
         <tr>
             <td colspan="4" align="left">
                 <input type="submit" value="Go"/>
@@ -207,36 +186,3 @@
 </td>     
 </tr>
 </table>
-<script language="Javascript">
-var <portlet:namespace/>form = document.<portlet:namespace/>searchForm;
-<c:if test="${!empty fromDate}">
-<portlet:namespace/>form.startMonth.selectedIndex = ${fromDate.month};
-</c:if>
-<c:if test="${!empty toDate}">
-<portlet:namespace/>form.endMonth.selectedIndex = ${toDate.month};
-</c:if>
-<portlet:namespace/>loadDates('startMonth','startDate','startYear');
-<portlet:namespace/>loadDates('endMonth','endDate','endYear');
-<c:if test="${!empty fromDate}">
-<portlet:namespace/>form.startDate.selectedIndex = ${fromDate.date}-1;
-with(<portlet:namespace/>form){
-    for(var i = 0; i < startYear.options.length; i++){
-        if(startYear.options[i].value == ${fromDate.year} + 1900){
-            startYear.selectedIndex = i;
-            break;
-        }
-    }
-}
-</c:if>
-<c:if test="${!empty toDate}">
-<portlet:namespace/>form.endDate.selectedIndex = ${toDate.date}-1;
-with(<portlet:namespace/>form){
-    for(var i = 0; i < endYear.options.length; i++){
-        if(endYear.options[i].value == ${toDate.year} + 1900){
-            endYear.selectedIndex = i;
-            break;
-        }
-    }
-}
-</c:if>
-</script>
\ No newline at end of file

Modified: geronimo/server/branches/1.2/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/1.2/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java?view=diff&rev=490685&r1=490684&r2=490685
==============================================================================
--- geronimo/server/branches/1.2/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java (original)
+++ geronimo/server/branches/1.2/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java Thu Dec 28 01:39:54 2006
@@ -37,12 +37,20 @@
 import javax.portlet.RenderResponse;
 import javax.portlet.WindowState;
 import java.io.IOException;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.Calendar;
+import java.util.Date;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
+/**
+ * @version $Rev$ $Date$
+ */
 public class WebAccessLogViewerPortlet extends BasePortlet {
     private final static Log log = LogFactory.getLog(WebAccessLogViewerPortlet.class);
+    private static final int DEFAULT_MAX_RESULTS = 10;
 
     protected PortletRequestDispatcher searchView;
 
@@ -121,20 +129,13 @@
             //todo: currently refreshes on every request; that's pretty slow.
         }
 
-
-        //todo: completely revamp this argument processing
-        String startDate = (String) renderRequest.getParameter("startDate");
-        String startMonth = (String) renderRequest.getParameter("startMonth");
-        String startYear = (String) renderRequest.getParameter("startYear");
-        String endDate = (String) renderRequest.getParameter("endDate");
-        String endMonth = (String) renderRequest.getParameter("endMonth");
-        String endYear = (String) renderRequest.getParameter("endYear");
+        String fromDateStr = (String) renderRequest.getParameter("fromDate");
+        String toDateStr = (String) renderRequest.getParameter("toDate");
 
         Calendar cal1 = Calendar.getInstance(), cal2 = Calendar.getInstance();
         // If not all dates were passed we assume than no fields were passed and just
         // filter on the current date.
-        if (startDate == null || startMonth == null || startYear == null
-                || endDate == null || endMonth == null || endYear == null) {
+        if(fromDateStr == null || toDateStr == null) {
             // just keep the month date and year
             cal1.set(Calendar.MILLISECOND, 0);
             cal1.set(Calendar.MINUTE, 0);
@@ -147,38 +148,82 @@
             cal2.set(Calendar.MILLISECOND, cal2.getMaximum(Calendar.MILLISECOND));
 
             WebAccessLog.SearchResults matchingItems = chosenLog.getMatchingItems(logToSearch,
-                                        null, null, null, null, cal1.getTime(), cal2.getTime(), null, null);
+                                        null, null, null, null, cal1.getTime(), cal2.getTime(), null, Integer.valueOf(DEFAULT_MAX_RESULTS - 1));
             renderRequest.setAttribute("logs", matchingItems.getResults());
             renderRequest.setAttribute("logLength", new Integer(matchingItems.getLineCount()));
+            renderRequest.setAttribute("maxResult", Integer.valueOf(DEFAULT_MAX_RESULTS));
         } else {
-            cal1.clear();
-            cal2.clear();
-            // get the requested start date (defaults to 00:00:00:000 for time
-            cal1.set(Calendar.DATE, Integer.parseInt(startDate));
-            cal1.set(Calendar.MONTH, Integer.parseInt(startMonth));
-            cal1.set(Calendar.YEAR, Integer.parseInt(startYear));
-            // get the requested end date - Note: must set time to end of day
-            cal2.set(Calendar.DATE, Integer.parseInt(endDate));
-            cal2.set(Calendar.MONTH, Integer.parseInt(endMonth));
-            cal2.set(Calendar.YEAR, Integer.parseInt(endYear));
-            cal2.set(Calendar.HOUR_OF_DAY, cal2.getMaximum(Calendar.HOUR_OF_DAY));
-            cal2.set(Calendar.MINUTE, cal2.getMaximum(Calendar.MINUTE));
-            cal2.set(Calendar.SECOND, cal2.getMaximum(Calendar.SECOND));
-            cal2.set(Calendar.MILLISECOND, cal2.getMaximum(Calendar.MILLISECOND));
             // Get other search criteria
             String requestHost = (String) renderRequest.getParameter("requestHost");
             String authUser = (String) renderRequest.getParameter("authUser");
             String requestMethod = (String) renderRequest.getParameter("requestMethod");
             String requestedURI = (String) renderRequest.getParameter("requestedURI");
+            String startResult = (String) renderRequest.getParameter("startResult");
+            String maxResult = (String) renderRequest.getParameter("maxResult");
+            Integer iStartResult = null;
+            Integer iMaxResult = Integer.valueOf(DEFAULT_MAX_RESULTS);
+            try{
+                iStartResult = Integer.valueOf(startResult);
+            }catch(NumberFormatException e){
+                //ignore
+            }
+            try{
+                iMaxResult = Integer.valueOf(maxResult);
+            }catch(NumberFormatException e){
+                //ignore
+            }
+            
             boolean ignoreDates = renderRequest.getParameter("ignoreDates") != null;
             if (ignoreDates) {
                 WebAccessLog.SearchResults matchingItems = chosenLog.getMatchingItems(logToSearch,
-                                                requestHost, authUser, requestMethod, requestedURI, null, null, null, null);
+                                                requestHost, authUser, requestMethod, requestedURI, null, null, iStartResult, Integer.valueOf(iMaxResult.intValue()-1));
                 renderRequest.setAttribute("logs", matchingItems.getResults());
                 renderRequest.setAttribute("logLength", new Integer(matchingItems.getLineCount()));
             } else {
+                Date fromDate = null, toDate = null;
+                // Check if the from and to date format is MM/DD/YYYY
+                DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
+                try {
+                    fromDate = df.parse(fromDateStr);
+                    // get the requested start date (defaults to 00:00:00:000 for time)
+                    cal1.setTime(fromDate);
+                    String mmddyyyy = (cal1.get(Calendar.MONTH) < 9 ? "0":"") + (cal1.get(Calendar.MONTH)+1);
+                    mmddyyyy += "/"+(cal1.get(Calendar.DAY_OF_MONTH) < 10 ? "0":"") + (cal1.get(Calendar.DAY_OF_MONTH));
+                    mmddyyyy += "/"+cal1.get(Calendar.YEAR);
+                    if(!mmddyyyy.equals(fromDateStr)) {
+                        // This should not arise since date input has been validated using javascript.
+                        // If this does occur, ignore dates in search criteria and log a WARNING
+                        log.warn("From date must be a date in MM/DD/YYYY format, not '"+fromDateStr+"'. Dates will be ignored.");
+                        fromDate = null;
+                    }
+                    toDate = df.parse(toDateStr);
+                    cal2.setTime(toDate);
+                    mmddyyyy = (cal2.get(Calendar.MONTH) < 9 ? "0":"") + (cal2.get(Calendar.MONTH)+1);
+                    mmddyyyy += "/"+(cal2.get(Calendar.DAY_OF_MONTH) < 10 ? "0":"") + (cal2.get(Calendar.DAY_OF_MONTH));
+                    mmddyyyy += "/"+cal2.get(Calendar.YEAR);
+                    if(!mmddyyyy.equals(toDateStr)) {
+                        // This should not arise since date input has been validated using javascript.
+                        // If this does occur, ignore to date in search criteria and log a WARNING
+                        log.warn("To date must be a date in MM/DD/YYYY format, not "+toDateStr+"'. Dates will be ignored.");
+                        toDate = null;
+                    } else {
+                        // get the requested end date - Note: must set time to end of day
+                        cal2.set(Calendar.HOUR_OF_DAY, cal2.getMaximum(Calendar.HOUR_OF_DAY));
+                        cal2.set(Calendar.MINUTE, cal2.getMaximum(Calendar.MINUTE));
+                        cal2.set(Calendar.SECOND, cal2.getMaximum(Calendar.SECOND));
+                        cal2.set(Calendar.MILLISECOND, cal2.getMaximum(Calendar.MILLISECOND));
+                        toDate = cal2.getTime();
+                    }
+                } catch (ParseException e) {
+                    // Should not occur since date input has been validated using javascript.
+                    // If this does occur, ignore from and to dates and log a WARNING
+                    log.warn("Error parsing input dates.  Dates will be ignored.", e);
+                }
+                if(fromDate == null || toDate == null) {
+                    fromDate = toDate = null;
+                }
                 WebAccessLog.SearchResults matchingItems = chosenLog.getMatchingItems(logToSearch,
-                                                requestHost, authUser, requestMethod, requestedURI, cal1.getTime(), cal2.getTime(), null, null);
+                                                requestHost, authUser, requestMethod, requestedURI, fromDate, toDate, iStartResult, Integer.valueOf(iMaxResult.intValue()-1));
                 renderRequest.setAttribute("logs", matchingItems.getResults());
                 renderRequest.setAttribute("logLength", new Integer(matchingItems.getLineCount()));
             }
@@ -187,10 +232,11 @@
             renderRequest.setAttribute("authUser", authUser);
             renderRequest.setAttribute("requestMethod", requestMethod);
             renderRequest.setAttribute("requestedURI", requestedURI);
-
+            if(iStartResult != null)renderRequest.setAttribute("startResult", iStartResult);
+            if(iMaxResult != null)renderRequest.setAttribute("maxResult", iMaxResult);
         }
-        renderRequest.setAttribute("toDate", cal2.getTime());
-        renderRequest.setAttribute("fromDate", cal1.getTime());
+        renderRequest.setAttribute("toDate", toDateStr);
+        renderRequest.setAttribute("fromDate", fromDateStr);
         searchView.include(renderRequest, renderRespose);
     }
 

Modified: geronimo/server/branches/1.2/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/webaccesslogmanager/view.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/branches/1.2/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/webaccesslogmanager/view.jsp?view=diff&rev=490685&r1=490684&r2=490685
==============================================================================
--- geronimo/server/branches/1.2/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/webaccesslogmanager/view.jsp (original)
+++ geronimo/server/branches/1.2/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/webaccesslogmanager/view.jsp Thu Dec 28 01:39:54 2006
@@ -14,42 +14,33 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 --%>
+
+<%-- $Rev$ $Date$ --%>
+
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
 <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
-<%!
-java.util.Calendar cal = java.util.Calendar.getInstance();
-int startYear = 1990;
-int currentYear = cal.get(java.util.Calendar.YEAR);
-%>
 <script language="Javascript">
+var <portlet:namespace/>formName = "<portlet:namespace/>searchForm";
+var <portlet:namespace/>dateFields = new Array("fromDate", "toDate");
 
-function <portlet:namespace/>loadDates(monthElemName,dateElemName,yearElemName){
-    var yearElem = eval("document.<portlet:namespace/>searchForm." + yearElemName);
-    var monthElem = eval("document.<portlet:namespace/>searchForm." + monthElemName);
-    var dateElem = eval("document.<portlet:namespace/>searchForm." + dateElemName);
-    var monthIndex = parseInt(monthElem.options[monthElem.selectedIndex].value);
-    var selectedYear = parseInt(yearElem.options[yearElem.selectedIndex].value);
-    var totalDays = 0;
-    // February
-    if(monthIndex == 1){
-        totalDays = (isLeapYear(selectedYear)? 29 : 28) 
-    }else if(monthIndex == 0 || monthIndex == 2 || monthIndex == 4 || monthIndex == 6 || monthIndex == 7 ||
-            monthIndex == 9 || monthIndex == 11){
-        totalDays = 31;
-    }else{
-        totalDays = 30;
+function <portlet:namespace/>validateForm(){
+    if(document.forms[<portlet:namespace/>formName].ignoreDates.checked)
+        return true;
+    for(i in <portlet:namespace/>dateFields) {
+        if(!checkDateMMDDYYYY(<portlet:namespace/>formName, <portlet:namespace/>dateFields[i]))
+            return false;
     }
-    dateElem.options.length = 0;
-    for(i = 0; i < totalDays; i++){
-        dateElem.options.length += 1; 
-        dateElem.options[i].text = dateElem.options[i].value = i+1;        
-    }            
+    // Check if to date is after from date
+    var fromDate = new Date(document.forms[<portlet:namespace/>formName].fromDate.value);
+    var toDate = new Date(document.forms[<portlet:namespace/>formName].toDate.value);
+    if(fromDate > toDate) {
+        alert('to date must be after from date.');
+        return false;
+    }
+    return true;
 }
 
-function isLeapYear(year) {
-    return (year%4 == 0 && (year % 100 != 0 || year % 400 == 0));
-}
 function <portlet:namespace/>refresh(){
     document.<portlet:namespace/>searchForm.action="<portlet:renderURL><portlet:param name="action" value="refresh"/></portlet:renderURL>";
     document.<portlet:namespace/>searchForm.submit();
@@ -63,7 +54,7 @@
 </tr>
 <tr>
     <td>
-    <form action="<portlet:renderURL/>" name="<portlet:namespace/>searchForm" method="post">
+    <form action="<portlet:renderURL/>" name="<portlet:namespace/>searchForm" method="post" onSubmit="return <portlet:namespace/>validateForm();">
     <b>Filter results:</b>
     <table width="680">
     <c:choose>
@@ -116,50 +107,10 @@
             <td colspan="4" class="DarkBackground"><b>Date:</b></td>
         </tr>
         <tr>
-            <td>From:</td>
-            <td>
-                <select name="startMonth" onchange="<portlet:namespace/>loadDates('startMonth','startDate','startYear');">
-                    <option value="0">January</option><option value="1">February</option>
-                    <option value="2">March</option><option value="3">April</option>
-                    <option value="4">May</option><option value="5">June</option>
-                    <option value="6">July</option><option value="7">August</option>
-                    <option value="8">September</option><option value="9">October</option>
-                    <option value="10">November</option><option value="11">December</option>
-                </select>
-                /
-                <select name="startDate">
-                </select>
-                /
-                <select name="startYear">
-                <%
-                for(int i = startYear;i <= currentYear; i++){
-                %>
-                <option value="<%=i%>"><%=i%></option>
-                <%}%>
-                </select>
-            </td>
-            <td>To:</td>
-            <td>
-                <select name="endMonth" onchange="<portlet:namespace/>loadDates('endMonth','endDate','endYear');">
-                    <option value="0">January</option><option value="1">February</option>
-                    <option value="2">March</option><option value="3">April</option>
-                    <option value="4">May</option><option value="5">June</option>
-                    <option value="6">July</option><option value="7">August</option>
-                    <option value="8">September</option><option value="9">October</option>
-                    <option value="10">November</option><option value="11">December</option>
-                </select>
-                /
-                <select name="endDate">
-                </select>
-                /
-                <select name="endYear">
-                    <%
-                    for(int i = startYear;i <= currentYear; i++){
-                    %>
-                    <option value="<%=i%>"><%=i%></option>
-                    <%}%>
-                </select>
-            </td>
+            <td>From (MM/DD/YYYY):</td>
+            <td><input type="text" name="fromDate" value="${fromDate}"></td>
+            <td>To (MM/DD/YYYY):</td>
+            <td><input type="text" name="toDate" value="${toDate}"></td>
         </tr>
         <tr>
             <td>Ignore Dates:</td>
@@ -186,10 +137,22 @@
                     <option value="" <c:if test="${empty requestMethod or requestMethod eq ''}"> selected</c:if>>ANY</option>
                     <option <c:if test="${requestMethod == 'GET'}"> selected</c:if>>GET</option>
                     <option <c:if test="${requestMethod == 'POST'}"> selected</c:if>>POST</option>
+                    <option <c:if test="${requestMethod == 'PUT'}"> selected</c:if>>PUT</option>
+                    <option <c:if test="${requestMethod == 'DELETE'}"> selected</c:if>>DELETE</option>
                 </select>
             </td>
             <td>Requested URI:</td>
             <td><input type="text" name="requestedURI" value="${requestedURI}"/></td>
+        </tr>
+        <tr>
+            <td colspan="4" class="DarkBackground"><b>Result Size:</b></td>
+        </tr>
+        <tr>
+            <td>Start Result:</td>
+            <td><input type="text" name="startResult" value="${startResult}"/></td>
+            <td>Max Results:</td>
+            <td><input type="text" name="maxResult" value="${maxResult}"/></td>
+        </tr>
         <tr>
             <td colspan="4" align="left">
                 <input type="submit" value="Go"/>
@@ -223,36 +186,3 @@
 </td>     
 </tr>
 </table>
-<script language="Javascript">
-var <portlet:namespace/>form = document.<portlet:namespace/>searchForm;
-<c:if test="${!empty fromDate}">
-<portlet:namespace/>form.startMonth.selectedIndex = ${fromDate.month};
-</c:if>
-<c:if test="${!empty toDate}">
-<portlet:namespace/>form.endMonth.selectedIndex = ${toDate.month};
-</c:if>
-<portlet:namespace/>loadDates('startMonth','startDate','startYear');
-<portlet:namespace/>loadDates('endMonth','endDate','endYear');
-<c:if test="${!empty fromDate}">
-<portlet:namespace/>form.startDate.selectedIndex = ${fromDate.date}-1;
-with(<portlet:namespace/>form){
-    for(var i = 0; i < startYear.options.length; i++){
-        if(startYear.options[i].value == ${fromDate.year} + 1900){
-            startYear.selectedIndex = i;
-            break;
-        }
-    }
-}
-</c:if>
-<c:if test="${!empty toDate}">
-<portlet:namespace/>form.endDate.selectedIndex = ${toDate.date}-1;
-with(<portlet:namespace/>form){
-    for(var i = 0; i < endYear.options.length; i++){
-        if(endYear.options[i].value == ${toDate.year} + 1900){
-            endYear.selectedIndex = i;
-            break;
-        }
-    }
-}
-</c:if>
-</script>

Modified: geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java?view=diff&rev=490685&r1=490684&r2=490685
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java (original)
+++ geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java Thu Dec 28 01:39:54 2006
@@ -37,12 +37,20 @@
 import javax.portlet.RenderResponse;
 import javax.portlet.WindowState;
 import java.io.IOException;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.Calendar;
+import java.util.Date;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
+/**
+ * @version $Rev$ $Date$
+ */
 public class WebAccessLogViewerPortlet extends BasePortlet {
     private final static Log log = LogFactory.getLog(WebAccessLogViewerPortlet.class);
+    private static final int DEFAULT_MAX_RESULTS = 10;
 
     protected PortletRequestDispatcher searchView;
 
@@ -121,20 +129,13 @@
             //todo: currently refreshes on every request; that's pretty slow.
         }
 
-
-        //todo: completely revamp this argument processing
-        String startDate = (String) renderRequest.getParameter("startDate");
-        String startMonth = (String) renderRequest.getParameter("startMonth");
-        String startYear = (String) renderRequest.getParameter("startYear");
-        String endDate = (String) renderRequest.getParameter("endDate");
-        String endMonth = (String) renderRequest.getParameter("endMonth");
-        String endYear = (String) renderRequest.getParameter("endYear");
+        String fromDateStr = (String) renderRequest.getParameter("fromDate");
+        String toDateStr = (String) renderRequest.getParameter("toDate");
 
         Calendar cal1 = Calendar.getInstance(), cal2 = Calendar.getInstance();
         // If not all dates were passed we assume than no fields were passed and just
         // filter on the current date.
-        if (startDate == null || startMonth == null || startYear == null
-                || endDate == null || endMonth == null || endYear == null) {
+        if(fromDateStr == null || toDateStr == null) {
             // just keep the month date and year
             cal1.set(Calendar.MILLISECOND, 0);
             cal1.set(Calendar.MINUTE, 0);
@@ -147,38 +148,82 @@
             cal2.set(Calendar.MILLISECOND, cal2.getMaximum(Calendar.MILLISECOND));
 
             WebAccessLog.SearchResults matchingItems = chosenLog.getMatchingItems(logToSearch,
-                                        null, null, null, null, cal1.getTime(), cal2.getTime(), null, null);
+                                        null, null, null, null, cal1.getTime(), cal2.getTime(), null, Integer.valueOf(DEFAULT_MAX_RESULTS - 1));
             renderRequest.setAttribute("logs", matchingItems.getResults());
             renderRequest.setAttribute("logLength", new Integer(matchingItems.getLineCount()));
+            renderRequest.setAttribute("maxResult", Integer.valueOf(DEFAULT_MAX_RESULTS));
         } else {
-            cal1.clear();
-            cal2.clear();
-            // get the requested start date (defaults to 00:00:00:000 for time
-            cal1.set(Calendar.DATE, Integer.parseInt(startDate));
-            cal1.set(Calendar.MONTH, Integer.parseInt(startMonth));
-            cal1.set(Calendar.YEAR, Integer.parseInt(startYear));
-            // get the requested end date - Note: must set time to end of day
-            cal2.set(Calendar.DATE, Integer.parseInt(endDate));
-            cal2.set(Calendar.MONTH, Integer.parseInt(endMonth));
-            cal2.set(Calendar.YEAR, Integer.parseInt(endYear));
-            cal2.set(Calendar.HOUR_OF_DAY, cal2.getMaximum(Calendar.HOUR_OF_DAY));
-            cal2.set(Calendar.MINUTE, cal2.getMaximum(Calendar.MINUTE));
-            cal2.set(Calendar.SECOND, cal2.getMaximum(Calendar.SECOND));
-            cal2.set(Calendar.MILLISECOND, cal2.getMaximum(Calendar.MILLISECOND));
             // Get other search criteria
             String requestHost = (String) renderRequest.getParameter("requestHost");
             String authUser = (String) renderRequest.getParameter("authUser");
             String requestMethod = (String) renderRequest.getParameter("requestMethod");
             String requestedURI = (String) renderRequest.getParameter("requestedURI");
+            String startResult = (String) renderRequest.getParameter("startResult");
+            String maxResult = (String) renderRequest.getParameter("maxResult");
+            Integer iStartResult = null;
+            Integer iMaxResult = Integer.valueOf(DEFAULT_MAX_RESULTS);
+            try{
+                iStartResult = Integer.valueOf(startResult);
+            }catch(NumberFormatException e){
+                //ignore
+            }
+            try{
+                iMaxResult = Integer.valueOf(maxResult);
+            }catch(NumberFormatException e){
+                //ignore
+            }
+            
             boolean ignoreDates = renderRequest.getParameter("ignoreDates") != null;
             if (ignoreDates) {
                 WebAccessLog.SearchResults matchingItems = chosenLog.getMatchingItems(logToSearch,
-                                                requestHost, authUser, requestMethod, requestedURI, null, null, null, null);
+                                                requestHost, authUser, requestMethod, requestedURI, null, null, iStartResult, Integer.valueOf(iMaxResult.intValue()-1));
                 renderRequest.setAttribute("logs", matchingItems.getResults());
                 renderRequest.setAttribute("logLength", new Integer(matchingItems.getLineCount()));
             } else {
+                Date fromDate = null, toDate = null;
+                // Check if the from and to date format is MM/DD/YYYY
+                DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
+                try {
+                    fromDate = df.parse(fromDateStr);
+                    // get the requested start date (defaults to 00:00:00:000 for time)
+                    cal1.setTime(fromDate);
+                    String mmddyyyy = (cal1.get(Calendar.MONTH) < 9 ? "0":"") + (cal1.get(Calendar.MONTH)+1);
+                    mmddyyyy += "/"+(cal1.get(Calendar.DAY_OF_MONTH) < 10 ? "0":"") + (cal1.get(Calendar.DAY_OF_MONTH));
+                    mmddyyyy += "/"+cal1.get(Calendar.YEAR);
+                    if(!mmddyyyy.equals(fromDateStr)) {
+                        // This should not arise since date input has been validated using javascript.
+                        // If this does occur, ignore dates in search criteria and log a WARNING
+                        log.warn("From date must be a date in MM/DD/YYYY format, not '"+fromDateStr+"'. Dates will be ignored.");
+                        fromDate = null;
+                    }
+                    toDate = df.parse(toDateStr);
+                    cal2.setTime(toDate);
+                    mmddyyyy = (cal2.get(Calendar.MONTH) < 9 ? "0":"") + (cal2.get(Calendar.MONTH)+1);
+                    mmddyyyy += "/"+(cal2.get(Calendar.DAY_OF_MONTH) < 10 ? "0":"") + (cal2.get(Calendar.DAY_OF_MONTH));
+                    mmddyyyy += "/"+cal2.get(Calendar.YEAR);
+                    if(!mmddyyyy.equals(toDateStr)) {
+                        // This should not arise since date input has been validated using javascript.
+                        // If this does occur, ignore to date in search criteria and log a WARNING
+                        log.warn("To date must be a date in MM/DD/YYYY format, not "+toDateStr+"'. Dates will be ignored.");
+                        toDate = null;
+                    } else {
+                        // get the requested end date - Note: must set time to end of day
+                        cal2.set(Calendar.HOUR_OF_DAY, cal2.getMaximum(Calendar.HOUR_OF_DAY));
+                        cal2.set(Calendar.MINUTE, cal2.getMaximum(Calendar.MINUTE));
+                        cal2.set(Calendar.SECOND, cal2.getMaximum(Calendar.SECOND));
+                        cal2.set(Calendar.MILLISECOND, cal2.getMaximum(Calendar.MILLISECOND));
+                        toDate = cal2.getTime();
+                    }
+                } catch (ParseException e) {
+                    // Should not occur since date input has been validated using javascript.
+                    // If this does occur, ignore from and to dates and log a WARNING
+                    log.warn("Error parsing input dates.  Dates will be ignored.", e);
+                }
+                if(fromDate == null || toDate == null) {
+                    fromDate = toDate = null;
+                }
                 WebAccessLog.SearchResults matchingItems = chosenLog.getMatchingItems(logToSearch,
-                                                requestHost, authUser, requestMethod, requestedURI, cal1.getTime(), cal2.getTime(), null, null);
+                                                requestHost, authUser, requestMethod, requestedURI, fromDate, toDate, iStartResult, Integer.valueOf(iMaxResult.intValue()-1));
                 renderRequest.setAttribute("logs", matchingItems.getResults());
                 renderRequest.setAttribute("logLength", new Integer(matchingItems.getLineCount()));
             }
@@ -187,10 +232,11 @@
             renderRequest.setAttribute("authUser", authUser);
             renderRequest.setAttribute("requestMethod", requestMethod);
             renderRequest.setAttribute("requestedURI", requestedURI);
-
+            if(iStartResult != null)renderRequest.setAttribute("startResult", iStartResult);
+            if(iMaxResult != null)renderRequest.setAttribute("maxResult", iMaxResult);
         }
-        renderRequest.setAttribute("toDate", cal2.getTime());
-        renderRequest.setAttribute("fromDate", cal1.getTime());
+        renderRequest.setAttribute("toDate", toDateStr);
+        renderRequest.setAttribute("fromDate", fromDateStr);
         searchView.include(renderRequest, renderRespose);
     }
 

Modified: geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/webaccesslogmanager/view.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/webaccesslogmanager/view.jsp?view=diff&rev=490685&r1=490684&r2=490685
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/webaccesslogmanager/view.jsp (original)
+++ geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/webaccesslogmanager/view.jsp Thu Dec 28 01:39:54 2006
@@ -14,42 +14,33 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 --%>
+
+<%-- $Rev$ $Date$ --%>
+
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
 <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
-<%!
-java.util.Calendar cal = java.util.Calendar.getInstance();
-int startYear = 1990;
-int currentYear = cal.get(java.util.Calendar.YEAR);
-%>
 <script language="Javascript">
+var <portlet:namespace/>formName = "<portlet:namespace/>searchForm";
+var <portlet:namespace/>dateFields = new Array("fromDate", "toDate");
 
-function <portlet:namespace/>loadDates(monthElemName,dateElemName,yearElemName){
-    var yearElem = eval("document.<portlet:namespace/>searchForm." + yearElemName);
-    var monthElem = eval("document.<portlet:namespace/>searchForm." + monthElemName);
-    var dateElem = eval("document.<portlet:namespace/>searchForm." + dateElemName);
-    var monthIndex = parseInt(monthElem.options[monthElem.selectedIndex].value);
-    var selectedYear = parseInt(yearElem.options[yearElem.selectedIndex].value);
-    var totalDays = 0;
-    // February
-    if(monthIndex == 1){
-        totalDays = (isLeapYear(selectedYear)? 29 : 28) 
-    }else if(monthIndex == 0 || monthIndex == 2 || monthIndex == 4 || monthIndex == 6 || monthIndex == 7 ||
-            monthIndex == 9 || monthIndex == 11){
-        totalDays = 31;
-    }else{
-        totalDays = 30;
+function <portlet:namespace/>validateForm(){
+    if(document.forms[<portlet:namespace/>formName].ignoreDates.checked)
+        return true;
+    for(i in <portlet:namespace/>dateFields) {
+        if(!checkDateMMDDYYYY(<portlet:namespace/>formName, <portlet:namespace/>dateFields[i]))
+            return false;
     }
-    dateElem.options.length = 0;
-    for(i = 0; i < totalDays; i++){
-        dateElem.options.length += 1; 
-        dateElem.options[i].text = dateElem.options[i].value = i+1;        
-    }            
+    // Check if to date is after from date
+    var fromDate = new Date(document.forms[<portlet:namespace/>formName].fromDate.value);
+    var toDate = new Date(document.forms[<portlet:namespace/>formName].toDate.value);
+    if(fromDate > toDate) {
+        alert('to date must be after from date.');
+        return false;
+    }
+    return true;
 }
 
-function isLeapYear(year) {
-    return (year%4 == 0 && (year % 100 != 0 || year % 400 == 0));
-}
 function <portlet:namespace/>refresh(){
     document.<portlet:namespace/>searchForm.action="<portlet:renderURL><portlet:param name="action" value="refresh"/></portlet:renderURL>";
     document.<portlet:namespace/>searchForm.submit();
@@ -63,7 +54,7 @@
 </tr>
 <tr>
     <td>
-    <form action="<portlet:renderURL/>" name="<portlet:namespace/>searchForm" method="post">
+    <form action="<portlet:renderURL/>" name="<portlet:namespace/>searchForm" method="post" onSubmit="return <portlet:namespace/>validateForm();">
     <b>Filter results:</b>
     <table width="680">
     <c:choose>
@@ -116,50 +107,10 @@
             <td colspan="4" class="DarkBackground"><b>Date:</b></td>
         </tr>
         <tr>
-            <td>From:</td>
-            <td>
-                <select name="startMonth" onchange="<portlet:namespace/>loadDates('startMonth','startDate','startYear');">
-                    <option value="0">January</option><option value="1">February</option>
-                    <option value="2">March</option><option value="3">April</option>
-                    <option value="4">May</option><option value="5">June</option>
-                    <option value="6">July</option><option value="7">August</option>
-                    <option value="8">September</option><option value="9">October</option>
-                    <option value="10">November</option><option value="11">December</option>
-                </select>
-                /
-                <select name="startDate">
-                </select>
-                /
-                <select name="startYear">
-                <%
-                for(int i = startYear;i <= currentYear; i++){
-                %>
-                <option value="<%=i%>"><%=i%></option>
-                <%}%>
-                </select>
-            </td>
-            <td>To:</td>
-            <td>
-                <select name="endMonth" onchange="<portlet:namespace/>loadDates('endMonth','endDate','endYear');">
-                    <option value="0">January</option><option value="1">February</option>
-                    <option value="2">March</option><option value="3">April</option>
-                    <option value="4">May</option><option value="5">June</option>
-                    <option value="6">July</option><option value="7">August</option>
-                    <option value="8">September</option><option value="9">October</option>
-                    <option value="10">November</option><option value="11">December</option>
-                </select>
-                /
-                <select name="endDate">
-                </select>
-                /
-                <select name="endYear">
-                    <%
-                    for(int i = startYear;i <= currentYear; i++){
-                    %>
-                    <option value="<%=i%>"><%=i%></option>
-                    <%}%>
-                </select>
-            </td>
+            <td>From (MM/DD/YYYY):</td>
+            <td><input type="text" name="fromDate" value="${fromDate}"></td>
+            <td>To (MM/DD/YYYY):</td>
+            <td><input type="text" name="toDate" value="${toDate}"></td>
         </tr>
         <tr>
             <td>Ignore Dates:</td>
@@ -186,10 +137,22 @@
                     <option value="" <c:if test="${empty requestMethod or requestMethod eq ''}"> selected</c:if>>ANY</option>
                     <option <c:if test="${requestMethod == 'GET'}"> selected</c:if>>GET</option>
                     <option <c:if test="${requestMethod == 'POST'}"> selected</c:if>>POST</option>
+                    <option <c:if test="${requestMethod == 'PUT'}"> selected</c:if>>PUT</option>
+                    <option <c:if test="${requestMethod == 'DELETE'}"> selected</c:if>>DELETE</option>
                 </select>
             </td>
             <td>Requested URI:</td>
             <td><input type="text" name="requestedURI" value="${requestedURI}"/></td>
+        </tr>
+        <tr>
+            <td colspan="4" class="DarkBackground"><b>Result Size:</b></td>
+        </tr>
+        <tr>
+            <td>Start Result:</td>
+            <td><input type="text" name="startResult" value="${startResult}"/></td>
+            <td>Max Results:</td>
+            <td><input type="text" name="maxResult" value="${maxResult}"/></td>
+        </tr>
         <tr>
             <td colspan="4" align="left">
                 <input type="submit" value="Go"/>
@@ -223,36 +186,3 @@
 </td>     
 </tr>
 </table>
-<script language="Javascript">
-var <portlet:namespace/>form = document.<portlet:namespace/>searchForm;
-<c:if test="${!empty fromDate}">
-<portlet:namespace/>form.startMonth.selectedIndex = ${fromDate.month};
-</c:if>
-<c:if test="${!empty toDate}">
-<portlet:namespace/>form.endMonth.selectedIndex = ${toDate.month};
-</c:if>
-<portlet:namespace/>loadDates('startMonth','startDate','startYear');
-<portlet:namespace/>loadDates('endMonth','endDate','endYear');
-<c:if test="${!empty fromDate}">
-<portlet:namespace/>form.startDate.selectedIndex = ${fromDate.date}-1;
-with(<portlet:namespace/>form){
-    for(var i = 0; i < startYear.options.length; i++){
-        if(startYear.options[i].value == ${fromDate.year} + 1900){
-            startYear.selectedIndex = i;
-            break;
-        }
-    }
-}
-</c:if>
-<c:if test="${!empty toDate}">
-<portlet:namespace/>form.endDate.selectedIndex = ${toDate.date}-1;
-with(<portlet:namespace/>form){
-    for(var i = 0; i < endYear.options.length; i++){
-        if(endYear.options[i].value == ${toDate.year} + 1900){
-            endYear.selectedIndex = i;
-            break;
-        }
-    }
-}
-</c:if>
-</script>



Mime
View raw message