Author: chris.laprun(a)jboss.com
Date: 2008-08-06 18:20:16 -0400 (Wed, 06 Aug 2008)
New Revision: 11672
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/navstate/WindowNavigationalState.java
Log:
- JBPORTAL-2114: InternalContentProvider.renderWindow now fails if a window state or mode
that the portlet doesn't support is requested.
- Renamed WindowNavigationalState.bilto to something more appropriate... :)
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java 2008-08-06
18:22:50 UTC (rev 11671)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java 2008-08-06
22:20:16 UTC (rev 11672)
@@ -25,6 +25,7 @@
import org.jboss.logging.Logger;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
+import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.core.aspects.portlet.AjaxInterceptor;
import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.controller.command.response.SecurityErrorResponse;
@@ -35,16 +36,18 @@
import org.jboss.portal.core.model.instance.Instance;
import org.jboss.portal.core.model.instance.InstancePermission;
import org.jboss.portal.core.model.portal.Portal;
+import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.command.response.MarkupResponse;
import org.jboss.portal.core.model.portal.content.ContentRenderer;
+import org.jboss.portal.core.model.portal.content.ContentRendererContext;
import org.jboss.portal.core.model.portal.content.WindowRendition;
-import org.jboss.portal.core.model.portal.content.ContentRendererContext;
import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
import org.jboss.portal.portlet.NoSuchPortletException;
+import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.info.CapabilitiesInfo;
+import org.jboss.portal.portlet.info.MetaInfo;
import org.jboss.portal.portlet.info.ModeInfo;
import org.jboss.portal.portlet.info.WindowStateInfo;
import org.jboss.portal.portlet.invocation.PortletInvocation;
@@ -59,6 +62,8 @@
import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
import org.jboss.portal.theme.impl.render.dynamic.DynaRenderOptions;
+import javax.portlet.PortletModeException;
+import javax.portlet.WindowStateException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -162,7 +167,7 @@
// Get the parent portal
Portal portal = null;
- for (PortalObject current = window;current != null;current = current.getParent())
+ for (PortalObject current = window; current != null; current =
current.getParent())
{
if (current.getType() == PortalObject.TYPE_PORTAL)
{
@@ -217,7 +222,8 @@
//
try
{
- CapabilitiesInfo capabilitiesInfo =
instance.getPortlet().getInfo().getCapabilities();
+ Portlet portlet = instance.getPortlet();
+ CapabilitiesInfo capabilitiesInfo = portlet.getInfo().getCapabilities();
//
Set windowStatesInfo = capabilitiesInfo.getAllWindowStates();
@@ -232,6 +238,14 @@
}
}
+ // fail fast if we are requesting a window state that is not supported by this
portlet
+ if (!supportedWindowStates.contains(windowState))
+ {
+ String windowStateName = windowState.toString();
+ throw new WindowStateException(windowStateName + " is not supported by
portlet " + getPortletName(portlet),
+ new javax.portlet.WindowState(windowStateName));
+ }
+
//
Set modesInfo = capabilitiesInfo.getAllModes();
supportedModes = new ArrayList(modesInfo.size());
@@ -245,6 +259,14 @@
}
}
+ // fail fast if we are requesting a window state that is not supported by this
portlet
+ if (!supportedModes.contains(mode))
+ {
+ String modeName = mode.toString();
+ throw new PortletModeException(modeName + " is not supported by portlet
" + getPortletName(portlet),
+ new javax.portlet.PortletMode(modeName));
+ }
+
// Remove edit mode if the user is not logged it
if (rendererContext.getUser() == null)
{
@@ -264,7 +286,7 @@
//
response = instance.invoke(invocation);
}
- catch (PortletInvokerException e)
+ catch (Exception e)
{
ControllerResponse cr;
@@ -345,4 +367,21 @@
//
return new WindowRendition(windowProps, windowState, mode, supportedWindowStates,
supportedModes, cr);
}
+
+ private String getPortletName(Portlet portlet) throws PortletInvokerException
+ {
+ LocalizedString displayName =
portlet.getInfo().getMeta().getMetaValue(MetaInfo.DISPLAY_NAME);
+ // if we can't get a display name, default to portlet id...
+ String name;
+ if (displayName == null)
+ {
+ name = portlet.getContext().getId();
+ }
+ else
+ {
+ name = displayName.getDefaultString();
+ }
+
+ return "'" + name + "'";
+ }
}
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java 2008-08-06
18:22:50 UTC (rev 11671)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java 2008-08-06
22:20:16 UTC (rev 11672)
@@ -36,8 +36,8 @@
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.portal.command.response.MarkupResponse;
+import org.jboss.portal.core.model.portal.content.ContentRendererContext;
import org.jboss.portal.core.model.portal.content.WindowRendition;
-import org.jboss.portal.core.model.portal.content.ContentRendererContext;
import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
import org.jboss.portal.portlet.PortletParametersStateString;
@@ -195,7 +195,7 @@
state.setValue("uri", uri);
//
-
rendererContext.setNavigationalState(WindowNavigationalState.bilto(navigationalState,
null, null, state));
+
rendererContext.setNavigationalState(WindowNavigationalState.copyAndUpdateIfNeeded(navigationalState,
null, null, state));
}
//
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java 2008-08-06
18:22:50 UTC (rev 11671)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java 2008-08-06
22:20:16 UTC (rev 11672)
@@ -50,21 +50,21 @@
protected final StateString navigationalState;
public InvokePortletWindowRenderCommand(
- PortalObjectId windowId,
- Mode mode,
- WindowState windowState,
- StateString navigationalState)
- throws IllegalArgumentException
+ PortalObjectId windowId,
+ Mode mode,
+ WindowState windowState,
+ StateString navigationalState)
+ throws IllegalArgumentException
{
super(windowId, mode, windowState);
this.navigationalState = navigationalState;
}
public InvokePortletWindowRenderCommand(
- PortalObjectId windowId,
- Mode mode,
- WindowState windowState)
- throws IllegalArgumentException
+ PortalObjectId windowId,
+ Mode mode,
+ WindowState windowState)
+ throws IllegalArgumentException
{
super(windowId, mode, windowState);
this.navigationalState = null;
@@ -90,7 +90,7 @@
WindowNavigationalState oldNS =
(WindowNavigationalState)ctx.getAttribute(NAVIGATIONAL_STATE_SCOPE, nsKey);
// Create new NS
- WindowNavigationalState newNS = WindowNavigationalState.bilto(oldNS,
this.windowState, this.mode, this.navigationalState);
+ WindowNavigationalState newNS =
WindowNavigationalState.copyAndUpdateIfNeeded(oldNS, this.windowState, this.mode,
this.navigationalState);
// Update NS
ctx.setAttribute(NAVIGATIONAL_STATE_SCOPE, nsKey, newNS);
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/navstate/WindowNavigationalState.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/navstate/WindowNavigationalState.java 2008-08-06
18:22:50 UTC (rev 11671)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/navstate/WindowNavigationalState.java 2008-08-06
22:20:16 UTC (rev 11672)
@@ -270,7 +270,7 @@
resolver.setAttribute(key, wns);
}
- public static WindowNavigationalState bilto(WindowNavigationalState oldNS, WindowState
windowState, Mode mode, StateString contentState)
+ public static WindowNavigationalState copyAndUpdateIfNeeded(WindowNavigationalState
oldNS, WindowState windowState, Mode mode, StateString contentState)
{
StateString newState = oldNS != null ? oldNS.getContentState() : null;
WindowState newWindowState = oldNS != null ? oldNS.getWindowState() :
WindowState.NORMAL;