Author: chris.laprun(a)jboss.com
Date: 2011-07-20 15:53:48 -0400 (Wed, 20 Jul 2011)
New Revision: 6901
Added:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/
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/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
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/portal/PortalImpl.java
Log:
- Adapted for API changes.
- Started implementing ContentRegistry scenario.
Modified: portal/branches/api/component/api-impl/pom.xml
===================================================================
--- portal/branches/api/component/api-impl/pom.xml 2011-07-20 12:33:23 UTC (rev 6900)
+++ portal/branches/api/component/api-impl/pom.xml 2011-07-20 19:53:48 UTC (rev 6901)
@@ -30,6 +30,10 @@
<artifactId>guava</artifactId>
<version>r09</version>
</dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.application-registry</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-07-20
12:33:23 UTC (rev 6900)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java 2011-07-20
19:53:48 UTC (rev 6901)
@@ -22,6 +22,8 @@
package org.gatein.portal.api.impl;
+import org.exoplatform.application.gadget.GadgetRegistryService;
+import org.exoplatform.application.registry.ApplicationRegistryService;
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.container.component.RequestLifeCycle;
@@ -40,6 +42,7 @@
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;
@@ -79,10 +82,14 @@
.withDefaultSeparator("::").build();
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();
private ExoContainer container;
private ModelDataStorage dataStorage;
private NavigationService navigationService;
private OrganizationService organizationService;
+ private ApplicationRegistryService registryService;
+ private GadgetRegistryService gadgetService;
public GateInImpl(ExoContainerContext context, InitParams params, ConfigurationManager
configurationManager)
{
@@ -249,7 +256,7 @@
public Id groupId(String root, String... children)
{
- return null; //To change body of implemented methods use File | Settings | File
Templates.
+ return Id.create(GROUP_CONTEXT, root, children);
}
public Id<Application> applicationId(String application, String portlet)
@@ -272,11 +279,16 @@
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)
+ public <T extends Content<T>> Id<ManagedContent<T>>
managedContentId(Id<T> contentId)
{
return null; //To change body of implemented methods use File | Settings | File
Templates.
}
+ public Id<Category> categoryId(String name)
+ {
+ return null;
+ }
+
public <T extends Site> Id<T> siteId(Site.Type<T> siteType, String
siteName)
{
return Id.create(CONTEXT, siteType.getValueType(), siteType.getName(), siteName);
@@ -293,6 +305,8 @@
dataStorage =
(ModelDataStorage)container.getComponentInstanceOfType(ModelDataStorage.class);
navigationService =
(NavigationService)container.getComponentInstanceOfType(NavigationService.class);
organizationService =
(OrganizationService)container.getComponentInstanceOfType(OrganizationService.class);
+ registryService =
(ApplicationRegistryService)container.getComponentInstanceOfType(ApplicationRegistryService.class);
+ gadgetService =
(GadgetRegistryService)container.getComponentInstanceOfType(GadgetRegistryService.class);
}
public void stop()
@@ -310,6 +324,11 @@
return navigationService;
}
+ public ApplicationRegistryService getRegistryService()
+ {
+ return registryService;
+ }
+
private PortalData getPortalDataFor(Id<Portal> portalId)
{
ParameterValidation.throwIllegalArgExceptionIfNull(portalId, "Portal
Id");
@@ -333,4 +352,9 @@
{
RequestLifeCycle.begin(container);
}
+
+ public GadgetRegistryService getGadgetService()
+ {
+ return gadgetService;
+ }
}
Added:
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
(rev 0)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ApplicationImpl.java 2011-07-20
19:53:48 UTC (rev 6901)
@@ -0,0 +1,40 @@
+/*
+* 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.id.Id;
+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;
+ }
+}
Added:
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
(rev 0)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/CategoryImpl.java 2011-07-20
19:53:48 UTC (rev 6901)
@@ -0,0 +1,101 @@
+/*
+* 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.ApplicationCategory;
+import org.gatein.api.GateIn;
+import org.gatein.api.content.Category;
+import org.gatein.api.content.Content;
+import org.gatein.api.content.ManagedContent;
+import org.gatein.api.id.Id;
+import org.gatein.portal.api.impl.GateInImpl;
+
+import java.util.List;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public class CategoryImpl implements Category
+{
+ private final ApplicationCategory category;
+ private final GateInImpl gateIn;
+
+ public CategoryImpl(ApplicationCategory category, GateInImpl gateIn)
+ {
+ this.category = category;
+ this.gateIn = gateIn;
+ }
+
+ public <T extends Content<T>> ManagedContent<T>
getContent(Id<ManagedContent<T>> contentId)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public boolean contains(Id<? extends ManagedContent> contentId)
+ {
+ return false; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public <T extends Content<T>> ManagedContent<T>
addContent(Id<T> contentId)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public List<Id<? extends ManagedContent>> getKnownManagedContentIds()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getDescription()
+ {
+ return category.getDescription();
+ }
+
+ public void setDescription(String description)
+ {
+ category.setDescription(description);
+ }
+
+ public <T extends Content<T>> void
removeContent(Id<ManagedContent<T>> id)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Id<Category> getId()
+ {
+ return gateIn.categoryId(getName());
+ }
+
+ public String getName()
+ {
+ return category.getName();
+ }
+
+ public String getDisplayName()
+ {
+ return category.getDisplayName();
+ }
+
+ public GateIn getGateIn()
+ {
+ return gateIn;
+ }
+}
Added:
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
(rev 0)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java 2011-07-20
19:53:48 UTC (rev 6901)
@@ -0,0 +1,128 @@
+/*
+* 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.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.id.Id;
+import org.gatein.api.util.IterableResult;
+import org.gatein.api.util.Query;
+import org.gatein.portal.api.impl.GateInImpl;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public class ContentRegistryImpl implements ContentRegistry
+{
+ private final GateInImpl gateIn;
+
+ public ContentRegistryImpl(GateInImpl gateIn)
+ {
+ this.gateIn = gateIn;
+ }
+
+ public Category getOrCreateCategory(String name)
+ {
+ return getOrCreateCategory(name, true);
+ }
+
+ public Category getCategory(String name)
+ {
+ return getOrCreateCategory(name, false);
+ }
+
+ private Category getOrCreateCategory(String name, boolean forceCreate)
+ {
+ try
+ {
+ ApplicationRegistryService registryService = gateIn.getRegistryService();
+ ApplicationCategory applicationCategory =
registryService.getApplicationCategory(name);
+ if (applicationCategory == null)
+ {
+ if (forceCreate)
+ {
+ applicationCategory = new ApplicationCategory();
+ applicationCategory.setName(name);
+ registryService.save(applicationCategory);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ return new CategoryImpl(applicationCategory, gateIn);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public <T extends Content<T>> T getContent(Id<T> id)
+ {
+ Class<T> type = id.getIdentifiableType();
+ Object result;
+ if (Application.class.equals(type))
+ {
+ try
+ {
+ result = new
ApplicationImpl(gateIn.getRegistryService().getApplication(id.toString()), gateIn);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ else if (Gadget.class.equals(type))
+ {
+ try
+ {
+ result = new GadgetImpl(gateIn.getGadgetService().getGadget(id.toString()),
gateIn);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unknown Content type: " +
type.getCanonicalName());
+ }
+ return type.cast(result);
+ }
+
+ public IterableResult<ManagedContent>
getManagedContents(Query<ManagedContent> query)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public Gadget createGadget(String gadget, String source)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+}
Added:
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
(rev 0)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/GadgetImpl.java 2011-07-20
19:53:48 UTC (rev 6901)
@@ -0,0 +1,75 @@
+/*
+* 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.gadget.Gadget;
+import org.gatein.api.id.Id;
+import org.gatein.portal.api.impl.GateInImpl;
+import org.gatein.portal.api.impl.IdentifiableImpl;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+
+/** @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
+{
+ private final Gadget gadget;
+
+ public GadgetImpl(Gadget gadget, GateInImpl gateIn)
+ {
+ super(Id.parse(GateInImpl.APPLICATION_CONTEXT, gadget.getName(),
org.gatein.api.content.Gadget.class), gadget.getName(), gateIn);
+ this.gadget = gadget;
+ }
+
+ public URL getViewURL()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public URL getEditURL()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public URL getReferenceURL()
+ {
+ try
+ {
+ return URI.create(gadget.getReferenceUrl()).toURL();
+ }
+ catch (MalformedURLException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public String getSource()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public void setSource(String source)
+ {
+ }
+}
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-07-20
12:33:23 UTC (rev 6900)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PortalImpl.java 2011-07-20
19:53:48 UTC (rev 6901)
@@ -28,6 +28,7 @@
import org.gatein.api.portal.Portal;
import org.gatein.api.portal.Site;
import org.gatein.portal.api.impl.GateInImpl;
+import org.gatein.portal.api.impl.content.ContentRegistryImpl;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
public class PortalImpl extends SiteImpl implements Portal
@@ -40,7 +41,7 @@
public ContentRegistry getContentRegistry()
{
- return null; //To change body of implemented methods use File | Settings | File
Templates.
+ return new ContentRegistryImpl(getGateInImpl());
}
public Type getType()