[gatein-commits] gatein SVN: r5763 - in components/pc/trunk: federation/src/main/java/org/gatein/pc/federation/impl and 6 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Jan 17 12:47:38 EST 2011


Author: chris.laprun at jboss.com
Date: 2011-01-17 12:47:37 -0500 (Mon, 17 Jan 2011)
New Revision: 5763

Modified:
   components/pc/trunk/api/src/main/java/org/gatein/pc/api/PortletInvoker.java
   components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatedPortletInvokerService.java
   components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatingPortletInvokerService.java
   components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/PortletInvokerInterceptor.java
   components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/container/ContainerPortletInvoker.java
   components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/state/consumer/ConsumerPortletInvoker.java
   components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/state/producer/ProducerPortletInvoker.java
   components/pc/trunk/portlet/src/test/java/org/gatein/pc/portlet/support/PortletInvokerSupport.java
   components/pc/trunk/portlet/src/test/java/org/gatein/pc/test/portlet/state/ProducerStatefulPortletInvokerTestCase.java
Log:
- GTNPC-49: Removed isExposed and isKnown methods. Fixed implementation of ProducerPortletInvoker.getStatus that needs to call to super to make sure that we don't miss offered portlets.

Modified: components/pc/trunk/api/src/main/java/org/gatein/pc/api/PortletInvoker.java
===================================================================
--- components/pc/trunk/api/src/main/java/org/gatein/pc/api/PortletInvoker.java	2011-01-17 08:23:08 UTC (rev 5762)
+++ components/pc/trunk/api/src/main/java/org/gatein/pc/api/PortletInvoker.java	2011-01-17 17:47:37 UTC (rev 5763)
@@ -57,46 +57,22 @@
     * @param portletContext the portlet context in the scope of this invoker
     * @return the <code>PortletInfo</code> for the specified portlet
     * @throws IllegalArgumentException if the portlet context is null
