Author: thomas.heute(a)jboss.com
Date: 2008-06-09 08:27:25 -0400 (Mon, 09 Jun 2008)
New Revision: 10960
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/impl/model/content/generic/InternalGenericContentProvider.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/navstate/WindowNavigationalState.java
Log:
- Fixed "uri" public parameter scoped to a unique window
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-06-09
10:33:35 UTC (rev 10959)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPageNavigationalState.java 2008-06-09
12:27:25 UTC (rev 10960)
@@ -22,14 +22,16 @@
******************************************************************************/
package org.jboss.portal.core.controller.portlet;
-import org.jboss.portal.common.util.ParameterMap;
-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.PageNavigationalState;
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
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.common.util.ParameterMap;
+import org.jboss.portal.core.CoreConstants;
+import org.jboss.portal.core.navstate.NavigationalStateContext;
+import org.jboss.portal.core.model.portal.Window;
import javax.xml.namespace.QName;
import java.util.Collections;
@@ -39,6 +41,7 @@
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision: 630 $
*/
public class ControllerPageNavigationalState implements PageNavigationalState
@@ -57,11 +60,14 @@
private final boolean mutable;
/** . */
- private Map<String, WindowNavigationalState> updates;
+ private Map<String,
org.jboss.portal.core.model.portal.navstate.WindowNavigationalState> updates;
/** . */
private Map<QName, String[]> pageUpdates;
+ /** . */
+ private Map<String, HashMap<QName, String[]>>
windowPublicNavigationalStateUpdate;
+
public ControllerPageNavigationalState(
NavigationalStateContext navigationalStateContext,
ControllerPortletControllerContext controllerContext,
@@ -72,6 +78,7 @@
this.mutable = mutable;
this.updates = null;
this.pageUpdates = null;
+ this.windowPublicNavigationalStateUpdate = null;
}
public ControllerPageNavigationalState(
@@ -81,8 +88,9 @@
this.navigationalStateContext = that.navigationalStateContext;
this.controllerContext = that.controllerContext;
this.mutable = mutable;
- this.updates = that.updates != null ? new HashMap<String,
WindowNavigationalState>(that.updates) : null;
+ this.updates = that.updates != null ? new HashMap<String,
org.jboss.portal.core.model.portal.navstate.WindowNavigationalState>(that.updates) :
null;
this.pageUpdates = that.pageUpdates != null ? new HashMap<QName,
String[]>(that.pageUpdates) : null;
+ this.windowPublicNavigationalStateUpdate = that.windowPublicNavigationalStateUpdate
!= null ? new HashMap<String, HashMap<QName,
String[]>>(that.windowPublicNavigationalStateUpdate) : null;
}
/**
@@ -90,15 +98,42 @@
*/
public void flushUpdates()
{
+
+ if (windowPublicNavigationalStateUpdate != null)
+ {
+ for (Map.Entry<String, HashMap<QName, String[]>> entry :
windowPublicNavigationalStateUpdate.entrySet())
+ {
+ org.jboss.portal.core.model.portal.navstate.WindowNavigationalState wns =
updates.get(entry.getKey());
+ if (wns == null)
+ {
+ Window window = controllerContext.getWindow(entry.getKey());
+ String windowId = window.getId().toString();
+ wns = navigationalStateContext.getWindowNavigationalState(windowId);
+ }
+
+ Map<String, String[]> parameters = new HashMap<String,
String[]>();
+
+ 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));
+ }
+
+ //
+ windowPublicNavigationalStateUpdate.clear();
+
+ }
+
if (updates != null)
{
- for (Map.Entry<String, WindowNavigationalState> entry :
updates.entrySet())
+ for (Map.Entry<String,
org.jboss.portal.core.model.portal.navstate.WindowNavigationalState> entry :
updates.entrySet())
{
Window window = controllerContext.getWindow(entry.getKey());
- org.jboss.portal.core.model.portal.navstate.WindowNavigationalState wns = new
org.jboss.portal.core.model.portal.navstate.WindowNavigationalState(
- entry.getValue().getWindowState(),
- entry.getValue().getMode(),
- entry.getValue().getPortletNavigationalState());
+ org.jboss.portal.core.model.portal.navstate.WindowNavigationalState wns =
entry.getValue();
navigationalStateContext.setWindowNavigationalState(window.getId().toString(), wns);
}
@@ -146,14 +181,20 @@
}
}
+ /**
+ *
+ */
public Set<String> getWindowIds()
{
return controllerContext.getWindowNames();
}
+ /**
+ *
+ */
public WindowNavigationalState getWindowNavigationalState(String windowName) throws
IllegalArgumentException
{
- WindowNavigationalState update = null;
+ org.jboss.portal.core.model.portal.navstate.WindowNavigationalState update = null;
//
if (updates != null)
@@ -164,7 +205,7 @@
//
if (update != null)
{
- return update;
+ return new WindowNavigationalState(update.getContentState(), update.getMode(),
update.getWindowState());
}
//
@@ -191,6 +232,9 @@
return null;
}
+ /**
+ *
+ */
public void setWindowNavigationalState(String windowName, WindowNavigationalState
windowNavigationalState) throws IllegalArgumentException, IllegalStateException
{
if (!mutable)
@@ -204,14 +248,71 @@
{
if (updates == null)
{
- updates = new HashMap<String, WindowNavigationalState>();
+ updates = new HashMap<String,
org.jboss.portal.core.model.portal.navstate.WindowNavigationalState>();
}
//
- updates.put(windowName, windowNavigationalState);
+ updates.put(windowName, new
org.jboss.portal.core.model.portal.navstate.WindowNavigationalState(windowNavigationalState.getWindowState(),
windowNavigationalState.getMode(), windowNavigationalState.getPortletNavigationalState(),
null));
}
}
+ public void setWindowPublicNavigationalState(String windowName, QName name, String[]
value) throws IllegalArgumentException, IllegalStateException
+ {
+ if (!mutable)
+ {
+ throw new IllegalStateException();
+ }
+
+ //
+ if (windowPublicNavigationalStateUpdate == null)
+ {
+ windowPublicNavigationalStateUpdate = new HashMap<String, HashMap<QName,
String[]>>();
+ }
+
+ if (windowPublicNavigationalStateUpdate.get(windowName) == null)
+ {
+ windowPublicNavigationalStateUpdate.put(windowName, new HashMap<QName,
String[]>());
+ }
+
+ windowPublicNavigationalStateUpdate.get(windowName).put(name, value);
+ }
+
+ public String[] getWindowPublicNavigationalState(String windowName, QName name) throws
IllegalArgumentException, IllegalStateException
+ {
+ String[] value = null;
+
+ //
+ if (windowPublicNavigationalStateUpdate != null)
+ {
+ if (windowPublicNavigationalStateUpdate.get(windowName) != null)
+ {
+ 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());
+
+ //
+ if (wns != null)
+ {
+ ParametersStateString pss =
(ParametersStateString)wns.getPublicContentState();
+ if (pss != null)
+ {
+ value = pss.getValues(name.toString());
+ }
+ }
+ }
+
+ //
+ 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.
*/
@@ -225,15 +326,34 @@
ParameterMap publicNavigationalState = new ParameterMap();
for (ParameterInfo parameterInfo : info.getNavigation().getPublicParameters())
{
- String[] parameterValue =
getPublicNavigationalState(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()))
+ {
+ String[] parameterValue = getWindowPublicNavigationalState(windowName,
parameterInfo.getName());
- //
- if (parameterValue != null)
+ //
+ 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 parameterId = parameterInfo.getId();
+ String[] parameterValue =
getPublicNavigationalState(parameterInfo.getName());
- // 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());
+
+ }
}
}
@@ -244,7 +364,9 @@
//
return null;
}
+
+
public String getPublicNavigationalParameterId(String windowName, QName name)
{
PortletInfo info = controllerContext.getPortletInfo(windowName);
@@ -265,6 +387,9 @@
return null;
}
+ /**
+ *
+ */
public void setPublicNavigationalState(String windowName, Map<String, String[]>
update)
{
if (!mutable)
@@ -291,19 +416,39 @@
{
QName name = parameterInfo.getName();
String[] value = entry.getValue();
- if (value.length > 0)
+
+ // Don't store the URI as a page scoped public render parameter but
window scoped
+ if (CoreConstants.JBOSS_PORTAL_CONTENT_URI.equals(name))
{
- setPublicNavigationalState(name, value);
+ if (value.length > 0)
+ {
+ setWindowPublicNavigationalState(windowName, name, value);
+ }
+ else
+ {
+ setWindowPublicNavigationalState(windowName, name, REMOVAL);
+ }
+
}
else
{
- removePublicNavigationalState(name);
+ if (value.length > 0)
+ {
+ setPublicNavigationalState(name, value);
+ }
+ else
+ {
+ removePublicNavigationalState(name);
+ }
}
}
}
}
}
+ /**
+ *
+ */
public Set<QName> getPublicNames()
{
if (pageUpdates == null)
@@ -315,6 +460,9 @@
return pageUpdates.keySet();
}
+ /**
+ *
+ */
public String[] getPublicNavigationalState(QName name) throws
IllegalArgumentException
{
String[] value = null;
@@ -341,6 +489,9 @@
return value != null && value.length > 0 ? value : null;
}
+ /**
+ *
+ */
public void setPublicNavigationalState(QName name, String[] value) throws
IllegalArgumentException, IllegalStateException
{
if (!mutable)
@@ -358,6 +509,9 @@
pageUpdates.put(name, value);
}
+ /**
+ *
+ */
public void removePublicNavigationalState(QName name) throws IllegalArgumentException,
IllegalStateException
{
if (!mutable)
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java 2008-06-09
10:33:35 UTC (rev 10959)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java 2008-06-09
12:27:25 UTC (rev 10960)
@@ -194,7 +194,7 @@
RenderInvocation invocation =
rendererContext.createRenderInvocation(navigationalState);
//
- if (invocation.getPublicNavigationalState() == null)
+ if (invocation.getPublicNavigationalState() == null ||
invocation.getPublicNavigationalState().size() == 0)
{
String id = null;
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java 2008-06-09
10:33:35 UTC (rev 10959)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java 2008-06-09
12:27:25 UTC (rev 10960)
@@ -253,7 +253,7 @@
if (!key.equals(maximizedKey) &&
wns.getWindowState().equals(WindowState.MAXIMIZED))
{
WindowNavigationalState wns2 = new
WindowNavigationalState(WindowState.NORMAL, wns.getMode(), wns
- .getContentState());
+ .getContentState(), wns.getPublicContentState());
store.setAttribute(key, wns2);
}
}
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/navstate/WindowNavigationalState.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/navstate/WindowNavigationalState.java 2008-06-09
10:33:35 UTC (rev 10959)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/navstate/WindowNavigationalState.java 2008-06-09
12:27:25 UTC (rev 10960)
@@ -50,12 +50,15 @@
/** . */
private final StateString contentState;
+ /** . */
+ private final StateString publicContentState;
+
public static WindowNavigationalState create()
{
return DEFAULT;
}
- public WindowNavigationalState(WindowState windowState, Mode mode, StateString
contentState)
+ public WindowNavigationalState(WindowState windowState, Mode mode, StateString
contentState, StateString publicContentState)
{
if (windowState == null)
{
@@ -68,11 +71,12 @@
this.windowState = windowState;
this.mode = mode;
this.contentState = contentState;
+ this.publicContentState = publicContentState;
}
private WindowNavigationalState()
{
- this(WindowState.NORMAL, Mode.VIEW, null);
+ this(WindowState.NORMAL, Mode.VIEW, null, null);
}
public WindowState getWindowState()
@@ -90,6 +94,11 @@
return contentState;
}
+ public StateString getPublicContentState()
+ {
+ return publicContentState;
+ }
+
public static WindowState getWindowState(AttributeResolver resolver, Object id)
{
NavigationalStateKey key = new NavigationalStateKey(WindowNavigationalState.class,
id);
@@ -127,11 +136,11 @@
//
if (wns == null)
{
- wns = new WindowNavigationalState(windowState, Mode.VIEW, null);
+ wns = new WindowNavigationalState(windowState, Mode.VIEW, null, null);
}
else
{
- wns = new WindowNavigationalState(windowState, wns.getMode(),
wns.getContentState());
+ wns = new WindowNavigationalState(windowState, wns.getMode(),
wns.getContentState(), wns.getPublicContentState());
}
//
@@ -175,11 +184,11 @@
//
if (wns == null)
{
- wns = new WindowNavigationalState(WindowState.NORMAL, mode, null);
+ wns = new WindowNavigationalState(WindowState.NORMAL, mode, null, null);
}
else
{
- wns = new WindowNavigationalState(wns.getWindowState(), mode,
wns.getContentState());
+ wns = new WindowNavigationalState(wns.getWindowState(), mode,
wns.getContentState(), wns.getPublicContentState());
}
//
@@ -202,6 +211,22 @@
setState(resolver, new NavigationalStateKey(WindowNavigationalState.class, id),
state);
}
+ public static StateString getPublicState(AttributeResolver resolver, Object id)
+ {
+ NavigationalStateKey key = new NavigationalStateKey(WindowNavigationalState.class,
id);
+
+ //
+ WindowNavigationalState wns = (WindowNavigationalState)resolver.getAttribute(key);
+
+ //
+ return wns != null ? wns.getPublicContentState() : null;
+ }
+
+ public static void setPublicState(AttributeResolver resolver, Object id, StateString
state)
+ {
+ setPublicState(resolver, new NavigationalStateKey(WindowNavigationalState.class,
id), state);
+ }
+
public static void setState(AttributeResolver resolver, NavigationalStateKey key,
StateString state)
{
if (resolver == null)
@@ -223,17 +248,49 @@
//
if (wns == null)
{
- wns = new WindowNavigationalState(WindowState.NORMAL, Mode.VIEW, state);
+ wns = new WindowNavigationalState(WindowState.NORMAL, Mode.VIEW, state, null);
}
else
{
- wns = new WindowNavigationalState(wns.getWindowState(), wns.getMode(), state);
+ wns = new WindowNavigationalState(wns.getWindowState(), wns.getMode(), state,
wns.getPublicContentState());
}
//
resolver.setAttribute(key, wns);
}
+ public static void setPublicState(AttributeResolver resolver, NavigationalStateKey
key, StateString publicState)
+ {
+ if (resolver == null)
+ {
+ throw new IllegalArgumentException("No null resolver");
+ }
+ if (key == null)
+ {
+ throw new IllegalArgumentException("No null key");
+ }
+ if (publicState == null)
+ {
+ throw new IllegalArgumentException("No null public state");
+ }
+
+ //
+ WindowNavigationalState wns = (WindowNavigationalState)resolver.getAttribute(key);
+
+ //
+ if (wns == null)
+ {
+ wns = new WindowNavigationalState(WindowState.NORMAL, Mode.VIEW, null,
publicState);
+ }
+ else
+ {
+ wns = new WindowNavigationalState(wns.getWindowState(), wns.getMode(),
wns.getContentState(), publicState);
+ }
+
+ //
+ resolver.setAttribute(key, wns);
+ }
+
public static void setState(AttributeResolver resolver, NavigationalStateKey key,
StateString state, Window window)
{
if (resolver == null)
@@ -259,11 +316,11 @@
//
if (wns == null)
{
- wns = new WindowNavigationalState(window.getInitialWindowState(),
window.getInitialMode(), state);
+ wns = new WindowNavigationalState(window.getInitialWindowState(),
window.getInitialMode(), state, null);
}
else
{
- wns = new WindowNavigationalState(wns.getWindowState(), wns.getMode(), state);
+ wns = new WindowNavigationalState(wns.getWindowState(), wns.getMode(), state,
wns.getPublicContentState());
}
//
@@ -295,6 +352,7 @@
}
// Create new NS
- return new WindowNavigationalState(newWindowState, newMode, newState);
+ return new WindowNavigationalState(newWindowState, newMode, newState,
oldNS.getPublicContentState());
}
+
}