[gatein-commits] gatein SVN: r7008 - in portal/branches/api/component/api-impl/src: main/java/org/gatein/portal/api/impl/content and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Aug 8 12:23:15 EDT 2011


Author: chris.laprun at jboss.com
Date: 2011-08-08 12:23:15 -0400 (Mon, 08 Aug 2011)
New Revision: 7008

Added:
   portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/AbstractPortlet.java
Modified:
   portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java
   portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/CategoryImpl.java
   portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java
   portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ManagedContentImpl.java
   portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/PortletImpl.java
   portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/WSRPImpl.java
   portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java
   portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java
   portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java
Log:
- Adapted for API changes.
- GateInImpl now waits on ExoKernelIntegration before being instantiated so that it's properly resolved when the component is started (via constructor dependency).
- Fixed Content implementation. Previous implementation was just a proxy to the Application provided by the ApplicationRegistry (which actually maps to ManagedContent). Content now maps to PC portlets. Gadget side was fine.
- ManagedContent is now late-binding.

Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java	2011-08-08 14:25:29 UTC (rev 7007)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java	2011-08-08 16:23:15 UTC (rev 7008)
@@ -38,6 +38,7 @@
 import org.exoplatform.portal.mop.SiteType;
 import org.exoplatform.portal.mop.description.DescriptionService;
 import org.exoplatform.portal.mop.navigation.NavigationService;
+import org.exoplatform.portal.pc.ExoKernelIntegration;
 import org.exoplatform.portal.pom.data.ModelDataStorage;
 import org.exoplatform.portal.pom.data.PageData;
 import org.exoplatform.portal.pom.data.PageKey;
@@ -69,6 +70,7 @@
 import org.gatein.api.util.IterableIdentifiableCollection;
 import org.gatein.api.util.Type;
 import org.gatein.common.util.ParameterValidation;
+import org.gatein.pc.federation.FederatingPortletInvoker;
 import org.gatein.portal.api.impl.id.ComplexApplicationContext;
 import org.gatein.portal.api.impl.id.ComplexApplicationId;
 import org.gatein.portal.api.impl.portal.DashboardSiteImpl;
@@ -93,8 +95,25 @@
    private static final Query<PortalData> PORTALS = new Query<PortalData>(SiteType.PORTAL.getName(), null, PortalData.class);
 
    private static final String GROUP_CHARS = "\\w|-|_";
+
    public static final String SITE_OWNER_COMPONENT = "owner";
    public static final String SITE_NAME_COMPONENT = "name";
+   public static final String APPLICATION_COMPONENT = "application";
+   public static final String PORTLET_COMPONENT = "portlet";
+   public static final String INVOKER_COMPONENT = "invoker";
+   public static final String CATEGORY_COMPONENT = "category";
+
+   public static final Pattern INVOKER_COMPONENT_PATTERN = Pattern.compile("\\w+");
+
+   public static final Context LOCAL_PORTLET_CONTEXT = GenericContext.builder().named("Local Portlet")
+      .requiredComponent(APPLICATION_COMPONENT, Identifiable.class, Pattern.compile("(" + GROUP_CHARS + "|\\.)+"))
+      .requiredComponent(PORTLET_COMPONENT, Portlet.class, Pattern.compile("\\w+"))
+      .withDefaultSeparator("/").build();
+   private static final Context WSRP_PORTLET_CONTEXT = GenericContext.builder().named("WSRP Portlet")
+      .requiredComponent(INVOKER_COMPONENT, Identifiable.class, INVOKER_COMPONENT_PATTERN)
+      .requiredComponent("portletcontext", WSRP.class, Pattern.compile("(" + GROUP_CHARS + ")+"))
+      .withDefaultSeparator(".").build();
+
    public static final Context SITE_CONTEXT = GenericContext.builder().named("Site")
       .requiredComponent(SITE_OWNER_COMPONENT, Identifiable.class, Pattern.compile(Site.PORTAL_TYPE_NAME + "|" + Site.GROUP_TYPE_NAME + "|" + Site.DASHBOARD_TYPE_NAME))
       .requiredComponent(SITE_NAME_COMPONENT, Site.class, Pattern.compile("(" + GROUP_CHARS + "|\\/)+"))
