cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r503698 - in /cocoon/branches/BRANCH_2_1_X: src/blocks/portal/WEB-INF/portlet.xml src/blocks/portal/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java status.xml
Date Mon, 05 Feb 2007 14:30:32 GMT
Author: cziegeler
Date: Mon Feb  5 06:30:30 2007
New Revision: 503698

URL: http://svn.apache.org/viewvc?view=rev&rev=503698
Log:
Apply patch from Woonsan Ko for bug COCOON-1998
CocoonPortlet needs to allow overriding servlet-path parameter with preferences.

Modified:
    cocoon/branches/BRANCH_2_1_X/src/blocks/portal/WEB-INF/portlet.xml
    cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java
    cocoon/branches/BRANCH_2_1_X/status.xml

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/WEB-INF/portlet.xml
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/WEB-INF/portlet.xml?view=diff&rev=503698&r1=503697&r2=503698
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/WEB-INF/portlet.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/WEB-INF/portlet.xml Mon Feb  5 06:30:30
2007
@@ -174,6 +174,15 @@
       <value>samples/blocks/portal/portlets/hello</value>
     </init-param>
 
+    <!--
+      If true or not set, this class will override servlet-path by preferences.
+      If false, it uses a fixed servlet-path.
+    -->
+    <init-param>
+      <name>servlet-path-overriding</name>
+      <value>true</value>
+    </init-param>
+
     <expiration-cache>-1</expiration-cache>
 
     <supports>

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java?view=diff&rev=503698&r1=503697&r2=503698
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java
Mon Feb  5 06:30:30 2007
@@ -51,6 +51,7 @@
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 import javax.portlet.PortletRequest;
+import javax.portlet.PortletPreferences;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -173,6 +174,11 @@
     protected boolean storeSessionPath;
 
     /**
+     * Allow overriding servletPath by request or preferences.
+     */
+    private boolean servletPathOverriding = true;
+
+    /**
      * Initialize this <code>CocoonPortlet</code> instance.
      *
      * <p>Uses the following parameters:
@@ -354,6 +360,8 @@
         }
 
         this.storeSessionPath = getInitParameterAsBoolean("store-session-path", false);
+
+        this.servletPathOverriding = getInitParameterAsBoolean("servlet-path-overriding",
true);
     }
 
     public void processAction(ActionRequest req, ActionResponse res)
@@ -397,13 +405,35 @@
         }
 
         // We got it... Process the request
-        String servletPath = this.servletPath;
-        if (servletPath == null) {
-            servletPath = "portlets/" + getPortletConfig().getPortletName();
+        String uri = this.servletPath;
+        if (uri == null) {
+            uri = "portlets/" + getPortletConfig().getPortletName();
+        }
+
+        // override servlet-path by the request
+        if (servletPathOverriding) {
+            String reqServletPath = (String) request.getAttribute("servlet-path");
+
+            if (reqServletPath != null) {
+                uri = reqServletPath;
+            } else {
+                PortletPreferences prefs = request.getPreferences();
+                
+                if (prefs != null) {
+                    uri = prefs.getValue("servlet-path", uri);
+                }
+            }
+        }
+
+        if (uri.startsWith("/")) {
+            uri = uri.substring(1);
         }
+        if (uri.endsWith("/")) {
+            uri = uri.substring(0, uri.length() - 1);
+        }
+
         String pathInfo = getPathInfo(request);
 
-        String uri = servletPath;
         if (pathInfo != null) {
             uri += pathInfo;
         }
@@ -544,13 +574,35 @@
         }
 
         // We got it... Process the request
-        String servletPath = this.servletPath;
+        String uri = this.servletPath;
         if (servletPath == null) {
-            servletPath = "portlets/" + getPortletConfig().getPortletName();
+            uri = "portlets/" + getPortletConfig().getPortletName();
+        }
+
+        // allow servlet-path override by request or preferences
+        if (servletPathOverriding) {
+            String reqServletPath = (String) request.getAttribute("servlet-path");
+
+            if (reqServletPath != null) {
+                uri = reqServletPath;
+            } else {
+                PortletPreferences prefs = request.getPreferences();
+            
+                if (prefs != null) {
+                    uri = prefs.getValue("servlet-path", uri);
+                }
+            }
+        }
+
+        if (uri.startsWith("/")) {
+            uri = uri.substring(1);
+        }
+        if (uri.endsWith("/")) {
+            uri = uri.substring(0, uri.length() - 1);
         }
+
         String pathInfo = getPathInfo(request);
 
-        String uri = servletPath;
         if (pathInfo != null) {
             uri += pathInfo;
         }

Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/status.xml?view=diff&rev=503698&r1=503697&r2=503698
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Mon Feb  5 06:30:30 2007
@@ -181,6 +181,9 @@
 
   <changes>
   <release version="2.1.11" date="TBD">
+    <action dev="CZ" type="fix" fixes-bug="COCOON-1998" due-to="Woonsan Ko">
+      Portal block: CocoonPortlet needs to allow overriding servlet-path parameter with preferences.
+    </action>
     <action dev="JJ" type="fix" fixes-bug="COCOON-2000" due-to="Abbas Mousavi">
       CForms: Fix "Serialization parameter {indent} must have the value yes or no" error
       in Form.prototype.saveXML() when using Saxon.



Mime
View raw message