portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r593808 - in /portals/jetspeed-2/trunk: components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/ components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/ jetspeed-portal-resources/src/main/resources/...
Date Sat, 10 Nov 2007 19:23:20 GMT
Author: taylor
Date: Sat Nov 10 11:23:19 2007
New Revision: 593808

URL: http://svn.apache.org/viewvc?rev=593808&view=rev
Log:
http://issues.apache.org/jira/browse/JS2-806
contribution from Mohan Kannapareddy

Added:
    portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/PageHistoryValve.java
    portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/SessionFullExtendedNavigationalState.java
Modified:
    portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/PortletWindowSessionNavigationalStates.java
    portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/SessionNavigationalState.java
    portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/pipelines.xml
    portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/portal-url-generation.xml

Added: portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/PageHistoryValve.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/PageHistoryValve.java?rev=593808&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/PageHistoryValve.java
(added)
+++ portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/PageHistoryValve.java
Sat Nov 10 11:23:19 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;
+
+
+/**
+ * <p>
+ * Valve basically mantains the page navigation history by maintaining a previous page id
in the session.
+ * Required by JS2-806
+ * </p>
+ * 
+ * @author <a href="mailto:kmoh.raj@gmail.com">Mohan Kannapareddy</a>
+ * @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/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/PortletWindowSessionNavigationalStates.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/PortletWindowSessionNavigationalStates.java?rev=593808&r1=593807&r2=593808&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/PortletWindowSessionNavigationalStates.java
(original)
+++ portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/PortletWindowSessionNavigationalStates.java
Sat Nov 10 11:23:19 2007
@@ -47,6 +47,76 @@
     {
         this.storeParameters = storeParameters;
     }
+    /*
+     * JS2-806 patch
+     * <p>
+     *   reset all portlets on page to mode VIEW and window state NORMAL in the case of page
navigation.
+     * </p>
+     */
+    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/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/SessionFullExtendedNavigationalState.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/SessionFullExtendedNavigationalState.java?rev=593808&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/SessionFullExtendedNavigationalState.java
(added)
+++ portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/SessionFullExtendedNavigationalState.java
Sat Nov 10 11:23:19 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 <a href="mailto:kmoh.raj@gmail.com">Mohan Kannapareddy</a>
+ * @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/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/SessionNavigationalState.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/SessionNavigationalState.java?rev=593808&r1=593807&r2=593808&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/SessionNavigationalState.java
(original)
+++ portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/SessionNavigationalState.java
Sat Nov 10 11:23:19 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
  *
+ * <p>
+ * Added the ability to reset portlet mode and window states to VIEW and NORMAL in the case
+ * of page navigation. JS2-806
+ * </p>
+ *
  * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
  * @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/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=593808&r1=593807&r2=593808&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
Sat Nov 10 11:23:19 2007
@@ -35,6 +35,31 @@
    </constructor-arg>
   </bean> 
   
+  <!-- 
+      To customize capabilityMap and requestContext on capabilities,
+      add this valve after each capabilityValve entry in the pipeline configs 
+      below
+   -->  
+  <bean id="capabilityCustomizerValve"
+        class="org.apache.jetspeed.capabilities.impl.CapabilityCustomizerValveImpl"
+        init-method="initialize"
+  >
+   <constructor-arg>
+       <ref bean="org.apache.jetspeed.capabilities.Capabilities" />
+   </constructor-arg>
+   <!-- client name to media type mapping
+   If a client has same preferred mime type (e.g. text/html) but 
+   it should be treated with other media type,
+   put additional mapping(s) below.
+   -->
+   <constructor-arg>
+       <map>
+           <!-- If a client is IE4 of Pocket PC, then the media type will be html-basic.
-->
+           <entry key="ie4ppc" value="html-basic" />
+       </map>
+   </constructor-arg>
+  </bean> 
+  
   <bean id="portalURLValve"
         class="org.apache.jetspeed.container.url.impl.PortalURLValveImpl"
         init-method="initialize"
@@ -147,6 +172,20 @@
    </constructor-arg>
   </bean>
 
+  <!--
+    JS2-806 
+      - this valve effectively maintains a previous page id in the session giving the downstream
valve
+        the ability to manipulate inter-page navigation characterstics.
+        
+        default : "true" (effectively disables the valve)
+                : "false" (enables it and sets the previous page id in session)
+   -->
+  <bean id="pageHistoryValve"
+        class="org.apache.jetspeed.container.PageHistoryValve"
+        init-method="initialize">
+        <property name="valveDisabled" value="true" />
+  </bean>
+  
   <bean id="containerValve"
         class="org.apache.jetspeed.container.ContainerValve"
         init-method="initialize"
@@ -352,6 +391,10 @@
       <ref bean="passwordCredentialValve"/>
       <ref bean="loginValidationValve"/>
       <ref bean="profilerValve"/>
+      <!--
+        JS2-806  
+       -->
+      <ref bean="pageHistoryValve"/>
       <ref bean="containerValve"/>
       <ref bean="actionValve"/>
       <ref bean="resourceValve"/>

Modified: portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/portal-url-generation.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/portal-url-generation.xml?rev=593808&r1=593807&r2=593808&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/portal-url-generation.xml
(original)
+++ portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/portal-url-generation.xml
Sat Nov 10 11:23:19 2007
@@ -27,16 +27,26 @@
   
   <!-- Navigation state we are currently using -->
   <bean id="NavigationalState" 
-  	   class="org.apache.jetspeed.container.state.impl.SessionFullNavigationalState"
+  	   class="org.apache.jetspeed.container.state.impl.SessionFullExtendedNavigationalState"
 	   singleton="false"
   >  	 
-       <constructor-arg><ref bean="NavigationalStateCodec"/></constructor-arg>
-       <constructor-arg>
+       <constructor-arg index='0'><ref bean="NavigationalStateCodec"/></constructor-arg>
+       <constructor-arg index='1'>
         	<ref bean="portletContentCache"/>
        </constructor-arg>       
-       <constructor-arg>
+       <constructor-arg index='2'>
         	<ref bean="decorationContentCache"/>
-       </constructor-arg>       
+       </constructor-arg>
+       <!--
+        JS2-806 
+           - set this to true along with PageHistoryValve will enable clearing the mode and
window state of
+            all portlets in the current page request.
+           - setting this to false effectively disables this, and reverts to the default

+             SessionFullNavigationalState object behaviour
+        -->
+       <constructor-arg index='3'>
+            <value>false</value>
+       </constructor-arg>
   </bean>
   
   <!-- PortalURL we are currently using -->



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message