Author: mmillson
Date: 2008-05-02 01:08:09 -0400 (Fri, 02 May 2008)
New Revision: 10734
Added:
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/aspects/controller/CleanNSInterceptor.java
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/server/src/main/org/jboss/portal/server/impl/invocation/SessionAttributeResolver.java
Modified:
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/server/src/main/org/jboss/portal/server/PortalConstants.java
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/server/src/main/org/jboss/portal/server/impl/ServerInvocationContextImpl.java
Log:
Provide mechanism for resetting render parameters (window state, portlet Mode, and render
request parameters) when rendering a page [JBPORTAL-2000]
Copied:
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/aspects/controller/CleanNSInterceptor.java
(from rev 10589,
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/aspects/controller/CleanNSInterceptor.java)
===================================================================
---
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/aspects/controller/CleanNSInterceptor.java
(rev 0)
+++
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/aspects/controller/CleanNSInterceptor.java 2008-05-02
05:08:09 UTC (rev 10734)
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * 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;
+
+import java.util.Collection;
+
+import org.jboss.portal.common.invocation.InvocationException;
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.controller.ControllerInterceptor;
+import org.jboss.portal.core.controller.ControllerResponse;
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.command.view.ViewPageCommand;
+import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
+import org.jboss.portal.core.navstate.NavigationalStateKey;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class CleanNSInterceptor extends ControllerInterceptor
+{
+
+ @Override
+ public ControllerResponse invoke(ControllerCommand cmd) throws Exception,
InvocationException
+ {
+ if (cmd instanceof ViewPageCommand)
+ {
+ ViewPageCommand vpc = (ViewPageCommand)cmd;
+ Collection<PortalObject> children = vpc.getPage().getChildren();
+ for (PortalObject portalObject: children)
+ {
+ cmd.removeAttribute(ControllerCommand.NAVIGATIONAL_STATE_SCOPE, new
NavigationalStateKey(WindowNavigationalState.class, portalObject.getId()));
+ }
+ }
+ return (ControllerResponse)cmd.invokeNext();
+ }
+
+}
+
Modified:
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java
===================================================================
---
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java 2008-05-02
04:59:30 UTC (rev 10733)
+++
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java 2008-05-02
05:08:09 UTC (rev 10734)
@@ -162,7 +162,7 @@
return render;
}
- private static class ControllerActionContext extends AbstractActionContext
+ public static class ControllerActionContext extends AbstractActionContext
{
private InvokePortletCommandFactory cmdFactory;
private ControllerContext controllerContext;
@@ -199,7 +199,7 @@
}
}
- private static class ControllerRenderContext extends AbstractRenderContext
+ public static class ControllerRenderContext extends AbstractRenderContext
{
private InvokePortletCommandFactory cmdFactory;
private ControllerContext controllerContext;
Modified:
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java
===================================================================
---
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java 2008-05-02
04:59:30 UTC (rev 10733)
+++
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java 2008-05-02
05:08:09 UTC (rev 10734)
@@ -120,14 +120,14 @@
*
* @return the children
*/
- Collection getChildren();
+ Collection<PortalObject> getChildren();
/**
* Return all the children of this object filtered with a particular mask.
*
* @return the children
*/
- Collection getChildren(int mask);
+ Collection<PortalObject> getChildren(int mask);
/**
* Return the parent object.
Modified:
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java
===================================================================
---
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java 2008-05-02
04:59:30 UTC (rev 10733)
+++
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java 2008-05-02
05:08:09 UTC (rev 10734)
@@ -28,6 +28,7 @@
import org.jboss.portal.core.navstate.NavigationalStateContext;
import org.jboss.portal.core.navstate.NavigationalStateKey;
import org.jboss.portal.core.navstate.NavigationalStateObjectChange;
+import org.jboss.portal.core.model.portal.PortalObjectId;
import java.util.Iterator;
import java.util.LinkedHashMap;
@@ -83,7 +84,8 @@
}
//
- return store.getAttribute(nsKey);
+ PortalObjectId id = (PortalObjectId)nsKey.getId();
+ return store.getAttribute(id.toString());
}
public void setAttribute(Object attrKey, Object attrValue) throws
IllegalArgumentException
@@ -122,7 +124,8 @@
// If we don't have the old ns then we try the store
if (oldNS == null)
{
- oldNS = (WindowNavigationalState)store.getAttribute(wantedKey);
+ PortalObjectId id = (PortalObjectId)wantedKey.getId();
+ oldNS = (WindowNavigationalState)store.getAttribute(id.toString());
}
//
@@ -198,7 +201,10 @@
maximizedKey = change.getKey();
}
}
- store.setAttribute(change.getKey(), change.getNewValue());
+
+ //
+ PortalObjectId id = (PortalObjectId)change.getKey().getId();
+ store.setAttribute(id.toString(), change.getNewValue());
}
// Unmaximize other windows if necessary
Modified:
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
===================================================================
---
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2008-05-02
04:59:30 UTC (rev 10733)
+++
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2008-05-02
05:08:09 UTC (rev 10734)
@@ -209,7 +209,17 @@
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
</mbean>
+ <!--
+ This interceptor cleans the Navigation state of windows when the user call a new
page or refresh the page
+ -->
<mbean
+ code="org.jboss.portal.core.aspects.controller.CleanNSInterceptor"
+ name="portal:service=Interceptor,type=Command,name=CleanNS"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
+ <mbean
code="org.jboss.portal.core.aspects.controller.node.PortalNodeInterceptor"
name="portal:service=Interceptor,type=Command,name=PortalNode"
xmbean-dd=""
@@ -267,6 +277,7 @@
<depends-list optional-attribute-name="InterceptorNames">
<depends-list-element>portal:service=Interceptor,type=Command,name=ResourceAcquisition</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Command,name=Ajax</depends-list-element>
+
<depends-list-element>portal:service=Interceptor,type=Command,name=CleanNS</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Command,name=NavigationalState</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Command,name=PortalNode</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Command,name=PolicyEnforcement</depends-list-element>
Modified:
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/server/src/main/org/jboss/portal/server/PortalConstants.java
===================================================================
---
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/server/src/main/org/jboss/portal/server/PortalConstants.java 2008-05-02
04:59:30 UTC (rev 10733)
+++
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/server/src/main/org/jboss/portal/server/PortalConstants.java 2008-05-02
05:08:09 UTC (rev 10734)
@@ -60,6 +60,6 @@
/** Generic session objects. */
public static final String PORTAL_SESSION_MAP_KEY = "portal.session";
- /** Navigational state objects. */
- public static final String NAVIGATIONAL_STATE_MAP_KEY =
"portal.navigationalstate";
+ /** Generic session objects. */
+ public static final String PORTAL_PRINCIPAL_MAP_KEY = "portal.principal";
}
Modified:
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/server/src/main/org/jboss/portal/server/impl/ServerInvocationContextImpl.java
===================================================================
---
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/server/src/main/org/jboss/portal/server/impl/ServerInvocationContextImpl.java 2008-05-02
04:59:30 UTC (rev 10733)
+++
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/server/src/main/org/jboss/portal/server/impl/ServerInvocationContextImpl.java 2008-05-02
05:08:09 UTC (rev 10734)
@@ -23,9 +23,7 @@
package org.jboss.portal.server.impl;
import org.jboss.portal.common.invocation.AbstractInvocationContext;
-import org.jboss.portal.common.invocation.resolver.PrincipalAttributeResolver;
import org.jboss.portal.common.invocation.resolver.RequestAttributeResolver;
-import org.jboss.portal.common.invocation.resolver.SessionAttributeResolver;
import org.jboss.portal.common.text.CharBuffer;
import org.jboss.portal.common.text.FastURLEncoder;
import org.jboss.portal.common.util.ParameterMap;
@@ -33,6 +31,7 @@
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.server.ServerInvocationContext;
import org.jboss.portal.server.ServerURL;
+import org.jboss.portal.server.impl.invocation.SessionAttributeResolver;
import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.server.request.URLFormat;
import org.jboss.portal.web.WebRequest;
@@ -133,8 +132,8 @@
//
addResolver(ServerInvocation.REQUEST_SCOPE, new RequestAttributeResolver(req));
- addResolver(ServerInvocation.SESSION_SCOPE, new SessionAttributeResolver(req,
PortalConstants.PORTAL_SESSION_MAP_KEY));
- addResolver(ServerInvocation.PRINCIPAL_SCOPE, new
PrincipalAttributeResolver(req));
+ addResolver(ServerInvocation.SESSION_SCOPE, new SessionAttributeResolver(req,
PortalConstants.PORTAL_SESSION_MAP_KEY, false));
+ addResolver(ServerInvocation.PRINCIPAL_SCOPE, new SessionAttributeResolver(req,
PortalConstants.PORTAL_PRINCIPAL_MAP_KEY, true));
}
public WebRequest getWebRequest()
Copied:
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/server/src/main/org/jboss/portal/server/impl/invocation/SessionAttributeResolver.java
(from rev 10324,
branches/JBoss_Portal_2_6_3_JBPORTAL-1956/server/src/main/org/jboss/portal/server/impl/invocation/SessionAttributeResolver.java)
===================================================================
---
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/server/src/main/org/jboss/portal/server/impl/invocation/SessionAttributeResolver.java
(rev 0)
+++
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/server/src/main/org/jboss/portal/server/impl/invocation/SessionAttributeResolver.java 2008-05-02
05:08:09 UTC (rev 10734)
@@ -0,0 +1,122 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.server.impl.invocation;
+
+import org.jboss.portal.common.invocation.AttributeResolver;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Enumeration;
+import java.util.Collections;
+import java.security.Principal;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class SessionAttributeResolver implements AttributeResolver
+{
+
+ /** . */
+ protected final HttpServletRequest req;
+
+ /** . */
+ protected final String prefix;
+
+ public SessionAttributeResolver(
+ HttpServletRequest req,
+ String prefix,
+ boolean principalScoped)
+ {
+ if (req == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (prefix == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ if (principalScoped)
+ {
+ Principal principal = req.getUserPrincipal();
+ if (principal != null)
+ {
+ prefix = prefix + principal.getName();
+ }
+ }
+
+ //
+ this.req = req;
+ this.prefix = prefix;
+ }
+
+ public Set getKeys()
+ {
+ HttpSession session = req.getSession(false);
+
+ //
+ if (session == null)
+ {
+ return Collections.EMPTY_SET;
+ }
+
+ //
+ Set keys = new HashSet();
+ for (Enumeration e = session.getAttributeNames();e.hasMoreElements();)
+ {
+ String key = (String)e.nextElement();
+
+ //
+ if (key.startsWith(prefix))
+ {
+ keys.add(key);
+ }
+ }
+
+ //
+ return keys;
+ }
+
+ public Object getAttribute(Object o) throws IllegalArgumentException
+ {
+ HttpSession session = req.getSession(false);
+
+ //
+ if (session == null)
+ {
+ return null;
+ }
+
+ //
+ return session.getAttribute(prefix + o);
+ }
+
+ public void setAttribute(Object o, Object o1) throws IllegalArgumentException
+ {
+ req.getSession().setAttribute(prefix + o, o1);
+ }
+}
\ No newline at end of file