portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r758136 [2/2] - in /portals/jetspeed-2/portal/trunk: components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/ components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/providers/ components/jetspeed-portal/s...
Date Wed, 25 Mar 2009 03:30:51 GMT
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/PortletWindowRequestNavigationalState.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/PortletWindowRequestNavigationalState.java?rev=758136&r1=758135&r2=758136&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/PortletWindowRequestNavigationalState.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/PortletWindowRequestNavigationalState.java Wed Mar 25 03:30:49 2009
@@ -16,9 +16,16 @@
  */
 package org.apache.jetspeed.container.state.impl;
 
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.xml.namespace.QName;
+
+import org.apache.jetspeed.om.portlet.ContainerRuntimeOption;
+import org.apache.jetspeed.om.portlet.PortletDefinition;
+import org.apache.pluto.container.om.portlet.PublicRenderParameter;
+
 /**
  * PortletWindowRequestNavigationalState
  *
@@ -30,10 +37,15 @@
     private static final long serialVersionUID = 3807035638733358425L;
 
     private String windowId;
+    private PortletDefinition pd;
     private String cacheLevel;
     private String resourceId;
     private Map<String, String[]> privateRenderParametersMap;
+    private Map<String, String[]> targetPublicRenderParmaetersMap;
     private Map<String, String[]> publicRenderParametersMap;
+    private Map<QName, String> qnameToIdentifierMap;
+    private Map<String, QName> identifierToQNameMap;
+    private boolean targetted;
     
     /**
      * true if for a targeted PortletWindow using StateFullParameters the saved (in the session) render parameters
@@ -44,9 +56,8 @@
      */
     private boolean clearParameters;
 
-    public PortletWindowRequestNavigationalState(String windowId, boolean actionScopedRequestAttributes)
+    public PortletWindowRequestNavigationalState(String windowId)
     {
-        super(actionScopedRequestAttributes);
         this.windowId = windowId;
     }
 
@@ -54,6 +65,67 @@
     {
         return windowId;
     }
+    
+    public void setPortletDefinition(PortletDefinition pd)
+    {
+        this.pd = pd;
+    }
+    
+    public void resolveActionScopedRequestAttributes()
+    {
+        if (pd != null)
+        {
+            ContainerRuntimeOption actionScopedRequestAttributesOption = 
+                pd.getContainerRuntimeOption(ContainerRuntimeOption.ACTION_SCOPED_REQUEST_ATTRIBUTES_OPTION);
+            if (actionScopedRequestAttributesOption == null)
+            {
+                actionScopedRequestAttributesOption = 
+                    pd.getApplication().getContainerRuntimeOption(ContainerRuntimeOption.ACTION_SCOPED_REQUEST_ATTRIBUTES_OPTION);
+            }
+            setActionScopedRequestAttributes((actionScopedRequestAttributesOption != null) &&
+                                             (actionScopedRequestAttributesOption.getValues() != null) &&
+                                             (actionScopedRequestAttributesOption.getValues().size() > 0) &&
+                                             Boolean.parseBoolean(actionScopedRequestAttributesOption.getValues().get(0)));
+        }
+    }
+    
+    public void resolvePublicRenderParametersMapping()
+    {
+        if (pd != null && qnameToIdentifierMap != null)
+        {
+            qnameToIdentifierMap = new HashMap<QName, String>();
+            identifierToQNameMap = new HashMap<String, QName>();
+            for (String identifier : pd.getSupportedPublicRenderParameters())
+            {
+                PublicRenderParameter prp = pd.getApplication().getPublicRenderParameter(identifier);
+                if (prp != null)
+                {
+                    qnameToIdentifierMap.put(prp.getQName(), identifier);
+                    identifierToQNameMap.put(identifier, prp.getQName());
+                }
+            }
+        }
+    }
+    
+    public PortletDefinition getPortletDefinition()
+    {
+        return pd;
+    }
+    
+    public Map<QName, String> getPublicRenderParametersQNameToIdentifierMap()
+    {
+        return qnameToIdentifierMap;
+    }
+    
+    public QName getPublicRenderParameterQNameByIdentifier(String identifier)
+    {
+        return identifierToQNameMap != null ? identifierToQNameMap.get(identifier) : null;
+    }
+        
+    public String getPublicRenderParameterIdentifierByQName(QName qname)
+    {
+        return qnameToIdentifierMap != null ? qnameToIdentifierMap.get(qname) : null;
+    }
         
     public String getCacheLevel()
     {
@@ -77,6 +149,10 @@
 
     public Map<String, String[]> getPrivateRenderParametersMap()
     {
+        if (privateRenderParametersMap == null)
+        {
+            privateRenderParametersMap = Collections.emptyMap();
+        }
         return privateRenderParametersMap;
     }
 
@@ -84,7 +160,7 @@
     {
         if (privateRenderParametersMap == null)
         {
-            privateRenderParametersMap = new HashMap<String, String[]>();
+            privateRenderParametersMap = Collections.emptyMap();
         }
         privateRenderParametersMap.put(name, values);
     }    
@@ -96,15 +172,12 @@
     
     public Map<String, String[]> getPublicRenderParametersMap()
     {
+        // leave handling null return value to caller
         return publicRenderParametersMap;
     }
 
     public void setPublicRenderParameters(String name, String[] values)
     {
-        if ( publicRenderParametersMap == null )
-        {
-            publicRenderParametersMap = new HashMap<String, String[]>();
-        }
         publicRenderParametersMap.put(name, values);
     }    
     
@@ -113,6 +186,16 @@
         this.publicRenderParametersMap = publicRenderParametersMap;
     }
     
