Return-Path: Delivered-To: apmail-portals-jetspeed-dev-archive@www.apache.org Received: (qmail 80735 invoked from network); 10 Nov 2007 19:22:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Nov 2007 19:22:28 -0000 Received: (qmail 94500 invoked by uid 500); 10 Nov 2007 19:22:15 -0000 Delivered-To: apmail-portals-jetspeed-dev-archive@portals.apache.org Received: (qmail 94369 invoked by uid 500); 10 Nov 2007 19:22:14 -0000 Mailing-List: contact jetspeed-dev-help@portals.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Jetspeed Developers List" Delivered-To: mailing list jetspeed-dev@portals.apache.org Received: (qmail 94358 invoked by uid 99); 10 Nov 2007 19:22:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 10 Nov 2007 11:22:14 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED 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; Sat, 10 Nov 2007 19:22:26 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D19201A9832; Sat, 10 Nov 2007 11:22:05 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r593807 - in /portals/jetspeed-2/branches/JETSPEED-2.1.3: components/portal/src/java/org/apache/jetspeed/container/ components/portal/src/java/org/apache/jetspeed/container/state/impl/ src/webapp/WEB-INF/assembly/ Date: Sat, 10 Nov 2007 19:22:05 -0000 To: jetspeed-dev@portals.apache.org From: taylor@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071110192205.D19201A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: taylor Date: Sat Nov 10 11:22:03 2007 New Revision: 593807 URL: http://svn.apache.org/viewvc?rev=593807&view=rev Log: http://issues.apache.org/jira/browse/JS2-806 contribution from Mohan Kannapareddy Added: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/PageHistoryValve.java portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/state/impl/SessionFullExtendedNavigationalState.java Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowSessionNavigationalStates.java portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/state/impl/SessionNavigationalState.java portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/pipelines.xml portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/portal-url-generation.xml Added: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/PageHistoryValve.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/PageHistoryValve.java?rev=593807&view=auto ============================================================================== --- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/PageHistoryValve.java (added) +++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/PageHistoryValve.java Sat Nov 10 11:22:03 2007 @@ -0,0 +1,127 @@ +/* + * 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; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.jetspeed.om.page.Page; +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; + + +/** + *

+ * Valve basically mantains the page navigation history by maintaining a previous page id in the session. + * Required by JS2-806 + *