@@ -102,18 +121,12 @@
       .withDefaultSeparator("::").build();
    public static final Context GROUP_CONTEXT = GenericContext.builder().named("Group").requiredUnboundedHierarchicalComponent("group", Identifiable.class, Pattern.compile("(" + GROUP_CHARS + ")+"))
       .withDefaultSeparator("/").requireSeparatorInFirstPosition().build();
-   public static final String APPLICATION_COMPONENT_NAME = "application";
-   public static final String PORTLET_COMPONENT_NAME = "portlet";
-   public static final Context APPLICATION_CONTEXT = GenericContext.builder().named("Application").requiredComponent(APPLICATION_COMPONENT_NAME, Identifiable.class, Pattern.compile("\\w+"))
-      .requiredComponent(PORTLET_COMPONENT_NAME, Portlet.class, Pattern.compile("\\w+")).withDefaultSeparator("/").build();
    private static final Context GADGET_CONTEXT = GenericContext.builder().named("Gadget").requiredComponent("name", Gadget.class, Pattern.compile("\\w+")).build();
    private static final Context USER_CONTEXT = GenericContext.builder().named("User").requiredComponent("name", Identifiable.class, Pattern.compile("[a-zA-Z0-9]+")).build();
    private static final Context CATEGORY_CONTEXT = GenericContext.builder().named("Category").requiredComponent("name", Category.class, Pattern.compile("\\w+")).build();
-   private static final Context WSRP_CONTEXT = GenericContext.builder().named("WSRP").requiredComponent("invoker", Identifiable.class, Pattern.compile("\\w+"))
-      .requiredComponent("portletcontext", WSRP.class, Pattern.compile(GROUP_CHARS + "+")).withDefaultSeparator(".").build();
-   private static final String MANAGED = "managed";
-   private static final Context MANAGED_CONTENT_CONTEXT = GenericContext.builder().named("ManagedContent")
-      .requiredComponent(MANAGED, ManagedContent.class, Pattern.compile(MANAGED))
+   public static final Context MANAGED_CONTENT_CONTEXT = GenericContext.builder().named("ManagedContent")
+      .requiredComponent(CATEGORY_COMPONENT, Category.class, Pattern.compile("\\w+"))
+      .requiredComponent("name", ManagedContent.class, Pattern.compile("(" + GROUP_CHARS + "|\\.)+"))
       .requiredComponent("content", Content.class, Pattern.compile(".+"))
       .withDefaultSeparator(":")
       .build();
@@ -126,8 +139,9 @@
    private UserPortalConfigService configService;
    private Map<Type, Object> properties = new HashMap<Type, Object>(7);
    private LifecycleManager lcManager = GateIn.NO_OP_MANAGER;
+   private FederatingPortletInvoker portletInvoker;
 
-   public GateInImpl(ExoContainerContext context, InitParams params, ConfigurationManager configurationManager)
+   public GateInImpl(ExoContainerContext context, InitParams params, ConfigurationManager configurationManager, ExoKernelIntegration exoKernelIntegration)
    {
       container = context.getContainer();
    }
