geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hogst...@apache.org
Subject svn commit: r563404 - in /geronimo/server/branches/2.0.0/applications/console/geronimo-console-standard/src/main: java/org/apache/geronimo/console/derbylogmanager/ java/org/apache/geronimo/console/logmanager/ webapp/WEB-INF/view/webaccesslogmanager/
Date Tue, 07 Aug 2007 06:38:35 GMT
Author: hogstrom
Date: Mon Aug  6 23:38:34 2007
New Revision: 563404

URL: http://svn.apache.org/viewvc?view=rev&rev=563404
Log:
GERONIMO-807 Corrects errors in log viewing when different portlets on a page are accessed.

Modified:
    geronimo/server/branches/2.0.0/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/derbylogmanager/DerbyLogViewerPortlet.java
    geronimo/server/branches/2.0.0/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/logmanager/LogManagerPortlet.java
    geronimo/server/branches/2.0.0/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/logmanager/LogViewerPortlet.java
    geronimo/server/branches/2.0.0/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java
    geronimo/server/branches/2.0.0/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/webaccesslogmanager/view.jsp

Modified: geronimo/server/branches/2.0.0/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/derbylogmanager/DerbyLogViewerPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0.0/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/derbylogmanager/DerbyLogViewerPortlet.java?view=diff&rev=563404&r1=563403&r2=563404
==============================================================================
--- geronimo/server/branches/2.0.0/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/derbylogmanager/DerbyLogViewerPortlet.java
(original)
+++ geronimo/server/branches/2.0.0/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/derbylogmanager/DerbyLogViewerPortlet.java
Mon Aug  6 23:38:34 2007
@@ -58,19 +58,17 @@
         String action = renderRequest.getParameter("action");
 
         DerbyLog log = (DerbyLog) PortletManager.getManagedBeans(renderRequest, DerbyLog.class)[0];//todo:
what if it's not there?
-        Criteria criteria;
-        if ("refresh".equals(action)) {
-            criteria = (Criteria) renderRequest.getPortletSession(true).getAttribute(CRITERIA_KEY,
PortletSession.PORTLET_SCOPE);
-        } else {
+        Criteria criteria = (Criteria) renderRequest.getPortletSession(true).getAttribute(CRITERIA_KEY,
PortletSession.PORTLET_SCOPE);
+        
+        if (criteria == null || (action != null && !"refresh".equals(action))) {
+            if(criteria == null)
+                criteria = new Criteria();
             String startPos = renderRequest.getParameter("startPos");
             String endPos = renderRequest.getParameter("endPos");
             String maxRows = renderRequest.getParameter("maxRows");
-            String searchString = renderRequest.getParameter("searchString");
-            if(maxRows == null || maxRows.equals("")) {
-                maxRows = "10";
-            }
-            criteria = new Criteria();
-            criteria.max = new Integer(maxRows);
+            String searchString = renderRequest.getParameter("searchString");           
+            
+            criteria.max = maxRows == null || maxRows.equals("") ? criteria.max : Integer.parseInt(maxRows);
             criteria.start = startPos == null || startPos.equals("") ? null : new Integer(startPos);
             criteria.stop = endPos == null || endPos.equals("") ? null : new Integer(endPos);
             criteria.text = searchString == null || searchString.equals("") ? null : searchString;
@@ -93,7 +91,7 @@
     }
 
     private static class Criteria implements Serializable {
-        Integer max;
+        Integer max = 10;
         Integer start;
         Integer stop;
         String text;

Modified: geronimo/server/branches/2.0.0/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/logmanager/LogManagerPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0.0/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/logmanager/LogManagerPortlet.java?view=diff&rev=563404&r1=563403&r2=563404
==============================================================================
--- geronimo/server/branches/2.0.0/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/logmanager/LogManagerPortlet.java
(original)
+++ geronimo/server/branches/2.0.0/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/logmanager/LogManagerPortlet.java
Mon Aug  6 23:38:34 2007
@@ -53,7 +53,11 @@
         renderRequest.setAttribute("configFile", log.getConfigFileName());
 //        renderRequest.setAttribute("configuration", LogHelper.getConfiguration());
         renderRequest.setAttribute("logLevel", log.getRootLoggerLevel());
-        renderRequest.setAttribute("refreshPeriod", new Integer(log.getRefreshPeriodSeconds()));
+        try{
+            renderRequest.setAttribute("refreshPeriod", new Integer(log.getRefreshPeriodSeconds()));
+        }catch(NumberFormatException e){
+            //ignore
+        }
 
         normalView.include(renderRequest, renderRespose);
     }
@@ -78,7 +82,12 @@
 
         if ("update".equals(action)) {
             if (refreshPeriod != null) {
-                int refreshPeriodInt = Integer.parseInt(refreshPeriod);
+                int refreshPeriodInt = 0;
+                try{
+                    refreshPeriodInt = Integer.parseInt(refreshPeriod);
+                }catch(NumberFormatException e){
+                    //ignore
+                }
                 if (refreshPeriodInt != log.getRefreshPeriodSeconds()) {
                     log.setRefreshPeriodSeconds(refreshPeriodInt);
                 }
@@ -91,4 +100,4 @@
             }
         }
     }