+    public Map<String, String[]> getTargetPublicRenderParametersMap()
+    {
+        return this.targetPublicRenderParmaetersMap;
+    }
+    
+    public void setTargetPublicRenderParametersMap(Map<String, String[]> map)
+    {
+        this.targetPublicRenderParmaetersMap = map;
+    }
+    
     public boolean isClearParameters()
     {
         return clearParameters;
@@ -122,4 +205,14 @@
     {
         this.clearParameters = ignoreParameters;
     }
+    
+    public boolean isTargetted()
+    {
+        return targetted;
+    }
+    
+    public void setTargetted(boolean targetted)
+    {
+        this.targetted = targetted;
+    }
 }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/PortletWindowRequestNavigationalStates.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/PortletWindowRequestNavigationalStates.java?rev=758136&r1=758135&r2=758136&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/PortletWindowRequestNavigationalStates.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/PortletWindowRequestNavigationalStates.java Wed Mar 25 03:30:49 2009
@@ -33,6 +33,7 @@
     private PortletWindow maximizedWindow;
     private PortletWindow actionWindow;
     private PortletWindow resourceWindow;
+    private String targetWindowId;
     private Map<QName, String[]> publicRenderParametersMap;
     
     public PortletWindowRequestNavigationalStates(String characterEncoding)
@@ -45,6 +46,11 @@
         return characterEncoding;
     }
     
+    public Map<String, PortletWindowRequestNavigationalState> getPortletWindowRequestNavigationalStates()
+    {
+        return pwnStates;
+    }
+    
     public Iterator<String> getWindowIdIterator()
     {
         return pwnStates.keySet().iterator();
@@ -82,7 +88,7 @@
     
     public PortletWindowRequestNavigationalState getPortletWindowNavigationalState(String windowId)
     {
-        return (PortletWindowRequestNavigationalState)pwnStates.get(windowId);
+        return pwnStates.get(windowId);
     }
     
     public void addPortletWindowNavigationalState(String windowId, PortletWindowRequestNavigationalState pwnState)
@@ -116,32 +122,50 @@
     {
         return resourceWindow;
     }
-
-    public Map<QName, String[]> getPublicRenderParametersMap()
+    
+    public void setTargetWindowId(String windowId)
     {
-        return publicRenderParametersMap;
+        this.targetWindowId = windowId;
     }
-
-    public void setPublicRenderParametersMap(Map<QName, String[]> publicRenderParametersMap)
+    
+    public String getTargetWindowId()
     {
-        this.publicRenderParametersMap = publicRenderParametersMap;
+        return targetWindowId;
     }
 
-    public void setPublicRenderParameters(QName qname, String[] values)
+    public Map<QName, String[]> getPublicRenderParametersMap()
     {
-        if (publicRenderParametersMap == null)
-        {
-            publicRenderParametersMap = new HashMap<QName, String[]>();
-        }
-        publicRenderParametersMap.put(qname, values);
-    }    
+        return publicRenderParametersMap;
+    }
     
-    public void addPublicRenderParametersMap(Map<QName, String[]> publicRenderParametersMap)
+    public Map<String, String[]> getPublicRenderParametersMap(String windowId)
     {
-        if (this.publicRenderParametersMap == null)
+        Map<String, String[]> map = null;
+        PortletWindowRequestNavigationalState state = pwnStates.get(windowId);
+        if (state != null && state.getPublicRenderParametersMap() == null)
         {
-            this.publicRenderParametersMap = new HashMap<QName, String[]>();
-        }
-        this.publicRenderParametersMap.putAll(publicRenderParametersMap);
+            if (publicRenderParametersMap != null && state.getPublicRenderParametersQNameToIdentifierMap() != null)
+            {
+                for (Map.Entry<QName, String> entry : state.getPublicRenderParametersQNameToIdentifierMap().entrySet())
+                {
+                    String[] values = publicRenderParametersMap.get(entry.getKey());
+                    if (values != null)
+                    {
+                        if (map == null)
+                        {
+                            map = new HashMap<String, String[]>();
+                        }
+                        map.put(entry.getValue(), values);
+                    }
+                }
+            }
+            state.setPublicRenderParametersMap(map);
+        }        
+        return map;
+    }
+    
+    public void setPublicRenderParametersMap(Map<QName, String[]> publicRenderParametersMap)
+    {
+        this.publicRenderParametersMap = publicRenderParametersMap;
     }
 }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/PortletWindowSessionNavigationalStates.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/PortletWindowSessionNavigationalStates.java?rev=758136&r1=758135&r2=758136&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/PortletWindowSessionNavigationalStates.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/PortletWindowSessionNavigationalStates.java Wed Mar 25 03:30:49 2009