@@ -138,16 +152,15 @@
       Class<Content> contentClass = getContentClassFor(type);
       if (Gadget.class.isAssignableFrom(contentClass))
       {
-         //TODO: for a gadget, it should probably be using application.getID instead of getContentId
          return staticGadgetId(application.getContentId());
       }
       else if (WSRP.class.isAssignableFrom(contentClass))
       {
-         return parseWSRPPortletId(application.getId());
+         return parseWSRPPortletId(application.getContentId());
       }
       else if (Portlet.class.isAssignableFrom(contentClass))
       {
-         return parsePortletId(application.getId());
+         return parsePortletId(application.getContentId());
       }
       else
       {
@@ -509,7 +522,7 @@
 
    public Id<Portlet> portletId(String application, String portlet)
    {
-      return APPLICATION_CONTEXT.create(Portlet.class, application, portlet);
+      return LOCAL_PORTLET_CONTEXT.create(Portlet.class, application, portlet);
    }
 
    public static Id<Portlet> parsePortletId(String contentId)
@@ -520,7 +533,7 @@
       }
       else
       {
-         return APPLICATION_CONTEXT.parse(contentId, Portlet.class);
+         return LOCAL_PORTLET_CONTEXT.parse(contentId, Portlet.class);
       }
    }
 
@@ -531,12 +544,12 @@
 
    private static Id<WSRP> staticWSRPPortletId(String invoker, String portlet)
    {
-      return WSRP_CONTEXT.create(WSRP.class, invoker, portlet);
+      return WSRP_PORTLET_CONTEXT.create(WSRP.class, invoker, portlet);
    }
 
    public static Id<WSRP> parseWSRPPortletId(String compositeId)
    {
-      return WSRP_CONTEXT.parse(compositeId, WSRP.class);
+      return WSRP_PORTLET_CONTEXT.parse(compositeId, WSRP.class);
    }
 
    public Id<Gadget> gadgetId(String gadgetName)
@@ -554,9 +567,9 @@
       return null;  //To change body of implemented methods use File | Settings | File Templates.
    }
 
-   public <T extends Content> Id<ManagedContent> managedContentId(Id<T> contentId)
+   public <T extends Content> Id<ManagedContent> managedContentId(Id<Category> categoryId, String name, Id<T> contentId)
    {
-      return MANAGED_CONTENT_CONTEXT.create(ManagedContent.class, MANAGED, contentId.toString());
+      return MANAGED_CONTENT_CONTEXT.create(ManagedContent.class, categoryId.toString(), name, contentId.toString());
    }
 
    public Id<Category> categoryId(String name)
@@ -582,6 +595,7 @@
       gadgetService = (GadgetRegistryService)container.getComponentInstanceOfType(GadgetRegistryService.class);
       sourceStorage = (SourceStorage)container.getComponentInstanceOfType(SourceStorage.class);
       configService = (UserPortalConfigService)container.getComponentInstanceOfType(UserPortalConfigService.class);
+      portletInvoker = (FederatingPortletInvoker)container.getComponentInstanceOfType(FederatingPortletInvoker.class);
    }
 
    public void stop()
@@ -609,6 +623,11 @@
       return sourceStorage;
    }
 
