You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by at...@apache.org on 2007/12/20 19:27:40 UTC
svn commit: r605990 - in /portals/jetspeed-2/trunk:
components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/url/impl/
jetspeed-api/src/main/java/org/apache/jetspeed/container/url/
jetspeed-portal-resources/src/main/resources/webapp/WEB-I...
Author: ate
Date: Thu Dec 20 10:27:37 2007
New Revision: 605990
URL: http://svn.apache.org/viewvc?rev=605990&view=rev
Log:
Implementing new feature JS2-834: Automatically cleanup of the PortalURL: no navigational state in browser url
Added:
portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/url/impl/CleanPathInfoEncodedNavStateFromPortalURLValve.java (with props)
Modified:
portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/url/impl/AbstractPortalURL.java
portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/url/impl/PathInfoEncodingPortalURL.java
portals/jetspeed-2/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/container/url/PortalURL.java
portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/pipelines.xml
Modified: portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/url/impl/AbstractPortalURL.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/url/impl/AbstractPortalURL.java?rev=605990&r1=605989&r2=605990&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/url/impl/AbstractPortalURL.java (original)
+++ portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/url/impl/AbstractPortalURL.java Thu Dec 20 10:27:37 2007
@@ -313,4 +313,14 @@
return null;
}
}
+
+ public boolean hasEncodedNavState()
+ {
+ return encodedNavState != null;
+ }
+
+ public boolean isPathInfoEncodingNavState()
+ {
+ return false;
+ }
}
Added: portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/url/impl/CleanPathInfoEncodedNavStateFromPortalURLValve.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/url/impl/CleanPathInfoEncodedNavStateFromPortalURLValve.java?rev=605990&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/url/impl/CleanPathInfoEncodedNavStateFromPortalURLValve.java (added)
+++ portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/url/impl/CleanPathInfoEncodedNavStateFromPortalURLValve.java Thu Dec 20 10:27:37 2007
@@ -0,0 +1,92 @@
+/*
+ * 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.
+ */
+package org.apache.jetspeed.container.url.impl;
+
+import java.io.IOException;
+
+import org.apache.jetspeed.container.state.NavigationalState;
+import org.apache.jetspeed.container.url.PortalURL;
+import org.apache.jetspeed.desktop.JetspeedDesktop;
+import org.apache.jetspeed.pipeline.PipelineException;
+import org.apache.jetspeed.pipeline.valve.AbstractValve;
+import org.apache.jetspeed.pipeline.valve.ValveContext;
+import org.apache.jetspeed.request.RequestContext;
+
+/**
+ * This Valve will clean encoded navstate from the browser url by sending a client side redirect
+ * to the same url with the navstate removed.
+ * <p>
+ * This Valve will only do this:
+ * <ul>
+ * <li>on a GET Render request (not for Resource or Action requests)</li>
+ * <li>the request is not served by the Desktop</li>
+ * <li>the navstate is encoded as PathInfo</li>
+ * <li>all the navstate is maintained in the session (portlet mode, window state and render parameters)</li>
+ * </ul>
+ * </p>
+ * <p>
+ * This valve needs to be added to the portal pipeline *after* the ContainerValve to ensure navstate is properly synchronized with the session.
+ * </p>
+ * <p>
+ * Caveats:<br/>
+ * <ul>
+ * <li>bookmarking browser url will no longer retain nav state, but with SessionFullNavigationState this wasn't really reliable anyway.</li>
+ * <li>back button history is no longer maintained by browsers for GET render urls, somewhat similar to Ajax based requests (e.g. Desktop)</li>
+ * </ul>
+ * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
+ * @version $Id$
+ *
+ */
+public class CleanPathInfoEncodedNavStateFromPortalURLValve extends AbstractValve
+{
+ public void invoke(RequestContext request, ValveContext context) throws PipelineException
+ {
+ NavigationalState state = request.getPortalURL().getNavigationalState();
+ PortalURL portalURL = request.getPortalURL();
+
+ Boolean desktopEnabled = (Boolean) request.getAttribute(JetspeedDesktop.DESKTOP_ENABLED_REQUEST_ATTRIBUTE);
+
+ if (request.getRequest().getMethod().equals("GET") && portalURL.hasEncodedNavState()
+ && portalURL.isPathInfoEncodingNavState() && state.isNavigationalParameterStateFull()
+ && state.isRenderParameterStateFull() && state.getPortletWindowOfAction() == null
+ && state.getPortletWindowOfResource() == null
+ && (desktopEnabled == null || desktopEnabled.booleanValue() == false))
+ {
+ try
+ {
+ StringBuffer location = new StringBuffer(request.getPortalURL().getBasePath());
+ String str = request.getPortalURL().getPath();
+ if (str != null)
+ {
+ location.append(str);
+ }
+ str = request.getRequest().getQueryString();
+ if (str != null && str.length() > 0)
+ {
+ location.append('?').append(request.getRequest().getQueryString());
+ }
+ request.getResponse().sendRedirect(request.getResponse().encodeRedirectURL(location.toString()));
+ }
+ catch (IOException e)
+ {
+ throw new PipelineException(e);
+ }
+ }
+ // Pass control to the next Valve in the Pipeline
+ context.invokeNext(request);
+ }
+}
Propchange: portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/url/impl/CleanPathInfoEncodedNavStateFromPortalURLValve.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/url/impl/CleanPathInfoEncodedNavStateFromPortalURLValve.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/url/impl/CleanPathInfoEncodedNavStateFromPortalURLValve.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/url/impl/PathInfoEncodingPortalURL.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/url/impl/PathInfoEncodingPortalURL.java?rev=605990&r1=605989&r2=605990&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/url/impl/PathInfoEncodingPortalURL.java (original)
+++ portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/url/impl/PathInfoEncodingPortalURL.java Thu Dec 20 10:27:37 2007
@@ -111,5 +111,10 @@
buffer.append(getPath());
}
return buffer.toString();
+ }
+
+ public boolean isPathInfoEncodingNavState()
+ {
+ return true;
}
}
Modified: portals/jetspeed-2/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/container/url/PortalURL.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/container/url/PortalURL.java?rev=605990&r1=605989&r2=605990&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/container/url/PortalURL.java (original)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/container/url/PortalURL.java Thu Dec 20 10:27:37 2007
@@ -172,4 +172,16 @@
* @return a Portal URL with encoded current navigational state
*/
String getPortalURL();
+
+ /**
+ * @return true if navigational state was provided on the url
+ */
+ boolean hasEncodedNavState();
+
+ /**
+ * @return true if navigational state is encoded as pathInfo
+ */
+ boolean isPathInfoEncodingNavState();
+
+
}
Modified: portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/pipelines.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/pipelines.xml?rev=605990&r1=605989&r2=605990&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/pipelines.xml (original)
+++ portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/pipelines.xml Thu Dec 20 10:27:37 2007
@@ -350,6 +350,9 @@
</constructor-arg>
</bean>
+ <bean id="cleanupPortalURLValve"
+ class="org.apache.jetspeed.container.url.impl.CleanPathInfoEncodedNavStateFromPortalURLValve"/>
+
<bean id="jetspeed-pipeline"
class="org.apache.jetspeed.pipeline.JetspeedPipeline"
init-method="initialize"
@@ -373,6 +376,10 @@
<ref bean="containerValve"/>
<ref bean="actionValve"/>
<ref bean="resourceValve"/>
+ <!--
+ JS2-834
+ <ref bean="cleanupPortalURLValve"/>
+ -->
<ref bean="DecorationValve" />
<ref bean="headerAggregatorValvePortal"/>
<ref bean="aggregatorValve"/>
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org