Author: julien(a)jboss.com
Date: 2007-04-29 18:03:38 -0400 (Sun, 29 Apr 2007)
New Revision: 7134
Added:
trunk/core/src/main/org/jboss/portal/core/impl/api/PortalRuntimeContextImpl.java
trunk/core/src/main/org/jboss/portal/core/impl/api/event/
trunk/core/src/main/org/jboss/portal/core/impl/api/event/EventBridge.java
trunk/core/src/main/org/jboss/portal/core/impl/api/event/PortalEventContextImpl.java
trunk/core/src/main/org/jboss/portal/core/impl/api/navstate/
trunk/core/src/main/org/jboss/portal/core/impl/api/navstate/NavigationalStateContextImpl.java
trunk/core/src/main/org/jboss/portal/core/impl/api/node/
trunk/core/src/main/org/jboss/portal/core/impl/api/node/PortalNodeEventContextImpl.java
trunk/core/src/main/org/jboss/portal/core/impl/api/node/PortalNodeImpl.java
trunk/core/src/main/org/jboss/portal/core/impl/api/node/PortalNodeURLFactory.java
trunk/core/src/main/org/jboss/portal/core/impl/api/session/
trunk/core/src/main/org/jboss/portal/core/impl/api/session/PortalSessionImpl.java
trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventBridgeTriggerInterceptor.java
Removed:
trunk/core/src/main/org/jboss/portal/core/impl/api/CoreNavigationalStateContext.java
trunk/core/src/main/org/jboss/portal/core/impl/api/CorePortalNode.java
trunk/core/src/main/org/jboss/portal/core/impl/api/CorePortalRuntimeContext.java
trunk/core/src/main/org/jboss/portal/core/impl/api/CorePortalSession.java
trunk/core/src/main/org/jboss/portal/core/impl/api/PortalNodeURLFactory.java
trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventBridge.java
trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventContext.java
trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventInterceptor.java
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/EventBroadcasterInterceptor.java
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/Navigation.java
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeInterceptor.java
trunk/core/src/main/org/jboss/portal/core/portlet/catalog/CatalogPortlet.java
trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
trunk/core/src/resources/portal-server-war/WEB-INF/web.xml
Log:
- WindowRenderEvent was not returned properly
- package reorg in the portal api impl to better match the api package org
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/EventBroadcasterInterceptor.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/EventBroadcasterInterceptor.java 2007-04-29
20:16:18 UTC (rev 7133)
+++
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/EventBroadcasterInterceptor.java 2007-04-29
22:03:38 UTC (rev 7134)
@@ -32,6 +32,7 @@
import org.jboss.portal.api.node.event.WindowNavigationEvent;
import org.jboss.portal.api.node.event.WindowRenderEvent;
import org.jboss.portal.api.node.event.PageRenderEvent;
+import org.jboss.portal.api.PortalRuntimeContext;
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.common.util.LazyMap;
import org.jboss.portal.core.controller.CommandRedirectionException;
@@ -46,8 +47,8 @@
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
import org.jboss.portal.core.event.PortalEventListenerRegistry;
-import org.jboss.portal.core.impl.api.CorePortalNode;
-import org.jboss.portal.core.impl.api.CorePortalRuntimeContext;
+import org.jboss.portal.core.impl.api.node.PortalNodeImpl;
+import org.jboss.portal.core.impl.api.node.PortalNodeEventContextImpl;
import org.jboss.portal.core.navstate.NavigationalStateKey;
import org.jboss.portal.portlet.PortletParameters;
import org.jboss.portal.portlet.PortletParametersStateString;
@@ -77,17 +78,28 @@
public ControllerResponse invoke(ControllerCommand cmd) throws Exception,
InvocationException
{
- CorePortalNode node = Navigation.getCurrentNode();
+ // Get the current node from the thread local
+ PortalNodeImpl node = Navigation.getCurrentNode();
+ // The next event that will optionally replace this one
+ PortalNodeEvent nextEvent = null;
+
+ // Create an event from the current node
+ PortalNodeEvent event = createEvent(cmd, node);
+
//
- PortalNodeEvent event = createEvent(cmd, node);
- PortalNodeEvent nextEvent = null;
if (event != null)
{
try
{
- CorePortalRuntimeContext runtimeContext = new
CorePortalRuntimeContext(cmd.getControllerContext());
- nextEvent = node.fireEvent(listenerRegistry, event, runtimeContext);
+ // Get runtime context from the thread local
+ PortalRuntimeContext runtimeContext = Navigation.getPortalRuntimeContext();
+
+ //
+ PortalNodeEventContextImpl nodeEventContext = new
PortalNodeEventContextImpl(listenerRegistry, node, event, runtimeContext);
+
+ // Fire the event
+ nextEvent = nodeEventContext.dispatch();
}
catch (Exception e)
{
@@ -96,26 +108,49 @@
}
//
- ControllerCommand redirection = null;
- if (nextEvent instanceof WindowEvent)
+ if (nextEvent != null)
{
- WindowEvent we = (WindowEvent)nextEvent;
+ ControllerCommand redirection = createCommand(nextEvent);
//
- CorePortalNode nextNode = (CorePortalNode)we.getNode();
+ if (redirection != null)
+ {
+ throw new CommandRedirectionException(redirection);
+ }
+ }
+
+ //
+ return (ControllerResponse)cmd.invokeNext();
+ }
+
+ /**
+ *
+ * @param event
+ * @return
+ */
+ private ControllerCommand createCommand(PortalNodeEvent event)
+ {
+ if (event instanceof WindowEvent)
+ {
+ WindowEvent we = (WindowEvent)event;
+
+ //
+ PortalNodeImpl nextNode = (PortalNodeImpl)we.getNode();
PortalObjectId nodeRef = nextNode.getObjectId();
Mode mode = we.getMode();
WindowState windowState = we.getWindowState();
- if (nextEvent instanceof WindowActionEvent)
+
+ //
+ if (event instanceof WindowActionEvent)
{
- WindowActionEvent wae = (WindowActionEvent)nextEvent;
+ WindowActionEvent wae = (WindowActionEvent)event;
Map params = wae.getParameters();
//
- PortletParameters interactionParams = null;
- if (params instanceof LazyParameterMap)
+ PortletParameters interactionParams;
+ if (params instanceof ActionParameterMap)
{
- interactionParams =
(PortletParameters)((LazyParameterMap)params).createDelegate();
+ interactionParams =
(PortletParameters)((ActionParameterMap)params).createDelegate();
}
else
{
@@ -125,7 +160,7 @@
//
if (interactionParams != null)
{
- redirection = new InvokePortletWindowActionCommand(
+ return new InvokePortletWindowActionCommand(
nodeRef,
mode,
windowState,
@@ -134,141 +169,112 @@
null);
}
}
- else if (nextEvent instanceof WindowRenderEvent)
+ else if (event instanceof WindowNavigationEvent)
{
- WindowRenderEvent wre = (WindowRenderEvent)nextEvent;
- Map params = wre.getParameters();
+ WindowNavigationEvent wne = (WindowNavigationEvent)event;
//
+ Map params = wne.getParameters();
PortletParameters navigationalParams = asParameters(params);
+ StateString state = navigationalParams != null ? new
PortletParametersStateString(navigationalParams) : null;
//
- if (navigationalParams != null)
- {
- redirection = new InvokePortletWindowRenderCommand(
- nodeRef,
- mode,
- windowState,
- new PortletParametersStateString(navigationalParams));
- }
+ return new InvokePortletWindowRenderCommand(nodeRef, mode, windowState,
state);
}
- else if (nextEvent instanceof WindowNavigationEvent)
- {
- redirection = new InvokePortletWindowRenderCommand(
- nodeRef,
- mode,
- windowState);
- }
}
- else
- {
- if (event instanceof WindowActionEvent)
- {
- WindowActionEvent wae = (WindowActionEvent)event;
- InvokePortletWindowActionCommand iwac =
(InvokePortletWindowActionCommand)cmd;
- Map params = wae.getParameters();
- if (params instanceof LazyParameterMap)
- {
- LazyParameterMap lpm = (LazyParameterMap)params;
- if (lpm.isModified())
- {
- iwac.setInteractionState(new
PortletParametersStateString(lpm.params));
- iwac.setFormParameters(null);
- }
- }
- }
- }
//
- if (redirection != null)
- {
- throw new CommandRedirectionException(redirection);
- }
- else
- {
- return (ControllerResponse)cmd.invokeNext();
- }
+ return null;
}
- private PortalNodeEvent createEvent(ControllerCommand cmd, PortalNode node)
+ /**
+ * Returns portal node event corresponding to the command or null.
+ *
+ * @param command
+ * @param node
+ * @return a portal node event
+ */
+ private PortalNodeEvent createEvent(ControllerCommand command, PortalNode node)
{
- if (cmd instanceof WindowCommand)
+ if (command instanceof WindowCommand)
{
- WindowCommand wc = (WindowCommand)cmd;
- if (cmd instanceof InvokePortletWindowActionCommand)
+ WindowCommand wc = (WindowCommand)command;
+
+ //
+ if (command instanceof InvokePortletWindowActionCommand)
{
InvokePortletWindowActionCommand iwac =
(InvokePortletWindowActionCommand)wc;
- //
- PortletParameters formParams = iwac.getFormParameters();
+ // Get form parameters
+ PortletParameters formParameters = iwac.getFormParameters();
- //
- PortletParameters interactionParams = null;
+ // Get interaction parameters
+ PortletParameters interactionParameters = null;
if (iwac.getInteractionState() instanceof PortletParametersStateString)
{
- interactionParams =
((PortletParametersStateString)iwac.getInteractionState()).getParameters();
+ interactionParameters =
((PortletParametersStateString)iwac.getInteractionState()).getParameters();
}
- //
- Map params;
- if (interactionParams != null)
+ // Build a map that represents the parameters of the action
+ Map actionParameters;
+ if (interactionParameters != null)
{
- if (formParams != null)
+ if (formParameters != null)
{
- params = new LazyParameterMap(interactionParams, formParams);
+ actionParameters = new ActionParameterMap(interactionParameters,
formParameters);
}
else
{
- params = interactionParams;
+ actionParameters = interactionParameters;
}
}
else
{
- if (formParams != null)
+ if (formParameters != null)
{
- params = formParams;
+ actionParameters = formParameters;
}
else
{
- params = new PortletParameters();
+ actionParameters = new PortletParameters();
}
}
- //
+ // Populate and return the window action event
WindowActionEvent action = new WindowActionEvent(node);
action.setMode(iwac.getMode());
action.setWindowState(iwac.getWindowState());
- action.setParameters(params);
+ action.setParameters(actionParameters);
return action;
}
- else if (cmd instanceof InvokePortletWindowRenderCommand)
+ else if (command instanceof InvokePortletWindowRenderCommand)
{
InvokePortletWindowRenderCommand iwrc =
(InvokePortletWindowRenderCommand)wc;
//
- WindowNavigationEvent navigation = new WindowNavigationEvent(node);
- navigation.setMode(iwrc.getMode());
- navigation.setWindowState(iwrc.getWindowState());
+ WindowNavigationEvent event = new WindowNavigationEvent(node);
+ event.setMode(iwrc.getMode());
+ event.setWindowState(iwrc.getWindowState());
//
StateString navigationalState = iwrc.getNavigationalState();
if (navigationalState instanceof PortletParametersStateString)
{
Map params =
((PortletParametersStateString)navigationalState).getParameters();
- navigation.setParameters(params);
+ event.setParameters(params);
}
//
- return navigation;
+ return event;
}
- else if (cmd instanceof RenderWindowCommand)
+ else if (command instanceof RenderWindowCommand)
{
WindowRenderEvent event = new WindowRenderEvent(node);
//
- RenderWindowCommand rwc = (RenderWindowCommand)cmd;
+ RenderWindowCommand rwc = (RenderWindowCommand)command;
NavigationalStateKey key = new
NavigationalStateKey(WindowNavigationalState.class, rwc.getTargetId());
- WindowNavigationalState navstate =
(WindowNavigationalState)cmd.getControllerContext().getAttribute(ControllerCommand.NAVIGATIONAL_STATE_SCOPE,
key);
+ WindowNavigationalState navstate =
(WindowNavigationalState)command.getControllerContext().getAttribute(ControllerCommand.NAVIGATIONAL_STATE_SCOPE,
key);
if (navstate != null)
{
event.setMode(navstate.getMode());
@@ -281,22 +287,32 @@
event.setParameters(params);
}
}
+
+ //
+ return event;
}
}
- else if (cmd instanceof RenderPageCommand)
+ else if (command instanceof RenderPageCommand)
{
return new PageRenderEvent(node);
}
+
+ //
return null;
}
+ /**
+ *
+ * @param map
+ * @return
+ */
private PortletParameters asParameters(Map map)
{
if (map == null)
{
return null;
}
- if (map instanceof PortletParameters)
+ else if (map instanceof PortletParameters)
{
return (PortletParameters)map;
}
@@ -309,12 +325,17 @@
catch (IllegalArgumentException e)
{
log.error("Window action event received wrong parameter set", e);
+
+ //
return null;
}
}
}
- private static class LazyParameterMap extends LazyMap
+ /**
+ *
+ */
+ private static class ActionParameterMap extends LazyMap
{
/** . */
private PortletParameters formParams;
@@ -325,7 +346,7 @@
/** . */
private PortletParameters params;
- public LazyParameterMap(PortletParameters interactionParams, PortletParameters
formParams)
+ public ActionParameterMap(PortletParameters interactionParams, PortletParameters
formParams)
{
this.formParams = formParams;
this.interactionParams = interactionParams;
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/Navigation.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/Navigation.java 2007-04-29
20:16:18 UTC (rev 7133)
+++
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/Navigation.java 2007-04-29
22:03:38 UTC (rev 7134)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.core.aspects.controller.node;
-import org.jboss.portal.core.impl.api.CorePortalNode;
+import org.jboss.portal.core.impl.api.node.PortalNodeImpl;
import org.jboss.portal.api.PortalRuntimeContext;
/**
@@ -38,12 +38,12 @@
/** . */
private static final ThreadLocal runtimeContextLocal = new ThreadLocal();
- public static CorePortalNode getCurrentNode()
+ public static PortalNodeImpl getCurrentNode()
{
- return (CorePortalNode)currentNodeLocal.get();
+ return (PortalNodeImpl)currentNodeLocal.get();
}
- static void setCurrentNode(CorePortalNode currentNode)
+ static void setCurrentNode(PortalNodeImpl currentNode)
{
currentNodeLocal.set(currentNode);
}
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeInterceptor.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeInterceptor.java 2007-04-29
20:16:18 UTC (rev 7133)
+++
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeInterceptor.java 2007-04-29
22:03:38 UTC (rev 7134)
@@ -30,8 +30,8 @@
import org.jboss.portal.core.model.portal.command.WindowCommand;
import org.jboss.portal.core.model.portal.Page;
import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.core.impl.api.CorePortalNode;
-import org.jboss.portal.core.impl.api.CorePortalRuntimeContext;
+import org.jboss.portal.core.impl.api.node.PortalNodeImpl;
+import org.jboss.portal.core.impl.api.PortalRuntimeContextImpl;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
@@ -58,10 +58,10 @@
public ControllerResponse invoke(ControllerCommand cmd) throws Exception,
InvocationException
{
// Get the next node
- CorePortalNode next = getNode(cmd);
+ PortalNodeImpl next = getNode(cmd);
// Save previous node temporarily
- CorePortalNode previous = Navigation.getCurrentNode();
+ PortalNodeImpl previous = Navigation.getCurrentNode();
// Whether or not we inherit from an existing factory
boolean noFactory = Navigation.getPortalRuntimeContext() == null;
@@ -74,7 +74,7 @@
//
if (noFactory)
{
- Navigation.setPortalRuntimeContext(new
CorePortalRuntimeContext(cmd.getControllerContext()));
+ Navigation.setPortalRuntimeContext(new
PortalRuntimeContextImpl(cmd.getControllerContext()));
}
// Invoke
@@ -93,23 +93,23 @@
}
}
- private CorePortalNode getNode(ControllerCommand cmd)
+ private PortalNodeImpl getNode(ControllerCommand cmd)
{
PortalAuthorizationManager pam = portalAuthorizationManagerFactory.getManager();
- CorePortalNode next = null;
+ PortalNodeImpl next = null;
//
if (cmd instanceof WindowCommand)
{
WindowCommand windowCmd = (WindowCommand)cmd;
Window window = windowCmd.getWindow();
- next = new CorePortalNode(pam, window);
+ next = new PortalNodeImpl(pam, window);
}
else if (cmd instanceof RenderPageCommand)
{
RenderPageCommand rpCmd = (RenderPageCommand)cmd;
Page page = rpCmd.getPage();
- next = new CorePortalNode(pam, page);
+ next = new PortalNodeImpl(pam, page);
}
//
Deleted:
trunk/core/src/main/org/jboss/portal/core/impl/api/CoreNavigationalStateContext.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/api/CoreNavigationalStateContext.java 2007-04-29
20:16:18 UTC (rev 7133)
+++
trunk/core/src/main/org/jboss/portal/core/impl/api/CoreNavigationalStateContext.java 2007-04-29
22:03:38 UTC (rev 7134)
@@ -1,132 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.impl.api;
-
-import org.jboss.portal.api.navstate.NavigationalStateContext;
-import org.jboss.portal.core.navstate.NavigationalStateKey;
-import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
-import org.jboss.portal.api.node.PortalNode;
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.common.invocation.AttributeResolver;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class CoreNavigationalStateContext implements NavigationalStateContext
-{
-
- /** . */
- private AttributeResolver navigationalStateResolver;
-
- public CoreNavigationalStateContext(AttributeResolver navigationalStateResolver)
- {
- this.navigationalStateResolver = navigationalStateResolver;
- }
-
- private WindowNavigationalState getWNS(PortalNode window, boolean create)
- {
- CorePortalNode pon = (CorePortalNode)window;
- NavigationalStateKey key = new NavigationalStateKey(WindowNavigationalState.class,
pon.getObjectId());
- WindowNavigationalState wns =
(WindowNavigationalState)navigationalStateResolver.getAttribute(key);
- if (wns == null && create)
- {
- wns = WindowNavigationalState.create();
- navigationalStateResolver.setAttribute(key, wns);
- }
- return wns;
- }
-
- public WindowState getWindowState(PortalNode window) throws IllegalArgumentException
- {
- if (window == null)
- {
- throw new IllegalArgumentException("No null window can be provided");
- }
-
- //
- WindowNavigationalState wns = getWNS(window, false);
- if (wns != null)
- {
- return wns.getWindowState();
- }
- else
- {
- return null;
- }
- }
-
- public void setWindowState(PortalNode window, WindowState windowState) throws
IllegalArgumentException
- {
- if (window == null)
- {
- throw new IllegalArgumentException("No null window can be provided");
- }
- if (windowState == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- CorePortalNode pon = (CorePortalNode)window;
- WindowNavigationalState.setWindowState(navigationalStateResolver,
pon.getObjectId(), windowState);
- }
-
- public Mode getMode(PortalNode window) throws IllegalArgumentException
- {
- if (window == null)
- {
- throw new IllegalArgumentException("No null window can be provided");
- }
-
- //
- WindowNavigationalState wns = getWNS(window, false);
- if (wns != null)
- {
- return wns.getMode();
- }
- else
- {
- return null;
- }
- }
-
- public void setMode(PortalNode window, Mode mode) throws IllegalArgumentException
- {
- if (window == null)
- {
- throw new IllegalArgumentException("No null window can be provided");
- }
- if (mode == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- CorePortalNode pon = (CorePortalNode)window;
-
- //
- WindowNavigationalState.setMode(navigationalStateResolver, pon.getObjectId(),
mode);
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/impl/api/CorePortalNode.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/api/CorePortalNode.java 2007-04-29
20:16:18 UTC (rev 7133)
+++ trunk/core/src/main/org/jboss/portal/core/impl/api/CorePortalNode.java 2007-04-29
22:03:38 UTC (rev 7134)
@@ -1,519 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.impl.api;
-
-import org.jboss.portal.api.node.PortalNode;
-import org.jboss.portal.api.node.PortalNodeURL;
-import org.jboss.portal.api.node.event.PortalNodeEvent;
-import org.jboss.portal.api.node.event.PortalNodeEventContext;
-import org.jboss.portal.api.node.event.PortalNodeEventListener;
-import org.jboss.portal.api.PortalRuntimeContext;
-import org.jboss.portal.common.path.RelativePathParser;
-import org.jboss.portal.common.i18n.ResourceBundleManager;
-import org.jboss.portal.common.i18n.SimpleResourceBundleFactory;
-import org.jboss.portal.core.event.PortalEventListenerRegistry;
-import org.jboss.portal.core.model.portal.PortalObject;
-import org.jboss.portal.core.model.portal.PortalObjectId;
-import org.jboss.portal.core.model.portal.PortalObjectPermission;
-import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Locale;
-import java.util.ResourceBundle;
-import java.util.MissingResourceException;
-import java.util.Comparator;
-import java.util.List;
-import java.util.ArrayList;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class CorePortalNode implements PortalNode
-{
-
- /** Order. */
- private static final String ORDER = "order";
-
- /** The prefix for resources in the bundle. */
- private static final String RESOURCE_PREFIX = "PAGENAME_";
-
- /** . */
- private static final String BUNDLE_BASE_NAME = "conf.bundles.Resource";
-
- /** . */
- private static final ResourceBundleManager resourceBundles = new
ResourceBundleManager(null, new SimpleResourceBundleFactory(BUNDLE_BASE_NAME,
CorePortalNode.class.getClassLoader()));
-
- /** The wrapped portal object. */
- private final PortalObject object;
-
- /** The parent node. */
- private CorePortalNode parentNode;
-
- /** The children. */
- private final NodeList children;
-
- /** The root node. */
- private PortalNode root;
-
- /** The key for the display name in the resource bundle. */
- private String displayNameKey;
-
- /** The security checks. */
- private final PortalAuthorizationManager portalAuthorizationManager;
-
- /**
- * Build a portal node object wrapping the specified portal object.
- *
- * @param object the wrapped portal object
- * @throws IllegalArgumentException if the specified object is null
- */
- public CorePortalNode(PortalAuthorizationManager portalAuthorizationManager,
PortalObject object) throws IllegalArgumentException
- {
- if (object == null)
- {
- throw new IllegalArgumentException();
- }
- this.portalAuthorizationManager = portalAuthorizationManager;
- this.object = object;
- this.children = new Children(this);
- }
-
- /**
- * Used during the construction of a children list.
- *
- * @param parentNode the parent node of this node
- * @param object the wrapped portal object
- */
- protected CorePortalNode(CorePortalNode parentNode, PortalObject object)
- {
- this.portalAuthorizationManager = parentNode.portalAuthorizationManager;
- this.parentNode = parentNode;
- this.object = object;
- this.children = new Children(this);
- }
-
- /**
- * Used when building the parent.
- *
- * @param object the wrapped portal object
- * @param childNode the child node creating that object
- */
- private CorePortalNode(PortalObject object, CorePortalNode childNode)
- {
- this.portalAuthorizationManager = childNode.portalAuthorizationManager;
- this.object = object;
- this.children = new Siblings(childNode);
- }
-
- public int getType()
- {
- return object.getType();
- }
-
- public PortalNode getRoot()
- {
- if (root == null)
- {
- PortalNode parent = getParent();
- if (parent == null)
- {
- root = this;
- }
- else
- {
- root = parent.getRoot();
- }
- }
- return root;
- }
-
- public PortalNode getParent()
- {
- if (parentNode == null)
- {
- PortalObject objectParent = object.getParent();
- if (objectParent != null)
- {
- parentNode = new CorePortalNode(objectParent, this);
- }
- }
- return parentNode;
- }
-
- public String getName()
- {
- return object.getName();
- }
-
- public String getDisplayName(Locale locale)
- {
- // Lazyly compute the display name
- if (displayNameKey == null)
- {
- displayNameKey = RESOURCE_PREFIX + object.getName();
- }
-
- // Try to get the display name from the resource bundles
- String displayName = null;
- ResourceBundle bundle = resourceBundles.getResourceBundle(locale);
- if (bundle != null)
- {
- try
- {
- displayName = bundle.getString(displayNameKey);
- }
- catch (MissingResourceException ignore)
- {
- }
- }
-
- // If nothing found just use the name
- if (displayName == null)
- {
- displayName = object.getName();
- }
-
- //
- return displayName;
- }
-
- public PortalNode getChild(String name)
- {
- return (PortalNode)children.getMap().get(name);
- }
-
- public Collection getChildren()
- {
- return children.getList();
- }
-
- public PortalNode resolve(String relativePath)
- {
- // Use this as a starting point
- PortalNode node = this;
-
- //
- RelativePathParser cursor = new RelativePathParser(relativePath);
- for (int i = cursor.next(); i != RelativePathParser.NONE && node != null; i
= cursor.next())
- {
- switch (i)
- {
- case RelativePathParser.DOWN:
- String name = relativePath.substring(cursor.getOffset(),
cursor.getOffset() + cursor.getLength());
- node = node.getChild(name);
- break;
- case RelativePathParser.UP:
- node = node.getParent();
- break;
- }
- }
- return node;
- }
-
- public Map getProperties()
- {
- return object.getProperties();
- }
-
- public PortalNodeURL createURL(PortalRuntimeContext portalRuntimeContext)
- {
- CorePortalRuntimeContext crc = (CorePortalRuntimeContext)portalRuntimeContext;
-
- //
- return crc.getURLFactory().createURL(this);
- }
-
- //
-
- public PortalObjectId getObjectId()
- {
- return object.getId();
- }
-
- public PortalNodeEvent fireEvent(PortalEventListenerRegistry registry, PortalNodeEvent
event, PortalRuntimeContext prc)
- {
- return new Bubbler(registry, this, event, prc).dispatch();
- }
-
- private static class Bubbler implements PortalNodeEventContext
- {
-
- /** . */
- PortalEventListenerRegistry registry;
-
- /** . */
- private PortalNodeEvent event;
-
- /** . */
- private CorePortalNode node;
-
- /** . */
- private PortalRuntimeContext prc;
-
- public Bubbler(
- PortalEventListenerRegistry registry,
- CorePortalNode node,
- PortalNodeEvent event,
- PortalRuntimeContext prc)
- {
- this.registry = registry;
- this.node = node;
- this.event = event;
- this.prc = prc;
- }
-
- public PortalRuntimeContext getPortalRuntimeContext()
- {
- return prc;
- }
-
- public PortalNodeEvent dispatch()
- {
- PortalNodeEventListener listener = null;
- if (node.object.getListener() != null)
- {
- Object tmp = registry.getListener(node.object.getListener());
- if (tmp != null && tmp instanceof PortalNodeEventListener)
- {
- listener = (PortalNodeEventListener)tmp;
- }
- }
-
- // Dispatch to the listener
- PortalNodeEvent nextEvent = null;
- if (listener != null)
- {
- CorePortalNode current = node;
- try
- {
- node = (CorePortalNode)node.getParent();
- nextEvent = listener.onEvent(this, event);
- }
- finally
- {
- node = current;
- }
- }
- else
- {
- if (node.getParent() != null)
- {
- CorePortalNode current = node;
- try
- {
- node = (CorePortalNode)node.getParent();
- nextEvent = dispatch();
- }
- finally
- {
- node = current;
- }
- }
- }
-
- //
- return nextEvent;
- }
-
- public PortalNode getNode()
- {
- return node;
- }
- }
-
- private float getWeight()
- {
- switch(object.getType())
- {
- case PortalObject.TYPE_CONTEXT:
- return 0;
- case PortalObject.TYPE_PORTAL:
- return 1;
- case PortalObject.TYPE_PAGE:
- String orderProperty = object.getDeclaredProperty(ORDER);
- if (orderProperty == null)
- {
- return 2.999f;
- }
- try
- {
- return Float.parseFloat("2." + orderProperty);
- }
- catch (NumberFormatException e)
- {
- return 2.999f;
- }
- case PortalObject.TYPE_WINDOW:
- return 3;
- default:
- return 4;
- }
- }
-
- private static final Comparator siblingComparator = new Comparator()
- {
- public int compare(Object o1, Object o2)
- {
- CorePortalNode node1 = (CorePortalNode)o1;
- CorePortalNode node2 = (CorePortalNode)o2;
- float weight1 = node1.getWeight();
- float weight2 = node2.getWeight();
- if (weight1 == weight2)
- {
- return node1.getName().compareTo(node2.getName());
- }
- else if (weight1 < weight2)
- {
- return -1;
- }
- else
- {
- return 1;
- }
- }
- };
-
- private abstract class NodeList
- {
-
- /** . */
- private Map map;
-
- /** . */
- private List list;
-
- protected abstract Map createMap();
-
- public final List getList()
- {
- if (list == null)
- {
- Map childrenMap = getMap();
-
- //
- list = new ArrayList(childrenMap.values());
- Collections.sort(list, siblingComparator);
- list = Collections.unmodifiableList(list);
- }
-
- //
- return list;
- }
-
- public final Map getMap()
- {
- if (map == null)
- {
- map = createMap();
- }
-
- //
- return map;
- }
-
- /**
- * Compute and returns a modifiable map made of the children nodes.
- */
- protected final Map buildChildMap(CorePortalNode objectNode)
- {
- PortalObject object = objectNode.object;
-
- //
- Collection tmp = object.getChildren();
-
- //
- if (tmp.size() > 0)
- {
- Map childrenMap = new HashMap();
-
- //
- for (Iterator i = tmp.iterator(); i.hasNext();)
- {
- PortalObject childObject = (PortalObject)i.next();
-
- // Prepare to check
- PortalObjectPermission perm = new
PortalObjectPermission(childObject.getId(), PortalObjectPermission.VIEW_MASK);
-
- // We only add it if the user can view the node
- if (portalAuthorizationManager.checkPermission(perm))
- {
- CorePortalNode child = new CorePortalNode(objectNode, childObject);
- childrenMap.put(child.getName(), child);
- }
- }
-
- //
- return childrenMap;
- }
- else
- {
- return Collections.EMPTY_MAP;
- }
- }
- }
-
- private class Children extends NodeList
- {
-
- /** . */
- private CorePortalNode node;
-
- public Children(CorePortalNode node)
- {
- this.node = node;
- }
-
- protected Map createMap()
- {
- return buildChildMap(node);
- }
- }
-
- private class Siblings extends NodeList
- {
-
- /** . */
- private CorePortalNode node;
-
- private Siblings(CorePortalNode node)
- {
- this.node = node;
- }
-
- protected Map createMap()
- {
- Map childrenNodes = buildChildMap(node.parentNode);
-
- // Replace the node with the one provided
- childrenNodes.put(node.getName(), node);
-
- //
- return childrenNodes;
- }
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/impl/api/CorePortalRuntimeContext.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/api/CorePortalRuntimeContext.java 2007-04-29
20:16:18 UTC (rev 7133)
+++
trunk/core/src/main/org/jboss/portal/core/impl/api/CorePortalRuntimeContext.java 2007-04-29
22:03:38 UTC (rev 7134)
@@ -1,97 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.impl.api;
-
-import org.jboss.portal.api.PortalRuntimeContext;
-import org.jboss.portal.api.navstate.NavigationalStateContext;
-import org.jboss.portal.api.session.PortalSession;
-import org.jboss.portal.core.controller.ControllerContext;
-import org.jboss.portal.core.controller.ControllerCommand;
-import org.jboss.portal.identity.User;
-
-import javax.servlet.http.HttpSession;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class CorePortalRuntimeContext implements PortalRuntimeContext
-{
-
- /** . */
- private CoreNavigationalStateContext navigationalStateContext;
-
- /** . */
- private PortalNodeURLFactory urlFactory;
-
- /** . */
- private PortalSession session;
-
- /** . */
- private String userId;
-
- public CorePortalRuntimeContext(HttpSession session)
- {
- this.session = new CorePortalSession(session);
- }
-
- public CorePortalRuntimeContext(HttpSession session, String userId)
- {
- this.session = new CorePortalSession(session);
- this.userId = userId;
- }
-
- public CorePortalRuntimeContext(ControllerContext controllerContext)
- {
- navigationalStateContext = new
CoreNavigationalStateContext(controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE));
- session = new
CorePortalSession(controllerContext.getServerInvocation().getServerContext().getClientRequest().getSession());
- urlFactory = new PortalNodeURLFactory(controllerContext);
-
- //
- User user = controllerContext.getUser();
- if (user != null)
- {
- userId = user.getId().toString();
- }
- }
-
- public String getUserId()
- {
- return userId;
- }
-
- public PortalSession getSession()
- {
- return session;
- }
-
- public NavigationalStateContext getNavigationalStateContext()
- {
- return navigationalStateContext;
- }
-
- public PortalNodeURLFactory getURLFactory()
- {
- return urlFactory;
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/impl/api/CorePortalSession.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/api/CorePortalSession.java 2007-04-29
20:16:18 UTC (rev 7133)
+++ trunk/core/src/main/org/jboss/portal/core/impl/api/CorePortalSession.java 2007-04-29
22:03:38 UTC (rev 7134)
@@ -1,79 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.impl.api;
-
-import org.jboss.portal.api.session.PortalSession;
-
-import javax.servlet.http.HttpSession;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class CorePortalSession implements PortalSession
-{
-
- /** . */
- private HttpSession session;
-
- public CorePortalSession(HttpSession session)
- {
- if (session == null)
- {
- throw new IllegalArgumentException();
- }
- this.session = session;
- }
-
- public String getId()
- {
- return session.getId();
- }
-
- public Object getAttribute(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException();
- }
- return session.getAttribute("blah." + name);
- }
-
- public void setAttribute(String name, Object attribute)
- {
- if (name == null)
- {
- throw new IllegalArgumentException();
- }
- session.setAttribute("blah." + name, attribute);
- }
-
- public void removeAttribute(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException();
- }
- session.removeAttribute("blah." + name);
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/impl/api/PortalNodeURLFactory.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/api/PortalNodeURLFactory.java 2007-04-29
20:16:18 UTC (rev 7133)
+++
trunk/core/src/main/org/jboss/portal/core/impl/api/PortalNodeURLFactory.java 2007-04-29
22:03:38 UTC (rev 7134)
@@ -1,158 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.impl.api;
-
-import org.jboss.portal.api.node.PortalNode;
-import org.jboss.portal.api.node.PortalNodeURL;
-import org.jboss.portal.portlet.PortletParametersStateString;
-import org.jboss.portal.server.request.URLContext;
-import org.jboss.portal.server.request.URLFormat;
-import org.jboss.portal.core.controller.ControllerContext;
-import
org.jboss.portal.core.model.portal.command.action.InvokePortletWindowRenderCommand;
-import org.jboss.portal.core.model.portal.command.view.ViewPageCommand;
-import org.jboss.portal.core.model.portal.PortalObjectId;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 5136 $
- */
-public class PortalNodeURLFactory
-{
-
- /** . */
- private final ControllerContext controllerContext;
-
- public PortalNodeURLFactory(ControllerContext controllerContext)
- {
- this.controllerContext = controllerContext;
- }
-
- public PortalNodeURL createURL(PortalNode node)
- {
- CorePortalNode pon = (CorePortalNode)node;
- switch (node.getType())
- {
- case PortalNode.TYPE_WINDOW:
- return new WindowURL(pon.getObjectId(), controllerContext);
- case PortalNode.TYPE_PAGE:
- return new PageURL(pon.getObjectId(), controllerContext);
- case PortalNode.TYPE_PORTAL:
- case PortalNode.TYPE_CONTEXT:
- default:
- throw new IllegalArgumentException("This kind of node does not support
render url " + node);
- }
- }
-
- private static class AbstractPortalNodeURL implements PortalNodeURL
- {
-
- /** . */
- protected PortalObjectId id;
-
- /** . */
- protected ControllerContext controllerContext;
-
- /** . */
- protected PortletParametersStateString parameters;
-
- /** . */
- protected Boolean wantSecure;
-
- /** . */
- protected Boolean wantAuthenticated;
-
- /** . */
- protected boolean relative;
-
- public AbstractPortalNodeURL(PortalObjectId id, ControllerContext
controllerContext)
- {
- this.id = id;
- this.controllerContext = controllerContext;
- this.relative = true;
- this.parameters = new PortletParametersStateString();
- }
-
- public void setParameter(String name, String value)
- {
- parameters.setValue(name, value);
- }
-
- public void setParameter(String name, String[] values)
- {
- parameters.setValues(name, values);
- }
-
- public void setAuthenticated(Boolean authenticated)
- {
- this.wantAuthenticated = authenticated;
- }
-
- public void setSecure(Boolean secure)
- {
- this.wantSecure = secure;
- }
-
- public void setRelative(boolean relative)
- {
- this.relative = relative;
- }
-
- protected URLContext getURLContext()
- {
- return
controllerContext.getServerInvocation().getServerContext().getURLContext();
- }
-
- }
-
- private static class WindowURL extends AbstractPortalNodeURL
- {
-
- public WindowURL(PortalObjectId id, ControllerContext controllerContext)
- {
- super(id, controllerContext);
- }
-
- public String toString()
- {
- InvokePortletWindowRenderCommand cmd = new InvokePortletWindowRenderCommand(id,
null, null, parameters);
- URLContext urlContext = getURLContext();
- return controllerContext.renderURL(cmd, urlContext,
URLFormat.newInstance(relative, true));
- }
- }
-
- private static class PageURL extends AbstractPortalNodeURL
- {
-
- public PageURL(PortalObjectId id, ControllerContext controllerContext)
- {
- super(id, controllerContext);
- }
-
- public String toString()
- {
- ViewPageCommand cmd = new ViewPageCommand(id);
- URLContext urlContext = getURLContext();
- return controllerContext.renderURL(cmd, urlContext,
URLFormat.newInstance(relative, true));
- }
- }
-}
Copied: trunk/core/src/main/org/jboss/portal/core/impl/api/PortalRuntimeContextImpl.java
(from rev 7130,
trunk/core/src/main/org/jboss/portal/core/impl/api/CorePortalRuntimeContext.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/api/PortalRuntimeContextImpl.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/api/PortalRuntimeContextImpl.java 2007-04-29
22:03:38 UTC (rev 7134)
@@ -0,0 +1,100 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.impl.api;
+
+import org.jboss.portal.api.PortalRuntimeContext;
+import org.jboss.portal.api.navstate.NavigationalStateContext;
+import org.jboss.portal.api.session.PortalSession;
+import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.impl.api.session.PortalSessionImpl;
+import org.jboss.portal.core.impl.api.navstate.NavigationalStateContextImpl;
+import org.jboss.portal.core.impl.api.node.PortalNodeURLFactory;
+import org.jboss.portal.identity.User;
+
+import javax.servlet.http.HttpSession;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortalRuntimeContextImpl implements PortalRuntimeContext
+{
+
+ /** . */
+ private NavigationalStateContextImpl navigationalStateContext;
+
+ /** . */
+ private PortalNodeURLFactory urlFactory;
+
+ /** . */
+ private PortalSession session;
+
+ /** . */
+ private String userId;
+
+ public PortalRuntimeContextImpl(HttpSession session)
+ {
+ this.session = new PortalSessionImpl(session);
+ }
+
+ public PortalRuntimeContextImpl(HttpSession session, String userId)
+ {
+ this.session = new PortalSessionImpl(session);
+ this.userId = userId;
+ }
+
+ public PortalRuntimeContextImpl(ControllerContext controllerContext)
+ {
+ navigationalStateContext = new
NavigationalStateContextImpl(controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE));
+ session = new
PortalSessionImpl(controllerContext.getServerInvocation().getServerContext().getClientRequest().getSession());
+ urlFactory = new PortalNodeURLFactory(controllerContext);
+
+ //
+ User user = controllerContext.getUser();
+ if (user != null)
+ {
+ userId = user.getId().toString();
+ }
+ }
+
+ public String getUserId()
+ {
+ return userId;
+ }
+
+ public PortalSession getSession()
+ {
+ return session;
+ }
+
+ public NavigationalStateContext getNavigationalStateContext()
+ {
+ return navigationalStateContext;
+ }
+
+ public PortalNodeURLFactory getURLFactory()
+ {
+ return urlFactory;
+ }
+}
Copied: trunk/core/src/main/org/jboss/portal/core/impl/api/event/EventBridge.java (from
rev 7130, trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventBridge.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/api/event/EventBridge.java
(rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/impl/api/event/EventBridge.java 2007-04-29
22:03:38 UTC (rev 7134)
@@ -0,0 +1,145 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.impl.api.event;
+
+import org.jboss.mx.util.MBeanProxy;
+import org.jboss.mx.util.MBeanProxyCreationException;
+import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.mx.util.ObjectNameFactory;
+import org.jboss.portal.api.event.PortalEvent;
+import org.jboss.portal.api.event.PortalEventContext;
+import org.jboss.portal.api.event.PortalEventListener;
+import org.jboss.portal.api.user.event.UserAuthenticationEvent;
+import org.jboss.portal.api.session.event.PortalSessionEvent;
+import org.jboss.portal.core.event.PortalEventListenerRegistry;
+import org.jboss.portal.core.impl.api.PortalRuntimeContextImpl;
+import org.jboss.portal.core.impl.api.event.PortalEventContextImpl;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.http.HttpSessionAttributeListener;
+import javax.servlet.http.HttpSessionBindingEvent;
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionListener;
+import java.util.Iterator;
+
+/**
+ * Bridge
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class EventBridge implements HttpSessionListener, ServletContextListener,
HttpSessionAttributeListener
+{
+
+ /** . */
+ private PortalEventListenerRegistry listenerRegistry;
+
+ // ServletContextListener implementation
****************************************************************************
+
+ public void contextInitialized(ServletContextEvent event)
+ {
+ try
+ {
+ listenerRegistry =
(PortalEventListenerRegistry)MBeanProxy.get(PortalEventListenerRegistry.class,
ObjectNameFactory.create("portal:service=ListenerRegistry"),
MBeanServerLocator.locateJBoss());
+ }
+ catch (MBeanProxyCreationException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void contextDestroyed(ServletContextEvent event)
+ {
+ listenerRegistry = null;
+ }
+
+ // HttpSessionListener implementation
*******************************************************************************
+
+ public void sessionCreated(HttpSessionEvent event)
+ {
+ PortalRuntimeContextImpl rt = new PortalRuntimeContextImpl(event.getSession());
+ PortalEventContextImpl uec = new PortalEventContextImpl(rt);
+ PortalSessionEvent use = new
PortalSessionEvent(PortalSessionEvent.SESSION_CREATED);
+ fireEvent(uec, use);
+ }
+
+ public void sessionDestroyed(HttpSessionEvent event)
+ {
+ PortalRuntimeContextImpl rt = new PortalRuntimeContextImpl(event.getSession());
+ PortalEventContextImpl uec = new PortalEventContextImpl(rt);
+ PortalSessionEvent use = new
PortalSessionEvent(PortalSessionEvent.SESSION_DESTROYED);
+ fireEvent(uec, use);
+ }
+
+ // HttpSessionAttributeListener implementation
**********************************************************************
+
+
+ public void attributeAdded(HttpSessionBindingEvent event)
+ {
+ if ("PRINCIPAL_TOKEN".equals(event.getName()))
+ {
+ String userId = (String)event.getValue();
+ PortalRuntimeContextImpl rt = new PortalRuntimeContextImpl(event.getSession(),
userId);
+ PortalEventContextImpl uec = new PortalEventContextImpl(rt);
+ UserAuthenticationEvent uae = new UserAuthenticationEvent(userId,
UserAuthenticationEvent.SIGN_IN);
+ fireEvent(uec, uae);
+ }
+ }
+
+ public void attributeRemoved(HttpSessionBindingEvent event)
+ {
+ if ("PRINCIPAL_TOKEN".equals(event.getName()))
+ {
+ String userId = (String)event.getValue();
+ PortalRuntimeContextImpl rt = new PortalRuntimeContextImpl(event.getSession(),
userId);
+ PortalEventContextImpl uec = new PortalEventContextImpl(rt);
+ UserAuthenticationEvent uae = new UserAuthenticationEvent(userId,
UserAuthenticationEvent.SIGN_OUT);
+ fireEvent(uec, uae);
+ }
+ }
+
+ public void attributeReplaced(HttpSessionBindingEvent event)
+ {
+ }
+
+ private void fireEvent(PortalEventContext eventContext, PortalEvent event)
+ {
+ for (Iterator i = listenerRegistry.getListeners().iterator(); i.hasNext();)
+ {
+ Object o = i.next();
+ if (o instanceof PortalEventListener)
+ {
+ PortalEventListener listener = (PortalEventListener)o;
+ try
+ {
+ listener.onEvent(eventContext, event);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+}
Copied:
trunk/core/src/main/org/jboss/portal/core/impl/api/event/PortalEventContextImpl.java (from
rev 7111, trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventContext.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/api/event/PortalEventContextImpl.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/api/event/PortalEventContextImpl.java 2007-04-29
22:03:38 UTC (rev 7134)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.impl.api.event;
+
+import org.jboss.portal.api.event.PortalEventContext;
+import org.jboss.portal.api.PortalRuntimeContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortalEventContextImpl implements PortalEventContext
+{
+
+ /** . */
+ private PortalRuntimeContext portalRuntimeContext;
+
+ public PortalEventContextImpl(PortalRuntimeContext portalRuntimeContext)
+ {
+ this.portalRuntimeContext = portalRuntimeContext;
+ }
+
+ public PortalRuntimeContext getPortalRuntimeContext()
+ {
+ return portalRuntimeContext;
+ }
+}
Copied:
trunk/core/src/main/org/jboss/portal/core/impl/api/navstate/NavigationalStateContextImpl.java
(from rev 7111,
trunk/core/src/main/org/jboss/portal/core/impl/api/CoreNavigationalStateContext.java)
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/api/navstate/NavigationalStateContextImpl.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/api/navstate/NavigationalStateContextImpl.java 2007-04-29
22:03:38 UTC (rev 7134)
@@ -0,0 +1,133 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.impl.api.navstate;
+
+import org.jboss.portal.api.navstate.NavigationalStateContext;
+import org.jboss.portal.core.navstate.NavigationalStateKey;
+import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
+import org.jboss.portal.core.impl.api.node.PortalNodeImpl;
+import org.jboss.portal.api.node.PortalNode;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.invocation.AttributeResolver;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class NavigationalStateContextImpl implements NavigationalStateContext
+{
+
+ /** . */
+ private AttributeResolver navigationalStateResolver;
+
+ public NavigationalStateContextImpl(AttributeResolver navigationalStateResolver)
+ {
+ this.navigationalStateResolver = navigationalStateResolver;
+ }
+
+ private WindowNavigationalState getWNS(PortalNode window, boolean create)
+ {
+ PortalNodeImpl pon = (PortalNodeImpl)window;
+ NavigationalStateKey key = new NavigationalStateKey(WindowNavigationalState.class,
pon.getObjectId());
+ WindowNavigationalState wns =
(WindowNavigationalState)navigationalStateResolver.getAttribute(key);
+ if (wns == null && create)
+ {
+ wns = WindowNavigationalState.create();
+ navigationalStateResolver.setAttribute(key, wns);
+ }
+ return wns;
+ }
+
+ public WindowState getWindowState(PortalNode window) throws IllegalArgumentException
+ {
+ if (window == null)
+ {
+ throw new IllegalArgumentException("No null window can be provided");
+ }
+
+ //
+ WindowNavigationalState wns = getWNS(window, false);
+ if (wns != null)
+ {
+ return wns.getWindowState();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void setWindowState(PortalNode window, WindowState windowState) throws
IllegalArgumentException
+ {
+ if (window == null)
+ {
+ throw new IllegalArgumentException("No null window can be provided");
+ }
+ if (windowState == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ PortalNodeImpl pon = (PortalNodeImpl)window;
+ WindowNavigationalState.setWindowState(navigationalStateResolver,
pon.getObjectId(), windowState);
+ }
+
+ public Mode getMode(PortalNode window) throws IllegalArgumentException
+ {
+ if (window == null)
+ {
+ throw new IllegalArgumentException("No null window can be provided");
+ }
+
+ //
+ WindowNavigationalState wns = getWNS(window, false);
+ if (wns != null)
+ {
+ return wns.getMode();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void setMode(PortalNode window, Mode mode) throws IllegalArgumentException
+ {
+ if (window == null)
+ {
+ throw new IllegalArgumentException("No null window can be provided");
+ }
+ if (mode == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ PortalNodeImpl pon = (PortalNodeImpl)window;
+
+ //
+ WindowNavigationalState.setMode(navigationalStateResolver, pon.getObjectId(),
mode);
+ }
+}
Added:
trunk/core/src/main/org/jboss/portal/core/impl/api/node/PortalNodeEventContextImpl.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/api/node/PortalNodeEventContextImpl.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/api/node/PortalNodeEventContextImpl.java 2007-04-29
22:03:38 UTC (rev 7134)
@@ -0,0 +1,120 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.impl.api.node;
+
+import org.jboss.portal.api.node.event.PortalNodeEventContext;
+import org.jboss.portal.api.node.event.PortalNodeEvent;
+import org.jboss.portal.api.node.event.PortalNodeEventListener;
+import org.jboss.portal.api.node.PortalNode;
+import org.jboss.portal.api.PortalRuntimeContext;
+import org.jboss.portal.core.event.PortalEventListenerRegistry;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortalNodeEventContextImpl implements PortalNodeEventContext
+{
+
+ /** . */
+ PortalEventListenerRegistry registry;
+
+ /** . */
+ private PortalNodeEvent event;
+
+ /** . */
+ private PortalNodeImpl node;
+
+ /** . */
+ private PortalRuntimeContext prc;
+
+ public PortalNodeEventContextImpl(
+ PortalEventListenerRegistry registry,
+ PortalNodeImpl node,
+ PortalNodeEvent event,
+ PortalRuntimeContext prc)
+ {
+ this.registry = registry;
+ this.node = node;
+ this.event = event;
+ this.prc = prc;
+ }
+
+ public PortalRuntimeContext getPortalRuntimeContext()
+ {
+ return prc;
+ }
+
+ public PortalNodeEvent dispatch()
+ {
+ PortalNodeEventListener listener = null;
+ if (node.object.getListener() != null)
+ {
+ Object tmp = registry.getListener(node.object.getListener());
+ if (tmp != null && tmp instanceof PortalNodeEventListener)
+ {
+ listener = (PortalNodeEventListener)tmp;
+ }
+ }
+
+ // Dispatch to the listener
+ PortalNodeEvent nextEvent = null;
+ if (listener != null)
+ {
+ PortalNodeImpl current = node;
+ try
+ {
+ node = (PortalNodeImpl)node.getParent();
+ nextEvent = listener.onEvent(this, event);
+ }
+ finally
+ {
+ node = current;
+ }
+ }
+ else
+ {
+ if (node.getParent() != null)
+ {
+ PortalNodeImpl current = node;
+ try
+ {
+ node = (PortalNodeImpl)node.getParent();
+ nextEvent = dispatch();
+ }
+ finally
+ {
+ node = current;
+ }
+ }
+ }
+
+ //
+ return nextEvent;
+ }
+
+ public PortalNode getNode()
+ {
+ return node;
+ }
+}
Copied: trunk/core/src/main/org/jboss/portal/core/impl/api/node/PortalNodeImpl.java (from
rev 7111, trunk/core/src/main/org/jboss/portal/core/impl/api/CorePortalNode.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/api/node/PortalNodeImpl.java
(rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/impl/api/node/PortalNodeImpl.java 2007-04-29
22:03:38 UTC (rev 7134)
@@ -0,0 +1,423 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.impl.api.node;
+
+import org.jboss.portal.api.node.PortalNode;
+import org.jboss.portal.api.node.PortalNodeURL;
+import org.jboss.portal.api.PortalRuntimeContext;
+import org.jboss.portal.common.path.RelativePathParser;
+import org.jboss.portal.common.i18n.ResourceBundleManager;
+import org.jboss.portal.common.i18n.SimpleResourceBundleFactory;
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.PortalObjectPermission;
+import org.jboss.portal.core.impl.api.PortalRuntimeContextImpl;
+import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.MissingResourceException;
+import java.util.Comparator;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortalNodeImpl implements PortalNode
+{
+
+ /** Order. */
+ private static final String ORDER = "order";
+
+ /** The prefix for resources in the bundle. */
+ private static final String RESOURCE_PREFIX = "PAGENAME_";
+
+ /** . */
+ private static final String BUNDLE_BASE_NAME = "conf.bundles.Resource";
+
+ /** . */
+ private static final ResourceBundleManager resourceBundles = new
ResourceBundleManager(null, new SimpleResourceBundleFactory(BUNDLE_BASE_NAME,
PortalNodeImpl.class.getClassLoader()));
+
+ /** The wrapped portal object. */
+ final PortalObject object;
+
+ /** The parent node. */
+ private PortalNodeImpl parentNode;
+
+ /** The children. */
+ private final NodeList children;
+
+ /** The root node. */
+ private PortalNode root;
+
+ /** The key for the display name in the resource bundle. */
+ private String displayNameKey;
+
+ /** The security checks. */
+ private final PortalAuthorizationManager portalAuthorizationManager;
+
+ /**
+ * Build a portal node object wrapping the specified portal object.
+ *
+ * @param object the wrapped portal object
+ * @throws IllegalArgumentException if the specified object is null
+ */
+ public PortalNodeImpl(PortalAuthorizationManager portalAuthorizationManager,
PortalObject object) throws IllegalArgumentException
+ {
+ if (object == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.portalAuthorizationManager = portalAuthorizationManager;
+ this.object = object;
+ this.children = new Children(this);
+ }
+
+ /**
+ * Used during the construction of a children list.
+ *
+ * @param parentNode the parent node of this node
+ * @param object the wrapped portal object
+ */
+ protected PortalNodeImpl(PortalNodeImpl parentNode, PortalObject object)
+ {
+ this.portalAuthorizationManager = parentNode.portalAuthorizationManager;
+ this.parentNode = parentNode;
+ this.object = object;
+ this.children = new Children(this);
+ }
+
+ /**
+ * Used when building the parent.
+ *
+ * @param object the wrapped portal object
+ * @param childNode the child node creating that object
+ */
+ private PortalNodeImpl(PortalObject object, PortalNodeImpl childNode)
+ {
+ this.portalAuthorizationManager = childNode.portalAuthorizationManager;
+ this.object = object;
+ this.children = new Siblings(childNode);
+ }
+
+ public int getType()
+ {
+ return object.getType();
+ }
+
+ public PortalNode getRoot()
+ {
+ if (root == null)
+ {
+ PortalNode parent = getParent();
+ if (parent == null)
+ {
+ root = this;
+ }
+ else
+ {
+ root = parent.getRoot();
+ }
+ }
+ return root;
+ }
+
+ public PortalNode getParent()
+ {
+ if (parentNode == null)
+ {
+ PortalObject objectParent = object.getParent();
+ if (objectParent != null)
+ {
+ parentNode = new PortalNodeImpl(objectParent, this);
+ }
+ }
+ return parentNode;
+ }
+
+ public String getName()
+ {
+ return object.getName();
+ }
+
+ public String getDisplayName(Locale locale)
+ {
+ // Lazyly compute the display name
+ if (displayNameKey == null)
+ {
+ displayNameKey = RESOURCE_PREFIX + object.getName();
+ }
+
+ // Try to get the display name from the resource bundles
+ String displayName = null;
+ ResourceBundle bundle = resourceBundles.getResourceBundle(locale);
+ if (bundle != null)
+ {
+ try
+ {
+ displayName = bundle.getString(displayNameKey);
+ }
+ catch (MissingResourceException ignore)
+ {
+ }
+ }
+
+ // If nothing found just use the name
+ if (displayName == null)
+ {
+ displayName = object.getName();
+ }
+
+ //
+ return displayName;
+ }
+
+ public PortalNode getChild(String name)
+ {
+ return (PortalNode)children.getMap().get(name);
+ }
+
+ public Collection getChildren()
+ {
+ return children.getList();
+ }
+
+ public PortalNode resolve(String relativePath)
+ {
+ // Use this as a starting point
+ PortalNode node = this;
+
+ //
+ RelativePathParser cursor = new RelativePathParser(relativePath);
+ for (int i = cursor.next(); i != RelativePathParser.NONE && node != null; i
= cursor.next())
+ {
+ switch (i)
+ {
+ case RelativePathParser.DOWN:
+ String name = relativePath.substring(cursor.getOffset(),
cursor.getOffset() + cursor.getLength());
+ node = node.getChild(name);
+ break;
+ case RelativePathParser.UP:
+ node = node.getParent();
+ break;
+ }
+ }
+ return node;
+ }
+
+ public Map getProperties()
+ {
+ return object.getProperties();
+ }
+
+ public PortalNodeURL createURL(PortalRuntimeContext portalRuntimeContext)
+ {
+ PortalRuntimeContextImpl crc = (PortalRuntimeContextImpl)portalRuntimeContext;
+
+ //
+ return crc.getURLFactory().createURL(this);
+ }
+
+ public PortalObjectId getObjectId()
+ {
+ return object.getId();
+ }
+
+ private float getWeight()
+ {
+ switch(object.getType())
+ {
+ case PortalObject.TYPE_CONTEXT:
+ return 0;
+ case PortalObject.TYPE_PORTAL:
+ return 1;
+ case PortalObject.TYPE_PAGE:
+ String orderProperty = object.getDeclaredProperty(ORDER);
+ if (orderProperty == null)
+ {
+ return 2.999f;
+ }
+ try
+ {
+ return Float.parseFloat("2." + orderProperty);
+ }
+ catch (NumberFormatException e)
+ {
+ return 2.999f;
+ }
+ case PortalObject.TYPE_WINDOW:
+ return 3;
+ default:
+ return 4;
+ }
+ }
+
+ private static final Comparator siblingComparator = new Comparator()
+ {
+ public int compare(Object o1, Object o2)
+ {
+ PortalNodeImpl node1 = (PortalNodeImpl)o1;
+ PortalNodeImpl node2 = (PortalNodeImpl)o2;
+ float weight1 = node1.getWeight();
+ float weight2 = node2.getWeight();
+ if (weight1 == weight2)
+ {
+ return node1.getName().compareTo(node2.getName());
+ }
+ else if (weight1 < weight2)
+ {
+ return -1;
+ }
+ else
+ {
+ return 1;
+ }
+ }
+ };
+
+ private abstract class NodeList
+ {
+
+ /** . */
+ private Map map;
+
+ /** . */
+ private List list;
+
+ protected abstract Map createMap();
+
+ public final List getList()
+ {
+ if (list == null)
+ {
+ Map childrenMap = getMap();
+
+ //
+ list = new ArrayList(childrenMap.values());
+ Collections.sort(list, siblingComparator);
+ list = Collections.unmodifiableList(list);
+ }
+
+ //
+ return list;
+ }
+
+ public final Map getMap()
+ {
+ if (map == null)
+ {
+ map = createMap();
+ }
+
+ //
+ return map;
+ }
+
+ /**
+ * Compute and returns a modifiable map made of the children nodes.
+ */
+ protected final Map buildChildMap(PortalNodeImpl objectNode)
+ {
+ PortalObject object = objectNode.object;
+
+ //
+ Collection tmp = object.getChildren();
+
+ //
+ if (tmp.size() > 0)
+ {
+ Map childrenMap = new HashMap();
+
+ //
+ for (Iterator i = tmp.iterator(); i.hasNext();)
+ {
+ PortalObject childObject = (PortalObject)i.next();
+
+ // Prepare to check
+ PortalObjectPermission perm = new
PortalObjectPermission(childObject.getId(), PortalObjectPermission.VIEW_MASK);
+
+ // We only add it if the user can view the node
+ if (portalAuthorizationManager.checkPermission(perm))
+ {
+ PortalNodeImpl child = new PortalNodeImpl(objectNode, childObject);
+ childrenMap.put(child.getName(), child);
+ }
+ }
+
+ //
+ return childrenMap;
+ }
+ else
+ {
+ return Collections.EMPTY_MAP;
+ }
+ }
+ }
+
+ private class Children extends NodeList
+ {
+
+ /** . */
+ private PortalNodeImpl node;
+
+ public Children(PortalNodeImpl node)
+ {
+ this.node = node;
+ }
+
+ protected Map createMap()
+ {
+ return buildChildMap(node);
+ }
+ }
+
+ private class Siblings extends NodeList
+ {
+
+ /** . */
+ private PortalNodeImpl node;
+
+ private Siblings(PortalNodeImpl node)
+ {
+ this.node = node;
+ }
+
+ protected Map createMap()
+ {
+ Map childrenNodes = buildChildMap(node.parentNode);
+
+ // Replace the node with the one provided
+ childrenNodes.put(node.getName(), node);
+
+ //
+ return childrenNodes;
+ }
+ }
+}
Copied: trunk/core/src/main/org/jboss/portal/core/impl/api/node/PortalNodeURLFactory.java
(from rev 7111,
trunk/core/src/main/org/jboss/portal/core/impl/api/PortalNodeURLFactory.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/api/node/PortalNodeURLFactory.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/api/node/PortalNodeURLFactory.java 2007-04-29
22:03:38 UTC (rev 7134)
@@ -0,0 +1,159 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.impl.api.node;
+
+import org.jboss.portal.api.node.PortalNode;
+import org.jboss.portal.api.node.PortalNodeURL;
+import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.server.request.URLContext;
+import org.jboss.portal.server.request.URLFormat;
+import org.jboss.portal.core.controller.ControllerContext;
+import
org.jboss.portal.core.model.portal.command.action.InvokePortletWindowRenderCommand;
+import org.jboss.portal.core.model.portal.command.view.ViewPageCommand;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.impl.api.node.PortalNodeImpl;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5136 $
+ */
+public class PortalNodeURLFactory
+{
+
+ /** . */
+ private final ControllerContext controllerContext;
+
+ public PortalNodeURLFactory(ControllerContext controllerContext)
+ {
+ this.controllerContext = controllerContext;
+ }
+
+ public PortalNodeURL createURL(PortalNode node)
+ {
+ PortalNodeImpl pon = (PortalNodeImpl)node;
+ switch (node.getType())
+ {
+ case PortalNode.TYPE_WINDOW:
+ return new WindowURL(pon.getObjectId(), controllerContext);
+ case PortalNode.TYPE_PAGE:
+ return new PageURL(pon.getObjectId(), controllerContext);
+ case PortalNode.TYPE_PORTAL:
+ case PortalNode.TYPE_CONTEXT:
+ default:
+ throw new IllegalArgumentException("This kind of node does not support
render url " + node);
+ }
+ }
+
+ private static class AbstractPortalNodeURL implements PortalNodeURL
+ {
+
+ /** . */
+ protected PortalObjectId id;
+
+ /** . */
+ protected ControllerContext controllerContext;
+
+ /** . */
+ protected PortletParametersStateString parameters;
+
+ /** . */
+ protected Boolean wantSecure;
+
+ /** . */
+ protected Boolean wantAuthenticated;
+
+ /** . */
+ protected boolean relative;
+
+ public AbstractPortalNodeURL(PortalObjectId id, ControllerContext
controllerContext)
+ {
+ this.id = id;
+ this.controllerContext = controllerContext;
+ this.relative = true;
+ this.parameters = new PortletParametersStateString();
+ }
+
+ public void setParameter(String name, String value)
+ {
+ parameters.setValue(name, value);
+ }
+
+ public void setParameter(String name, String[] values)
+ {
+ parameters.setValues(name, values);
+ }
+
+ public void setAuthenticated(Boolean authenticated)
+ {
+ this.wantAuthenticated = authenticated;
+ }
+
+ public void setSecure(Boolean secure)
+ {
+ this.wantSecure = secure;
+ }
+
+ public void setRelative(boolean relative)
+ {
+ this.relative = relative;
+ }
+
+ protected URLContext getURLContext()
+ {
+ return
controllerContext.getServerInvocation().getServerContext().getURLContext();
+ }
+
+ }
+
+ private static class WindowURL extends AbstractPortalNodeURL
+ {
+
+ public WindowURL(PortalObjectId id, ControllerContext controllerContext)
+ {
+ super(id, controllerContext);
+ }
+
+ public String toString()
+ {
+ InvokePortletWindowRenderCommand cmd = new InvokePortletWindowRenderCommand(id,
null, null, parameters);
+ URLContext urlContext = getURLContext();
+ return controllerContext.renderURL(cmd, urlContext,
URLFormat.newInstance(relative, true));
+ }
+ }
+
+ private static class PageURL extends AbstractPortalNodeURL
+ {
+
+ public PageURL(PortalObjectId id, ControllerContext controllerContext)
+ {
+ super(id, controllerContext);
+ }
+
+ public String toString()
+ {
+ ViewPageCommand cmd = new ViewPageCommand(id);
+ URLContext urlContext = getURLContext();
+ return controllerContext.renderURL(cmd, urlContext,
URLFormat.newInstance(relative, true));
+ }
+ }
+}
Copied: trunk/core/src/main/org/jboss/portal/core/impl/api/session/PortalSessionImpl.java
(from rev 7130,
trunk/core/src/main/org/jboss/portal/core/impl/api/CorePortalSession.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/api/session/PortalSessionImpl.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/api/session/PortalSessionImpl.java 2007-04-29
22:03:38 UTC (rev 7134)
@@ -0,0 +1,79 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.impl.api.session;
+
+import org.jboss.portal.api.session.PortalSession;
+
+import javax.servlet.http.HttpSession;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortalSessionImpl implements PortalSession
+{
+
+ /** . */
+ private HttpSession session;
+
+ public PortalSessionImpl(HttpSession session)
+ {
+ if (session == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.session = session;
+ }
+
+ public String getId()
+ {
+ return session.getId();
+ }
+
+ public Object getAttribute(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return session.getAttribute("api." + name);
+ }
+
+ public void setAttribute(String name, Object attribute)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ session.setAttribute("api." + name, attribute);
+ }
+
+ public void removeAttribute(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ session.removeAttribute("api." + name);
+ }
+}
Deleted: trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventBridge.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventBridge.java 2007-04-29
20:16:18 UTC (rev 7133)
+++
trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventBridge.java 2007-04-29
22:03:38 UTC (rev 7134)
@@ -1,142 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.impl.api.user;
-
-import org.jboss.mx.util.MBeanProxy;
-import org.jboss.mx.util.MBeanProxyCreationException;
-import org.jboss.mx.util.MBeanServerLocator;
-import org.jboss.mx.util.ObjectNameFactory;
-import org.jboss.portal.api.event.PortalEvent;
-import org.jboss.portal.api.event.PortalEventContext;
-import org.jboss.portal.api.event.PortalEventListener;
-import org.jboss.portal.api.user.event.UserAuthenticationEvent;
-import org.jboss.portal.api.session.event.PortalSessionEvent;
-import org.jboss.portal.core.event.PortalEventListenerRegistry;
-import org.jboss.portal.core.impl.api.CorePortalRuntimeContext;
-
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-import javax.servlet.http.HttpSessionAttributeListener;
-import javax.servlet.http.HttpSessionBindingEvent;
-import javax.servlet.http.HttpSessionEvent;
-import javax.servlet.http.HttpSessionListener;
-import java.util.Iterator;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class UserEventBridge implements HttpSessionListener, ServletContextListener,
HttpSessionAttributeListener
-{
-
- /** . */
- private PortalEventListenerRegistry listenerRegistry;
-
- // ServletContextListener implementation
****************************************************************************
-
- public void contextInitialized(ServletContextEvent event)
- {
- try
- {
- listenerRegistry =
(PortalEventListenerRegistry)MBeanProxy.get(PortalEventListenerRegistry.class,
ObjectNameFactory.create("portal:service=ListenerRegistry"),
MBeanServerLocator.locateJBoss());
- }
- catch (MBeanProxyCreationException e)
- {
- e.printStackTrace();
- }
- }
-
- public void contextDestroyed(ServletContextEvent event)
- {
- listenerRegistry = null;
- }
-
- // HttpSessionListener implementation
*******************************************************************************
-
- public void sessionCreated(HttpSessionEvent event)
- {
- CorePortalRuntimeContext rt = new CorePortalRuntimeContext(event.getSession());
- UserEventContext uec = new UserEventContext(rt);
- PortalSessionEvent use = new
PortalSessionEvent(PortalSessionEvent.SESSION_CREATED);
- fireEvent(uec, use);
- }
-
- public void sessionDestroyed(HttpSessionEvent event)
- {
- CorePortalRuntimeContext rt = new CorePortalRuntimeContext(event.getSession());
- UserEventContext uec = new UserEventContext(rt);
- PortalSessionEvent use = new
PortalSessionEvent(PortalSessionEvent.SESSION_DESTROYED);
- fireEvent(uec, use);
- }
-
- // HttpSessionAttributeListener implementation
**********************************************************************
-
-
- public void attributeAdded(HttpSessionBindingEvent event)
- {
- if ("PRINCIPAL_TOKEN".equals(event.getName()))
- {
- String userId = (String)event.getValue();
- CorePortalRuntimeContext rt = new CorePortalRuntimeContext(event.getSession(),
userId);
- UserEventContext uec = new UserEventContext(rt);
- UserAuthenticationEvent uae = new UserAuthenticationEvent(userId,
UserAuthenticationEvent.SIGN_IN);
- fireEvent(uec, uae);
- }
- }
-
- public void attributeRemoved(HttpSessionBindingEvent event)
- {
- if ("PRINCIPAL_TOKEN".equals(event.getName()))
- {
- String userId = (String)event.getValue();
- CorePortalRuntimeContext rt = new CorePortalRuntimeContext(event.getSession(),
userId);
- UserEventContext uec = new UserEventContext(rt);
- UserAuthenticationEvent uae = new UserAuthenticationEvent(userId,
UserAuthenticationEvent.SIGN_OUT);
- fireEvent(uec, uae);
- }
- }
-
- public void attributeReplaced(HttpSessionBindingEvent event)
- {
- }
-
- private void fireEvent(PortalEventContext eventContext, PortalEvent event)
- {
- for (Iterator i = listenerRegistry.getListeners().iterator(); i.hasNext();)
- {
- Object o = i.next();
- if (o instanceof PortalEventListener)
- {
- PortalEventListener listener = (PortalEventListener)o;
- try
- {
- listener.onEvent(eventContext, event);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- }
-}
Copied:
trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventBridgeTriggerInterceptor.java
(from rev 7111,
trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventInterceptor.java)
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventBridgeTriggerInterceptor.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventBridgeTriggerInterceptor.java 2007-04-29
22:03:38 UTC (rev 7134)
@@ -0,0 +1,67 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.impl.api.user;
+
+import org.jboss.portal.server.ServerInterceptor;
+import org.jboss.portal.server.ServerInvocation;
+import org.jboss.portal.common.invocation.InvocationException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import java.security.Principal;
+
+/**
+ * Trigger user events in the event bridge.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class UserEventBridgeTriggerInterceptor extends ServerInterceptor
+{
+ protected void invoke(ServerInvocation invocation) throws Exception,
InvocationException
+ {
+ HttpServletRequest req = invocation.getServerContext().getClientRequest();
+ HttpSession session = req.getSession(false);
+ if (session != null)
+ {
+ Principal userPrincipal = req.getUserPrincipal();
+ if (userPrincipal != null)
+ {
+ if (session.getAttribute("PRINCIPAL_TOKEN") == null)
+ {
+ session.setAttribute("PRINCIPAL_TOKEN",
userPrincipal.getName());
+ }
+ }
+ else
+ {
+ if (session.getAttribute("PRINCIPAL_TOKEN") != null)
+ {
+ session.removeAttribute("PRINCIPAL_TOKEN");
+ }
+ }
+ }
+
+ //
+ invocation.invokeNext();
+ }
+}
Deleted: trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventContext.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventContext.java 2007-04-29
20:16:18 UTC (rev 7133)
+++
trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventContext.java 2007-04-29
22:03:38 UTC (rev 7134)
@@ -1,47 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.impl.api.user;
-
-import org.jboss.portal.api.event.PortalEventContext;
-import org.jboss.portal.api.PortalRuntimeContext;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class UserEventContext implements PortalEventContext
-{
-
- /** . */
- private PortalRuntimeContext portalRuntimeContext;
-
- public UserEventContext(PortalRuntimeContext portalRuntimeContext)
- {
- this.portalRuntimeContext = portalRuntimeContext;
- }
-
- public PortalRuntimeContext getPortalRuntimeContext()
- {
- return portalRuntimeContext;
- }
-}
Deleted:
trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventInterceptor.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventInterceptor.java 2007-04-29
20:16:18 UTC (rev 7133)
+++
trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventInterceptor.java 2007-04-29
22:03:38 UTC (rev 7134)
@@ -1,65 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.impl.api.user;
-
-import org.jboss.portal.server.ServerInterceptor;
-import org.jboss.portal.server.ServerInvocation;
-import org.jboss.portal.common.invocation.InvocationException;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import java.security.Principal;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class UserEventInterceptor extends ServerInterceptor
-{
- protected void invoke(ServerInvocation invocation) throws Exception,
InvocationException
- {
- HttpServletRequest req = invocation.getServerContext().getClientRequest();
- HttpSession session = req.getSession(false);
- if (session != null)
- {
- Principal userPrincipal = req.getUserPrincipal();
- if (userPrincipal != null)
- {
- if (session.getAttribute("PRINCIPAL_TOKEN") == null)
- {
- session.setAttribute("PRINCIPAL_TOKEN",
userPrincipal.getName());
- }
- }
- else
- {
- if (session.getAttribute("PRINCIPAL_TOKEN") != null)
- {
- session.removeAttribute("PRINCIPAL_TOKEN");
- }
- }
- }
-
- //
- invocation.invokeNext();
- }
-}
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/catalog/CatalogPortlet.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/portlet/catalog/CatalogPortlet.java 2007-04-29
20:16:18 UTC (rev 7133)
+++
trunk/core/src/main/org/jboss/portal/core/portlet/catalog/CatalogPortlet.java 2007-04-29
22:03:38 UTC (rev 7134)
@@ -24,7 +24,7 @@
import org.jboss.portal.api.node.PortalNode;
import org.jboss.portal.api.node.PortalNodeURL;
-import org.jboss.portal.core.impl.api.CorePortalNode;
+import org.jboss.portal.core.impl.api.node.PortalNodeImpl;
import org.jboss.portal.core.model.portal.PortalObjectPermission;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
import org.jboss.portlet.JBossPortlet;
@@ -127,9 +127,9 @@
{
boolean allowed = false;
// check if the current user is allowed to access this page
- if (child instanceof CorePortalNode)
+ if (child instanceof PortalNodeImpl)
{
- CorePortalNode pn = (CorePortalNode)child;
+ PortalNodeImpl pn = (PortalNodeImpl)child;
PortalObjectPermission perm = new
PortalObjectPermission(pn.getObjectId(), PortalObjectPermission.VIEW_MASK);
if
(portalAuthorizationManagerFactory.getManager().checkPermission(perm))
{
@@ -152,9 +152,9 @@
{
boolean allowed = false;
// check if the current user is allowed to access this page
- if (parentSibling instanceof CorePortalNode)
+ if (parentSibling instanceof PortalNodeImpl)
{
- CorePortalNode pn = (CorePortalNode)parentSibling;
+ PortalNodeImpl pn = (PortalNodeImpl)parentSibling;
PortalObjectPermission perm = new
PortalObjectPermission(pn.getObjectId(), PortalObjectPermission.VIEW_MASK);
if
(portalAuthorizationManagerFactory.getManager().checkPermission(perm))
{
Modified: trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-04-29
20:16:18 UTC (rev 7133)
+++ trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-04-29
22:03:38 UTC (rev 7134)
@@ -108,7 +108,7 @@
<xmbean/>
</mbean>
<mbean
- code="org.jboss.portal.core.impl.api.user.UserEventInterceptor"
+
code="org.jboss.portal.core.impl.api.user.UserEventBridgeTriggerInterceptor"
name="portal:service=Interceptor,type=Server,name=UserEvent"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
Modified: trunk/core/src/resources/portal-server-war/WEB-INF/web.xml
===================================================================
--- trunk/core/src/resources/portal-server-war/WEB-INF/web.xml 2007-04-29 20:16:18 UTC
(rev 7133)
+++ trunk/core/src/resources/portal-server-war/WEB-INF/web.xml 2007-04-29 22:03:38 UTC
(rev 7134)
@@ -33,7 +33,7 @@
<!-- Bridge portal user events -->
<listener>
-
<listener-class>org.jboss.portal.core.impl.api.user.UserEventBridge</listener-class>
+
<listener-class>org.jboss.portal.core.impl.api.event.EventBridge</listener-class>
</listener>
<!-- The portal servlet is the main entrance point -->