@@ -26,10 +26,8 @@
 import javax.portlet.WindowState;
 import javax.xml.namespace.QName;
 
-import org.apache.jetspeed.Jetspeed;
 import org.apache.jetspeed.cache.ContentCacheKey;
 import org.apache.jetspeed.cache.JetspeedContentCache;
-import org.apache.jetspeed.container.window.PortletWindowAccessor;
 import org.apache.jetspeed.om.page.Page;
 import org.apache.jetspeed.request.RequestContext;
 import org.apache.jetspeed.container.PortletWindow;
@@ -38,7 +36,7 @@
 {
     private static final long serialVersionUID = -2891442112700830546L;
 
-    private static final class PageState implements Serializable
+    static final class PageState implements Serializable
     {
         private static final long serialVersionUID = -2730733728229116932L;
         
@@ -46,14 +44,12 @@
         public String maximizedWindowId;
     }
 
-    private final SessionNavigationalState navState;
     private final boolean storeParameters;
     private Map<String, PageState> pageStates = new HashMap<String, PageState>();
-    private Map<QName, String[]> publicRenderParametersMap = Collections.synchronizedMap(new HashMap<QName, String[]>());
+    private Map<QName, ValuesAndWindowUsage> publicRenderParametersMap = Collections.synchronizedMap(new HashMap<QName, ValuesAndWindowUsage>());
 
-    public PortletWindowSessionNavigationalStates(SessionNavigationalState navState, boolean storeParameters)
+    public PortletWindowSessionNavigationalStates(boolean storeParameters)
     {
-        this.navState = navState;
         this.storeParameters = storeParameters;
     }
     
@@ -92,55 +88,99 @@
         }
         synchronized (pageState.windowStates)
         {
-            Iterator<String> iter = requestStates.getWindowIdIterator();
-            iter = pageState.windowStates.keySet().iterator();
+            Iterator<String> iter = pageState.windowStates.keySet().iterator();
             String windowId;
             while ( iter.hasNext() )
             {
-                windowId = (String)iter.next();
+                windowId = iter.next();
                 requestState = requestStates.getPortletWindowNavigationalState(windowId);
+                sessionState = pageState.windowStates.get(windowId);
                 if ( requestState == null )
                 {
-                    requestState = new PortletWindowRequestNavigationalState(windowId, navState.getActionScopedRequestAttributes(windowId));
+                    requestState = new PortletWindowRequestNavigationalState(windowId);
+                    requestState.setActionScopedRequestAttributes(sessionState.isActionScopedRequestAttributes());
                 }
                 //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(requestState.isActionScopedRequestAttributes());
-                    }
-                    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, requestStates, requestState, (PortletWindowBaseNavigationalState)pageState.windowStates.get(windowId));
+                boolean changed = syncStates(false, requestStates, requestState, sessionState);
                 if (changed)
                 {
-                    removeFromCache(context, requestState.getWindowId(), cache);
-                    removeFromCache(context, page.getId(), decorationCache);                    
+                    removeFromCache(context, windowId, cache);
+                    removeFromCache(context, page.getId(), decorationCache);   
                     if (storeParameters)
                     {
                         ((PortletWindowExtendedNavigationalState)sessionState).resetDecoratorActionEncodings();
                     }
                 }
+                syncPublicRequestParameters(context, requestStates, false, cache, decorationCache);
             }      
         } 
     }
     