-    * @throws PortletInvokerException a portlet invoker exception
+    * @throws PortletInvokerException  a portlet invoker exception
     */
    Portlet getPortlet(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException;
 
    /**
-    * Returns the status of a specified {@code #PortletContext} or null if the portlet context does not have
-    * a relationship with this portlet invoker.
+    * Returns the status of a specified {@code #PortletContext} or null if the portlet context does not have a
+    * relationship with this portlet invoker.
     *
-    * @param portletContext the portlet context 
+    * @param portletContext the portlet context
     * @return the portlet status
     * @throws IllegalArgumentException if the portlet context is null
-    * @throws PortletInvokerException a portlet invoker exception
+    * @throws PortletInvokerException  a portlet invoker exception
     */
    PortletStatus getStatus(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException;
 
    /**
-    * Determines whether the specified PortletContext is part of the set of exposed Portlets as returned by {@link
-    * #getPortlets()}.
-    *
-    * @param portletContext the PortletContext which exposed status we want to determine
-    * @return <code>true</code> if the Portlet associated with the specified PortletContext is exposed by this
-    *         PortletInvoker, <code>false</code> otherwise
-    * @throws IllegalArgumentException if the specified PortletContext is null
-    * @throws PortletInvokerException  if some other error occurs
-    */
-   boolean isExposed(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException;
-
-   /**
-    * Determines whether the Portlet associated with the specified PortletContext (if it exists) is known to this
-    * PortletInvoker whether it is exposed or not. In particular, if this method returns <code>true</code> then {@link
-    * #getPortlet(PortletContext)} will return a valid Portlet.
-    *
-    * @param portletContext the PortletContext to check
-    * @return <code>true</code>
-    * @throws IllegalArgumentException
-    * @throws PortletInvokerException
-    */
-   boolean isKnown(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException;
-
-   /**
     * Invoke an operation on a specific portlet.
     *
     * @param invocation the portlet invocation

Modified: components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatedPortletInvokerService.java
===================================================================
--- components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatedPortletInvokerService.java	2011-01-17 08:23:08 UTC (rev 5762)
+++ components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatedPortletInvokerService.java	2011-01-17 17:47:37 UTC (rev 5763)
@@ -114,16 +114,6 @@
       return portletInvoker.getStatus(context);
    }
 
-   public boolean isExposed(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException
-   {
-      return getStatus(portletContext) == PortletStatus.OFFERED;
-   }
-
-   public boolean isKnown(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException
-   {
-      return getStatus(portletContext) != null;
-   }
-
    private class FederatedInstanceContext implements InstanceContext
    {
 

Modified: components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatingPortletInvokerService.java
===================================================================
--- components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatingPortletInvokerService.java	2011-01-17 08:23:08 UTC (rev 5762)
+++ components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatingPortletInvokerService.java	2011-01-17 17:47:37 UTC (rev 5763)
@@ -211,16 +211,6 @@
       return federated.getStatus(portletContext);
    }
 
-   public boolean isExposed(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException
-   {
-      return getStatus(portletContext) == PortletStatus.OFFERED;
-   }
-
-   public boolean isKnown(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException
-   {
-      return getStatus(portletContext) != null;
-   }
-
    public PortletInvocationResponse invoke(PortletInvocation invocation) throws PortletInvokerException
    {
       PortletContext compoundPortletContext = invocation.getTarget();

Modified: components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/PortletInvokerInterceptor.java
===================================================================
--- components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/PortletInvokerInterceptor.java	2011-01-17 08:23:08 UTC (rev 5762)
+++ components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/PortletInvokerInterceptor.java	2011-01-17 17:47:37 UTC (rev 5763)
@@ -88,16 +88,6 @@
       return safeGetNext().getStatus(portletContext);
    }
 
-   public boolean isExposed(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException
-   {
-      return safeGetNext().isExposed(portletContext);
-   }
-
-   public boolean isKnown(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException
-   {
-      return safeGetNext().isKnown(portletContext);
-   }
-
    public PortletInvocationResponse invoke(PortletInvocation invocation) throws IllegalArgumentException, PortletInvokerException
    {
       return safeGetNext().invoke(invocation);

Modified: components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/container/ContainerPortletInvoker.java
===================================================================
--- components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/container/ContainerPortletInvoker.java	2011-01-17 08:23:08 UTC (rev 5762)
+++ components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/container/ContainerPortletInvoker.java	2011-01-17 17:47:37 UTC (rev 5763)
@@ -22,7 +22,6 @@
  ******************************************************************************/
 package org.gatein.pc.portlet.container;
 
-import org.gatein.common.util.ParameterValidation;
 import org.gatein.pc.api.NoSuchPortletException;
 import org.gatein.pc.api.Portlet;
 import org.gatein.pc.api.PortletContext;
@@ -101,16 +100,6 @@
       return null;
    }
 
-   public boolean isExposed(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException
-   {
-      return getStatus(portletContext) == PortletStatus.OFFERED;
-   }
-
-   public boolean isKnown(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException
-   {
-      return getStatus(portletContext) != null;
-   }
-
    public Portlet getPortlet(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException
    {
       if (portletContext == null)

Modified: components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/state/consumer/ConsumerPortletInvoker.java
===================================================================
--- components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/state/consumer/ConsumerPortletInvoker.java	2011-01-17 08:23:08 UTC (rev 5762)
+++ components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/state/consumer/ConsumerPortletInvoker.java	2011-01-17 17:47:37 UTC (rev 5763)
@@ -121,19 +121,6 @@
       return getConsumerContext(portletContext).getPortlet();
    }
 
-   @Override
-   public boolean isKnown(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException
-   {
-      try
-      {
-         return getPortlet(portletContext) != null;
-      }
-      catch (NoSuchPortletException e)
-      {
-         return false;
-      }
-   }
-
    public PortletInvocationResponse invoke(PortletInvocation invocation) throws IllegalArgumentException, PortletInvokerException
    {
       PortletContext portletContext = invocation.getTarget();

Modified: components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/state/producer/ProducerPortletInvoker.java
===================================================================
--- components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/state/producer/ProducerPortletInvoker.java	2011-01-17 08:23:08 UTC (rev 5762)
+++ components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/state/producer/ProducerPortletInvoker.java	2011-01-17 17:47:37 UTC (rev 5763)
@@ -128,23 +128,26 @@
    @Override
    public PortletStatus getStatus(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException
    {
-      try
+      PortletStatus status = super.getStatus(portletContext);
+
+      if (status != null)
       {
-         getPortlet(portletContext);
-         return PortletStatus.MANAGED;
+         return status;
       }
-      catch (NoSuchPortletException e)
+      else
       {
-         return null;
+         try
+         {
+            Portlet portlet = getPortlet(portletContext);
+            return portlet != null ? PortletStatus.MANAGED : null;
+         }
+         catch (NoSuchPortletException e)
+         {
+            return null;
+         }
       }
    }
 
-   @Override
-   public boolean isKnown(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException
-   {
-      return getStatus(portletContext) != null;
-   }
-
    private <S extends Serializable> Portlet _getPortlet(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException
    {
 

Modified: components/pc/trunk/portlet/src/test/java/org/gatein/pc/portlet/support/PortletInvokerSupport.java
===================================================================
--- components/pc/trunk/portlet/src/test/java/org/gatein/pc/portlet/support/PortletInvokerSupport.java	2011-01-17 08:23:08 UTC (rev 5762)
+++ components/pc/trunk/portlet/src/test/java/org/gatein/pc/portlet/support/PortletInvokerSupport.java	2011-01-17 17:47:37 UTC (rev 5763)
@@ -138,16 +138,6 @@
       return portlets.containsKey(portletContext.getId()) ? PortletStatus.OFFERED : null;
    }
 
-   public boolean isExposed(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException
-   {
-      return getStatus(portletContext) == PortletStatus.OFFERED;
-   }
-
-   public boolean isKnown(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException
-   {
-      return getStatus(portletContext) != null;
-   }
-
    public PortletInvocationResponse invoke(PortletInvocation invocation) throws PortletInvokerException
    {
       PortletContext portletContext = invocation.getTarget();

Modified: components/pc/trunk/portlet/src/test/java/org/gatein/pc/test/portlet/state/ProducerStatefulPortletInvokerTestCase.java
===================================================================
--- components/pc/trunk/portlet/src/test/java/org/gatein/pc/test/portlet/state/ProducerStatefulPortletInvokerTestCase.java	2011-01-17 08:23:08 UTC (rev 5762)
+++ components/pc/trunk/portlet/src/test/java/org/gatein/pc/test/portlet/state/ProducerStatefulPortletInvokerTestCase.java	2011-01-17 17:47:37 UTC (rev 5763)
@@ -26,29 +26,31 @@
 import org.gatein.pc.api.PortletContext;
 import org.gatein.pc.api.PortletInvokerException;
 import org.gatein.pc.api.PortletStateType;
-import org.gatein.pc.api.state.PropertyMap;
-import org.gatein.pc.portlet.impl.state.StateManagementPolicyService;
-import org.gatein.pc.portlet.impl.state.StateConverterV0;
-import org.gatein.pc.portlet.impl.state.producer.PortletStatePersistenceManagerService;
-import org.gatein.pc.portlet.impl.spi.AbstractInstanceContext;
+import org.gatein.pc.api.PortletStatus;
 import org.gatein.pc.api.invocation.ActionInvocation;
 import org.gatein.pc.api.invocation.PortletInvocation;
 import org.gatein.pc.api.state.AccessMode;
 import org.gatein.pc.api.state.PropertyChange;
+import org.gatein.pc.api.state.PropertyMap;
+import org.gatein.pc.portlet.impl.spi.AbstractInstanceContext;
+import org.gatein.pc.portlet.impl.state.StateConverterV0;
+import org.gatein.pc.portlet.impl.state.StateManagementPolicyService;
+import org.gatein.pc.portlet.impl.state.producer.PortletStatePersistenceManagerService;
 import org.gatein.pc.portlet.state.StateConverter;
+import org.gatein.pc.portlet.state.producer.ProducerPortlet;
 import org.gatein.pc.portlet.state.producer.ProducerPortletInvoker;
-import org.gatein.pc.portlet.state.producer.ProducerPortlet;
-import org.gatein.pc.portlet.support.info.PortletInfoSupport;
 import org.gatein.pc.portlet.support.PortletInvokerSupport;
 import org.gatein.pc.portlet.support.PortletSupport;
-
-import static org.jboss.unit.api.Assert.*;
+import org.gatein.pc.portlet.support.info.PortletInfoSupport;
 import org.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Test;
 
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 
+import static org.jboss.unit.api.Assert.*;
+
 /**
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
  * @version $Revision: 6691 $
@@ -210,12 +212,14 @@
    protected ActionInvocation createAction(PortletContext portletRef, AccessMode accessMode)
    {
       ActionContextImpl actionCtx = new ActionContextImpl();
-      AbstractInstanceContext instanceCtx = new AbstractInstanceContext("blah", accessMode) {
+      AbstractInstanceContext instanceCtx = new AbstractInstanceContext("blah", accessMode)
+      {
          @Override
-         public PortletStateType<?> getStateType() {
+         public PortletStateType<?> getStateType()
+         {
             return persistLocally ? null : PortletStateType.OPAQUE;
          }
-     };
+      };
 
       //
       ActionInvocation action = new ActionInvocation(actionCtx);
@@ -237,14 +241,36 @@
       assertEquals(1, portlets.size());
       return (Portlet)portlets.iterator().next();
    }
-   
+
    protected PortletContext importPortletContext(PortletContext contextToImport) throws PortletInvokerException
    {
       return producer.importPortlet(PortletStateType.OPAQUE, contextToImport);
    }
-   
+
    protected PortletContext exportPortletContext(PortletContext originalPortletContext) throws PortletInvokerException
    {
       return producer.exportPortlet(PortletStateType.OPAQUE, originalPortletContext);
    }
+
+   @Test
+   public void testGetStatus() throws Exception
+   {
+      PortletInfoSupport info = new PortletInfoSupport();
+      info.getMeta().setDisplayName("MyPortlet");
+      PortletContext popCtx = createPOPRef(info);
+
+      // POP
+      assertEquals(PortletStatus.OFFERED, producer.getStatus(popCtx));
+
+      // clone a POP
+      PortletContext ccp1Ctx = createClone(popCtx);
+      assertEquals(PortletStatus.MANAGED, producer.getStatus(ccp1Ctx));
+
+      // Clone a CCP
+      PortletContext ccp2Ctx = createClone(ccp1Ctx);
+      assertEquals(PortletStatus.MANAGED, producer.getStatus(ccp2Ctx));
+
+      // inexistent portlet
+      assertNull(producer.getStatus(PortletContext.createPortletContext("foo")));
+   }
 }



More information about the gatein-commits mailing list