[jboss-svn-commits] JBoss Portal SVN: r5134 - in trunk: api/src/main/org/jboss/portal/api/node core/src/main/org/jboss/portal/core core/src/main/org/jboss/portal/core/aspects/controller core/src/main/org/jboss/portal/core/cms/command core/src/main/org/jboss/portal/core/command core/src/main/org/jboss/portal/core/command/info core/src/main/org/jboss/portal/core/command/portlet core/src/main/org/jboss/portal/core/impl/model/portal core/src/main/org/jboss/portal/core/model/portal core/src/main/org/jboss/portal/core/portlet/cms/admin core/src/main/org/jboss/portlet theme/src/main/org/jboss/portal/theme theme/src/main/org/jboss/portal/theme/page
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Sep 4 08:44:12 EDT 2006
Author: julien at jboss.com
Date: 2006-09-04 08:43:32 -0400 (Mon, 04 Sep 2006)
New Revision: 5134
Added:
trunk/core/src/main/org/jboss/portal/core/command/info/
trunk/core/src/main/org/jboss/portal/core/command/info/ActionCommandInfo.java
trunk/core/src/main/org/jboss/portal/core/command/info/CommandInfo.java
trunk/core/src/main/org/jboss/portal/core/command/info/ViewCommandInfo.java
trunk/theme/src/main/org/jboss/portal/theme/PageRendition.java
Removed:
trunk/core/src/main/org/jboss/portal/core/command/CommandInfo.java
trunk/core/src/main/org/jboss/portal/core/command/ExecutionContext.java
trunk/core/src/main/org/jboss/portal/core/command/InvokeWindowMoveCommand.java
trunk/core/src/main/org/jboss/portal/core/command/RenderRegionCommand.java
trunk/core/src/main/org/jboss/portal/core/command/RenderWindowContextCommand.java
trunk/theme/src/main/org/jboss/portal/theme/page/UnusableMarkupResult.java
Modified:
trunk/api/src/main/org/jboss/portal/api/node/PortalNode.java
trunk/core/src/main/org/jboss/portal/core/CoreController.java
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageNavigationInterceptor.java
trunk/core/src/main/org/jboss/portal/core/cms/command/StreamContentCommand.java
trunk/core/src/main/org/jboss/portal/core/command/CommandContext.java
trunk/core/src/main/org/jboss/portal/core/command/ControllerCommand.java
trunk/core/src/main/org/jboss/portal/core/command/InvokeWindowActionCommand.java
trunk/core/src/main/org/jboss/portal/core/command/InvokeWindowRenderCommand.java
trunk/core/src/main/org/jboss/portal/core/command/MarkupCommand.java
trunk/core/src/main/org/jboss/portal/core/command/RenderPageCommand.java
trunk/core/src/main/org/jboss/portal/core/command/RenderWindowCommand.java
trunk/core/src/main/org/jboss/portal/core/command/WindowCommand.java
trunk/core/src/main/org/jboss/portal/core/command/portlet/CorePortletInvocationContext.java
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java
trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java
trunk/core/src/main/org/jboss/portlet/JBossRenderRequest.java
Log:
- ControllerCommand do not take care of updating the response, it is delegated in the controller instead, command just perform a state modifying job
- moving most of the output logic to the controller class in order to handle everything in one place to order readility
- removed ExecutionContext to simplify the controller logic as a side effect of previous points
Modified: trunk/api/src/main/org/jboss/portal/api/node/PortalNode.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/api/node/PortalNode.java 2006-09-02 20:17:57 UTC (rev 5133)
+++ trunk/api/src/main/org/jboss/portal/api/node/PortalNode.java 2006-09-04 12:43:32 UTC (rev 5134)
@@ -22,6 +22,7 @@
package org.jboss.portal.api.node;
import java.util.Collection;
+import java.util.Map;
/**
* @author <a href="mailto:julien at jboss.org">Julien Viet</a>
@@ -44,31 +45,44 @@
/**
* Return the node type.
+ *
+ * @return the node type
*/
int getType();
/**
* Return the root node of this node.
+ *
+ * @return the root node
*/
PortalNode getRoot();
/**
* Return the parent node of this node.
+ *
+ * @return the parent node
*/
PortalNode getParent();
/**
* Return the node name relative to its parent.
+ *
+ * @return the node name
*/
String getName();
/**
* Return a child of this object.
+ *
+ * @param name the child name
+ * @return a named child
*/
PortalNode getChild(String name);
/**
* Return the children of this object.
+ *
+ * @return the children
*/
Collection getChildren();
@@ -79,4 +93,11 @@
* @return the relative object
*/
PortalNode resolve(String relativePath);
+
+ /**
+ * Returns the node properties.
+ *
+ * @return the node properties
+ */
+ Map getProperties();
}
Modified: trunk/core/src/main/org/jboss/portal/core/CoreController.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/CoreController.java 2006-09-02 20:17:57 UTC (rev 5133)
+++ trunk/core/src/main/org/jboss/portal/core/CoreController.java 2006-09-04 12:43:32 UTC (rev 5134)
@@ -25,21 +25,40 @@
import org.jboss.portal.common.system.AbstractJBossService;
import org.jboss.portal.core.command.CommandException;
import org.jboss.portal.core.command.ControllerCommand;
-import org.jboss.portal.core.command.ErrorResultException;
-import org.jboss.portal.core.command.ExecutionContext;
import org.jboss.portal.core.command.ObjectNotFoundException;
+import org.jboss.portal.core.command.RenderPageCommand;
+import org.jboss.portal.core.command.InvokeWindowActionCommand;
+import org.jboss.portal.core.command.InvokeWindowRenderCommand;
+import org.jboss.portal.core.command.CommandContext;
+import org.jboss.portal.core.command.info.CommandInfo;
+import org.jboss.portal.core.command.info.ActionCommandInfo;
import org.jboss.portal.core.command.mapper.CommandFactory;
import org.jboss.portal.core.command.mapper.URLFactory;
import org.jboss.portal.core.model.instance.InstanceContainer;
import org.jboss.portal.core.model.portal.PortalObjectContainer;
+import org.jboss.portal.core.model.portal.Page;
+import org.jboss.portal.core.output.SignOutResult;
+import org.jboss.portal.core.cms.command.StreamContentCommand;
import org.jboss.portal.server.RequestController;
import org.jboss.portal.server.ServerException;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.server.ServerURL;
import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.theme.page.PageService;
+import org.jboss.portal.theme.PageRendition;
+import org.jboss.portal.portlet.result.Result;
+import org.jboss.portal.portlet.result.RenderResult;
+import org.jboss.portal.portlet.result.HTTPRedirectionResult;
+import org.jboss.portal.portlet.result.InsufficientTransportGuaranteeResult;
+import org.jboss.portal.portlet.result.InsufficientPrivilegesResult;
+import org.jboss.portal.portlet.result.ErrorResult;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.Mode;
import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletException;
import java.io.IOException;
/**
@@ -51,11 +70,22 @@
public class CoreController extends AbstractJBossService implements RequestController
{
+ /** . */
private PageService pageService;
+
+ /** . */
private CommandFactory commandFactory;
+
+ /** . */
private URLFactory urlFactory;
+
+ /** . */
private InterceptorStackFactory stackFactory;
+
+ /** . */
private PortalObjectContainer portalObjectContainer;
+
+ /** . */
private InstanceContainer instanceContainer;
public InstanceContainer getInstanceContainer()
@@ -121,15 +151,50 @@
public void handle(ServerInvocation invocation) throws ServerException
{
URLContext urlContext = invocation.getServerContext().getURLContext();
- ExecutionContext ec = new ExecutionContext(this, invocation);
+ CommandContext commandContext = new CommandContext(invocation, this);
- ControllerCommand cmd = null;
+ // Invoke the chain that creates the initial command
+ ControllerCommand cmd = commandFactory.doMapping(invocation, invocation.getServerContext().getPortalContextPath(), invocation.getServerContext().getPortalRequestPath());
+
+ //
+ if (cmd == null)
+ {
+ // Handle that case
+ throw new ServerException("No valid command");
+ }
+
try
{
- cmd = commandFactory.doMapping(invocation, invocation.getServerContext().getPortalContextPath(), invocation.getServerContext().getPortalRequestPath());
- ec.execute(cmd );
+ while (true)
+ {
+ // Execute command
+ commandContext.execute(cmd);
+
+ // Handle the result
+ Forward forward = handleResult(cmd, invocation);
+ if (forward == null)
+ {
+ break;
+ }
+
+ // Redirect or execute in the same server invocation
+ if (forward.isRedirect(invocation))
+ {
+ String url = commandContext.encodeURL(forward.getCommand(), forward.getURLContext(), null);
+ if (url == null)
+ {
+ throw new CommandException();
+ }
+ sendRedirect(invocation, url);
+ break;
+ }
+ else
+ {
+ cmd = forward.getCommand();
+ }
+ }
}
- catch (org.jboss.portal.core.command.SecurityException e)
+ catch (SecurityException e)
{
if (urlContext.isAuthenticated())
{
@@ -143,10 +208,6 @@
sendRedirect(invocation, url);
}
}
- catch (ErrorResultException e)
- {
- sendStatusCode(invocation, HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- }
catch (ObjectNotFoundException e)
{
sendStatusCode(invocation, HttpServletResponse.SC_NOT_FOUND);
@@ -155,8 +216,115 @@
{
throw new ServerException(e);
}
+ catch (ServletException e)
+ {
+ throw new ServerException(e);
+ }
+ catch (IOException e)
+ {
+ throw new ServerException(e);
+ }
}
+ /**
+ *
+ */
+ private Forward handleResult(ControllerCommand cmd, ServerInvocation invocation) throws IOException, ServletException, ServerException
+ {
+ if (cmd instanceof RenderPageCommand)
+ {
+ PageRendition rendition = ((RenderPageCommand)cmd).getResult();
+ rendition.render(invocation);
+ return null;
+ }
+ else if (cmd instanceof InvokeWindowActionCommand)
+ {
+ InvokeWindowActionCommand iwac = (InvokeWindowActionCommand)cmd;
+ PortletInvocation pinv = iwac.getInvocation();
+
+ //
+ Result result = pinv.getResult();
+
+ //
+ if (result instanceof RenderResult)
+ {
+ RenderResult renderResult = (RenderResult)result;
+ StateString portletNavState = renderResult.getNavigationalState();
+ WindowState windowState = renderResult.getWindowState();
+ Mode mode = renderResult.getMode();
+ InvokeWindowRenderCommand iwrc = new InvokeWindowRenderCommand(
+ iwac.getWindowRef(),
+ mode,
+ windowState,
+ portletNavState);
+ return new Forward(iwrc, null);
+ }
+ else if (result instanceof HTTPRedirectionResult)
+ {
+ HTTPRedirectionResult redirectionResult = (HTTPRedirectionResult)result;
+ String url = redirectionResult.getLocation();
+ sendRedirect(invocation, url);
+ }
+ else if (result instanceof InsufficientTransportGuaranteeResult)
+ {
+ boolean authenticated = invocation.getServerContext().getURLContext().isAuthenticated();
+ return new Forward(iwac, URLContext.newInstance(true, authenticated));
+ }
+ else if (result instanceof InsufficientPrivilegesResult)
+ {
+ boolean authenticated = invocation.getServerContext().getURLContext().isAuthenticated();
+ return new Forward(iwac, URLContext.newInstance(true, authenticated));
+ }
+ else if (result instanceof SignOutResult)
+ {
+ SignOutResult signOut = (SignOutResult)result;
+
+ // Indicate that we want a sign out to be done
+ invocation.getResponse().setWantSignOut(true);
+
+ // Get the optional signout location
+ String location = signOut.getLocation();
+
+ //
+ if (location == null)
+ {
+ // Redirect to the same page
+ Page page = iwac.getPage();
+ RenderPageCommand renderCmd = new RenderPageCommand(page.getId());
+ boolean secure = invocation.getServerContext().getURLContext().getSecure();
+ URLContext urlInfo = URLContext.newInstance(secure, false);
+ return new Forward(renderCmd, urlInfo);
+ }
+ else
+ {
+ sendRedirect(invocation, location);
+ }
+ }
+ else if (result instanceof ErrorResult)
+ {
+ ErrorResult error = (ErrorResult)result;
+ error.logErrorTo(log, "An portlet exception occured in portlet " + iwac.getInstance().getId());
+ sendStatusCode(invocation, HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+ }
+ else
+ {
+ throw new IllegalStateException();
+ }
+ }
+ else if (cmd instanceof InvokeWindowRenderCommand)
+ {
+ InvokeWindowRenderCommand iwrc = (InvokeWindowRenderCommand)cmd;
+ RenderPageCommand renderCmd = new RenderPageCommand(iwrc.getPage().getId());
+ return new Forward(renderCmd, null);
+ }
+ else if (cmd instanceof StreamContentCommand)
+ {
+ StreamContentCommand scc = (StreamContentCommand)cmd;
+ scc.stream(invocation);
+ }
+ return null;
+ }
+
private void sendStatusCode(ServerInvocation invocation, int sc) throws ServerException
{
try
@@ -182,4 +350,56 @@
throw new ServerException(e);
}
}
+
+ public static class Forward
+ {
+
+ /** . */
+ private final ControllerCommand cmd;
+
+ /** . */
+ private final URLContext urlCtx;
+
+ public Forward(ControllerCommand cmd, URLContext urlCtx)
+ {
+ this.cmd = cmd;
+ this.urlCtx = urlCtx;
+ }
+
+ public boolean isRedirect(ServerInvocation invocation)
+ {
+ CommandInfo cmdInfo = cmd.getInfo();
+ if (cmdInfo instanceof ActionCommandInfo && !((ActionCommandInfo)cmdInfo).isIdempotent())
+ {
+ return true;
+ }
+ else
+ {
+ boolean currentAuthenticated = invocation.getServerContext().getURLContext().isAuthenticated();
+ if (urlCtx != null && currentAuthenticated != urlCtx.isAuthenticated())
+ {
+ return true;
+ }
+ else
+ {
+ boolean currentSecure = invocation.getServerContext().getURLContext().getSecure();
+ if (urlCtx != null && urlCtx.getSecure() && !currentSecure)
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public ControllerCommand getCommand()
+ {
+ return cmd;
+ }
+
+ public URLContext getURLContext()
+ {
+ return urlCtx;
+ }
+ }
}
Modified: trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageNavigationInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageNavigationInterceptor.java 2006-09-02 20:17:57 UTC (rev 5133)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageNavigationInterceptor.java 2006-09-04 12:43:32 UTC (rev 5134)
@@ -52,7 +52,7 @@
{
if (cmd instanceof PortalObjectCommand)
{
- // Get the session out of the command
+ //
PortalObject target = ((PortalObjectCommand)cmd).getTarget();
while (target != null && PortalObject.TYPE_PAGE != target.getType() && target.getParent() != null)
{
@@ -68,8 +68,8 @@
try
{
- ServerInvocation sinv = ((CommandContext)cmd.getContext()).getExecutionContext().getServerInvocation();
- LayoutService layoutService = ((CommandContext)cmd.getContext()).getExecutionContext().getController().getPageService().getLayoutService();
+ ServerInvocation sinv = ((CommandContext)cmd.getContext()).getServerInvocation();
+ LayoutService layoutService = ((CommandContext)cmd.getContext()).getController().getPageService().getLayoutService();
AttributeResolver navCtx = cmd.getContext().getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
ensurePageNavigationalState(layoutService, navCtx, sinv, page);
}
Modified: trunk/core/src/main/org/jboss/portal/core/cms/command/StreamContentCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/cms/command/StreamContentCommand.java 2006-09-02 20:17:57 UTC (rev 5133)
+++ trunk/core/src/main/org/jboss/portal/core/cms/command/StreamContentCommand.java 2006-09-04 12:43:32 UTC (rev 5134)
@@ -28,7 +28,8 @@
import org.jboss.portal.cms.model.Content;
import org.jboss.portal.cms.model.File;
import org.jboss.portal.common.invocation.InvocationException;
-import org.jboss.portal.core.command.CommandInfo;
+import org.jboss.portal.core.command.info.CommandInfo;
+import org.jboss.portal.core.command.info.ViewCommandInfo;
import org.jboss.portal.core.command.ControllerCommand;
import org.jboss.portal.server.ServerInvocation;
@@ -48,7 +49,7 @@
public class StreamContentCommand extends ControllerCommand
{
- private static final CommandInfo info = new CommandInfo(false, null, true);
+ private static final CommandInfo info = new ViewCommandInfo(false, null);
private String path;
@@ -70,27 +71,16 @@
public void execute() throws InvocationException
{
- ServerInvocation serverInvocation = context.getExecutionContext().getServerInvocation();
+ }
+
+ public void stream(ServerInvocation serverInvocation)
+ {
HttpServletResponse resp = serverInvocation.getServerContext().getClientResponse();
try
{
MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
CMS CMSService = (CMS) MBeanProxy.get(CMS.class, new ObjectName("portal:service=CMS"), mbeanServer);
-
-/*
- Command itemExistsCMD = CMSService.getCommandFactory().createItemExistsCommand(path + "/" + serverInvocation.getRequest().getLocale().getLanguage());
- Boolean bExists = (Boolean) CMSService.execute(itemExistsCMD);
- Command getCMD;
- if(bExists.booleanValue())
- {
- getCMD = CMSService.getCommandFactory().createFileGetCommand(path, serverInvocation.getRequest().getLocale());
- }
- else
- {
- getCMD = CMSService.getCommandFactory().createFileGetCommand(path, new Locale(CMSService.getDefaultLocale()));
- }
-*/
Command getCMD = CMSService.getCommandFactory().createFileGetCommand(path, serverInvocation.getRequest().getLocale());
File file = (File) CMSService.execute(getCMD);
if(file == null)
@@ -98,10 +88,7 @@
getCMD = CMSService.getCommandFactory().createFileGetCommand(path, new Locale(CMSService.getDefaultLocale()));
file = (File) CMSService.execute(getCMD);
}
-
-// File file = (File) CMSService.execute(getCMD);
Content content = file.getContent();
-
resp.setContentType(content.getMimeType());
ServletOutputStream sout = resp.getOutputStream();
InputStream is = content.getStream();
@@ -116,14 +103,13 @@
}
catch(Exception e)
{
- // e.printStackTrace();
try
{
resp.sendError(HttpServletResponse.SC_NOT_FOUND, e.getMessage());
}
catch(IOException e1)
{
- e1.printStackTrace();
+ log.error("An error occured when wanting to stream the command", e);
}
}
}
Modified: trunk/core/src/main/org/jboss/portal/core/command/CommandContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/command/CommandContext.java 2006-09-02 20:17:57 UTC (rev 5133)
+++ trunk/core/src/main/org/jboss/portal/core/command/CommandContext.java 2006-09-04 12:43:32 UTC (rev 5134)
@@ -22,6 +22,9 @@
package org.jboss.portal.core.command;
import org.jboss.portal.server.request.URLContext;
+import org.jboss.portal.server.request.URLFormat;
+import org.jboss.portal.server.ServerInvocation;
+import org.jboss.portal.server.ServerURL;
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.common.invocation.InterceptorStack;
import org.jboss.portal.common.invocation.AbstractInvocationContext;
@@ -34,49 +37,50 @@
public class CommandContext extends AbstractInvocationContext
{
- /** The command executed within this context. */
- protected final ControllerCommand command;
+ /** The server invocation. */
+ private ServerInvocation serverInvocation;
- /** The execution context. */
- protected ExecutionContext executionContext;
+ /** The controller. */
+ private CoreController controller;
- /** Depth of the forward chain. */
-// protected int forwardDepth;
+ /** Depth of the next chain. */
+ protected int nextDepth;
- public CommandContext(ExecutionContext executionContext, ControllerCommand command)
+ /** The forward command context if any. */
+ protected ControllerCommand forwardCommand;
+
+ /** . */
+ protected URLContext forwardURLContext;
+
+ public CommandContext(ServerInvocation serverInvocation, CoreController controller)
{
- if (executionContext == null)
+ if (serverInvocation == null)
{
throw new IllegalArgumentException();
}
- if (command == null)
+ if (controller == null)
{
throw new IllegalArgumentException();
}
//
- this.executionContext = executionContext;
- this.command = command;
+ this.serverInvocation = serverInvocation;
+ this.controller = controller;
//
- addResolver(ControllerCommand.REQUEST_SCOPE, executionContext.getServerInvocation().getContext());
- addResolver(ControllerCommand.SESSION_SCOPE, executionContext.getServerInvocation().getContext());
- addResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE, executionContext.getServerInvocation().getContext());
- addResolver(ControllerCommand.PRINCIPAL_SCOPE, executionContext.getServerInvocation().getContext());
+ addResolver(ControllerCommand.REQUEST_SCOPE, serverInvocation.getContext());
+ addResolver(ControllerCommand.SESSION_SCOPE, serverInvocation.getContext());
+ addResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE, serverInvocation.getContext());
+ addResolver(ControllerCommand.PRINCIPAL_SCOPE, serverInvocation.getContext());
}
- public ExecutionContext getExecutionContext()
+ public void execute(ControllerCommand command) throws CommandException
{
- return executionContext;
- }
+ if (command == null)
+ {
+ throw new IllegalArgumentException();
+ }
- public ControllerCommand getCommand()
- {
- return command;
- }
-
- void execute() throws CommandException
- {
//
command.setContext(this);
@@ -86,9 +90,10 @@
//
try
{
+ //
+ nextDepth++;
// Execute
- CoreController controller = executionContext.getController();
InterceptorStack commandStack = controller.getStackFactory().getInterceptorStack();
//
@@ -116,26 +121,58 @@
//
command.setContext(null);
+
+ //
+ nextDepth--;
}
}
+ public void forward(ControllerCommand forwardCommand, URLContext urlContext)
+ {
+ if (nextDepth > 1)
+ {
+ throw new IllegalStateException("A nested command cannot forward a command");
+ }
+ if (this.forwardCommand != null)
+ {
+ throw new IllegalStateException();
+ }
+ if (forwardCommand == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.forwardCommand = forwardCommand;
+ this.forwardURLContext = urlContext;
+ }
+
public void forward(ControllerCommand nextCommand) throws InvocationException
{
- executionContext.forward(nextCommand, null);
+ forward(nextCommand, null);
}
- public void forward(ControllerCommand nextCommand, URLContext urlContext) throws InvocationException
+ public String encodeURL(ControllerCommand cmd, URLContext urlContext, URLFormat format)
{
- executionContext.forward(nextCommand, urlContext);
+ ServerURL serverURL = controller.getURLFactory().doMapping(serverInvocation, cmd);
+ return serverInvocation.getResponse().encodeURL(serverURL, urlContext, format);
}
- public void chain(ControllerCommand nextCommand) throws CommandException
+ public ServerInvocation getServerInvocation()
{
- executionContext.chain(nextCommand);
+ return serverInvocation;
}
- public String toString()
+ public CoreController getController()
{
- return "CommandContext[" + command + "]";
+ return controller;
}
+
+ public ControllerCommand getForwardCommand()
+ {
+ return forwardCommand;
+ }
+
+ public URLContext getForwardURLContext()
+ {
+ return forwardURLContext;
+ }
}
Deleted: trunk/core/src/main/org/jboss/portal/core/command/CommandInfo.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/command/CommandInfo.java 2006-09-02 20:17:57 UTC (rev 5133)
+++ trunk/core/src/main/org/jboss/portal/core/command/CommandInfo.java 2006-09-04 12:43:32 UTC (rev 5134)
@@ -1,70 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., 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.command;
-
-/**
- * Runtime meta data for a command, this object is immutable.
- *
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class CommandInfo
-{
-
- private final boolean secured;
- private final String action;
- private final boolean idempotent;
-
- public CommandInfo(boolean secured, String action, boolean idempotent)
- {
- this.secured = secured;
- this.action = action;
- this.idempotent = idempotent;
- }
-
- /**
- * Is this command a secured command? If so, access rights to this command will be enforced via a security policy.
- * <p>The default returns false. Extending command classes need to set the <code>isSecured</code> member variable to true
- * in the command's constructor if they want to enforce access right checks for the command.</p>
- * @return true if this command requires security checks
- */
- public boolean isSecured()
- {
- return secured;
- }
-
- /**
- * @return the associated action of this command for security checks (is the user allowed to call this action...)
- */
- public String getAction()
- {
- return action;
- }
-
- /**
- * Return true if the command is idempotent, i.e it can be reinvoked again safely.
- */
- public boolean isIdempotent()
- {
- return idempotent;
- }
-}
Modified: trunk/core/src/main/org/jboss/portal/core/command/ControllerCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/command/ControllerCommand.java 2006-09-02 20:17:57 UTC (rev 5133)
+++ trunk/core/src/main/org/jboss/portal/core/command/ControllerCommand.java 2006-09-04 12:43:32 UTC (rev 5134)
@@ -29,6 +29,7 @@
import org.jboss.portal.common.invocation.InvocationHandler;
import org.jboss.portal.security.PortalSecurityException;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
+import org.jboss.portal.core.command.info.CommandInfo;
/**
* A controller command.
@@ -50,7 +51,7 @@
/** . */
public static final Scope NAVIGATIONAL_STATE_SCOPE = new Scope("navigationalstate");
-
+
/** . */
protected static Logger log = Logger.getLogger(ControllerCommand.class);
@@ -98,7 +99,7 @@
* @throws SecurityException
*/
public void enforceSecurity(PortalAuthorizationManager pam) throws SecurityException, PortalSecurityException
- {
+ {
}
/**
Deleted: trunk/core/src/main/org/jboss/portal/core/command/ExecutionContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/command/ExecutionContext.java 2006-09-02 20:17:57 UTC (rev 5133)
+++ trunk/core/src/main/org/jboss/portal/core/command/ExecutionContext.java 2006-09-04 12:43:32 UTC (rev 5134)
@@ -1,184 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., 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.command;
-
-import org.jboss.portal.core.CoreController;
-import org.jboss.portal.server.ServerInvocation;
-import org.jboss.portal.server.ServerURL;
-import org.jboss.portal.server.request.URLContext;
-import org.jboss.portal.server.request.URLFormat;
-
-import java.io.IOException;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class ExecutionContext
-{
-
- /** The server invocation. */
- private final ServerInvocation serverInvocation;
-
- /** The controller. */
- private final CoreController controller;
-
- /** Depth of the next chain. */
- protected int nextDepth;
-
- /** The forward command context if any. */
- protected CommandContext currentForwardCommandContext;
-
- /** . */
- protected URLContext currentForwardURLContext;
-
- public ExecutionContext(CoreController controller, ServerInvocation serverInvocation)
- {
- this.serverInvocation = serverInvocation;
- this.controller = controller;
- }
-
- public ServerInvocation getServerInvocation()
- {
- return serverInvocation;
- }
-
- public CoreController getController()
- {
- return controller;
- }
-
- public String encodeURL(ControllerCommand cmd, URLContext urlContext, URLFormat format)
- {
- ServerURL serverURL = controller.getURLFactory().doMapping(serverInvocation, cmd);
- return serverInvocation.getResponse().encodeURL(serverURL, urlContext, format);
- }
-
- void chain(ControllerCommand nextCommand) throws CommandException
- {
- if (nextCommand == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- CommandContext nextCommandContext = new CommandContext(this, nextCommand);
- execute(nextCommandContext);
- }
-
- public void execute(ControllerCommand nextCommand) throws CommandException
- {
- execute(new CommandContext(this, nextCommand));
- }
-
- public void execute(CommandContext commandContext) throws CommandException
- {
- if (commandContext == null)
- {
- throw new IllegalArgumentException();
- }
- try
- {
- nextDepth++;
- commandContext.execute();
- }
- finally
- {
- nextDepth--;
- }
-
- // Invoke forward command if necessary
- if (this.currentForwardCommandContext != null)
- {
- //
- CommandContext forwardCommandContext = currentForwardCommandContext;
- URLContext forwardURLContext = currentForwardURLContext;
-
- //
- currentForwardCommandContext = null;
- currentForwardURLContext = null;
-
- // Guess the redirect value
- boolean redirect = false;
- if (!commandContext.getCommand().getInfo().isIdempotent())
- {
- redirect = true;
- }
- else
- {
- boolean currentAuthenticated = serverInvocation.getServerContext().getURLContext().isAuthenticated();
- if (forwardURLContext != null && currentAuthenticated != forwardURLContext.isAuthenticated())
- {
- redirect = true;
- }
- else
- {
- boolean currentSecure = serverInvocation.getServerContext().getURLContext().getSecure();
- if (forwardURLContext != null && forwardURLContext.getSecure() && !currentSecure)
- {
- redirect = true;
- }
- }
- }
-
- //
- if (redirect)
- {
- String url = encodeURL(forwardCommandContext.getCommand(), forwardURLContext, null);
- if (url == null)
- {
- throw new CommandException();
- }
- try
- {
- serverInvocation.getServerContext().getClientResponse().sendRedirect(url);
- }
- catch (IOException e)
- {
- throw new CommandException(e);
- }
- }
- else
- {
- execute(forwardCommandContext);
- }
- }
- }
-
- public void forward(ControllerCommand forwardCommand, URLContext urlContext)
- {
- if (nextDepth > 1)
- {
- throw new IllegalStateException("A nested command cannot forward a command");
- }
- if (currentForwardCommandContext != null)
- {
- throw new IllegalStateException();
- }
- if (forwardCommand == null)
- {
- throw new IllegalArgumentException();
- }
- this.currentForwardCommandContext = new CommandContext(this, forwardCommand);
- this.currentForwardURLContext = urlContext;
- }
-}
Modified: trunk/core/src/main/org/jboss/portal/core/command/InvokeWindowActionCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/command/InvokeWindowActionCommand.java 2006-09-02 20:17:57 UTC (rev 5133)
+++ trunk/core/src/main/org/jboss/portal/core/command/InvokeWindowActionCommand.java 2006-09-04 12:43:32 UTC (rev 5134)
@@ -25,23 +25,15 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import org.jboss.portal.core.command.portlet.CoreActionContext;
-import org.jboss.portal.core.output.SignOutResult;
+import org.jboss.portal.core.command.info.CommandInfo;
+import org.jboss.portal.core.command.info.ActionCommandInfo;
import org.jboss.portal.portlet.NoSuchPortletException;
import org.jboss.portal.portlet.Parameters;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.result.ErrorResult;
-import org.jboss.portal.portlet.result.HTTPRedirectionResult;
-import org.jboss.portal.portlet.result.InsufficientPrivilegesResult;
-import org.jboss.portal.portlet.result.InsufficientTransportGuaranteeResult;
-import org.jboss.portal.portlet.result.RenderResult;
-import org.jboss.portal.portlet.result.Result;
import org.jboss.portal.server.ServerInvocation;
-import org.jboss.portal.server.request.URLContext;
-import java.io.IOException;
-
/**
* @author <a href="mailto:julien at jboss.org">Julien Viet</a>
* @version $Revision$
@@ -53,7 +45,7 @@
private static final Logger log = Logger.getLogger(InvokeWindowActionCommand.class);
/** . */
- private static final CommandInfo info = new CommandInfo(false, "view", false);
+ private static final CommandInfo info = new ActionCommandInfo(false, "view", false);
/** . */
private StateString navigationalState;
@@ -64,7 +56,16 @@
/** . */
private Parameters formParameters;
- public InvokeWindowActionCommand(String windowRef, Mode mode, WindowState windowState, StateString navigationalState, StateString interactionState, Parameters formParameters)
+ /** . */
+ private PortletInvocation invocation;
+
+ public InvokeWindowActionCommand(
+ String windowRef,
+ Mode mode,
+ WindowState windowState,
+ StateString navigationalState,
+ StateString interactionState,
+ Parameters formParameters)
throws IllegalArgumentException
{
super(windowRef, mode, windowState);
@@ -103,21 +104,23 @@
return info;
}
- public void execute() throws CommandException
+ public PortletInvocation getInvocation()
{
- ServerInvocation sinv = context.getExecutionContext().getServerInvocation();
+ return invocation;
+ }
- //
- CommandContext commandCtx = (CommandContext)getContext();
- CoreActionContext actionCtx = new CoreActionContext(commandCtx, sinv, portal, navigationalState, getWindowState(), getMode(), interactionState, formParameters, window);
-
- //
- PortletInvocation invocation = actionCtx.createInvocation();
-
- //
+ public void execute() throws CommandException
+ {
try
{
- instance.invoke(invocation);
+ ServerInvocation sinv = context.getServerInvocation();
+ CommandContext commandCtx = (CommandContext)getContext();
+ CoreActionContext actionCtx = new CoreActionContext(commandCtx, sinv, portal, navigationalState, getWindowState(), getMode(), interactionState, formParameters, window);
+ PortletInvocation invocation = actionCtx.createInvocation();
+
+ //
+ this.instance.invoke(invocation);
+ this.invocation = invocation;
}
catch (PortletInvokerException e)
{
@@ -130,89 +133,5 @@
throw new CommandException(e);
}
}
-
- //
- Result result = invocation.getResult();
-
- // Switch case
- if (result instanceof RenderResult)
- {
- RenderResult renderResult = (RenderResult)result;
- StateString portletNavState = renderResult.getNavigationalState();
- WindowState windowState = renderResult.getWindowState();
- Mode mode = renderResult.getMode();
- InvokeWindowRenderCommand iwrc = new InvokeWindowRenderCommand(
- windowRef,
- mode,
- windowState,
- portletNavState);
- context.forward(iwrc);
- }
- else if (result instanceof HTTPRedirectionResult)
- {
- try
- {
- HTTPRedirectionResult redirectionResult = (HTTPRedirectionResult)result;
- String url = redirectionResult.getLocation();
- sinv.getServerContext().getClientResponse().sendRedirect(url);
- }
- catch (IOException e)
- {
- throw new CommandException(e);
- }
- }
- else if (result instanceof InsufficientTransportGuaranteeResult)
- {
- boolean authenticated = context.getExecutionContext().getServerInvocation().getServerContext().getURLContext().isAuthenticated();
- context.forward(this, URLContext.newInstance(true, authenticated));
- }
- else if (result instanceof InsufficientPrivilegesResult)
- {
- boolean authenticated = context.getExecutionContext().getServerInvocation().getServerContext().getURLContext().isAuthenticated();
- context.forward(this, URLContext.newInstance(true, authenticated));
- }
- else if (result instanceof SignOutResult)
- {
- SignOutResult signOut = (SignOutResult)result;
-
- // Indicate that we want a sign out to be done
- sinv.getResponse().setWantSignOut(true);
-
- //
- String location = signOut.getLocation();
-
- //
- if (location == null)
- {
- // Redirect to the url we were targetting
- RenderPageCommand renderCmd = new RenderPageCommand(page.getId());
- boolean secure = context.getExecutionContext().getServerInvocation().getServerContext().getURLContext().getSecure();
- URLContext urlInfo = URLContext.newInstance(secure, false);
- context.forward(renderCmd, urlInfo);
- }
- else
- {
- try
- {
- sinv.getServerContext().getClientResponse().sendRedirect(location);
- }
- catch (IOException e)
- {
- throw new CommandException(e);
- }
- }
- }
- else if (result instanceof ErrorResult)
- {
- ErrorResult error = (ErrorResult)result;
- // Log the error message
- error.logErrorTo(log, "An portlet exception occured in portlet " + window.getInstanceRef());
-
- throw new ErrorResultException(error);
- }
- else
- {
- throw new CommandException("todo");
- }
}
}
Deleted: trunk/core/src/main/org/jboss/portal/core/command/InvokeWindowMoveCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/command/InvokeWindowMoveCommand.java 2006-09-02 20:17:57 UTC (rev 5133)
+++ trunk/core/src/main/org/jboss/portal/core/command/InvokeWindowMoveCommand.java 2006-09-04 12:43:32 UTC (rev 5134)
@@ -1,81 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., 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.command;
-
-import org.jboss.portal.server.ServerInvocation;
-
-import java.io.IOException;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class InvokeWindowMoveCommand extends WindowCommand
-{
-
-// protected int direction;
-
- private static final CommandInfo info = new CommandInfo(false, "view", false);
-
- public InvokeWindowMoveCommand(String windowRef)
- throws IllegalArgumentException
- {
- super(windowRef);
- }
-
- public CommandInfo getInfo()
- {
- return info;
- }
-
- public void execute() throws CommandException
- {
- ServerInvocation sinv = context.getExecutionContext().getServerInvocation();
-
- //
- String windowRef = window.getId();
-
-// UserContext uctx = sinv.getRequest().getUser();
-// if (uctx != null)
-// {
-// PreferenceStore store = uctx.getPreferences();
-// PreferenceSet prefs = store.get(windowRef, true);
-// prefs.setValue("region", new StringValue("right"));
-// }
-
- // Render page
- String pageRef = page.getId();
- RenderPageCommand rpc = new RenderPageCommand(pageRef);
- String url = context.getExecutionContext().encodeURL(rpc, null, null);
- try
- {
- sinv.getServerContext().getClientResponse().sendRedirect(url);
- }
- catch (IOException e)
- {
- throw new CommandException(e);
- }
-
-
-
- }
-}
Modified: trunk/core/src/main/org/jboss/portal/core/command/InvokeWindowRenderCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/command/InvokeWindowRenderCommand.java 2006-09-02 20:17:57 UTC (rev 5133)
+++ trunk/core/src/main/org/jboss/portal/core/command/InvokeWindowRenderCommand.java 2006-09-04 12:43:32 UTC (rev 5134)
@@ -27,6 +27,8 @@
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.common.invocation.InvocationContext;
import org.jboss.portal.core.aspects.controller.PageNavigationInterceptor;
+import org.jboss.portal.core.command.info.CommandInfo;
+import org.jboss.portal.core.command.info.ViewCommandInfo;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.theme.strategy.StrategyException;
import org.jboss.portal.theme.navigation.WindowNavigationalState;
@@ -39,7 +41,7 @@
public class InvokeWindowRenderCommand extends InvokeWindowCommand
{
- private static final CommandInfo info = new CommandInfo(false, "view", true);
+ private static final CommandInfo info = new ViewCommandInfo(false, "view");
/** . */
protected final StateString navigationalState;
@@ -48,7 +50,8 @@
String windowRef,
Mode mode,
WindowState windowState,
- StateString navigationalState) throws IllegalArgumentException
+ StateString navigationalState)
+ throws IllegalArgumentException
{
super(windowRef, mode, windowState);
this.navigationalState = navigationalState;
@@ -57,7 +60,8 @@
public InvokeWindowRenderCommand(
String windowRef,
Mode mode,
- WindowState windowState) throws IllegalArgumentException
+ WindowState windowState)
+ throws IllegalArgumentException
{
super(windowRef, mode, windowState);
this.navigationalState = null;
@@ -102,17 +106,13 @@
// Udpate the page nav state
try
{
- ServerInvocation sinv = ((CommandContext)getContext()).getExecutionContext().getServerInvocation();
- LayoutService layoutService = ((CommandContext)getContext()).getExecutionContext().getController().getPageService().getLayoutService();
+ ServerInvocation sinv = ((CommandContext)getContext()).getServerInvocation();
+ LayoutService layoutService = ((CommandContext)getContext()).getController().getPageService().getLayoutService();
PageNavigationInterceptor.updatePageNavigationalState(layoutService, context, sinv, portal, page, window, getMode(), getWindowState());
}
catch (StrategyException e)
{
throw new InvocationException(e);
}
-
- // Forward to render page
- RenderPageCommand renderCmd = new RenderPageCommand(page.getId());
- context.forward(renderCmd);
}
}
\ No newline at end of file
Modified: trunk/core/src/main/org/jboss/portal/core/command/MarkupCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/command/MarkupCommand.java 2006-09-02 20:17:57 UTC (rev 5133)
+++ trunk/core/src/main/org/jboss/portal/core/command/MarkupCommand.java 2006-09-04 12:43:32 UTC (rev 5134)
@@ -27,6 +27,8 @@
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.common.util.Exceptions;
import org.jboss.portal.core.command.portlet.CorePortletInvocationContext;
+import org.jboss.portal.core.command.info.CommandInfo;
+import org.jboss.portal.core.command.info.ViewCommandInfo;
import org.jboss.portal.core.model.instance.Instance;
import org.jboss.portal.core.model.portal.Page;
import org.jboss.portal.core.model.portal.PortalObject;
@@ -55,15 +57,14 @@
import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portal.theme.ThemeResult;
import org.jboss.portal.theme.ThemeService;
+import org.jboss.portal.theme.PageRendition;
import org.jboss.portal.theme.navigation.PageNavigationalState;
import org.jboss.portal.theme.navigation.WindowNavigationalState;
import org.jboss.portal.theme.page.MarkupContainer;
import org.jboss.portal.theme.page.ModifiableWindowResult;
import org.jboss.portal.theme.page.PageService;
-import org.jboss.portal.theme.page.UnusableMarkupResult;
import org.jboss.portal.theme.page.WindowResult;
import org.jboss.portal.theme.render.MarkupResult;
-import org.jboss.portal.theme.render.ModifiableMarkupResult;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
@@ -85,71 +86,48 @@
public abstract class MarkupCommand extends PortalObjectCommand
{
- /**
- * .
- */
+ /** . */
private static String WINDOW_ACCESS_DENIED = "core.render.window_access_denied";
- /**
- * .
- */
+ /** . */
private static String WINDOW_UNAVAILABLE = "core.render.window_unavailable";
- /**
- * .
- */
+ /** . */
private static String WINDOW_ERROR = "core.render.window_error";
- /**
- * .
- */
+ /** . */
private static String WINDOW_INTERNAL_ERROR = "core.render.window_internal_error";
- /**
- * .
- */
+ /** . */
private static String WINDOW_NOT_FOUND = "core.render.window_not_found";
- /**
- * .
- */
+ /** . */
private static String HIDE = "hide";
- /**
- * .
- */
+ /** . */
private static String SHOW = "show";
- /**
- * .
- */
- private static final CommandInfo info = new CommandInfo(false, "view", true);
+ /** . */
+ private static final CommandInfo info = new ViewCommandInfo(false, "view");
- /**
- * .
- */
+ /** . */
private final String pageRef;
- /**
- * .
- */
+ /** . */
private final MarkupContainer markupContainer;
- /**
- * .
- */
+ /** . */
private Page page;
- /**
- * .
- */
+ /** . */
private PortalLayout layout;
- /**
- * .
- */
+ /** . */
private boolean personalizable;
+ /** . */
+ private PageRendition result;
+
/**
* render the entire page
*
@@ -247,6 +225,11 @@
return markupContainer;
}
+ public PageRendition getResult()
+ {
+ return result;
+ }
+
/**
* initialize the command
*
@@ -255,7 +238,7 @@
public void create() throws CommandException
{
// Get page
- page = (Page)context.getExecutionContext().getController().getPortalObjectContainer().getObject(pageRef);
+ page = (Page)context.getController().getPortalObjectContainer().getObject(pageRef);
if (page == null)
{
throw new ObjectNotFoundException(pageRef);
@@ -267,7 +250,8 @@
throw new ObjectNotFoundException("Portal for " + pageRef);
}
- LayoutService layoutService = context.getExecutionContext().getController().getPageService().getLayoutService();
+ //
+ LayoutService layoutService = context.getController().getPageService().getLayoutService();
layout = getLayout(layoutService, page);
}
@@ -289,7 +273,7 @@
*/
public final void execute() throws InvocationException
{
- ServerInvocation sinv = context.getExecutionContext().getServerInvocation();
+ ServerInvocation sinv = context.getServerInvocation();
HttpServletRequest request = sinv.getServerContext().getClientRequest();
try
{
@@ -303,13 +287,13 @@
}
//
- PageService pageService = context.getExecutionContext().getController().getPageService();
+ PageService pageService = context.getController().getPageService();
PortalTheme theme = null;
if (personalizable)
{
CommandContext commandCtx = (CommandContext)getContext();
- User user = (User)commandCtx.getExecutionContext().getServerInvocation().getRequest().getUser();
+ User user = (User)commandCtx.getServerInvocation().getRequest().getUser();
if (user != null)
{
String themeId = user.getTheme();
@@ -340,25 +324,8 @@
ServerConfig cfg = sinv.getRequest().getServer().getConfig();
MarkupResult renderResult = renderFragments(cfg, navCtx);
- // React to redirects, and other non markup generating events
- if (renderResult instanceof UnusableMarkupResult)
- {
- return;
- }
-
- // If possible and needed, propagate the navigational state of the page into the result
- if (renderResult instanceof ModifiableMarkupResult)
- {
- ModifiableMarkupResult modResult = (ModifiableMarkupResult)renderResult;
- modResult.setLayoutURI(pageNavState.getLayoutURI());
- modResult.setLayoutState(pageNavState.getLayoutState());
- }
-
- // place a reference to the theme service into the request so that the theme tag can get to a theme via a theme
- // name (specified as tag attribute); this is useful if no theme was defined for the portal or the page
- request.setAttribute(ThemeConstants.ATTR_THEMESERVER, pageService.getThemeService());
- // now delegate to the layout to do the rest (assemble the markup fragments into a response)
- layout.assembleResponse(sinv, renderResult);
+ //
+ result = new PageRendition(layout, pageNavState, renderResult, pageService);
}
catch (InvocationException e)
{
@@ -379,7 +346,7 @@
private PortalTheme getTheme(String themeIdString)
{
//
- ThemeService service = context.getExecutionContext().getController().getPageService().getThemeService();
+ ThemeService service = context.getController().getPageService().getThemeService();
// If the id is provided in the form of context.name then look up the theme via a registration id
if (themeIdString.lastIndexOf(".") > 0)
@@ -461,17 +428,19 @@
try
{
RenderWindowCommand renderCmd = new RenderWindowCommand(windowRef);
- context.chain(renderCmd);
+ //
+ context.execute(renderCmd);
+
// The result should be a fragment result
Result result = renderCmd.getResult();
//
if (result instanceof InsufficientTransportGuaranteeResult)
{
- boolean authenticated = context.getExecutionContext().getServerInvocation().getServerContext().getURLContext().isAuthenticated();
+ boolean authenticated = context.getServerInvocation().getServerContext().getURLContext().isAuthenticated();
context.forward(this, URLContext.newInstance(true, authenticated));
- return new UnusableMarkupResult();
+ return null;
}
// Compute actions
@@ -589,7 +558,7 @@
else
{
log.error("Unexpected result from a portlet invocation " + result);
- return new UnusableMarkupResult();
+ return null;
}
}
catch (ObjectSecurityException e)
Modified: trunk/core/src/main/org/jboss/portal/core/command/RenderPageCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/command/RenderPageCommand.java 2006-09-02 20:17:57 UTC (rev 5133)
+++ trunk/core/src/main/org/jboss/portal/core/command/RenderPageCommand.java 2006-09-04 12:43:32 UTC (rev 5134)
@@ -28,7 +28,6 @@
import org.jboss.portal.server.config.ServerConfig;
import org.jboss.portal.theme.navigation.PageNavigationalState;
import org.jboss.portal.theme.page.ModifiablePageResult;
-import org.jboss.portal.theme.page.UnusableMarkupResult;
import org.jboss.portal.theme.page.WindowResult;
import org.jboss.portal.theme.render.MarkupResult;
@@ -68,24 +67,21 @@
for (Iterator i = windows.iterator(); i.hasNext();)
{
PortalObject o = (PortalObject)i.next();
+
+ // Render only window children
if (o instanceof Window)
{
Window window = (Window)o;
+
+ // That are visible ?
if (pageNavState.isWindowVisible(window.getId()))
{
MarkupResult result = renderPortletWindow(cfg, window);
- if (result == null)
+ if (result != null)
{
- continue;
+ pageResult.addWindowContext(pageNavState.getWindowContext(window.getId()));
+ pageResult.addWindowResult(window.getId(), (WindowResult)result);
}
-
- if (result instanceof UnusableMarkupResult)
- {
- return result;
- }
-
- pageResult.addWindowContext(pageNavState.getWindowContext(window.getId()));
- pageResult.addWindowResult(window.getId(), (WindowResult)result);
}
}
}
Deleted: trunk/core/src/main/org/jboss/portal/core/command/RenderRegionCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/command/RenderRegionCommand.java 2006-09-02 20:17:57 UTC (rev 5133)
+++ trunk/core/src/main/org/jboss/portal/core/command/RenderRegionCommand.java 2006-09-04 12:43:32 UTC (rev 5134)
@@ -1,106 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., 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.command;
-
-import org.jboss.portal.common.invocation.InvocationException;
-import org.jboss.portal.common.invocation.AttributeResolver;
-import org.jboss.portal.core.model.portal.PortalObject;
-import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.server.config.ServerConfig;
-import org.jboss.portal.theme.navigation.PageNavigationalState;
-import org.jboss.portal.theme.page.ModifiableRegionResult;
-import org.jboss.portal.theme.page.Region;
-import org.jboss.portal.theme.page.UnusableMarkupResult;
-import org.jboss.portal.theme.page.WindowContext;
-import org.jboss.portal.theme.page.WindowResult;
-import org.jboss.portal.theme.render.MarkupResult;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-/**
- * Render the content (markup) of a particular region on a page.
- *
- * @author <a href="mailto:mholzner at novell.com">Martin Holzner</a>
- * @version $Revision$
- */
-public final class RenderRegionCommand extends MarkupCommand
-{
- public RenderRegionCommand(String pageRef, Region region)
- {
- super(pageRef, region);
- }
-
- /**
- * Call the component / portlet invocation for each portlet window in this region, and assemble the resulting markup fragments into a region result
- *
- * @param cfg the server configuration to get access to customizable error behaviour
- * @param navCtx the navigational state context to access page and window navigational state
- * @return a modifiable region result containing the markup fragments from the individual portlets on this page
- * @throws InvocationException
- */
- public MarkupResult renderFragments(ServerConfig cfg, AttributeResolver navCtx) throws CommandException
- {
- PageNavigationalState pageNavState = (PageNavigationalState)navCtx.getAttribute(getPage().getId());
- Region region = (Region)getMarkupContainer();
- ModifiableRegionResult regionResult = new ModifiableRegionResult(navCtx, getPage().getName(), region, getPage().getDeclaredPropertyMap(), getPage().getPortal().getDeclaredPropertyMap());
-
- // all windows on the page
- Collection windows = getPage().getChildren();
-
- // make sure that only those portlets get rendered that are in the requeste region, and not switched to invisible by the layout strategy
- // Get the window ids (portlets) to render from the page navigatinal state
- // transfer all the visible portlet contexts to the page result (the layout strategy might have made some of them invisible)
- for (Iterator i = windows.iterator(); i.hasNext();)
- {
- PortalObject o = (PortalObject)i.next();
- if (o instanceof Window)
- {
- Window window = (Window)o;
- // consider only those portletContexts that need to be rendered (after the strategy was applied)
- if (pageNavState.isWindowVisible(window.getId()))
- {
- WindowContext windowContext = pageNavState.getWindowContext(window.getId());
-
- if (region.getId().equals(windowContext.getRegionName()))
- {
- MarkupResult result = renderPortletWindow(cfg, window);
- if (result == null)
- {
- continue;
- }
-
- if (result instanceof UnusableMarkupResult)
- {
- return result;
- }
-
- regionResult.addWindowContext(windowContext);
- regionResult.addWindowResult(window.getId(), (WindowResult)result);
- }
- }
- }
- }
-
- return regionResult;
- }
-}
Modified: trunk/core/src/main/org/jboss/portal/core/command/RenderWindowCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/command/RenderWindowCommand.java 2006-09-02 20:17:57 UTC (rev 5133)
+++ trunk/core/src/main/org/jboss/portal/core/command/RenderWindowCommand.java 2006-09-04 12:43:32 UTC (rev 5134)
@@ -22,6 +22,8 @@
package org.jboss.portal.core.command;
import org.jboss.portal.core.command.portlet.CoreRenderContext;
+import org.jboss.portal.core.command.info.CommandInfo;
+import org.jboss.portal.core.command.info.ViewCommandInfo;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.PortletInvokerException;
@@ -41,7 +43,7 @@
public class RenderWindowCommand extends WindowCommand
{
- private static final CommandInfo info = new CommandInfo(true, "view", true);
+ private static final CommandInfo info = new ViewCommandInfo(true, "view");
// private RenderInvocation render;
@@ -77,7 +79,7 @@
public void execute() throws CommandException
{
- ServerInvocation sinv = context.getExecutionContext().getServerInvocation();
+ ServerInvocation sinv = context.getServerInvocation();
//
StateString ns = (StateString)getAttribute(ControllerCommand.NAVIGATIONAL_STATE_SCOPE, window.getInstanceRef());
Deleted: trunk/core/src/main/org/jboss/portal/core/command/RenderWindowContextCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/command/RenderWindowContextCommand.java 2006-09-02 20:17:57 UTC (rev 5133)
+++ trunk/core/src/main/org/jboss/portal/core/command/RenderWindowContextCommand.java 2006-09-04 12:43:32 UTC (rev 5134)
@@ -1,104 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., 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.command;
-
-import org.jboss.portal.common.invocation.InvocationException;
-import org.jboss.portal.common.invocation.AttributeResolver;
-import org.jboss.portal.core.model.portal.PortalObject;
-import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.server.config.ServerConfig;
-import org.jboss.portal.theme.navigation.PageNavigationalState;
-import org.jboss.portal.theme.page.ModifiableWindowResult;
-import org.jboss.portal.theme.page.UnusableMarkupResult;
-import org.jboss.portal.theme.page.WindowContext;
-import org.jboss.portal.theme.render.MarkupResult;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-/**
- * Render the markup fragment of only one window.
- *
- * @author <a href="mailto:mholzner at novell.com">Martin Holzner</a>
- * @version $Revision$
- */
-public final class RenderWindowContextCommand extends MarkupCommand
-{
- public RenderWindowContextCommand(String pageRef, WindowContext windowContext)
- {
- super(pageRef, windowContext);
- }
-
- /**
- * Call the component / portlet invocation for the portlet assigned to this window, and create a window result from the resulting markup fragment
- *
- * @param cfg the server configuration to get access to customizable error behaviour
- * @param navCtx the navigational state context to access page and window navigational state
- * @return a modifiable window result containing the markup fragment from the portlet assigned to this window
- * @throws InvocationException
- */
- public MarkupResult renderFragments(ServerConfig cfg, AttributeResolver navCtx) throws CommandException
- {
- PageNavigationalState pageNavState = (PageNavigationalState)navCtx.getAttribute(getPage().getId());
- WindowContext windowFragment = (WindowContext)getMarkupContainer();
-
- // all windows on the page
- Collection windows = getPage().getChildren();
-
- // make sure that only those portlets get rendered that are in the requeste region, and not switched to
- // invisible by the layout strategy
- // Get the window ids (portlets) to render from the page navigatinal state
- // transfer all the visible portlet contexts to the page result (the layout strategy might have made some of
- // them invisible)
- for (Iterator i = windows.iterator(); i.hasNext();)
- {
- PortalObject o = (PortalObject)i.next();
- if (o instanceof Window)
- {
- Window window = (Window)o;
- // consider only those portletContexts that need to be rendered (after the strategy was applied)
- if (pageNavState.isWindowVisible(window.getId()) &&
- windowFragment.getId().equals(window.getId()))
- {
- ModifiableWindowResult result = (ModifiableWindowResult)renderPortletWindow(cfg, window);
- ///make sure all the references are filled to allow the assembler to do its thing
- result.setNavigationalStateContext(navCtx);
- result.setPageName(getPage().getName());
- result.setPageProperties(getPage().getDeclaredPropertyMap());
- result.setPortalProperties(getPage().getPortal().getDeclaredPropertyMap());
-
- // ensure that the result has the window context for the window result
- String windowName = windowFragment.getWindowName();
- String windowId = windowFragment.getId();
- String regionName = windowFragment.getRegionName();
- int order = windowFragment.getOrder();
- WindowContext windowContext = new WindowContext(windowName, windowId, regionName, order);
- result.addWindowContext(windowContext);
-
- return result;
- }
- }
- }
-
- return new UnusableMarkupResult();
- }
-}
Modified: trunk/core/src/main/org/jboss/portal/core/command/WindowCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/command/WindowCommand.java 2006-09-02 20:17:57 UTC (rev 5133)
+++ trunk/core/src/main/org/jboss/portal/core/command/WindowCommand.java 2006-09-04 12:43:32 UTC (rev 5134)
@@ -95,7 +95,7 @@
public void create() throws CommandException
{
// Retrieve the window
- window = (Window)context.getExecutionContext().getController().getPortalObjectContainer().getObject(windowRef);
+ window = (Window)context.getController().getPortalObjectContainer().getObject(windowRef);
if (window == null)
{
throw new ObjectNotFoundException(windowRef);
@@ -116,7 +116,7 @@
}
// Get instance
- instance = context.getExecutionContext().getController().getInstanceContainer().getInstance(window.getInstanceRef());
+ instance = context.getController().getInstanceContainer().getInstance(window.getInstanceRef());
if (instance == null)
{
throw new ObjectNotFoundException(window.getInstanceRef());
Added: trunk/core/src/main/org/jboss/portal/core/command/info/ActionCommandInfo.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/command/info/ActionCommandInfo.java 2006-09-02 20:17:57 UTC (rev 5133)
+++ trunk/core/src/main/org/jboss/portal/core/command/info/ActionCommandInfo.java 2006-09-04 12:43:32 UTC (rev 5134)
@@ -0,0 +1,48 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.command.info;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ActionCommandInfo extends CommandInfo
+{
+
+ /** . */
+ private final boolean idempotent;
+
+ public ActionCommandInfo(boolean secured, String action, boolean idempotent)
+ {
+ super(secured, action);
+ this.idempotent = idempotent;
+ }
+
+ /**
+ * Return true if the command is idempotent, i.e it can be reinvoked again safely.
+ */
+ public boolean isIdempotent()
+ {
+ return idempotent;
+ }
+
+}
Copied: trunk/core/src/main/org/jboss/portal/core/command/info/CommandInfo.java (from rev 5124, trunk/core/src/main/org/jboss/portal/core/command/CommandInfo.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/command/CommandInfo.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ trunk/core/src/main/org/jboss/portal/core/command/info/CommandInfo.java 2006-09-04 12:43:32 UTC (rev 5134)
@@ -0,0 +1,64 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.command.info;
+
+/**
+ * Runtime meta data for a command, this object is immutable.
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public abstract class CommandInfo
+{
+
+ /** . */
+ private final boolean secured;
+
+ /** . */
+ private final String action;
+
+ public CommandInfo(boolean secured, String action)
+ {
+ this.secured = secured;
+ this.action = action;
+ }
+
+ /**
+ * Is this command a secured command? If so, access rights to this command will be enforced via a security policy.
+ * <p>The default returns false. Extending command classes need to set the <code>isSecured</code> member variable to true
+ * in the command's constructor if they want to enforce access right checks for the command.</p>
+ *
+ * @return true if this command requires security checks
+ */
+ public boolean isSecured()
+ {
+ return secured;
+ }
+
+ /**
+ * @return the associated action of this command for security checks (is the user allowed to call this action...)
+ */
+ public String getAction()
+ {
+ return action;
+ }
+}
Property changes on: trunk/core/src/main/org/jboss/portal/core/command/info/CommandInfo.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/core/src/main/org/jboss/portal/core/command/info/ViewCommandInfo.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/command/info/ViewCommandInfo.java 2006-09-02 20:17:57 UTC (rev 5133)
+++ trunk/core/src/main/org/jboss/portal/core/command/info/ViewCommandInfo.java 2006-09-04 12:43:32 UTC (rev 5134)
@@ -0,0 +1,34 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.command.info;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ViewCommandInfo extends CommandInfo
+{
+ public ViewCommandInfo(boolean secured, String action)
+ {
+ super(secured, action);
+ }
+}
Modified: trunk/core/src/main/org/jboss/portal/core/command/portlet/CorePortletInvocationContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/command/portlet/CorePortletInvocationContext.java 2006-09-02 20:17:57 UTC (rev 5133)
+++ trunk/core/src/main/org/jboss/portal/core/command/portlet/CorePortletInvocationContext.java 2006-09-04 12:43:32 UTC (rev 5134)
@@ -178,7 +178,7 @@
}
URLContext info = URLContext.newInstance(secure, authenticated);
- return commandContext.getExecutionContext().encodeURL(cmd, info, URLFormat.newInstance(relative, true));
+ return commandContext.encodeURL(cmd, info, URLFormat.newInstance(relative, true));
}
public PortletInvocation createInvocation()
@@ -198,7 +198,7 @@
public String encodeURL(ControllerCommand cmd, URLContext urlContext, boolean relative)
{
- return commandContext.getExecutionContext().encodeURL(cmd, urlContext, URLFormat.newInstance(relative, true));
+ return commandContext.encodeURL(cmd, urlContext, URLFormat.newInstance(relative, true));
}
public String createUpdateNavigationalStateURL(Mode mode, WindowState windowState)
@@ -207,6 +207,6 @@
boolean secure = invocation.getServerContext().getURLContext().getSecure();
boolean authenticated = invocation.getServerContext().getURLContext().isAuthenticated();
URLContext urlContext = URLContext.newInstance(secure, authenticated);
- return commandContext.getExecutionContext().encodeURL(cmd, urlContext, URLFormat.newInstance(true, true));
+ return commandContext.encodeURL(cmd, urlContext, URLFormat.newInstance(true, true));
}
}
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 2006-09-02 20:17:57 UTC (rev 5133)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java 2006-09-04 12:43:32 UTC (rev 5134)
@@ -68,6 +68,7 @@
protected PortalNodeImpl portalNode;
protected Collection collection;
+ protected Map properties;
public PortalObjectImpl()
{
@@ -246,7 +247,6 @@
public PortalObject getChild(String name)
{
- Map c = objectNode.getChildren();
ObjectNode childNode = (ObjectNode)objectNode.getChildren().get(name);
if (childNode != null)
{
@@ -258,6 +258,22 @@
}
}
+ public Map getProperties()
+ {
+ if (properties == null)
+ {
+ Map properties = new HashMap();
+ ObjectNode node = objectNode;
+ while (node != null)
+ {
+ properties.putAll(node.getObject().declaredProperties);
+ node = node.getParent();
+ }
+ this.properties = Collections.unmodifiableMap(properties);
+ }
+ return properties;
+ }
+
public Map getDeclaredProperties()
{
return declaredProperties;
@@ -304,14 +320,12 @@
{
throw new IllegalArgumentException();
}
- ObjectNode node = objectNode;
- String value = null;
- while (value == null && node != null)
- {
- value = (String)node.getObject().declaredProperties.get(name);
- node = node.getParent();
- }
- return value;
+
+ // Trigger the lazy loading
+ Map properties = getProperties();
+
+ // Lookup the property
+ return (String)properties.get(name);
}
public PortalObject resolve(String relativePath)
@@ -347,7 +361,10 @@
private static class PortalNodeImpl implements JBossPortalNode
{
+ /** . */
private final PortalObjectImpl object;
+
+ /** . */
private CollectionImpl children;
public PortalNodeImpl(PortalObjectImpl object)
@@ -360,6 +377,7 @@
{
return object.getType();
}
+
public PortalNode getRoot()
{
if (object.getObjectNode().getParent().getObject() instanceof ContextImpl)
@@ -372,6 +390,7 @@
throw new UnsupportedOperationException();
}
}
+
public PortalNode getParent()
{
if (object.getObjectNode().getParent() != null)
@@ -383,10 +402,12 @@
return null;
}
}
+
public String getName()
{
return object.getObjectNode().getName();
}
+
public PortalNode getChild(String name)
{
PortalObjectImpl child = (PortalObjectImpl)object.getChild(name);
@@ -399,6 +420,7 @@
return null;
}
}
+
public Collection getChildren()
{
if (children == null)
@@ -407,6 +429,12 @@
}
return children;
}
+
+ public Map getProperties()
+ {
+ return object.getProperties();
+ }
+
public PortalNode resolve(String relativePath)
{
PortalObjectImpl relative = (PortalObjectImpl)object.resolve(relativePath);
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 2006-09-02 20:17:57 UTC (rev 5133)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java 2006-09-04 12:43:32 UTC (rev 5134)
@@ -34,14 +34,10 @@
public interface PortalObject
{
- /**
- * Portal property name that indicates the name of the default portal to lookup.
- */
+ /** Portal property name that indicates the name of the default portal to lookup. */
String PORTAL_PROP_DEFAULT_OBJECT_NAME = "portal.defaultObjectName";
- /**
- * The default portal name.
- */
+ /** The default portal name. */
String DEFAULT_OBJECT_NAME = "default";
int TYPE_CONTEXT = 0;
@@ -121,6 +117,11 @@
String getProperty(String name);
/**
+ * Returns a read only map that contains the object properties.
+ */
+ Map getProperties();
+
+ /**
*
*/
Map getDeclaredPropertyMap();
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java 2006-09-02 20:17:57 UTC (rev 5133)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java 2006-09-04 12:43:32 UTC (rev 5134)
@@ -251,6 +251,8 @@
sbUrl.append(rReq.getServerPort());
}
+ throw new PortletException("Julien commented some code as the theme cannot be available from the portlet");
+/*
PortalTheme theme = rReq.getTheme();
List links = theme.getThemeInfo().getLinks();
ThemeLink cssLink = (ThemeLink)links.get(0);
@@ -264,6 +266,7 @@
rReq.setAttribute("css_url", sbUrl.toString() + sCSSURL);
javax.portlet.PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher(CMSAdminConstants.CMS_JSP_PATH + "/create.jsp");
prd.include(rReq, rRes);
+*/
}
else if (CMSAdminConstants.OP_EDIT.equals(op))
{
@@ -282,6 +285,8 @@
sbUrl.append(rReq.getServerPort());
}
+ throw new PortletException("Julien commented some code as the theme cannot be available from the portlet");
+/*
PortalTheme theme = rReq.getTheme();
List links = theme.getThemeInfo().getLinks();
ThemeLink cssLink = (ThemeLink)links.get(0);
@@ -316,6 +321,7 @@
javax.portlet.PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher(CMSAdminConstants.CMS_JSP_PATH + "/edit.jsp");
prd.include(rReq, rRes);
+*/
}
else if (CMSAdminConstants.OP_EXPORTARCHIVE.equals(op))
{
Modified: trunk/core/src/main/org/jboss/portlet/JBossRenderRequest.java
===================================================================
--- trunk/core/src/main/org/jboss/portlet/JBossRenderRequest.java 2006-09-02 20:17:57 UTC (rev 5133)
+++ trunk/core/src/main/org/jboss/portlet/JBossRenderRequest.java 2006-09-04 12:43:32 UTC (rev 5134)
@@ -113,8 +113,8 @@
return null;
}
- public PortalTheme getTheme()
- {
- return (PortalTheme)invocation.getDispatchedRequest().getAttribute(ThemeConstants.ATTR_THEME);
- }
+// public PortalTheme getTheme()
+// {
+// return (PortalTheme)invocation.getDispatchedRequest().getAttribute(ThemeConstants.ATTR_THEME);
+// }
}
\ No newline at end of file
Added: trunk/theme/src/main/org/jboss/portal/theme/PageRendition.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/PageRendition.java 2006-09-02 20:17:57 UTC (rev 5133)
+++ trunk/theme/src/main/org/jboss/portal/theme/PageRendition.java 2006-09-04 12:43:32 UTC (rev 5134)
@@ -0,0 +1,93 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.theme;
+
+import org.jboss.portal.theme.render.MarkupResult;
+import org.jboss.portal.theme.render.ModifiableMarkupResult;
+import org.jboss.portal.theme.page.PageService;
+import org.jboss.portal.theme.navigation.PageNavigationalState;
+import org.jboss.portal.server.ServerInvocation;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.ServletException;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PageRendition
+{
+
+ /** . */
+ private PortalLayout layout;
+
+ /** . */
+ private PageNavigationalState pageNavState;
+
+ /** . */
+ private MarkupResult markupResult;
+
+ /** . */
+ private PageService pageService;
+
+ public PageRendition(PortalLayout layout, PageNavigationalState pageNavState, MarkupResult markupResult, PageService pageService)
+ {
+ this.layout = layout;
+ this.pageNavState = pageNavState;
+ this.markupResult = markupResult;
+ this.pageService = pageService;
+ }
+
+ /**
+ * Performs the page rendition.
+ */
+ public void render(ServerInvocation invocation) throws IOException, ServletException
+ {
+ // If possible and needed, propagate the navigational state of the page into the result
+ if (markupResult instanceof ModifiableMarkupResult)
+ {
+ ModifiableMarkupResult modResult = (ModifiableMarkupResult)markupResult;
+ modResult.setLayoutURI(pageNavState.getLayoutURI());
+ modResult.setLayoutState(pageNavState.getLayoutState());
+ }
+
+ //
+ HttpServletRequest clientRequest = invocation.getServerContext().getClientRequest();
+
+ try
+ {
+
+ // Place a reference to the theme service into the request so that the theme tag can get to a theme via a theme
+ // name (specified as tag attribute); this is useful if no theme was defined for the portal or the page
+ clientRequest.setAttribute(ThemeConstants.ATTR_THEMESERVER, pageService.getThemeService());
+
+ // now delegate to the layout to do the rest (assemble the markup fragments into a response)
+ layout.assembleResponse(invocation, markupResult);
+ }
+ finally
+ {
+ clientRequest.removeAttribute(ThemeConstants.ATTR_THEMESERVER);
+ }
+ }
+}
Deleted: trunk/theme/src/main/org/jboss/portal/theme/page/UnusableMarkupResult.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/UnusableMarkupResult.java 2006-09-02 20:17:57 UTC (rev 5133)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/UnusableMarkupResult.java 2006-09-04 12:43:32 UTC (rev 5134)
@@ -1,38 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., 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.theme.page;
-
-import org.jboss.portal.theme.render.MarkupResult;
-
-/**
- * Flagging result to handle unexpected results.
- *
- * @author <a href="mailto:mholzner at novell.com">Martin Holzner</a>
- * @version $Revision$
- */
-public final class UnusableMarkupResult extends MarkupResult
-{
- public UnusableMarkupResult()
- {
- super();
- }
-}
More information about the jboss-svn-commits
mailing list