-    public void sync(RequestContext context, Page page, PortletWindowRequestNavigationalStates requestStates, JetspeedContentCache cache, JetspeedContentCache decorationCache)    
+    public void syncPublicRequestParameters(RequestContext context, PortletWindowRequestNavigationalStates requestStates, 
+                                               boolean transientNavState, 
+                                               JetspeedContentCache cache, JetspeedContentCache decorationCache)
+    {
+        // sync session states public render parameters
+        if (!transientNavState && requestStates.getPublicRenderParametersMap() != null)
+        {            
+            for (Iterator<Map.Entry<QName, String[]>> iter = requestStates.getPublicRenderParametersMap().entrySet().iterator(); iter.hasNext(); )
+            {
+                Map.Entry<QName, String[]> entry = iter.next();
+                ValuesAndWindowUsage vawu = publicRenderParametersMap.get(entry.getKey());
+                if (vawu != null && changedParameterValues(entry.getValue(), vawu.getValues()))
+                {
+                    if (vawu.getWindowIds() != null)
+                    {
+                        for (String windowId : vawu.getWindowIds())
+                        {
+                            removeFromCache(context, windowId, cache);
+                        }
+                        for (String pageId : vawu.getPageIds())
+                        {
+                            removeFromCache(context, pageId, decorationCache);
+                        }
+                    }
+                    if (entry.getValue() == null)
+                    {
+                        iter.remove();
+                    }
+                    else
+                    {
+                        vawu.setValues(entry.getValue());
+                    }
+                }
+            }
+        }
+        
+        if (!publicRenderParametersMap.isEmpty())
+        {
+            Map<QName, String[]> map = requestStates.getPublicRenderParametersMap();
+            if (map == null)
+            {
+                map = new HashMap<QName, String[]>();
+            }
+            for (Map.Entry<QName, ValuesAndWindowUsage> entry : publicRenderParametersMap.entrySet())
+            {
+                if (!map.containsKey(entry.getKey()))
+                {
+                    map.put(entry.getKey(), entry.getValue().getValues());
+                }
+            }
+            requestStates.setPublicRenderParametersMap(map);
+        }
+    }
+    
+    public void sync(RequestContext context, Page page, 
+                     PortletWindowRequestNavigationalStates requestStates, 
+                     JetspeedContentCache cache, JetspeedContentCache decorationCache)
     {
         PageState pageState = null;
         synchronized (pageStates)
         {
-            pageState = (PageState)pageStates.get(page.getId());
+            pageState = pageStates.get(page.getId());
             if (pageState == null)
             {
                 pageState = new PageState();
@@ -175,11 +215,7 @@
                 }
                 else
                 {
-                    // check PortletWindow still exists...
-                    // depends on PortletWindowAccessor cache to be active
-                    PortletWindowAccessor accessor = 
-                        (PortletWindowAccessor)Jetspeed.getComponentManager().getComponent(PortletWindowAccessor.class);
-                    PortletWindow maximizedWindow = accessor.getPortletWindow(pageState.maximizedWindowId);
+                    PortletWindow maximizedWindow = context.resolvePortletWindow(pageState.maximizedWindowId);
                     if ( maximizedWindow == null )
                     {
                         // gone: remove sessionState
@@ -197,7 +233,7 @@
                 // When can a non-maximized window request maximized state while another already has it?
                 // Maybe from a decoration portlet which always needs to be viewable?
                 requestState = requestStates.getPortletWindowNavigationalState(pageState.maximizedWindowId);
-                sessionState = (PortletWindowBaseNavigationalState)pageState.windowStates.get(pageState.maximizedWindowId);
+                sessionState = pageState.windowStates.get(pageState.maximizedWindowId);
                 if ( requestState == null || requestState.getWindowState() == null )
                 {
                     // need to clear it ourselves first
@@ -214,22 +250,23 @@
         
         // now synchronize requestStates and sessionStates
         Iterator<String> iter = requestStates.getWindowIdIterator();
-        String actionWindowId = requestStates.getActionWindow() != null ? requestStates.getActionWindow().getId().toString() : null;
+        String actionWindowId = requestStates.getActionWindow() != null ? requestStates.getActionWindow().getWindowId() : null;
         boolean actionRequestState = false;
         while ( iter.hasNext() )
         {
-            requestState = requestStates.getPortletWindowNavigationalState((String)iter.next());
-            sessionState = (PortletWindowBaseNavigationalState)pageState.windowStates.get(requestState.getWindowId());
+            requestState = requestStates.getPortletWindowNavigationalState(iter.next());
+            sessionState = pageState.windowStates.get(requestState.getWindowId());
             if ( sessionState == null )
             {
                 if ( storeParameters )
                 {
-                    sessionState = new PortletWindowExtendedNavigationalState(requestState.isActionScopedRequestAttributes());
+                    sessionState = new PortletWindowExtendedNavigationalState();
                 }
                 else
                 {
                     sessionState = new PortletWindowBaseNavigationalState();
                 }
+                sessionState.setActionScopedRequestAttributes(requestState.isActionScopedRequestAttributes());
                 pageState.windowStates.put(requestState.getWindowId(),sessionState);
             }
 
@@ -247,144 +284,44 @@
         }
 
         // now copy missing requestStates from the pageState
-        synchronized (pageState.windowStates)
+        synchronized(pageState.windowStates)
         {
             iter = pageState.windowStates.keySet().iterator();
             String windowId;
             while ( iter.hasNext() )
             {
-                windowId = (String)iter.next();
+                windowId = iter.next();
                 requestState = requestStates.getPortletWindowNavigationalState(windowId);
                 if ( requestState == null )
                 {
-                    requestState = new PortletWindowRequestNavigationalState(windowId, navState.getActionScopedRequestAttributes(windowId));
-                    boolean changed = syncStates(false, requestStates, requestState, (PortletWindowBaseNavigationalState)pageState.windowStates.get(windowId));
-                    requestStates.addPortletWindowNavigationalState(windowId, requestState);
-                    if (changed)
-                    {
-                        removeFromCache(context, requestState.getWindowId(), cache);
-                        removeFromCache(context, page.getId(), decorationCache);                    
-                        if (storeParameters)
-                        {
-                            sessionState = pageState.windowStates.get(windowId);
-                            ((PortletWindowExtendedNavigationalState)sessionState).resetDecoratorActionEncodings();
-                        }
-                    }
-                }
-            }
-        }        
-
-        // sync session states public render parameters
-        Map<QName, String[]> changedPublicRenderParametersMap = null;
-        requestStates.setPublicRenderParametersMap(new HashMap<QName, String[]>());
-        iter = requestStates.getWindowIdIterator();
-        while (iter.hasNext())
-        {
-            String windowId = iter.next();
-            requestState = requestStates.getPortletWindowNavigationalState(windowId);
-            if (requestState.getPublicRenderParametersMap() != null)
-            {
-                // determine changed session states public render parameters
-                for (Map.Entry<String, String[]> parameter : requestState.getPublicRenderParametersMap().entrySet())
-                {
-                    String parameterName = parameter.getKey();
-                    String[] requestParameterValues = parameter.getValue();
-                    // get qname for request public render parameter name
-                    QName parameterQName = navState.getPublicRenderParameterQName(windowId, parameterName);
-                    if (parameterQName != null)
-                    {
-                        String[] sessionParameterValues = publicRenderParametersMap.get(parameterQName);
-                        if (changedParameterValues(requestParameterValues, sessionParameterValues))
-                        {
-                            // track changed public render parameter qnames and values
-                            if (changedPublicRenderParametersMap == null)
-                            {
-                                changedPublicRenderParametersMap = new HashMap<QName, String[]>();
-                            }
-                            changedPublicRenderParametersMap.put(parameterQName, requestParameterValues);
-                        }
-                    }
-                }
-            }
-        }
-        
-        // sync session states public render parameter changes
-        if (changedPublicRenderParametersMap != null)
-        {
-            for (Map.Entry<QName, String[]> parameterChange : changedPublicRenderParametersMap.entrySet())
-            {
-                QName changedParameterQName = parameterChange.getKey();
-                String[] changedParameterValues = parameterChange.getValue();
-                if (changedParameterValues != null)
-                {
-                    // sync new or updated public render parameter value
-                    publicRenderParametersMap.put(changedParameterQName, changedParameterValues);
-                }
-                else
-                {
-                    // null public render parameter value implies delete
-                    publicRenderParametersMap.remove(changedParameterQName);                    
-                }
-            }
-        }
-        
-        // clear cached contexts and encodings if public render parameters have changed
-        if (changedPublicRenderParametersMap != null)
-        {
-            // find pages and windows in session state that have public render parameters
-            synchronized (pageStates)
-            {
-                for (Map.Entry<String, PageState> sessionPageState : pageStates.entrySet())
-                {
-                    String pageId = sessionPageState.getKey();
-                    Map<String, PortletWindowBaseNavigationalState> windowStates = sessionPageState.getValue().windowStates;
-                    for (Map.Entry<String, PortletWindowBaseNavigationalState> windowState : windowStates.entrySet())
+                    if (context.resolvePortletWindow(windowId) != null)
                     {
-                        String windowId = windowState.getKey();
-                        sessionState = windowState.getValue();
-                        // test window for changed public render parameter qnames
-                        if (navState.hasPublicRenderParameterQNames(windowId, changedPublicRenderParametersMap.keySet()))
+                        requestState = new PortletWindowRequestNavigationalState(windowId);
+                        sessionState = pageState.windowStates.get(windowId);
+                        requestState.setActionScopedRequestAttributes(sessionState.isActionScopedRequestAttributes());
+                        requestStates.addPortletWindowNavigationalState(windowId, requestState);
+                        boolean changed = syncStates(false, requestStates, requestState, sessionState);
+                        if (changed)
                         {
-                            // clear cached items associated with window
                             removeFromCache(context, windowId, cache);
-                            removeFromCache(context, pageId, decorationCache);                    
+                            removeFromCache(context, page.getId(), decorationCache);                    
                             if (storeParameters)
                             {
+                                sessionState = pageState.windowStates.get(windowId);
                                 ((PortletWindowExtendedNavigationalState)sessionState).resetDecoratorActionEncodings();
-                            }                            
+                            }
                         }
                     }
-                }
-            }
-        }
-        
-        // reset and sync request states public render parameters
-        requestStates.setPublicRenderParametersMap(null);
-        iter = requestStates.getWindowIdIterator();
-        while (iter.hasNext())
-        {
-            String windowId = iter.next();
-            requestState = requestStates.getPortletWindowNavigationalState(windowId);
-            requestState.setPublicRenderParametersMap(null);
-            // get all public render parameter names for window
-            Map<String, QName> parameterNames = navState.getPublicRenderParameterNamesMap(windowId);
-            if (parameterNames != null)
-            {
-                // get synced session public render parameter values 
-                for (Map.Entry<String, QName> parameterNamesEntry : parameterNames.entrySet())
-                {
-                    QName parameterQName = parameterNamesEntry.getValue();
-                    String[] parameterValues = publicRenderParametersMap.get(parameterQName);
-                    if (parameterValues != null)
-                    {
-                        // refresh request state and states public render parameters
-                        String parameterName = parameterNamesEntry.getKey();
-                        requestState.setPublicRenderParameters(parameterName, parameterValues);
-                        requestStates.setPublicRenderParameters(parameterQName, parameterValues);
+                    else
+                    {
+                        removeFromCache(context, windowId, cache);
+                        removeFromCache(context, page.getId(), decorationCache);                    
+                        iter.remove();
                     }
                 }
             }
-        }
+        }        
+        syncPublicRequestParameters(context, requestStates, false, cache, decorationCache);
     }
     
     private boolean modeChanged(PortletMode req, PortletMode ses)
@@ -428,7 +365,9 @@
     }
 
     
-    private boolean syncStates(boolean actionRequestState, PortletWindowRequestNavigationalStates requestStates, PortletWindowRequestNavigationalState requestState, PortletWindowBaseNavigationalState sessionState)
+    private boolean syncStates(boolean actionRequestState,
+                               PortletWindowRequestNavigationalStates requestStates, PortletWindowRequestNavigationalState requestState, 
+                               PortletWindowBaseNavigationalState sessionState)
     {
         boolean changed = false;
         
@@ -478,6 +417,12 @@
             requestState.setWindowState(sessionState.getWindowState());
         }
         
+        if (requestState.isActionScopedRequestAttributes() != sessionState.isActionScopedRequestAttributes())
+        {
+            changed = true;
+            sessionState.setActionScopedRequestAttributes(requestState.isActionScopedRequestAttributes());
+        }
+        
         if (storeParameters)
         {
             // sync parameters
@@ -507,8 +452,8 @@
                 requestState.setParametersMap(new HashMap<String, String[]>(extendedSessionState.getParametersMap()));
             }
             
-            // sync action scope parameter
-            if (requestState.isActionScopedRequestAttributes() && extendedSessionState.isActionScopedRequestAttributes())
+            // sync action scope parameters
+            if (requestState.isActionScopedRequestAttributes())
             {
                 if (requestState.getActionScopeId() != null)
                 {
@@ -530,6 +475,14 @@
                     requestState.setActionScopeRendered(extendedSessionState.isActionScopeRendered());                
                 }
             }
+            else
+            {
+                // clear out any action scope parameters
+                requestState.setActionScopeId(null);
+                requestState.setActionScopeRendered(false);
+                extendedSessionState.setActionScopeId(null);
+                extendedSessionState.setActionScopeRendered(false);
+            }
 
             // reset clear parameters
             if (requestState.isClearParameters())
@@ -601,7 +554,7 @@
     
     protected Map<String, PortletWindowBaseNavigationalState> getWindowStates(Page page)
     {
-        PageState pageState = (PageState)pageStates.get(page.getId());
+        PageState pageState = pageStates.get(page.getId());
         return pageState != null ? pageState.windowStates : null;
     }
 }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/SessionFullExtendedNavigationalState.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/SessionFullExtendedNavigationalState.java?rev=758136&r1=758135&r2=758136&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/SessionFullExtendedNavigationalState.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/SessionFullExtendedNavigationalState.java Wed Mar 25 03:30:49 2009
@@ -65,7 +65,7 @@
     	return result;
     }
     
