[jboss-svn-commits] JBoss Portal SVN: r5135 - in trunk/core/src/main/org/jboss/portal/core: . aspects/controller command

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Sep 4 10:45:26 EDT 2006


Author: julien at jboss.com
Date: 2006-09-04 10:45:10 -0400 (Mon, 04 Sep 2006)
New Revision: 5135

Added:
   trunk/core/src/main/org/jboss/portal/core/command/CommandRedirectionException.java
   trunk/core/src/main/org/jboss/portal/core/command/ControllerSecurityException.java
   trunk/core/src/main/org/jboss/portal/core/command/InsufficientTransportGuaranteeException.java
Removed:
   trunk/core/src/main/org/jboss/portal/core/command/SecurityException.java
Modified:
   trunk/core/src/main/org/jboss/portal/core/CoreController.java
   trunk/core/src/main/org/jboss/portal/core/aspects/controller/EventBroadcasterInterceptor.java
   trunk/core/src/main/org/jboss/portal/core/aspects/controller/PolicyEnforcementInterceptor.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/MarkupCommand.java
   trunk/core/src/main/org/jboss/portal/core/command/ObjectSecurityException.java
   trunk/core/src/main/org/jboss/portal/core/command/PortalObjectCommand.java
   trunk/core/src/main/org/jboss/portal/core/command/WindowCommand.java
Log:
- align https and eventing with new controller flow

Modified: trunk/core/src/main/org/jboss/portal/core/CoreController.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/CoreController.java	2006-09-04 12:43:32 UTC (rev 5134)
+++ trunk/core/src/main/org/jboss/portal/core/CoreController.java	2006-09-04 14:45:10 UTC (rev 5135)
@@ -30,6 +30,9 @@
 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.InsufficientTransportGuaranteeException;
+import org.jboss.portal.core.command.ControllerSecurityException;
+import org.jboss.portal.core.command.CommandRedirectionException;
 import org.jboss.portal.core.command.info.CommandInfo;
 import org.jboss.portal.core.command.info.ActionCommandInfo;
 import org.jboss.portal.core.command.mapper.CommandFactory;
@@ -167,18 +170,31 @@
       {
          while (true)
          {
+            Forward forward = null;
+
             // Execute command
-            commandContext.execute(cmd);
+            try
+            {
+               //
+               commandContext.execute(cmd);
 
-            // Handle the result
-            Forward forward = handleResult(cmd, invocation);
+               // Handle the result
+               forward = handleResult(cmd, invocation);
+            }
+            catch (CommandRedirectionException e)
+            {
+               // Handle the redirection as forward
+               forward = new Forward(e.getRedirection(), null);
+            }
+
+            //
             if (forward == null)
             {
                break;
             }
 
-            // Redirect or execute in the same server invocation
-            if (forward.isRedirect(invocation))
+            // Find out if we can execute in the same server invocation
+            if (forward.requiresRedirect(invocation))
             {
                String url = commandContext.encodeURL(forward.getCommand(), forward.getURLContext(), null);
                if (url == null)
@@ -194,8 +210,15 @@
             }
          }
       }