+   public FederatingPortletInvoker getPortletInvoker()
+   {
+      return portletInvoker;
+   }
+
    private PortalData getPortalDataFor(Id<Portal> portalId)
    {
       ParameterValidation.throwIllegalArgExceptionIfNull(portalId, "Portal Id");

Added: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/AbstractPortlet.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/AbstractPortlet.java	                        (rev 0)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/AbstractPortlet.java	2011-08-08 16:23:15 UTC (rev 7008)
@@ -0,0 +1,47 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.gatein.portal.api.impl.content;
+
+import org.gatein.api.content.Content;
+import org.gatein.api.id.Id;
+import org.gatein.portal.api.impl.GateInImpl;
+import org.gatein.portal.api.impl.IdentifiableImpl;
+
+/** @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a> */
+public abstract class AbstractPortlet<T extends Content<T>> extends IdentifiableImpl<T> implements Content<T>
+{
+   private final org.gatein.pc.api.Portlet portlet;
+
+   public AbstractPortlet(Id<T> id, org.gatein.pc.api.Portlet application, GateInImpl gateIn)
+   {
+      super(id, application.getInfo().getName(), gateIn);
+      this.portlet = application;
+   }
+
+   @Override
+   public String toString()
+   {
+      return getType().getName() + " Portlet '" + getName() + "' @" + getId();
+   }
+
+}

Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/CategoryImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/CategoryImpl.java	2011-08-08 14:25:29 UTC (rev 7007)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/CategoryImpl.java	2011-08-08 16:23:15 UTC (rev 7008)
@@ -31,10 +31,12 @@
 import org.gatein.api.content.Category;
 import org.gatein.api.content.Content;
 import org.gatein.api.content.ContentRegistry;
+import org.gatein.api.content.Gadget;
 import org.gatein.api.content.ManagedContent;
 import org.gatein.api.id.Id;
 import org.gatein.api.util.IterableCollection;
 import org.gatein.api.util.Type;
+import org.gatein.common.util.ParameterValidation;
 import org.gatein.mop.api.content.ContentType;
 import org.gatein.portal.api.impl.GateInImpl;
 import org.gatein.portal.api.impl.util.AdaptedIterableCollection;
@@ -63,8 +65,7 @@
       {
          public ManagedContent adapt(Application old)
          {
-            Content content = registry.get(GateInImpl.getContentIdFrom(old));
-            return new ManagedContentImpl(content, CategoryImpl.this);
+            return new ManagedContentImpl(old.getApplicationName(), GateInImpl.getContentIdFrom(old), CategoryImpl.this);
          }
 
          public boolean contains(ManagedContent managedContent)
@@ -87,6 +88,11 @@
       return sb.toString();
    }
 
+   ContentRegistry getRegistry()
+   {
+      return registry;
+   }
+
    public boolean contains(String managedContentName)
    {
       return getApplication(managedContentName) != null;
@@ -109,27 +115,20 @@
       }
    }
 
-   public <T extends Content> ManagedContent<T> addContent(Id<T> contentId)
+   public <T extends Content> ManagedContent<T> addContent(Id<T> contentId, String name)
    {
-      // get content from registry
-      T t = registry.get(contentId);
+      ParameterValidation.throwIllegalArgExceptionIfNull(contentId, "Content Id");
+      GateInImpl.MANAGED_CONTENT_CONTEXT.validateValueFor("name", name);
 
-      if (t == null)
-      {
-         throw new IllegalArgumentException("No Content with id " + contentId + " exists");
-      }
+      final ContentType<?> contentType = getContentTypeFor(contentId);
 
-      // figure out which type it is for the ApplicationRegistry
-      Type type = t.getType();
-      ContentType<?> contentType = getContentTypeFor(type);
-
       // default permissions by default
       ArrayList<String> permissions = new ArrayList<String>();
       permissions.add(UserACL.EVERYONE);
 
-      gateIn.getRegistryService().createOrReplaceContentIn(category.getName(), t.getName(), contentType, t.getId().toString(), t.getDisplayName(), null, permissions);
+      gateIn.getRegistryService().createOrReplaceContentIn(category.getName(), name, contentType, contentId.toString(), name, null, permissions);
 
-      return new ManagedContentImpl<T>(t, this);
+      return new ManagedContentImpl<T>(name, contentId, this);
    }
 
    private ContentType<?> getContentTypeFor(Type type)
@@ -152,6 +151,27 @@
       }
    }
 
+   private ContentType<?> getContentTypeFor(Id id)
+   {
+      final Class type = id.getIdentifiableType();
+      if (Gadget.class.equals(type))
+      {
+         return org.exoplatform.portal.pom.spi.gadget.Gadget.CONTENT_TYPE;
+      }
+      else if (org.gatein.api.content.Portlet.class.equals(type))
+      {
+         return Portlet.CONTENT_TYPE;
+      }
+      else if (org.gatein.api.content.WSRP.class.equals(type))
+      {
+         return WSRP.CONTENT_TYPE;
+      }
+      else
+      {
+         throw new IllegalArgumentException("Unknown Content type: " + type);
+      }
+   }
+
    public String getDescription()
    {
       return category.getDescription();
@@ -214,8 +234,8 @@
          return null;
       }
 