-    public synchronized void sync(RequestContext context)
+    public synchronized boolean sync(RequestContext context)
     {
         // JS2-806, check the session for a psuedo inter page navigation.
         boolean resetPagePortlets = false;
@@ -81,6 +81,6 @@
         // push the informaion up to SessionNavigationalState, so that we can handle it appropriately there
         setClearPortletsModeAndWindowStateEnabled(resetPagePortlets);
         //Inform the super
-        super.sync(context);
+        return super.sync(context);
     }
 }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/SessionNavigationalState.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/SessionNavigationalState.java?rev=758136&r1=758135&r2=758136&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/SessionNavigationalState.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/SessionNavigationalState.java Wed Mar 25 03:30:49 2009
@@ -55,78 +55,99 @@
     public SessionNavigationalState(NavigationalStateCodec codec, JetspeedContentCache cache, JetspeedContentCache decorationCache)
     {
         super(codec, cache, decorationCache);
-    }    
-
-    public synchronized void sync(RequestContext context)
+    }
+    
+    public boolean sync(RequestContext context)
     {
-        PortletWindowRequestNavigationalStates requestStates = getPortletWindowRequestNavigationalStates();
-        
-        // for Resource (PortletURL) requests, session state is never synchronized
-        boolean transientNavState = requestStates.getResourceWindow() != null;
-        
-        String clearCacheWindowId = null;
-        
-        if (!transientNavState)
+        HttpSession session = context.getRequest().getSession();
+        Object syncLock = session;
+        if (syncLock == null)
         {
-            // Check if a maximized window is set in the request.
-            // This can mean a window with state MAXIMIZED *or* SOLO.
-            // With a SOLO state, also skip all synchroniziations!
-            String requestMaximizedWindowId = null;
-            
-            if ( requestStates.getMaximizedWindow() != null )
-            {
-                requestMaximizedWindowId = requestStates.getMaximizedWindow().getId().toString();
-                WindowState state = requestStates.getPortletWindowNavigationalState(requestMaximizedWindowId).getWindowState();
-                transientNavState = JetspeedActions.SOLO_STATE.equals(state);
-                clearCacheWindowId = requestMaximizedWindowId;
-            }
-            
+            syncLock = new Object();
         }
-        if (transientNavState)
+        synchronized (syncLock)
         {
-            // no navState synchronizations
+            boolean result = resolvePortletWindows(context);
+            resolvePublicParametersMap();
+            PortletWindowRequestNavigationalStates requestStates = getPortletWindowRequestNavigationalStates();
+            
+            // for Resource (PortletURL) requests, session state is never synchronized/updated
+            boolean transientNavState = requestStates.getResourceWindow() != null;
             
-            if (clearCacheWindowId != null)
+            String clearCacheWindowId = null;
+            
+            if (!transientNavState)
             {
-                HttpSession session = context.getRequest().getSession();
+                // Check if a maximized window is set in the request.
+                // This can mean a window with state MAXIMIZED *or* SOLO.
+                // With a SOLO state, also don't update session state!
+                String requestMaximizedWindowId = null;
+                
+                if ( requestStates.getMaximizedWindow() != null )
+                {
+                    requestMaximizedWindowId = requestStates.getMaximizedWindow().getId().toString();
+                    WindowState state = requestStates.getPortletWindowNavigationalState(requestMaximizedWindowId).getWindowState();
+                    transientNavState = JetspeedActions.SOLO_STATE.equals(state);
+                    clearCacheWindowId = requestMaximizedWindowId;
+                }
+                
+            }
+            if (transientNavState)
+            {
+                // no navState synchronizations
+                
+                if (clearCacheWindowId != null)
+                {
+                    if ( session != null )
+                    {
+                        PortletWindowSessionNavigationalStates sessionStates = (PortletWindowSessionNavigationalStates)session.getAttribute(NavigationalState.NAVSTATE_SESSION_KEY);
+                        if ( sessionStates != null )
+                        {
+                            sessionStates.removeFromCache(context, clearCacheWindowId, cache);
+                            ContentPage page = context.getPage();
+                            sessionStates.removeFromCache(context, page.getId(), decorationCache);                        
+                        }
+                    }
+                }
                 if ( session != null )
                 {
                     PortletWindowSessionNavigationalStates sessionStates = (PortletWindowSessionNavigationalStates)session.getAttribute(NavigationalState.NAVSTATE_SESSION_KEY);
                     if ( sessionStates != null )
                     {
-                        sessionStates.removeFromCache(context, clearCacheWindowId, cache);
-                        ContentPage page = context.getPage();
-                        sessionStates.removeFromCache(context, page.getId(), decorationCache);                        
+                        sessionStates.syncPublicRequestParameters(context, requestStates, true, cache, decorationCache);
                     }
                 }
             }
-        }
-        else
-        {
-            HttpSession session = context.getRequest().getSession();
-            if ( session != null )
+            else
             {
-                PortletWindowSessionNavigationalStates sessionStates = (PortletWindowSessionNavigationalStates)session.getAttribute(NavigationalState.NAVSTATE_SESSION_KEY);
-                if ( sessionStates == null )
-                {
-                    sessionStates = new PortletWindowSessionNavigationalStates(this, isRenderParameterStateFull());
-                    session.setAttribute(NavigationalState.NAVSTATE_SESSION_KEY, sessionStates);
-                }
-                Page page = context.getPage();
-                // JS2-806
-                if (isClearPortletsModeAndWindowStateEnabled())
-                {
-                    sessionStates.changeAllPortletsToViewModeAndNormalWindowState(context, page, requestStates, cache, decorationCache);
-                }
-                else
-                {
-                    sessionStates.sync(context, (Page) context.getPage(), requestStates, cache, decorationCache);
-                }
-                if (isNavigationalParameterStateFull() && isRenderParameterStateFull())
+                if ( session != null )
                 {
-                    currentPageWindowStates = sessionStates.getWindowStates(page);
+                    PortletWindowSessionNavigationalStates sessionStates = (PortletWindowSessionNavigationalStates)session.getAttribute(NavigationalState.NAVSTATE_SESSION_KEY);
+                    if ( sessionStates == null )
+                    {
+                        sessionStates = new PortletWindowSessionNavigationalStates(isRenderParameterStateFull());
+                        session.setAttribute(NavigationalState.NAVSTATE_SESSION_KEY, sessionStates);
+                    }
+                    Page page = context.getPage();
+                    // JS2-806
+                    if (isClearPortletsModeAndWindowStateEnabled())
+                    {
+                        sessionStates.changeAllPortletsToViewModeAndNormalWindowState(context, page, requestStates, cache, decorationCache);
+                    }
+                    else
+                    {
+                        sessionStates.sync(context, context.getPage(), requestStates, cache, decorationCache);
+                    }
+                    if (isNavigationalParameterStateFull() && isRenderParameterStateFull())
+                    {
+                        currentPageWindowStates = sessionStates.getWindowStates(page);
+                    }
                 }
             }
+            
+            this.resetRequestPortletWindowPublicRenderParameters();
+            
+            return result;
         }
     }
     

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/ValuesAndWindowUsage.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/ValuesAndWindowUsage.java?rev=758136&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/ValuesAndWindowUsage.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/ValuesAndWindowUsage.java Wed Mar 25 03:30:49 2009
@@ -0,0 +1,73 @@
+/*
+ * 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 java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @version $Id$
+ *
+ */
+public class ValuesAndWindowUsage implements Serializable
+{
+    private static final long serialVersionUID = -888938963573388334L;
+    
+    private String[] values;
+    private Set<String> windowIds;
+    private Set<String> pageIds;
+    
+    public ValuesAndWindowUsage(String[] values)
+    {
+        this.values = values;
+    }
+    
+    public void setValues(String[] values)
+    {
+        this.values = values;
+        this.windowIds = null;
+        this.pageIds = null;
+    }
+    
+    public String[] getValues()
+    {
+        return values;
+    }        
+    
+    public void registerWindowUsage(String pageId, String windowId)
+    {
+        if (windowIds == null)
+        {
+            windowIds = new HashSet<String>();
+            pageIds = new HashSet<String>();
+        }
+        windowIds.add(windowId);
+        pageIds.add(pageId);
+    }
+
+    public Set<String> getWindowIds()
+    {
+        return windowIds;
+    }
+
+    public Set<String> getPageIds()
+    {
+        return pageIds;
+    }
+}

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/ValuesAndWindowUsage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/ValuesAndWindowUsage.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/state/impl/ValuesAndWindowUsage.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/container/state/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Mar 25 03:30:49 2009
@@ -1,2 +1,2 @@
-target
+target
 surefire*.properties

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/window/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Mar 25 03:30:49 2009
@@ -1,2 +1,2 @@
-target
+target
 surefire*.properties

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/container/state/MutableNavigationalState.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/container/state/MutableNavigationalState.java?rev=758136&r1=758135&r2=758136&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/container/state/MutableNavigationalState.java (original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/container/state/MutableNavigationalState.java Wed Mar 25 03:30:49 2009
@@ -79,6 +79,9 @@
      * 
      * @param window
      */
+    
+    void setTargetted(PortletWindow window);
+    
     void clearParameters(PortletWindow window);
     
     void setParametersMap(PortletWindow window, Map<String, String[]> parametersMap);

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/container/state/NavigationalState.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/container/state/NavigationalState.java?rev=758136&r1=758135&r2=758136&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/container/state/NavigationalState.java (original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/container/state/NavigationalState.java Wed Mar 25 03:30:49 2009
@@ -55,11 +55,11 @@
     /**
      * Synchronize the Navigational State with saved state (if used).
      * <br>
-     * Should be called by the PortalURL impl right after calling {@link #init(String)}
      *
      * @param context The RequestContext for this Navigational State
+     * @return false if the target PortletWindow (action or resource) could not be resolved
      */
-    void sync(RequestContext context);
+    boolean sync(RequestContext context);
 
     /**
      * Gets the window state for given portlet window.
@@ -135,10 +135,6 @@
      */
     PortletWindow getMaximizedWindow();
         
-    Iterator<String> getParameterNames(PortletWindow window);
-    
-    String[] getParameterValues(PortletWindow window, String parameterName);
-
     Map<String, String[]> getParameterMap(PortletWindow window);
 
     boolean isActionScopedRequestAttributes(PortletWindow window);
@@ -149,18 +145,10 @@
 
     String getCacheLevel(PortletWindow window);
 
-    String getResourceId(PortletWindow window);
-    
-    Iterator<String> getPrivateRenderParameterNames(PortletWindow window);
+    String getResourceID(PortletWindow window);
     
-    String[] getPrivateRenderParameterValues(PortletWindow window, String parameterName);
-
     Map<String, String[]> getPrivateRenderParameterMap(PortletWindow window);
     
-    Iterator<String> getPublicRenderParameterNames(PortletWindow window);
-    
-    String[] getPublicRenderParameterValues(PortletWindow window, String parameterName);
-
     Map<String, String[]> getPublicRenderParameterMap(PortletWindow window);
 
     PortalURL.URLType getURLType();



---------------------------------------------------------------------
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