-      catch (SecurityException e)
+      catch (InsufficientTransportGuaranteeException e)
       {
+         urlContext = URLContext.newInstance(true, urlContext.isAuthenticated());
+         ServerURL serverURL = getURLFactory().doMapping(invocation, cmd);
+         String url = invocation.getResponse().encodeURL(serverURL, urlContext, null);
+         sendRedirect(invocation, url);
+      }
+      catch (ControllerSecurityException e)
+      {
          if (urlContext.isAuthenticated())
          {
             sendStatusCode(invocation, HttpServletResponse.SC_UNAUTHORIZED);
@@ -362,11 +385,15 @@
 
       public Forward(ControllerCommand cmd, URLContext urlCtx)
       {
+         if (cmd == null)
+         {
+            throw new IllegalArgumentException("No command provided");
+         }
          this.cmd = cmd;
          this.urlCtx = urlCtx;
       }
 
-      public boolean isRedirect(ServerInvocation invocation)
+      public boolean requiresRedirect(ServerInvocation invocation)
       {
          CommandInfo cmdInfo = cmd.getInfo();
          if (cmdInfo instanceof ActionCommandInfo && !((ActionCommandInfo)cmdInfo).isIdempotent())

Modified: trunk/core/src/main/org/jboss/portal/core/aspects/controller/EventBroadcasterInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/controller/EventBroadcasterInterceptor.java	2006-09-04 12:43:32 UTC (rev 5134)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/EventBroadcasterInterceptor.java	2006-09-04 14:45:10 UTC (rev 5135)
@@ -29,6 +29,7 @@
 import org.jboss.portal.core.command.InvokeWindowActionCommand;
 import org.jboss.portal.core.command.WindowCommand;
 import org.jboss.portal.core.command.CommandContext;
+import org.jboss.portal.core.command.CommandRedirectionException;
 import org.jboss.portal.core.api.JBossPortalNode;
 import org.jboss.portal.common.invocation.InvocationException;
 import org.jboss.portal.portlet.ParametersStateString;
@@ -166,7 +167,7 @@
       if (redirection != null)
       {
          CommandContext ctx = (CommandContext)cmd.getContext();
-         ctx.forward(redirection);
+         throw new CommandRedirectionException(redirection);
       }
       else
       {

Modified: trunk/core/src/main/org/jboss/portal/core/aspects/controller/PolicyEnforcementInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/controller/PolicyEnforcementInterceptor.java	2006-09-04 12:43:32 UTC (rev 5134)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/PolicyEnforcementInterceptor.java	2006-09-04 14:45:10 UTC (rev 5135)
@@ -25,7 +25,7 @@
 import org.jboss.logging.Logger;
 import org.jboss.portal.core.command.CommandInterceptor;
 import org.jboss.portal.core.command.ControllerCommand;
-import org.jboss.portal.core.command.SecurityException;
+import org.jboss.portal.core.command.ControllerSecurityException;
 import org.jboss.portal.common.invocation.InvocationException;
 import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
 import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
@@ -84,7 +84,7 @@
          {
             log.error("Security Exception", e);
          }
-         throw new SecurityException(e);
+         throw new ControllerSecurityException(e);
       } 
    } 
 }
\ No newline at end of file

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-04 12:43:32 UTC (rev 5134)
+++ trunk/core/src/main/org/jboss/portal/core/command/CommandContext.java	2006-09-04 14:45:10 UTC (rev 5135)
@@ -46,9 +46,6 @@
    /** Depth of the next chain. */
    protected int nextDepth;
 
-   /** The forward command context if any. */
-   protected ControllerCommand forwardCommand;
-
    /** . */
    protected URLContext forwardURLContext;
 
@@ -74,7 +71,7 @@
       addResolver(ControllerCommand.PRINCIPAL_SCOPE, serverInvocation.getContext());
    }
 
-   public void execute(ControllerCommand command) throws CommandException
+   public void execute(ControllerCommand command) throws CommandException, InvocationException
    {
       if (command == null)
       {
@@ -101,18 +98,7 @@
       }
       catch (Exception e)
       {
-         if (e instanceof CommandException)
-         {
-            throw (CommandException)e;
-         }
-         else if (e instanceof RuntimeException)
-         {
-            throw (RuntimeException)e;
-         }
-         else
-         {
-            throw new CommandException(e);
-         }
+         ControllerCommand.rethrow(e);
       }
       finally
       {
@@ -127,29 +113,6 @@
       }
    }
 
-   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
-   {
-      forward(nextCommand, null);
-   }
-
    public String encodeURL(ControllerCommand cmd, URLContext urlContext, URLFormat format)
    {
       ServerURL serverURL = controller.getURLFactory().doMapping(serverInvocation, cmd);
@@ -165,14 +128,4 @@
    {
       return controller;
    }
-
-   public ControllerCommand getForwardCommand()
-   {
-      return forwardCommand;
-   }
-
-   public URLContext getForwardURLContext()
-   {
-      return forwardURLContext;
-   }
 }

