weaver 2004/09/08 07:15:35
Modified: portal/src/java/org/apache/jetspeed/velocity
JetspeedPowerTool.java
Log:
Recent changes to getDecoratorActions() made it so that a null pointer exception
would be raised if the portlet for a fragment was not registered.
This stopped jetspeed from correctly reporting the error via portlet error screens
and instead displayed a velocity error screen that indicated a NPE
had been encountered.
Now all exceptions are caught and logged with a level of WARN and a
Collections.EMPTY_LIST is returned allowing for the proper error
screens to report.
Revision Changes Path
1.24 +91 -82
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerTool.java
Index: JetspeedPowerTool.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerTool.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- JetspeedPowerTool.java 7 Sep 2004 03:58:46 -0000 1.23
+++ JetspeedPowerTool.java 8 Sep 2004 14:15:35 -0000 1.24
@@ -20,6 +20,7 @@
import java.io.Writer;
import java.security.AccessControlException;
import java.security.AccessController;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -803,105 +804,113 @@
* @return A list of actions available to the current window, filtered by
securty access and current state.
* @throws Exception
*/
- public List getDecoratorActions() throws Exception
+ public List getDecoratorActions()
{
- RequestContext context = Jetspeed.getCurrentRequestContext();
- String key = getPage().getId() + ":" + this.getCurrentFragment().getId();
- Map sessionActions =
(Map)context.getSessionAttribute(POWER_TOOL_SESSION_ACTIONS);
- if (null == sessionActions)
+ try
{
- sessionActions = new HashMap();
- context.setSessionAttribute(POWER_TOOL_SESSION_ACTIONS, sessionActions);
- }
- PortletWindowActionState actionState =
(PortletWindowActionState)sessionActions.get(key);
-
- String state = getWindowState().toString();
- String mode = getPortletMode().toString();
+ RequestContext context = Jetspeed.getCurrentRequestContext();
+ String key = getPage().getId() + ":" +
this.getCurrentFragment().getId();
+ Map sessionActions =
(Map)context.getSessionAttribute(POWER_TOOL_SESSION_ACTIONS);
+ if (null == sessionActions)
+ {
+ sessionActions = new HashMap();
+ context.setSessionAttribute(POWER_TOOL_SESSION_ACTIONS,
sessionActions);
+ }
+ PortletWindowActionState actionState =
(PortletWindowActionState)sessionActions.get(key);
+
+ String state = getWindowState().toString();
+ String mode = getPortletMode().toString();
- if (null == actionState)
- {
- actionState = new PortletWindowActionState(state, mode);
- sessionActions.put(key, actionState);
- }
- else
- {
- // check to see if state or mode has changed
- if (actionState.getWindowState().equals(state))
+ if (null == actionState)
+ {
+ actionState = new PortletWindowActionState(state, mode);
+ sessionActions.put(key, actionState);
+ }
+ else
{
- if (actionState.getPortletMode().equals(mode))
+ // check to see if state or mode has changed
+ if (actionState.getWindowState().equals(state))
{
- // nothing has changed
- return actionState.getActions();
- }
+ if (actionState.getPortletMode().equals(mode))
+ {
+ // nothing has changed
+ return actionState.getActions();
+ }
+ else
+ {
+ actionState.setPortletMode(mode);
+ }
+ }
else
{
- actionState.setPortletMode(mode);
+ actionState.setWindowState(state);
}
+ // something has changed, rebuild the list
}
- else
+
+
+ List actions = actionState.getActions();
+ actions.clear();
+
+ PortletDefinitionComposite portlet =
+ (PortletDefinitionComposite)
getCurrentPortletEntity().getPortletDefinition();
+ if (null == portlet)
+ {
+ return actions; // allow nothing
+ }
+
+ ContentTypeSet content = portlet.getContentTypeSet();
+
+ if (state.equals(WindowState.NORMAL.toString()))
{
- actionState.setWindowState(state);
+ createAction(actions, JetspeedActions.INDEX_MINIMIZE, portlet);
+ createAction(actions, JetspeedActions.INDEX_MAXIMIZE, portlet);
}
- // something has changed, rebuild the list
- }
-
-
- List actions = actionState.getActions();
- actions.clear();
-
- PortletDefinitionComposite portlet =
- (PortletDefinitionComposite)
getCurrentPortletEntity().getPortletDefinition();
- if (null == portlet)
- {
- return actions; // allow nothing
- }
-
- ContentTypeSet content = portlet.getContentTypeSet();
-
- if (state.equals(WindowState.NORMAL.toString()))
- {
- createAction(actions, JetspeedActions.INDEX_MINIMIZE, portlet);
- createAction(actions, JetspeedActions.INDEX_MAXIMIZE, portlet);
- }
- else if (state.equals(WindowState.MAXIMIZED.toString()))
- {
- createAction(actions, JetspeedActions.INDEX_MINIMIZE, portlet);
- createAction(actions, JetspeedActions.INDEX_NORMAL, portlet);
- }
- else // minimized
- {
- createAction(actions, JetspeedActions.INDEX_MAXIMIZE, portlet);
- createAction(actions, JetspeedActions.INDEX_NORMAL, portlet);
- }
-
- if (mode.equals(PortletMode.VIEW.toString()))
- {
- if (content.supportsPortletMode(PortletMode.EDIT))
+ else if (state.equals(WindowState.MAXIMIZED.toString()))
{
- createAction(actions, JetspeedActions.INDEX_EDIT, portlet);
+ createAction(actions, JetspeedActions.INDEX_MINIMIZE, portlet);
+ createAction(actions, JetspeedActions.INDEX_NORMAL, portlet);
}
- if (content.supportsPortletMode(PortletMode.HELP))
- {
- createAction(actions, JetspeedActions.INDEX_HELP, portlet);
+ else // minimized
+ {
+ createAction(actions, JetspeedActions.INDEX_MAXIMIZE, portlet);
+ createAction(actions, JetspeedActions.INDEX_NORMAL, portlet);
}
- }
- else if (mode.equals(PortletMode.EDIT.toString()))
- {
- createAction(actions, JetspeedActions.INDEX_VIEW, portlet);
- if (content.supportsPortletMode(PortletMode.HELP))
- {
- createAction(actions, JetspeedActions.INDEX_HELP, portlet);
+
+ if (mode.equals(PortletMode.VIEW.toString()))
+ {
+ if (content.supportsPortletMode(PortletMode.EDIT))
+ {
+ createAction(actions, JetspeedActions.INDEX_EDIT, portlet);
+ }
+ if (content.supportsPortletMode(PortletMode.HELP))
+ {
+ createAction(actions, JetspeedActions.INDEX_HELP, portlet);
+ }
+ }
+ else if (mode.equals(PortletMode.EDIT.toString()))
+ {
+ createAction(actions, JetspeedActions.INDEX_VIEW, portlet);
+ if (content.supportsPortletMode(PortletMode.HELP))
+ {
+ createAction(actions, JetspeedActions.INDEX_HELP, portlet);
+ }
+ }
+ else // help
+ {
+ createAction(actions, JetspeedActions.INDEX_VIEW, portlet);
+ if (content.supportsPortletMode(PortletMode.EDIT))
+ {
+ createAction(actions, JetspeedActions.INDEX_EDIT, portlet);
+ }
}
+ return actions;
}
- else // help
+ catch (Exception e)
{
- createAction(actions, JetspeedActions.INDEX_VIEW, portlet);
- if (content.supportsPortletMode(PortletMode.EDIT))
- {
- createAction(actions, JetspeedActions.INDEX_EDIT, portlet);
- }
+ log.warn("Unable to generate decortator actions: "+e.toString());
+ return Collections.EMPTY_LIST;
}
- return actions;
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]