-}
\ No newline at end of file
+}

Modified: geronimo/server/branches/2.0.0/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/logmanager/LogViewerPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0.0/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/logmanager/LogViewerPortlet.java?view=diff&rev=563404&r1=563403&r2=563404
==============================================================================
--- geronimo/server/branches/2.0.0/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/logmanager/LogViewerPortlet.java
(original)
+++ geronimo/server/branches/2.0.0/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/logmanager/LogViewerPortlet.java
Mon Aug  6 23:38:34 2007
@@ -59,10 +59,11 @@
         for (int i = 0; i < files.length; i++) {
             files[i] = new LogFile(logFiles[i]);
         }
-        Criteria criteria;
-        if ("refresh".equals(action)) {
-            criteria = (Criteria) renderRequest.getPortletSession(true).getAttribute(CRITERIA_KEY,
PortletSession.PORTLET_SCOPE);
-        } else {
+        Criteria criteria = (Criteria) renderRequest.getPortletSession(true).getAttribute(CRITERIA_KEY,
PortletSession.PORTLET_SCOPE);
+        
+        if (criteria == null || (action != null && !"refresh".equals(action))) {
+            if(criteria == null)
+                criteria = new Criteria();
             String startPos = renderRequest.getParameter("startPos");
             String endPos = renderRequest.getParameter("endPos");
             String maxRows = renderRequest.getParameter("maxRows");
@@ -73,19 +74,26 @@
             if(logFile == null || logFile.equals("")) {
                 logFile = logFiles[0];
             }
-            if(logLevel == null || logLevel.equals("")) {
-                logLevel = "WARN";
+            
+            criteria.level = logLevel == null || logLevel.equals("") ? criteria.level : logLevel;
+            try{
+                criteria.max = maxRows == null || maxRows.equals("") ? criteria.max : Integer.parseInt(maxRows);
+            }catch(NumberFormatException e){
+                //ignore
             }
-            if(maxRows == null || maxRows.equals("")) {
-                maxRows = "10";
+            try{
+                criteria.start = startPos == null || startPos.equals("") ? null : new Integer(startPos);
+            }catch(NumberFormatException e){
+            //ignore
             }
-            criteria = new Criteria();
-            criteria.max = Integer.parseInt(maxRows);
-            criteria.start = startPos == null || startPos.equals("") ? null : new Integer(startPos);
-            criteria.stop = endPos == null || endPos.equals("") ? null : new Integer(endPos);
+            try{
+                criteria.stop = endPos == null || endPos.equals("") ? null : new Integer(endPos);
+            }catch(NumberFormatException e){
+                //ignore
+                }
             criteria.logFile = logFile;
             criteria.stackTraces = stackTraces != null && !stackTraces.equals("");
-            criteria.level = logLevel;
+            
             criteria.text = searchString == null || searchString.equals("") ? null : searchString;
             renderRequest.getPortletSession(true).setAttribute(CRITERIA_KEY, criteria, PortletSession.PORTLET_SCOPE);
         }
@@ -121,11 +129,11 @@
     }
 
     private static class Criteria implements Serializable {
-        int max;
+        int max = 10;
         Integer start;
         Integer stop;
         String text;
-        String level;
+        String level = "WARN";
         String logFile;
         boolean stackTraces;
     }
@@ -153,4 +161,4 @@
             return name;
         }
     }
-}
\ No newline at end of file
+}

Modified: geronimo/server/branches/2.0.0/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0.0/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java?view=diff&rev=563404&r1=563403&r2=563404
==============================================================================
--- geronimo/server/branches/2.0.0/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java
(original)
+++ geronimo/server/branches/2.0.0/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java
Mon Aug  6 23:38:34 2007
@@ -33,10 +33,12 @@
 import javax.portlet.PortletContext;
 import javax.portlet.PortletException;
 import javax.portlet.PortletRequestDispatcher;
