geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dwo...@apache.org
Subject svn commit: r560984 - in /geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/apache/jk: ApacheConfigPortlet.java BaseApacheHandler.java
Date Mon, 30 Jul 2007 13:56:45 GMT
Author: dwoods
Date: Mon Jul 30 06:56:44 2007
New Revision: 560984

URL: http://svn.apache.org/viewvc?view=rev&rev=560984
Log:
GERONIMO-3349 Broken link in console when on the Apache HTTP page.  Patch from Viet Hung Nguyen.

Modified:
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/apache/jk/ApacheConfigPortlet.java
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/apache/jk/BaseApacheHandler.java

Modified: geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/apache/jk/ApacheConfigPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/apache/jk/ApacheConfigPortlet.java?view=diff&rev=560984&r1=560983&r2=560984
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/apache/jk/ApacheConfigPortlet.java
(original)
+++ geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/apache/jk/ApacheConfigPortlet.java
Mon Jul 30 06:56:44 2007
@@ -16,12 +16,18 @@
  */
 package org.apache.geronimo.console.apache.jk;
 
+import java.io.IOException;
+
+import org.apache.geronimo.console.MultiPageAbstractHandler;
 import org.apache.geronimo.console.MultiPagePortlet;
-import org.apache.geronimo.console.MultiPageModel;
+import org.apache.geronimo.console.apache.jk.BaseApacheHandler.ApacheModel;
 
 import javax.portlet.PortletConfig;
 import javax.portlet.PortletException;
 import javax.portlet.PortletRequest;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.WindowState;
 
 /**
  * Portlet that helps you configure Geronimo for Apache 2 with mod_jk
@@ -38,11 +44,37 @@
         addHelper(new ResultsHandler(), config);
     }
 
+    public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws
IOException, PortletException {
+        if(WindowState.MINIMIZED.equals(renderRequest.getWindowState())) {
+            return;
+        }
+        String mode = renderRequest.getParameter(MODE_KEY);
+        ApacheModel model = (ApacheModel)getModel(renderRequest);
+        if(mode == null || mode.equals("")) {
+            mode = getDefaultMode();
+        }
+        MultiPageAbstractHandler handler = (MultiPageAbstractHandler)helpers.get(mode);
+        try {
+            if(handler != null) {
+                handler.renderView(renderRequest, renderResponse, model);
+            }
+        } catch (Throwable e) {
+            
+        }
+        // decode the paths in model object
+        model.setLogFilePath(model.getLogFilePath());
+        model.setWorkersPath(model.getWorkersPath());
+        renderRequest.setAttribute(getModelJSPVariableName(), model);
+        if(handler != null) {
+            handler.getView().include(renderRequest, renderResponse);
+        }
+    }
+
     protected String getModelJSPVariableName() {
         return "model";
     }
 
-    protected MultiPageModel getModel(PortletRequest request) {
+    protected ApacheModel getModel(PortletRequest request) {
         return new BaseApacheHandler.ApacheModel(request);
     }
 }

Modified: geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/apache/jk/BaseApacheHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/apache/jk/BaseApacheHandler.java?view=diff&rev=560984&r1=560983&r2=560984
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/apache/jk/BaseApacheHandler.java
(original)
+++ geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/apache/jk/BaseApacheHandler.java
Mon Jul 30 06:56:44 2007
@@ -160,17 +160,21 @@
         private String logFilePath;
         private String workersPath;
         private List webApps = new ArrayList();
+        // list of encodings for special chars
+        private String[][] ENCODINGS = {{":", "0x0"},{"\\", "0x1"}};
 
         public ApacheModel(PortletRequest request) {
             Map map = request.getParameterMap();
             os = request.getParameter("os");
-            logFilePath = request.getParameter("logFilePath");
+            // logFilePath and workersPath need to be encoded before saving
+            // and decoded after fetching
+            logFilePath = encodePath(request.getParameter("logFilePath"));
             if(logFilePath == null) {
-                logFilePath = PortletManager.getCurrentServer(request).getServerInfo().resolve("var/log/apache_mod_jk.log").getPath();
+                logFilePath = encodePath(PortletManager.getCurrentServer(request).getServerInfo().resolve("var/log/apache_mod_jk.log").getPath());
             }
-            workersPath = request.getParameter("workersPath");
+            workersPath = encodePath(request.getParameter("workersPath"));
             if(workersPath == null) {
-                workersPath = PortletManager.getCurrentServer(request).getServerInfo().resolve("var/config/workers.properties").getPath();
+                workersPath = encodePath(PortletManager.getCurrentServer(request).getServerInfo().resolve("var/config/workers.properties").getPath());
             }
             String ajp = request.getParameter("addAjpPort");
             if(!isEmpty(ajp)) addAjpPort = new Integer(ajp);
@@ -203,6 +207,30 @@
             }
         }
 
+        private String encodePath(String value) {
+            if(value == null) {
+                return value;
+            }
+            for(int i = 0; i < ENCODINGS.length; i++) {
+                if(value.contains(ENCODINGS[i][0])) {
+                    value = value.replace(ENCODINGS[i][0], ENCODINGS[i][1]);
+                }
+            }
+            return value;
+        }
+        
+        private String decodePath(String value) {
+            if(value == null) {
+                return value;
+            }
+            for(int i = 0; i < ENCODINGS.length; i++) {
+                if(value.contains(ENCODINGS[i][1])) {
+                    value = value.replace(ENCODINGS[i][1], ENCODINGS[i][0]);
+                }
+            }
+            return value;
+        }
+        
         public String getOs() {
             return os;
         }
@@ -220,7 +248,7 @@
         }
 
         public String getLogFilePath() {
-            return logFilePath;
+            return decodePath(logFilePath);
         }
 
         public void setLogFilePath(String logFilePath) {
@@ -228,7 +256,7 @@
         }
 
         public String getWorkersPath() {
-            return workersPath;
+            return decodePath(workersPath);
         }
 
         public void setWorkersPath(String workersPath) {



Mime
View raw message