Author: julien(a)jboss.com
Date: 2007-01-09 21:17:27 -0500 (Tue, 09 Jan 2007)
New Revision: 5972
Added:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/DashboardCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/ImportPageToDashboardCommand.java
Modified:
trunk/common/src/main/org/jboss/portal/common/util/ParameterMap.java
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java
trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerUserContext.java
trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletContextFactory.java
trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PersistentPortalObjectContainer.java
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java
trunk/core/src/main/org/jboss/portal/core/model/CustomizationManager.java
trunk/core/src/main/org/jboss/portal/core/model/portal/DashboardCommandFactory.java
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/ViewDashboardCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/WindowCommand.java
trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java
trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
trunk/portlet/src/main/org/jboss/portal/portlet/Parameters.java
trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManager.java
trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManagerFactory.java
trunk/server/src/main/org/jboss/portal/server/ServerInvocationContext.java
trunk/server/src/main/org/jboss/portal/server/impl/ServerInvocationContextImpl.java
trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java
Log:
- JBPORTAL-1181 : bug fix in send redirect with non idempotent commands
- JBPORTAL-1182 : Add "Add to dashboard" command displayed on shared pages
Modified: trunk/common/src/main/org/jboss/portal/common/util/ParameterMap.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/ParameterMap.java 2007-01-09
14:43:56 UTC (rev 5971)
+++ trunk/common/src/main/org/jboss/portal/common/util/ParameterMap.java 2007-01-10
02:17:27 UTC (rev 5972)
@@ -96,4 +96,58 @@
String[] valuesR = (String[])right;
return Arrays.equals(valuesL, valuesR);
}
+
+ /**
+ * Return the parameter value or null if it does not exist.
+ *
+ * @param name the parameter name
+ * @return the parameter value or null if it does not exist
+ * @throws NullPointerException if the name is null
+ */
+ public String getValue(String name) throws IllegalArgumentException
+ {
+ String[] value = (String[])get(name);
+ return value == null ? null : value[0];
+ }
+
+ /**
+ * Return the parameter values or null if it does not exist.
+ *
+ * @param name the value to get
+ * @return the parameter values
+ * @throws NullPointerException if the name is null
+ */
+ public String[] getValues(String name) throws IllegalArgumentException
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No null name");
+ }
+ return (String[])get(name);
+ }
+
+ /**
+ * Set the a parameter value.
+ *
+ * @param name the parameter name
+ * @param value the parameter value
+ * @throws NullPointerException if the name or the value is null
+ */
+ public void setValue(String name, String value)
+ {
+ put(name, new String[]{value});
+ }
+
+ /**
+ * Set the parameter values. This method does not make a defensive copy of the
values.
+ *
+ * @param name the parameter name
+ * @param values the parameter values
+ * @throws NullPointerException if the name or the value is null
+ * @throws IllegalArgumentException if the values length is zero or contains a null
element
+ */
+ public void setValues(String name, String[] values) throws NullPointerException,
IllegalArgumentException
+ {
+ put(name, values);
+ }
}
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-01-09
14:43:56 UTC (rev 5971)
+++
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-01-10
02:17:27 UTC (rev 5972)
@@ -27,6 +27,8 @@
import org.jboss.portal.api.node.PortalNode;
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerInterceptor;
+import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.controller.Controller;
import org.jboss.portal.core.controller.command.SignOutCommand;
import org.jboss.portal.core.impl.model.portal.PortalObjectImpl;
import org.jboss.portal.core.model.instance.command.InvokePortletInstanceRenderCommand;
@@ -39,6 +41,8 @@
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.portal.command.RenderPageCommand;
import org.jboss.portal.core.model.portal.command.ViewDashboardCommand;
+import org.jboss.portal.core.model.portal.command.ImportPageToDashboardCommand;
+import org.jboss.portal.core.model.CustomizationManager;
import org.jboss.portal.identity.User;
import org.jboss.portal.portlet.impl.PortletRequestDecoder;
import org.jboss.portal.portlet.ParametersStateString;
@@ -146,49 +150,72 @@
public StringBuffer injectDashboardNav(ControllerCommand cc)
{
StringBuffer sb = new StringBuffer();
- if
(cc.getControllerContext().getServerInvocation().getServerContext().getClientRequest().getRemoteUser()
== null)
+ ControllerContext controllerCtx = cc.getControllerContext();
+ Controller controller = controllerCtx.getController();
+ User user = controllerCtx.getUser();
+
+ //
+ if
(controllerCtx.getServerInvocation().getServerContext().getClientRequest().getRemoteUser()
== null)
{
- URLContext ctx =
cc.getControllerContext().getServerInvocation().getServerContext().getURLContext();
+ URLContext ctx =
controllerCtx.getServerInvocation().getServerContext().getURLContext();
ctx = URLContext.newInstance(ctx.getSecure(), true);
- String loginURL = cc.getControllerContext().renderURL(cc, ctx, null);
+ String loginURL = controllerCtx.renderURL(cc, ctx, null);
sb.append("<a
href=\"").append(loginURL).append("\">Login</a>");
}
else
{
- String configureURL = null;
+ String dashboardActionURL = null;
+ String dashboardActionLabel = null;
- boolean dashboard = false;
+ boolean isDashboard = false;
if (cc instanceof RenderPageCommand)
{
RenderPageCommand rpc = (RenderPageCommand)cc;
- dashboard = rpc.isDashboard();
+ Page page = rpc.getPage();
+ String pageName = page.getName();
+ isDashboard = rpc.isDashboard();
//
- if (dashboard)
+ if (isDashboard)
{
// Edit page
ParametersStateString navState = new ParametersStateString();
- navState.setValue("editPageSelect", rpc.getPage().getName());
+ navState.setValue("editPageSelect", pageName);
InvokePortletInstanceRenderCommand command = new
InvokePortletInstanceRenderCommand("ConfiguratorPortletInstance", navState);
- configureURL = cc.getControllerContext().renderURL(command, null, null);
+ 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";
+ }
+ }
}
+
+ // Compute label
String pageURL;
String label;
- if (dashboard)
+ if (isDashboard)
{
RenderPageCommand _rpc = new RenderPageCommand(new PortalObjectId(new
String[]{"default", "default"}));
- pageURL = cc.getControllerContext().renderURL(_rpc, null, null);
+ pageURL = controllerCtx.renderURL(_rpc, null, null);
label = "Portal";
}
else
{
- ViewDashboardCommand vdc = new ViewDashboardCommand(new PortalObjectId(new
String[]{"dashboard"}));
- pageURL = cc.getControllerContext().renderURL(vdc, null, null);
+ //
+ ViewDashboardCommand vdc = new ViewDashboardCommand();
+ pageURL = controllerCtx.renderURL(vdc, null, null);
label = "My Dashboard";
+
}
-
- //
// Link to admin/default portal
@@ -207,17 +234,17 @@
if (admin)
{
RenderPageCommand showDefault = new RenderPageCommand(new PortalObjectId(new
String[]{"default"}));
- showDefaultURL = cc.getControllerContext().renderURL(showDefault, null,
null);
+ showDefaultURL = controllerCtx.renderURL(showDefault, null, null);
}
else
{
PortalObjectPermission perm = new PortalObjectPermission(new
PortalObjectId(new String[]{"admin"}), PortalObjectPermission.VIEW_MASK);
try
{
- if
(cc.getControllerContext().getController().getPortalAuthorizationManagerFactory().getManager().checkPermission(perm))
+ if
(controller.getPortalAuthorizationManagerFactory().getManager().checkPermission(perm))
{
RenderPageCommand showadmin = new RenderPageCommand(new
PortalObjectId(new String[]{"admin"}));
- showadminURL = cc.getControllerContext().renderURL(showadmin, null,
null);
+ showadminURL = controllerCtx.renderURL(showadmin, null, null);
}
}
catch (PortalSecurityException e)
@@ -227,9 +254,9 @@
}
SignOutCommand cmd = new SignOutCommand();
- String logoutURL = cc.getControllerContext().renderURL(cmd, null, null);
+ String logoutURL = controllerCtx.renderURL(cmd, null, null);
- User user =
(User)cc.getControllerContext().getServerInvocation().getRequest().getUser();
+ //
if (user != null)
{
sb.append("Logged in as: ").append(user.getUserName());
@@ -249,26 +276,25 @@
sb.append(" | ");
sb.append("<a
href=\"").append(showadminURL).append("\">Admin</a>");
}
- else
+ else if (!isDashboard)
{
- if (!dashboard)
- {
- sb.append(" | ");
- sb.append("<a
href=\"").append(showDefaultURL).append("\">Main</a>");
- }
+ sb.append(" | ");
+ sb.append("<a
href=\"").append(showDefaultURL).append("\">Main</a>");
}
- //
- if (configureURL != null)
+ // Dashboard action
+ if (dashboardActionURL != null)
{
sb.append(" | ");
- sb.append("<a
href=\"").append(configureURL).append("\">Edit
Content</a>");
+ sb.append("<a
href=\"").append(dashboardActionURL).append("\">").append(dashboardActionLabel).append("</a>");
}
//
sb.append(" | ");
sb.append("<a
href=\"").append(logoutURL).append("\">Logout</a>");
}
+
+ //
return sb;
}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java 2007-01-09
14:43:56 UTC (rev 5971)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java 2007-01-10
02:17:27 UTC (rev 5972)
@@ -29,6 +29,7 @@
import org.jboss.portal.server.ServerURL;
import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.server.request.URLFormat;
+import org.jboss.portal.identity.User;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -111,4 +112,9 @@
{
return controller;
}
+
+ public User getUser()
+ {
+ return (User)serverInvocation.getRequest().getUser();
+ }
}
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java 2007-01-09
14:43:56 UTC (rev 5971)
+++
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java 2007-01-10
02:17:27 UTC (rev 5972)
@@ -103,7 +103,7 @@
}
// Find out if we can execute in the same server invocation
- if (requiresRedirect(urlContext, forward))
+ if (requiresRedirect(cmd, urlContext, forward))
{
String url = ctx.renderURL(forward.getCommand(), forward.getURLContext(),
null);
if (url == null)
@@ -172,16 +172,27 @@
return null;
}
- public boolean requiresRedirect(URLContext currentURLCtx, CommandForward forward)
+ /**
+ * Return true if the execution of the next command requires a redirect.
+ *
+ * @param currentCmd the current command which has been executed
+ * @param currentURLCtx the request URL context
+ * @param forward the forward
+ * @return
+ */
+ public boolean requiresRedirect(
+ ControllerCommand currentCmd,
+ URLContext currentURLCtx,
+ CommandForward forward)
{
- CommandInfo cmdInfo = forward.getCommand().getInfo();
- URLContext nextURLCtx = forward.getURLContext();
- if (cmdInfo instanceof ActionCommandInfo &&
!((ActionCommandInfo)cmdInfo).isIdempotent())
+ CommandInfo currentCmdInfo = currentCmd.getInfo();
+ if (currentCmdInfo instanceof ActionCommandInfo &&
!((ActionCommandInfo)currentCmdInfo).isIdempotent())
{
return true;
}
else
{
+ URLContext nextURLCtx = forward.getURLContext();
boolean currentAuthenticated = currentURLCtx.isAuthenticated();
if (nextURLCtx != null && currentAuthenticated !=
nextURLCtx.isAuthenticated())
{
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerUserContext.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerUserContext.java 2007-01-09
14:43:56 UTC (rev 5971)
+++
trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerUserContext.java 2007-01-10
02:17:27 UTC (rev 5972)
@@ -25,13 +25,12 @@
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.identity.User;
import org.jboss.portal.identity.UserProfileModule;
-import org.jboss.portal.identity.UserModule;
import org.jboss.portal.identity.IdentityException;
import org.jboss.portal.portlet.spi.UserContext;
import org.jboss.portal.server.ServerInvocation;
+import org.jboss.portal.core.controller.ControllerContext;
import javax.naming.InitialContext;
-import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
import java.util.List;
import java.util.Locale;
@@ -49,15 +48,19 @@
/** . */
private final ServerInvocation invocation;
- public ControllerUserContext(ServerInvocation invocation)
+ /** . */
+ private final User user;
+
+ public ControllerUserContext(ControllerContext controllerContext)
{
- this.invocation = invocation;
+ this.invocation = controllerContext.getServerInvocation();
+ this.user = controllerContext.getUser();
}
/** This implementation returns the remote user value from the underlying http
request. */
public String getId()
{
- return invocation.getServerContext().getClientRequest().getRemoteUser();
+ return user != null ? user.getUserName() : null;
}
public Map getInformations()
@@ -78,7 +81,6 @@
if (user != null && userProfileModule != null)
{
- //return user.getProfile();
try
{
return userProfileModule.getProperties(user);
@@ -97,7 +99,7 @@
public User getUser()
{
- return (User)invocation.getRequest().getUser();
+ return user;
}
public Locale getLocale()
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletContextFactory.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletContextFactory.java 2007-01-09
14:43:56 UTC (rev 5971)
+++
trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletContextFactory.java 2007-01-10
02:17:27 UTC (rev 5972)
@@ -66,7 +66,7 @@
{
this.requestContext = new
AbstractRequestContext(controllerContext.getServerInvocation().getServerContext().getClientRequest(),
controllerContext.getServerInvocation().getServerContext().getClientResponse());
this.securityContext = new
AbstractSecurityContext(controllerContext.getServerInvocation().getServerContext().getClientRequest());
- this.userContext = new
ControllerUserContext(controllerContext.getServerInvocation());
+ this.userContext = new ControllerUserContext(controllerContext);
this.portalContext = new
org.jboss.portal.core.model.portal.portlet.PortalContextImpl(portal);
this.windowContext = new
org.jboss.portal.core.model.portal.portlet.WindowContextImpl(window);
}
@@ -75,7 +75,7 @@
{
this.requestContext = new
AbstractRequestContext(controllerContext.getServerInvocation().getServerContext().getClientRequest(),
controllerContext.getServerInvocation().getServerContext().getClientResponse());
this.securityContext = new
AbstractSecurityContext(controllerContext.getServerInvocation().getServerContext().getClientRequest());
- this.userContext = new
ControllerUserContext(controllerContext.getServerInvocation());
+ this.userContext = new ControllerUserContext(controllerContext);
this.portalContext = portalContextImpl;
this.windowContext = new WindowContextImpl("abc"); // Well ????
}
Modified:
trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java 2007-01-09
14:43:56 UTC (rev 5971)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java 2007-01-10
02:17:27 UTC (rev 5972)
@@ -29,6 +29,11 @@
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.portal.PortalObjectPermission;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.Portal;
+import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
+import org.jboss.portal.core.model.portal.PortalContainer;
+import org.jboss.portal.core.model.portal.PortalObjectContainer;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
import org.jboss.portal.identity.UserModule;
@@ -47,6 +52,12 @@
private static final Logger log = Logger.getLogger(CustomizationManager.class);
/** . */
+ private String dashboardContextId;
+
+ /** . */
+ private PortalObjectId dashboardContextObjectId;
+
+ /** . */
private InstanceContainer instanceContainer;
/** . */
@@ -58,6 +69,29 @@
/** . */
private RoleModule roleModule;
+ /** . */
+ private PortalObjectContainer portalObjectContainer;
+
+ public PortalObjectContainer getPortalObjectContainer()
+ {
+ return portalObjectContainer;
+ }
+
+ public void setPortalObjectContainer(PortalObjectContainer portalObjectContainer)
+ {
+ this.portalObjectContainer = portalObjectContainer;
+ }
+
+ public String getDashboardContextId()
+ {
+ return dashboardContextId;
+ }
+
+ public void setDashboardContextId(String dashboardContextId)
+ {
+ this.dashboardContextId = dashboardContextId;
+ }
+
public InstanceContainer getInstanceContainer()
{
return instanceContainer;
@@ -98,6 +132,23 @@
this.roleModule = roleModule;
}
+ protected void createService() throws Exception
+ {
+ super.createService();
+
+ //
+ dashboardContextObjectId = PortalObjectId.parse(dashboardContextId,
PortalObjectId.LEGACY_FORMAT);
+ }
+
+
+ protected void destroyService() throws Exception
+ {
+ dashboardContextObjectId = null;
+
+ //
+ super.destroyService();
+ }
+
public Instance getInstance(Window window) throws IllegalArgumentException
{
return getInstance(window, null);
@@ -124,7 +175,7 @@
// If we are in the context of an existing user we get a customization for that
user
if (user != null)
{
- String userId = user.getId().toString();
+ String userId = getUserId(user);
// And if it is in a dashboard context we get the per window customization
if (isDashboard(window, user))
@@ -183,4 +234,45 @@
return false;
}
}
+
+ public Portal getDashboard(User user) throws IllegalArgumentException
+ {
+ //
+ Portal dashboardPortal = null;
+
+ if (user != null)
+ {
+ String userId = getUserId(user);
+
+ //
+ try
+ {
+ PortalContainer dashboardContext =
(PortalContainer)portalObjectContainer.getObject(dashboardContextObjectId);
+
+ //
+ dashboardPortal = dashboardContext.getPortal(userId);
+
+ // Create if not exist
+ if (dashboardPortal == null)
+ {
+ Portal templatePortal = (Portal)portalObjectContainer.getObject(new
PortalObjectId("/template", PortalObjectId.CANONICAL_FORMAT));
+
+ // Copy the template portal
+ dashboardPortal = (Portal)templatePortal.copy(dashboardContext, userId,
true);
+ }
+ }
+ catch (DuplicatePortalObjectException e)
+ {
+ log.error("", e);
+ }
+ }
+
+ //
+ return dashboardPortal;
+ }
+
+ private String getUserId(User user)
+ {
+ return user.getUserName();
+ }
}
Modified:
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PersistentPortalObjectContainer.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PersistentPortalObjectContainer.java 2007-01-09
14:43:56 UTC (rev 5971)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PersistentPortalObjectContainer.java 2007-01-10
02:17:27 UTC (rev 5972)
@@ -38,8 +38,6 @@
import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
-import java.util.List;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
@@ -256,7 +254,7 @@
private ObjectNode getObjectNodeNoCache(Session session, String path)
{
- List results;
+ Object result;
if (path.length() == 0)
{
// For oracle where an empty path is treated as null so we need to add that
here
@@ -264,20 +262,16 @@
Query query = session.createQuery(LOOKUP_QUERY_FOR_NULL_PATH);
query.setParameter("path", path);
query.setCacheable(true);
- results = query.list();
+ result = query.uniqueResult();
}
else
{
Criteria criteria = session.createCriteria(ObjectNode.class);
criteria.add(Restrictions.naturalId().set("path", path));
criteria.setCacheable(true);
- results = criteria.list();
+ result = criteria.uniqueResult();
}
- if (results.isEmpty())
- {
- return null;
- }
- return (ObjectNode)results.get(0);
+ return (ObjectNode)result;
}
private ObjectNode getObjectNode(Session session, String path)
Modified:
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java 2007-01-09
14:43:56 UTC (rev 5971)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java 2007-01-10
02:17:27 UTC (rev 5972)
@@ -124,7 +124,7 @@
}
- public PortalObject copy(PortalObject parent, String name) throws
DuplicatePortalObjectException, IllegalArgumentException
+ public PortalObject copy(PortalObject parent, String name, boolean deep) throws
DuplicatePortalObjectException, IllegalArgumentException
{
if (parent == null)
{
@@ -134,10 +134,10 @@
{
throw new IllegalArgumentException("No null name accepted");
}
- return copy((PortalObjectImpl)parent, name);
+ return copy((PortalObjectImpl)parent, name, deep);
}
- private PortalObjectImpl copy(PortalObjectImpl parent, String name) throws
DuplicatePortalObjectException
+ private PortalObjectImpl copy(PortalObjectImpl parent, String name, boolean deep)
throws DuplicatePortalObjectException
{
// Clone this node
PortalObjectImpl clone = cloneObject();
@@ -145,13 +145,16 @@
// Add the clone to the specified parent
parent.addChild(name, clone);
- // Clone children reccursively
- for (Iterator i = getChildren().iterator();i.hasNext();)
+ // Clone children recursively
+ if (deep)
{
- PortalObjectImpl child = (PortalObjectImpl)i.next();
+ for (Iterator i = getChildren().iterator();i.hasNext();)
+ {
+ PortalObjectImpl child = (PortalObjectImpl)i.next();
- //
- child.copy(clone, child.getName());
+ //
+ child.copy(clone, child.getName(), true);
+ }
}
//
Modified: trunk/core/src/main/org/jboss/portal/core/model/CustomizationManager.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/CustomizationManager.java 2007-01-09
14:43:56 UTC (rev 5971)
+++ trunk/core/src/main/org/jboss/portal/core/model/CustomizationManager.java 2007-01-10
02:17:27 UTC (rev 5972)
@@ -25,10 +25,11 @@
import org.jboss.portal.core.model.instance.Instance;
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.Portal;
import org.jboss.portal.identity.User;
/**
- * Encapsulate portlet customization semantics.
+ * Integration logic between portal objects, instances and users.
*
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -56,6 +57,15 @@
Instance getInstance(Window window, User user) throws IllegalArgumentException;
/**
+ * Returns the dashboard of a specific user.
+ *
+ * @param user
+ * @return
+ * @throws IllegalArgumentException
+ */
+ Portal getDashboard(User user) throws IllegalArgumentException;
+
+ /**
* Return true if the portal object is in a dashboard context for the specified user.
*
* @param object
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/DashboardCommandFactory.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/DashboardCommandFactory.java 2007-01-09
14:43:56 UTC (rev 5971)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/DashboardCommandFactory.java 2007-01-10
02:17:27 UTC (rev 5972)
@@ -33,43 +33,8 @@
*/
public class DashboardCommandFactory extends AbstractCommandFactory
{
-
- /** . */
- private String dashboardId;
-
- /** . */
- private PortalObjectId objectId;
-
- public String getDashboardId()
- {
- return dashboardId;
- }
-
- public void setDashboardId(String dashboardId)
- {
- this.dashboardId = dashboardId;
- }
-
-
- protected void createService() throws Exception
- {
- super.createService();
-
- //
- objectId = PortalObjectId.parse(dashboardId, PortalObjectId.LEGACY_FORMAT);
- }
-
-
- protected void destroyService() throws Exception
- {
- objectId = null;
-
- //
- super.destroyService();
- }
-
public ControllerCommand doMapping(ServerInvocation invocation, String
portalContextPath, String portalRequestPath)
{
- return new ViewDashboardCommand(objectId);
+ return new ViewDashboardCommand();
}
}
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java 2007-01-09
14:43:56 UTC (rev 5971)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java 2007-01-10
02:17:27 UTC (rev 5972)
@@ -122,11 +122,12 @@
*
* @param parent the parent of the copy
* @param name the name of the child
+ * @param deep true copies recursively children
* @return the newly created node child of the specified parent
* @throws DuplicatePortalObjectException if the specified parent has already a node
with such a name
* @throws IllegalArgumentException if the specified parent is null
*/
- PortalObject copy(PortalObject parent, String name) throws
DuplicatePortalObjectException, IllegalArgumentException;
+ PortalObject copy(PortalObject parent, String name, boolean deep) throws
DuplicatePortalObjectException, IllegalArgumentException;
/**
* Return a property of that object.
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java 2007-01-09
14:43:56 UTC (rev 5971)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java 2007-01-10
02:17:27 UTC (rev 5972)
@@ -24,10 +24,12 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.model.portal.command.InvokePortletWindowActionCommand;
import org.jboss.portal.core.model.portal.command.InvokePortletWindowRenderCommand;
import org.jboss.portal.core.model.portal.command.RenderPageCommand;
+import org.jboss.portal.core.model.portal.command.ImportPageToDashboardCommand;
import org.jboss.portal.core.controller.command.mapper.AbstractCommandFactory;
import org.jboss.portal.portlet.impl.PortletRequestDecoder;
import org.jboss.portal.server.ServerInvocation;
@@ -36,6 +38,8 @@
import org.jboss.portal.server.servlet.PathParser;
import org.jboss.portal.theme.navigation.WindowNavigationalState;
+import java.util.Map;
+
/**
* This command mapper is used to map portal objects living in a container to
<code>org.jboss.portal.core.command.RenderPageCommand</code>
*
@@ -104,13 +108,16 @@
ControllerCommand cmd = null;
//
+ ParameterMap queryParams = invocation.getServerContext().getQueryParameterMap();
+
+ //
if (target instanceof Window)
{
Window window = (Window)target;
//
PortletRequestDecoder decoder = new PortletRequestDecoder();
- decoder.decode(invocation.getServerContext().getQueryParameterMap(),
invocation.getServerContext().getBodyParameterMap());
+ decoder.decode(queryParams,
invocation.getServerContext().getBodyParameterMap());
// Get the window navigational state
WindowNavigationalState windowNavState =
(WindowNavigationalState)invocation.getAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE,
window.getId() + "_window");
@@ -164,7 +171,19 @@
{
Page page = (Page)target;
PortalObjectId id = page.getId();
- cmd = new RenderPageCommand(id);
+
+ //
+ String action = queryParams.getValue("action");
+
+ //
+ if ("import".equals(action))
+ {
+ cmd = new ImportPageToDashboardCommand(id);
+ }
+ else
+ {
+ cmd = new RenderPageCommand(id);
+ }
}
}
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.java 2007-01-09
14:43:56 UTC (rev 5971)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.java 2007-01-10
02:17:27 UTC (rev 5972)
@@ -31,6 +31,7 @@
import org.jboss.portal.core.model.portal.command.InvokePortletWindowRenderCommand;
import org.jboss.portal.core.model.portal.command.RenderPageCommand;
import org.jboss.portal.core.model.portal.command.PortalObjectCommand;
+import org.jboss.portal.core.model.portal.command.ImportPageToDashboardCommand;
import org.jboss.portal.core.controller.command.mapper.URLFactoryDelegate;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.impl.PortletRequestEncoder;
@@ -73,19 +74,20 @@
//
if (cmd instanceof PortalObjectCommand)
{
+ PortalObjectCommand poc = (PortalObjectCommand)cmd;
+
+ // Get base URL
+ ServerURL url = getBaseURL(poc.getTargetId());
+
+ // Customize further more
if (cmd instanceof RenderPageCommand)
{
- RenderPageCommand rpCmd = (RenderPageCommand)cmd;
- PortalObjectId pageId = rpCmd.getTargetId();
- return getBaseURL(pageId);
+ // Nothing for now, we let the statement just to show that it handles page
rendering commands
}
else if (cmd instanceof InvokeWindowCommand)
{
InvokeWindowCommand iwaCmd = (InvokeWindowCommand)cmd;
- // The base URL
- AbstractServerURL serverURL = getBaseURL(iwaCmd.getTargetId());
-
Mode mode = iwaCmd.getMode();
WindowState windowState = iwaCmd.getWindowState();
@@ -94,17 +96,21 @@
{
StateString interactionState =
((InvokePortletWindowActionCommand)iwaCmd).getInteractionState();
StateString navigationalState =
((InvokePortletWindowActionCommand)iwaCmd).getNavigationalState();
- PortletRequestEncoder.encodeAction(serverURL, navigationalState,
interactionState, mode, windowState);
+ PortletRequestEncoder.encodeAction(url, navigationalState,
interactionState, mode, windowState);
}
else
{
StateString navigationalState =
((InvokePortletWindowRenderCommand)iwaCmd).getNavigationalState();
- PortletRequestEncoder.encodeRender(serverURL, navigationalState, mode,
windowState);
+ PortletRequestEncoder.encodeRender(url, navigationalState, mode,
windowState);
}
+ }
+ else if (cmd instanceof ImportPageToDashboardCommand)
+ {
+ url.setParameterValue("action", "import");
+ }
- //
- return serverURL;
- }
+ //
+ return url;
}
//
Added:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/DashboardCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/command/DashboardCommand.java 2007-01-09
14:43:56 UTC (rev 5971)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/command/DashboardCommand.java 2007-01-10
02:17:27 UTC (rev 5972)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * 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.model.portal.command;
+
+import org.jboss.portal.core.controller.ControllerCommand;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class DashboardCommand extends ControllerCommand
+{
+}
Added:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/ImportPageToDashboardCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/command/ImportPageToDashboardCommand.java 2007-01-09
14:43:56 UTC (rev 5971)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/command/ImportPageToDashboardCommand.java 2007-01-10
02:17:27 UTC (rev 5972)
@@ -0,0 +1,111 @@
+/******************************************************************************
+ * 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.model.portal.command;
+
+import org.jboss.portal.core.controller.command.info.CommandInfo;
+import org.jboss.portal.core.controller.command.info.ActionCommandInfo;
+import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.Portal;
+import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.command.response.UpdateViewResponse;
+import org.jboss.portal.core.model.CustomizationManager;
+import org.jboss.portal.identity.User;
+
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ImportPageToDashboardCommand extends PageCommand
+{
+
+ /** . */
+ private static final CommandInfo info = new ActionCommandInfo(true, "view",
false);
+
+ /** . */
+ private Portal dashboardPortal;
+
+ public ImportPageToDashboardCommand(PortalObjectId pageId)
+ {
+ super(pageId);
+ }
+
+ public CommandInfo getInfo()
+ {
+ return info;
+ }
+
+ public void create() throws ControllerException
+ {
+ super.create();
+
+ //
+ CustomizationManager manager =
getControllerContext().getController().getCustomizationManager();
+
+ //
+ User user = getControllerContext().getUser();
+
+ //
+ dashboardPortal = manager.getDashboard(user);
+ }
+
+ public Object execute() throws ControllerException
+ {
+ String name = target.getName();
+
+ //
+ PortalObject dashboardPage = dashboardPortal.getChild(name);
+
+ //
+ if (dashboardPage == null)
+ {
+ try
+ {
+ // Copy page
+ dashboardPage = target.copy(dashboardPortal, name, false);
+
+ // Copy children windows only
+ for (Iterator i = target.getChildren().iterator();i.hasNext();)
+ {
+ PortalObject child = (PortalObject)i.next();
+ if (child.getType() == PortalObject.TYPE_WINDOW)
+ {
+ child.copy(dashboardPage, child.getName(), false);
+ }
+ }
+ }
+ catch (DuplicatePortalObjectException e)
+ {
+ log.error("Unexpected exception during the copy of a page to a dashboard
page", e);
+
+ //
+ throw new ControllerException(e);
+ }
+ }
+
+ return new UpdateViewResponse(dashboardPage.getId());
+ }
+}
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java 2007-01-09
14:43:56 UTC (rev 5971)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java 2007-01-10
02:17:27 UTC (rev 5972)
@@ -110,7 +110,7 @@
{
if (dashboard == null)
{
- User user =
(User)getControllerContext().getServerInvocation().getRequest().getUser();
+ User user = getControllerContext().getUser();
boolean tmp =
context.getController().getCustomizationManager().isDashboard(target, user);
dashboard = Boolean.valueOf(tmp);
}
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java 2007-01-09
14:43:56 UTC (rev 5971)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java 2007-01-10
02:17:27 UTC (rev 5972)
@@ -228,7 +228,7 @@
if (personalizable)
{
ControllerContext controllerCtx = (ControllerContext)getContext();
- User user =
(User)controllerCtx.getServerInvocation().getRequest().getUser();
+ User user = controllerCtx.getUser();
if (user != null)
{
UserProfileModule userProfileModule = null;
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/ViewDashboardCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/command/ViewDashboardCommand.java 2007-01-09
14:43:56 UTC (rev 5971)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/command/ViewDashboardCommand.java 2007-01-10
02:17:27 UTC (rev 5972)
@@ -27,19 +27,18 @@
import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
import org.jboss.portal.core.model.portal.command.response.UpdateViewResponse;
-import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
import org.jboss.portal.core.model.portal.Page;
-import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.Portal;
-import org.jboss.portal.core.model.portal.PortalContainer;
+import org.jboss.portal.core.model.CustomizationManager;
import org.jboss.portal.security.PortalSecurityException;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
+import org.jboss.portal.identity.User;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class ViewDashboardCommand extends PortalObjectCommand
+public class ViewDashboardCommand extends DashboardCommand
{
/** . */
@@ -52,14 +51,10 @@
private Page dashboardPage;
/** . */
- private PortalContainer dashboardContext;
+ private User user;
- /** . */
- private String userId;
-
- public ViewDashboardCommand(PortalObjectId portalId)
+ public ViewDashboardCommand()
{
- super(portalId);
}
public CommandInfo getInfo()
@@ -67,11 +62,6 @@
return info;
}
- public PortalContainer getDashboardContext()
- {
- return dashboardContext;
- }
-
public Portal getDashboardPortal()
{
return dashboardPortal;
@@ -93,37 +83,21 @@
super.create();
//
- dashboardContext = (PortalContainer)getTarget();
+ CustomizationManager manager =
getControllerContext().getController().getCustomizationManager();
//
- userId =
getControllerContext().getServerInvocation().getServerContext().getClientRequest().getRemoteUser();
+ user = getControllerContext().getUser();
- try
- {
- //
- dashboardPortal = dashboardContext.getPortal(userId);
+ //
+ dashboardPortal = manager.getDashboard(user);
- // Create if not exist
- if (dashboardPortal == null)
- {
- Portal templatePortal =
(Portal)context.getController().getPortalObjectContainer().getObject(new
PortalObjectId("/template", PortalObjectId.CANONICAL_FORMAT));
-
- // Copy the template portal
- dashboardPortal = (Portal)templatePortal.copy(dashboardContext, userId);
- }
-
- //
- dashboardPage = dashboardPortal.getDefaultPage();
- }
- catch (DuplicatePortalObjectException e)
- {
- throw new ControllerException(e);
- }
+ //
+ dashboardPage = dashboardPortal.getDefaultPage();
}
public void enforceSecurity(PortalAuthorizationManager pam) throws
ControllerSecurityException, PortalSecurityException
{
- if (userId == null)
+ if (user == null)
{
throw new ControllerSecurityException("User needs to be authenticated to
view a dashboard");
}
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/WindowCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/command/WindowCommand.java 2007-01-09
14:43:56 UTC (rev 5971)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/command/WindowCommand.java 2007-01-10
02:17:27 UTC (rev 5972)
@@ -102,7 +102,7 @@
}
// We need the user id
- User user =
(User)getControllerContext().getServerInvocation().getRequest().getUser();
+ User user = getControllerContext().getUser();
// Get instance
instance = context.getController().getCustomizationManager().getInstance(window,
user);
Modified:
trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java 2007-01-09
14:43:56 UTC (rev 5971)
+++
trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java 2007-01-10
02:17:27 UTC (rev 5972)
@@ -279,7 +279,7 @@
hibernate.openSession();
ctx = (PortalContainer)container.getRootObject();
portal = (Portal)container.getObject(defaultId);
- portal = (Portal)portal.copy(ctx, "copy");
+ portal = (Portal)portal.copy(ctx, "copy", true);
assertNotNull(portal);
assertEquals("copy", portal.getName());
assertEquals(Collections.singleton(WindowState.NORMAL),
portal.getSupportedWindowStates());
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-01-09
14:43:56 UTC (rev 5971)
+++ trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-01-10
02:17:27 UTC (rev 5972)
@@ -612,7 +612,11 @@
<depends
optional-attribute-name="InstanceContainer"
proxy-type="attribute">portal:container=Instance</depends>
+ <depends
+ optional-attribute-name="PortalObjectContainer"
+
proxy-type="attribute">portal:container=PortalObject</depends>
<depends>portal:service=Module,type=IdentityServiceController</depends>
+ <attribute name="DashboardContextId">dashboard</attribute>
</mbean>
<!-- Command factories -->
@@ -688,7 +692,6 @@
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
- <attribute name="DashboardId">dashboard</attribute>
</mbean>
<mbean
code="org.jboss.portal.core.controller.command.mapper.CommandFactoryDelegate"
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/Parameters.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/Parameters.java 2007-01-09 14:43:56
UTC (rev 5971)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/Parameters.java 2007-01-10 02:17:27
UTC (rev 5972)
@@ -97,60 +97,6 @@
}
/**
- * Return the parameter value or null if it does not exist.
- *
- * @param name the parameter name
- * @return the parameter value or null if it does not exist
- * @throws NullPointerException if the name is null
- */
- public String getValue(String name) throws IllegalArgumentException
- {
- String[] value = (String[])get(name);
- return value == null ? null : value[0];
- }
-
- /**
- * Return the parameter values or null if it does not exist.
- *
- * @param name the value to get
- * @return the parameter values
- * @throws NullPointerException if the name is null
- */
- public String[] getValues(String name) throws IllegalArgumentException
- {
- if (name == null)
- {
- throw new IllegalArgumentException("No null name");
- }
- return (String[])get(name);
- }
-
- /**
- * Set the a parameter value.
- *
- * @param name the parameter name
- * @param value the parameter value
- * @throws NullPointerException if the name or the value is null
- */
- public void setValue(String name, String value)
- {
- put(name, new String[]{value});
- }
-
- /**
- * Set the parameter values. This method does not make a defensive copy of the
values.
- *
- * @param name the parameter name
- * @param values the parameter values
- * @throws NullPointerException if the name or the value is null
- * @throws IllegalArgumentException if the values length is zero or contains a null
element
- */
- public void setValues(String name, String[] values) throws NullPointerException,
IllegalArgumentException
- {
- put(name, values);
- }
-
- /**
* Append the content of the argument map to that map. If both maps contains an entry
sharing the same key, then the
* string arrays or the two entries will be concatenated into a single array. Each
entry present on the argument map
* and not in the current map will be kept as is. The argument validation is performed
before the state is updated.
Modified:
trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManager.java
===================================================================
---
trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManager.java 2007-01-09
14:43:56 UTC (rev 5971)
+++
trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManager.java 2007-01-10
02:17:27 UTC (rev 5972)
@@ -148,6 +148,9 @@
//
Principal[] principals;
+ // Always check the unckeded permission container
+ checkRoleConfig(contextID, SecurityConstants.UNCHECKED_ROLE_NAME);
+
//
if (currentSubject != null)
{
@@ -177,8 +180,6 @@
}
else
{
- // Lazy check the unckeded permission container
- checkRoleConfig(contextID, SecurityConstants.UNCHECKED_ROLE_NAME);
principals = new Principal[0];
}
Modified:
trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManagerFactory.java
===================================================================
---
trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManagerFactory.java 2007-01-09
14:43:56 UTC (rev 5971)
+++
trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManagerFactory.java 2007-01-10
02:17:27 UTC (rev 5972)
@@ -83,7 +83,7 @@
else
{
// New config
- log.debug("No existing delegating policy in place, adding one configured
with the PortalPermission clas");
+ log.debug("No existing delegating policy in place, adding one configured
with the PortalPermission class");
DelegatingPolicy dp = DelegatingPolicy.getInstance();
dp.setExternalPermissionTypes(new Class[]{PortalPermission.class});
Policy.setPolicy(dp);
Modified: trunk/server/src/main/org/jboss/portal/server/ServerInvocationContext.java
===================================================================
--- trunk/server/src/main/org/jboss/portal/server/ServerInvocationContext.java 2007-01-09
14:43:56 UTC (rev 5971)
+++ trunk/server/src/main/org/jboss/portal/server/ServerInvocationContext.java 2007-01-10
02:17:27 UTC (rev 5972)
@@ -23,12 +23,12 @@
package org.jboss.portal.server;
import org.jboss.portal.common.invocation.InvocationContext;
+import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.server.request.URLFormat;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import java.util.Map;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -36,26 +36,38 @@
*/
public interface ServerInvocationContext extends InvocationContext
{
- /** Return the request that made the connection to the server. */
+ /**
+ * Return the request that made the connection to the server.
+ *
+ * @return the http request.
+ */
HttpServletRequest getClientRequest();
/**
- * The original servlet response.
+ * Return the response that will be used by the server.
*
* @return the http response
*/
HttpServletResponse getClientResponse();
- /** Return the parameter map decoded form the query string. */
- Map getQueryParameterMap();
+ /**
+ * Return the parameter map decoded form the query string.
+ *
+ * @returns the query parameter map
+ */
+ ParameterMap getQueryParameterMap();
/**
* Return the parameter map for the body if the request was a POST with the content
type x-www-formurlencoded
* otherwise return null.
*/
- Map getBodyParameterMap();
+ ParameterMap getBodyParameterMap();
- /** Return the normalized media type of the request or null if none has been provided
by the client. */
+ /**
+ * Return the normalized media type of the request or null if none has been provided
by the client.
+ *
+ * @return the media type
+ */
String getMediaType();
/**
@@ -63,13 +75,25 @@
*/
// Charset getCharset();
- /** Return the url context of this request. */
+ /**
+ * Return the url context of this request.
+ *
+ * @return the url context
+ */
URLContext getURLContext();
- /** Return the value of the portal request path for this request. */
+ /**
+ * Return the value of the portal request path for this request.
+ *
+ * @return the portal request path
+ */
String getPortalRequestPath();
- /** Return the value of the portal context path for this request. */
+ /**
+ * Return the value of the portal context path for this request.
+ *
+ * @return the portal context path
+ */
String getPortalContextPath();
/**
Modified:
trunk/server/src/main/org/jboss/portal/server/impl/ServerInvocationContextImpl.java
===================================================================
---
trunk/server/src/main/org/jboss/portal/server/impl/ServerInvocationContextImpl.java 2007-01-09
14:43:56 UTC (rev 5971)
+++
trunk/server/src/main/org/jboss/portal/server/impl/ServerInvocationContextImpl.java 2007-01-10
02:17:27 UTC (rev 5972)
@@ -25,6 +25,7 @@
import org.jboss.portal.common.invocation.AbstractInvocationContext;
import org.jboss.portal.common.text.CharBuffer;
import org.jboss.portal.common.text.FastURLEncoder;
+import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.server.PortalConstants;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.server.ServerInvocationContext;
@@ -63,10 +64,10 @@
private String mediaType;
/** The query parameter map. */
- private Map queryParameterMap;
+ private ParameterMap queryParameterMap;
/** The body parameter map or null. */
- private Map bodyParameterMap;
+ private ParameterMap bodyParameterMap;
/** The url context. */
private URLContext urlContext;
@@ -104,8 +105,8 @@
this.resp = resp;
this.portalRequestPath = portalRequestPath;
this.portalContextPath = portalContextPath;
- this.queryParameterMap = queryParameterMap;
- this.bodyParameterMap = bodyParameterMap;
+ this.queryParameterMap = new InternalParameterMap(queryParameterMap);
+ this.bodyParameterMap = bodyParameterMap != null ? new
InternalParameterMap(bodyParameterMap) : null;
this.urlContext = urlContext;
this.mediaType = mediaType;
this.buffers = new Buffer[16];
@@ -157,12 +158,12 @@
return urlContext;
}
- public Map getQueryParameterMap()
+ public ParameterMap getQueryParameterMap()
{
return queryParameterMap;
}
- public Map getBodyParameterMap()
+ public ParameterMap getBodyParameterMap()
{
return bodyParameterMap;
}
@@ -272,4 +273,21 @@
return s;
}
}
+
+ private static class InternalParameterMap extends ParameterMap
+ {
+
+ /** . */
+ private Map delegate;
+
+ public InternalParameterMap(Map delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ protected Map getDelegate()
+ {
+ return delegate;
+ }
+ }
}
Modified: trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java
===================================================================
--- trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java 2007-01-09
14:43:56 UTC (rev 5971)
+++ trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java 2007-01-10
02:17:27 UTC (rev 5972)
@@ -29,6 +29,7 @@
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.common.util.Exceptions;
import org.jboss.portal.common.util.URLTools;
+import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.server.PortalConstants;
import org.jboss.portal.server.RequestController;
import org.jboss.portal.server.RequestControllerDispatcher;