Author: bdaw
Date: 2008-07-23 15:28:07 -0400 (Wed, 23 Jul 2008)
New Revision: 11561
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPageNavigationalState.java
Log:
- in EXPLICIT make not binded parameters window private
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 2008-07-23
13:58:30 UTC (rev 11560)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPageNavigationalState.java 2008-07-23
19:28:07 UTC (rev 11561)
@@ -31,6 +31,8 @@
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.model.portal.Page;
+import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.navstate.PageNavigationalState;
import org.jboss.portal.core.controller.coordination.CoordinationManager;
import org.jboss.portal.core.controller.coordination.CoordinationStrategy;
@@ -42,6 +44,7 @@
import java.util.Map;
import java.util.Set;
import java.util.Collection;
+import java.util.HashSet;
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
@@ -104,7 +107,7 @@
public void flushUpdates()
{
- if (windowPublicNavigationalStateUpdate != null)
+ if (windowPublicNavigationalStateUpdate != null && updates != null)
{
for (Map.Entry<String, HashMap<QName, String[]>> entry :
windowPublicNavigationalStateUpdate.entrySet())
{
@@ -116,16 +119,20 @@
wns = navigationalStateContext.getWindowNavigationalState(windowId);
}
- Map<String, String[]> parameters = new HashMap<String,
String[]>();
-
- for (Map.Entry<QName, String[]> value : entry.getValue().entrySet())
+
+ if (wns != null)
{
- parameters.put(value.getKey().toString(), value.getValue());
- }
- ParametersStateString pss = ParametersStateString.create(parameters);
+ Map<String, String[]> parameters = new HashMap<String,
String[]>();
- updates.put(entry.getKey(), new
org.jboss.portal.core.model.portal.navstate.WindowNavigationalState(wns.getWindowState(),
wns.getMode(), wns.getContentState(), pss));
+ for (Map.Entry<QName, String[]> value :
entry.getValue().entrySet())
+ {
+ parameters.put(value.getKey().toString(), value.getValue());
+ }
+
+ ParametersStateString pss = ParametersStateString.create(parameters);
+ updates.put(entry.getKey(), new
org.jboss.portal.core.model.portal.navstate.WindowNavigationalState(wns.getWindowState(),
wns.getMode(), wns.getContentState(), pss));
+ }
}
//
@@ -272,10 +279,19 @@
throw new IllegalStateException();
}
+ CoordinationStrategy strategy =
getCoordinationManager().resolveBindingStrategy(getWindow(windowName).getPage());
+
//
if (windowPublicNavigationalStateUpdate == null)
{
- windowPublicNavigationalStateUpdate = new HashMap<String, HashMap<QName,
String[]>>();
+ if (strategy.equals(CoordinationStrategy.EXPLICIT))
+ {
+ initiateWindowPublicNavigationalStateUpdate(windowName);
+ }
+ else
+ {
+ windowPublicNavigationalStateUpdate = new HashMap<String,
HashMap<QName, String[]>>();
+ }
}
if (windowPublicNavigationalStateUpdate.get(windowName) == null)
@@ -329,14 +345,29 @@
{
PortletInfo info = controllerContext.getPortletInfo(windowName);
+ CoordinationManager manager = getCoordinationManager();
+
+ CoordinationStrategy strategy =
manager.resolveBindingStrategy(getWindow(windowName).getPage());
+
+ // For explicit initiate windowPublicNavigationStateUpdate with previous state
+ if (strategy.equals(CoordinationStrategy.EXPLICIT) &&
windowPublicNavigationalStateUpdate == null)
+ {
+ initiateWindowPublicNavigationalStateUpdate(windowName);
+ }
+
//
if (info != null && info.getNavigation() != null)
{
Map<String, String[]> publicNavigationalState = new HashMap<String,
String[]>();
for (ParameterInfo parameterInfo : info.getNavigation().getPublicParameters())
{
+
+ Collection<String> bindings =
manager.getBindingNames(getWindow(windowName), parameterInfo.getName());
+
// Don't store the URI as a page scoped public render parameter but
window scoped
- if (CoreConstants.JBOSS_PORTAL_CONTENT_URI.equals(parameterInfo.getName()))
+ // Also for explicit strategy and parameter with no bindings
+ if (CoreConstants.JBOSS_PORTAL_CONTENT_URI.equals(parameterInfo.getName())
+ || (strategy.equals(CoordinationStrategy.EXPLICIT) &&
bindings.size() == 0))
{
String[] parameterValue = getWindowPublicNavigationalState(windowName,
parameterInfo.getName());
@@ -358,8 +389,6 @@
String[] explicitParameterValue = null;
// Check all bindings for this window/qname pair
- Collection<String> bindings =
getCoordinationManager().getBindingNames(getWindow(windowName), parameterInfo.getName());
-
// If this window/qname is binded several times with different updated
params value will be unpredictable...
for (String binding : bindings)
{
@@ -370,7 +399,6 @@
String parameterId = parameterInfo.getId();
//
- CoordinationStrategy strategy =
getCoordinationManager().resolveBindingStrategy(getWindow(windowName).getPage());
if (strategy.equals(CoordinationStrategy.EXPLICIT) ||
(strategy.equals(CoordinationStrategy.FALLBACK) &&
explicitParameterValue != null))
{
@@ -453,9 +481,16 @@
{
QName name = parameterInfo.getName();
String[] value = entry.getValue();
+
+ CoordinationStrategy strategy =
manager.resolveBindingStrategy(getWindow(windowName).getPage());
+
+ Collection<String> bindings =
manager.getBindingNames(getWindow(windowName), name);
+
// Don't store the URI as a page scoped public render parameter but
window scoped
- if (CoreConstants.JBOSS_PORTAL_CONTENT_URI.equals(name))
+ // Also for explicit strategy and parameter with no bindings
+ if (CoreConstants.JBOSS_PORTAL_CONTENT_URI.equals(name)
+ || (strategy.equals(CoordinationStrategy.EXPLICIT) &&
bindings.size() == 0))
{
if (value.length > 0)
{
@@ -479,8 +514,6 @@
}
// Explicit bindings
- Collection<String> bindings =
manager.getBindingNames(getWindow(windowName), name);
-
for (String binding : bindings)
{
setPublicNavigationalState(new QName(XMLConstants.DEFAULT_NS_PREFIX,
binding), value);
@@ -574,6 +607,57 @@
pageUpdates.put(name, REMOVAL);
}
+ /**
+ *
+ */
+ public HashMap<QName, String[]> getWindowPublicContentStateParameters(String
windowName)
+ {
+ HashMap<QName, String[]> params = new HashMap<QName, String[]>();
+
+ org.jboss.portal.core.model.portal.navstate.WindowNavigationalState wns =
navigationalStateContext.getWindowNavigationalState(getWindow(windowName).getId().toString());
+
+ if (wns != null)
+ {
+
+ ParametersStateString pss = (ParametersStateString)wns.getPublicContentState();
+
+ if (pss != null)
+ {
+ for (Map.Entry<String, String[]> entry :
pss.getParameters().entrySet())
+ {
+ params.put(QName.valueOf(entry.getKey()), entry.getValue());
+ }
+ }
+ }
+
+ return params;
+ }
+
+ /**
+ *
+ */
+ public void initiateWindowPublicNavigationalStateUpdate(String windowName)
+ {
+
+ Page page = getWindow(windowName).getPage();
+ CoordinationStrategy strategy =
getCoordinationManager().resolveBindingStrategy(getWindow(windowName).getPage());
+
+
+ windowPublicNavigationalStateUpdate = new HashMap<String, HashMap<QName,
String[]>>();
+
+ // Initial state for all windows on this page
+ for (PortalObject portalObject : page.getChildren())
+ {
+ if (portalObject instanceof Window)
+ {
+ Window window = (Window)portalObject;
+ windowPublicNavigationalStateUpdate.put(window.getName(),
getWindowPublicContentStateParameters(window.getName()));
+ }
+ }
+
+ }
+
+
public Window getWindow(String windowName)
{
return controllerContext.getWindow(windowName);
@@ -583,4 +667,7 @@
{
return
controllerContext.getControllerContext().getController().getCoordinationManager();
}
+
+
+
}