+import javax.portlet.PortletSession;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 import javax.portlet.WindowState;
 import java.io.IOException;
+import java.io.Serializable;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -49,6 +51,7 @@
  * @version $Rev$ $Date$
  */
 public class WebAccessLogViewerPortlet extends BasePortlet {
+    private final static String CRITERIA_KEY = "org.apache.geronimo.console.web.log.CRITERIA";
     private final static Log log = LogFactory.getLog(WebAccessLogViewerPortlet.class);
     private static final int DEFAULT_MAX_RESULTS = 10;
 
@@ -68,7 +71,10 @@
         }
 
         WebManager[] managers = PortletManager.getCurrentServer(renderRequest).getWebManagers();
-
+        
+        Criteria criteria = (Criteria) renderRequest.getPortletSession(true).getAttribute(CRITERIA_KEY,
PortletSession.PORTLET_SCOPE);
+        
+        
         //todo: new
         Map products = new LinkedHashMap();
         String chosen = renderRequest.getParameter("selectedContainer");
@@ -125,12 +131,37 @@
         }
 
         String action = renderRequest.getParameter("action");
-        if ("refresh".equals(action)) {
-            //todo: currently refreshes on every request; that's pretty slow.
+        if (criteria == null || (action != null && !"refresh".equals(action))) {
+            if(criteria == null)
+                criteria = new Criteria();
+            
+            String fromDate = renderRequest.getParameter("fromDate");
+            String toDate = renderRequest.getParameter("toDate");
+            String requestHost = renderRequest.getParameter("requestHost");
+            String authUser = renderRequest.getParameter("authUser");
+            String method = renderRequest.getParameter("requestMethod");
+            String uri = renderRequest.getParameter("requestedURI");
+            String result = renderRequest.getParameter("startResult");
+            Integer max = criteria.maxResult;
+            try{
+                max = Integer.parseInt(renderRequest.getParameter("maxResult"));
+            }catch(NumberFormatException e){
+            //ignore
+            }
+            String ignoreDates = renderRequest.getParameter("ignoreDates");
+            
+            criteria.fromDate = fromDate == null || fromDate.equals("") ? null : fromDate;
+            criteria.toDate = toDate == null || toDate.equals("") ? null : toDate;
+            criteria.requestHost = requestHost == null || requestHost.equals("") ? null :
requestHost;
+            criteria.authUser = authUser == null || authUser.equals("") ? null : authUser;
+            criteria.requestMethod = method == null || method.equals("") ? null : method;
+            criteria.requestedURI = uri == null || uri.equals("") ? null : uri;
+            criteria.startResult = result == null || result.equals("") ? null : result;
+            criteria.maxResult = max;
+            criteria.ignoreDates = ignoreDates != null && !ignoreDates.equals("");
 
         }
-
-        String fromDateStr = (String) renderRequest.getParameter("fromDate");
-        String toDateStr = (String) renderRequest.getParameter("toDate");
+        String fromDateStr = criteria.fromDate;
+        String toDateStr = criteria.toDate;
 
         Calendar cal1 = Calendar.getInstance(), cal2 = Calendar.getInstance();
         // If not all dates were passed we assume than no fields were passed and just
@@ -148,32 +179,28 @@
             cal2.set(Calendar.MILLISECOND, cal2.getMaximum(Calendar.MILLISECOND));
 
             WebAccessLog.SearchResults matchingItems = chosenLog.getMatchingItems(logToSearch,
-                                        null, null, null, null, cal1.getTime(), cal2.getTime(),
null, Integer.valueOf(DEFAULT_MAX_RESULTS - 1));
+                                        null, null, null, null, cal1.getTime(), cal2.getTime(),
null, Integer.valueOf(criteria.maxResult.intValue()-1));
             renderRequest.setAttribute("logs", matchingItems.getResults());
             renderRequest.setAttribute("logLength", new Integer(matchingItems.getLineCount()));
