gatein SVN: r7006 - in epp/portal/branches/EPP_5_2_Branch: portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component and 1 other directory.
by do-not-reply@jboss.org
Author: hfnukal
Date: 2011-08-08 04:59:59 -0400 (Mon, 08 Aug 2011)
New Revision: 7006
Modified:
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIPortletInfo.java
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIPortletManagement.java
Log:
JBEPP-983 Different portlet names for remote portlets added in "Portlet" menu
Modified: epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java 2011-08-08 07:17:58 UTC (rev 7005)
+++ epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java 2011-08-08 08:59:59 UTC (rev 7006)
@@ -542,6 +542,7 @@
if (srcChild instanceof ApplicationData)
{
ApplicationData<?> app = (ApplicationData)srcChild;
+ // todo julien: shouldn't we be checking for WSRP as well here?
if (app.getType() == ApplicationType.PORTLET && app.getState() instanceof TransientApplicationState)
{
TransientApplicationState<?> state = (TransientApplicationState<?>)app.getState();
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIPortletInfo.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIPortletInfo.java 2011-08-08 07:17:58 UTC (rev 7005)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIPortletInfo.java 2011-08-08 08:59:59 UTC (rev 7006)
@@ -74,7 +74,16 @@
UICategorySelector selector = uiPortletInfo.addChild(UICategorySelector.class, null, CATEGORY_ID);
Application app = new Application();
app.setApplicationName(portlet.getName());
- app.setType(ApplicationType.PORTLET);
+
+ // I really hate the fact that the code to create Applications is spread all over and doesn't properly deal with application types
+ if(portlet.isRemote())
+ {
+ app.setType(ApplicationType.WSRP_PORTLET);
+ }
+ else
+ {
+ app.setType(ApplicationType.PORTLET);
+ }
app.setDisplayName(portlet.getDisplayName());
app.setContentId(portlet.getId());
app.setAccessPermissions(new ArrayList<String>());
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIPortletManagement.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIPortletManagement.java 2011-08-08 07:17:58 UTC (rev 7005)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIPortletManagement.java 2011-08-08 08:59:59 UTC (rev 7006)
@@ -1,16 +1,16 @@
/**
* Copyright (C) 2009 eXo Platform SAS.
- *
+ *
* 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
@@ -19,12 +19,12 @@
package org.exoplatform.applicationregistry.webui.component;
+import org.exoplatform.commons.serialization.api.annotations.Converted;
+import org.exoplatform.commons.serialization.api.annotations.Serialized;
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.web.application.ApplicationMessage;
import org.exoplatform.webui.application.WebuiRequestContext;
-import org.exoplatform.commons.serialization.api.annotations.Converted;
-import org.exoplatform.commons.serialization.api.annotations.Serialized;
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.config.annotation.EventConfig;
import org.exoplatform.webui.core.UIContainer;
@@ -33,7 +33,6 @@
import org.gatein.common.i18n.LocalizedString;
import org.gatein.pc.api.Portlet;
import org.gatein.pc.api.PortletContext;
-import org.gatein.pc.api.PortletInvoker;
import org.gatein.pc.api.info.MetaInfo;
import org.gatein.pc.api.info.PortletInfo;
import org.gatein.pc.api.info.PreferencesInfo;
@@ -49,8 +48,8 @@
/**
* Created by The eXo Platform SAS
* Author : Pham Thanh Tung
- * thanhtungty(a)gmail.com
- * Jun 24, 2008
+ * thanhtungty(a)gmail.com
+ * Jun 24, 2008
*/
@ComponentConfig(template = "app:/groovy/applicationregistry/webui/component/UIPortletManagement.gtmpl", events = {
@@ -60,6 +59,9 @@
public class UIPortletManagement extends UIContainer
{
+ /** Should match WSRPPortletInfo.PRODUCER_NAME_META_INFO_KEY */
+ private static final String PRODUCER_NAME_META_INFO_KEY = "producer-name";
+
static final public String LOCAL = "local";
static final public String REMOTE = "remote";
@@ -121,8 +123,26 @@
for (Portlet portlet : portlets)
{
PortletInfo info = portlet.getInfo();
- String appName = info.getApplicationName();
+ // in the remote case, the "application name" will be the name of the remote invoker
+ String appName;
+ if (remote)
+ {
+ LocalizedString producerNameLS = info.getMeta().getMetaValue(PRODUCER_NAME_META_INFO_KEY);
+ if (producerNameLS != null)
+ {
+ appName = producerNameLS.getDefaultString();
+ }
+ else
+ {
+ throw new IllegalStateException("Missing PortletInvoker id in remote portlet metadata");
+ }
+ }
+ else
+ {
+ appName = info.getApplicationName();
+ }
+
WebApp webApp = getWebApp(appName);
if (webApp == null)
{
@@ -144,7 +164,9 @@
for (WebApp ele : webApps)
{
if (ele.getName().equals(name))
+ {
return ele;
+ }
}
return null;
}
@@ -167,10 +189,14 @@
{
List<PortletExtra> list = webApps.get(0).getPortlets();
if (!list.isEmpty())
+ {
setSelectedPortlet(list.get(0));
+ }
}
else
+ {
setSelectedPortlet((PortletExtra)null);
+ }
}
public String[] getPortletTypes()
@@ -205,11 +231,26 @@
public void setSelectedPortlet(String id) throws Exception
{
- String[] fragments = id.split("/");
- WebApp webApp = getWebApp(fragments[0]);
+ String webAppName;
+ String portletName;
+ if (LOCAL.equals(selectedType))
+ {
+ String[] fragments = id.split("/");
+ webAppName = fragments[0];
+ portletName = fragments[1];
+ }
+ else
+ {
+ // extract PortletInvoker id to use as WebApp name
+ final int separatorIndex = id.indexOf('.');
+ webAppName = id.substring(0, separatorIndex);
+ portletName = id.substring(separatorIndex + 1);
+ }
+
+ WebApp webApp = getWebApp(webAppName);
for (PortletExtra ele : webApp.getPortlets())
{
- if (ele.getName().equals(fragments[1]))
+ if (ele.getName().equals(portletName))
{
setSelectedPortlet(ele);
break;
@@ -263,32 +304,35 @@
private PortletInfo portletInfo_;
final PortletContext context;
- private static final String SEPARATOR = "/";
- private static final int SEPARATOR_LENGTH = SEPARATOR.length();
public PortletExtra(Portlet portlet)
{
PortletInfo info = portlet.getInfo();
- String portletName = info.getName();
+
+ context = portlet.getContext();
+
String appName = info.getApplicationName();
boolean remote = portlet.isRemote();
- // if the portlet is remote, we might have an extra '/' at the beginning of the portlet name
- if(remote && portletName.startsWith(SEPARATOR))
+ String portletId;
+ if (remote)
{
- portletName = portletName.substring(SEPARATOR_LENGTH);
+ portletId = context.getId();
}
-
- String portletId = appName + SEPARATOR + portletName;
+ else
+ {
+ portletId = info.getApplicationName() + "/" + info.getName();
+ }
+
String type = remote ? REMOTE : LOCAL;
//
id_ = portletId;
group_ = appName;
- name_ = portletName;
+ name_ = info.getName();
type_ = type;
portletInfo_ = info;
- context = portlet.getContext();
+
}
public String getId()
@@ -315,7 +359,8 @@
{
try
{
- return getMetaValue(MetaInfo.DISPLAY_NAME, name_);
+ final String displayName = getMetaValue(MetaInfo.DISPLAY_NAME, name_);
+ return isRemote() ? displayName + " (remote)" : displayName;
}
catch (Exception ex)
{
@@ -351,9 +396,16 @@
{
LocalizedString metaValue = portletInfo_.getMeta().getMetaValue(metaKey);
if (metaValue == null || metaValue.getDefaultString() == null)
+ {
return defaultValue;
+ }
return metaValue.getDefaultString();
}
+
+ public boolean isRemote()
+ {
+ return REMOTE.equals(type_);
+ }
}
@Serialized
@@ -402,7 +454,9 @@
public void addPortlet(PortletExtra portlet)
{
if (portlets_ == null)
+ {
portlets_ = new ArrayList<PortletExtra>();
+ }
portlets_.add(portlet);
}
13 years, 4 months
gatein SVN: r7005 - portal/branches.
by do-not-reply@jboss.org
Author: kien_nguyen
Date: 2011-08-08 03:17:58 -0400 (Mon, 08 Aug 2011)
New Revision: 7005
Removed:
portal/branches/branch-GTNPORTAL-1963/
Log:
13 years, 4 months
gatein SVN: r7004 - in epp/portal/branches/EPP_5_2_Branch/distribution: jboss-epp and 1 other directory.
by do-not-reply@jboss.org
Author: hfnukal
Date: 2011-08-07 04:23:16 -0400 (Sun, 07 Aug 2011)
New Revision: 7004
Modified:
epp/portal/branches/EPP_5_2_Branch/distribution/jboss-epp/pom.xml
epp/portal/branches/EPP_5_2_Branch/distribution/pom.xml
Log:
JBEPP-1039 Distribution packaging
Modified: epp/portal/branches/EPP_5_2_Branch/distribution/jboss-epp/pom.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/distribution/jboss-epp/pom.xml 2011-08-05 22:39:11 UTC (rev 7003)
+++ epp/portal/branches/EPP_5_2_Branch/distribution/jboss-epp/pom.xml 2011-08-07 08:23:16 UTC (rev 7004)
@@ -150,7 +150,7 @@
<profile>
<id>epp-distribution-zip</id>
<activation>
- <activeByDefault>true</activeByDefault>
+ <activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
Modified: epp/portal/branches/EPP_5_2_Branch/distribution/pom.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/distribution/pom.xml 2011-08-05 22:39:11 UTC (rev 7003)
+++ epp/portal/branches/EPP_5_2_Branch/distribution/pom.xml 2011-08-07 08:23:16 UTC (rev 7004)
@@ -15,7 +15,7 @@
<name>Distribution</name>
<properties>
- <eap.version>5.1.1.CR1</eap.version>
+ <eap.version>5.1.1</eap.version>
<eap.groupId>org.jboss.jbossas</eap.groupId>
<eap.dir>jboss-eap-5.1</eap.dir>
<epp.dir>jboss-epp-5.2</epp.dir>
13 years, 4 months
gatein SVN: r7003 - portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2011-08-05 18:39:11 -0400 (Fri, 05 Aug 2011)
New Revision: 7003
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java
Log:
- GTNPORTAL-1989: make sure that the new ApplicationCategory has a display name otherwise it will crash the application registry portlet.
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-05 22:13:09 UTC (rev 7002)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java 2011-08-05 22:39:11 UTC (rev 7003)
@@ -155,6 +155,8 @@
{
applicationCategory = new ApplicationCategory();
applicationCategory.setName(name);
+ applicationCategory.setDisplayName(name);
+ applicationCategory.setDescription(name);
registryService.save(applicationCategory);
}
else
13 years, 4 months
gatein SVN: r7002 - portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2011-08-05 18:13:09 -0400 (Fri, 05 Aug 2011)
New Revision: 7002
Modified:
portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/ContentRegistryPortlet.java
Log:
- Improved output of ContentRegistryPortlet.
Modified: portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/ContentRegistryPortlet.java
===================================================================
--- portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/ContentRegistryPortlet.java 2011-08-05 22:12:23 UTC (rev 7001)
+++ portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/ContentRegistryPortlet.java 2011-08-05 22:13:09 UTC (rev 7002)
@@ -24,6 +24,8 @@
import org.gatein.api.GateIn;
import org.gatein.api.content.Category;
+import org.gatein.api.content.ManagedContent;
+import org.gatein.api.util.IterableCollection;
import org.gatein.api.util.IterableIdentifiableCollection;
import javax.portlet.GenericPortlet;
@@ -57,8 +59,31 @@
IterableIdentifiableCollection<Category> categories = gateIn.getDefaultPortal().getContentRegistry().getAllCategories();
for (Category category : categories)
{
- writer.println("<li>" + category + "</li>");
+ writer.println("<li>");
+ outputCategory(category, writer);
+ writer.println("</li>");
}
writer.println("</ul>");
}
+
+ private void outputCategory(Category category, PrintWriter writer) throws IOException
+ {
+ writer.println("<h2>" + category.getDisplayName() + "</h2>");
+ writer.println("<ul>");
+
+ final IterableCollection<ManagedContent> managedContents = category.getManagedContents();
+ for (ManagedContent managedContent : managedContents)
+ {
+ outputManagedContent(managedContent, writer);
+ }
+
+ writer.println("</ul><br/>");
+ }
+
+ private void outputManagedContent(ManagedContent content, PrintWriter writer) throws IOException
+ {
+ writer.println("<h3>" + content.getDisplayName() + "</h3>");
+ writer.println("Content: " + content.getContent());
+ writer.println("<br/>");
+ }
}
13 years, 4 months
gatein SVN: r7001 - in portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl: content and 1 other directory.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2011-08-05 18:12:23 -0400 (Fri, 05 Aug 2011)
New Revision: 7001
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
Log:
- Implemented ContentRegistry.getAll method.
- Made Category.getManagedContents public to follow API change.
- Moved getContentIdFrom and getContentClassFor methods to GateInImpl.
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-05 18:18:34 UTC (rev 7000)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java 2011-08-05 22:12:23 UTC (rev 7001)
@@ -24,6 +24,7 @@
import org.exoplatform.application.gadget.GadgetRegistryService;
import org.exoplatform.application.gadget.SourceStorage;
+import org.exoplatform.application.registry.Application;
import org.exoplatform.application.registry.ApplicationRegistryService;
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
@@ -32,6 +33,7 @@
import org.exoplatform.portal.config.Query;
import org.exoplatform.portal.config.UserACL;
import org.exoplatform.portal.config.UserPortalConfigService;
+import org.exoplatform.portal.config.model.ApplicationType;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.mop.SiteType;
import org.exoplatform.portal.mop.description.DescriptionService;
@@ -130,6 +132,49 @@
container = context.getContainer();
}
+ public static Id<? extends Content> getContentIdFrom(Application application)
+ {
+ ApplicationType type = application.getType();
+ 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());
+ }
+ else if (Portlet.class.isAssignableFrom(contentClass))
+ {
+ return parsePortletId(application.getId());
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unknown application type: " + type);
+ }
+ }
+
+ public static <T extends Content> Class<T> getContentClassFor(ApplicationType type)
+ {
+ if (ApplicationType.GADGET.equals(type))
+ {
+ return (Class<T>)Gadget.class;
+ }
+ else if (ApplicationType.PORTLET.equals(type))
+ {
+ return (Class<T>)Portlet.class;
+ }
+ else if (ApplicationType.WSRP_PORTLET.equals(type))
+ {
+ return (Class<T>)WSRP.class;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unknown ApplicationType: " + type);
+ }
+ }
+
public <T> T getProperty(Type<T> property)
{
if (property == null)
@@ -467,7 +512,7 @@
return APPLICATION_CONTEXT.create(Portlet.class, application, portlet);
}
- public Id<Portlet> parsePortletId(String contentId)
+ public static Id<Portlet> parsePortletId(String contentId)
{
if (contentId.contains(ComplexApplicationId.START))
{
@@ -481,16 +526,26 @@
public Id<WSRP> wsrpPortletId(String invoker, String portlet)
{
+ return staticWSRPPortletId(invoker, portlet);
+ }
+
+ private static Id<WSRP> staticWSRPPortletId(String invoker, String portlet)
+ {
return WSRP_CONTEXT.create(WSRP.class, invoker, portlet);
}
- public Id<WSRP> parseWSRPPortletId(String compositeId)
+ public static Id<WSRP> parseWSRPPortletId(String compositeId)
{
return WSRP_CONTEXT.parse(compositeId, WSRP.class);
}
public Id<Gadget> gadgetId(String gadgetName)
{
+ return staticGadgetId(gadgetName);
+ }
+
+ private static Id<Gadget> staticGadgetId(String gadgetName)
+ {
return GADGET_CONTEXT.create(Gadget.class, gadgetName);
}
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-05 18:18:34 UTC (rev 7000)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/CategoryImpl.java 2011-08-05 22:12:23 UTC (rev 7001)
@@ -25,14 +25,12 @@
import org.exoplatform.application.registry.Application;
import org.exoplatform.application.registry.ApplicationCategory;
import org.exoplatform.portal.config.UserACL;
-import org.exoplatform.portal.config.model.ApplicationType;
import org.exoplatform.portal.pom.spi.portlet.Portlet;
import org.exoplatform.portal.pom.spi.wsrp.WSRP;
import org.gatein.api.GateIn;
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;
@@ -58,14 +56,14 @@
this.gateIn = gateIn;
}
- private IterableCollection<ManagedContent> getManagedContents()
+ public IterableCollection<ManagedContent> getManagedContents()
{
List<Application> applications = category.getApplications();
return new AdaptedIterableCollection<Application, ManagedContent>(applications.size(), applications.iterator())
{
public ManagedContent adapt(Application old)
{
- Content content = registry.get(getContentIdFrom(old));
+ Content content = registry.get(GateInImpl.getContentIdFrom(old));
return new ManagedContentImpl(content, CategoryImpl.this);
}
@@ -76,29 +74,6 @@
};
}
- private Id<? extends Content> getContentIdFrom(Application application)
- {
- ApplicationType type = application.getType();
- 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 gateIn.gadgetId(application.getContentId());
- }
- else if (org.gatein.api.content.WSRP.class.isAssignableFrom(contentClass))
- {
- return gateIn.parseWSRPPortletId(application.getId());
- }
- else if (org.gatein.api.content.Portlet.class.isAssignableFrom(contentClass))
- {
- return gateIn.parsePortletId(application.getId());
- }
- else
- {
- throw new IllegalArgumentException("Unknown application type: " + type);
- }
- }
-
@Override
public String toString()
{
@@ -177,26 +152,6 @@
}
}
- private <T extends Content> Class<T> getContentClassFor(ApplicationType type)
- {
- if (ApplicationType.GADGET.equals(type))
- {
- return (Class<T>)Gadget.class;
- }
- else if (ApplicationType.PORTLET.equals(type))
- {
- return (Class<T>)org.gatein.api.content.Portlet.class;
- }
- else if (ApplicationType.WSRP_PORTLET.equals(type))
- {
- return (Class<T>)org.gatein.api.content.WSRP.class;
- }
- else
- {
- throw new IllegalArgumentException("Unknown ApplicationType: " + type);
- }
- }
-
public String getDescription()
{
return category.getDescription();
@@ -259,7 +214,7 @@
return null;
}
- Content content = registry.get(getContentIdFrom(application));
+ Content content = registry.get(GateInImpl.getContentIdFrom(application));
return new ManagedContentImpl(content, this);
}
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-05 18:18:34 UTC (rev 7000)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java 2011-08-05 22:12:23 UTC (rev 7001)
@@ -22,6 +22,7 @@
package org.gatein.portal.api.impl.content;
+import org.exoplatform.application.registry.Application;
import org.exoplatform.application.registry.ApplicationCategory;
import org.exoplatform.application.registry.ApplicationRegistryService;
import org.gatein.api.content.Category;
@@ -195,74 +196,57 @@
{
Class<T> type = id.getIdentifiableType();
Object result;
- if (Portlet.class.equals(type))
+ Object regitryItem;
+ try
{
- try
+ gateIn.begin();
+ if (Portlet.class.equals(type) || WSRP.class.equals(type))
{
- gateIn.begin();
- org.exoplatform.application.registry.Application application = gateIn.getRegistryService().getApplication(id.toString());
- if (application == null)
- {
- return null;
- }
- result = new PortletImpl((Id<Portlet>)id, application, gateIn);
+ regitryItem = gateIn.getRegistryService().getApplication(id.toString());
}
- catch (Exception e)
+ else if (Gadget.class.equals(type))
{
- throw new RuntimeException(e);
+ regitryItem = gateIn.getGadgetService().getGadget(id.toString());
}
- finally
+ else
{
- gateIn.end();
+ throw new IllegalArgumentException("Unknown Content type: " + type.getCanonicalName());
}
+
+ result = newContentFrom(id, regitryItem, type);
+ return type.cast(result);
}
- else if (Gadget.class.equals(type))
+ catch (Exception e)
{
- try
- {
- gateIn.begin();
- org.exoplatform.application.gadget.Gadget gadget = gateIn.getGadgetService().getGadget(id.toString());
- if (gadget == null)
- {
- return null;
- }
- result = new GadgetImpl((Id<Gadget>)id, gadget, gateIn);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- gateIn.end();
- }
+ throw new RuntimeException(e);
}
- else if (WSRP.class.equals(type))
+ finally
{
- try
- {
- gateIn.begin();
- org.exoplatform.application.registry.Application application = gateIn.getRegistryService().getApplication(id.toString());
- if (application == null)
- {
- return null;
- }
- result = new WSRPImpl((Id<WSRP>)id, application, gateIn);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- gateIn.end();
- }
+ gateIn.end();
}
+ }
+
+ private <T extends Content> Content newContentFrom(Id id, Object registryItem, Class<T> wanted)
+ {
+ Object result;
+ if (Portlet.class.equals(wanted))
+ {
+ result = new PortletImpl((Id<Portlet>)id, (Application)registryItem, gateIn);
+ }
+ else if (Gadget.class.equals(wanted))
+ {
+ result = new GadgetImpl((Id<Gadget>)id, (org.exoplatform.application.gadget.Gadget)registryItem, gateIn);
+ }
+ else if (WSRP.class.equals(wanted))
+ {
+ result = new WSRPImpl((Id<WSRP>)id, (Application)registryItem, gateIn);
+ }
else
{
- throw new IllegalArgumentException("Unknown Content type: " + type.getCanonicalName());
+ throw new IllegalArgumentException("Unknown Content type: " + wanted.getCanonicalName());
}
- return type.cast(result);
+
+ return wanted.cast(result);
}
public IterableIdentifiableCollection<ManagedContent> getManagedContents(Query<ManagedContent> query)
@@ -277,7 +261,49 @@
public IterableIdentifiableCollection<Content> getAll()
{
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ try
+ {
+ gateIn.begin();
+ final List<Application> applications = gateIn.getRegistryService().getAllApplications();
+
+ return new AdaptedIterableIdentifiableCollection<Application, Content>(applications.size(), applications.iterator())
+ {
+ public Content adapt(Application old)
+ {
+ final Id<? extends Content> id = GateInImpl.getContentIdFrom(old);
+
+ // if we're asking for a gadget, we need to retrieve it from the gadget registry first
+ if (Gadget.class.isAssignableFrom(id.getIdentifiableType()))
+ {
+ return get(id);
+ }
+ else
+ {
+ return newContentFrom(id, old, id.getIdentifiableType());
+ }
+ }
+
+ public boolean contains(Id<Content> t)
+ {
+ try
+ {
+ return gateIn.getRegistryService().getApplication(t.toString()) != null;
+ }
+ catch (Exception e)
+ {
+ return false;
+ }
+ }
+ };
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ gateIn.end();
+ }
}
public int size()
@@ -292,6 +318,6 @@
public <U extends Content> IterableIdentifiableCollection<U> getAllSatisfying(Query<U> query)
{
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ return null;
}
}
13 years, 4 months
gatein SVN: r7000 - portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2011-08-05 14:18:34 -0400 (Fri, 05 Aug 2011)
New Revision: 7000
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java
Log:
- GTNPORTAL-1988: added implementation for deleteCategory method.
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-05 18:03:16 UTC (rev 6999)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java 2011-08-05 18:18:34 UTC (rev 7000)
@@ -64,6 +64,25 @@
return getOrCreateCategory(name, false);
}
+ public void deleteCategory(String name)
+ {
+ try
+ {
+ final ApplicationCategory category = new ApplicationCategory();
+ category.setName(name);
+ gateIn.begin();
+ gateIn.getRegistryService().remove(category);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ gateIn.end();
+ }
+ }
+
public IterableCollection<String> getCategoryNames()
{
try
13 years, 4 months
gatein SVN: r6999 - in portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl: portal and 1 other directory.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2011-08-05 14:03:16 -0400 (Fri, 05 Aug 2011)
New Revision: 6999
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/portal/NavigationImpl.java
Log:
- GTNPORTAL-1985: removed redundant method.
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-05 17:17:06 UTC (rev 6998)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java 2011-08-05 18:03:16 UTC (rev 6999)
@@ -32,7 +32,6 @@
import org.gatein.api.content.Portlet;
import org.gatein.api.content.WSRP;
import org.gatein.api.id.Id;
-import org.gatein.api.util.Filter;
import org.gatein.api.util.IterableCollection;
import org.gatein.api.util.IterableIdentifiableCollection;
import org.gatein.api.util.Query;
@@ -272,11 +271,6 @@
return false; //To change body of implemented methods use File | Settings | File Templates.
}
- public <U extends Content> IterableIdentifiableCollection<U> getAllWhere(Filter<U> filter)
- {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
public <U extends Content> IterableIdentifiableCollection<U> getAllSatisfying(Query<U> query)
{
return null; //To change body of implemented methods use File | Settings | File Templates.
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-08-05 17:17:06 UTC (rev 6998)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java 2011-08-05 18:03:16 UTC (rev 6999)
@@ -43,7 +43,6 @@
import org.gatein.api.portal.Navigation;
import org.gatein.api.portal.Page;
import org.gatein.api.portal.Site;
-import org.gatein.api.util.Filter;
import org.gatein.api.util.IterableIdentifiableCollection;
import org.gatein.api.util.Query;
import org.gatein.common.net.URLTools;
@@ -258,11 +257,6 @@
return site.getIdForChild(key);
}
- public <U extends Navigation> IterableIdentifiableCollection<U> getAllWhere(Filter<U> filter)
- {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
public <U extends Navigation> IterableIdentifiableCollection<U> getAllSatisfying(Query<U> query)
{
return null; //To change body of implemented methods use File | Settings | File Templates.
13 years, 4 months
gatein SVN: r6998 - portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2011-08-05 13:17:06 -0400 (Fri, 05 Aug 2011)
New Revision: 6998
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/CategoryImpl.java
Log:
- GTNPORTAL-1982: added setDisplayName method.
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-05 16:15:50 UTC (rev 6997)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/CategoryImpl.java 2011-08-05 17:17:06 UTC (rev 6998)
@@ -205,6 +205,11 @@
public void setDescription(String description)
{
category.setDescription(description);
+ save();
+ }
+
+ private void save()
+ {
try
{
gateIn.begin();
@@ -220,6 +225,12 @@
}
}
+ public void setDisplayName(String displayName)
+ {
+ category.setDisplayName(displayName);
+ save();
+ }
+
public void removeContent(String managedContentName)
{
Application application = getApplication(managedContentName);
13 years, 4 months
gatein SVN: r6997 - in portal/branches/api/component/api-impl/src: main/java/org/gatein/portal/api/impl/id and 2 other directories.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2011-08-05 12:15:50 -0400 (Fri, 05 Aug 2011)
New Revision: 6997
Added:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/
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/
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java
Log:
- Added ComplexApplicationContext and ComplexApplicationId since I couldn't get the generic versions to work in a reasonable amount of time with multiple separators. :(
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-05 06:40:35 UTC (rev 6996)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java 2011-08-05 16:15:50 UTC (rev 6997)
@@ -67,6 +67,8 @@
import org.gatein.api.util.IterableIdentifiableCollection;
import org.gatein.api.util.Type;
import org.gatein.common.util.ParameterValidation;
+import org.gatein.portal.api.impl.id.ComplexApplicationContext;
+import org.gatein.portal.api.impl.id.ComplexApplicationId;
import org.gatein.portal.api.impl.portal.DashboardSiteImpl;
import org.gatein.portal.api.impl.portal.GroupSiteImpl;
import org.gatein.portal.api.impl.portal.PageImpl;
@@ -98,8 +100,10 @@
.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 Context APPLICATION_CONTEXT = GenericContext.builder().named("Application").requiredComponent("application", Identifiable.class, Pattern.compile("\\w+"))
- .requiredComponent("portlet", Portlet.class, Pattern.compile("\\w+")).withDefaultSeparator("/").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();
@@ -465,7 +469,14 @@
public Id<Portlet> parsePortletId(String contentId)
{
- return APPLICATION_CONTEXT.parse(contentId, Portlet.class);
+ if (contentId.contains(ComplexApplicationId.START))
+ {
+ return ComplexApplicationContext.INSTANCE.parse(contentId, Portlet.class);
+ }
+ else
+ {
+ return APPLICATION_CONTEXT.parse(contentId, Portlet.class);
+ }
}
public Id<WSRP> wsrpPortletId(String invoker, String portlet)
Added: 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 (rev 0)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java 2011-08-05 16:15:50 UTC (rev 6997)
@@ -0,0 +1,106 @@
+/*
+* 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.id;
+
+import org.gatein.api.content.Portlet;
+import org.gatein.api.id.Context;
+import org.gatein.api.id.Id;
+import org.gatein.api.id.Identifiable;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a> */
+public class ComplexApplicationContext implements Context
+{
+ public static final Context INSTANCE = new ComplexApplicationContext();
+
+ public String getName()
+ {
+ return "Application with prefixed invoker id";
+ }
+
+ public Id create(String rootComponent, String... additionalComponent)
+ {
+ return create(Identifiable.class, rootComponent, additionalComponent);
+ }
+
+ public <T extends Identifiable> Id<T> create(Class<T> type, String rootComponent, String... additionalComponents)
+ {
+ if (!type.isAssignableFrom(Portlet.class))
+ {
+ throw new IllegalArgumentException("ComplexApplicationContext can only create Id<Portlet>. Was asked to create Id<" + type.getSimpleName() + ">");
+ }
+
+ if (additionalComponents != null && additionalComponents.length == 2)
+ {
+ return (Id<T>)new ComplexApplicationId(rootComponent, additionalComponents[0], additionalComponents[1], this);
+ }
+ else
+ {
+ throw new IllegalArgumentException("ComplexApplicationContext can only create Ids with 3 components: category name, application name and portlet name");
+ }
+ }
+
+ public Id parse(String idAsString)
+ {
+ return parse(idAsString, Identifiable.class);
+ }
+
+ public <U extends Identifiable<U>> Id<U> parse(String idAsString, Class<U> expectedType)
+ {
+ final int index = idAsString.indexOf(ComplexApplicationId.START);
+ if (index < 0)
+ {
+ throw new IllegalArgumentException("'" + idAsString + "' cannot be understood by ComplexApplicationContext. Understood format is 'local._applicationName.portletName'");
+ }
+
+ final int slash = idAsString.indexOf('/');
+ String category = idAsString.substring(0, slash);
+
+ final int separator = idAsString.indexOf('.', index + ComplexApplicationId.START.length());
+ String app = idAsString.substring(index + ComplexApplicationId.START.length(), separator);
+ String portlet = idAsString.substring(separator + 1);
+
+ return create(expectedType, category, app, portlet);
+ }
+
+ public String toString(Id id)
+ {
+ if (id instanceof ComplexApplicationId)
+ {
+ return id.toString();
+ }
+ else
+ {
+ throw new IllegalArgumentException("ComplexApplicationContext cannot handle Ids that are not ComplexApplicationIds");
+ }
+ }
+
+ public boolean isComponentRequired(String component)
+ {
+ return true; // all components are required
+ }
+
+ public boolean isComponentUnboundedHierarchical(String component)
+ {
+ return false; // no components are hierarchical
+ }
+}
Added: 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 (rev 0)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java 2011-08-05 16:15:50 UTC (rev 6997)
@@ -0,0 +1,176 @@
+/*
+* 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.id;
+
+import org.gatein.api.content.Portlet;
+import org.gatein.api.id.Context;
+import org.gatein.api.id.Id;
+import org.gatein.portal.api.impl.GateInImpl;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a> */
+public class ComplexApplicationId implements Id<Portlet>
+{
+ public static final String LOCAL = "local";
+ public static final String START = LOCAL + "._";
+ private final String category;
+ private final String app;
+ 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;
+ this.app = appName;
+ this.portlet = portletName;
+ this.context = context;
+ }
+
+ @Override
+ public String toString()
+ {
+ return toString(context);
+ }
+
+ public String toString(Context context)
+ {
+ if (this.context.equals(context))
+ {
+ return category + '/' + START + app + '.' + portlet;
+ }
+ else
+ {
+ throw new IllegalArgumentException("ComplexApplicationIds can only be rendered by ComplexApplicationContext at the moment.");
+ }
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ ComplexApplicationId that = (ComplexApplicationId)o;
+
+ if (!app.equals(that.app))
+ {
+ return false;
+ }
+ if (!category.equals(that.category))
+ {
+ return false;
+ }
+ if (!portlet.equals(that.portlet))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = category.hashCode();
+ result = 31 * result + app.hashCode();
+ result = 31 * result + portlet.hashCode();
+ return result;
+ }
+
+ public Class<Portlet> getIdentifiableType()
+ {
+ return Portlet.class;
+ }
+
+ public Id getIdForChild(String childId)
+ {
+ throw new IllegalArgumentException("ComplexApplicationId doesn't currently allow children Ids.");
+ }
+
+ public String getComponent(String component)
+ {
+ if (GateInImpl.APPLICATION_COMPONENT_NAME.equals(component))
+ {
+ return app;
+ }
+ else if (GateInImpl.PORTLET_COMPONENT_NAME.equals(component))
+ {
+ return portlet;
+ }
+ else if (INVOKER_COMPONENT.equals(component))
+ {
+ return LOCAL;
+ }
+ else if (CATEGORY_COMPONENT.equals(component))
+ {
+ return category;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unknown component '" + component + "' for ComplexApplicationId");
+ }
+ }
+
+ public Context getOriginalContext()
+ {
+ return context;
+ }
+
+ public int getComponentNumber()
+ {
+ return 4;
+ }
+
+ public String getRootComponent()
+ {
+ return LOCAL;
+ }
+
+ public Id getParent()
+ {
+ return null;
+ }
+
+ public String[] getComponents()
+ {
+ return new String[]{category, LOCAL, app, portlet};
+ }
+
+ public void associateComponentWith(int componentIndex, String name)
+ {
+ // do nothing as it shouldn't be called
+ }
+
+ public int compareTo(Id o)
+ {
+ return toString().compareTo(o.toString());
+ }
+}
Added: 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 (rev 0)
+++ portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java 2011-08-05 16:15:50 UTC (rev 6997)
@@ -0,0 +1,43 @@
+/*
+* 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.id;
+
+import org.gatein.api.content.Portlet;
+import org.gatein.api.id.Id;
+import org.gatein.portal.api.impl.GateInImpl;
+import org.testng.annotations.Test;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a> */
+public class ComplexApplicationContextTestCase
+{
+ @Test
+ 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 id.equals(ComplexApplicationContext.INSTANCE.parse(id.toString()));
+ }
+}
13 years, 4 months