Author: chris.laprun(a)jboss.com
Date: 2011-07-11 17:26:57 -0400 (Mon, 11 Jul 2011)
New Revision: 6859
Added:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/IdentifiableImpl.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/NavigationImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/PortalImpl.java
Log:
- Adapted for API changes.
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-11
21:25:15 UTC (rev 6858)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java 2011-07-11
21:26:57 UTC (rev 6859)
@@ -22,35 +22,44 @@
package org.gatein.portal.api.impl;
-import com.google.common.base.Function;
-import org.bouncycastle.ocsp.OCSPReqGenerator;
+import org.exoplatform.commons.utils.LazyPageList;
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
-import org.exoplatform.container.PortalContainer;
import org.exoplatform.container.configuration.ConfigurationManager;
import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.portal.config.Query;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.mop.SiteType;
import org.exoplatform.portal.mop.navigation.NavigationService;
import org.exoplatform.portal.pom.config.POMSession;
import org.exoplatform.portal.pom.config.POMSessionManager;
+import org.exoplatform.portal.pom.data.ModelDataStorage;
+import org.exoplatform.portal.pom.data.PortalData;
+import org.exoplatform.portal.pom.data.PortalKey;
import org.gatein.api.GateIn;
import org.gatein.api.IterableResult;
import org.gatein.api.Portal;
+import org.gatein.api.content.Application;
+import org.gatein.api.content.Content;
+import org.gatein.api.content.Gadget;
+import org.gatein.api.content.ManagedContent;
import org.gatein.api.id.Id;
import org.gatein.api.id.Identifiable;
import org.gatein.api.navigation.Site;
import org.gatein.mop.api.workspace.ObjectType;
-import org.gatein.mop.api.workspace.WorkspaceObject;
import org.picocontainer.Startable;
-import java.util.Collection;
+import java.net.URI;
import java.util.Iterator;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
public class GateInImpl implements GateIn, Startable
{
+ private static final Query<PortalConfig> PORTALS = new
Query<PortalConfig>(SiteType.PORTAL.getName(), null, PortalConfig.class);
private ExoContainer container;
+ private ModelDataStorage dataStorage;
+ private NavigationService navigationService;
private POMSessionManager pomSessionManager;
- private NavigationService navigationService;
public GateInImpl(ExoContainerContext context, InitParams params, ConfigurationManager
configurationManager)
{
@@ -59,54 +68,65 @@
public IterableResult<Portal> getPortals()
{
- final POMSession session = pomSessionManager.getSession();
- final Collection<org.gatein.mop.api.workspace.Site> sites =
session.getWorkspace().getSites(ObjectType.PORTAL_SITE);
- return new IterableResult<Portal>() {
- private int size = -1;
+ try
+ {
+ LazyPageList<PortalConfig> portals = dataStorage.find(PORTALS);
- public int size()
+ return new IterableResult<Portal>()
{
- if(size != -1)
+ private int size = -1;
+
+ public int size()
{
- return size;
+ if (size != -1)
+ {
+ return size;
+ }
+ else
+ {
+ POMSession session = pomSessionManager.getSession();
+ size = session.findObjects(ObjectType.PORTAL_SITE,
ObjectType.PORTAL_SITE, null, null, 0, 1).hits();
+ session.close();
+ return size;
+ }
}
- else
+
+ public boolean contains(Portal portal)
{
- size = session.findObjects(ObjectType.PORTAL_SITE, ObjectType.PORTAL_SITE,
null, null, 0, 1).hits();
- return size;
+ POMSession session = pomSessionManager.getSession();
+ boolean found = portal != null &&
session.findObjectById(portal.getId().toString()) != null;
+ session.close();
+ return found;
}
- }
- public boolean contains(Portal portal)
- {
- return portal != null &&
session.findObjectById(portal.getId().toString()) != null;
- }
-
- public Iterator<Portal> iterator()
- {
- return null ;
- }
- };
+ public Iterator<Portal> iterator()
+ {
+ return null;
+ }
+ };
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
}
public Portal getPortal(Id<Portal> portalId)
{
- final POMSession session = pomSessionManager.getSession();
- WorkspaceObject objectById = session.findObjectById(portalId.toString());
- if (objectById instanceof org.gatein.mop.api.workspace.Site)
+ try
{
- org.gatein.mop.api.workspace.Site site =
(org.gatein.mop.api.workspace.Site)objectById;
- if(ObjectType.PORTAL_SITE.equals(site.getObjectType()))
- {
- return new PortalImpl(site);
- }
+ PortalData portalConfig =
dataStorage.getPortalConfig(PortalKey.create(portalId.toString()));
+ return new PortalImpl(portalConfig, this);
}
- return null;
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
}
public Portal getDefaultPortal()
{
- return null; //To change body of implemented methods use File | Settings | File
Templates.
+ return getPortal(portalId("default")); // todo: check
}
public IterableResult<Site> getSites()
@@ -149,14 +169,65 @@
return null; //To change body of implemented methods use File | Settings | File
Templates.
}
+ public Id userId(String user)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public Id groupId(String root, String... children)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public Id<Application> applicationId(String application, String portlet)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public Id<Content> wsrpPortletId(String invoker, String portlet)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public Id<Gadget> gadgetId(String gadgetName)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public Id<Gadget> gadgetId(URI uri)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public <T extends Content> Id<ManagedContent<T>>
managedContentId(Id<Content<T>> contentId)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public Id<Portal> portalId(String portalName)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
public void start()
{
- pomSessionManager = (POMSessionManager)
container.getComponentInstanceOfType(POMSessionManager.class);
- navigationService = (NavigationService)
container.getComponentInstanceOfType(NavigationService.class);
+ dataStorage =
(ModelDataStorage)container.getComponentInstanceOfType(ModelDataStorage.class);
+ navigationService =
(NavigationService)container.getComponentInstanceOfType(NavigationService.class);
+ pomSessionManager =
(POMSessionManager)container.getComponentInstanceOfType(POMSessionManager.class);
}
public void stop()
{
//To change body of implemented methods use File | Settings | File Templates.
}
+
+ ModelDataStorage getDataStorage()
+ {
+ return dataStorage;
+ }
+
+ NavigationService getNavigationService()
+ {
+ return navigationService;
+ }
}
Added:
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
(rev 0)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/IdentifiableImpl.java 2011-07-11
21:26:57 UTC (rev 6859)
@@ -0,0 +1,69 @@
+/*
+* 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;
+
+import org.gatein.api.GateIn;
+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 IdentifiableImpl<T extends Identifiable<T>> implements
Identifiable<T>
+{
+ private final Id<T> id;
+ private final String name;
+ private final String displayName;
+ private final GateInImpl gateIn;
+
+ public IdentifiableImpl(Id<T> id, String name, GateInImpl gateIn)
+ {
+ this.id = id;
+ this.name = name;
+ this.gateIn = gateIn;
+ this.displayName = name; // todo: fix-me
+ }
+
+ public Id<T> getId()
+ {
+ return id;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getDisplayName()
+ {
+ return displayName;
+ }
+
+ public GateIn getGateIn()
+ {
+ return getGateInImpl();
+ }
+
+ protected GateInImpl getGateInImpl()
+ {
+ return gateIn;
+ }
+}
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/NavigationImpl.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/NavigationImpl.java 2011-07-11
21:25:15 UTC (rev 6858)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/NavigationImpl.java 2011-07-11
21:26:57 UTC (rev 6859)
@@ -22,19 +22,20 @@
package org.gatein.portal.api.impl;
+import org.exoplatform.portal.mop.navigation.NodeContext;
import org.gatein.api.Filter;
import org.gatein.api.IterableResult;
import org.gatein.api.Query;
-import org.gatein.api.id.Id;
import org.gatein.api.navigation.Navigation;
import org.gatein.api.navigation.Page;
import org.gatein.api.navigation.Site;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public class NavigationImpl implements Navigation
+public class NavigationImpl extends IdentifiableImpl<Navigation> implements
Navigation
{
- public NavigationImpl(org.gatein.mop.api.workspace.Navigation navigation)
+ public NavigationImpl(NodeContext<?> navigation, GateInImpl gateIn)
{
+ super(null, navigation.getName(), gateIn);
}
public Page getTargetPage()
@@ -86,19 +87,4 @@
{
return null; //To change body of implemented methods use File | Settings | File
Templates.
}
-
- public Id<Navigation> getId()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getName()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getDisplayName()
- {
- 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/PortalImpl.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/PortalImpl.java 2011-07-11
21:25:15 UTC (rev 6858)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/PortalImpl.java 2011-07-11
21:26:57 UTC (rev 6859)
@@ -22,23 +22,33 @@
package org.gatein.portal.api.impl;
+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.NodeContext;
+import org.exoplatform.portal.mop.navigation.NodeModel;
+import org.exoplatform.portal.mop.navigation.Scope;
+import org.exoplatform.portal.pom.data.PortalData;
import org.gatein.api.Container;
import org.gatein.api.Portal;
import org.gatein.api.content.ContentRegistry;
+import org.gatein.api.id.Context;
import org.gatein.api.id.Id;
import org.gatein.api.navigation.Navigation;
import org.gatein.api.navigation.Page;
import org.gatein.api.navigation.Site;
-import org.gatein.api.navigation.Targetable;
+import java.util.regex.Pattern;
+
/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public class PortalImpl implements Portal
+public class PortalImpl extends IdentifiableImpl implements Portal
{
- private final org.gatein.mop.api.workspace.Site site;
+ public static final Context CONTEXT =
Context.builder().requiredComponent("owner", Site.class,
Pattern.compile("\\w+"))
+ .requiredComponent("name", Portal.class,
Pattern.compile("\\w+")).withDefaultSeparator("::").build();
- public PortalImpl(org.gatein.mop.api.workspace.Site site)
+ public PortalImpl(PortalData portal, GateInImpl gateIn)
{
- this.site = site;
+ super(Id.create(CONTEXT, Portal.class, portal.getKey().getType(),
portal.getKey().getId()), portal.getName(), gateIn);
}
public ContentRegistry getContentRegistry()
@@ -46,37 +56,28 @@
return null; //To change body of implemented methods use File | Settings | File
Templates.
}
- public Id<Portal> getId()
+ public Container<String, Page> getPageRegistry()
{
return null; //To change body of implemented methods use File | Settings | File
Templates.
}
- public String getName()
+ public Navigation getNavigation()
{
- return site.getName();
- }
+ NavigationService service = getGateInImpl().getNavigationService();
+ NavigationContext navigation = service.loadNavigation(SiteKey.portal(getName()));
- public String getDisplayName()
- {
- return getName(); // todo: fix me
- }
+ //
+ NodeContext<?> node = service.loadNode(NodeModel.SELF_MODEL, navigation,
Scope.SINGLE, null).getNode();
- public Container<String, Page> getPageRegistry()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
+ return new NavigationImpl(node, getGateInImpl());
}
- public Navigation getNavigation()
- {
- return new NavigationImpl(site.getRootNavigation());
- }
-
public Type getType()
{
return Type.PORTAL;
}
- public Navigation createNavigationTo(Targetable node, Navigation parent)
+ public Navigation createNavigationTo(Page node, Navigation parent)
{
return null; //To change body of implemented methods use File | Settings | File
Templates.
}