-            renderRequest.setAttribute("maxResult", Integer.valueOf(DEFAULT_MAX_RESULTS));
+            renderRequest.setAttribute("maxResult", criteria.maxResult);
+            renderRequest.setAttribute("ignoreDates", Boolean.valueOf(criteria.ignoreDates));
+            
         } else {
             // 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");
+            String requestHost = criteria.requestHost;
+            String authUser = criteria.authUser;
+            String requestMethod = criteria.requestMethod;
+            String requestedURI = criteria.requestedURI;
+            String startResult = criteria.startResult;
             Integer iStartResult = null;
-            Integer iMaxResult = Integer.valueOf(DEFAULT_MAX_RESULTS);
+            Integer iMaxResult = criteria.maxResult;
             try{
                 iStartResult = Integer.valueOf(startResult);
             }catch(NumberFormatException e){
                 //ignore
             }
-            try{
-                iMaxResult = Integer.valueOf(maxResult);
-            }catch(NumberFormatException e){
-                //ignore
-            }
             
-            boolean ignoreDates = renderRequest.getParameter("ignoreDates") != null;
+            boolean ignoreDates = criteria.ignoreDates;
             if (ignoreDates) {
                 WebAccessLog.SearchResults matchingItems = chosenLog.getMatchingItems(logToSearch,
                                                 requestHost, authUser, requestMethod, requestedURI,
null, null, iStartResult, Integer.valueOf(iMaxResult.intValue()-1));
@@ -227,7 +254,7 @@
                 renderRequest.setAttribute("logs", matchingItems.getResults());
                 renderRequest.setAttribute("logLength", new Integer(matchingItems.getLineCount()));
             }
-            if (ignoreDates) renderRequest.setAttribute("ignoreDates", new Boolean(ignoreDates));
+            renderRequest.setAttribute("ignoreDates", new Boolean(ignoreDates));
             renderRequest.setAttribute("requestHost", requestHost);
             renderRequest.setAttribute("authUser", authUser);
             renderRequest.setAttribute("requestMethod", requestMethod);
@@ -237,6 +264,7 @@
         }
         renderRequest.setAttribute("toDate", toDateStr);
         renderRequest.setAttribute("fromDate", fromDateStr);
+        renderRequest.getPortletSession(true).setAttribute(CRITERIA_KEY, criteria, PortletSession.PORTLET_SCOPE);
         searchView.include(renderRequest, renderRespose);
     }
 
@@ -250,6 +278,17 @@
     public void processAction(ActionRequest actionRequest,
             ActionResponse actionResponse) throws PortletException, IOException {
         //todo: according to portlet spec, all forms should submit to Action not Render
+    }
+    private static class Criteria implements Serializable {
+        Integer maxResult = new Integer(DEFAULT_MAX_RESULTS);
+        String fromDate = null;
+        String toDate = null;
+        boolean ignoreDates = false;
+        String requestHost = null;
+        String authUser = null;
+        String requestMethod = "ANY";
+        String requestedURI = null;
+        String startResult = null;
     }
 
 }

Modified: geronimo/server/branches/2.0.0/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/webaccesslogmanager/view.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0.0/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/webaccesslogmanager/view.jsp?view=diff&rev=563404&r1=563403&r2=563404
==============================================================================
--- geronimo/server/branches/2.0.0/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/webaccesslogmanager/view.jsp
(original)
+++ geronimo/server/branches/2.0.0/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/webaccesslogmanager/view.jsp
Mon Aug  6 23:38:34 2007
@@ -41,21 +41,18 @@
     return true;
 }
 
-function <portlet:namespace/>refresh(){
-    document.<portlet:namespace/>searchForm.action="<portlet:renderURL><portlet:param
name="action" value="refresh"/></portlet:renderURL>";
-    document.<portlet:namespace/>searchForm.submit();
-}
 </script>
 <table>
 <tr>
 <td>
-<a href="javascript:<portlet:namespace/>refresh()">Refresh</a>
+<a href="<portlet:renderURL><portlet:param name="action" value="refresh"/></portlet:renderURL>">Refresh</a>
 </td>     
 </tr>
 <tr>
     <td>
     <form action="<portlet:renderURL/>" name="<portlet:namespace/>searchForm"
method="post" onSubmit="return <portlet:namespace/>validateForm();">
     <b>Filter results:</b>
+    <input type="hidden" value="search" name="action"/>    
     <table width="680">
     <c:choose>
       <c:when test="${fn:length(webContainers) > 1}">
@@ -149,10 +146,12 @@
         </tr>
         <tr>
             <td>Start Result:</td>
-            <td><input type="text" name="startResult" value="${startResult}"/></td>
+            <td><input type="text" name="startResult" value="${startResult}"/>
+            </td>
             <td>Max Results:</td>
-            <td><input type="text" name="maxResult" value="${maxResult}"/></td>
-        </tr>
+            <td><input type="text" name="maxResult" value="${maxResult}"/>
+            </td>
+        </tr>        
         <tr>
             <td colspan="4" align="left">
                 <input type="submit" value="Go"/>



Mime
View raw message