Author: chris.laprun(a)jboss.com
Date: 2011-07-25 12:55:48 -0400 (Mon, 25 Jul 2011)
New Revision: 6926
Added:
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
Removed:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ApplicationImpl.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/GadgetImpl.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/portal/NavigationImpl.java
portal/branches/api/pom.xml
Log:
- Use version 1.0.0-Alpha01 of the API and adapted for changes.
- In particular, added WSRPImpl and improved content retrieval.
- Added more Id-managing methods.
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-07-25
10:28:06 UTC (rev 6925)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java 2011-07-25
16:55:48 UTC (rev 6926)
@@ -43,11 +43,12 @@
import org.exoplatform.services.organization.GroupHandler;
import org.exoplatform.services.organization.OrganizationService;
import org.gatein.api.GateIn;
-import org.gatein.api.content.Application;
import org.gatein.api.content.Category;
import org.gatein.api.content.Content;
import org.gatein.api.content.Gadget;
import org.gatein.api.content.ManagedContent;
+import org.gatein.api.content.Portlet;
+import org.gatein.api.content.WSRP;
import org.gatein.api.id.Context;
import org.gatein.api.id.Id;
import org.gatein.api.id.Identifiable;
@@ -74,6 +75,7 @@
private static final Query<PortalData> PORTALS = new
Query<PortalData>(SiteType.PORTAL.getName(), null, PortalData.class);
private static final Query<DashboardData> DASHBOARDS = new
Query<DashboardData>(SiteType.USER.getName(), null, DashboardData.class);
private static final Query<PageData> GROUPS = new
Query<PageData>(SiteType.GROUP.getName(), null, PageData.class);
+
private static final String GROUP_CHARS = "\\w|-|_";
public static final Context CONTEXT = Context.builder()
.requiredComponent("owner", Site.class, Pattern.compile(Site.PORTAL_NAME
+ "|" + Site.GROUP_NAME + "|" + Site.DASHBOARD_NAME))
@@ -83,8 +85,17 @@
public static final Context GROUP_CONTEXT =
Context.builder().requiredUnboundedHierarchicalComponent("group",
Identifiable.class, Pattern.compile("(" + GROUP_CHARS + ")+"))
.withDefaultSeparator("/").requireSeparatorInFirstPosition().build();
public static final Context APPLICATION_CONTEXT =
Context.builder().requiredComponent("application", Identifiable.class,
Pattern.compile("\\w+"))
- .requiredComponent("portlet", Application.class,
Pattern.compile("\\w+")).withDefaultSeparator("/").build();
+ .requiredComponent("portlet", Portlet.class,
Pattern.compile("\\w+")).withDefaultSeparator("/").build();
private static final Context GADGET_CONTEXT =
Context.builder().requiredComponent("name", Gadget.class,
Pattern.compile("\\w+")).build();
+ private static final Context CATEGORY_CONTEXT =
Context.builder().requiredComponent("name", Category.class,
Pattern.compile("\\w+")).build();
+ private static final Context WSRP_CONTEXT =
Context.builder().requiredComponent("invoker", Identifiable.class,
Pattern.compile("\\w+"))
+ .requiredComponent("portletcontext", WSRP.class,
Pattern.compile(GROUP_CHARS + "+")).build();
+ private static final String MANAGED = "managed";
+ private static final Context MANAGED_CONTENT_CONTEXT = Context.builder()
+ .requiredComponent(MANAGED, ManagedContent.class, Pattern.compile(MANAGED))
+ .requiredComponent("content", Content.class,
Pattern.compile(".+"))
+ .build();
+
private ExoContainer container;
private ModelDataStorage dataStorage;
private NavigationService navigationService;
@@ -258,21 +269,26 @@
return Id.create(GROUP_CONTEXT, root, children);
}
- public Id<Application> applicationId(String application, String portlet)
+ public Id<Portlet> portletId(String application, String portlet)
{
- return null; //To change body of implemented methods use File | Settings | File
Templates.
+ return Id.create(APPLICATION_CONTEXT, Portlet.class, application, portlet);
}
- public <T extends Content> Id<T> contentId(String contentId,
Class<T> expectedType)
+ public Id<Portlet> parsePortletId(String contentId)
{
- return Id.parse(GateInImpl.APPLICATION_CONTEXT, contentId, expectedType);
+ return Id.parse(GateInImpl.APPLICATION_CONTEXT, contentId, Portlet.class);
}
- public Id<Content> wsrpPortletId(String invoker, String portlet)
+ public Id<WSRP> wsrpPortletId(String invoker, String portlet)
{
- return null; //To change body of implemented methods use File | Settings | File
Templates.
+ return Id.create(WSRP_CONTEXT, WSRP.class, invoker, portlet);
}
+ public Id<WSRP> parseWSRPPortletId(String compositeId)
+ {
+ return Id.parse(WSRP_CONTEXT, compositeId, WSRP.class);
+ }
+
public Id<Gadget> gadgetId(String gadgetName)
{
return Id.create(GADGET_CONTEXT, Gadget.class, gadgetName);
@@ -283,14 +299,14 @@
return null; //To change body of implemented methods use File | Settings | File
Templates.
}
- public <T extends Content<T>> Id<ManagedContent<T>>
managedContentId(Id<T> contentId)
+ public <T extends Content> Id<ManagedContent> managedContentId(Id<T>
contentId)
{
- return null; //To change body of implemented methods use File | Settings | File
Templates.
+ return Id.create(MANAGED_CONTENT_CONTEXT, ManagedContent.class, MANAGED,
contentId.toString());
}
public Id<Category> categoryId(String name)
{
- return null;
+ return Id.create(CATEGORY_CONTEXT, Category.class, name);
}
public <T extends Site> Id<T> siteId(Type<T, Site> siteType, String
siteName)
@@ -301,7 +317,7 @@
public <T extends Site> Id<Page> pageId(Id<T> ownerSite, String
pageName)
{
ParameterValidation.throwIllegalArgExceptionIfNull(ownerSite, "Owner Site
Id");
- return ownerSite.getIdforChild(pageName);
+ return ownerSite.getIdForChild(pageName);
}
public void start()
Deleted:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ApplicationImpl.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ApplicationImpl.java 2011-07-25
10:28:06 UTC (rev 6925)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ApplicationImpl.java 2011-07-25
16:55:48 UTC (rev 6926)
@@ -1,53 +0,0 @@
-/*
-* 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.exoplatform.application.registry.Application;
-import org.gatein.api.content.Content;
-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@jboss.com">Chris
Laprun</a> */
-public class ApplicationImpl extends
IdentifiableImpl<org.gatein.api.content.Application> implements
org.gatein.api.content.Application
-{
- private final Application application;
-
- public ApplicationImpl(Application application, GateInImpl gateIn)
- {
- super(Id.parse(GateInImpl.APPLICATION_CONTEXT, application.getId()),
application.getApplicationName(), gateIn);
- this.application = application;
- }
-
- @Override
- public String toString()
- {
- return "Application '" + getName() + "' @" + getId();
- }
-
- public Type<org.gatein.api.content.Application, Content> getType()
- {
- return Content.PORTLET;
- }
-}
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-07-25
10:28:06 UTC (rev 6925)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/CategoryImpl.java 2011-07-25
16:55:48 UTC (rev 6926)
@@ -84,9 +84,17 @@
{
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.getContentId());
+ }
else
{
- return gateIn.contentId(application.getId(), contentClass);
+ throw new IllegalArgumentException("Unknown application type: " +
type);
}
}
@@ -176,11 +184,11 @@
}
else if (ApplicationType.PORTLET.equals(type))
{
- return (Class<T>)org.gatein.api.content.Application.class;
+ return (Class<T>)org.gatein.api.content.Portlet.class;
}
else if (ApplicationType.WSRP_PORTLET.equals(type))
{
- return (Class<T>)org.gatein.api.content.Application.class;
+ return (Class<T>)org.gatein.api.content.WSRP.class;
}
else
{
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-07-25
10:28:06 UTC (rev 6925)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java 2011-07-25
16:55:48 UTC (rev 6926)
@@ -24,12 +24,13 @@
import org.exoplatform.application.registry.ApplicationCategory;
import org.exoplatform.application.registry.ApplicationRegistryService;
-import org.gatein.api.content.Application;
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.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;
@@ -176,7 +177,7 @@
{
Class<T> type = id.getIdentifiableType();
Object result;
- if (Application.class.equals(type))
+ if (Portlet.class.equals(type))
{
try
{
@@ -186,7 +187,7 @@
{
return null;
}
- result = new ApplicationImpl(application, gateIn);
+ result = new PortletImpl((Id<Portlet>)id, application, gateIn);
}
catch (Exception e)
{
@@ -207,7 +208,7 @@
{
return null;
}
- result = new GadgetImpl(gadget, gateIn);
+ result = new GadgetImpl((Id<Gadget>)id, gadget, gateIn);
}
catch (Exception e)
{
@@ -218,6 +219,27 @@
gateIn.end();
}
}
+ else if (WSRP.class.equals(type))
+ {
+ 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();
+ }
+ }
else
{
throw new IllegalArgumentException("Unknown Content type: " +
type.getCanonicalName());
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-07-25
10:28:06 UTC (rev 6925)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/GadgetImpl.java 2011-07-25
16:55:48 UTC (rev 6926)
@@ -25,6 +25,7 @@
import org.exoplatform.application.gadget.Gadget;
import org.exoplatform.application.gadget.Source;
import org.gatein.api.content.Content;
+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;
@@ -36,9 +37,9 @@
{
private final Gadget gadget;
- public GadgetImpl(Gadget gadget, GateInImpl gateIn)
+ public GadgetImpl(Id<org.gatein.api.content.Gadget> id, Gadget gadget,
GateInImpl gateIn)
{
- super(gateIn.gadgetId(gadget.getName()), gadget.getName(), gateIn);
+ super(id, gadget.getName(), gateIn);
this.gadget = gadget;
}
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-07-25
10:28:06 UTC (rev 6925)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ManagedContentImpl.java 2011-07-25
16:55:48 UTC (rev 6926)
@@ -26,12 +26,9 @@
import org.gatein.api.GateIn;
import org.gatein.api.content.Content;
import org.gatein.api.content.ManagedContent;
-import org.gatein.api.id.Context;
import org.gatein.api.id.Id;
import org.gatein.common.util.ParameterValidation;
-import java.util.regex.Pattern;
-
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
* @version $Revision$
@@ -44,17 +41,13 @@
private String name;
private String displayName;
private String description;
- private static final String MANAGED = "managed";
- private static final Context CONTEXT = Context.builder()
- .requiredComponent(MANAGED, ManagedContentImpl.class, Pattern.compile(MANAGED))
- .requiredComponent("content", Content.class,
Pattern.compile(".+"))
- .build();
+
public ManagedContentImpl(T content, CategoryImpl category)
{
ParameterValidation.throwIllegalArgExceptionIfNull(content, "Content");
this.content = content;
- this.id = Id.create(CONTEXT, MANAGED, content.getId().toString());
+ this.id = content.getGateIn().managedContentId(content.getId());
this.category = category;
}
Copied:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/PortletImpl.java
(from rev 6924,
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ApplicationImpl.java)
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/PortletImpl.java
(rev 0)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/PortletImpl.java 2011-07-25
16:55:48 UTC (rev 6926)
@@ -0,0 +1,54 @@
+/*
+* 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.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@jboss.com">Chris
Laprun</a> */
+public class PortletImpl extends IdentifiableImpl<Portlet> implements Portlet
+{
+ private final Application application;
+
+ public PortletImpl(Id<Portlet> id, Application application, GateInImpl gateIn)
+ {
+ super(id, application.getApplicationName(), gateIn);
+ this.application = application;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Application '" + getName() + "' @" + getId();
+ }
+
+ public Type<Portlet, Content> getType()
+ {
+ return Content.PORTLET;
+ }
+}
Added:
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
(rev 0)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/WSRPImpl.java 2011-07-25
16:55:48 UTC (rev 6926)
@@ -0,0 +1,45 @@
+/*
+* 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.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@jboss.com">Chris
Laprun</a> */
+public class WSRPImpl extends IdentifiableImpl<WSRP> implements WSRP
+{
+ public WSRPImpl(Id<WSRP> id, Application application, GateInImpl gateIn)
+ {
+ super(id, application.getApplicationName(), gateIn);
+ }
+
+ public Type<WSRP, Content> 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-07-25
10:28:06 UTC (rev 6925)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java 2011-07-25
16:55:48 UTC (rev 6926)
@@ -193,7 +193,7 @@
public Id<Navigation> getIdForChild(String key)
{
- return site.getIdforChild(key);
+ return site.getIdForChild(key);
}
public <U extends Navigation> IterableIdentifiableCollection<U>
getAllWhere(Filter<U> filter)
Modified: portal/branches/api/pom.xml
===================================================================
--- portal/branches/api/pom.xml 2011-07-25 10:28:06 UTC (rev 6925)
+++ portal/branches/api/pom.xml 2011-07-25 16:55:48 UTC (rev 6926)
@@ -50,7 +50,7 @@
<org.picketlink.idm>1.3.0.Alpha03</org.picketlink.idm>
<org.gatein.wsrp.version>2.1.0-Beta04</org.gatein.wsrp.version>
<org.gatein.mop.version>1.1.0-Beta05</org.gatein.mop.version>
- <org.gatein.api.version>1.0.0-Beta01-SNAPSHOT</org.gatein.api.version>
+
<org.gatein.api.version>1.0.0-Alpha01-SNAPSHOT</org.gatein.api.version>
<org.slf4j.version>1.5.8</org.slf4j.version>
<commons-pool.version>1.5.5</commons-pool.version>
<rhino.version>1.6R5</rhino.version>