Author: chris.laprun(a)jboss.com
Date: 2011-07-28 06:59:21 -0400 (Thu, 28 Jul 2011)
New Revision: 6939
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/util/AggregatedIterableIdentifiableCollection.java
portal/branches/api/pom.xml
Log:
- Updated to API Alpha02-SNAPSHOT.
- Improved AggregatedIterableIdentifiableCollection so that it can be used in getSites but
still not very satisfying (i.e. no real type safety) :(
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-28
00:02:21 UTC (rev 6938)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java 2011-07-28
10:59:21 UTC (rev 6939)
@@ -25,6 +25,7 @@
import org.exoplatform.application.gadget.GadgetRegistryService;
import org.exoplatform.application.gadget.SourceStorage;
import org.exoplatform.application.registry.ApplicationRegistryService;
+import org.exoplatform.commons.utils.ListAccess;
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.container.configuration.ConfigurationManager;
@@ -41,6 +42,8 @@
import org.exoplatform.services.organization.Group;
import org.exoplatform.services.organization.GroupHandler;
import org.exoplatform.services.organization.OrganizationService;
+import org.exoplatform.services.organization.User;
+import org.exoplatform.services.organization.UserHandler;
import org.gatein.api.GateIn;
import org.gatein.api.content.Category;
import org.gatein.api.content.Content;
@@ -58,13 +61,16 @@
import org.gatein.api.util.Type;
import org.gatein.common.util.ParameterValidation;
import org.gatein.portal.api.impl.lifecycle.NoOpLifecycleManager;
+import org.gatein.portal.api.impl.portal.DashboardSiteImpl;
import org.gatein.portal.api.impl.portal.GroupSiteImpl;
import org.gatein.portal.api.impl.portal.PageImpl;
import org.gatein.portal.api.impl.portal.PortalImpl;
import org.gatein.portal.api.impl.util.AdaptedIterableIdentifiableCollection;
+import org.gatein.portal.api.impl.util.AggregatedIterableIdentifiableCollection;
import org.picocontainer.Startable;
import java.net.URI;
+import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.regex.Pattern;
@@ -156,11 +162,59 @@
return getPortal(siteId(Site.PORTAL, "classic")); // todo: check
}
- public IterableIdentifiableCollection<Site> getSites()
+ public IterableIdentifiableCollection<? extends Site> getSites()
{
- return null; //To change body of implemented methods use File | Settings | File
Templates.
+ IterableIdentifiableCollection<Site> groupSites = getGroupSites();
+ IterableIdentifiableCollection<Portal> portals = getPortals();
+ IterableIdentifiableCollection<Site> dashboards = getDashboards();
+
+ AggregatedIterableIdentifiableCollection collection = new
AggregatedIterableIdentifiableCollection();
+ collection.addCollection(groupSites);
+ collection.addCollection(portals);
+ collection.addCollection(dashboards);
+
+ return collection;
}
+ private IterableIdentifiableCollection<Site> getDashboards()
+ {
+ try
+ {
+ final UserHandler userHandler = organizationService.getUserHandler();
+
+ // todo: optimize
+ ListAccess<User> usersAccess = userHandler.findAllUsers();
+ List<User> users = Arrays.asList(usersAccess.load(0,
usersAccess.getSize()));
+
+
+ // todo: check for correctness
+ return new AdaptedIterableIdentifiableCollection<User, Site>(users.size(),
users.iterator())
+ {
+
+ public Site adapt(User old)
+ {
+ return getDashboard(userId(old.getUserName()));
+ }
+
+ public boolean contains(Id<Site> t)
+ {
+ try
+ {
+ return dataStorage.loadDashboard(t.toString()) != null;
+ }
+ catch (Exception e)
+ {
+ return false;
+ }
+ }
+ };
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
public IterableIdentifiableCollection<Site> getGroupSites()
{
try
@@ -215,7 +269,10 @@
public Site getDashboard(Id userId)
{
- return null; //To change body of implemented methods use File | Settings | File
Templates.
+ String user = userId.toString();
+ Id<Site> siteId = siteId(Site.DASHBOARD, user);
+
+ return new DashboardSiteImpl(siteId, user, this);
}
public <T extends Identifiable> T get(Id<T> id)
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollection.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollection.java 2011-07-28
00:02:21 UTC (rev 6938)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollection.java 2011-07-28
10:59:21 UTC (rev 6939)
@@ -34,9 +34,9 @@
/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
public class AggregatedIterableIdentifiableCollection<T extends
Identifiable<T>> implements IterableIdentifiableCollection<T>
{
- private List<IterableIdentifiableCollection<T>> aggregated = new
ArrayList<IterableIdentifiableCollection<T>>(7);
+ private List<IterableIdentifiableCollection> aggregated = new
ArrayList<IterableIdentifiableCollection>(7);
- public void addCollection(IterableIdentifiableCollection<T> collection)
+ public void addCollection(IterableIdentifiableCollection<? extends T>
collection)
{
aggregated.add(collection);
}
@@ -73,7 +73,7 @@
public Iterator<T> iterator()
{
- final Iterator<IterableIdentifiableCollection<T>> iterator =
aggregated.iterator();
+ final Iterator<IterableIdentifiableCollection> iterator =
aggregated.iterator();
if (iterator.hasNext())
{
Modified: portal/branches/api/pom.xml
===================================================================
--- portal/branches/api/pom.xml 2011-07-28 00:02:21 UTC (rev 6938)
+++ portal/branches/api/pom.xml 2011-07-28 10:59:21 UTC (rev 6939)
@@ -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-Alpha01</org.gatein.api.version>
+
<org.gatein.api.version>1.0.0-Alpha02-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>