Added: trunk/core/src/main/org/jboss/portal/core/command/CommandRedirectionException.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/command/CommandRedirectionException.java	2006-09-04 12:43:32 UTC (rev 5134)
+++ trunk/core/src/main/org/jboss/portal/core/command/CommandRedirectionException.java	2006-09-04 14:45:10 UTC (rev 5135)
@@ -0,0 +1,46 @@
+/*
+* 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;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CommandRedirectionException extends CommandException
+{
+
+   private final ControllerCommand redirection;
+
+   public CommandRedirectionException(ControllerCommand redirection)
+   {
+      if (redirection == null)
+      {
+         throw new IllegalArgumentException("A command must be provided");
+      }
+      this.redirection = redirection;
+   }
+
+   public ControllerCommand getRedirection()
+   {
+      return redirection;
+   }
+}

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-04 12:43:32 UTC (rev 5134)
+++ trunk/core/src/main/org/jboss/portal/core/command/ControllerCommand.java	2006-09-04 14:45:10 UTC (rev 5135)
@@ -96,9 +96,9 @@
     * Enforce the security on this command.
     *
     * @throws PortalSecurityException
-    * @throws SecurityException
+    * @throws ControllerSecurityException
     */
-   public void enforceSecurity(PortalAuthorizationManager pam) throws SecurityException, PortalSecurityException
+   public void enforceSecurity(PortalAuthorizationManager pam) throws ControllerSecurityException, PortalSecurityException
    {
    }
 
@@ -120,4 +120,21 @@
     * Execute the command.
     */
    public abstract void execute() throws CommandException;
+
+   public static void rethrow(Exception e) throws CommandException, InvocationException, RuntimeException
+   {
+      if (e instanceof InvocationException)
+      {
+         throw (InvocationException)e;
+      }
+      if (e instanceof CommandException)
+      {
+         throw (CommandException)e;
+      }
+      if (e instanceof RuntimeException)
+      {
+         throw (RuntimeException)e;
+      }
+      throw new CommandException(e);
+   }
 }

Copied: trunk/core/src/main/org/jboss/portal/core/command/ControllerSecurityException.java (from rev 5134, trunk/core/src/main/org/jboss/portal/core/command/SecurityException.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/command/SecurityException.java	2006-09-04 12:43:32 UTC (rev 5134)
+++ trunk/core/src/main/org/jboss/portal/core/command/ControllerSecurityException.java	2006-09-04 14:45:10 UTC (rev 5135)
@@ -0,0 +1,51 @@
+/*
+* 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;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class ControllerSecurityException extends CommandException
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = -157650218749390553L;
+
+   public ControllerSecurityException()
+   {
+   }
+
+   public ControllerSecurityException(String message)
+   {
+      super(message);
+   }
+
+   public ControllerSecurityException(Throwable cause)
+   {
+      super(cause);
+   }
+
+   public ControllerSecurityException(String message, Throwable cause)
+   {
+      super(message, cause);
+   }
+}


Property changes on: trunk/core/src/main/org/jboss/portal/core/command/ControllerSecurityException.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/InsufficientTransportGuaranteeException.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/command/InsufficientTransportGuaranteeException.java	2006-09-04 12:43:32 UTC (rev 5134)
+++ trunk/core/src/main/org/jboss/portal/core/command/InsufficientTransportGuaranteeException.java	2006-09-04 14:45:10 UTC (rev 5135)
@@ -0,0 +1,31 @@
+/*
+* 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;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class InsufficientTransportGuaranteeException extends ControllerSecurityException
+{
+
+}

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-04 12:43:32 UTC (rev 5134)
+++ trunk/core/src/main/org/jboss/portal/core/command/MarkupCommand.java	2006-09-04 14:45:10 UTC (rev 5135)
@@ -49,7 +49,6 @@
 import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
 import org.jboss.portal.server.ServerInvocation;
 import org.jboss.portal.server.config.ServerConfig;
-import org.jboss.portal.server.request.URLContext;
 import org.jboss.portal.theme.LayoutService;
 import org.jboss.portal.theme.PortalLayout;
 import org.jboss.portal.theme.PortalTheme;
@@ -255,7 +254,7 @@
       layout = getLayout(layoutService, page);
    }
 
-   public void enforceSecurity(PortalAuthorizationManager pam) throws SecurityException, PortalSecurityException
+   public void enforceSecurity(PortalAuthorizationManager pam) throws ControllerSecurityException, PortalSecurityException
    {
       //
       super.enforceSecurity(pam);
@@ -271,7 +270,7 @@
     *
     * @throws InvocationException
     */
-   public final void execute() throws InvocationException
+   public final void execute() throws CommandException, InvocationException
    {
       ServerInvocation sinv = context.getServerInvocation();
       HttpServletRequest request = sinv.getServerContext().getClientRequest();
@@ -327,13 +326,9 @@
          //
          result = new PageRendition(layout, pageNavState, renderResult, pageService);
       }
-      catch (InvocationException e)
-      {
-         throw e;
-      }
       catch (Exception e)
       {
-         throw new InvocationException(e);
+         ControllerCommand.rethrow(e);
       }
       finally
       {
@@ -438,9 +433,7 @@
          //
          if (result instanceof InsufficientTransportGuaranteeResult)
          {
-            boolean authenticated = context.getServerInvocation().getServerContext().getURLContext().isAuthenticated();
-            context.forward(this, URLContext.newInstance(true, authenticated));
-            return null;
+            throw new InsufficientTransportGuaranteeException();
          }
 
          // Compute actions
@@ -593,6 +586,11 @@
             return new ModifiableWindowResult(windowTitle, contentChars, actionMap, windowProps, responseProps, headerChars);
          }
       }
