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

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Sep 2 09:22:58 EDT 2011


Author: julien_viet
Date: 2011-09-02 09:22:58 -0400 (Fri, 02 Sep 2011)
New Revision: 7292

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/GadgetImpl.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/portal/NavigationImpl.java
   portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/AbstractAPITestCase.java
   portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/content/ContentRegistryTestCase.java
Log:
test more portlet stuff


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-09-02 09:47:08 UTC (rev 7291)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java	2011-09-02 13:22:58 UTC (rev 7292)
@@ -52,6 +52,7 @@
 import org.exoplatform.services.organization.UserHandler;
 import org.exoplatform.services.security.Identity;
 import org.exoplatform.services.security.MembershipEntry;
+import org.exoplatform.web.application.RequestContext;
 import org.gatein.api.GateIn;
 import org.gatein.api.content.Category;
 import org.gatein.api.content.Content;
@@ -84,6 +85,7 @@
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.regex.Pattern;
 
@@ -739,6 +741,11 @@
       lcManager.end();
    }
 
+   public Locale getUserLocale()
+   {
+      return RequestContext.getCurrentInstance().getLocale();
+   }
+
    public GadgetRegistryService getGadgetService()
    {
       return gadgetService;

Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/GadgetImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/GadgetImpl.java	2011-09-02 09:47:08 UTC (rev 7291)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/GadgetImpl.java	2011-09-02 13:22:58 UTC (rev 7292)
@@ -60,6 +60,11 @@
       return URI.create(gadget.getUrl());
    }
 
+   public String getDescription()
+   {
+      throw new UnsupportedOperationException();
+   }
+
    public Data getData()
    {
       if (isLocal())

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-09-02 09:47:08 UTC (rev 7291)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/PortletImpl.java	2011-09-02 13:22:58 UTC (rev 7292)
@@ -25,9 +25,13 @@
 import org.gatein.api.content.Content;
 import org.gatein.api.content.Portlet;
 import org.gatein.api.util.Type;
+import org.gatein.common.i18n.LocalizedString;
+import org.gatein.pc.api.info.MetaInfo;
 import org.gatein.portal.api.impl.GateInImpl;
 import org.gatein.portal.api.impl.IdentifiableImpl;
 
+import java.util.Locale;
+
 /** @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a> */
 public class PortletImpl extends IdentifiableImpl<Portlet, Portlet.Id> implements Portlet
 {
@@ -46,6 +50,32 @@
       this.portlet = portlet;
    }
 
+   private String getMetaValue(String key)
+   {
+      Locale locale = gateIn.getUserLocale();
+      LocalizedString metaValue = portlet.getInfo().getMeta().getMetaValue(key);
+      if (metaValue != null)
+      {
+         LocalizedString.Value value = metaValue.getValue(locale, true);
+         if (value != null)
+         {
+            return value.getString();
+         }
+      }
+      return null;
+   }
+
+   @Override
+   public String getDisplayName()
+   {
+      return getMetaValue(MetaInfo.DISPLAY_NAME);
+   }
+
+   public String getDescription()
+   {
+      return getMetaValue(MetaInfo.DESCRIPTION);
+   }
+
    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-09-02 09:47:08 UTC (rev 7291)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/WSRPImpl.java	2011-09-02 13:22:58 UTC (rev 7292)
@@ -45,6 +45,11 @@
       this.portlet = portlet;
    }
 
+   public String getDescription()
+   {
+      throw new UnsupportedOperationException();
+   }
+
    public Type<WSRP> getType()
    {
       return Content.WSRP;

Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java	2011-09-02 09:47:08 UTC (rev 7291)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java	2011-09-02 13:22:58 UTC (rev 7292)
@@ -249,7 +249,7 @@
          }
          else if (id != null)
          {
-            Locale userLocale = getUserLocale();
+            Locale userLocale = gateIn.getUserLocale();
             DescriptionService descriptionService = gateIn.getDescriptionService();
             Described.State description = descriptionService.resolveDescription(id, userLocale);
             if (description != null)
@@ -270,18 +270,13 @@
       return displayName;
    }
 
-   public Locale getUserLocale()
-   {
-      return RequestContext.getCurrentInstance().getLocale();
-   }
-
    public ResourceBundle getBundle()
    {
       if (bundle == null)
       {
          ExoContainer container = ExoContainerContext.getCurrentContainer();
          ResourceBundleManager rbMgr = (ResourceBundleManager)container.getComponentInstanceOfType(ResourceBundleManager.class);
-         Locale locale = getUserLocale();
+         Locale locale = gateIn.getUserLocale();
          bundle = rbMgr.getNavigationResourceBundle(
             locale.getLanguage(),
             site.getId().getType().getName(),

Modified: portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/AbstractAPITestCase.java
===================================================================
--- portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/AbstractAPITestCase.java	2011-09-02 09:47:08 UTC (rev 7291)
+++ portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/AbstractAPITestCase.java	2011-09-02 13:22:58 UTC (rev 7292)
@@ -21,6 +21,8 @@
 import org.gatein.api.GateIn;
 import org.gatein.pc.api.PortletInvoker;
 
+import java.util.Locale;
+
 /** @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a> */
 @ConfiguredBy({
    @ConfigurationUnit(scope = ContainerScope.PORTAL, path = "conf/exo.portal.component.test.jcr-configuration.xml"),
@@ -47,6 +49,9 @@
    /** . */
    protected GateIn gatein;
 
+   /** The current user locale, may be changed for testing purpose. */
+   protected Locale userLocale;
+
    @Override
    protected void setUp() throws Exception
    {
@@ -71,12 +76,20 @@
       this.navService = navService;
       this.storage = (ModelDataStorage)container.getComponentInstanceOfType(ModelDataStorage.class);
       this.invoker = invoker;
+      this.userLocale = Locale.ENGLISH;
 
       //
       begin();
 
       //
-      RequestContext.setCurrentInstance(new SimpleRequestContext(null));
+      RequestContext.setCurrentInstance(new SimpleRequestContext(null)
+      {
+         @Override
+         public Locale getLocale()
+         {
+            return userLocale;
+         }
+      });
    }
 
    @Override

Modified: portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/content/ContentRegistryTestCase.java
===================================================================
--- portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/content/ContentRegistryTestCase.java	2011-09-02 09:47:08 UTC (rev 7291)
+++ portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/content/ContentRegistryTestCase.java	2011-09-02 13:22:58 UTC (rev 7292)
@@ -44,10 +44,13 @@
       PortletInfoSupport info = new PortletInfoSupport();
       info.setApplicationName("foo");
       info.setName("bar");
+      info.getMeta().setDescription("The Bar Portlet");
+      info.getMeta().setDisplayName("Bar");
       invoker.localInvoker.addPortlet("/foo.bar", info);
 
       //
       Portlet portlet = registry.getContent(new Portlet.Id("foo", "bar"));
       assertEquals("bar", portlet.getName());
+      assertEquals("Bar", portlet.getDisplayName());
    }
 }



More information about the gatein-commits mailing list