JBoss Portal SVN: r7046 - in trunk: api/src/main/org/jboss/portal/api/event and 10 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-04-25 11:54:20 -0400 (Wed, 25 Apr 2007)
New Revision: 7046
Added:
trunk/api/src/main/org/jboss/portal/api/PortalRuntimeContext.java
trunk/api/src/main/org/jboss/portal/api/navstate/
trunk/api/src/main/org/jboss/portal/api/navstate/NavigationalStateContext.java
Removed:
trunk/api/src/main/org/jboss/portal/spi/runtime/NavigationalStateContext.java
trunk/api/src/main/org/jboss/portal/spi/runtime/PortalRuntimeContext.java
Modified:
trunk/api/src/main/org/jboss/portal/api/event/PortalEventContext.java
trunk/api/src/main/org/jboss/portal/api/node/PortalNode.java
trunk/api/src/main/org/jboss/portal/api/node/event/PortalNodeEvent.java
trunk/api/src/main/org/jboss/portal/api/node/event/PortalNodeEventContext.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/node/Navigation.java
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/user/UserEventContext.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:
minor reorg of API for non published classes
Copied: trunk/api/src/main/org/jboss/portal/api/PortalRuntimeContext.java (from rev 7042, trunk/api/src/main/org/jboss/portal/spi/runtime/PortalRuntimeContext.java)
===================================================================
--- trunk/api/src/main/org/jboss/portal/api/PortalRuntimeContext.java (rev 0)
+++ trunk/api/src/main/org/jboss/portal/api/PortalRuntimeContext.java 2007-04-25 15:54:20 UTC (rev 7046)
@@ -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;
+
+import org.jboss.portal.api.navstate.NavigationalStateContext;
+import org.jboss.portal.api.PortalSession;
+
+/**
+ * The portal runtime context which provides access to runtime objects.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface PortalRuntimeContext
+{
+ /**
+ * Return the user id or null if no user is associated with the context.
+ *
+ * @return the user id
+ */
+ String getUserId();
+
+ /**
+ * Return the portal session or null if no session is associated with the context.
+ *
+ * @return the portal session
+ */
+ 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();
+}
Modified: trunk/api/src/main/org/jboss/portal/api/event/PortalEventContext.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/api/event/PortalEventContext.java 2007-04-25 15:30:21 UTC (rev 7045)
+++ trunk/api/src/main/org/jboss/portal/api/event/PortalEventContext.java 2007-04-25 15:54:20 UTC (rev 7046)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.api.event;
-import org.jboss.portal.spi.runtime.PortalRuntimeContext;
+import org.jboss.portal.api.PortalRuntimeContext;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
Added: trunk/api/src/main/org/jboss/portal/api/navstate/NavigationalStateContext.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/api/navstate/NavigationalStateContext.java (rev 0)
+++ trunk/api/src/main/org/jboss/portal/api/navstate/NavigationalStateContext.java 2007-04-25 15:54:20 UTC (rev 7046)
@@ -0,0 +1,72 @@
+/******************************************************************************
+ * 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.navstate;
+
+import org.jboss.portal.WindowState;
+import org.jboss.portal.Mode;
+import org.jboss.portal.api.node.PortalNode;
+
+/**
+ * Provide access to a portion of the navigational state managed by the portal.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface NavigationalStateContext
+{
+ /**
+ * Returns the window state of a window or null if it is not found.
+ *
+ * @param window the window from which the window state is returned
+ * @return the window state
+ * @throws IllegalArgumentException
+ */
+ WindowState getWindowState(PortalNode window) throws IllegalArgumentException;
+
+ /**
+ * Updates the window state of a window.
+ *
+ * @param window the window to update
+ * @param windowState the new window state value
+ * @throws IllegalArgumentException
+ */
+ void setWindowState(PortalNode window, WindowState windowState) throws IllegalArgumentException;
+
+ /**
+ * Returns the mode of a window or null if it is not found.
+ *
+ * @param window the window from which the mode is returned
+ * @return the mode
+ * @throws IllegalArgumentException
+ */
+ Mode getMode(PortalNode window) throws IllegalArgumentException;
+
+ /**
+ * Updates the mode of a window.
+ *
+ * @param window the window to update
+ * @param mode the new mode value
+ * @throws IllegalArgumentException
+ */
+ void setMode(PortalNode window, Mode mode) throws IllegalArgumentException;
+}
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 15:30:21 UTC (rev 7045)
+++ trunk/api/src/main/org/jboss/portal/api/node/PortalNode.java 2007-04-25 15:54:20 UTC (rev 7046)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.api.node;
-import org.jboss.portal.spi.runtime.PortalRuntimeContext;
+import org.jboss.portal.api.PortalRuntimeContext;
import java.util.Collection;
import java.util.Map;
Modified: trunk/api/src/main/org/jboss/portal/api/node/event/PortalNodeEvent.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/api/node/event/PortalNodeEvent.java 2007-04-25 15:30:21 UTC (rev 7045)
+++ trunk/api/src/main/org/jboss/portal/api/node/event/PortalNodeEvent.java 2007-04-25 15:54:20 UTC (rev 7046)
@@ -23,13 +23,14 @@
package org.jboss.portal.api.node.event;
import org.jboss.portal.api.node.PortalNode;
+import org.jboss.portal.api.event.PortalEvent;
/**
* Base class for all portal node events.
*
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
*/
-public abstract class PortalNodeEvent
+public abstract class PortalNodeEvent extends PortalEvent
{
/** The portal node targetted by this event. */
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 15:30:21 UTC (rev 7045)
+++ trunk/api/src/main/org/jboss/portal/api/node/event/PortalNodeEventContext.java 2007-04-25 15:54:20 UTC (rev 7046)
@@ -24,7 +24,6 @@
import org.jboss.portal.api.node.PortalNode;
import org.jboss.portal.api.event.PortalEventContext;
-import org.jboss.portal.spi.runtime.PortalRuntimeContext;
/**
* The context in which a <code>PortalNodeEvent</code> is dispatched.
Deleted: trunk/api/src/main/org/jboss/portal/spi/runtime/NavigationalStateContext.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/spi/runtime/NavigationalStateContext.java 2007-04-25 15:30:21 UTC (rev 7045)
+++ trunk/api/src/main/org/jboss/portal/spi/runtime/NavigationalStateContext.java 2007-04-25 15:54:20 UTC (rev 7046)
@@ -1,72 +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;
-
-import org.jboss.portal.WindowState;
-import org.jboss.portal.Mode;
-import org.jboss.portal.api.node.PortalNode;
-
-/**
- * Provide access to a portion of the navigational state managed by the portal.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public interface NavigationalStateContext
-{
- /**
- * Returns the window state of a window or null if it is not found.
- *
- * @param window the window from which the window state is returned
- * @return the window state
- * @throws IllegalArgumentException
- */
- WindowState getWindowState(PortalNode window) throws IllegalArgumentException;
-
- /**
- * Updates the window state of a window.
- *
- * @param window the window to update
- * @param windowState the new window state value
- * @throws IllegalArgumentException
- */
- void setWindowState(PortalNode window, WindowState windowState) throws IllegalArgumentException;
-
- /**
- * Returns the mode of a window or null if it is not found.
- *
- * @param window the window from which the mode is returned
- * @return the mode
- * @thrpows IllegalArgumentException
- */
- Mode getMode(PortalNode window) throws IllegalArgumentException;
-
- /**
- * Updates the mode of a window.
- *
- * @param window the window to update
- * @param mode the new mode value
- * @throws IllegalArgumentException
- */
- void setMode(PortalNode window, Mode mode) throws IllegalArgumentException;
-}
Deleted: 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 15:30:21 UTC (rev 7045)
+++ trunk/api/src/main/org/jboss/portal/spi/runtime/PortalRuntimeContext.java 2007-04-25 15:54:20 UTC (rev 7046)
@@ -1,53 +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;
-
-import org.jboss.portal.api.PortalSession;
-
-/**
- * The portal runtime context which provides access to runtime objects.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public interface PortalRuntimeContext
-{
- /**
- * Return the user id or null if no user is associated with the context.
- *
- * @return the user id
- */
- String getUserId();
-
- /**
- * 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();
-}
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 15:30:21 UTC (rev 7045)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/Navigation.java 2007-04-25 15:54:20 UTC (rev 7046)
@@ -23,7 +23,7 @@
package org.jboss.portal.core.aspects.controller.node;
import org.jboss.portal.core.impl.api.CorePortalNode;
-import org.jboss.portal.spi.runtime.PortalRuntimeContext;
+import org.jboss.portal.api.PortalRuntimeContext;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
Modified: 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-25 15:30:21 UTC (rev 7045)
+++ trunk/core/src/main/org/jboss/portal/core/impl/api/CoreNavigationalStateContext.java 2007-04-25 15:54:20 UTC (rev 7046)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.core.impl.api;
-import org.jboss.portal.spi.runtime.NavigationalStateContext;
+import org.jboss.portal.api.navstate.NavigationalStateContext;
import org.jboss.portal.core.ns.NavigationalStateKey;
import org.jboss.portal.core.model.portal.ns.WindowNavigationalState;
import org.jboss.portal.api.node.PortalNode;
Modified: 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-25 15:30:21 UTC (rev 7045)
+++ trunk/core/src/main/org/jboss/portal/core/impl/api/CorePortalNode.java 2007-04-25 15:54:20 UTC (rev 7046)
@@ -27,6 +27,7 @@
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;
@@ -34,7 +35,6 @@
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;
Modified: 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-25 15:30:21 UTC (rev 7045)
+++ trunk/core/src/main/org/jboss/portal/core/impl/api/CorePortalRuntimeContext.java 2007-04-25 15:54:20 UTC (rev 7046)
@@ -22,8 +22,8 @@
******************************************************************************/
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.PortalRuntimeContext;
+import org.jboss.portal.api.navstate.NavigationalStateContext;
import org.jboss.portal.api.PortalSession;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.ControllerCommand;
Modified: 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-25 15:30:21 UTC (rev 7045)
+++ trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventContext.java 2007-04-25 15:54:20 UTC (rev 7046)
@@ -23,7 +23,7 @@
package org.jboss.portal.core.impl.api.user;
import org.jboss.portal.api.event.PortalEventContext;
-import org.jboss.portal.spi.runtime.PortalRuntimeContext;
+import org.jboss.portal.api.PortalRuntimeContext;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
Modified: trunk/core/src/main/org/jboss/portlet/JBossActionResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portlet/JBossActionResponse.java 2007-04-25 15:30:21 UTC (rev 7045)
+++ trunk/core/src/main/org/jboss/portlet/JBossActionResponse.java 2007-04-25 15:54:20 UTC (rev 7046)
@@ -24,13 +24,13 @@
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.util.URLTools;
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;
Modified: trunk/core/src/main/org/jboss/portlet/JBossRenderResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portlet/JBossRenderResponse.java 2007-04-25 15:30:21 UTC (rev 7045)
+++ trunk/core/src/main/org/jboss/portlet/JBossRenderResponse.java 2007-04-25 15:54:20 UTC (rev 7046)
@@ -24,12 +24,12 @@
import org.jboss.portal.api.node.PortalNode;
import org.jboss.portal.api.node.PortalNodeURL;
+import org.jboss.portal.api.PortalRuntimeContext;
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>
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 15:30:21 UTC (rev 7045)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/tabs.jsp 2007-04-25 15:54:20 UTC (rev 7046)
@@ -2,7 +2,7 @@
<%@ page import="org.jboss.portal.api.node.PortalNode" %>
<%@ page import="java.util.Locale" %>
<%@ page import="java.util.ArrayList" %>
-<%@ page import="org.jboss.portal.spi.runtime.PortalRuntimeContext" %>
+<%@ page import="org.jboss.portal.api.PortalRuntimeContext" %>
<%
PortalNode root = (PortalNode)request.getAttribute("org.jboss.portal.api.PORTAL_NODE");
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 15:30:21 UTC (rev 7045)
+++ trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/event/WindowConstraintEventListener.java 2007-04-25 15:54:20 UTC (rev 7046)
@@ -28,8 +28,8 @@
import org.jboss.portal.api.node.event.PageRenderEvent;
import org.jboss.portal.api.node.event.WindowNavigationEvent;
import org.jboss.portal.api.node.PortalNode;
+import org.jboss.portal.api.navstate.NavigationalStateContext;
import org.jboss.portal.theme.ThemeConstants;
-import org.jboss.portal.spi.runtime.NavigationalStateContext;
import org.jboss.portal.WindowState;
import java.util.Map;
17 years, 2 months
JBoss Portal SVN: r7045 - trunk/api/src/main/org/jboss/portal/spi/runtime.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-04-25 11:30:21 -0400 (Wed, 25 Apr 2007)
New Revision: 7045
Removed:
trunk/api/src/main/org/jboss/portal/spi/runtime/PortalRuntimeObject.java
Log:
removed unused interface
Deleted: trunk/api/src/main/org/jboss/portal/spi/runtime/PortalRuntimeObject.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/spi/runtime/PortalRuntimeObject.java 2007-04-25 14:27:31 UTC (rev 7044)
+++ trunk/api/src/main/org/jboss/portal/spi/runtime/PortalRuntimeObject.java 2007-04-25 15:30:21 UTC (rev 7045)
@@ -1,32 +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;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public interface PortalRuntimeObject
-{
- PortalRuntimeContext getRuntimeContext();
-}
17 years, 2 months
JBoss Portal SVN: r7043 - in trunk: api/src/main/org/jboss/portal/api/event and 10 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-04-25 10:26:47 -0400 (Wed, 25 Apr 2007)
New Revision: 7043
Added:
trunk/api/src/main/org/jboss/portal/api/event/PortalEventContext.java
trunk/core/src/main/org/jboss/portal/core/impl/api/user/
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
Removed:
trunk/core/src/main/org/jboss/portal/core/event/SessionEventListenerRegistry.java
trunk/core/src/main/org/jboss/portal/core/event/user/
Modified:
trunk/api/src/main/org/jboss/portal/api/PortalSession.java
trunk/api/src/main/org/jboss/portal/api/event/PortalEvent.java
trunk/api/src/main/org/jboss/portal/api/event/PortalEventListener.java
trunk/api/src/main/org/jboss/portal/api/node/event/PortalNodeEventContext.java
trunk/api/src/main/org/jboss/portal/api/user/event/UserAuthenticationEvent.java
trunk/api/src/main/org/jboss/portal/api/user/event/UserEvent.java
trunk/api/src/main/org/jboss/portal/api/user/event/UserSessionEvent.java
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/event/PortalEventListenerLogger.java
trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
trunk/core/src/resources/portal-server-war/WEB-INF/web.xml
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/SessionHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
Log:
- slight improvement to portal API
Modified: trunk/api/src/main/org/jboss/portal/api/PortalSession.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/api/PortalSession.java 2007-04-25 13:37:42 UTC (rev 7042)
+++ trunk/api/src/main/org/jboss/portal/api/PortalSession.java 2007-04-25 14:26:47 UTC (rev 7043)
@@ -38,10 +38,29 @@
*/
String getId();
- Object getAttribute(String name);
+ /**
+ * Returns a session attribute.
+ *
+ * @param name the attribute name
+ * @return the attribute value or null if it is not found
+ * @throws IllegalArgumentException if the attribute name is null
+ */
+ Object getAttribute(String name) throws IllegalArgumentException;
- void setAttribute(String name, Object attribute);
+ /**
+ * Update an attribute value. If the attribute value is null, then it is considered as a removal.
+ *
+ * @param name the attribute name
+ * @param attribute the attribute value
+ * @throws IllegalArgumentException if the attribute name is null
+ */
+ void setAttribute(String name, Object attribute) throws IllegalArgumentException;
- void removeAttribute(String name);
-
+ /**
+ * Removes an attribute value.
+ *
+ * @param name the attribute name
+ * @throws IllegalArgumentException if the attribute name is null
+ */
+ void removeAttribute(String name) throws IllegalArgumentException;
}
Modified: trunk/api/src/main/org/jboss/portal/api/event/PortalEvent.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/api/event/PortalEvent.java 2007-04-25 13:37:42 UTC (rev 7042)
+++ trunk/api/src/main/org/jboss/portal/api/event/PortalEvent.java 2007-04-25 14:26:47 UTC (rev 7043)
@@ -22,8 +22,6 @@
******************************************************************************/
package org.jboss.portal.api.event;
-import org.jboss.portal.spi.runtime.PortalRuntimeContext;
-
/**
* Base event class for portal events.
*
@@ -32,22 +30,4 @@
*/
public abstract class PortalEvent
{
-
- /** The portal runtime context. */
- protected PortalRuntimeContext runtimeContext;
-
- protected PortalEvent(PortalRuntimeContext runtimeContext)
- {
- this.runtimeContext = runtimeContext;
- }
-
- /**
- * Returns the runtime context or null if it is not available during the event broadcasting.
- *
- * @return the portal runtime context
- */
- public PortalRuntimeContext getRuntimeContext()
- {
- return runtimeContext;
- }
}
Added: trunk/api/src/main/org/jboss/portal/api/event/PortalEventContext.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/api/event/PortalEventContext.java (rev 0)
+++ trunk/api/src/main/org/jboss/portal/api/event/PortalEventContext.java 2007-04-25 14:26:47 UTC (rev 7043)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * 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.event;
+
+import org.jboss.portal.spi.runtime.PortalRuntimeContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface PortalEventContext
+{
+ /**
+ * Returns the portal runtime context or null if no event context can be associated with the event.
+ *
+ * @return the portal runtime context
+ */
+ PortalRuntimeContext getPortalRuntimeContext();
+}
Modified: trunk/api/src/main/org/jboss/portal/api/event/PortalEventListener.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/api/event/PortalEventListener.java 2007-04-25 13:37:42 UTC (rev 7042)
+++ trunk/api/src/main/org/jboss/portal/api/event/PortalEventListener.java 2007-04-25 14:26:47 UTC (rev 7043)
@@ -28,5 +28,5 @@
*/
public interface PortalEventListener
{
- void onEvent(PortalEvent event);
+ void onEvent(PortalEventContext eventContext, PortalEvent event);
}
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 13:37:42 UTC (rev 7042)
+++ trunk/api/src/main/org/jboss/portal/api/node/event/PortalNodeEventContext.java 2007-04-25 14:26:47 UTC (rev 7043)
@@ -23,6 +23,7 @@
package org.jboss.portal.api.node.event;
import org.jboss.portal.api.node.PortalNode;
+import org.jboss.portal.api.event.PortalEventContext;
import org.jboss.portal.spi.runtime.PortalRuntimeContext;
/**
@@ -31,7 +32,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public interface PortalNodeEventContext
+public interface PortalNodeEventContext extends PortalEventContext
{
/**
* Dispatch the event to the next listeners.
@@ -46,11 +47,4 @@
* @return the current node.
*/
PortalNode getNode();
-
- /**
- * Returns the portal runtime context.
- *
- * @return the portal runtime context
- */
- PortalRuntimeContext getPortalRuntimeContext();
}
Modified: trunk/api/src/main/org/jboss/portal/api/user/event/UserAuthenticationEvent.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/api/user/event/UserAuthenticationEvent.java 2007-04-25 13:37:42 UTC (rev 7042)
+++ trunk/api/src/main/org/jboss/portal/api/user/event/UserAuthenticationEvent.java 2007-04-25 14:26:47 UTC (rev 7043)
@@ -22,8 +22,6 @@
******************************************************************************/
package org.jboss.portal.api.user.event;
-import org.jboss.portal.spi.runtime.PortalRuntimeContext;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -38,15 +36,11 @@
private final int type;
- public UserAuthenticationEvent(PortalRuntimeContext runtimeContext, String userId, int type)
+ public UserAuthenticationEvent(String userId, int type)
{
- super(runtimeContext, userId);
+ super(userId);
//
- if (runtimeContext == null)
- {
- throw new IllegalArgumentException("Need a runtime context for this kind of event");
- }
if (userId == null)
{
throw new IllegalArgumentException("No user id provided");
Modified: trunk/api/src/main/org/jboss/portal/api/user/event/UserEvent.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/api/user/event/UserEvent.java 2007-04-25 13:37:42 UTC (rev 7042)
+++ trunk/api/src/main/org/jboss/portal/api/user/event/UserEvent.java 2007-04-25 14:26:47 UTC (rev 7043)
@@ -23,7 +23,6 @@
package org.jboss.portal.api.user.event;
import org.jboss.portal.api.event.PortalEvent;
-import org.jboss.portal.spi.runtime.PortalRuntimeContext;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -35,9 +34,8 @@
/** The user id or null if the user is anonymous. */
protected final String userId;
- public UserEvent(PortalRuntimeContext runtimeContext, String userId)
+ public UserEvent(String userId)
{
- super(runtimeContext);
this.userId = userId;
}
Modified: trunk/api/src/main/org/jboss/portal/api/user/event/UserSessionEvent.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/api/user/event/UserSessionEvent.java 2007-04-25 13:37:42 UTC (rev 7042)
+++ trunk/api/src/main/org/jboss/portal/api/user/event/UserSessionEvent.java 2007-04-25 14:26:47 UTC (rev 7043)
@@ -22,8 +22,6 @@
******************************************************************************/
package org.jboss.portal.api.user.event;
-import org.jboss.portal.spi.runtime.PortalRuntimeContext;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -37,15 +35,11 @@
private final int type;
- public UserSessionEvent(PortalRuntimeContext runtimeContext, String userId, int type)
+ public UserSessionEvent(String userId, int type)
{
- super(runtimeContext, userId);
+ super(userId);
//
- if (runtimeContext == null)
- {
- throw new IllegalArgumentException("Need a runtime context for this kind of event");
- }
if (type < SESSION_CREATED || type > SESSION_DESTROYED)
{
throw new IllegalArgumentException("Wrong event type");
Deleted: trunk/core/src/main/org/jboss/portal/core/event/SessionEventListenerRegistry.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/event/SessionEventListenerRegistry.java 2007-04-25 13:37:42 UTC (rev 7042)
+++ trunk/core/src/main/org/jboss/portal/core/event/SessionEventListenerRegistry.java 2007-04-25 14:26:47 UTC (rev 7043)
@@ -1,83 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2007, 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.event;
-
-import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
-import org.jboss.portal.common.util.ParameterValidation;
-
-import javax.servlet.http.HttpSessionEvent;
-import javax.servlet.http.HttpSessionListener;
-import java.util.Iterator;
-import java.util.Map;
-
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
- * @version $Revision$
- * @since 2.6
- */
-public class SessionEventListenerRegistry implements HttpSessionListener
-{
- private static final Map listeners = new ConcurrentHashMap();
-
- public static void registerListener(String id, HttpSessionListener listener)
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(listener, "listener");
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "listener identifier", "registerListener");
-
- listeners.put(id, listener);
- }
-
- public static void unregisterListener(String id)
- {
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "listener identifier", "unregisterListener");
-
- listeners.remove(id);
- }
-
- public static HttpSessionListener getListener(String id)
- {
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "listener identifier", "getListener");
-
- return (HttpSessionListener)listeners.get(id);
- }
-
- public void sessionCreated(HttpSessionEvent httpSessionEvent)
- {
- for (Iterator allListeners = listeners.values().iterator(); allListeners.hasNext();)
- {
- HttpSessionListener listener = (HttpSessionListener)allListeners.next();
- listener.sessionCreated(httpSessionEvent);
- }
- }
-
- public void sessionDestroyed(HttpSessionEvent httpSessionEvent)
- {
- for (Iterator allListeners = listeners.values().iterator(); allListeners.hasNext();)
- {
- HttpSessionListener listener = (HttpSessionListener)allListeners.next();
- listener.sessionDestroyed(httpSessionEvent);
- }
- }
-}
Copied: trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventBridge.java (from rev 7042, trunk/core/src/main/org/jboss/portal/core/event/user/UserEventBridge.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventBridge.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventBridge.java 2007-04-25 14:26:47 UTC (rev 7043)
@@ -0,0 +1,142 @@
+/******************************************************************************
+ * 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.core.event.PortalEventListenerRegistry;
+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;
+import org.jboss.portal.api.event.PortalEventListener;
+import org.jboss.portal.api.event.PortalEventContext;
+import org.jboss.mx.util.MBeanProxy;
+import org.jboss.mx.util.ObjectNameFactory;
+import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.mx.util.MBeanProxyCreationException;
+
+import javax.servlet.http.HttpSessionListener;
+import javax.servlet.http.HttpSessionAttributeListener;
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionBindingEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletContextEvent;
+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);
+ UserSessionEvent use = new UserSessionEvent(null, UserSessionEvent.SESSION_CREATED);
+ fireEvent(uec, use);
+ }
+
+ public void sessionDestroyed(HttpSessionEvent event)
+ {
+ CorePortalRuntimeContext rt = new CorePortalRuntimeContext(event.getSession());
+ UserEventContext uec = new UserEventContext(rt);
+ UserSessionEvent use = new UserSessionEvent(null, UserSessionEvent.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(null, event);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+}
Added: 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 (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventContext.java 2007-04-25 14:26:47 UTC (rev 7043)
@@ -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.user;
+
+import org.jboss.portal.api.event.PortalEventContext;
+import org.jboss.portal.spi.runtime.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;
+ }
+}
Copied: trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventInterceptor.java (from rev 7039, trunk/core/src/main/org/jboss/portal/core/event/user/UserEventInterceptor.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventInterceptor.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventInterceptor.java 2007-04-25 14:26:47 UTC (rev 7043)
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * 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/resources/portal-core-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-04-25 13:37:42 UTC (rev 7042)
+++ trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-04-25 14:26:47 UTC (rev 7043)
@@ -108,7 +108,7 @@
<xmbean/>
</mbean>
<mbean
- code="org.jboss.portal.core.event.user.UserEventInterceptor"
+ code="org.jboss.portal.core.impl.api.user.UserEventInterceptor"
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-25 13:37:42 UTC (rev 7042)
+++ trunk/core/src/resources/portal-server-war/WEB-INF/web.xml 2007-04-25 14:26:47 UTC (rev 7043)
@@ -33,7 +33,7 @@
<!-- Bridge portal user events -->
<listener>
- <listener-class>org.jboss.portal.core.event.user.UserEventBridge</listener-class>
+ <listener-class>org.jboss.portal.core.impl.api.user.UserEventBridge</listener-class>
</listener>
<!-- The portal servlet is the main entrance point -->
Modified: trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/event/PortalEventListenerLogger.java
===================================================================
--- trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/event/PortalEventListenerLogger.java 2007-04-25 13:37:42 UTC (rev 7042)
+++ trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/event/PortalEventListenerLogger.java 2007-04-25 14:26:47 UTC (rev 7043)
@@ -24,6 +24,7 @@
import org.jboss.portal.api.event.PortalEventListener;
import org.jboss.portal.api.event.PortalEvent;
+import org.jboss.portal.api.event.PortalEventContext;
import org.jboss.portal.api.user.event.UserSessionEvent;
import org.jboss.portal.api.user.event.UserAuthenticationEvent;
@@ -33,7 +34,7 @@
*/
public class PortalEventListenerLogger implements PortalEventListener
{
- public void onEvent(PortalEvent event)
+ public void onEvent(PortalEventContext eventContext, PortalEvent event)
{
if (event instanceof UserSessionEvent)
{
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java 2007-04-25 13:37:42 UTC (rev 7042)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java 2007-04-25 14:26:47 UTC (rev 7043)
@@ -24,6 +24,7 @@
package org.jboss.portal.test.wsrp.framework.support;
import org.jboss.portal.api.event.PortalEvent;
+import org.jboss.portal.api.event.PortalEventContext;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletContext;
import org.jboss.portal.portlet.PortletInvokerException;
@@ -160,7 +161,7 @@
{
}
- public void onEvent(PortalEvent event)
+ public void onEvent(PortalEventContext eventContext, PortalEvent event)
{
}
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/SessionHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/SessionHandler.java 2007-04-25 13:37:42 UTC (rev 7042)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/SessionHandler.java 2007-04-25 14:26:47 UTC (rev 7043)
@@ -26,6 +26,7 @@
import org.jboss.logging.Logger;
import org.jboss.portal.api.event.PortalEvent;
import org.jboss.portal.api.event.PortalEventListener;
+import org.jboss.portal.api.event.PortalEventContext;
import org.jboss.portal.api.user.event.UserSessionEvent;
import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.portlet.InvokerUnavailableException;
@@ -400,13 +401,13 @@
// PortalEventListener implementation
- public void onEvent(PortalEvent event)
+ public void onEvent(PortalEventContext eventContext, PortalEvent event)
{
if (event instanceof UserSessionEvent)
{
UserSessionEvent use = (UserSessionEvent)event;
int type = use.getType();
- String id = use.getRuntimeContext().getSession().getId();
+ String id = eventContext.getPortalRuntimeContext().getSession().getId();
switch (type)
{
case UserSessionEvent.SESSION_CREATED:
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-04-25 13:37:42 UTC (rev 7042)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-04-25 14:26:47 UTC (rev 7043)
@@ -23,6 +23,7 @@
package org.jboss.portal.wsrp.consumer;
import org.jboss.portal.api.event.PortalEvent;
+import org.jboss.portal.api.event.PortalEventContext;
import org.jboss.portal.common.i18n.LocaleInfo;
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.common.util.ParameterValidation;
@@ -627,11 +628,12 @@
/**
* Just delegate to SessionHandler
*
+ * @param eventContext
* @param event
* @since 2.6
*/
- public void onEvent(PortalEvent event)
+ public void onEvent(PortalEventContext eventContext, PortalEvent event)
{
- sessionHandler.onEvent(event);
+ sessionHandler.onEvent(null, event);
}
}
17 years, 2 months
JBoss Portal SVN: r7042 - in trunk: api/src/main/org/jboss/portal/api/node and 11 other directories.
by portal-commits@lists.jboss.org
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();
17 years, 2 months
JBoss Portal SVN: r7041 - in trunk: common/src/main/org/jboss/portal/common and 8 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-04-25 08:36:23 -0400 (Wed, 25 Apr 2007)
New Revision: 7041
Added:
trunk/api/src/main/org/jboss/portal/api/node/PortalNodeURLFactory.java
trunk/common/src/main/org/jboss/portal/common/servlet/
trunk/common/src/main/org/jboss/portal/common/servlet/BufferingRequestWrapper.java
trunk/common/src/main/org/jboss/portal/common/servlet/BufferingResponseWrapper.java
trunk/common/src/main/org/jboss/portal/common/servlet/ServletOutputStreamBuffer.java
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeURLFactoryImpl.java
Removed:
trunk/common/src/main/org/jboss/portal/common/http/HttpServletRequestWrapper.java
trunk/common/src/main/org/jboss/portal/common/http/HttpServletResponseWriter.java
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeURLFactory.java
Modified:
trunk/api/src/main/org/jboss/portal/api/node/PortalNode.java
trunk/common/src/main/org/jboss/portal/common/util/Tools.java
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.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/aspects/controller/node/PortalObjectNode.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-sar/META-INF/jboss-service.xml
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/header.jsp
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/tabs.jsp
Log:
- improved implementation of PortalNode to include security filtering, display name
- use PortalNode api for the tabs JSP as it is part of the API (no need to expose a new API)
- renamed PageCustomizer attributes to have suffix "Path" instead of "JSP" as any servlet can be used, not only JSPs
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:15:13 UTC (rev 7040)
+++ trunk/api/src/main/org/jboss/portal/api/node/PortalNode.java 2007-04-25 12:36:23 UTC (rev 7041)
@@ -24,6 +24,7 @@
import java.util.Collection;
import java.util.Map;
+import java.util.Locale;
/**
* Represents a portal node, a first class entity for the portal.
@@ -75,6 +76,13 @@
String getName();
/**
+ * Returns the best display name for specified locale.
+ *
+ * @return the display name
+ */
+ String getDisplayName(Locale locale);
+
+ /**
* Return a child of this object.
*
* @param name the child name
Added: trunk/api/src/main/org/jboss/portal/api/node/PortalNodeURLFactory.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/api/node/PortalNodeURLFactory.java (rev 0)
+++ trunk/api/src/main/org/jboss/portal/api/node/PortalNodeURLFactory.java 2007-04-25 12:36:23 UTC (rev 7041)
@@ -0,0 +1,36 @@
+/******************************************************************************
+ * 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;
+
+}
Deleted: trunk/common/src/main/org/jboss/portal/common/http/HttpServletRequestWrapper.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/http/HttpServletRequestWrapper.java 2007-04-25 12:15:13 UTC (rev 7040)
+++ trunk/common/src/main/org/jboss/portal/common/http/HttpServletRequestWrapper.java 2007-04-25 12:36:23 UTC (rev 7041)
@@ -1,70 +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.common.http;
-
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * Wrapper around a HTTPServletRequest to add attributes without
- * affecting the actual request
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision: 1.1 $
- */
-public class HttpServletRequestWrapper extends
- javax.servlet.http.HttpServletRequestWrapper
-{
-
- private Map attributes;
-
-
- public HttpServletRequestWrapper(HttpServletRequest servletRequest)
- {
- super(servletRequest);
- attributes = new HashMap();
- }
-
- public void setAttribute(String name, Object value)
- {
- attributes.put(name, value);
- }
-
- public Object getAttribute(String name)
- {
- Object value = attributes.get(name);
- if (value == null)
- {
- value = getRequest().getAttribute(name);
- }
- return value;
- }
-
- public Enumeration getAttributeNames()
- {
- throw new UnsupportedOperationException();
- }
-
-}
Deleted: trunk/common/src/main/org/jboss/portal/common/http/HttpServletResponseWriter.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/http/HttpServletResponseWriter.java 2007-04-25 12:15:13 UTC (rev 7040)
+++ trunk/common/src/main/org/jboss/portal/common/http/HttpServletResponseWriter.java 2007-04-25 12:36:23 UTC (rev 7041)
@@ -1,286 +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.common.http;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.util.Locale;
-
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * Redirection of the Writer
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision: 1.1 $
- */
-public class HttpServletResponseWriter implements HttpServletResponse
-{
-
- static class MockServletOutputStream extends ServletOutputStream
- {
- private ByteArrayOutputStream buffer;
-
- private String encoding;
-
- public MockServletOutputStream(int size, String encoding)
- {
- buffer = new ByteArrayOutputStream(size);
- this.encoding = encoding;
- }
-
- public void setEncoding(String encoding)
- {
- this.encoding = encoding;
- }
-
- public void write(int value) throws IOException
- {
- buffer.write(value);
- }
-
- public String getContent() throws IOException
- {
- try {
- buffer.flush();
- return buffer.toString(encoding);
- } catch (IOException e) {
- throw e;
- }
- }
-
- public byte[] getBinaryContent() throws IOException
- {
- try {
- buffer.flush();
- return buffer.toByteArray();
- } catch (IOException e) {
- throw e;
- }
- }
-
- public void clearContent()
- {
- buffer = new ByteArrayOutputStream();
- }
-
- public String toString()
- {
- try {
- return getContent();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return super.toString();
- }
- }
-
- private ServletOutputStream outputStream;
- private PrintWriter writer;
- private String characterEncoding;
- private int bufferSize;
-
- public HttpServletResponseWriter(HttpServletResponse response)
- {
- this.characterEncoding = response.getCharacterEncoding();
- this.outputStream = new MockServletOutputStream(bufferSize, this.characterEncoding);
- this.bufferSize = response.getBufferSize();
- }
-
- public String getContent()
- {
- try {
- return ((MockServletOutputStream)outputStream).getContent();
- } catch (IOException e) {
- return "test";
- }
- }
-
- public void addCookie(Cookie arg0)
- {
- throw new UnsupportedOperationException();
- }
-
- public void addDateHeader(String arg0, long arg1)
- {
- throw new UnsupportedOperationException();
- }
-
- public void addHeader(String arg0, String arg1)
- {
- throw new UnsupportedOperationException();
- }
-
- public void addIntHeader(String arg0, int arg1)
- {
- throw new UnsupportedOperationException();
- }
-
- public boolean containsHeader(String arg0)
- {
- throw new UnsupportedOperationException();
- }
-
- public String encodeRedirectURL(String arg0)
- {
- throw new UnsupportedOperationException();
- }
-
- public String encodeRedirectUrl(String arg0)
- {
- throw new UnsupportedOperationException();
- }
-
- public String encodeURL(String arg0)
- {
- throw new UnsupportedOperationException();
- }
-
- public String encodeUrl(String arg0)
- {
- throw new UnsupportedOperationException();
- }
-
- public void sendError(int arg0) throws IOException
- {
- throw new UnsupportedOperationException();
- }
-
- public void sendError(int arg0, String arg1) throws IOException
- {
- throw new UnsupportedOperationException();
- }
-
- public void sendRedirect(String arg0) throws IOException
- {
- throw new UnsupportedOperationException();
- }
-
- public void setDateHeader(String arg0, long arg1)
- {
- throw new UnsupportedOperationException();
- }
-
- public void setHeader(String arg0, String arg1)
- {
- throw new UnsupportedOperationException();
- }
-
- public void setIntHeader(String arg0, int arg1)
- {
- throw new UnsupportedOperationException();
- }
-
- public void setStatus(int arg0)
- {
- throw new UnsupportedOperationException();
- }
-
- public void setStatus(int arg0, String arg1)
- {
- throw new UnsupportedOperationException();
- }
-
- public void flushBuffer() throws IOException
- {
- throw new UnsupportedOperationException();
- }
-
- public int getBufferSize()
- {
- return bufferSize;
- }
-
- public String getCharacterEncoding()
- {
- return characterEncoding;
- }
-
- public String getContentType()
- {
- throw new UnsupportedOperationException();
- }
-
- public Locale getLocale()
- {
- throw new UnsupportedOperationException();
- }
-
- public ServletOutputStream getOutputStream() throws IOException
- {
- return outputStream;
- }
-
- public PrintWriter getWriter() throws IOException
- {
- if (writer == null)
- {
- writer = new PrintWriter(new OutputStreamWriter(outputStream, characterEncoding), true);
- }
- return writer;
- }
-
- public boolean isCommitted()
- {
- throw new UnsupportedOperationException();
- }
-
- public void reset()
- {
- throw new UnsupportedOperationException();
- }
-
- public void resetBuffer()
- {
- throw new UnsupportedOperationException();
- }
-
- public void setBufferSize(int bufferSize)
- {
- this.bufferSize = bufferSize;
- }
-
- public void setCharacterEncoding(String characterEncoding)
- {
- this.characterEncoding = characterEncoding;
- }
-
- public void setContentLength(int arg0)
- {
- throw new UnsupportedOperationException();
- }
-
- public void setContentType(String arg0)
- {
- throw new UnsupportedOperationException();
- }
-
- public void setLocale(Locale arg0)
- {
- throw new UnsupportedOperationException();
- }
-
-}
Added: trunk/common/src/main/org/jboss/portal/common/servlet/BufferingRequestWrapper.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/servlet/BufferingRequestWrapper.java (rev 0)
+++ trunk/common/src/main/org/jboss/portal/common/servlet/BufferingRequestWrapper.java 2007-04-25 12:36:23 UTC (rev 7041)
@@ -0,0 +1,153 @@
+/******************************************************************************
+ * 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.common.servlet;
+
+import org.jboss.portal.common.util.Tools;
+
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Locale;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+
+/**
+ * Wrapper around a HTTPServletRequest to add attributes without
+ * affecting the actual request.
+ *
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.1 $
+ */
+public class BufferingRequestWrapper extends HttpServletRequestWrapper
+{
+
+ /** . */
+ private static final Object REMOVED_ATTRIBUTE = new Object();
+
+ /** . */
+ private Map attributes;
+
+ /** . */
+ private Locale[] locales;
+
+ /** . */
+ private String contextPath;
+
+ public BufferingRequestWrapper(HttpServletRequest servletRequest, String contextPath, Locale[] locales)
+ {
+ super(servletRequest);
+
+ //
+ this.contextPath = contextPath;
+ this.locales = locales;
+ this.attributes = new HashMap();
+ }
+
+ public String getContextPath()
+ {
+ return contextPath;
+ }
+
+ public Locale getLocale()
+ {
+ return locales.length > 0 ? locales[0] : null;
+ }
+
+ public Enumeration getLocales()
+ {
+ return Tools.toEnumeration(locales);
+ }
+
+ public String getMethod()
+ {
+ return "GET";
+ }
+
+ public void setAttribute(String name, Object value)
+ {
+ if (value == null)
+ {
+ value = REMOVED_ATTRIBUTE;
+ }
+
+ //
+ attributes.put(name, value);
+ }
+
+ public Object getAttribute(String name)
+ {
+ Object value = attributes.get(name);
+
+ //
+ if (value == REMOVED_ATTRIBUTE)
+ {
+ value = null;
+ }
+ else if (value == null)
+ {
+ value = getRequest().getAttribute(name);
+ }
+
+ //
+ return value;
+ }
+
+ public void removeAttribute(String name)
+ {
+ setAttribute(name, null);
+ }
+
+ public Enumeration getAttributeNames()
+ {
+ Set names = new HashSet();
+
+ //
+ for (Enumeration e = getRequest().getAttributeNames();e.hasMoreElements();)
+ {
+ names.add(e.nextElement());
+ }
+
+ //
+ for (Iterator i = attributes.entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ String name = (String)entry.getKey();
+ Object value = entry.getValue();
+ if (value == REMOVED_ATTRIBUTE)
+ {
+ names.remove(name);
+ }
+ else
+ {
+ names.add(name);
+ }
+ }
+
+ //
+ return Tools.toEnumeration(names.iterator());
+ }
+}
Added: trunk/common/src/main/org/jboss/portal/common/servlet/BufferingResponseWrapper.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/servlet/BufferingResponseWrapper.java (rev 0)
+++ trunk/common/src/main/org/jboss/portal/common/servlet/BufferingResponseWrapper.java 2007-04-25 12:36:23 UTC (rev 7041)
@@ -0,0 +1,225 @@
+/******************************************************************************
+ * 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.common.servlet;
+
+import org.jboss.portal.common.io.UndeclaredIOException;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Locale;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
+
+/**
+ * Redirection of the Writer
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.1 $
+ */
+public class BufferingResponseWrapper extends HttpServletResponseWrapper
+{
+
+ /** . */
+ private ServletOutputStreamBuffer outputStream;
+
+ /** . */
+ private PrintWriter writer;
+
+ /** . */
+ private StringWriter chars;
+
+ /** . */
+ private String characterEncoding;
+
+ /** Not really used but we need it to memorize what the client set optionally. */
+ protected int bufferSize;
+
+ public BufferingResponseWrapper(HttpServletResponse response)
+ {
+ super(response);
+
+ // By default inherit the character encoding of the wrapped response
+ this.characterEncoding = response.getCharacterEncoding();
+
+ // 0 means no buffering - we say no buffering
+ this.bufferSize = 0;
+ }
+
+ public String getContent()
+ {
+ if (outputStream != null)
+ {
+ try
+ {
+ outputStream.flush();
+ return outputStream.getContent(characterEncoding);
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ }
+ else if (chars != null)
+ {
+ writer.flush();
+ return chars.toString();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void addCookie(Cookie arg0)
+ {
+ }
+
+ public void addDateHeader(String arg0, long arg1)
+ {
+ }
+
+ public void addHeader(String arg0, String arg1)
+ {
+ }
+
+ public void addIntHeader(String arg0, int arg1)
+ {
+ }
+
+ public void sendError(int arg0) throws IOException
+ {
+ }
+
+ public void sendError(int arg0, String arg1) throws IOException
+ {
+ }
+
+ public void sendRedirect(String arg0) throws IOException
+ {
+ }
+
+ public void setDateHeader(String arg0, long arg1)
+ {
+ }
+
+ public void setHeader(String arg0, String arg1)
+ {
+ }
+
+ public void setIntHeader(String arg0, int arg1)
+ {
+ }
+
+ public void setStatus(int arg0)
+ {
+ }
+
+ public void setStatus(int arg0, String arg1)
+ {
+ }
+
+ public int getBufferSize()
+ {
+ return bufferSize;
+ }
+
+ public String getCharacterEncoding()
+ {
+ return characterEncoding;
+ }
+
+ public ServletOutputStream getOutputStream() throws IOException
+ {
+ if (writer != null)
+ {
+ throw new IllegalStateException("Already obtained a PrintWriter");
+ }
+ if (outputStream == null)
+ {
+ outputStream = new ServletOutputStreamBuffer(500);
+ }
+ return outputStream;
+ }
+
+ public PrintWriter getWriter() throws IOException
+ {
+ if (outputStream != null)
+ {
+ throw new IllegalStateException("Already obtained a ServletOutputStream");
+ }
+ if (writer == null)
+ {
+ chars = new StringWriter();
+ writer = new PrintWriter(chars, false);
+ }
+ return writer;
+ }
+
+ public boolean isCommitted()
+ {
+ return false;
+ }
+
+ public void reset()
+ {
+ resetBuffer();
+ }
+
+ public void resetBuffer()
+ {
+ if (outputStream != null)
+ {
+ outputStream.reset();
+ }
+ else if (chars != null)
+ {
+ writer.flush();
+ chars.getBuffer().setLength(0);
+ }
+ }
+
+ public void setBufferSize(int bufferSize)
+ {
+ this.bufferSize = bufferSize;
+ }
+
+ public void setCharacterEncoding(String characterEncoding)
+ {
+ this.characterEncoding = characterEncoding;
+ }
+
+ public void setContentLength(int arg0)
+ {
+ }
+
+ public void setContentType(String arg0)
+ {
+ }
+
+ public void setLocale(Locale arg0)
+ {
+ }
+}
Added: trunk/common/src/main/org/jboss/portal/common/servlet/ServletOutputStreamBuffer.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/servlet/ServletOutputStreamBuffer.java (rev 0)
+++ trunk/common/src/main/org/jboss/portal/common/servlet/ServletOutputStreamBuffer.java 2007-04-25 12:36:23 UTC (rev 7041)
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * 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.common.servlet;
+
+import javax.servlet.ServletOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ServletOutputStreamBuffer extends ServletOutputStream
+{
+
+ /** . */
+ private ByteArrayOutputStream buffer;
+
+ public ServletOutputStreamBuffer(int size)
+ {
+ buffer = new ByteArrayOutputStream(size);
+ }
+
+ public void write(int value) throws IOException
+ {
+ buffer.write(value);
+ }
+
+ public String getContent(String encoding) throws IOException
+ {
+ buffer.flush();
+
+ //
+ return buffer.toString(encoding);
+ }
+
+ public byte[] getBinaryContent() throws IOException
+ {
+ buffer.flush();
+
+ //
+ return buffer.toByteArray();
+ }
+
+ public void reset()
+ {
+ buffer.reset();
+ }
+}
Modified: trunk/common/src/main/org/jboss/portal/common/util/Tools.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/Tools.java 2007-04-25 12:15:13 UTC (rev 7040)
+++ trunk/common/src/main/org/jboss/portal/common/util/Tools.java 2007-04-25 12:36:23 UTC (rev 7041)
@@ -404,6 +404,31 @@
};
}
+ public static Enumeration toEnumeration(final Object[] objects)
+ {
+ return new Enumeration()
+ {
+ int index = 0;
+
+ public boolean hasMoreElements()
+ {
+ return index < objects.length;
+ }
+
+ public Object nextElement()
+ {
+ if (index < objects.length)
+ {
+ return objects[index++];
+ }
+ else
+ {
+ throw new NoSuchElementException();
+ }
+ }
+ };
+ }
+
public static Enumeration toEnumeration(final Object o)
{
return new Enumeration()
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:15:13 UTC (rev 7040)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-04-25 12:36:23 UTC (rev 7041)
@@ -23,51 +23,38 @@
package org.jboss.portal.core.aspects.controller;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
-import java.util.Comparator;
import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
-import org.jboss.portal.api.node.PortalNode;
-import org.jboss.portal.common.http.HttpServletRequestWrapper;
-import org.jboss.portal.common.http.HttpServletResponseWriter;
+import org.jboss.portal.common.servlet.BufferingRequestWrapper;
+import org.jboss.portal.common.servlet.BufferingResponseWrapper;
import org.jboss.portal.core.controller.Controller;
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.ControllerInterceptor;
import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.controller.command.SignOutCommand;
-import org.jboss.portal.core.impl.model.portal.PortalObjectImpl;
import org.jboss.portal.core.model.CustomizationManager;
import org.jboss.portal.core.model.instance.command.action.InvokePortletInstanceRenderCommand;
import org.jboss.portal.core.model.portal.Page;
import org.jboss.portal.core.model.portal.Portal;
-import org.jboss.portal.core.model.portal.PortalContainer;
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.model.portal.Window;
import org.jboss.portal.core.model.portal.command.action.ImportPageToDashboardCommand;
import org.jboss.portal.core.model.portal.command.render.RenderPageCommand;
import org.jboss.portal.core.model.portal.command.view.ViewDashboardCommand;
import org.jboss.portal.core.model.portal.command.view.ViewPageCommand;
import org.jboss.portal.core.theme.PageRendition;
+import org.jboss.portal.core.aspects.controller.node.Navigation;
import org.jboss.portal.identity.User;
import org.jboss.portal.portlet.PortletParametersStateString;
import org.jboss.portal.security.PortalSecurityException;
@@ -95,20 +82,17 @@
private static final DynaRenderOptions NO_AJAX_OPTIONS = DynaRenderOptions.getOptions(Boolean.FALSE, Boolean.FALSE);
/** . */
- private static final String RESOURCE_PREFIX = "PAGENAME_";
+ private String targetContextPath;
- private String JSPContext;
+ /** . */
+ private String headerPath;
- private String headerJSP;
+ /** . */
+ private String tabsPath;
- private String tabsJSP;
-
/** . */
private PortalAuthorizationManagerFactory portalAuthorizationManagerFactory;
- /** Tab order. */
- private static final String ORDER = "order";
-
public PortalAuthorizationManagerFactory getPortalAuthorizationManagerFactory()
{
return portalAuthorizationManagerFactory;
@@ -133,14 +117,14 @@
RenderPageCommand rpc = (RenderPageCommand)cmd;
//
- StringBuffer tabbedNav = injectTabbedNav(rpc);
+ String tabbedNav = injectTabbedNav(rpc);
if (tabbedNav != null)
{
Map windowProps = new HashMap();
windowProps.put(ThemeConstants.PORTAL_PROP_WINDOW_RENDERER, "emptyRenderer");
windowProps.put(ThemeConstants.PORTAL_PROP_DECORATION_RENDERER, "emptyRenderer");
windowProps.put(ThemeConstants.PORTAL_PROP_PORTLET_RENDERER, "emptyRenderer");
- WindowResult res = new WindowResult("", tabbedNav.toString(), Collections.EMPTY_MAP, windowProps, null, WindowState.NORMAL, Mode.VIEW);
+ WindowResult res = new WindowResult("", tabbedNav, Collections.EMPTY_MAP, windowProps, null, WindowState.NORMAL, Mode.VIEW);
WindowContext blah = new WindowContext("BLAH", "navigation", 0, res);
rendition.getPageResult().addWindowContext(blah);
@@ -151,14 +135,14 @@
}
//
- StringBuffer dashboardNav = injectDashboardNav(cmd);
+ String dashboardNav = injectDashboardNav(cmd);
if (dashboardNav != null)
{
Map windowProps = new HashMap();
windowProps.put(ThemeConstants.PORTAL_PROP_WINDOW_RENDERER, "emptyRenderer");
windowProps.put(ThemeConstants.PORTAL_PROP_DECORATION_RENDERER, "emptyRenderer");
windowProps.put(ThemeConstants.PORTAL_PROP_PORTLET_RENDERER, "emptyRenderer");
- WindowResult res = new WindowResult("", dashboardNav.toString(), Collections.EMPTY_MAP, windowProps, null, WindowState.NORMAL, Mode.VIEW);
+ WindowResult res = new WindowResult("", dashboardNav, Collections.EMPTY_MAP, windowProps, null, WindowState.NORMAL, Mode.VIEW);
WindowContext bluh = new WindowContext("BLUH", "dashboardnav", 0, res);
rendition.getPageResult().addWindowContext(bluh);
@@ -172,378 +156,205 @@
return resp;
}
- public StringBuffer injectDashboardNav(ControllerCommand cc)
+ public String injectDashboardNav(ControllerCommand cc)
{
StringBuffer sb = new StringBuffer();
ControllerContext controllerCtx = cc.getControllerContext();
-
ServerInvocationContext serverContext = controllerCtx.getServerInvocation().getServerContext();
- ServletContext servletContext = serverContext.getClientRequest().getSession().getServletContext().getContext(JSPContext);
-
- RequestDispatcher rd = servletContext.getRequestDispatcher(headerJSP);
-
- HttpServletResponse response = new HttpServletResponseWriter(serverContext.getClientResponse());
- HttpServletRequest request = new HttpServletRequestWrapper(serverContext.getClientRequest());
-
- // Get user
- Controller controller = controllerCtx.getController();
- User user = controllerCtx.getUser();
- request.setAttribute("org.jboss.portal.header.user", user);
-
- // Edit dashboard page || Copy to dashboard link
- boolean isDashboard = false;
- if (cc instanceof RenderPageCommand)
+ ServletContext servletContext = serverContext.getClientRequest().getSession().getServletContext().getContext(targetContextPath);
+ RequestDispatcher rd = servletContext.getRequestDispatcher(headerPath);
+
+ //
+ if (rd != null)
{
- RenderPageCommand rpc = (RenderPageCommand)cc;
- Page page = rpc.getPage();
- String pageName = page.getName();
- isDashboard = rpc.isDashboard();
- //
- if (isDashboard)
+ BufferingResponseWrapper response = new BufferingResponseWrapper(serverContext.getClientResponse());
+ BufferingRequestWrapper request = new BufferingRequestWrapper(
+ serverContext.getClientRequest(),
+ targetContextPath,
+ cc.getControllerContext().getServerInvocation().getRequest().getLocales());
+
+ // Get user
+ Controller controller = controllerCtx.getController();
+ User user = controllerCtx.getUser();
+ request.setAttribute("org.jboss.portal.header.USER", user);
+
+ // Edit dashboard page || Copy to dashboard link
+ boolean isDashboard = false;
+ if (cc instanceof RenderPageCommand)
{
- // Edit page
- PortletParametersStateString navState = new PortletParametersStateString();
- navState.setValue("editPageSelect", pageName);
- InvokePortletInstanceRenderCommand command = new InvokePortletInstanceRenderCommand("DashboardConfigPortletInstance", navState);
- request.setAttribute("org.jboss.portal.header.editDashboardURL", controllerCtx.renderURL(command, null, null));
- }
- else
- {
+ RenderPageCommand rpc = (RenderPageCommand)cc;
+ Page page = rpc.getPage();
+ String pageName = page.getName();
+ isDashboard = rpc.isDashboard();
+
//
- if (user != null)
+ if (isDashboard)
{
- CustomizationManager cm = controller.getCustomizationManager();
- Portal dashboard = cm.getDashboard(user);
- if (dashboard.getChild(pageName) == null)
+ // Edit page
+ PortletParametersStateString navState = new PortletParametersStateString();
+ navState.setValue("editPageSelect", pageName);
+ InvokePortletInstanceRenderCommand command = new InvokePortletInstanceRenderCommand("DashboardConfigPortletInstance", navState);
+ request.setAttribute("org.jboss.portal.header.EDIT_DASDHBOARD_URL", controllerCtx.renderURL(command, null, null));
+ }
+ else
+ {
+ //
+ if (user != null)
{
- ImportPageToDashboardCommand iptdc = new ImportPageToDashboardCommand(page.getId());
- request.setAttribute("org.jboss.portal.header.copyToDashboardURL", controllerCtx.renderURL(iptdc, null, null));
+ CustomizationManager cm = controller.getCustomizationManager();
+ Portal dashboard = cm.getDashboard(user);
+ if (dashboard.getChild(pageName) == null)
+ {
+ ImportPageToDashboardCommand iptdc = new ImportPageToDashboardCommand(page.getId());
+ request.setAttribute("org.jboss.portal.header.COPY_TO_DASHBOARD_URL", controllerCtx.renderURL(iptdc, null, null));
+ }
}
+
}
-
}
- }
- if (! isDashboard)
- {
- ViewDashboardCommand vdc = new ViewDashboardCommand();
- request.setAttribute("org.jboss.portal.header.dashboardURL", controllerCtx.renderURL(vdc, null, null));
- }
-
- boolean admin = false;
- if (cc instanceof RenderPageCommand)
- {
- RenderPageCommand rpc = (RenderPageCommand)cc;
- PortalObject portalObject = rpc.getPage().getPortal();
- admin = "admin".equalsIgnoreCase(portalObject.getName());
- }
-
- if (!admin || isDashboard)
- {
- PortalObjectPermission perm = new PortalObjectPermission(new PortalObjectId(new String[]{"admin"}), PortalObjectPermission.VIEW_MASK);
- try
+ //
+ if (! isDashboard)
{
- if (controller.getPortalAuthorizationManagerFactory().getManager().checkPermission(perm))
- {
- ViewPageCommand showadmin = new ViewPageCommand(new PortalObjectId(new String[]{"admin"}));
- request.setAttribute("org.jboss.portal.header.adminPortalURL", controllerCtx.renderURL(showadmin, null, null));
- }
+ ViewDashboardCommand vdc = new ViewDashboardCommand();
+ request.setAttribute("org.jboss.portal.header.DASHBOARD_URL", controllerCtx.renderURL(vdc, null, null));
}
- catch (PortalSecurityException e)
- {
- log.error("", e);
- }
- }
-
- if (admin || isDashboard)
- {
- // Link to default page of default portal
- ViewPageCommand _rpc = new ViewPageCommand(new PortalObjectId(new String[]{"default", "default"}));
- request.setAttribute("org.jboss.portal.header.defaultPortalURL", controllerCtx.renderURL(_rpc, null, null));
- }
-
- SignOutCommand cmd = new SignOutCommand();
- URLContext urlContext = controllerCtx.getServerInvocation().getServerContext().getURLContext();
- String logoutURL = controllerCtx.renderURL(cmd, urlContext.asNonAuthenticated(), null);
- request.setAttribute("org.jboss.portal.header.signOutURL", logoutURL);
-
- try
- {
- rd.include(request, response);
- response.getWriter().flush();
- }
- catch (ServletException e1)
- {
- e1.printStackTrace();
- }
- catch (IOException e1)
- {
- e1.printStackTrace();
- }
-
- try
- {
- sb.append(response.getOutputStream().toString());
- }
- catch (IOException e1)
- {
- e1.printStackTrace();
- }
-
- return sb;
- }
-
- public StringBuffer injectTabbedNav(RenderPageCommand rpc)
- {
- StringBuffer sb = new StringBuffer();
- ControllerContext controllerCtx = rpc.getControllerContext();
-
- ServerInvocationContext serverContext = controllerCtx.getServerInvocation().getServerContext();
- ServletContext servletContext = serverContext.getClientRequest().getSession().getServletContext().getContext(JSPContext);
-
- RequestDispatcher rd = servletContext.getRequestDispatcher(tabsJSP);
-
- HttpServletResponse response = new HttpServletResponseWriter(serverContext.getClientResponse());
- HttpServletRequest request = new HttpServletRequestWrapper(serverContext.getClientRequest());
-
-
- Node root = new Node("root", null);
-
- try
- {
- Page page = rpc.getPage();
-
- // Now build the list
- List navElements = new ArrayList();
- for (Iterator iterator = page.getPortal().getChildren().iterator(); iterator.hasNext();)
+ //
+ boolean admin = false;
+ if (cc instanceof RenderPageCommand)
{
- PortalObject child = (PortalObject)iterator.next();
- if (child.getType() == PortalNode.TYPE_PAGE)
- {
- PortalObjectImpl portalObject = (PortalObjectImpl)child;
- navElements.add(portalObject);
- }
+ RenderPageCommand rpc = (RenderPageCommand)cc;
+ PortalObject portalObject = rpc.getPage().getPortal();
+ admin = "admin".equalsIgnoreCase(portalObject.getName());
}
- sortTabs(navElements);
- for (Iterator i = navElements.iterator(); i.hasNext();)
+ //
+ if (!admin || isDashboard)
{
- PortalObjectImpl navElement = (PortalObjectImpl)i.next();
-
- // build up markup for the navigation , based on these nodes
- String name = navElement.getName();
+ PortalObjectPermission perm = new PortalObjectPermission(new PortalObjectId(new String[]{"admin"}), PortalObjectPermission.VIEW_MASK);
try
{
- // localize node name
- Locale requestLocale = rpc.getControllerContext().getServerInvocation().getRequest().getLocale();
- ResourceBundle rb = ResourceBundle.getBundle("conf.bundles.Resource", requestLocale, Thread.currentThread().getContextClassLoader());
- name = rb.getString(RESOURCE_PREFIX + name);
+ if (controller.getPortalAuthorizationManagerFactory().getManager().checkPermission(perm))
+ {
+ ViewPageCommand showadmin = new ViewPageCommand(new PortalObjectId(new String[]{"admin"}));
+ request.setAttribute("org.jboss.portal.header.ADMIN_PORTAL_URL", controllerCtx.renderURL(showadmin, null, null));
+ }
}
- catch (MissingResourceException e)
+ catch (PortalSecurityException e)
{
+ log.error("", e);
}
+ }
- PortalObjectId id = navElement.getId();
+ //
+ if (admin || isDashboard)
+ {
+ // Link to default page of default portal
+ ViewPageCommand _rpc = new ViewPageCommand(new PortalObjectId(new String[]{"default", "default"}));
+ request.setAttribute("org.jboss.portal.header.DASHBOARD_URL", controllerCtx.renderURL(_rpc, null, null));
+ }
- PortalObjectPermission perm = new PortalObjectPermission(id, PortalObjectPermission.VIEW_MASK);
- if (portalAuthorizationManagerFactory.getManager().checkPermission(perm))
- {
- ViewPageCommand cmd = new ViewPageCommand(navElement.getId());
- String childURL = rpc.getControllerContext().renderURL(cmd, null, null);
- Node childNode = new Node(name, childURL);
- if (page == navElement)
- {
- childNode.current = true;
- }
-
- root.addChild(childNode);
- // if we were able to detect the selected node in the hierarchie level of the nav elements,
- // then flag the node so the css can style it as the selected one
+ //
+ SignOutCommand cmd = new SignOutCommand();
+ URLContext urlContext = controllerCtx.getServerInvocation().getServerContext().getURLContext();
+ String logoutURL = controllerCtx.renderURL(cmd, urlContext.asNonAuthenticated(), null);
+ request.setAttribute("org.jboss.portal.header.SIGN_OUT_URL", logoutURL);
- List childPages = getAuthorizedChildrenPages(navElement);
-
- // Submenu logic
- if (childPages.size() != 0)
- {
- for (Iterator j = childPages.iterator(); j.hasNext();)
- {
- PortalObject child = (PortalObject)j.next();
- if (child.getType() == PortalObject.TYPE_PAGE)
- {
- ViewPageCommand renderCmd = new ViewPageCommand(child.getId());
- String subChildURL = rpc.getControllerContext().renderURL(renderCmd, null, null);
- String childName = child.getName();
- try
- {
- // localize node name
- Locale requestLocale = rpc.getControllerContext().getServerInvocation().getRequest().getLocale();
- ResourceBundle rb = ResourceBundle.getBundle("conf.bundles.Resource", requestLocale, Thread.currentThread().getContextClassLoader());
- childName = rb.getString(RESOURCE_PREFIX + childName);
- }
- catch (MissingResourceException e)
- {
- }
- childNode.addChild(new Node(childName, subChildURL));
- }
- }
- }
- }
+ //
+ try
+ {
+ rd.include(request, response);
+ return response.getContent();
}
- }
- catch (Exception e)
- {
- log.error("", e);
- }
-
- request.setAttribute("org.jboss.portal.header.root", root);
-
- try
- {
- rd.include(request, response);
- response.getWriter().flush();
- }
- catch (ServletException e1)
- {
- e1.printStackTrace();
- }
- catch (IOException e1)
- {
- e1.printStackTrace();
- }
-
- try
- {
- sb.append(response.getOutputStream().toString());
- }
- catch (IOException e1)
- {
- e1.printStackTrace();
- }
- return sb;
- }
-
- private List getAuthorizedChildrenPages(PortalObject portalObject)
- {
- List result = new ArrayList();
- Collection children = portalObject.getChildren(PortalObject.PAGE_MASK);
-
- for (Iterator i = children.iterator(); i.hasNext();)
- {
- PortalObject child = (PortalObject)i.next();
- PortalObjectId id = child.getId();
-
- PortalObjectPermission perm = new PortalObjectPermission(id, PortalObjectPermission.VIEW_MASK);
- if (portalAuthorizationManagerFactory.getManager().checkPermission(perm))
+ catch (ServletException e1)
{
- result.add(child);
+ e1.printStackTrace();
}
- }
- return result;
- }
-
- protected void sortTabs(List navElements)
- {
- Collections.sort(navElements, new Comparator()
- {
- public int compare(Object o1, Object o2)
+ catch (IOException e1)
{
- Float high1 = new Float(getOrder(o1));
- Float high2 = new Float(getOrder(o2));
- if (high1.equals(high2))
- {
- return ((PortalObject)o1).getName()
- .compareTo(((PortalObject)o2).getName());
- }
- else
- {
- return high1.compareTo(high2);
- }
+ e1.printStackTrace();
}
- });
+ }
+
+ //
+ return null;
}
- private static float getOrder(Object o)
+ public String injectTabbedNav(RenderPageCommand rpc)
{
- if (o instanceof PortalContainer)
+ ControllerContext controllerCtx = rpc.getControllerContext();
+
+ //
+ ServerInvocationContext serverContext = controllerCtx.getServerInvocation().getServerContext();
+
+ // Get the right servlet context
+ ServletContext servletContext = serverContext.getClientRequest().getSession().getServletContext().getContext(targetContextPath);
+
+ // Get request dispatcher
+ RequestDispatcher rd = servletContext.getRequestDispatcher(tabsPath);
+
+ //
+ if (rd != null)
{
- return 0;
- }
- if (o instanceof Portal)
- {
- return 1;
- }
- if (o instanceof Page)
- {
- String orderProperty = ((Page)o).getDeclaredProperty(ORDER);
- if (orderProperty == null)
+ // Wrap request and response safely
+ BufferingResponseWrapper response = new BufferingResponseWrapper(serverContext.getClientResponse());
+ BufferingRequestWrapper request = new BufferingRequestWrapper(
+ serverContext.getClientRequest(),
+ targetContextPath,
+ rpc.getControllerContext().getServerInvocation().getRequest().getLocales());
+
+ //
+ request.setAttribute("org.jboss.portal.api.PORTAL_NODE", Navigation.getCurrentNode());
+ request.setAttribute("org.jboss.portal.api.PORTAL_NODE_URL_FACTORY", Navigation.getFactory());
+
+ //
+ try
{
- return 2.999f;
+ rd.include(request, response);
+ return response.getContent();
}
- try
+ catch (ServletException e)
{
- return Float.parseFloat("2." + orderProperty);
+ e.printStackTrace();
}
- catch (NumberFormatException e)
+ catch (IOException e)
{
- return 2.999f;
+ e.printStackTrace();
}
}
- if (o instanceof Window)
- {
- return 3;
- }
- return 4;
+
+ //
+ return null;
}
-
- public class Node
- {
- public String name;
- public List children;
- public String url;
- public boolean current;
-
- public Node(String name, String url)
- {
- this.name = name;
- this.url = url;
- this.children = new ArrayList();
- this.current = false;
- }
-
- public void addChild(Node node)
- {
- children.add(node);
- }
- }
- public String getHeaderJSP()
+ public String getHeaderPath()
{
- return headerJSP;
+ return headerPath;
}
- public void setHeaderJSP(String headerJSP)
+ public void setHeaderPath(String headerPath)
{
- this.headerJSP = headerJSP;
+ this.headerPath = headerPath;
}
- public String getJSPContext()
+ public String getTargetContextPath()
{
- return JSPContext;
+ return targetContextPath;
}
- public void setJSPContext(String context)
+ public void setTargetContextPath(String context)
{
- JSPContext = context;
+ targetContextPath = context;
}
- public String getTabsJSP()
+ public String getTabsPath()
{
- return tabsJSP;
+ return tabsPath;
}
- public void setTabsJSP(String tabsJSP)
+ public void setTabsPath(String tabsPath)
{
- this.tabsJSP = tabsJSP;
+ this.tabsPath = tabsPath;
}
}
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:15:13 UTC (rev 7040)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/Navigation.java 2007-04-25 12:36:23 UTC (rev 7041)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.core.aspects.controller.node;
+import org.jboss.portal.api.node.PortalNodeURLFactory;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 3201 $
@@ -29,20 +31,34 @@
public class Navigation
{
- /** Enforce singleton. */
- private Navigation()
- {
- }
-
+ /** . */
private static final ThreadLocal currentNodeLocal = new ThreadLocal();
+ /** . */
+ private static final ThreadLocal factoryLocal = new ThreadLocal();
+
public static PortalObjectNode getCurrentNode()
{
return (PortalObjectNode)currentNodeLocal.get();
}
- public static void setCurrentNode(PortalObjectNode currentNode)
+ static void setCurrentNode(PortalObjectNode currentNode)
{
currentNodeLocal.set(currentNode);
}
+
+ public static PortalNodeURLFactory getFactory()
+ {
+ return (PortalNodeURLFactory)factoryLocal.get();
+ }
+
+ static void setFactory(PortalNodeURLFactory factory)
+ {
+ factoryLocal.set(factory);
+ }
+
+ /** Enforce singleton. */
+ private Navigation()
+ {
+ }
}
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:15:13 UTC (rev 7040)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeInterceptor.java 2007-04-25 12:36:23 UTC (rev 7041)
@@ -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.security.spi.auth.PortalAuthorizationManagerFactory;
+import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -38,6 +40,19 @@
public class PortalNodeInterceptor extends ControllerInterceptor
{
+ /** . */
+ private PortalAuthorizationManagerFactory portalAuthorizationManagerFactory;
+
+ public PortalAuthorizationManagerFactory getPortalAuthorizationManagerFactory()
+ {
+ return portalAuthorizationManagerFactory;
+ }
+
+ public void setPortalAuthorizationManagerFactory(PortalAuthorizationManagerFactory portalAuthorizationManagerFactory)
+ {
+ this.portalAuthorizationManagerFactory = portalAuthorizationManagerFactory;
+ }
+
public ControllerResponse invoke(ControllerCommand cmd) throws Exception, InvocationException
{
// Get the next node
@@ -46,11 +61,20 @@
// Save previous node temporarily
PortalObjectNode previous = Navigation.getCurrentNode();
+ // Whether or not we inherit from an existing factory
+ boolean noFactory = Navigation.getFactory() == null;
+
try
{
// Set next node
Navigation.setCurrentNode(next);
+ //
+ if (noFactory)
+ {
+ Navigation.setFactory(new PortalNodeURLFactoryImpl(cmd.getControllerContext()));
+ }
+
// Invoke
return (ControllerResponse)cmd.invokeNext();
}
@@ -58,24 +82,35 @@
{
// Set previous node back
Navigation.setCurrentNode(previous);
+
+ //
+ if (noFactory)
+ {
+ Navigation.setFactory(null);
+ }
}
}
private PortalObjectNode getNode(ControllerCommand cmd)
{
+ PortalAuthorizationManager pam = portalAuthorizationManagerFactory.getManager();
PortalObjectNode next = null;
+
+ //
if (cmd instanceof WindowCommand)
{
WindowCommand windowCmd = (WindowCommand)cmd;
Window window = windowCmd.getWindow();
- next = new PortalObjectNode(window);
+ next = new PortalObjectNode(pam, window);
}
else if (cmd instanceof RenderPageCommand)
{
RenderPageCommand rpCmd = (RenderPageCommand)cmd;
Page page = rpCmd.getPage();
- next = new PortalObjectNode(page);
+ next = new PortalObjectNode(pam, page);
}
+
+ //
return next;
}
}
Deleted: trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeURLFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeURLFactory.java 2007-04-25 12:15:13 UTC (rev 7040)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeURLFactory.java 2007-04-25 12:36:23 UTC (rev 7041)
@@ -1,154 +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.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
-{
-
- public static PortalNodeURL createActionURL(PortalObjectNode node, ControllerContext controllerContext)
- {
- switch (node.getType())
- {
- case PortalNode.TYPE_WINDOW:
- return null;
- case PortalNode.TYPE_CONTEXT:
- case PortalNode.TYPE_PAGE:
- case PortalNode.TYPE_PORTAL:
- default:
- throw new IllegalArgumentException("This kind of node does not support action url " + node);
- }
- }
-
- public static PortalNodeURL createRenderURL(PortalObjectNode node, ControllerContext controllerContext)
- {
- switch (node.getType())
- {
- case PortalNode.TYPE_WINDOW:
- return new WindowURL(node.getObjectId(), controllerContext);
- case PortalNode.TYPE_PAGE:
- return new PageURL(node.getObjectId(), controllerContext);
- case PortalNode.TYPE_PORTAL:
- return null;
- 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/aspects/controller/node/PortalNodeURLFactoryImpl.java (from rev 7039, trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeURLFactory.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeURLFactoryImpl.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeURLFactoryImpl.java 2007-04-25 12:36:23 UTC (rev 7041)
@@ -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.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));
+ }
+ }
+}
Modified: 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:15:13 UTC (rev 7040)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalObjectNode.java 2007-04-25 12:36:23 UTC (rev 7041)
@@ -27,16 +27,26 @@
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>
@@ -45,55 +55,78 @@
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 map. */
- private Map childrenNodes;
+ /** 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(PortalObject object) throws IllegalArgumentException
+ 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
*/
- private PortalObjectNode(PortalObjectNode parentNode, PortalObject 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;
-
- //
- Map childrenNodes = getChildrenNodes();
- childrenNodes.put(childNode.getName(), childNode);
- this.childrenNodes = Collections.unmodifiableMap(childrenNodes);
+ this.children = new Siblings(childNode);
}
public int getType()
@@ -136,22 +169,46 @@
return object.getName();
}
- public PortalNode getChild(String name)
+ public String getDisplayName(Locale locale)
{
- if (childrenNodes == null)
+ // Lazyly compute the display name
+ if (displayNameKey == null)
{
- childrenNodes = Collections.unmodifiableMap(getChildrenNodes());
+ displayNameKey = RESOURCE_PREFIX + object.getName();
}
- return (PortalNode)childrenNodes.get(name);
+
+ // 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()
{
- if (childrenNodes == null)
- {
- childrenNodes = Collections.unmodifiableMap(getChildrenNodes());
- }
- return childrenNodes.values();
+ return children.getList();
}
public PortalNode resolve(String relativePath)
@@ -195,23 +252,6 @@
return bubbler.dispatch();
}
- private Map getChildrenNodes()
- {
- Map childrenMap = Collections.EMPTY_MAP;
- Collection tmp = object.getChildren();
- if (tmp.isEmpty() == false)
- {
- childrenMap = new HashMap();
- for (Iterator i = tmp.iterator(); i.hasNext();)
- {
- PortalObject childObject = (PortalObject)i.next();
- PortalObjectNode child = new PortalObjectNode(this, childObject);
- childrenMap.put(child.getName(), child);
- }
- }
- return childrenMap;
- }
-
private static class Bubbler implements PortalNodeEventContext
{
@@ -297,4 +337,175 @@
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/portlet/JBossActionResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portlet/JBossActionResponse.java 2007-04-25 12:15:13 UTC (rev 7040)
+++ trunk/core/src/main/org/jboss/portlet/JBossActionResponse.java 2007-04-25 12:36:23 UTC (rev 7041)
@@ -24,15 +24,14 @@
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.PortalNodeURLFactory;
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.core.controller.ControllerContext;
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.portlet.invocation.PortletInvocation;
import javax.portlet.PortletRequest;
@@ -43,15 +42,9 @@
public class JBossActionResponse extends ActionResponseImpl
{
- /** . */
- private ControllerContext controllerContext;
-
public JBossActionResponse(ActionInvocation invocation, PortletRequestImpl preq)
{
super(invocation, preq);
-
- //
- this.controllerContext = (ControllerContext)invocation.getAttribute(PortletInvocation.INVOCATION_SCOPE, "controller_context");
}
// /**
@@ -95,13 +88,18 @@
public PortalNodeURL createActionURL(PortalNode node) throws IllegalArgumentException, IllegalStateException
{
- if (controllerContext == null)
+ PortalNodeURLFactory factory = Navigation.getFactory();
+
+ //
+ if (factory == null)
{
throw new IllegalStateException("Not in a controller context");
}
+
+ //
if (node instanceof PortalObjectNode)
{
- return PortalNodeURLFactory.createActionURL((PortalObjectNode)node, controllerContext);
+ return factory.createURL(node);
}
else
{
@@ -111,13 +109,18 @@
public PortalNodeURL createRenderURL(PortalNode node) throws IllegalArgumentException, IllegalStateException
{
- if (controllerContext == null)
+ PortalNodeURLFactory factory = Navigation.getFactory();
+
+ //
+ if (factory == null)
{
throw new IllegalStateException("Not in a controller context");
}
+
+ //
if (node instanceof PortalObjectNode)
{
- return PortalNodeURLFactory.createRenderURL((PortalObjectNode)node, controllerContext);
+ return factory.createURL(node);
}
else
{
Modified: trunk/core/src/main/org/jboss/portlet/JBossRenderResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portlet/JBossRenderResponse.java 2007-04-25 12:15:13 UTC (rev 7040)
+++ trunk/core/src/main/org/jboss/portlet/JBossRenderResponse.java 2007-04-25 12:36:23 UTC (rev 7041)
@@ -24,9 +24,9 @@
import org.jboss.portal.api.node.PortalNode;
import org.jboss.portal.api.node.PortalNodeURL;
-import org.jboss.portal.core.aspects.controller.node.PortalNodeURLFactory;
+import org.jboss.portal.api.node.PortalNodeURLFactory;
import org.jboss.portal.core.aspects.controller.node.PortalObjectNode;
-import org.jboss.portal.core.controller.ControllerContext;
+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;
@@ -39,26 +39,25 @@
public class JBossRenderResponse extends RenderResponseImpl
{
- /** . */
- private ControllerContext controllerContext;
-
public JBossRenderResponse(RenderInvocation invocation, PortletRequestImpl preq)
{
super(invocation, preq);
-
- //
- this.controllerContext = (ControllerContext)invocation.getAttribute(PortletInvocation.INVOCATION_SCOPE, "controller_context");
}
public PortalNodeURL createActionURL(PortalNode node) throws IllegalArgumentException, IllegalStateException
{
- if (controllerContext == null)
+ PortalNodeURLFactory factory = Navigation.getFactory();
+
+ //
+ if (factory == null)
{
throw new IllegalStateException("Not in a controller context");
}
+
+ //
if (node instanceof PortalObjectNode)
{
- return PortalNodeURLFactory.createActionURL((PortalObjectNode)node, controllerContext);
+ return factory.createURL(node);
}
else
{
@@ -68,13 +67,18 @@
public PortalNodeURL createRenderURL(PortalNode node) throws IllegalArgumentException, IllegalStateException
{
- if (controllerContext == null)
+ PortalNodeURLFactory factory = Navigation.getFactory();
+
+ //
+ if (factory == null)
{
throw new IllegalStateException("Not in a controller context");
}
+
+ //
if (node instanceof PortalObjectNode)
{
- return PortalNodeURLFactory.createRenderURL((PortalObjectNode)node, controllerContext);
+ return factory.createURL(node);
}
else
{
@@ -87,5 +91,4 @@
{
return invocation;
}
-
}
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-25 12:15:13 UTC (rev 7040)
+++ trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-04-25 12:36:23 UTC (rev 7041)
@@ -182,6 +182,9 @@
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
+ <depends
+ optional-attribute-name="PortalAuthorizationManagerFactory"
+ proxy-type="attribute">portal:service=PortalAuthorizationManagerFactory</depends>
</mbean>
<mbean
code="org.jboss.portal.core.aspects.controller.PolicyEnforcementInterceptor"
@@ -196,9 +199,9 @@
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
- <attribute name="JSPContext">/portal-core</attribute>
- <attribute name="HeaderJSP">/WEB-INF/jsp/header/header.jsp</attribute>
- <attribute name="TabsJSP">/WEB-INF/jsp/header/tabs.jsp</attribute>
+ <attribute name="TargetContextPath">/portal-core</attribute>
+ <attribute name="HeaderPath">/WEB-INF/jsp/header/header.jsp</attribute>
+ <attribute name="TabsPath">/WEB-INF/jsp/header/tabs.jsp</attribute>
<depends
optional-attribute-name="PortalAuthorizationManagerFactory"
proxy-type="attribute">portal:service=PortalAuthorizationManagerFactory</depends>
Modified: trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/header.jsp
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/header.jsp 2007-04-25 12:15:13 UTC (rev 7040)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/header.jsp 2007-04-25 12:36:23 UTC (rev 7041)
@@ -1,13 +1,13 @@
<%@ page import="org.jboss.portal.identity.User" %>
<%
- User user = (User) request.getAttribute("org.jboss.portal.header.user");
- String dashboardURL = (String) request.getAttribute("org.jboss.portal.header.dashboardURL");
- String defaultPortalURL = (String) request.getAttribute("org.jboss.portal.header.defaultPortalURL");
- String adminPortalURL = (String) request.getAttribute("org.jboss.portal.header.adminPortalURL");
- String editDashboardURL = (String) request.getAttribute("org.jboss.portal.header.editDashboardURL");
- String copyToDashboardURL = (String) request.getAttribute("org.jboss.portal.header.copyToDashboardURL");
- String signOutURL = (String) request.getAttribute("org.jboss.portal.header.signOutURL");
+ User user = (User) request.getAttribute("org.jboss.portal.header.USER");
+ String dashboardURL = (String) request.getAttribute("org.jboss.portal.header.DASHBOARD_URL");
+ String defaultPortalURL = (String) request.getAttribute("org.jboss.portal.header.DEFAULT_PORTAL_URL");
+ String adminPortalURL = (String) request.getAttribute("org.jboss.portal.header.ADMIN_PORTAL_URL");
+ String editDashboardURL = (String) request.getAttribute("org.jboss.portal.header.EDIT_DASDHBOARD_URL");
+ String copyToDashboardURL = (String) request.getAttribute("org.jboss.portal.header.COPY_TO_DASHBOARD_URL");
+ String signOutURL = (String) request.getAttribute("org.jboss.portal.header.SIGN_OUT_URL");
%>
<%
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:15:13 UTC (rev 7040)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/tabs.jsp 2007-04-25 12:36:23 UTC (rev 7041)
@@ -1,20 +1,43 @@
-<%@ page import="org.jboss.portal.core.aspects.controller.PageCustomizerInterceptor.Node" %>
<%@ 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" %>
<%
- Node root = (Node) request.getAttribute("org.jboss.portal.header.root");
+ PortalNode root = (PortalNode)request.getAttribute("org.jboss.portal.api.PORTAL_NODE");
+ PortalNodeURLFactory factory = (PortalNodeURLFactory)request.getAttribute("org.jboss.portal.api.PORTAL_NODE_URL_FACTORY");
+
+ // Get a locale
+ Locale locale = request.getLocale();
+ if (locale == null)
+ {
+ locale = Locale.getDefault();
+ }
%>
<ul id="tabsHeader">
<%
- Iterator childrenIt = root.children.iterator();
- while (childrenIt.hasNext())
+ ArrayList tmp = new ArrayList(10);
+ Iterator siblingsIt = root.getParent().getChildren().iterator();
+ while (siblingsIt.hasNext())
{
- Node child = (Node)childrenIt.next();
+ PortalNode sibling = (PortalNode)siblingsIt.next();
+
+ // Get the list of child pages
+ tmp.clear();
+ for (Iterator i = sibling.getChildren().iterator();i.hasNext();)
+ {
+ PortalNode siblingChild = (PortalNode)i.next();
+ if (siblingChild.getType() == PortalNode.TYPE_PAGE)
+ {
+ tmp.add(siblingChild);
+ }
+ }
%>
- <li <% if(child.current) out.println(" id=\"current\""); %> onmouseover="this.className='hoverOn'" onmouseout="this.className='hoverOff'"><a href="<%= child.url %>"><%= child.name %>
+ <li <% if(sibling == root) out.println(" id=\"current\""); %> onmouseover="this.className='hoverOn'" onmouseout="this.className='hoverOff'"><a href="<%= factory.createURL(sibling) %>"><%= sibling.getDisplayName(locale) %>
<%
- if (child.children.size() == 0)
+ if (tmp.size() == 0)
{
%>
</a>
@@ -27,11 +50,11 @@
<!--[if lte IE 6]><table><tr><td><![endif]-->
<ul>
<%
- for (Iterator j = child.children.iterator(); j.hasNext();)
+ for (Iterator j = tmp.iterator(); j.hasNext();)
{
- Node subChild = (Node)j.next();
+ PortalNode siblingChild = (PortalNode)j.next();
%>
- <li><a href='<%= subChild.url %>'><%= subChild.name %></a></li>
+ <li><a href='<%= factory.createURL(siblingChild) %>'><%= siblingChild.getDisplayName(locale) %></a></li>
<%
}
%>
17 years, 2 months
JBoss Portal SVN: r7040 - docs/trunk/referenceGuide/en/modules.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-04-25 08:15:13 -0400 (Wed, 25 Apr 2007)
New Revision: 7040
Modified:
docs/trunk/referenceGuide/en/modules/navtabs.xml
Log:
Fixed typo
Modified: docs/trunk/referenceGuide/en/modules/navtabs.xml
===================================================================
--- docs/trunk/referenceGuide/en/modules/navtabs.xml 2007-04-24 13:22:26 UTC (rev 7039)
+++ docs/trunk/referenceGuide/en/modules/navtabs.xml 2007-04-25 12:15:13 UTC (rev 7040)
@@ -56,7 +56,7 @@
PAGENAME_Test=Test
PAGENAME_News=Actualités]]></programlisting>
So the mapping pattern is
- <emphasis>PAGE_NAME_[Name in *-object.xml]=[translated value]</emphasis>
+ <emphasis>PAGENAME_[Name in *-object.xml]=[translated value]</emphasis>
</para>
</sect1>
</chapter>
\ No newline at end of file
17 years, 2 months
JBoss Portal SVN: r7039 - trunk/core/src/main/org/jboss/portal/core/portlet/user.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-04-24 09:22:26 -0400 (Tue, 24 Apr 2007)
New Revision: 7039
Modified:
trunk/core/src/main/org/jboss/portal/core/portlet/user/UserPortlet.java
Log:
Default profile's language to default locale. (instead of arabic)
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/user/UserPortlet.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/user/UserPortlet.java 2007-04-24 12:59:46 UTC (rev 7038)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/user/UserPortlet.java 2007-04-24 13:22:26 UTC (rev 7039)
@@ -733,6 +733,8 @@
subscriptionMode = UserPortletConstants.SUBSCRIPTIONMODE_AUTOMATIC;
}
+ setProperty(user, User.INFO_USER_LOCALE, req.getLocale().toString());
+
if (UserPortletConstants.SUBSCRIPTIONMODE_AUTOMATIC.equals(subscriptionMode) || req.isUserInRole("Admin"))
{
setProperty(user, User.INFO_USER_ENABLED, Boolean.TRUE);
17 years, 2 months
JBoss Portal SVN: r7038 - in trunk: core/src/main/org/jboss/portal/core/aspects/controller and 3 other directories.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-04-24 08:59:46 -0400 (Tue, 24 Apr 2007)
New Revision: 7038
Added:
trunk/common/src/main/org/jboss/portal/common/http/HttpServletRequestWrapper.java
trunk/common/src/main/org/jboss/portal/common/http/HttpServletResponseWriter.java
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/header.jsp
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/tabs.jsp
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
Log:
PageCustomizerInterceptor now uses external JSPs for rendering, should help on basic customization.
Added: trunk/common/src/main/org/jboss/portal/common/http/HttpServletRequestWrapper.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/http/HttpServletRequestWrapper.java (rev 0)
+++ trunk/common/src/main/org/jboss/portal/common/http/HttpServletRequestWrapper.java 2007-04-24 12:59:46 UTC (rev 7038)
@@ -0,0 +1,70 @@
+/******************************************************************************
+ * 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.common.http;
+
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Wrapper around a HTTPServletRequest to add attributes without
+ * affecting the actual request
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.1 $
+ */
+public class HttpServletRequestWrapper extends
+ javax.servlet.http.HttpServletRequestWrapper
+{
+
+ private Map attributes;
+
+
+ public HttpServletRequestWrapper(HttpServletRequest servletRequest)
+ {
+ super(servletRequest);
+ attributes = new HashMap();
+ }
+
+ public void setAttribute(String name, Object value)
+ {
+ attributes.put(name, value);
+ }
+
+ public Object getAttribute(String name)
+ {
+ Object value = attributes.get(name);
+ if (value == null)
+ {
+ value = getRequest().getAttribute(name);
+ }
+ return value;
+ }
+
+ public Enumeration getAttributeNames()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+}
Added: trunk/common/src/main/org/jboss/portal/common/http/HttpServletResponseWriter.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/http/HttpServletResponseWriter.java (rev 0)
+++ trunk/common/src/main/org/jboss/portal/common/http/HttpServletResponseWriter.java 2007-04-24 12:59:46 UTC (rev 7038)
@@ -0,0 +1,286 @@
+/******************************************************************************
+ * 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.common.http;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.util.Locale;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Redirection of the Writer
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.1 $
+ */
+public class HttpServletResponseWriter implements HttpServletResponse
+{
+
+ static class MockServletOutputStream extends ServletOutputStream
+ {
+ private ByteArrayOutputStream buffer;
+
+ private String encoding;
+
+ public MockServletOutputStream(int size, String encoding)
+ {
+ buffer = new ByteArrayOutputStream(size);
+ this.encoding = encoding;
+ }
+
+ public void setEncoding(String encoding)
+ {
+ this.encoding = encoding;
+ }
+
+ public void write(int value) throws IOException
+ {
+ buffer.write(value);
+ }
+
+ public String getContent() throws IOException
+ {
+ try {
+ buffer.flush();
+ return buffer.toString(encoding);
+ } catch (IOException e) {
+ throw e;
+ }
+ }
+
+ public byte[] getBinaryContent() throws IOException
+ {
+ try {
+ buffer.flush();
+ return buffer.toByteArray();
+ } catch (IOException e) {
+ throw e;
+ }
+ }
+
+ public void clearContent()
+ {
+ buffer = new ByteArrayOutputStream();
+ }
+
+ public String toString()
+ {
+ try {
+ return getContent();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return super.toString();
+ }
+ }
+
+ private ServletOutputStream outputStream;
+ private PrintWriter writer;
+ private String characterEncoding;
+ private int bufferSize;
+
+ public HttpServletResponseWriter(HttpServletResponse response)
+ {
+ this.characterEncoding = response.getCharacterEncoding();
+ this.outputStream = new MockServletOutputStream(bufferSize, this.characterEncoding);
+ this.bufferSize = response.getBufferSize();
+ }
+
+ public String getContent()
+ {
+ try {
+ return ((MockServletOutputStream)outputStream).getContent();
+ } catch (IOException e) {
+ return "test";
+ }
+ }
+
+ public void addCookie(Cookie arg0)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addDateHeader(String arg0, long arg1)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addHeader(String arg0, String arg1)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addIntHeader(String arg0, int arg1)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean containsHeader(String arg0)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String encodeRedirectURL(String arg0)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String encodeRedirectUrl(String arg0)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String encodeURL(String arg0)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String encodeUrl(String arg0)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void sendError(int arg0) throws IOException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void sendError(int arg0, String arg1) throws IOException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void sendRedirect(String arg0) throws IOException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setDateHeader(String arg0, long arg1)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setHeader(String arg0, String arg1)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setIntHeader(String arg0, int arg1)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setStatus(int arg0)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setStatus(int arg0, String arg1)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void flushBuffer() throws IOException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getBufferSize()
+ {
+ return bufferSize;
+ }
+
+ public String getCharacterEncoding()
+ {
+ return characterEncoding;
+ }
+
+ public String getContentType()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Locale getLocale()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public ServletOutputStream getOutputStream() throws IOException
+ {
+ return outputStream;
+ }
+
+ public PrintWriter getWriter() throws IOException
+ {
+ if (writer == null)
+ {
+ writer = new PrintWriter(new OutputStreamWriter(outputStream, characterEncoding), true);
+ }
+ return writer;
+ }
+
+ public boolean isCommitted()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void reset()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void resetBuffer()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setBufferSize(int bufferSize)
+ {
+ this.bufferSize = bufferSize;
+ }
+
+ public void setCharacterEncoding(String characterEncoding)
+ {
+ this.characterEncoding = characterEncoding;
+ }
+
+ public void setContentLength(int arg0)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setContentType(String arg0)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setLocale(Locale arg0)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+}
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-24 01:58:12 UTC (rev 7037)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-04-24 12:59:46 UTC (rev 7038)
@@ -22,9 +22,31 @@
******************************************************************************/
package org.jboss.portal.core.aspects.controller;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.log4j.Logger;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import org.jboss.portal.api.node.PortalNode;
+import org.jboss.portal.common.http.HttpServletRequestWrapper;
+import org.jboss.portal.common.http.HttpServletResponseWriter;
import org.jboss.portal.core.controller.Controller;
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerContext;
@@ -50,28 +72,17 @@
import org.jboss.portal.portlet.PortletParametersStateString;
import org.jboss.portal.security.PortalSecurityException;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
+import org.jboss.portal.server.ServerInvocationContext;
import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portal.theme.impl.render.dynamic.DynaRenderOptions;
import org.jboss.portal.theme.page.Region;
import org.jboss.portal.theme.page.WindowContext;
import org.jboss.portal.theme.page.WindowResult;
-import org.apache.log4j.Logger;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision: 1.1 $
*/
public class PageCustomizerInterceptor extends ControllerInterceptor
@@ -86,6 +97,12 @@
/** . */
private static final String RESOURCE_PREFIX = "PAGENAME_";
+ private String JSPContext;
+
+ private String headerJSP;
+
+ private String tabsJSP;
+
/** . */
private PortalAuthorizationManagerFactory portalAuthorizationManagerFactory;
@@ -159,155 +176,140 @@
{
StringBuffer sb = new StringBuffer();
ControllerContext controllerCtx = cc.getControllerContext();
+
+ ServerInvocationContext serverContext = controllerCtx.getServerInvocation().getServerContext();
+ ServletContext servletContext = serverContext.getClientRequest().getSession().getServletContext().getContext(JSPContext);
+
+ RequestDispatcher rd = servletContext.getRequestDispatcher(headerJSP);
+
+ HttpServletResponse response = new HttpServletResponseWriter(serverContext.getClientResponse());
+ HttpServletRequest request = new HttpServletRequestWrapper(serverContext.getClientRequest());
+
+ // Get user
Controller controller = controllerCtx.getController();
User user = controllerCtx.getUser();
-
- //
- if (controllerCtx.getServerInvocation().getServerContext().getClientRequest().getRemoteUser() == null)
+ request.setAttribute("org.jboss.portal.header.user", user);
+
+ // Edit dashboard page || Copy to dashboard link
+ boolean isDashboard = false;
+ if (cc instanceof RenderPageCommand)
{
- URLContext ctx = controllerCtx.getServerInvocation().getServerContext().getURLContext();
- ctx = URLContext.newInstance(ctx.isSecure(), true);
- String loginURL = controllerCtx.renderURL(cc, ctx, null);
- sb.append("<a href=\"").append(loginURL).append("\">Login</a>");
- }
- else
- {
- String dashboardActionURL = null;
- String dashboardActionLabel = null;
-
- boolean isDashboard = false;
- if (cc instanceof RenderPageCommand)
+ RenderPageCommand rpc = (RenderPageCommand)cc;
+ Page page = rpc.getPage();
+ String pageName = page.getName();
+ isDashboard = rpc.isDashboard();
+ //
+ if (isDashboard)
{
- RenderPageCommand rpc = (RenderPageCommand)cc;
- Page page = rpc.getPage();
- String pageName = page.getName();
- isDashboard = rpc.isDashboard();
-
+ // Edit page
+ PortletParametersStateString navState = new PortletParametersStateString();
+ navState.setValue("editPageSelect", pageName);
+ InvokePortletInstanceRenderCommand command = new InvokePortletInstanceRenderCommand("DashboardConfigPortletInstance", navState);
+ request.setAttribute("org.jboss.portal.header.editDashboardURL", controllerCtx.renderURL(command, null, null));
+ }
+ else
+ {
//
- if (isDashboard)
+ if (user != null)
{
- // Edit page
- PortletParametersStateString navState = new PortletParametersStateString();
- navState.setValue("editPageSelect", pageName);
- InvokePortletInstanceRenderCommand command = new InvokePortletInstanceRenderCommand("DashboardConfigPortletInstance", navState);
- dashboardActionURL = controllerCtx.renderURL(command, null, null);
- dashboardActionLabel = "Edit Content";
- }
- else
- {
- //
CustomizationManager cm = controller.getCustomizationManager();
Portal dashboard = cm.getDashboard(user);
if (dashboard.getChild(pageName) == null)
{
ImportPageToDashboardCommand iptdc = new ImportPageToDashboardCommand(page.getId());
- dashboardActionURL = controllerCtx.renderURL(iptdc, null, null);
- dashboardActionLabel = "Add to dashboard";
+ request.setAttribute("org.jboss.portal.header.copyToDashboardURL", controllerCtx.renderURL(iptdc, null, null));
}
}
+
}
+ }
- // Compute label
- String pageURL;
- String label;
- if (isDashboard)
- {
- ViewPageCommand _rpc = new ViewPageCommand(new PortalObjectId(new String[]{"default", "default"}));
- pageURL = controllerCtx.renderURL(_rpc, null, null);
- label = "Portal";
- }
- else
- {
- //
- ViewDashboardCommand vdc = new ViewDashboardCommand();
- pageURL = controllerCtx.renderURL(vdc, null, null);
- label = "My Dashboard";
+ if (! isDashboard)
+ {
+ ViewDashboardCommand vdc = new ViewDashboardCommand();
+ request.setAttribute("org.jboss.portal.header.dashboardURL", controllerCtx.renderURL(vdc, null, null));
+ }
+
+ boolean admin = false;
+ if (cc instanceof RenderPageCommand)
+ {
+ RenderPageCommand rpc = (RenderPageCommand)cc;
+ PortalObject portalObject = rpc.getPage().getPortal();
+ admin = "admin".equalsIgnoreCase(portalObject.getName());
+ }
- }
-
- // Link to admin/default portal
- String showadminURL = null;
- String showDefaultURL = null;
-
- // Recode me, it's not a good criteria
- boolean admin = false;
- if (cc instanceof RenderPageCommand)
+ if (!admin || isDashboard)
+ {
+ PortalObjectPermission perm = new PortalObjectPermission(new PortalObjectId(new String[]{"admin"}), PortalObjectPermission.VIEW_MASK);
+ try
{
- RenderPageCommand rpc = (RenderPageCommand)cc;
- PortalObject portalObject = rpc.getPage().getPortal();
- admin = "admin".equalsIgnoreCase(portalObject.getName());
- }
-
- if (admin)
- {
- ViewPageCommand showDefault = new ViewPageCommand(new PortalObjectId(new String[]{"default"}));
- showDefaultURL = controllerCtx.renderURL(showDefault, null, null);
- }
- else
- {
- PortalObjectPermission perm = new PortalObjectPermission(new PortalObjectId(new String[]{"admin"}), PortalObjectPermission.VIEW_MASK);
- try
+ if (controller.getPortalAuthorizationManagerFactory().getManager().checkPermission(perm))
{
- if (controller.getPortalAuthorizationManagerFactory().getManager().checkPermission(perm))
- {
- ViewPageCommand showadmin = new ViewPageCommand(new PortalObjectId(new String[]{"admin"}));
- showadminURL = controllerCtx.renderURL(showadmin, null, null);
- }
+ ViewPageCommand showadmin = new ViewPageCommand(new PortalObjectId(new String[]{"admin"}));
+ request.setAttribute("org.jboss.portal.header.adminPortalURL", controllerCtx.renderURL(showadmin, null, null));
}
- catch (PortalSecurityException e)
- {
- log.error("", e);
- }
}
-
- SignOutCommand cmd = new SignOutCommand();
- URLContext urlContext = controllerCtx.getServerInvocation().getServerContext().getURLContext();
- String logoutURL = controllerCtx.renderURL(cmd, urlContext.asNonAuthenticated(), null);
-
- //
- if (user != null)
+ catch (PortalSecurityException e)
{
- sb.append("Logged in as: ").append(user.getUserName());
+ log.error("", e);
}
- else
- {
- sb.append("Logged in");
- }
- sb.append("<br/><br/>");
+ }
+
+ if (admin || isDashboard)
+ {
+ // Link to default page of default portal
+ ViewPageCommand _rpc = new ViewPageCommand(new PortalObjectId(new String[]{"default", "default"}));
+ request.setAttribute("org.jboss.portal.header.defaultPortalURL", controllerCtx.renderURL(_rpc, null, null));
+ }
+
+ SignOutCommand cmd = new SignOutCommand();
+ URLContext urlContext = controllerCtx.getServerInvocation().getServerContext().getURLContext();
+ String logoutURL = controllerCtx.renderURL(cmd, urlContext.asNonAuthenticated(), null);
+ request.setAttribute("org.jboss.portal.header.signOutURL", logoutURL);
- //
- sb.append("<a href=\"").append(pageURL).append("\">").append(label).append("</a>");
+
+ try
+ {
+ rd.include(request, response);
+ response.getWriter().flush();
+ }
+ catch (ServletException e1)
+ {
+ e1.printStackTrace();
+ }
+ catch (IOException e1)
+ {
+ e1.printStackTrace();
+ }
- //
- if (showadminURL != null)
- {
- sb.append(" | ");
- sb.append("<a href=\"").append(showadminURL).append("\">Admin</a>");
- }
- else if (!isDashboard)
- {
- sb.append(" | ");
- sb.append("<a href=\"").append(showDefaultURL).append("\">Main</a>");
- }
-
- // Dashboard action
- if (dashboardActionURL != null)
- {
- sb.append(" | ");
- sb.append("<a href=\"").append(dashboardActionURL).append("\">").append(dashboardActionLabel).append("</a>");
- }
-
- //
- sb.append(" | ");
- sb.append("<a href=\"").append(logoutURL).append("\">Logout</a>");
+ try
+ {
+ sb.append(response.getOutputStream().toString());
}
+ catch (IOException e1)
+ {
+ e1.printStackTrace();
+ }
- //
return sb;
}
public StringBuffer injectTabbedNav(RenderPageCommand rpc)
{
+ StringBuffer sb = new StringBuffer();
+ ControllerContext controllerCtx = rpc.getControllerContext();
+
+ ServerInvocationContext serverContext = controllerCtx.getServerInvocation().getServerContext();
+ ServletContext servletContext = serverContext.getClientRequest().getSession().getServletContext().getContext(JSPContext);
+
+ RequestDispatcher rd = servletContext.getRequestDispatcher(tabsJSP);
+
+ HttpServletResponse response = new HttpServletResponseWriter(serverContext.getClientResponse());
+ HttpServletRequest request = new HttpServletRequestWrapper(serverContext.getClientRequest());
+
+
+ Node root = new Node("root", null);
+
try
{
Page page = rpc.getPage();
@@ -325,15 +327,12 @@
}
sortTabs(navElements);
- StringBuffer html = new StringBuffer();
- html.append("<ul id=\"tabsHeader\">");
for (Iterator i = navElements.iterator(); i.hasNext();)
{
PortalObjectImpl navElement = (PortalObjectImpl)i.next();
// build up markup for the navigation , based on these nodes
String name = navElement.getName();
-
try
{
// localize node name
@@ -352,32 +351,21 @@
{
ViewPageCommand cmd = new ViewPageCommand(navElement.getId());
String childURL = rpc.getControllerContext().renderURL(cmd, null, null);
- html.append("<li");
- // if we were able to detect the selected node in the hierarchie level of the nav elements,
- // then flag the node so the css can style it as the selected one
+ Node childNode = new Node(name, childURL);
if (page == navElement)
{
- html.append(" id=\"current\"");
+ childNode.current = true;
}
- html.append(" onmouseover=\"this.className='hoverOn'\" onmouseout=\"this.className='hoverOff'\"><a href='").append(childURL).append("'>").append(name);
+
+ root.addChild(childNode);
+ // if we were able to detect the selected node in the hierarchie level of the nav elements,
+ // then flag the node so the css can style it as the selected one
List childPages = getAuthorizedChildrenPages(navElement);
- // ie 6 hack
- if (childPages.size() != 0)
- {
- html.append("<!--[if IE 7]><!--></a><!--<![endif]-->");
- html.append("<!--[if lte IE 6]><table><tr><td><![endif]-->");
- }
- else
- {
- html.append("</a>");
- }
-
// Submenu logic
if (childPages.size() != 0)
{
- html.append("<ul>");
for (Iterator j = childPages.iterator(); j.hasNext();)
{
PortalObject child = (PortalObject)j.next();
@@ -385,25 +373,54 @@
{
ViewPageCommand renderCmd = new ViewPageCommand(child.getId());
String subChildURL = rpc.getControllerContext().renderURL(renderCmd, null, null);
-
- html.append("<li>").append("<a href='").append(subChildURL).append("'>").append(child.getName()).append("</a></li>");
+ String childName = child.getName();
+ try
+ {
+ // localize node name
+ Locale requestLocale = rpc.getControllerContext().getServerInvocation().getRequest().getLocale();
+ ResourceBundle rb = ResourceBundle.getBundle("conf.bundles.Resource", requestLocale, Thread.currentThread().getContextClassLoader());
+ childName = rb.getString(RESOURCE_PREFIX + childName);
+ }
+ catch (MissingResourceException e)
+ {
+ }
+ childNode.addChild(new Node(childName, subChildURL));
}
}
- html.append("</ul>");
- html.append("<!--[if lte IE 6]></td></tr></table></a><![endif]-->");
}
- html.append("</li>");
}
}
- html.append("</ul>");
-
- return html;
}
catch (Exception e)
{
log.error("", e);
- return null;
}
+
+ request.setAttribute("org.jboss.portal.header.root", root);
+
+ try
+ {
+ rd.include(request, response);
+ response.getWriter().flush();
+ }
+ catch (ServletException e1)
+ {
+ e1.printStackTrace();
+ }
+ catch (IOException e1)
+ {
+ e1.printStackTrace();
+ }
+
+ try
+ {
+ sb.append(response.getOutputStream().toString());
+ }
+ catch (IOException e1)
+ {
+ e1.printStackTrace();
+ }
+ return sb;
}
private List getAuthorizedChildrenPages(PortalObject portalObject)
@@ -478,4 +495,55 @@
}
return 4;
}
+
+ public class Node
+ {
+ public String name;
+ public List children;
+ public String url;
+ public boolean current;
+
+ public Node(String name, String url)
+ {
+ this.name = name;
+ this.url = url;
+ this.children = new ArrayList();
+ this.current = false;
+ }
+
+ public void addChild(Node node)
+ {
+ children.add(node);
+ }
+ }
+
+ public String getHeaderJSP()
+ {
+ return headerJSP;
+ }
+
+ public void setHeaderJSP(String headerJSP)
+ {
+ this.headerJSP = headerJSP;
+ }
+
+ public String getJSPContext()
+ {
+ return JSPContext;
+ }
+
+ public void setJSPContext(String context)
+ {
+ JSPContext = context;
+ }
+
+ public String getTabsJSP()
+ {
+ return tabsJSP;
+ }
+
+ public void setTabsJSP(String tabsJSP)
+ {
+ this.tabsJSP = tabsJSP;
+ }
}
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-24 01:58:12 UTC (rev 7037)
+++ trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-04-24 12:59:46 UTC (rev 7038)
@@ -196,6 +196,9 @@
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
+ <attribute name="JSPContext">/portal-core</attribute>
+ <attribute name="HeaderJSP">/WEB-INF/jsp/header/header.jsp</attribute>
+ <attribute name="TabsJSP">/WEB-INF/jsp/header/tabs.jsp</attribute>
<depends
optional-attribute-name="PortalAuthorizationManagerFactory"
proxy-type="attribute">portal:service=PortalAuthorizationManagerFactory</depends>
Added: trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/header.jsp
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/header.jsp (rev 0)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/header.jsp 2007-04-24 12:59:46 UTC (rev 7038)
@@ -0,0 +1,53 @@
+<%@ page import="org.jboss.portal.identity.User" %>
+
+<%
+ User user = (User) request.getAttribute("org.jboss.portal.header.user");
+ String dashboardURL = (String) request.getAttribute("org.jboss.portal.header.dashboardURL");
+ String defaultPortalURL = (String) request.getAttribute("org.jboss.portal.header.defaultPortalURL");
+ String adminPortalURL = (String) request.getAttribute("org.jboss.portal.header.adminPortalURL");
+ String editDashboardURL = (String) request.getAttribute("org.jboss.portal.header.editDashboardURL");
+ String copyToDashboardURL = (String) request.getAttribute("org.jboss.portal.header.copyToDashboardURL");
+ String signOutURL = (String) request.getAttribute("org.jboss.portal.header.signOutURL");
+%>
+
+<%
+ if (user == null)
+ {
+%>
+ <a href="/portal/auth/portal/default/default">Login</a>
+<%
+ }
+ else
+ {
+%>
+Logged in as: <%= user.getUserName() %><br/><br/>
+
+<%
+ if (dashboardURL != null)
+ {
+%> <a href="<%= dashboardURL %>">Dashboard</a> |<%
+ }
+
+ if (defaultPortalURL != null)
+ {
+%> <a href="<%= defaultPortalURL %>">Portal</a> |<%
+ }
+
+ if (adminPortalURL != null)
+ {
+%> <a href="<%= adminPortalURL %>">Admin</a> |<%
+ }
+
+ if (editDashboardURL != null)
+ {
+%> <a href="<%= editDashboardURL %>">Edit page</a> |<%
+ }
+
+ if (copyToDashboardURL != null)
+ {
+%> <a href="<%= copyToDashboardURL %>">Copy to my dashboard</a> |<%
+ }
+%> <a href="<%= signOutURL %>">Logout</a>
+<%
+ }
+%>
\ No newline at end of file
Added: 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 (rev 0)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/tabs.jsp 2007-04-24 12:59:46 UTC (rev 7038)
@@ -0,0 +1,48 @@
+<%@ page import="org.jboss.portal.core.aspects.controller.PageCustomizerInterceptor.Node" %>
+<%@ page import="java.util.Iterator" %>
+
+<%
+ Node root = (Node) request.getAttribute("org.jboss.portal.header.root");
+%>
+
+<ul id="tabsHeader">
+<%
+ Iterator childrenIt = root.children.iterator();
+ while (childrenIt.hasNext())
+ {
+ Node child = (Node)childrenIt.next();
+%>
+ <li <% if(child.current) out.println(" id=\"current\""); %> onmouseover="this.className='hoverOn'" onmouseout="this.className='hoverOff'"><a href="<%= child.url %>"><%= child.name %>
+<%
+ if (child.children.size() == 0)
+ {
+%>
+ </a>
+<%
+ }
+ else
+ {
+%>
+ <!--[if IE 7]><!--></a><!--<![endif]-->
+ <!--[if lte IE 6]><table><tr><td><![endif]-->
+ <ul>
+<%
+ for (Iterator j = child.children.iterator(); j.hasNext();)
+ {
+ Node subChild = (Node)j.next();
+%>
+ <li><a href='<%= subChild.url %>'><%= subChild.name %></a></li>
+<%
+ }
+%>
+ </ul>
+ <!--[if lte IE 6]></td></tr></table></a><![endif]-->
+<%
+ }
+%>
+ </li>
+<%
+ }
+
+%>
+</ul>
17 years, 2 months
JBoss Portal SVN: r7037 - trunk/portlet-server.
by portal-commits@lists.jboss.org
Author: prabhat.jha(a)jboss.com
Date: 2007-04-23 21:58:12 -0400 (Mon, 23 Apr 2007)
New Revision: 7037
Modified:
trunk/portlet-server/build.xml
Log:
fix test-ha target
Modified: trunk/portlet-server/build.xml
===================================================================
--- trunk/portlet-server/build.xml 2007-04-23 22:47:04 UTC (rev 7036)
+++ trunk/portlet-server/build.xml 2007-04-24 01:58:12 UTC (rev 7037)
@@ -396,24 +396,25 @@
<jvmarg value="-Xdebug"/>
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=7878,server=y,suspend=y"/>
-->
- <sysproperty key="test.root" value="${build.lib}"/>
+ <sysproperty key="test.root" value="${jboss.portal-portlet.root}/lib"/>
<sysproperty key="test.uri" value="/test/redirect/"/>
</x-sysproperty>
<x-test>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.ha.session.SessionTestCase"/>
</x-test>
<x-classpath>
- <path refid="oswego.concurrent.classpath"/>
- <path refid="jboss.remoting.classpath"/>
- <path refid="jboss.microcontainer.classpath"/>
- <path refid="jboss.jbossxb.classpath"/>
- <path refid="apache.xerces.classpath"/>
- <path refid="jbossas/core.libs.classpath"/>
- <pathelement location="${source.java}"/>
- <pathelement location="${build.classes}"/>
- <pathelement location="${build.resources}"/>
- <path refid="library.classpath"/>
- <path refid="dependentmodule.classpath"/>
+ <path refid="oswego.concurrent.classpath"/>
+ <path refid="jboss.remoting.classpath"/>
+ <path refid="jboss.microcontainer.classpath"/>
+ <path refid="jboss.jbossxb.classpath"/>
+ <path refid="apache.xerces.classpath"/>
+ <path refid="jbossas/core.libs.classpath"/>
+ <pathelement location="${source.java}"/>
+ <pathelement location="${build.classes}"/>
+ <pathelement location="${build.resources}"/>
+ <path refid="library.classpath"/>
+ <path refid="dependentmodule.classpath"/>
+ <pathelement location="${jboss.portal-portlet.root}/classes"/>
</x-classpath>
</execute-tests>
</target>
17 years, 2 months