+      catch (CommandException e)
+      {
+         // It's a CommandException that we rethrow
+         throw e;
+      }
       catch (Exception e)
       {
          log.error("Rendering portlet window " + windowRef + " produced an internal error", e);

Modified: trunk/core/src/main/org/jboss/portal/core/command/ObjectSecurityException.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/command/ObjectSecurityException.java	2006-09-04 12:43:32 UTC (rev 5134)
+++ trunk/core/src/main/org/jboss/portal/core/command/ObjectSecurityException.java	2006-09-04 14:45:10 UTC (rev 5135)
@@ -25,7 +25,7 @@
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
  * @version $Revision$
  */
-public class ObjectSecurityException extends SecurityException
+public class ObjectSecurityException extends ControllerSecurityException
 {
 
    /** The serialVersionUID */

Modified: trunk/core/src/main/org/jboss/portal/core/command/PortalObjectCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/command/PortalObjectCommand.java	2006-09-04 12:43:32 UTC (rev 5134)
+++ trunk/core/src/main/org/jboss/portal/core/command/PortalObjectCommand.java	2006-09-04 14:45:10 UTC (rev 5135)
@@ -37,9 +37,9 @@
     * Enforce the security on this command using the provided portal authorization manager.
     *
     * @param pam the portal authorization manager
-    * @throws SecurityException if the access is not granted
+    * @throws ControllerSecurityException if the access is not granted
     */
-   public void enforceSecurity(PortalAuthorizationManager pam) throws SecurityException, PortalSecurityException
+   public void enforceSecurity(PortalAuthorizationManager pam) throws ControllerSecurityException, PortalSecurityException
    {
       PortalObject target = getTarget();
       String id = target.getId();

Deleted: trunk/core/src/main/org/jboss/portal/core/command/SecurityException.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/command/SecurityException.java	2006-09-04 12:43:32 UTC (rev 5134)
+++ trunk/core/src/main/org/jboss/portal/core/command/SecurityException.java	2006-09-04 14:45:10 UTC (rev 5135)
@@ -1,53 +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.command.CommandException;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class SecurityException extends CommandException
-{
-   /** The serialVersionUID */
-   private static final long serialVersionUID = -157650218749390553L;
-
-   public SecurityException()
-   {
-   }
-
-   public SecurityException(String message)
-   {
-      super(message);
-   }
-
-   public SecurityException(Throwable cause)
-   {
-      super(cause);
-   }
-
-   public SecurityException(String message, Throwable cause)
-   {
-      super(message, cause);
-   }
-}

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-04 12:43:32 UTC (rev 5134)
+++ trunk/core/src/main/org/jboss/portal/core/command/WindowCommand.java	2006-09-04 14:45:10 UTC (rev 5135)
@@ -128,10 +128,10 @@
     * We only enforce security at instance and component level.
     *
     * @param pam
-    * @throws SecurityException
+    * @throws ControllerSecurityException
     * @throws org.jboss.portal.security.PortalSecurityException
     */
-   public void enforceSecurity(PortalAuthorizationManager pam) throws SecurityException, PortalSecurityException
+   public void enforceSecurity(PortalAuthorizationManager pam) throws ControllerSecurityException, PortalSecurityException
    {
    }
 }




More information about the jboss-svn-commits mailing list