+ * + * @author Mohan Kannapareddy + * @version $Id$ + */ +public class PageHistoryValve extends AbstractValve +{ + protected final Log log = LogFactory.getLog(getClass()); + + // SessionFullExtendedNavigationalState object needs this. + public static final String REQUEST_CLEAR_PORTLETS_MODE_AND_WINDOWSTATE_KEY = "clearPortletsModeAndWindowState"; + + private final String SESSION_PREVIOUS_PAGEID_KEY = "PreviousPageId"; + private boolean valveDisabled = false; + + /* (non-Javadoc) + * @see org.apache.jetspeed.pipeline.valve.AbstractValve#invoke(org.apache.jetspeed.request.RequestContext, org.apache.jetspeed.pipeline.valve.ValveContext) + */ + public void invoke(RequestContext request, ValveContext context) throws PipelineException + { + if (valveDisabled) + { + if (log.isDebugEnabled()) + { + log.debug(toString() + " is DISABLED"); + } + } + else + { //OK, the valve is enabled check and see if are a inter-page nav. + try + { + // create a session if not already created, necessary for Tomcat 5 + request.getRequest().getSession(true); + + Page page = request.getPage(); + String curPageId = page.getId(); + + String prevPageId = (String) request.getSessionAttribute(SESSION_PREVIOUS_PAGEID_KEY); + if (prevPageId == null) + { + //First time, lets set it + request.setSessionAttribute(SESSION_PREVIOUS_PAGEID_KEY, curPageId); + if (log.isDebugEnabled()) + { + log.debug("No previous page Id found in session, setting it for the first time"); + } + } + else + { + + if (prevPageId.equalsIgnoreCase(curPageId)) + { + if (log.isDebugEnabled()) + { + log.debug("Previous page id is same as current page id, not clearing page state"); + } + } + else + { + if (log.isDebugEnabled()) + { + log.debug("Page Change encountered Current Page:" + curPageId + " Prev Page:" + prevPageId); + } + // Make sure we set the prevPageId in session + request.setSessionAttribute(SESSION_PREVIOUS_PAGEID_KEY, curPageId); + // inform NavigationalState object we want to clear all Modes + request.setAttribute(REQUEST_CLEAR_PORTLETS_MODE_AND_WINDOWSTATE_KEY, Boolean.TRUE); + } + } + } + catch (Exception e) + { + throw new PipelineException(e); + } + } + // Pass control to the next Valve in the Pipeline + context.invokeNext(request); + + } + + public String toString() + { + return "PageHistoryValve"; + } + + public void setValveDisabled(boolean valveDisabled) + { + this.valveDisabled = valveDisabled; + } + + public boolean isValveDisabled() + { + return valveDisabled; + } + +} Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowSessionNavigationalStates.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowSessionNavigationalStates.java?rev=593807&r1=593806&r2=593807&view=diff ============================================================================== --- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowSessionNavigationalStates.java (original) +++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowSessionNavigationalStates.java Sat Nov 10 11:22:03 2007 @@ -47,6 +47,76 @@ { this.storeParameters = storeParameters; } + /* + * JS2-806 patch + *

+ * reset all portlets on page to mode VIEW and window state NORMAL in the case of page navigation. + *

+ */ + public void changeAllPortletsToViewModeAndNormalWindowState(RequestContext context, Page page, PortletWindowRequestNavigationalStates requestStates, JetspeedContentCache cache, JetspeedContentCache decorationCache) + { + final PortletMode viewMode = PortletMode.VIEW; + final WindowState normalWindowState = WindowState.NORMAL; + + PageState pageState = (PageState)pageStates.get(page.getId()); + if ( pageState == null ) + { + pageState = new PageState(); + pageStates.put(page.getId(), pageState); + } + + PortletWindowRequestNavigationalState requestState = null; + PortletWindowBaseNavigationalState sessionState = null; + + //remove any maximized windows + if (null != pageState.maximizedWindowId) + { + pageState.windowStates.remove(pageState.maximizedWindowId); + pageState.maximizedWindowId = null; + } + + Iterator iter = requestStates.getWindowIdIterator(); + iter = pageState.windowStates.keySet().iterator(); + String windowId; + while ( iter.hasNext() ) + { + windowId = (String)iter.next(); + requestState = requestStates.getPortletWindowNavigationalState(windowId); + if ( requestState == null ) + { + requestState = new PortletWindowRequestNavigationalState(windowId); + } + //regardless, reset portlet mode and window state + requestState.setPortletMode(viewMode); + requestState.setWindowState(normalWindowState); + // get the session case just in case and create a new one + sessionState = (PortletWindowBaseNavigationalState)pageState.windowStates.get(requestState.getWindowId()); + if ( sessionState == null ) + { + if ( storeParameters ) + { + sessionState = new PortletWindowExtendedNavigationalState(); + } + else + { + sessionState = new PortletWindowBaseNavigationalState(); + } + pageState.windowStates.put(requestState.getWindowId(),sessionState); + } + //Now, sync up. NOTE we should not be in this method if there is an portlet action request. + boolean changed = syncStates(false, requestState,(PortletWindowBaseNavigationalState)pageState.windowStates.get(windowId)); + if (changed) + { + removeFromCache(context, requestState.getWindowId(), cache); + removeFromCache(context, page.getId(), decorationCache); + if (storeParameters) + { + ((PortletWindowExtendedNavigationalState)sessionState).resetDecoratorActionEncodings(); + } + } + + } + } public void sync(RequestContext context, Page page, PortletWindowRequestNavigationalStates requestStates, JetspeedContentCache cache, JetspeedContentCache decorationCache) { Added: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/state/impl/SessionFullExtendedNavigationalState.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/state/impl/SessionFullExtendedNavigationalState.java?rev=593807&view=auto ============================================================================== --- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/state/impl/SessionFullExtendedNavigationalState.java (added) +++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/state/impl/SessionFullExtendedNavigationalState.java Sat Nov 10 11:22:03 2007 @@ -0,0 +1,86 @@ +/* + * 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.state.impl; + +import org.apache.jetspeed.cache.JetspeedContentCache; +import org.apache.jetspeed.container.PageHistoryValve; +import org.apache.jetspeed.request.RequestContext; + +/** + * SessionFullClearOnChangePageNavigationalState, stores all nav parameters in the session, including render parameters + * + * @author Mohan Kannapareddy + * @version $Id$ + */ + +public class SessionFullExtendedNavigationalState extends SessionFullNavigationalState +{ + private boolean clearStateOnPageChangeEnabled = false; + + + public SessionFullExtendedNavigationalState(NavigationalStateCodec codec,JetspeedContentCache cache) + { + super(codec, cache); + } + public SessionFullExtendedNavigationalState(NavigationalStateCodec codec, JetspeedContentCache cache, JetspeedContentCache decorationCache) + { + super(codec, cache, decorationCache); + } + + public SessionFullExtendedNavigationalState(NavigationalStateCodec codec, JetspeedContentCache cache, JetspeedContentCache decorationCache, boolean clearStateOnPageChangeEnabled) + { + super(codec, cache, decorationCache); + this.clearStateOnPageChangeEnabled = clearStateOnPageChangeEnabled; + } + + protected boolean clearPagePortletsModeAndWindowState(RequestContext context) + { + String contextKey = PageHistoryValve.REQUEST_CLEAR_PORTLETS_MODE_AND_WINDOWSTATE_KEY; + boolean result = false; + if (clearStateOnPageChangeEnabled) + { + Boolean pageNavigationEvent = (Boolean) context.getAttribute(contextKey); + if ((pageNavigationEvent != null)) + { + result = pageNavigationEvent.booleanValue(); + } + } + //Just to be safe make it false + context.setAttribute(contextKey, Boolean.FALSE); + + return result; + } + + public synchronized void sync(RequestContext context) + { + // JS2-806, check the session for a psuedo inter page navigation. + boolean resetPagePortlets = false; + if (clearStateOnPageChangeEnabled) + { + resetPagePortlets = clearPagePortletsModeAndWindowState(context); + if (log.isDebugEnabled()) + { + log.debug("resetPagePortlets:" + resetPagePortlets); + } + } + + // push the informaion up to SessionNavigationalState, so that we can handle it appropriately there + setClearPortletsModeAndWindowStateEnabled(resetPagePortlets); + //Inform the super + super.sync(context); + } +} Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/state/impl/SessionNavigationalState.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/state/impl/SessionNavigationalState.java?rev=593807&r1=593806&r2=593807&view=diff ============================================================================== --- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/state/impl/SessionNavigationalState.java (original) +++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/state/impl/SessionNavigationalState.java Sat Nov 10 11:22:03 2007 @@ -21,6 +21,8 @@ import javax.portlet.WindowState; import javax.servlet.http.HttpSession; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.jetspeed.JetspeedActions; import org.apache.jetspeed.cache.JetspeedContentCache; import org.apache.jetspeed.container.state.NavigationalState; @@ -31,12 +33,19 @@ /** * SessionNavigationalState, stores nav parameters in the session, not on URL * + *

+ * Added the ability to reset portlet mode and window states to VIEW and NORMAL in the case + * of page navigation. JS2-806 + *

+ * * @author David Sean Taylor * @version $Id$ */ public class SessionNavigationalState extends AbstractNavigationalState { + protected final Log log = LogFactory.getLog(getClass()); private Map currentPageWindowStates; + private boolean clearPortletsModeAndWindowStateEnabled = false; public SessionNavigationalState(NavigationalStateCodec codec, JetspeedContentCache cache) { @@ -104,7 +113,15 @@ session.setAttribute(NavigationalState.NAVSTATE_SESSION_KEY, sessionStates); } Page page = context.getPage(); - sessionStates.sync(context, (Page) context.getPage(), requestStates, cache, decorationCache); + // JS2-806 + if (isClearPortletsModeAndWindowStateEnabled()) + { + sessionStates.changeAllPortletsToViewModeAndNormalWindowState(context, page, requestStates, cache, decorationCache); + } + else + { + sessionStates.sync(context, (Page) context.getPage(), requestStates, cache, decorationCache); + } if (isNavigationalParameterStateFull() && isRenderParameterStateFull()) { currentPageWindowStates = sessionStates.getWindowStates(page); @@ -126,5 +143,16 @@ public boolean isRenderParameterStateFull() { return false; + } + + protected void setClearPortletsModeAndWindowStateEnabled( + boolean clearPortletsModeAndWindowStateEnabled) + { + this.clearPortletsModeAndWindowStateEnabled = clearPortletsModeAndWindowStateEnabled; + } + + protected boolean isClearPortletsModeAndWindowStateEnabled() + { + return clearPortletsModeAndWindowStateEnabled; } } Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/pipelines.xml URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/pipelines.xml?rev=593807&r1=593806&r2=593807&view=diff ============================================================================== --- portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/pipelines.xml (original) +++ portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/pipelines.xml Sat Nov 10 11:22:03 2007 @@ -172,6 +172,20 @@ + + + + + + + Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/portal-url-generation.xml URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/portal-url-generation.xml?rev=593807&r1=593806&r2=593807&view=diff ============================================================================== --- portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/portal-url-generation.xml (original) +++ portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/portal-url-generation.xml Sat Nov 10 11:22:03 2007 @@ -27,16 +27,26 @@ - - + + - + - + + + + false + --------------------------------------------------------------------- To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org For additional commands, e-mail: jetspeed-dev-help@portals.apache.org