Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 62312 invoked from network); 5 Feb 2007 14:30:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Feb 2007 14:30:54 -0000 Received: (qmail 36291 invoked by uid 500); 5 Feb 2007 14:31:01 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 36234 invoked by uid 500); 5 Feb 2007 14:31:00 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 36218 invoked by uid 99); 5 Feb 2007 14:31:00 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Feb 2007 06:31:00 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Feb 2007 06:30:53 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 1DFA71A981A; Mon, 5 Feb 2007 06:30:33 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: cvs@cocoon.apache.org From: cziegeler@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070205143033.1DFA71A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 @@ samples/blocks/portal/portlets/hello + + + servlet-path-overriding + true + + -1 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 CocoonPortlet instance. * *

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 @@ + + Portal block: CocoonPortlet needs to allow overriding servlet-path parameter with preferences. + CForms: Fix "Serialization parameter {indent} must have the value yes or no" error in Form.prototype.saveXML() when using Saxon.