Author: chris.laprun(a)jboss.com
Date: 2009-02-28 09:11:23 -0500 (Sat, 28 Feb 2009)
New Revision: 12906
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPageNavigationalState.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewPageCommand.java
Log:
- JBPORTAL-2326:
+ Not sure why previous PNS was saved in ViewPageCommand: limited testing hasn't
shown any adverse side effects so far
+ Do not iterate over all bindings when looking for PNS for a window (was previously
overwriting found PNS)
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPageNavigationalState.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPageNavigationalState.java 2009-02-27
21:46:10 UTC (rev 12905)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPageNavigationalState.java 2009-02-28
14:11:23 UTC (rev 12906)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
* contributors as indicated by the @authors tag. See the *
* copyright.txt in the distribution for a full listing of *
* individual contributors. *
@@ -22,24 +22,24 @@
******************************************************************************/
package org.jboss.portal.core.controller.portlet;
+import org.jboss.portal.core.CoreConstants;
+import org.jboss.portal.core.controller.coordination.CoordinationManager;
+import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.navstate.NavigationalStateContext;
import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.controller.state.PortletPageNavigationalState;
import org.jboss.portal.portlet.controller.state.PortletWindowNavigationalState;
import org.jboss.portal.portlet.info.NavigationInfo;
import org.jboss.portal.portlet.info.ParameterInfo;
import org.jboss.portal.portlet.info.PortletInfo;
-import org.jboss.portal.core.CoreConstants;
-import org.jboss.portal.core.navstate.NavigationalStateContext;
-import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.core.controller.coordination.CoordinationManager;
-import javax.xml.namespace.QName;
import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-import java.util.Collection;
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
@@ -102,12 +102,10 @@
this.implicitMode =
getCoordinationManager().resolveParameterBindingImplicitModeEnabled(controllerContext.getPage());
}
- /**
- * Flush all updates to the navigational state context.
- */
+ /** Flush all updates to the navigational state context. */
public void flushUpdates()
{
-
+
if (windowPublicNavigationalStateUpdate != null && updates != null)
{
for (Map.Entry<String, HashMap<QName, String[]>> entry :
windowPublicNavigationalStateUpdate.entrySet())
@@ -125,7 +123,7 @@
{
Map<String, String[]> parameters = new HashMap<String,
String[]>();
-
+
for (Map.Entry<QName, String[]> value :
entry.getValue().entrySet())
{
parameters.put(value.getKey().toString(), value.getValue());
@@ -140,7 +138,7 @@
windowPublicNavigationalStateUpdate.clear();
}
-
+
if (updates != null)
{
for (Map.Entry<String,
org.jboss.portal.core.model.portal.navstate.WindowNavigationalState> entry :
updates.entrySet())
@@ -195,11 +193,10 @@
}
-
}
/**
- *
+ *
*/
public Set<String> getPortletWindowIds()
{
@@ -207,7 +204,7 @@
}
/**
- *
+ *
*/
public PortletWindowNavigationalState getPortletWindowNavigationalState(String
windowName) throws IllegalArgumentException
{
@@ -250,7 +247,7 @@
}
/**
- *
+ *
*/
public void setPortletWindowNavigationalState(String windowName,
PortletWindowNavigationalState windowNavigationalState) throws IllegalArgumentException,
IllegalStateException
{
@@ -286,13 +283,11 @@
initiateWindowPublicNavigationalStateUpdate();
}
- //
if (windowPublicNavigationalStateUpdate.get(windowName) == null)
{
windowPublicNavigationalStateUpdate.put(windowName, new HashMap<QName,
String[]>());
}
- //
windowPublicNavigationalStateUpdate.get(windowName).put(name, value);
}
@@ -307,13 +302,13 @@
{
value = windowPublicNavigationalStateUpdate.get(windowName).get(name);
}
-
+
}
-
+
//
if (value == null)
{
-
+
Window window = controllerContext.getWindow(windowName);
org.jboss.portal.core.model.portal.navstate.WindowNavigationalState wns =
navigationalStateContext.getWindowNavigationalState(window.getId().toString());
@@ -332,9 +327,7 @@
return value != null && value.length > 0 ? value : null;
}
- /**
- * For now we do not implement any kind of mapping between qnames, it's the basic
straightforward 1-1 mapping.
- */
+ /** For now we do not implement any kind of mapping between qnames, it's the basic
straightforward 1-1 mapping. */
public Map<String, String[]> getPortletPublicNavigationalState(String
windowName) throws IllegalArgumentException
{
PortletInfo info = controllerContext.getPortletInfo(windowName);
@@ -347,70 +340,77 @@
initiateWindowPublicNavigationalStateUpdate();
}
- //
- if (info != null && info.getNavigation() != null)
+ if (info != null)
{
- Map<String, String[]> publicNavigationalState = new HashMap<String,
String[]>();
- for (ParameterInfo parameterInfo : info.getNavigation().getPublicParameters())
+ NavigationInfo navigation = info.getNavigation();
+ if (navigation != null)
{
-
- Collection<String> bindings =
manager.getBindingNames(getWindow(windowName), parameterInfo.getName());
-
- // Don't store the URI as a page scoped public render parameter but
window scoped
- // Also for explicit and parameter with no bindings
- if (CoreConstants.JBOSS_PORTAL_CONTENT_URI.equals(parameterInfo.getName()) ||
(!implicitMode && bindings.size() == 0))
+ Map<String, String[]> publicNavigationalState = new HashMap<String,
String[]>();
+ for (ParameterInfo parameterInfo : navigation.getPublicParameters())
{
- String[] parameterValue = getWindowPublicNavigationalState(windowName,
parameterInfo.getName());
- //
- if (parameterValue != null)
+ QName parameterName = parameterInfo.getName();
+ Collection<String> bindings =
manager.getBindingNames(getWindow(windowName), parameterName);
+
+ // Don't store the URI as a page scoped public render parameter but
window scoped
+ // Also for explicit and parameter with no bindings
+ if (CoreConstants.JBOSS_PORTAL_CONTENT_URI.equals(parameterName) ||
(!implicitMode && bindings.size() == 0))
{
- String parameterId = parameterInfo.getId();
+ String[] parameterValue = getWindowPublicNavigationalState(windowName,
parameterName);
- // We clone the value here so we keep the internal state not
potentially changed
- publicNavigationalState.put(parameterId, parameterValue.clone());
+ if (parameterValue != null)
+ {
+ String parameterId = parameterInfo.getId();
+ // We clone the value here so we keep the internal state not
potentially changed
+ publicNavigationalState.put(parameterId, parameterValue.clone());
+ }
}
- }
- else
- {
- String[] parameterValue =
getPublicNavigationalState(parameterInfo.getName());
+ else
+ {
+ String[] parameterValue = getPublicNavigationalState(parameterName);
- // Explicit binding
- String[] explicitParameterValue = null;
+ // Explicit binding
+ String[] explicitParameterValue = null;
- // Check all bindings for this window/qname pair
- // If this window/qname is binded several times with different updated
params value will be unpredictable...
- for (String binding : bindings)
- {
- explicitParameterValue = getPublicNavigationalState(new
QName(XMLConstants.DEFAULT_NS_PREFIX, binding));
- }
+ // Check all bindings for this window/qname pair
+ // If this window/qname is bound several times with different updated
params value will be unpredictable...
+ for (String binding : bindings)
+ {
+ explicitParameterValue = getPublicNavigationalState(new
QName(XMLConstants.DEFAULT_NS_PREFIX, binding));
- //
- String parameterId = parameterInfo.getId();
+ // if a PNS has been found for a binding, use it and do not look
further
+ if (explicitParameterValue != null)
+ {
+ break;
+ }
+ }
- //
- if (explicitParameterValue != null)
- {
- // We clone the value here so we keep the internal state not
potentially changed
- publicNavigationalState.put(parameterId,
explicitParameterValue.clone());
+ //
+ String parameterId = parameterInfo.getId();
+
+ //
+ if (explicitParameterValue != null)
+ {
+ // We clone the value here so we keep the internal state not
potentially changed
+ publicNavigationalState.put(parameterId,
explicitParameterValue.clone());
+ }
+ else if (implicitMode && parameterValue != null)
+ {
+ // We clone the value here so we keep the internal state not
potentially changed
+ publicNavigationalState.put(parameterId, parameterValue.clone());
+ }
}
- else if (implicitMode && parameterValue != null)
- {
- // We clone the value here so we keep the internal state not
potentially changed
- publicNavigationalState.put(parameterId, parameterValue.clone());
- }
}
- }
- //
- return publicNavigationalState;
+ //
+ return publicNavigationalState;
+ }
}
//
return null;
}
-
public String getPublicNavigationalParameterId(String windowName, QName name)
@@ -434,7 +434,7 @@
}
/**
- *
+ *
*/
public void setPortletPublicNavigationalState(String windowName, Map<String,
String[]> update)
{
@@ -472,7 +472,7 @@
// Don't store the URI as a page scoped public render parameter but
window scoped
// Also for explicit and parameter with no bindings
if (CoreConstants.JBOSS_PORTAL_CONTENT_URI.equals(name)
- || (!implicitMode && bindings.size() == 0))
+ || (!implicitMode && bindings.size() == 0))
{
if (value.length > 0)
{
@@ -509,7 +509,7 @@
}
/**
- *
+ *
*/
public Set<QName> getPublicNames()
{
@@ -523,7 +523,7 @@
}
/**
- *
+ *
*/
public String[] getPublicNavigationalState(QName name) throws
IllegalArgumentException
{
@@ -552,7 +552,7 @@
}
/**
- *
+ *
*/
public void setPublicNavigationalState(QName name, String[] value) throws
IllegalArgumentException, IllegalStateException
{
@@ -572,7 +572,7 @@
}
/**
- *
+ *
*/
public void removePublicNavigationalState(QName name) throws IllegalArgumentException,
IllegalStateException
{
@@ -592,7 +592,7 @@
}
/**
- *
+ *
*/
public HashMap<QName, String[]> getWindowPublicContentStateParameters(String
windowName)
{
@@ -617,13 +617,11 @@
}
}
}
-
+
return params;
}
- /**
- * @throws IllegalStateException if the public navigational state of the window is
already initialized
- */
+ /** @throws IllegalStateException if the public navigational state of the window is
already initialized */
private void initiateWindowPublicNavigationalStateUpdate() throws
IllegalStateException
{
if (windowPublicNavigationalStateUpdate != null)
@@ -653,5 +651,4 @@
}
-
}
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewPageCommand.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewPageCommand.java 2009-02-27
21:46:10 UTC (rev 12905)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewPageCommand.java 2009-02-28
14:11:23 UTC (rev 12906)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
* contributors as indicated by the @authors tag. See the *
* copyright.txt in the distribution for a full listing of *
* individual contributors. *
@@ -22,24 +22,23 @@
******************************************************************************/
package org.jboss.portal.core.model.portal.command.view;
+import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerException;
import org.jboss.portal.core.controller.ControllerResponse;
-import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
import org.jboss.portal.core.model.portal.Page;
import org.jboss.portal.core.model.portal.PortalObjectId;
-import org.jboss.portal.core.model.portal.navstate.PageNavigationalState;
import org.jboss.portal.core.model.portal.command.PageCommand;
import org.jboss.portal.core.model.portal.command.response.UpdatePageResponse;
+import org.jboss.portal.core.model.portal.navstate.PageNavigationalState;
import org.jboss.portal.core.navstate.NavigationalStateContext;
-import org.jboss.portal.common.util.ParameterMap;
-import javax.xml.namespace.QName;
import javax.xml.XMLConstants;
-import java.util.Map;
+import javax.xml.namespace.QName;
import java.util.Collections;
import java.util.HashMap;
+import java.util.Map;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -52,7 +51,7 @@
private static final CommandInfo info = new ViewCommandInfo();
/** . */
- private static final Map<String,String[]> EMPTY_PARAMETERS =
Collections.emptyMap();
+ private static final Map<String, String[]> EMPTY_PARAMETERS =
Collections.emptyMap();
/** . */
private Map<String, String[]> parameters;
@@ -106,12 +105,6 @@
//
Map<QName, String[]> state = new HashMap<QName, String[]>();
- // Clone the previous state if needed
- if (previousPNS != null)
- {
- state.putAll(previousPNS.getParameters());
- }
-
//
for (Map.Entry<String, String[]> entry : parameters.entrySet())
{