Author: julien_viet
Date: 2011-08-15 16:55:43 -0400 (Mon, 15 Aug 2011)
New Revision: 7138
Added:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/GateInTypesResolver.java
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java
Modified:
portal/branches/api/component/api-impl/pom.xml
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/IdentifiableImpl.java
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/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/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/main/java/org/gatein/portal/api/impl/portal/DashboardSiteImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/GroupSiteImpl.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/main/java/org/gatein/portal/api/impl/portal/PageImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PortalImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterableIdentifiableCollection.java
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/portal/SiteTestCase.java
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollectionTestCase.java
portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/NavigationPortlet.java
portal/branches/api/pom.xml
Log:
some work on api impl
Modified: portal/branches/api/component/api-impl/pom.xml
===================================================================
--- portal/branches/api/component/api-impl/pom.xml 2011-08-15 20:52:16 UTC (rev 7137)
+++ portal/branches/api/component/api-impl/pom.xml 2011-08-15 20:55:43 UTC (rev 7138)
@@ -34,17 +34,44 @@
<artifactId>exo.portal.component.application-registry</artifactId>
</dependency>
<dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.web.controller</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.chromattic</groupId>
+ <artifactId>chromattic.core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.test.core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.test.jcr</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.portal</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.identity</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>5.14.10</version>
<scope>test</scope>
</dependency>
-
- <!-- To be able to access Util to generate Navigation URI -->
- <dependency>
- <groupId>org.exoplatform.portal</groupId>
- <artifactId>exo.portal.webui.portal</artifactId>
- </dependency>
</dependencies>
<build>
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-15
20:52:16 UTC (rev 7137)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java 2011-08-15
20:55:43 UTC (rev 7138)
@@ -59,8 +59,6 @@
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.GenericContext;
import org.gatein.api.id.Id;
import org.gatein.api.id.Identifiable;
import org.gatein.api.portal.Navigation;
@@ -72,8 +70,6 @@
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;
import org.gatein.portal.api.impl.portal.GroupSiteImpl;
import org.gatein.portal.api.impl.portal.PageImpl;
@@ -82,6 +78,7 @@
import org.gatein.portal.api.impl.util.AggregatedIterableIdentifiableCollection;
import org.picocontainer.Startable;
+import java.lang.reflect.UndeclaredThrowableException;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
@@ -106,6 +103,7 @@
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+"))
@@ -142,6 +140,7 @@
.requiredComponent(NAVIGATION_COMPONENT, Navigation.class,
Pattern.compile("[a-z0-9]+"))
.withDefaultSeparator("@")
.build();
+*/
private ExoContainer container;
private ModelDataStorage dataStorage;
@@ -158,8 +157,9 @@
container = context.getContainer();
}
- public static Id<? extends Content> getContentIdFrom(Application application)
+ public static Content.Id getContentIdFrom(Application application)
{
+/*
ApplicationType type = application.getType();
Class<Content> contentClass = getContentClassFor(type);
if (Gadget.class.isAssignableFrom(contentClass))
@@ -178,6 +178,8 @@
{
throw new IllegalArgumentException("Unknown application type: " +
type);
}
+*/
+ throw new UnsupportedOperationException();
}
public static <T extends Content> Class<T>
getContentClassFor(ApplicationType type)
@@ -224,23 +226,23 @@
}
}
- public IterableIdentifiableCollection<Portal> getPortals()
+ public IterableIdentifiableCollection<Site> getPortals()
{
try
{
begin();
final List<PortalData> portals = dataStorage.find(PORTALS).getAll();
- return new AdaptedIterableIdentifiableCollection<PortalData,
Portal>(portals.size(), portals.iterator())
+ return new AdaptedIterableIdentifiableCollection<PortalData,
Site>(portals.size(), portals.iterator())
{
public Portal adapt(PortalData old)
{
return new PortalImpl(old, GateInImpl.this);
}
- public boolean contains(Id<Portal> id)
+ public boolean contains(Id<Site> id)
{
- return getPortalDataFor(id) != null;
+ return getPortalDataFor((Site.Id)id) != null;
}
};
}
@@ -254,7 +256,7 @@
}
}
- public Portal getPortal(Id<Portal> portalId)
+ public Portal getPortal(Site.Id portalId)
{
PortalData portalData = getPortalDataFor(portalId);
return new PortalImpl(portalData, this);
@@ -265,13 +267,13 @@
return getPortal(siteId(Site.PORTAL, "classic")); // todo: check
}
- public IterableIdentifiableCollection<? extends Site> getSites()
+ public IterableIdentifiableCollection<Site> getSites()
{
IterableIdentifiableCollection<Site> groupSites = getGroupSites();
- IterableIdentifiableCollection<Portal> portals = getPortals();
+ IterableIdentifiableCollection<Site> portals = getPortals();
IterableIdentifiableCollection<Site> dashboards = getDashboards();
- AggregatedIterableIdentifiableCollection collection = new
AggregatedIterableIdentifiableCollection();
+ AggregatedIterableIdentifiableCollection<Site> collection = new
AggregatedIterableIdentifiableCollection<Site>();
collection.addCollection(groupSites);
collection.addCollection(portals);
collection.addCollection(dashboards);
@@ -295,7 +297,7 @@
public Site adapt(User old)
{
- return getDashboard(userId(old.getUserName()));
+ return getDashboard(old.getUserName());
}
public boolean contains(Id<Site> t)
@@ -347,7 +349,8 @@
public Site adapt(Object old)
{
Group group = (Group)old;
- return getGroupSite(GROUP_CONTEXT.parse(group.getId()));
+ // Should parse group id
+ return getGroupSite(group.getId());
}
};
}
@@ -361,15 +364,20 @@
}
}
- public Site getGroupSite(Id groupId)
+ public Site getGroupSite(String... names)
{
- String groupName = groupId.toString();
- Id<Site> siteId = siteId(Site.GROUP, groupName);
+ StringBuilder sb = new StringBuilder();
+ for (String name : names)
+ {
+ sb.append("/").append(name);
+ }
+ String groupId = sb.toString();
+ Site.Id siteId = siteId(Site.GROUP, groupId);
- return new GroupSiteImpl(siteId, groupName, this);
+ return new GroupSiteImpl(siteId, groupId, this);
}
- public IterableIdentifiableCollection<Site> getGroupSites(Id userId)
+ public IterableIdentifiableCollection<Site> getGroupSites(String userId)
{
final GroupHandler groupHandler = getOrganizationService().getGroupHandler();
try
@@ -396,7 +404,7 @@
public Site adapt(Object old)
{
Group group = (Group)old;
- return getGroupSite(GROUP_CONTEXT.parse(group.getId()));
+ return getGroupSite(group.getId());
}
};
}
@@ -410,7 +418,7 @@
}
}
- public IterableIdentifiableCollection<Portal> getPortalSites(Id userId)
+ public IterableIdentifiableCollection<Site> getPortalSites(String userId)
{
try
{
@@ -418,17 +426,16 @@
final List<PortalData> portalDatas = dataStorage.find(PORTALS).getAll();
// first build Identity based on user id so that we can check its permissions
using UserACL... ugh! :(
- final String user = userId.toString();
- final Collection membershipsByUser =
getOrganizationService().getMembershipHandler().findMembershipsByUser(user);
+ final Collection membershipsByUser =
getOrganizationService().getMembershipHandler().findMembershipsByUser(userId);
Collection<MembershipEntry> membershipEntries = new
ArrayList<MembershipEntry>(membershipsByUser.size());
for (Object o : membershipsByUser)
{
Membership membership = (Membership)o;
membershipEntries.add(new MembershipEntry(membership.getGroupId(),
membership.getMembershipType()));
}
- final Identity identity = new Identity(user, membershipEntries);
+ final Identity identity = new Identity(userId, membershipEntries);
- final List<Portal> portals = new
ArrayList<Portal>(portalDatas.size());
+ final List<Site> portals = new ArrayList<Site>(portalDatas.size());
final Filter<PortalData> filter = new Filter<PortalData>()
{
@Override
@@ -446,16 +453,16 @@
}
}
- return new AdaptedIterableIdentifiableCollection<Portal,
Portal>(portals.size(), portals.iterator())
+ return new AdaptedIterableIdentifiableCollection<Site,
Site>(portals.size(), portals.iterator())
{
- public Portal adapt(Portal old)
+ public Site adapt(Site old)
{
return old;
}
- public boolean contains(Id<Portal> id)
+ public boolean contains(Id<Site> id)
{
- final PortalData portalData = getPortalDataFor(id);
+ final PortalData portalData = getPortalDataFor((Site.Id)id);
return portalData != null && filter.accept(portalData);
}
};
@@ -470,15 +477,14 @@
}
}
- public Site getDashboard(Id userId)
+ public Site getDashboard(String userId)
{
- String user = userId.toString();
- Id<Site> siteId = siteId(Site.DASHBOARD, user);
+ Site.Id siteId = siteId(Site.DASHBOARD, userId);
- return new DashboardSiteImpl(siteId, user, this);
+ return new DashboardSiteImpl(siteId, userId, this);
}
- public <T extends Identifiable> T get(Id<T> id)
+ public <T extends Identifiable<T>> T get(Id<T> id)
{
Class<T> type = id.getIdentifiableType();
@@ -486,7 +492,7 @@
if (Portal.class.equals(type))
{
- result = getPortal((Id<Portal>)id);
+ result = getPortal((Site.Id)(Id)id);
}
else if (Page.class.equals(type))
{
@@ -494,7 +500,8 @@
{
begin();
PageData pageData = dataStorage.getPage(PageKey.create(id.toString()));
- result = new PageImpl(pageData, id.getParent(), this);
+ Page.Id pageId = (Page.Id)(Id)id;
+ result = new PageImpl(pageData, pageId.getSite(), this);
}
catch (Exception e)
{
@@ -507,16 +514,15 @@
}
else if (Site.class.equals(type))
{
- Id<Site> siteId = (Id<Site>)id;
- result = getSite(siteId, null);
+ result = getSite((Site.Id)(Id)id);
}
else if (Content.class.isAssignableFrom(type))
{
// todo: split by types and optimize by calling portlet invoker or gadget
registry directly
- final IterableIdentifiableCollection<Portal> portals = getPortals();
- for (Portal portal : portals)
+ final IterableIdentifiableCollection<Site> portals = getPortals();
+ for (Site portal : portals)
{
- result = portal.getContentRegistry().get((Id<? extends Content>)id);
+ result = ((Portal)portal).getContentRegistry().get((Content.Id)(Id)id);
if (result != null)
{
break;
@@ -526,10 +532,10 @@
else if (Category.class.equals(type))
{
// todo: optimize by adding portal id to category id (so that appropriate
content registry can be retrieved) and calling application registry directly
- final IterableIdentifiableCollection<Portal> portals = getPortals();
- for (Portal portal : portals)
+ final IterableIdentifiableCollection<Site> portals = getPortals();
+ for (Site portal : portals)
{
- result = portal.getContentRegistry().getCategory(id.toString());
+ result = ((Portal)portal).getContentRegistry().getCategory(id.toString());
if (result != null)
{
break;
@@ -544,12 +550,6 @@
}
else if (Navigation.class.equals(type))
{
- final String siteStringId = id.getComponent(NAVIGATION_SITE_COMPONENT);
- final Id<Site> siteId = SITE_CONTEXT.parse(siteStringId, Site.class);
- final Site site = getSite(siteId, null);
- //todo: need to get all the parents of a Navigation to be able to load it so we
would need to add the complete path to the Id to be able to resolve Navigations properly
- result = site.getNavigation().get(id.getComponent(NAVIGATION_COMPONENT));
-
throw new UnsupportedOperationException("Id<" +
type.getSimpleName() + "> not yet supported");
}
else
@@ -560,22 +560,22 @@
return type.cast(result);
}
- public <T extends Site> T getSite(Id<T> siteId, Type<T> type)
+ public Site getSite(Site.Id siteId)
{
final String siteType = siteId.getComponent(SITE_TYPE_COMPONENT);
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(siteType, "Site
type", "A valid Site Id");
- if (Site.PORTAL.equals(siteType))
+ if (Site.PORTAL_TYPE_NAME.equals(siteType))
{
- return (T)getPortal((Id<Portal>)siteId);
+ return getPortal(siteId);
}
else if (Site.GROUP_TYPE_NAME.equals(siteType))
{
- return (T)getGroupSite(groupId(siteId.getComponent(SITE_NAME_COMPONENT)));
+ return getGroupSite(siteId.getComponent(SITE_NAME_COMPONENT));
}
else if (Site.DASHBOARD_TYPE_NAME.equals(siteType))
{
- return (T)getDashboard(userId(siteId.getComponent(SITE_NAME_COMPONENT)));
+ return getDashboard(siteId.getComponent(SITE_NAME_COMPONENT));
}
else
{
@@ -583,21 +583,12 @@
}
}
- public Id userId(String user)
+ public Portlet.Id portletId(String application, String portlet)
{
- return USER_CONTEXT.create(user);
+ throw new UnsupportedOperationException();
}
- public Id groupId(String root, String... children)
- {
- return GROUP_CONTEXT.create(root, children);
- }
-
- public Id<Portlet> portletId(String application, String portlet)
- {
- return LOCAL_PORTLET_CONTEXT.create(Portlet.class, application, portlet);
- }
-
+/*
public static Id<Portlet> parsePortletId(String contentId)
{
if (contentId.contains(ComplexApplicationId.START))
@@ -609,12 +600,14 @@
return LOCAL_PORTLET_CONTEXT.parse(contentId, Portlet.class);
}
}
+*/
- public Id<WSRP> wsrpPortletId(String invoker, String portlet)
+ public WSRP.Id wsrpPortletId(String invoker, String portlet)
{
- return staticWSRPPortletId(invoker, portlet);
+ throw new UnsupportedOperationException();
}
+/*
private static Id<WSRP> staticWSRPPortletId(String invoker, String portlet)
{
return WSRP_PORTLET_CONTEXT.create(WSRP.class, invoker, portlet);
@@ -624,41 +617,51 @@
{
return WSRP_PORTLET_CONTEXT.parse(compositeId, WSRP.class);
}
+*/
- public Id<Gadget> gadgetId(String gadgetName)
+ public Gadget.Id gadgetId(String gadgetName)
{
- return staticGadgetId(gadgetName);
+ throw new UnsupportedOperationException();
}
- private static Id<Gadget> staticGadgetId(String gadgetName)
+/*
+ private static Gadget.Id staticGadgetId(String gadgetName)
{
- return GADGET_CONTEXT.create(Gadget.class, gadgetName);
+ throw new UnsupportedOperationException();
}
+*/
- public Id<Gadget> gadgetId(URI uri)
+ public Gadget.Id gadgetId(URI uri)
{
- return GADGET_CONTEXT.create(Gadget.class, uri.toString());
+ throw new UnsupportedOperationException();
}
- public <T extends Content> Id<ManagedContent>
managedContentId(Id<Category> categoryId, String name, Id<T> contentId)
+ public ManagedContent.Id managedContentId(Category.Id categoryId, String name,
Content.Id contentId)
{
- return MANAGED_CONTENT_CONTEXT.create(ManagedContent.class, categoryId.toString(),
name, contentId.toString());
+ throw new UnsupportedOperationException();
}
- public Id<Category> categoryId(String name)
+ public Category.Id categoryId(String name)
{
- return CATEGORY_CONTEXT.create(Category.class, name);
+ return new Category.Id(name);
}
+/*
public <T extends Site> Id<T> siteId(Type<T> siteType, String
siteName)
{
return SITE_CONTEXT.create(siteType.getValueType(), siteType.getName(), siteName);
}
+*/
- public <T extends Site> Id<Page> pageId(Id<T> ownerSite, String
pageName)
+ public Site.Id siteId(Type<Site> siteType, String portalName)
{
+ return new Site.Id(siteType, portalName);
+ }
+
+ public Page.Id pageId(Site.Id ownerSite, String pageName)
+ {
ParameterValidation.throwIllegalArgExceptionIfNull(ownerSite, "Owner Site
Id");
- return ownerSite.getIdForChild(pageName);
+ return new Page.Id(ownerSite, pageName);
}
public void start()
@@ -701,18 +704,32 @@
return portletInvoker;
}
- private PortalData getPortalDataFor(Id<Portal> portalId)
+ private PortalData getPortalDataFor(Site.Id portalId)
{
ParameterValidation.throwIllegalArgExceptionIfNull(portalId, "Portal
Id");
try
{
begin();
- return dataStorage.getPortalConfig(PortalKey.create(portalId.toString()));
+ String type;
+ if (portalId.getType() == Site.PORTAL)
+ {
+ type = "portal";
+ }
+ else if (portalId.getType() == Site.GROUP)
+ {
+ type = "group";
+ }
+ else
+ {
+ type = "user";
+ }
+
+ return dataStorage.getPortalConfig(new PortalKey(type, portalId.getName()));
}
catch (Exception e)
{
- throw new RuntimeException(e);
+ throw new UndeclaredThrowableException(e);
}
finally
{
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/IdentifiableImpl.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/IdentifiableImpl.java 2011-08-15
20:52:16 UTC (rev 7137)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/IdentifiableImpl.java 2011-08-15
20:55:43 UTC (rev 7138)
@@ -27,14 +27,14 @@
import org.gatein.api.id.Identifiable;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public class IdentifiableImpl<T extends Identifiable<T>> implements
Identifiable<T>
+public class IdentifiableImpl<T extends Identifiable<T>, I extends
Id<T>> implements Identifiable<T>
{
- private final Id<T> id;
+ private final I id;
private final String name;
private final String displayName;
private final GateInImpl gateIn;
- public IdentifiableImpl(Id<T> id, String name, GateInImpl gateIn)
+ public IdentifiableImpl(I id, String name, GateInImpl gateIn)
{
this.id = id;
this.name = name;
@@ -42,7 +42,7 @@
this.displayName = name; // todo: fix-me
}
- public Id<T> getId()
+ public I getId()
{
return id;
}
Modified:
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 2011-08-15
20:52:16 UTC (rev 7137)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/AbstractPortlet.java 2011-08-15
20:55:43 UTC (rev 7138)
@@ -28,11 +28,11 @@
import org.gatein.portal.api.impl.IdentifiableImpl;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public abstract class AbstractPortlet<T extends Content<T>> extends
IdentifiableImpl<T> implements Content<T>
+public abstract class AbstractPortlet extends IdentifiableImpl<Content, Content.Id>
implements Content
{
private final org.gatein.pc.api.Portlet portlet;
- public AbstractPortlet(Id<T> id, org.gatein.pc.api.Portlet application,
GateInImpl gateIn)
+ public AbstractPortlet(Content.Id id, org.gatein.pc.api.Portlet application,
GateInImpl gateIn)
{
super(id, application.getInfo().getName(), gateIn);
this.portlet = application;
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-15
20:52:16 UTC (rev 7137)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/CategoryImpl.java 2011-08-15
20:55:43 UTC (rev 7138)
@@ -115,10 +115,10 @@
}
}
- public <T extends Content> ManagedContent<T> addContent(Id<T>
contentId, String name)
+ public ManagedContent addContent(Content.Id contentId, String name)
{
ParameterValidation.throwIllegalArgExceptionIfNull(contentId, "Content
Id");
- GateInImpl.MANAGED_CONTENT_CONTEXT.validateValueFor("name", name);
+// GateInImpl.MANAGED_CONTENT_CONTEXT.validateValueFor("name", name);
final ContentType<?> contentType = getContentTypeFor(contentId);
@@ -132,7 +132,7 @@
final ApplicationRegistryService registryService = gateIn.getRegistryService();
final Application application =
registryService.createOrUpdateApplication(category.getName(), name, contentType,
contentId.toString(), name, null, permissions);
- return new ManagedContentImpl<T>(name, contentId, application, this);
+ return new ManagedContentImpl(name, contentId, application, this);
}
catch (Exception e)
{
@@ -164,7 +164,7 @@
}
}
- private ContentType<?> getContentTypeFor(Id id)
+ private ContentType<?> getContentTypeFor(Content.Id id)
{
final Class type = id.getIdentifiableType();
if (Gadget.class.equals(type))
@@ -247,7 +247,7 @@
return null;
}
- final Id<? extends Content> contentId =
GateInImpl.getContentIdFrom(application);
+ Content.Id contentId = GateInImpl.getContentIdFrom(application);
return new ManagedContentImpl(name, contentId, application, this);
}
@@ -268,7 +268,7 @@
};
}
- public Id<Category> getId()
+ public Category.Id getId()
{
return gateIn.categoryId(getName());
}
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-15
20:52:16 UTC (rev 7137)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java 2011-08-15
20:55:43 UTC (rev 7138)
@@ -199,9 +199,9 @@
}
}
- public <T extends Content> T get(Id<T> id)
+ public Content get(Id<Content> id)
{
- Class<T> type = id.getIdentifiableType();
+ Class<Content> type = id.getIdentifiableType();
Object result;
Object regitryItem;
try
@@ -233,7 +233,7 @@
}
}
- private <T extends Content> Object getPortletFrom(Id<T> id) throws
PortletInvokerException
+ private Object getPortletFrom(Id<Content> id) throws PortletInvokerException
{
PortletContext portletContext;
Object regitryItem;
@@ -255,15 +255,15 @@
Object result;
if (Portlet.class.equals(wanted))
{
- result = new PortletImpl((Id<Portlet>)id,
(org.gatein.pc.api.Portlet)registryItem, gateIn);
+ result = new PortletImpl((Portlet.Id)id,
(org.gatein.pc.api.Portlet)registryItem, gateIn);
}
else if (Gadget.class.equals(wanted))
{
- result = new GadgetImpl((Id<Gadget>)id,
(org.exoplatform.application.gadget.Gadget)registryItem, gateIn);
+ result = new GadgetImpl((Gadget.Id)id,
(org.exoplatform.application.gadget.Gadget)registryItem, gateIn);
}
else if (WSRP.class.equals(wanted))
{
- result = new WSRPImpl((Id<WSRP>)id,
(org.gatein.pc.api.Portlet)registryItem, gateIn);
+ result = new WSRPImpl((WSRP.Id)id, (org.gatein.pc.api.Portlet)registryItem,
gateIn);
}
else
{
@@ -330,21 +330,22 @@
}
}
- public IterableIdentifiableCollection<Portlet> getLocalPortlets()
+ public IterableIdentifiableCollection<Content> getLocalPortlets()
{
try
{
gateIn.begin();
final FederatingPortletInvoker portletInvoker = gateIn.getPortletInvoker();
final Set<org.gatein.pc.api.Portlet> initialLocalPortlets =
portletInvoker.getLocalPortlets();
- return new AdaptedIterableIdentifiableCollection<org.gatein.pc.api.Portlet,
Portlet>(initialLocalPortlets.size(), initialLocalPortlets.iterator())
+ return new AdaptedIterableIdentifiableCollection<org.gatein.pc.api.Portlet,
Content>(initialLocalPortlets.size(), initialLocalPortlets.iterator())
{
public Portlet adapt(org.gatein.pc.api.Portlet old)
{
- return
(Portlet)newContentFrom(GateInImpl.parsePortletId(old.getContext().getId()), old,
Portlet.class);
+// return
(Portlet)newContentFrom(GateInImpl.parsePortletId(old.getContext().getId()), old,
Portlet.class);
+ throw new UnsupportedOperationException();
}
- public boolean contains(Id<Portlet> t)
+ public boolean contains(Id<Content> t)
{
try
{
@@ -367,21 +368,22 @@
}
}
- public IterableIdentifiableCollection<WSRP> getRemotePortlets()
+ public IterableIdentifiableCollection<Content> getRemotePortlets()
{
try
{
gateIn.begin();
final FederatingPortletInvoker portletInvoker = gateIn.getPortletInvoker();
final Set<org.gatein.pc.api.Portlet> initialRemotePortlets =
portletInvoker.getRemotePortlets();
- return new AdaptedIterableIdentifiableCollection<org.gatein.pc.api.Portlet,
WSRP>(initialRemotePortlets.size(), initialRemotePortlets.iterator())
+ return new AdaptedIterableIdentifiableCollection<org.gatein.pc.api.Portlet,
Content>(initialRemotePortlets.size(), initialRemotePortlets.iterator())
{
public WSRP adapt(org.gatein.pc.api.Portlet old)
{
- return
(WSRP)newContentFrom(GateInImpl.parseWSRPPortletId(old.getContext().getId()), old,
WSRP.class);
+// return
(WSRP)newContentFrom(GateInImpl.parseWSRPPortletId(old.getContext().getId()), old,
WSRP.class);
+ throw new UnsupportedOperationException();
}
- public boolean contains(Id<WSRP> id)
+ public boolean contains(Id<Content> id)
{
try
{
@@ -404,20 +406,20 @@
}
}
- public IterableIdentifiableCollection<Gadget> getGadgets()
+ public IterableIdentifiableCollection<Content> getGadgets()
{
try
{
gateIn.begin();
final List<org.exoplatform.application.gadget.Gadget> initialGadgets =
gateIn.getGadgetService().getAllGadgets();
- return new
AdaptedIterableIdentifiableCollection<org.exoplatform.application.gadget.Gadget,
Gadget>(initialGadgets.size(), initialGadgets.iterator())
+ return new
AdaptedIterableIdentifiableCollection<org.exoplatform.application.gadget.Gadget,
Content>(initialGadgets.size(), initialGadgets.iterator())
{
public Gadget adapt(org.exoplatform.application.gadget.Gadget old)
{
return (Gadget)newContentFrom(gateIn.gadgetId(old.getName()), old,
Gadget.class);
}
- public boolean contains(Id<Gadget> id)
+ public boolean contains(Id<Content> id)
{
try
{
@@ -446,7 +448,7 @@
return getAll().size();
}
- public <U extends Content> boolean contains(Id<U> id)
+ public boolean contains(Id<Content> id)
{
// todo: optimize
return get(id) != null;
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-08-15
20:52:16 UTC (rev 7137)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/GadgetImpl.java 2011-08-15
20:55:43 UTC (rev 7138)
@@ -25,7 +25,6 @@
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;
@@ -33,11 +32,11 @@
import java.net.URI;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public class GadgetImpl extends IdentifiableImpl<org.gatein.api.content.Gadget>
implements org.gatein.api.content.Gadget
+public class GadgetImpl extends IdentifiableImpl<org.gatein.api.content.Content,
org.gatein.api.content.Content.Id> implements org.gatein.api.content.Gadget
{
private final Gadget gadget;
- public GadgetImpl(Id<org.gatein.api.content.Gadget> id, Gadget gadget,
GateInImpl gateIn)
+ public GadgetImpl(org.gatein.api.content.Gadget.Id id, Gadget gadget, GateInImpl
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-08-15
20:52:16 UTC (rev 7137)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ManagedContentImpl.java 2011-08-15
20:55:43 UTC (rev 7138)
@@ -33,15 +33,15 @@
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
* @version $Revision$
*/
-public class ManagedContentImpl<T extends Content> implements
ManagedContent<T>
+public class ManagedContentImpl implements ManagedContent
{
- private T content;
- private final Id<T> contentId;
- private final Id<ManagedContent<T>> id;
+ private Content content;
+ private final Content.Id contentId;
+ private final ManagedContent.Id id;
private final CategoryImpl category;
private final Application application;
- ManagedContentImpl(String name, Id contentId, Application application, CategoryImpl
category)
+ ManagedContentImpl(String name, Content.Id contentId, Application application,
CategoryImpl category)
{
this.contentId = contentId;
this.id = category.getGateIn().managedContentId(category.getId(), name,
contentId);
@@ -55,7 +55,7 @@
return "ManagedContent '" + getName() + "' =>" +
getContent();
}
- public Id<ManagedContent<T>> getId()
+ public ManagedContent.Id getId()
{
return id;
}
@@ -92,7 +92,7 @@
return category.getGateIn();
}
- public T getContent()
+ public Content getContent()
{
if (content == null)
{
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-15
20:52:16 UTC (rev 7137)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/PortletImpl.java 2011-08-15
20:55:43 UTC (rev 7138)
@@ -29,9 +29,9 @@
import org.gatein.portal.api.impl.GateInImpl;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public class PortletImpl extends AbstractPortlet<Portlet> implements Portlet
+public class PortletImpl extends AbstractPortlet implements Portlet
{
- public PortletImpl(Id<Portlet> id, org.gatein.pc.api.Portlet application,
GateInImpl gateIn)
+ public PortletImpl(Portlet.Id id, org.gatein.pc.api.Portlet application, GateInImpl
gateIn)
{
super(id, application, gateIn);
}
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-15
20:52:16 UTC (rev 7137)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/WSRPImpl.java 2011-08-15
20:55:43 UTC (rev 7138)
@@ -29,9 +29,9 @@
import org.gatein.portal.api.impl.GateInImpl;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public class WSRPImpl extends AbstractPortlet<WSRP> implements WSRP
+public class WSRPImpl extends AbstractPortlet implements WSRP
{
- public WSRPImpl(Id<WSRP> id, org.gatein.pc.api.Portlet application, GateInImpl
gateIn)
+ public WSRPImpl(WSRP.Id id, org.gatein.pc.api.Portlet application, GateInImpl gateIn)
{
super(id, application, gateIn);
}
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-15
20:52:16 UTC (rev 7137)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java 2011-08-15
20:55:43 UTC (rev 7138)
@@ -43,7 +43,7 @@
return create(Identifiable.class, rootComponent, additionalComponent);
}
- public <T extends Identifiable> Id<T> create(Class<T> type, String
rootComponent, String... additionalComponents)
+ public <T extends Identifiable<T>> Id<T> create(Class<T> type,
String rootComponent, String... additionalComponents)
{
if (!type.isAssignableFrom(Portlet.class))
{
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-15
20:52:16 UTC (rev 7137)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java 2011-08-15
20:55:43 UTC (rev 7138)
@@ -29,7 +29,7 @@
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 class ComplexApplicationId // implements Id<Portlet>
{
public static final String LOCAL = "local";
public static final String START = LOCAL + ".";
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/DashboardSiteImpl.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/DashboardSiteImpl.java 2011-08-15
20:52:16 UTC (rev 7137)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/DashboardSiteImpl.java 2011-08-15
20:55:43 UTC (rev 7138)
@@ -23,7 +23,6 @@
package org.gatein.portal.api.impl.portal;
import org.exoplatform.portal.mop.SiteKey;
-import org.gatein.api.id.Id;
import org.gatein.api.portal.Site;
import org.gatein.api.util.Type;
import org.gatein.portal.api.impl.GateInImpl;
@@ -31,7 +30,7 @@
/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
public class DashboardSiteImpl extends SiteImpl
{
- public DashboardSiteImpl(Id<? extends Site> siteId, String name, GateInImpl
gateIn)
+ public DashboardSiteImpl(Site.Id siteId, String name, GateInImpl gateIn)
{
super(siteId, name, gateIn);
}
@@ -42,7 +41,7 @@
return SiteKey.user(getName());
}
- public Type getType()
+ public Type<Site> getType()
{
return Site.DASHBOARD;
}
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/GroupSiteImpl.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/GroupSiteImpl.java 2011-08-15
20:52:16 UTC (rev 7137)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/GroupSiteImpl.java 2011-08-15
20:55:43 UTC (rev 7138)
@@ -31,7 +31,7 @@
/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
public class GroupSiteImpl extends SiteImpl
{
- public GroupSiteImpl(Id<? extends Site> siteId, String name, GateInImpl gateIn)
+ public GroupSiteImpl(Site.Id siteId, String name, GateInImpl gateIn)
{
super(siteId, name, gateIn);
}
@@ -42,7 +42,7 @@
return SiteKey.group(getName());
}
- public Type getType()
+ public Type<Site> getType()
{
return Site.GROUP;
}
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-15
20:52:16 UTC (rev 7137)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java 2011-08-15
20:55:43 UTC (rev 7138)
@@ -25,7 +25,6 @@
import org.exoplatform.commons.utils.ExpressionUtil;
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
-import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.mop.Described;
import org.exoplatform.portal.mop.SiteType;
import org.exoplatform.portal.mop.description.DescriptionService;
@@ -34,12 +33,11 @@
import org.exoplatform.portal.mop.navigation.NodeModel;
import org.exoplatform.portal.mop.navigation.NodeState;
import org.exoplatform.portal.mop.navigation.Scope;
-import org.exoplatform.portal.webui.util.Util;
import org.exoplatform.services.resources.ResourceBundleManager;
+import org.exoplatform.web.application.RequestContext;
import org.exoplatform.web.url.navigation.NavigationResource;
import org.exoplatform.web.url.navigation.NodeURL;
import org.gatein.api.GateIn;
-import org.gatein.api.id.Id;
import org.gatein.api.id.Identifiable;
import org.gatein.api.portal.Navigation;
import org.gatein.api.portal.Page;
@@ -61,14 +59,14 @@
public class NavigationImpl implements Navigation, Identifiable<Navigation>
{
private final NodeContext<NavigationImpl> context;
- private Id<? extends Site> site;
- private Id<Navigation> id;
+ private Site.Id site;
+ private Navigation.Id id;
private final GateInImpl gateIn;
private URI uri;
private String displayName;
private ResourceBundle bundle;
- public NavigationImpl(Id<Site> siteId, NodeContext<NavigationImpl>
context, GateInImpl gateIn)
+ public NavigationImpl(Site.Id siteId, NodeContext<NavigationImpl> context,
GateInImpl gateIn)
{
this.context = context;
this.site = siteId;
@@ -116,7 +114,7 @@
{
try
{
- PortalRequestContext requestContext = Util.getPortalRequestContext();
+ RequestContext requestContext = RequestContext.getCurrentInstance();
SiteType siteType = SiteType.valueOf(site.getComponents()[0].toUpperCase());
String siteName = site.getComponents()[1];
@@ -172,7 +170,7 @@
setTargetPage(target.getId());
}
- public void setTargetPage(Id<Page> targetId)
+ public void setTargetPage(Page.Id targetId)
{
context.setState(new
NodeState.Builder(context.getState()).pageRef(targetId.toString()).build());
}
@@ -193,7 +191,7 @@
return old;
}
- public boolean contains(Id<Navigation> id)
+ public boolean contains(org.gatein.api.id.Id<Navigation> id)
{
return NavigationImpl.this.contains(id);
}
@@ -227,16 +225,17 @@
return contains(getIdForChild(key));
}
- public <U extends Navigation> boolean contains(Id<U> navigationId)
+ public boolean contains(org.gatein.api.id.Id<Navigation> navigationId)
{
loadChildrenIfNeeded();
return getChild(navigationId) != null;
}
- private <U extends Navigation> NodeContext<NavigationImpl>
getChild(Id<U> navigationId)
+ private NodeContext<NavigationImpl>
getChild(org.gatein.api.id.Id<Navigation> navigationId)
{
- return context.get(navigationId.getComponent(GateInImpl.NAVIGATION_COMPONENT));
+// return context.get(navigationId.getComponent(GateInImpl.NAVIGATION_COMPONENT));
+ throw new UnsupportedOperationException();
}
public Navigation createAndAdd(String key)
@@ -244,7 +243,7 @@
return createAndAdd(getIdForChild(key));
}
- public <U extends Navigation> U createAndAdd(Id<U> navigationId)
+ public Navigation createAndAdd(org.gatein.api.id.Id<Navigation> navigationId)
{
throw new NotYetImplemented(); // TODO
}
@@ -254,7 +253,7 @@
return get(getIdForChild(key));
}
- public <U extends Navigation> U get(Id<U> navigationId)
+ public Navigation get(org.gatein.api.id.Id<Navigation> navigationId)
{
if (navigationId == null)
{
@@ -263,22 +262,22 @@
else
{
loadChildrenIfNeeded();
- final Class<U> type = navigationId.getIdentifiableType();
final NodeContext<NavigationImpl> child = getChild(navigationId);
- return child != null ? type.cast(child.getNode()) : null;
+ return child != null ? child.getNode() : null;
}
}
- public Id<Navigation> getIdForChild(String key)
+ public Navigation.Id getIdForChild(String key)
{
- return site.getIdForChild(key);
+// return site.getIdForChild(key);
+ throw new UnsupportedOperationException();
}
- public Id<Navigation> getId()
+ public Navigation.Id getId()
{
if (id == null)
{
- id = GateInImpl.NAVIGATION_CONTEXT.create(Navigation.class, site.toString(),
context.getId());
+ id = new Navigation.Id(context.getId());
}
return id;
@@ -327,7 +326,7 @@
public Locale getUserLocale()
{
- return Util.getPortalRequestContext().getLocale();
+ return RequestContext.getCurrentInstance().getLocale();
}
@@ -337,7 +336,7 @@
{
ExoContainer container = ExoContainerContext.getCurrentContainer();
ResourceBundleManager rbMgr =
(ResourceBundleManager)container.getComponentInstanceOfType(ResourceBundleManager.class);
- Locale locale = Util.getPortalRequestContext().getLocale();
+ Locale locale = getUserLocale();
bundle = rbMgr.getNavigationResourceBundle(
locale.getLanguage(),
site.getComponent(GateInImpl.SITE_TYPE_COMPONENT),
@@ -359,10 +358,10 @@
static class NavigationNodeModel implements NodeModel<NavigationImpl>
{
- private final Id<Site> siteId;
+ private final Site.Id siteId;
private final GateInImpl gateIn;
- NavigationNodeModel(Id<Site> siteId, GateInImpl gateIn)
+ NavigationNodeModel(Site.Id siteId, GateInImpl gateIn)
{
this.siteId = siteId;
this.gateIn = gateIn;
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PageImpl.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PageImpl.java 2011-08-15
20:52:16 UTC (rev 7137)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PageImpl.java 2011-08-15
20:55:43 UTC (rev 7138)
@@ -34,12 +34,12 @@
import org.gatein.portal.api.impl.IdentifiableImpl;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public class PageImpl extends IdentifiableImpl<Page> implements Page
+public class PageImpl extends IdentifiableImpl<Page, Page.Id> implements Page
{
- private final Id<? extends Site> site;
+ private final Site.Id site;
private PageData pageData;
- public PageImpl(PageData pageData, Id<? extends Site> parent, GateInImpl
gateIn)
+ public PageImpl(PageData pageData, Site.Id parent, GateInImpl gateIn)
{
super(gateIn.pageId(parent, pageData.getName()), pageData.getName(), gateIn);
this.site = parent;
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PortalImpl.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PortalImpl.java 2011-08-15
20:52:16 UTC (rev 7137)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PortalImpl.java 2011-08-15
20:55:43 UTC (rev 7138)
@@ -45,7 +45,7 @@
return new ContentRegistryImpl(getGateInImpl(), this);
}
- public Type getType()
+ public Type<Site> getType()
{
return Site.PORTAL;
}
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java 2011-08-15
20:52:16 UTC (rev 7137)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java 2011-08-15
20:55:43 UTC (rev 7138)
@@ -32,11 +32,9 @@
import org.exoplatform.portal.pom.data.OwnerKey;
import org.exoplatform.portal.pom.data.PageData;
import org.exoplatform.portal.pom.data.PageKey;
-import org.gatein.api.id.Id;
import org.gatein.api.portal.Navigation;
import org.gatein.api.portal.Page;
import org.gatein.api.portal.Site;
-import org.gatein.api.util.GateInTypesResolver;
import org.gatein.api.util.HierarchicalContainer;
import org.gatein.api.util.IterableIdentifiableCollection;
import org.gatein.api.util.Type;
@@ -44,15 +42,16 @@
import org.gatein.portal.api.impl.GateInImpl;
import org.gatein.portal.api.impl.IdentifiableImpl;
import org.gatein.portal.api.impl.util.AdaptedIterableIdentifiableCollection;
+import org.gatein.portal.api.impl.util.GateInTypesResolver;
import java.util.List;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public abstract class SiteImpl extends IdentifiableImpl implements Site
+public abstract class SiteImpl extends IdentifiableImpl<Site, Site.Id> implements
Site
{
private PageContainer pageRegistry;
- public SiteImpl(Id<? extends Site> siteId, String name, GateInImpl gateIn)
+ public SiteImpl(Site.Id siteId, String name, GateInImpl gateIn)
{
super(siteId, name, gateIn);
pageRegistry = new PageContainer(gateIn, this);
@@ -173,14 +172,14 @@
return pageData != null ? new PageImpl(pageData, site.getId(), gateIn) : null;
}
- public Id<Page> getIdForChild(String key)
+ public org.gatein.api.id.Id<Page> getIdForChild(String key)
{
return site.getId().getIdForChild(key);
}
- public <U extends Page> U createAndAdd(Id<U> id)
+ public Page createAndAdd(org.gatein.api.id.Id<Page> id)
{
- return (U)createAndAdd(id.toString());
+ return createAndAdd(id.toString());
}
public IterableIdentifiableCollection<Page> getAll()
@@ -193,7 +192,7 @@
return new PageImpl(old, site.getId(), gateIn);
}
- public boolean contains(Id<Page> t)
+ public boolean contains(org.gatein.api.id.Id<Page> t)
{
return getPageData(t.toString()) != null;
}
@@ -224,12 +223,12 @@
return getAllPageData().size();
}
- public <U extends Page> U get(Id<U> id)
+ public Page get(org.gatein.api.id.Id<Page> id)
{
- return (U)get(id.toString());
+ return get(id.toString());
}
- public <U extends Page> boolean contains(Id<U> id)
+ public boolean contains(org.gatein.api.id.Id<Page> id)
{
return contains(id.toString());
}
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterableIdentifiableCollection.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterableIdentifiableCollection.java 2011-08-15
20:52:16 UTC (rev 7137)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AdaptedIterableIdentifiableCollection.java 2011-08-15
20:55:43 UTC (rev 7138)
@@ -29,7 +29,7 @@
import java.util.Iterator;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public abstract class AdaptedIterableIdentifiableCollection<O, N extends
Identifiable> extends AdaptedIterableCollection<O, N> implements
IterableIdentifiableCollection<N>
+public abstract class AdaptedIterableIdentifiableCollection<O, N extends
Identifiable<N>> extends AdaptedIterableCollection<O, N> implements
IterableIdentifiableCollection<N>
{
public AdaptedIterableIdentifiableCollection(int size, Iterator<O> adaptee)
{
Added:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/GateInTypesResolver.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/GateInTypesResolver.java
(rev 0)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/GateInTypesResolver.java 2011-08-15
20:55:43 UTC (rev 7138)
@@ -0,0 +1,63 @@
+package org.gatein.portal.api.impl.util;
+
+import org.gatein.api.GateIn;
+import org.gatein.api.content.Content;
+import org.gatein.api.portal.Site;
+import org.gatein.api.util.Type;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public class GateInTypesResolver
+{
+ public static Type forName(String name, Class originatingClass)
+ {
+ if (originatingClass == null)
+ {
+ throw new IllegalArgumentException("Must pass a valid class for which a
Type needs to be resolved");
+ }
+
+ if (name == null || name.isEmpty())
+ {
+ throw new IllegalArgumentException("Must pass a valid name for the Type to
be resolved");
+ }
+
+ if (Site.class.equals(originatingClass))
+ {
+ if (Site.PORTAL_TYPE_NAME.equalsIgnoreCase(name))
+ {
+ return Site.PORTAL;
+ }
+ else if (Site.GROUP_TYPE_NAME.equalsIgnoreCase(name))
+ {
+ return Site.GROUP;
+ }
+ else if (Site.DASHBOARD_TYPE_NAME.equalsIgnoreCase(name))
+ {
+ return Site.DASHBOARD;
+ }
+ }
+ else if (Content.class.equals(originatingClass))
+ {
+ if (Content.PORTLET_TYPE_NAME.equalsIgnoreCase(name))
+ {
+ return Content.PORTLET;
+ }
+ else if (Content.GADGET_TYPE_NAME.equalsIgnoreCase(name))
+ {
+ return Content.GADGET;
+ }
+ else if (Content.WSRP_TYPE_NAME.equalsIgnoreCase(name))
+ {
+ return Content.WSRP;
+ }
+ }
+ else if (GateIn.class.equals(originatingClass))
+ {
+ if (GateIn.LIFECYCLEMANAGER_TYPE_NAME.equalsIgnoreCase(name))
+ {
+ return GateIn.LIFECYCLE_MANAGER;
+ }
+ }
+
+ throw new IllegalArgumentException("Unknown Type '" + name +
"' for class " + originatingClass.getName());
+ }
+}
\ No newline at end of file
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-15
20:52:16 UTC (rev 7137)
+++
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java 2011-08-15
20:55:43 UTC (rev 7138)
@@ -33,6 +33,7 @@
@Test
public void checkParsing()
{
+/*
Id<Portlet> id =
ComplexApplicationContext.INSTANCE.parse("category/local._webapp.portlet",
Portlet.class);
assert
"category".equals(id.getComponent(GateInImpl.CATEGORY_COMPONENT));
assert
"webapp".equals(id.getComponent(GateInImpl.APPLICATION_COMPONENT));
@@ -47,5 +48,6 @@
assert "portlet".equals(id.getComponent(GateInImpl.PORTLET_COMPONENT));
assert id.equals(ComplexApplicationContext.INSTANCE.parse(id.toString()));
+*/
}
}
Added:
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java
===================================================================
---
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java
(rev 0)
+++
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java 2011-08-15
20:55:43 UTC (rev 7138)
@@ -0,0 +1,121 @@
+package org.gatein.portal.api.impl.portal;
+
+import org.exoplatform.component.test.ConfigurationUnit;
+import org.exoplatform.component.test.ConfiguredBy;
+import org.exoplatform.component.test.ContainerScope;
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.portal.AbstractPortalTest;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.navigation.NavigationContext;
+import org.exoplatform.portal.mop.navigation.NavigationService;
+import org.exoplatform.portal.mop.navigation.NavigationState;
+import org.exoplatform.portal.mop.navigation.NodeContext;
+import org.exoplatform.portal.mop.navigation.NodeModel;
+import org.exoplatform.portal.mop.navigation.Scope;
+import org.exoplatform.portal.pom.config.POMSessionManager;
+import org.exoplatform.portal.pom.data.ModelDataStorage;
+import org.gatein.api.GateIn;
+import org.gatein.api.portal.Navigation;
+import org.gatein.api.portal.Site;
+import org.gatein.portal.api.impl.GateInImpl;
+
+import java.util.Iterator;
+
+/** @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a> */
+@ConfiguredBy({
+ @ConfigurationUnit(scope = ContainerScope.PORTAL, path =
"conf/exo.portal.component.test.jcr-configuration.xml"),
+ @ConfigurationUnit(scope = ContainerScope.PORTAL, path =
"conf/exo.portal.component.identity-configuration.xml"),
+ @ConfigurationUnit(scope = ContainerScope.PORTAL, path =
"conf/exo.portal.component.portal-configuration.xml")
+})
+public class NavigationTestCase extends AbstractPortalTest
+{
+
+ /** . */
+ protected POMSessionManager mgr;
+
+ /** . */
+ protected NavigationService navService;
+
+ /** . */
+ protected GateIn gatein;
+
+ /** . */
+ protected NodeContext root;
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ //
+ PortalContainer container = getContainer();
+ POMSessionManager mgr =
(POMSessionManager)container.getComponentInstanceOfType(POMSessionManager.class);
+ NavigationService navService =
(NavigationService)container.getComponentInstanceOfType(NavigationService.class);
+ GateInImpl gatein = new GateInImpl(container.getContext(), null, null, null);
+
+ //
+ gatein.start();
+
+ // Clear the cache for each test
+ // navService.clearCache();
+
+ //
+ this.gatein = gatein;
+ this.mgr = mgr;
+ this.navService = navService;
+
+ //
+ begin();
+
+ //
+ ModelDataStorage storage =
(ModelDataStorage)container.getComponentInstanceOfType(ModelDataStorage.class);
+ storage.create(new PortalConfig("portal", "classic").build());
+ NavigationContext nav = new NavigationContext(SiteKey.portal("classic"),
new NavigationState(0));
+ navService.saveNavigation(nav);
+ root = navService.loadNode(NodeModel.SELF_MODEL, nav, Scope.ALL, null);
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ end(false);
+ }
+
+ public void testEmptyNavigation()
+ {
+ Site site = gatein.getPortal(new Site.Id(Site.PORTAL, "classic"));
+ assertNotNull(site);
+ Site.Id id = site.getId();
+ assertEquals(Site.PORTAL, id.getType());
+ assertEquals("classic", id.getName());
+
+ //
+ Navigation navigation = site.getNavigation();
+ assertNotNull(navigation);
+ Iterator<Navigation> i = navigation.getAll().iterator();
+ assertFalse(i.hasNext());
+ }
+
+ public void testSingleNavigation()
+ {
+ root.add(null, "home");
+ navService.saveNode(root, null);
+
+ //
+ Site site = gatein.getPortal(new Site.Id(Site.PORTAL, "classic"));
+ assertNotNull(site);
+ Site.Id id = site.getId();
+ assertEquals(Site.PORTAL, id.getType());
+ assertEquals("classic", id.getName());
+
+ //
+ Navigation navigation = site.getNavigation();
+ assertNotNull(navigation);
+ Iterator<Navigation> i = navigation.getAll().iterator();
+ assertTrue(i.hasNext());
+ Navigation home = i.next();
+ assertEquals("home", home.getName());
+ assertFalse(i.hasNext());
+ }
+}
Modified:
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/SiteTestCase.java
===================================================================
---
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/SiteTestCase.java 2011-08-15
20:52:16 UTC (rev 7137)
+++
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/SiteTestCase.java 2011-08-15
20:55:43 UTC (rev 7138)
@@ -26,8 +26,8 @@
import org.exoplatform.portal.pom.data.PageKey;
import org.exoplatform.portal.pom.data.PortalKey;
import org.gatein.api.portal.Site;
-import org.gatein.api.util.GateInTypesResolver;
import org.gatein.api.util.Type;
+import org.gatein.portal.api.impl.util.GateInTypesResolver;
import org.testng.annotations.Test;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
@@ -48,4 +48,6 @@
assert Site.PORTAL.equals(SiteImpl.getAPITypeFrom(new
PortalKey(SiteType.PORTAL.getName(), "foo")));
assert Site.PORTAL.equals(SiteImpl.getAPITypeFrom(new PortalKey("portal",
"foo")));
}
+
+
}
Modified:
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollectionTestCase.java
===================================================================
---
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollectionTestCase.java 2011-08-15
20:52:16 UTC (rev 7137)
+++
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollectionTestCase.java 2011-08-15
20:55:43 UTC (rev 7138)
@@ -37,6 +37,7 @@
/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
public class AggregatedIterableIdentifiableCollectionTestCase
{
+/*
private AggregatedIterableIdentifiableCollection collection;
private static final IterableIdentifiableCollection fixture3 = new
TestCollection("1", "2", "3");
private static final IterableIdentifiableCollection fixture4 = new
TestCollection("a", "b", "c", "d");
@@ -169,4 +170,5 @@
return elements.values().iterator();
}
}
+*/
}
Modified:
portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/NavigationPortlet.java
===================================================================
---
portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/NavigationPortlet.java 2011-08-15
20:52:16 UTC (rev 7137)
+++
portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/NavigationPortlet.java 2011-08-15
20:55:43 UTC (rev 7138)
@@ -51,26 +51,24 @@
@Override
protected void doView(RenderRequest request, RenderResponse response) throws
PortletException, IOException
{
- Id userId = gateIn.userId("root");
-
PrintWriter writer = response.getWriter();
writer.println("<h1>Portal Sites</h1>");
- IterableIdentifiableCollection<? extends Site> sites =
gateIn.getPortalSites(userId);
+ IterableIdentifiableCollection<? extends Site> sites =
gateIn.getPortalSites("root");
for (Site site : sites)
{
outputSite(site, writer);
}
writer.println("<h1>Group Sites</h1>");
- sites = gateIn.getGroupSites(userId);
+ sites = gateIn.getGroupSites("root");
for (Site site : sites)
{
outputSite(site, writer);
}
writer.println("<h1>Dashboard</h1>");
- outputSite(gateIn.getDashboard(userId), writer);
+ outputSite(gateIn.getDashboard("root"), writer);
}
private void outputSite(Site site, PrintWriter writer) throws IOException
Modified: portal/branches/api/pom.xml
===================================================================
--- portal/branches/api/pom.xml 2011-08-15 20:52:16 UTC (rev 7137)
+++ portal/branches/api/pom.xml 2011-08-15 20:55:43 UTC (rev 7138)
@@ -50,7 +50,7 @@
<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.mgmt.version>1.0.0-Beta01</org.gatein.mgmt.version>
- <org.gatein.api.version>1.0.0-Beta01</org.gatein.api.version>
+ <org.gatein.api.version>1.0.0-Beta02-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>