-      Content content = registry.get(GateInImpl.getContentIdFrom(application));
-      return new ManagedContentImpl(content, this);
+      final Id<? extends Content> contentId = GateInImpl.getContentIdFrom(application);
+      return new ManagedContentImpl(name, contentId, this);
    }
 
    public IterableCollection<String> getKnownManagedContentNames()

Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java	2011-08-08 14:25:29 UTC (rev 7007)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java	2011-08-08 16:23:15 UTC (rev 7008)
@@ -36,6 +36,7 @@
 import org.gatein.api.util.IterableCollection;
 import org.gatein.api.util.IterableIdentifiableCollection;
 import org.gatein.api.util.Query;
+import org.gatein.pc.api.PortletContext;
 import org.gatein.portal.api.impl.GateInImpl;
 import org.gatein.portal.api.impl.portal.PortalImpl;
 import org.gatein.portal.api.impl.util.AdaptedIterableCollection;
@@ -204,7 +205,17 @@
          gateIn.begin();
          if (Portlet.class.equals(type) || WSRP.class.equals(type))
          {
-            regitryItem = gateIn.getRegistryService().getApplication(id.toString());
+            final PortletContext portletContext;
+            if (!id.knowsComponent(GateInImpl.INVOKER_COMPONENT))
+            {
+               portletContext = PortletContext.createPortletContext(id.getComponent(GateInImpl.APPLICATION_COMPONENT), id.getComponent(GateInImpl.PORTLET_COMPONENT));
+               regitryItem = gateIn.getPortletInvoker().getFederatedInvoker("local").getPortletInvoker().getPortlet(portletContext);
+            }
+            else
+            {
+               portletContext = PortletContext.createPortletContext(id.toString());
+               regitryItem = gateIn.getPortletInvoker().getPortlet(portletContext);
+            }
          }
          else if (Gadget.class.equals(type))
          {
@@ -233,7 +244,7 @@
       Object result;
       if (Portlet.class.equals(wanted))
       {
-         result = new PortletImpl((Id<Portlet>)id, (Application)registryItem, gateIn);
+         result = new PortletImpl((Id<Portlet>)id, (org.gatein.pc.api.Portlet)registryItem, gateIn);
       }
       else if (Gadget.class.equals(wanted))
       {
@@ -241,7 +252,7 @@
       }
       else if (WSRP.class.equals(wanted))
       {
-         result = new WSRPImpl((Id<WSRP>)id, (Application)registryItem, gateIn);
+         result = new WSRPImpl((Id<WSRP>)id, (org.gatein.pc.api.Portlet)registryItem, gateIn);
       }
       else
       {

Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ManagedContentImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ManagedContentImpl.java	2011-08-08 14:25:29 UTC (rev 7007)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ManagedContentImpl.java	2011-08-08 16:23:15 UTC (rev 7008)
@@ -35,7 +35,8 @@
  */
 public class ManagedContentImpl<T extends Content> implements ManagedContent<T>
 {
-   private final T content;
+   private T content;
+   private final Id<T> contentId;
    private final Id<ManagedContent<T>> id;
    private final CategoryImpl category;
    private String name;
@@ -43,18 +44,27 @@
    private String description;
 
 
-   public ManagedContentImpl(T content, CategoryImpl category)
+   ManagedContentImpl(T content, CategoryImpl category)
    {
       ParameterValidation.throwIllegalArgExceptionIfNull(content, "Content");
       this.content = content;
-      this.id = content.getGateIn().managedContentId(content.getId());
+      this.contentId = content.getId();
+      this.id = content.getGateIn().managedContentId(category.getId(), content.getName(), content.getId());
       this.category = category;
    }
 
+   ManagedContentImpl(String name, Id contentId, CategoryImpl category)
+   {
+      this.name = name;
+      this.contentId = contentId;
+      this.id = category.getGateIn().managedContentId(category.getId(), name, contentId);
+      this.category = category;
+   }
+
    @Override
    public String toString()
    {
-      return "ManagedContent '" + getName() + "' =>" + content;
+      return "ManagedContent '" + getName() + "' =>" + getContent();
    }
 
    public Id<ManagedContent<T>> getId()
@@ -68,7 +78,7 @@
       {
          return name;
       }
-      return content.getName();
+      return getContent().getName();
    }
 
    public void setName(String name)
@@ -83,12 +93,12 @@
       {
          return displayName;
       }
-      return content.getDisplayName();
+      return getContent().getDisplayName();
    }
 
    public GateIn getGateIn()
    {
-      return content.getGateIn();
+      return getContent().getGateIn();
    }
 
    public void setDisplayName(String displayName)
@@ -98,6 +108,11 @@
 
    public T getContent()
    {
+      if (content == null)
+      {
+         content = category.getRegistry().get(contentId);
+      }
+
       return content;
    }
 

Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/PortletImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/PortletImpl.java	2011-08-08 14:25:29 UTC (rev 7007)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/PortletImpl.java	2011-08-08 16:23:15 UTC (rev 7008)
@@ -22,31 +22,20 @@
 
 package org.gatein.portal.api.impl.content;
 
-import org.exoplatform.application.registry.Application;
 import org.gatein.api.content.Content;
 import org.gatein.api.content.Portlet;
 import org.gatein.api.id.Id;
 import org.gatein.api.util.Type;
 import org.gatein.portal.api.impl.GateInImpl;
-import org.gatein.portal.api.impl.IdentifiableImpl;
 
 /** @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a> */
-public class PortletImpl extends IdentifiableImpl<Portlet> implements Portlet
+public class PortletImpl extends AbstractPortlet<Portlet> implements Portlet
 {
-   private final Application application;
-
-   public PortletImpl(Id<Portlet> id, Application application, GateInImpl gateIn)
+   public PortletImpl(Id<Portlet> id, org.gatein.pc.api.Portlet application, GateInImpl gateIn)
    {
-      super(id, application.getApplicationName(), gateIn);
-      this.application = application;
+      super(id, application, gateIn);
    }
 
-   @Override
-   public String toString()
-   {
-      return "Application '" + getName() + "' @" + getId();
-   }
-
    public Type<Portlet> getType()
    {
       return Content.PORTLET;

Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/WSRPImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/WSRPImpl.java	2011-08-08 14:25:29 UTC (rev 7007)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/WSRPImpl.java	2011-08-08 16:23:15 UTC (rev 7008)
@@ -22,20 +22,18 @@
 
 package org.gatein.portal.api.impl.content;
 
-import org.exoplatform.application.registry.Application;
 import org.gatein.api.content.Content;
 import org.gatein.api.content.WSRP;
 import org.gatein.api.id.Id;
 import org.gatein.api.util.Type;
 import org.gatein.portal.api.impl.GateInImpl;
-import org.gatein.portal.api.impl.IdentifiableImpl;
 
 /** @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a> */
-public class WSRPImpl extends IdentifiableImpl<WSRP> implements WSRP
+public class WSRPImpl extends AbstractPortlet<WSRP> implements WSRP
 {
-   public WSRPImpl(Id<WSRP> id, Application application, GateInImpl gateIn)
+   public WSRPImpl(Id<WSRP> id, org.gatein.pc.api.Portlet application, GateInImpl gateIn)
    {
-      super(id, application.getApplicationName(), gateIn);
+      super(id, application, gateIn);
    }
 
    public Type<WSRP> getType()

Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java	2011-08-08 14:25:29 UTC (rev 7007)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java	2011-08-08 16:23:15 UTC (rev 7008)
@@ -26,6 +26,7 @@
 import org.gatein.api.id.Context;
 import org.gatein.api.id.Id;
 import org.gatein.api.id.Identifiable;
+import org.gatein.portal.api.impl.GateInImpl;
 
 /** @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a> */
 public class ComplexApplicationContext implements Context
@@ -103,4 +104,14 @@
    {
       return false;  // no components are hierarchical
    }
+
+   public boolean hasComponent(String component)
+   {
+      return GateInImpl.APPLICATION_COMPONENT.equals(component) || GateInImpl.PORTLET_COMPONENT.equals(component) || GateInImpl.CATEGORY_COMPONENT.equals(component) || GateInImpl.INVOKER_COMPONENT.equals(component);
+   }
+
+   public void validateValueFor(String component, String value) throws IllegalArgumentException
+   {
+      // todo
+   }
 }

Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java	2011-08-08 14:25:29 UTC (rev 7007)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java	2011-08-08 16:23:15 UTC (rev 7008)
@@ -25,6 +25,7 @@
 import org.gatein.api.content.Portlet;
 import org.gatein.api.id.Context;
 import org.gatein.api.id.Id;
+import org.gatein.api.id.RenderingContext;
 import org.gatein.portal.api.impl.GateInImpl;
 
 /** @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a> */
@@ -37,9 +38,6 @@
    private final String portlet;
    private final Context context;
 
-   public static final String INVOKER_COMPONENT = "invoker";
-   public static final String CATEGORY_COMPONENT = "category";
-
    public ComplexApplicationId(String category, String appName, String portletName, ComplexApplicationContext context)
    {
       this.category = category;
@@ -54,7 +52,7 @@
       return toString(context);
    }
 
-   public String toString(Context context)
+   public String toString(RenderingContext context)
    {
       if (this.context.equals(context))
       {
@@ -117,19 +115,19 @@
 
    public String getComponent(String component)
    {
-      if (GateInImpl.APPLICATION_COMPONENT_NAME.equals(component))
+      if (GateInImpl.APPLICATION_COMPONENT.equals(component))
       {
          return app;
       }
-      else if (GateInImpl.PORTLET_COMPONENT_NAME.equals(component))
+      else if (GateInImpl.PORTLET_COMPONENT.equals(component))
       {
          return portlet;
       }
-      else if (INVOKER_COMPONENT.equals(component))
+      else if (GateInImpl.INVOKER_COMPONENT.equals(component))
       {
          return LOCAL;
       }
-      else if (CATEGORY_COMPONENT.equals(component))
+      else if (GateInImpl.CATEGORY_COMPONENT.equals(component))
       {
          return category;
       }
@@ -169,6 +167,11 @@
       // do nothing as it shouldn't be called
    }
 
+   public boolean knowsComponent(String name)
+   {
+      return context.hasComponent(name);
+   }
+
    public int compareTo(Id o)
    {
       return toString().compareTo(o.toString());

Modified: portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java
===================================================================
--- portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java	2011-08-08 14:25:29 UTC (rev 7007)
+++ portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java	2011-08-08 16:23:15 UTC (rev 7008)
@@ -34,9 +34,9 @@
    public void checkParsing()
    {
       final Id<Portlet> id = ComplexApplicationContext.INSTANCE.parse("category/local._webapp.portlet", Portlet.class);
-      assert "category".equals(id.getComponent(ComplexApplicationId.CATEGORY_COMPONENT));
-      assert "webapp".equals(id.getComponent(GateInImpl.APPLICATION_COMPONENT_NAME));
-      assert "portlet".equals(id.getComponent(GateInImpl.PORTLET_COMPONENT_NAME));
+      assert "category".equals(id.getComponent(GateInImpl.CATEGORY_COMPONENT));
+      assert "webapp".equals(id.getComponent(GateInImpl.APPLICATION_COMPONENT));
+      assert "portlet".equals(id.getComponent(GateInImpl.PORTLET_COMPONENT));
 
       assert id.equals(ComplexApplicationContext.INSTANCE.parse(id.toString()));
    }



More information about the gatein-commits mailing list