Author: julien(a)jboss.com
Date: 2007-04-25 09:37:42 -0400 (Wed, 25 Apr 2007)
New Revision: 7042
Added:
trunk/api/src/main/org/jboss/portal/api/PortalSession.java
trunk/api/src/main/org/jboss/portal/api/PortalURL.java
trunk/core/src/main/org/jboss/portal/core/impl/api/
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
Removed:
trunk/api/src/main/org/jboss/portal/api/node/PortalNodeURLFactory.java
trunk/api/src/main/org/jboss/portal/spi/runtime/PortalSession.java
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeURLFactoryImpl.java
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalObjectNode.java
trunk/core/src/main/org/jboss/portal/core/impl/CoreRuntimeContext.java
trunk/core/src/main/org/jboss/portal/core/impl/CoreSession.java
Modified:
trunk/api/src/main/org/jboss/portal/api/node/PortalNode.java
trunk/api/src/main/org/jboss/portal/api/node/PortalNodeURL.java
trunk/api/src/main/org/jboss/portal/api/node/event/PortalNodeEventContext.java
trunk/api/src/main/org/jboss/portal/spi/runtime/PortalRuntimeContext.java
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/event/WindowConstraintEventListener.java
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
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/event/user/UserEventBridge.java
trunk/core/src/main/org/jboss/portal/core/portlet/catalog/CatalogPortlet.java
trunk/core/src/main/org/jboss/portlet/JBossActionResponse.java
trunk/core/src/main/org/jboss/portlet/JBossRenderResponse.java
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/tabs.jsp
Log:
- reworked a bit the portal API that has not yet been published
Copied: trunk/api/src/main/org/jboss/portal/api/PortalSession.java (from rev 7039,
trunk/api/src/main/org/jboss/portal/spi/runtime/PortalSession.java)
===================================================================
--- trunk/api/src/main/org/jboss/portal/api/PortalSession.java
(rev 0)
+++ trunk/api/src/main/org/jboss/portal/api/PortalSession.java 2007-04-25 13:37:42 UTC
(rev 7042)
@@ -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.api;
+
+/**
+ * The portal session, the portal session attributes are accessible however it is not
possible to influence
+ * the lifecycle of the session as it is managed by the portal.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface PortalSession
+{
+ /**
+ * Return the session id.
+ *
+ * @return the session id
+ */
+ String getId();
+
+ Object getAttribute(String name);
+
+ void setAttribute(String name, Object attribute);
+
+ void removeAttribute(String name);
+
+}
Added: trunk/api/src/main/org/jboss/portal/api/PortalURL.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/api/PortalURL.java (rev
0)
+++ trunk/api/src/main/org/jboss/portal/api/PortalURL.java 2007-04-25 13:37:42 UTC (rev
7042)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * 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.api;
+
+/**
+ * Base interface for portal urls.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface PortalURL
+{
+ /**
+ * Affect the authentication mode of the transport protocol that the URL will
designate.
+ * A null value indicates that it should reuse the value of the incoming transport.
+ */
+ void setAuthenticated(Boolean wantAuthenticated);
+
+ /**
+ * Affect the security mode of the transport protocol that the URL will designate.
+ * A null value indicates that it should reuse the value of the incoming transport.
+ */
+ void setSecure(Boolean wantSecure);
+
+ /**
+ * Affet the URL generation by creating either a relative or an absolute URL.
+ */
+ void setRelative(boolean relative);
+
+ /**
+ * Generate an URL for this node.
+ *
+ * @return a generated url.
+ */
+ String toString();
+}
Modified: trunk/api/src/main/org/jboss/portal/api/node/PortalNode.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/api/node/PortalNode.java 2007-04-25 12:36:23 UTC
(rev 7041)
+++ trunk/api/src/main/org/jboss/portal/api/node/PortalNode.java 2007-04-25 13:37:42 UTC
(rev 7042)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.api.node;
+import org.jboss.portal.spi.runtime.PortalRuntimeContext;
+
import java.util.Collection;
import java.util.Map;
import java.util.Locale;
@@ -111,4 +113,12 @@
* @return the node properties
*/
Map getProperties();
+
+ /**
+ * Create a portal node url for this object.
+ *
+ * @param portalRuntimeContext the portal runtime context
+ * @return the portal node url
+ */
+ PortalNodeURL createURL(PortalRuntimeContext portalRuntimeContext);
}
Modified: trunk/api/src/main/org/jboss/portal/api/node/PortalNodeURL.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/api/node/PortalNodeURL.java 2007-04-25 12:36:23
UTC (rev 7041)
+++ trunk/api/src/main/org/jboss/portal/api/node/PortalNodeURL.java 2007-04-25 13:37:42
UTC (rev 7042)
@@ -22,13 +22,15 @@
******************************************************************************/
package org.jboss.portal.api.node;
+import org.jboss.portal.api.PortalURL;
+
/**
* An URL which can target a portal node.
*
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public interface PortalNodeURL
+public interface PortalNodeURL extends PortalURL
{
/**
* Set a parameter on the URL.
@@ -47,28 +49,4 @@
* @throws IllegalArgumentException if the name is null
*/
void setParameter(String name, String[] values) throws IllegalArgumentException;
-
- /**
- * Affect the authentication mode of the transport protocol that the URL will
designate.
- * A null value indicates that it should reuse the value of the incoming transport.
- */
- void setAuthenticated(Boolean wantAuthenticated);
-
- /**
- * Affect the security mode of the transport protocol that the URL will designate.
- * A null value indicates that it should reuse the value of the incoming transport.
- */
- void setSecure(Boolean wantSecure);
-
- /**
- * Affet the URL generation by creating either a relative or an absolute URL.
- */
- void setRelative(boolean relative);
-
- /**
- * Generate an URL for this node.
- *
- * @return a generated url.
- */
- String toString();
}
Deleted: trunk/api/src/main/org/jboss/portal/api/node/PortalNodeURLFactory.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/api/node/PortalNodeURLFactory.java 2007-04-25
12:36:23 UTC (rev 7041)
+++ trunk/api/src/main/org/jboss/portal/api/node/PortalNodeURLFactory.java 2007-04-25
13:37:42 UTC (rev 7042)
@@ -1,36 +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.api.node;
-
-/**
- * The context of a portal node.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public interface PortalNodeURLFactory
-{
-
- PortalNodeURL createURL(PortalNode node) throws IllegalArgumentException;
-
-}
Modified: trunk/api/src/main/org/jboss/portal/api/node/event/PortalNodeEventContext.java
===================================================================
---
trunk/api/src/main/org/jboss/portal/api/node/event/PortalNodeEventContext.java 2007-04-25
12:36:23 UTC (rev 7041)
+++
trunk/api/src/main/org/jboss/portal/api/node/event/PortalNodeEventContext.java 2007-04-25
13:37:42 UTC (rev 7042)
@@ -23,7 +23,7 @@
package org.jboss.portal.api.node.event;
import org.jboss.portal.api.node.PortalNode;
-import org.jboss.portal.spi.runtime.NavigationalStateContext;
+import org.jboss.portal.spi.runtime.PortalRuntimeContext;
/**
* The context in which a <code>PortalNodeEvent</code> is dispatched.
@@ -48,9 +48,9 @@
PortalNode getNode();
/**
- * Returns the navigational state context.
+ * Returns the portal runtime context.
*
- * @return the navigational state context
+ * @return the portal runtime context
*/
- NavigationalStateContext getNavigationalStateContext();
+ PortalRuntimeContext getPortalRuntimeContext();
}
Modified: trunk/api/src/main/org/jboss/portal/spi/runtime/PortalRuntimeContext.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/spi/runtime/PortalRuntimeContext.java 2007-04-25
12:36:23 UTC (rev 7041)
+++ trunk/api/src/main/org/jboss/portal/spi/runtime/PortalRuntimeContext.java 2007-04-25
13:37:42 UTC (rev 7042)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.spi.runtime;
+import org.jboss.portal.api.PortalSession;
+
/**
* The portal runtime context which provides access to runtime objects.
*
@@ -38,7 +40,14 @@
String getUserId();
/**
- * Return the portal session or null if no session is associated with the client.
+ * Return the portal session or null if no session is associated with the context.
*/
PortalSession getSession();
+
+ /**
+ * Returns the navigational state context or null if no navigational state is
associated with the context.
+ *
+ * @return the navigational state context
+ */
+ NavigationalStateContext getNavigationalStateContext();
}
Deleted: trunk/api/src/main/org/jboss/portal/spi/runtime/PortalSession.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/spi/runtime/PortalSession.java 2007-04-25 12:36:23
UTC (rev 7041)
+++ trunk/api/src/main/org/jboss/portal/spi/runtime/PortalSession.java 2007-04-25 13:37:42
UTC (rev 7042)
@@ -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.spi.runtime;
-
-/**
- * The portal session, the portal session attributes are accessible however it is not
possible to influence
- * the lifecycle of the session as it is managed by the portal.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public interface PortalSession
-{
- /**
- * Return the session id.
- *
- * @return the session id
- */
- String getId();
-
- Object getAttribute(String name);
-
- void setAttribute(String name, Object attribute);
-
- void removeAttribute(String name);
-
-}
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-04-25
12:36:23 UTC (rev 7041)
+++
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-04-25
13:37:42 UTC (rev 7042)
@@ -306,7 +306,7 @@
//
request.setAttribute("org.jboss.portal.api.PORTAL_NODE",
Navigation.getCurrentNode());
- request.setAttribute("org.jboss.portal.api.PORTAL_NODE_URL_FACTORY",
Navigation.getFactory());
+ request.setAttribute("org.jboss.portal.api.PORTAL_RUNTIME_CONTEXT",
Navigation.getPortalRuntimeContext());
//
try
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-25
12:36:23 UTC (rev 7041)
+++
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/EventBroadcasterInterceptor.java 2007-04-25
13:37:42 UTC (rev 7042)
@@ -25,7 +25,6 @@
import org.apache.log4j.Logger;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
-import org.jboss.portal.spi.runtime.NavigationalStateContext;
import org.jboss.portal.api.node.PortalNode;
import org.jboss.portal.api.node.event.PortalNodeEvent;
import org.jboss.portal.api.node.event.WindowActionEvent;
@@ -34,7 +33,6 @@
import org.jboss.portal.api.node.event.WindowRenderEvent;
import org.jboss.portal.api.node.event.PageRenderEvent;
import org.jboss.portal.common.invocation.InvocationException;
-import org.jboss.portal.common.invocation.AttributeResolver;
import org.jboss.portal.common.util.LazyMap;
import org.jboss.portal.core.controller.CommandRedirectionException;
import org.jboss.portal.core.controller.ControllerCommand;
@@ -45,9 +43,9 @@
import org.jboss.portal.core.model.portal.command.WindowCommand;
import org.jboss.portal.core.model.portal.command.render.RenderPageCommand;
import org.jboss.portal.core.model.portal.PortalObjectId;
-import org.jboss.portal.core.model.portal.ns.WindowNavigationalState;
import org.jboss.portal.core.event.PortalEventListenerRegistry;
-import org.jboss.portal.core.ns.NavigationalStateKey;
+import org.jboss.portal.core.impl.api.CorePortalNode;
+import org.jboss.portal.core.impl.api.CorePortalRuntimeContext;
import org.jboss.portal.portlet.PortletParameters;
import org.jboss.portal.portlet.PortletParametersStateString;
import org.jboss.portal.portlet.StateString;
@@ -76,7 +74,7 @@
public ControllerResponse invoke(ControllerCommand cmd) throws Exception,
InvocationException
{
- PortalObjectNode node = Navigation.getCurrentNode();
+ CorePortalNode node = Navigation.getCurrentNode();
//
PortalNodeEvent event = createEvent(cmd, node);
@@ -85,8 +83,8 @@
{
try
{
- NavigationalStateContextImpl nsContext = new
NavigationalStateContextImpl(cmd.getContext().getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE));
- nextEvent = node.fireEvent(listenerRegistry, event, nsContext);
+ CorePortalRuntimeContext runtimeContext = new
CorePortalRuntimeContext(cmd.getControllerContext());
+ nextEvent = node.fireEvent(listenerRegistry, event, runtimeContext);
}
catch (Exception e)
{
@@ -101,7 +99,7 @@
WindowEvent we = (WindowEvent)nextEvent;
//
- PortalObjectNode nextNode = (PortalObjectNode)we.getNode();
+ CorePortalNode nextNode = (CorePortalNode)we.getNode();
PortalObjectId nodeRef = nextNode.getObjectId();
Mode mode = we.getMode();
WindowState windowState = we.getWindowState();
@@ -329,101 +327,4 @@
return params;
}
}
-
- private static class NavigationalStateContextImpl implements NavigationalStateContext
- {
-
- /** . */
- private AttributeResolver navigationalStateResolver;
-
- public NavigationalStateContextImpl(AttributeResolver navigationalStateResolver)
- {
- this.navigationalStateResolver = navigationalStateResolver;
- }
-
- private WindowNavigationalState getWNS(PortalNode window, boolean create)
- {
- PortalObjectNode pon = (PortalObjectNode)window;
- NavigationalStateKey key = new
NavigationalStateKey(WindowNavigationalState.class, pon.getObjectId());
- WindowNavigationalState wns =
(WindowNavigationalState)navigationalStateResolver.getAttribute(key);
- if (wns == null && create)
- {
- wns = new WindowNavigationalState();
- 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();
- }
-
- //
- PortalObjectNode pon = (PortalObjectNode)window;
- NavigationalStateKey key = new NavigationalStateKey(WindowState.class,
pon.getObjectId());
- navigationalStateResolver.setAttribute(key, 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();
- }
-
- //
- PortalObjectNode pon = (PortalObjectNode)window;
- NavigationalStateKey key = new NavigationalStateKey(Mode.class,
pon.getObjectId());
- navigationalStateResolver.setAttribute(key, mode);
- }
- }
}
\ No newline at end of file
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-25
12:36:23 UTC (rev 7041)
+++
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/Navigation.java 2007-04-25
13:37:42 UTC (rev 7042)
@@ -22,7 +22,8 @@
******************************************************************************/
package org.jboss.portal.core.aspects.controller.node;
-import org.jboss.portal.api.node.PortalNodeURLFactory;
+import org.jboss.portal.core.impl.api.CorePortalNode;
+import org.jboss.portal.spi.runtime.PortalRuntimeContext;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -35,26 +36,26 @@
private static final ThreadLocal currentNodeLocal = new ThreadLocal();
/** . */
- private static final ThreadLocal factoryLocal = new ThreadLocal();
+ private static final ThreadLocal runtimeContextLocal = new ThreadLocal();
- public static PortalObjectNode getCurrentNode()
+ public static CorePortalNode getCurrentNode()
{
- return (PortalObjectNode)currentNodeLocal.get();
+ return (CorePortalNode)currentNodeLocal.get();
}
- static void setCurrentNode(PortalObjectNode currentNode)
+ static void setCurrentNode(CorePortalNode currentNode)
{
currentNodeLocal.set(currentNode);
}
- public static PortalNodeURLFactory getFactory()
+ public static PortalRuntimeContext getPortalRuntimeContext()
{
- return (PortalNodeURLFactory)factoryLocal.get();
+ return (PortalRuntimeContext)runtimeContextLocal.get();
}
- static void setFactory(PortalNodeURLFactory factory)
+ static void setPortalRuntimeContext(PortalRuntimeContext portalRuntimeContext)
{
- factoryLocal.set(factory);
+ runtimeContextLocal.set(portalRuntimeContext);
}
/** Enforce singleton. */
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-25
12:36:23 UTC (rev 7041)
+++
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeInterceptor.java 2007-04-25
13:37:42 UTC (rev 7042)
@@ -30,6 +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.security.spi.auth.PortalAuthorizationManagerFactory;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
@@ -56,13 +58,13 @@
public ControllerResponse invoke(ControllerCommand cmd) throws Exception,
InvocationException
{
// Get the next node
- PortalObjectNode next = getNode(cmd);
+ CorePortalNode next = getNode(cmd);
// Save previous node temporarily
- PortalObjectNode previous = Navigation.getCurrentNode();
+ CorePortalNode previous = Navigation.getCurrentNode();
// Whether or not we inherit from an existing factory
- boolean noFactory = Navigation.getFactory() == null;
+ boolean noFactory = Navigation.getPortalRuntimeContext() == null;
try
{
@@ -72,7 +74,7 @@
//
if (noFactory)
{
- Navigation.setFactory(new
PortalNodeURLFactoryImpl(cmd.getControllerContext()));
+ Navigation.setPortalRuntimeContext(new
CorePortalRuntimeContext(cmd.getControllerContext()));
}
// Invoke
@@ -86,28 +88,28 @@
//
if (noFactory)
{
- Navigation.setFactory(null);
+ Navigation.setPortalRuntimeContext(null);
}
}
}
- private PortalObjectNode getNode(ControllerCommand cmd)
+ private CorePortalNode getNode(ControllerCommand cmd)
{
PortalAuthorizationManager pam = portalAuthorizationManagerFactory.getManager();
- PortalObjectNode next = null;
+ CorePortalNode next = null;
//
if (cmd instanceof WindowCommand)
{
WindowCommand windowCmd = (WindowCommand)cmd;
Window window = windowCmd.getWindow();
- next = new PortalObjectNode(pam, window);
+ next = new CorePortalNode(pam, window);
}
else if (cmd instanceof RenderPageCommand)
{
RenderPageCommand rpCmd = (RenderPageCommand)cmd;
Page page = rpCmd.getPage();
- next = new PortalObjectNode(pam, page);
+ next = new CorePortalNode(pam, page);
}
//
Deleted:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeURLFactoryImpl.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeURLFactoryImpl.java 2007-04-25
12:36:23 UTC (rev 7041)
+++
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeURLFactoryImpl.java 2007-04-25
13:37:42 UTC (rev 7042)
@@ -1,159 +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.aspects.controller.node;
-
-import org.jboss.portal.api.node.PortalNode;
-import org.jboss.portal.api.node.PortalNodeURL;
-import org.jboss.portal.api.node.PortalNodeURLFactory;
-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 PortalNodeURLFactoryImpl implements PortalNodeURLFactory
-{
-
- /** . */
- private final ControllerContext controllerContext;
-
- public PortalNodeURLFactoryImpl(ControllerContext controllerContext)
- {
- this.controllerContext = controllerContext;
- }
-
- public PortalNodeURL createURL(PortalNode node)
- {
- PortalObjectNode pon = (PortalObjectNode)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));
- }
- }
-}
Deleted:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalObjectNode.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalObjectNode.java 2007-04-25
12:36:23 UTC (rev 7041)
+++
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalObjectNode.java 2007-04-25
13:37:42 UTC (rev 7042)
@@ -1,511 +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.aspects.controller.node;
-
-import org.jboss.portal.api.node.PortalNode;
-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.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.spi.runtime.NavigationalStateContext;
-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 PortalObjectNode 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,
PortalObjectNode.class.getClassLoader()));
-
- /** The wrapped portal object. */
- private final PortalObject object;
-
- /** The parent node. */
- private PortalObjectNode 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 PortalObjectNode(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 PortalObjectNode(PortalObjectNode 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 PortalObjectNode(PortalObject object, PortalObjectNode 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 PortalObjectNode(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 PortalObjectId getObjectId()
- {
- return object.getId();
- }
-
- public PortalNodeEvent fireEvent(PortalEventListenerRegistry registry, PortalNodeEvent
event, NavigationalStateContext nsContext)
- {
- Bubbler bubbler = new Bubbler(registry, this, event, nsContext);
- return bubbler.dispatch();
- }
-
- private static class Bubbler implements PortalNodeEventContext
- {
-
- /** . */
- PortalEventListenerRegistry registry;
-
- /** . */
- private PortalNodeEvent event;
-
- /** . */
- private PortalObjectNode node;
-
- /** . */
- private NavigationalStateContext nsContext;
-
- public Bubbler(
- PortalEventListenerRegistry registry,
- PortalObjectNode node,
- PortalNodeEvent event,
- NavigationalStateContext nsContext)
- {
- this.registry = registry;
- this.node = node;
- this.event = event;
- this.nsContext = nsContext;
- }
-
- public NavigationalStateContext getNavigationalStateContext()
- {
- return nsContext;
- }
-
- 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)
- {
- PortalObjectNode current = node;
- try
- {
- node = (PortalObjectNode)node.getParent();
- nextEvent = listener.onEvent(this, event);
- }
- finally
- {
- node = current;
- }
- }
- else
- {
- if (node.getParent() != null)
- {
- PortalObjectNode current = node;
- try
- {
- node = (PortalObjectNode)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)
- {
- PortalObjectNode node1 = (PortalObjectNode)o1;
- PortalObjectNode node2 = (PortalObjectNode)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 class Children extends NodeList
- {
-
- /** . */
- private PortalObjectNode node;
-
- public Children(PortalObjectNode node)
- {
- this.node = node;
- }
-
- protected Map createMap()
- {
- return buildChildMap(node);
- }
- }
-
- private class Siblings extends NodeList
- {
-
- /** . */
- private PortalObjectNode node;
-
- private Siblings(PortalObjectNode 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;
- }
- }
-
- 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(PortalObjectNode 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))
- {
- PortalObjectNode child = new PortalObjectNode(objectNode,
childObject);
- childrenMap.put(child.getName(), child);
- }
- }
-
- //
- return childrenMap;
- }
- else
- {
- return Collections.EMPTY_MAP;
- }
- }
- }
-}
Modified: trunk/core/src/main/org/jboss/portal/core/event/user/UserEventBridge.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/event/user/UserEventBridge.java 2007-04-25
12:36:23 UTC (rev 7041)
+++ trunk/core/src/main/org/jboss/portal/core/event/user/UserEventBridge.java 2007-04-25
13:37:42 UTC (rev 7042)
@@ -23,8 +23,7 @@
package org.jboss.portal.core.event.user;
import org.jboss.portal.core.event.PortalEventListenerRegistry;
-import org.jboss.portal.core.impl.CoreRuntimeContext;
-import org.jboss.portal.core.impl.CoreSession;
+import org.jboss.portal.core.impl.api.CorePortalRuntimeContext;
import org.jboss.portal.api.user.event.UserSessionEvent;
import org.jboss.portal.api.user.event.UserAuthenticationEvent;
import org.jboss.portal.api.event.PortalEvent;
@@ -75,8 +74,7 @@
public void sessionCreated(HttpSessionEvent event)
{
- CoreRuntimeContext rt = new CoreRuntimeContext();
- rt.setSession(new CoreSession(event.getSession()));
+ CorePortalRuntimeContext rt = new CorePortalRuntimeContext(event.getSession());
//
UserSessionEvent use = new UserSessionEvent(rt, null,
UserSessionEvent.SESSION_CREATED);
@@ -85,8 +83,7 @@
public void sessionDestroyed(HttpSessionEvent event)
{
- CoreRuntimeContext rt = new CoreRuntimeContext();
- rt.setSession(new CoreSession(event.getSession()));
+ CorePortalRuntimeContext rt = new CorePortalRuntimeContext(event.getSession());
//
UserSessionEvent use = new UserSessionEvent(rt, null,
UserSessionEvent.SESSION_DESTROYED);
@@ -101,9 +98,7 @@
if ("PRINCIPAL_TOKEN".equals(event.getName()))
{
String userId = (String)event.getValue();
- CoreRuntimeContext rt = new CoreRuntimeContext();
- rt.setSession(new CoreSession(event.getSession()));
- rt.setUserId(userId);
+ CorePortalRuntimeContext rt = new CorePortalRuntimeContext(event.getSession(),
userId);
UserAuthenticationEvent uae = new UserAuthenticationEvent(rt, userId,
UserAuthenticationEvent.SIGN_IN);
fireEvent(uae);
}
@@ -114,9 +109,7 @@
if ("PRINCIPAL_TOKEN".equals(event.getName()))
{
String userId = (String)event.getValue();
- CoreRuntimeContext rt = new CoreRuntimeContext();
- rt.setSession(new CoreSession(event.getSession()));
- rt.setUserId(userId);
+ CorePortalRuntimeContext rt = new CorePortalRuntimeContext(event.getSession(),
userId);
UserAuthenticationEvent uae = new UserAuthenticationEvent(rt, userId,
UserAuthenticationEvent.SIGN_OUT);
fireEvent(uae);
}
Deleted: trunk/core/src/main/org/jboss/portal/core/impl/CoreRuntimeContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/CoreRuntimeContext.java 2007-04-25
12:36:23 UTC (rev 7041)
+++ trunk/core/src/main/org/jboss/portal/core/impl/CoreRuntimeContext.java 2007-04-25
13:37:42 UTC (rev 7042)
@@ -1,60 +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;
-
-import org.jboss.portal.spi.runtime.PortalRuntimeContext;
-import org.jboss.portal.spi.runtime.PortalSession;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class CoreRuntimeContext implements PortalRuntimeContext
-{
-
- /** . */
- private PortalSession session;
-
- /** . */
- private String userId;
-
- public String getUserId()
- {
- return null;
- }
-
- public void setUserId(String userId)
- {
- this.userId = userId;
- }
-
- public PortalSession getSession()
- {
- return session;
- }
-
- public void setSession(PortalSession session)
- {
- this.session = session;
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/impl/CoreSession.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/CoreSession.java 2007-04-25 12:36:23
UTC (rev 7041)
+++ trunk/core/src/main/org/jboss/portal/core/impl/CoreSession.java 2007-04-25 13:37:42
UTC (rev 7042)
@@ -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;
-
-import org.jboss.portal.spi.runtime.PortalSession;
-
-import javax.servlet.http.HttpSession;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class CoreSession implements PortalSession
-{
-
- /** . */
- private HttpSession session;
-
- public CoreSession(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);
- }
-}
Added:
trunk/core/src/main/org/jboss/portal/core/impl/api/CoreNavigationalStateContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/api/CoreNavigationalStateContext.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/api/CoreNavigationalStateContext.java 2007-04-25
13:37:42 UTC (rev 7042)
@@ -0,0 +1,132 @@
+/******************************************************************************
+ * 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.spi.runtime.NavigationalStateContext;
+import org.jboss.portal.core.ns.NavigationalStateKey;
+import org.jboss.portal.core.model.portal.ns.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 = new WindowNavigationalState();
+ 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;
+ NavigationalStateKey key = new NavigationalStateKey(WindowState.class,
pon.getObjectId());
+ navigationalStateResolver.setAttribute(key, 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;
+ NavigationalStateKey key = new NavigationalStateKey(Mode.class,
pon.getObjectId());
+ navigationalStateResolver.setAttribute(key, mode);
+ }
+}
Copied: trunk/core/src/main/org/jboss/portal/core/impl/api/CorePortalNode.java (from rev
7041,
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalObjectNode.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/api/CorePortalNode.java
(rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/impl/api/CorePortalNode.java 2007-04-25
13:37:42 UTC (rev 7042)
@@ -0,0 +1,519 @@
+/******************************************************************************
+ * 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.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.spi.runtime.PortalRuntimeContext;
+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;
+ }
+ }
+}
Copied: trunk/core/src/main/org/jboss/portal/core/impl/api/CorePortalRuntimeContext.java
(from rev 7039, trunk/core/src/main/org/jboss/portal/core/impl/CoreRuntimeContext.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/api/CorePortalRuntimeContext.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/api/CorePortalRuntimeContext.java 2007-04-25
13:37:42 UTC (rev 7042)
@@ -0,0 +1,97 @@
+/******************************************************************************
+ * 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.spi.runtime.PortalRuntimeContext;
+import org.jboss.portal.spi.runtime.NavigationalStateContext;
+import org.jboss.portal.api.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;
+ }
+}
Copied: trunk/core/src/main/org/jboss/portal/core/impl/api/CorePortalSession.java (from
rev 7039, trunk/core/src/main/org/jboss/portal/core/impl/CoreSession.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/api/CorePortalSession.java
(rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/impl/api/CorePortalSession.java 2007-04-25
13:37:42 UTC (rev 7042)
@@ -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;
+
+import org.jboss.portal.api.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);
+ }
+}
Copied: trunk/core/src/main/org/jboss/portal/core/impl/api/PortalNodeURLFactory.java (from
rev 7041,
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeURLFactoryImpl.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/api/PortalNodeURLFactory.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/api/PortalNodeURLFactory.java 2007-04-25
13:37:42 UTC (rev 7042)
@@ -0,0 +1,158 @@
+/******************************************************************************
+ * 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));
+ }
+ }
+}
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-25
12:36:23 UTC (rev 7041)
+++
trunk/core/src/main/org/jboss/portal/core/portlet/catalog/CatalogPortlet.java 2007-04-25
13:37:42 UTC (rev 7042)
@@ -24,7 +24,7 @@
import org.jboss.portal.api.node.PortalNode;
import org.jboss.portal.api.node.PortalNodeURL;
-import org.jboss.portal.core.aspects.controller.node.PortalObjectNode;
+import org.jboss.portal.core.impl.api.CorePortalNode;
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 PortalObjectNode)
+ if (child instanceof CorePortalNode)
{
- PortalObjectNode pn = (PortalObjectNode)child;
+ CorePortalNode pn = (CorePortalNode)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 PortalObjectNode)
+ if (parentSibling instanceof CorePortalNode)
{
- PortalObjectNode pn = (PortalObjectNode)parentSibling;
+ CorePortalNode pn = (CorePortalNode)parentSibling;
PortalObjectPermission perm = new
PortalObjectPermission(pn.getObjectId(), PortalObjectPermission.VIEW_MASK);
if
(portalAuthorizationManagerFactory.getManager().checkPermission(perm))
{
Modified: trunk/core/src/main/org/jboss/portlet/JBossActionResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portlet/JBossActionResponse.java 2007-04-25 12:36:23 UTC
(rev 7041)
+++ trunk/core/src/main/org/jboss/portlet/JBossActionResponse.java 2007-04-25 13:37:42 UTC
(rev 7042)
@@ -24,14 +24,13 @@
import org.jboss.portal.api.node.PortalNode;
import org.jboss.portal.api.node.PortalNodeURL;
-import org.jboss.portal.api.node.PortalNodeURLFactory;
import org.jboss.portal.common.util.URLTools;
-import org.jboss.portal.core.aspects.controller.node.PortalObjectNode;
import org.jboss.portal.core.aspects.controller.node.Navigation;
import org.jboss.portal.core.controller.portlet.SignOutResponse;
import org.jboss.portal.portlet.impl.jsr168.api.ActionResponseImpl;
import org.jboss.portal.portlet.impl.jsr168.api.PortletRequestImpl;
import org.jboss.portal.portlet.invocation.ActionInvocation;
+import org.jboss.portal.spi.runtime.PortalRuntimeContext;
import javax.portlet.PortletRequest;
@@ -88,44 +87,30 @@
public PortalNodeURL createActionURL(PortalNode node) throws IllegalArgumentException,
IllegalStateException
{
- PortalNodeURLFactory factory = Navigation.getFactory();
+ PortalRuntimeContext context = Navigation.getPortalRuntimeContext();
//
- if (factory == null)
+ if (context == null)
{
throw new IllegalStateException("Not in a controller context");
}
//
- if (node instanceof PortalObjectNode)
- {
- return factory.createURL(node);
- }
- else
- {
- throw new IllegalArgumentException();
- }
+ return node.createURL(context);
}
public PortalNodeURL createRenderURL(PortalNode node) throws IllegalArgumentException,
IllegalStateException
{
- PortalNodeURLFactory factory = Navigation.getFactory();
+ PortalRuntimeContext context = Navigation.getPortalRuntimeContext();
//
- if (factory == null)
+ if (context == null)
{
throw new IllegalStateException("Not in a controller context");
}
//
- if (node instanceof PortalObjectNode)
- {
- return factory.createURL(node);
- }
- else
- {
- throw new IllegalArgumentException();
- }
+ return node.createURL(context);
}
/**
Modified: trunk/core/src/main/org/jboss/portlet/JBossRenderResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portlet/JBossRenderResponse.java 2007-04-25 12:36:23 UTC
(rev 7041)
+++ trunk/core/src/main/org/jboss/portlet/JBossRenderResponse.java 2007-04-25 13:37:42 UTC
(rev 7042)
@@ -24,13 +24,12 @@
import org.jboss.portal.api.node.PortalNode;
import org.jboss.portal.api.node.PortalNodeURL;
-import org.jboss.portal.api.node.PortalNodeURLFactory;
-import org.jboss.portal.core.aspects.controller.node.PortalObjectNode;
import org.jboss.portal.core.aspects.controller.node.Navigation;
import org.jboss.portal.portlet.impl.jsr168.api.PortletRequestImpl;
import org.jboss.portal.portlet.impl.jsr168.api.RenderResponseImpl;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.spi.runtime.PortalRuntimeContext;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -46,44 +45,30 @@
public PortalNodeURL createActionURL(PortalNode node) throws IllegalArgumentException,
IllegalStateException
{
- PortalNodeURLFactory factory = Navigation.getFactory();
+ PortalRuntimeContext context = Navigation.getPortalRuntimeContext();
//
- if (factory == null)
+ if (context == null)
{
throw new IllegalStateException("Not in a controller context");
}
//
- if (node instanceof PortalObjectNode)
- {
- return factory.createURL(node);
- }
- else
- {
- throw new IllegalArgumentException();
- }
+ return node.createURL(context);
}
public PortalNodeURL createRenderURL(PortalNode node) throws IllegalArgumentException,
IllegalStateException
{
- PortalNodeURLFactory factory = Navigation.getFactory();
+ PortalRuntimeContext context = Navigation.getPortalRuntimeContext();
//
- if (factory == null)
+ if (context == null)
{
throw new IllegalStateException("Not in a controller context");
}
//
- if (node instanceof PortalObjectNode)
- {
- return factory.createURL(node);
- }
- else
- {
- throw new IllegalArgumentException();
- }
+ return node.createURL(context);
}
/** @deprecated */
Modified: trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/tabs.jsp
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/tabs.jsp 2007-04-25
12:36:23 UTC (rev 7041)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/tabs.jsp 2007-04-25
13:37:42 UTC (rev 7042)
@@ -1,12 +1,12 @@
<%@ page import="java.util.Iterator" %>
<%@ page import="org.jboss.portal.api.node.PortalNode" %>
-<%@ page import="org.jboss.portal.api.node.PortalNodeURLFactory" %>
<%@ page import="java.util.Locale" %>
<%@ page import="java.util.ArrayList" %>
+<%@ page import="org.jboss.portal.spi.runtime.PortalRuntimeContext" %>
<%
PortalNode root =
(PortalNode)request.getAttribute("org.jboss.portal.api.PORTAL_NODE");
- PortalNodeURLFactory factory =
(PortalNodeURLFactory)request.getAttribute("org.jboss.portal.api.PORTAL_NODE_URL_FACTORY");
+ PortalRuntimeContext context =
(PortalRuntimeContext)request.getAttribute("org.jboss.portal.api.PORTAL_RUNTIME_CONTEXT");
// Get a locale
Locale locale = request.getLocale();
@@ -35,7 +35,7 @@
}
}
%>
- <li <% if(sibling == root) out.println(" id=\"current\"");
%> onmouseover="this.className='hoverOn'"
onmouseout="this.className='hoverOff'"><a href="<%=
factory.createURL(sibling) %>"><%= sibling.getDisplayName(locale) %>
+ <li <% if(sibling == root) out.println(" id=\"current\"");
%> onmouseover="this.className='hoverOn'"
onmouseout="this.className='hoverOff'"><a href="<%=
sibling.createURL(context) %>"><%= sibling.getDisplayName(locale) %>
<%
if (tmp.size() == 0)
{
@@ -54,7 +54,7 @@
{
PortalNode siblingChild = (PortalNode)j.next();
%>
- <li><a href='<%= factory.createURL(siblingChild)
%>'><%= siblingChild.getDisplayName(locale) %></a></li>
+ <li><a href='<%= siblingChild.createURL(context)
%>'><%= siblingChild.getDisplayName(locale) %></a></li>
<%
}
%>
Modified:
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/event/WindowConstraintEventListener.java
===================================================================
---
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/event/WindowConstraintEventListener.java 2007-04-25
12:36:23 UTC (rev 7041)
+++
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/event/WindowConstraintEventListener.java 2007-04-25
13:37:42 UTC (rev 7042)
@@ -52,7 +52,7 @@
if (event instanceof PageRenderEvent)
{
PortalNode targetPage = event.getNode();
- WindowManipulator manipulator = new
WindowManipulator(context.getNavigationalStateContext(), targetPage);
+ WindowManipulator manipulator = new
WindowManipulator(context.getPortalRuntimeContext().getNavigationalStateContext(),
targetPage);
// Filter window state for normal and minimized
for (Iterator i = manipulator.getRegionNames().iterator();i.hasNext();)
@@ -104,7 +104,7 @@
{
WindowNavigationEvent wne = (WindowNavigationEvent)event;
PortalNode targetWindow = event.getNode();
- WindowManipulator manipulator = new
WindowManipulator(context.getNavigationalStateContext(), targetWindow.getParent());
+ WindowManipulator manipulator = new
WindowManipulator(context.getPortalRuntimeContext().getNavigationalStateContext(),
targetWindow.getParent());
//
WindowState ws = wne.getWindowState();