Author: julien_viet
Date: 2011-09-01 13:22:57 -0400 (Thu, 01 Sep 2011)
New Revision: 7284
Removed:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/AbstractPortlet.java
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/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/test/java/org/gatein/portal/api/impl/content/ContentRegistryTestCase.java
Log:
start to unit test portlet content
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-09-01
17:20:20 UTC (rev 7283)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java 2011-09-01
17:22:57 UTC (rev 7284)
@@ -496,7 +496,7 @@
final IterableIdentifiableCollection<Site> portals = getPortals();
for (Site portal : portals)
{
- result = ((Portal)portal).getContentRegistry().get((Content.Id)(Id)id);
+ result =
((Portal)portal).getContentRegistry().getContent((Content.Id)(Id)id);
if (result != null)
{
break;
Deleted:
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-09-01
17:20:20 UTC (rev 7283)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/AbstractPortlet.java 2011-09-01
17:22:57 UTC (rev 7284)
@@ -1,47 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-
-package org.gatein.portal.api.impl.content;
-
-import org.gatein.api.content.Content;
-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 abstract class AbstractPortlet extends IdentifiableImpl<Content, Content.Id>
implements Content
-{
- private final org.gatein.pc.api.Portlet portlet;
-
- public AbstractPortlet(Content.Id id, org.gatein.pc.api.Portlet application,
GateInImpl gateIn)
- {
- super(id, application.getInfo().getName(), gateIn);
- this.portlet = application;
- }
-
- @Override
- public String toString()
- {
- return getType().getName() + " Portlet '" + getName() + "'
@" + getId();
- }
-
-}
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-09-01
17:20:20 UTC (rev 7283)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java 2011-09-01
17:22:57 UTC (rev 7284)
@@ -34,14 +34,8 @@
import org.gatein.api.content.Portlet;
import org.gatein.api.content.WSRP;
import org.gatein.api.id.Id;
-import org.gatein.api.util.IterableIdentifiableCollection;
-import org.gatein.pc.api.PortletContext;
-import org.gatein.pc.api.PortletInvokerException;
-import org.gatein.pc.federation.FederatingPortletInvoker;
import org.gatein.portal.api.impl.GateInImpl;
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 java.util.ArrayList;
import java.util.Collection;
@@ -187,6 +181,33 @@
}
}
+ public <C extends Content<C>> C getContent(Content.Id<C> id)
+ {
+ if (id == null)
+ {
+ throw new NullPointerException("No null id accepted");
+ }
+
+ //
+ Class<C> type = id.getIdentifiableType();
+ if (Portlet.class.equals(type))
+ {
+ throw new UnsupportedOperationException("todo for portlet");
+ }
+ if (WSRP.class.equals(type))
+ {
+ throw new UnsupportedOperationException("todo for wsrp");
+ }
+ if (Gadget.class.equals(type))
+ {
+ throw new UnsupportedOperationException("todo for gadget");
+ }
+
+ //
+ throw new IllegalArgumentException("Illegal content type " +
type.getSimpleName());
+ }
+
+/*
public Content get(Id<Content> id)
{
Class<Content> type = id.getIdentifiableType();
@@ -220,12 +241,13 @@
gateIn.end();
}
}
+*/
+/*
private Object getPortletFrom(Id<Content> id) throws PortletInvokerException
{
PortletContext portletContext;
Object regitryItem;
-/*
if (!id.knowsComponent(GateInImpl.INVOKER_COMPONENT))
{
portletContext =
PortletContext.createPortletContext(id.getComponent(GateInImpl.APPLICATION_COMPONENT),
id.getComponent(GateInImpl.PORTLET_COMPONENT));
@@ -237,16 +259,16 @@
regitryItem = gateIn.getPortletInvoker().getPortlet(portletContext);
}
return regitryItem;
-*/
throw new UnsupportedOperationException("disabled for now");
}
+*/
private <T extends Content> Content newContentFrom(Id id, Object registryItem,
Class<T> wanted)
{
Object result;
if (Portlet.class.equals(wanted))
{
- result = new PortletImpl((Portlet.Id)id,
(org.gatein.pc.api.Portlet)registryItem, gateIn);
+ result = new PortletImpl((org.gatein.pc.api.Portlet)registryItem, gateIn);
}
else if (Gadget.class.equals(wanted))
{
@@ -296,6 +318,7 @@
}
}
+/*
public IterableIdentifiableCollection<Content> getAll()
{
try
@@ -320,7 +343,9 @@
gateIn.end();
}
}
+*/
+/*
public IterableIdentifiableCollection<Content> getLocalPortlets()
{
try
@@ -432,16 +457,5 @@
gateIn.end();
}
}
-
- public int size()
- {
- // todo: optimize
- return getAll().size();
- }
-
- 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-09-01
17:20:20 UTC (rev 7283)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/GadgetImpl.java 2011-09-01
17:22:57 UTC (rev 7284)
@@ -32,13 +32,15 @@
import java.net.URI;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public class GadgetImpl extends IdentifiableImpl<org.gatein.api.content.Content,
org.gatein.api.content.Content.Id> implements org.gatein.api.content.Gadget
+public class GadgetImpl extends IdentifiableImpl<org.gatein.api.content.Gadget,
org.gatein.api.content.Gadget.Id> implements org.gatein.api.content.Gadget
{
private final Gadget gadget;
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-09-01
17:20:20 UTC (rev 7283)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ManagedContentImpl.java 2011-09-01
17:22:57 UTC (rev 7284)
@@ -96,7 +96,7 @@
{
if (content == null)
{
- content = category.getRegistry().get(contentId);
+ content = category.getRegistry().getContent(contentId);
}
return content;
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-09-01
17:20:20 UTC (rev 7283)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/PortletImpl.java 2011-09-01
17:22:57 UTC (rev 7284)
@@ -24,16 +24,26 @@
import org.gatein.api.content.Content;
import org.gatein.api.content.Portlet;
-import org.gatein.api.id.Id;
import org.gatein.api.util.Type;
import org.gatein.portal.api.impl.GateInImpl;
+import org.gatein.portal.api.impl.IdentifiableImpl;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public class PortletImpl extends AbstractPortlet implements Portlet
+public class PortletImpl extends IdentifiableImpl<Portlet, Portlet.Id> implements
Portlet
{
- public PortletImpl(Portlet.Id id, org.gatein.pc.api.Portlet application, GateInImpl
gateIn)
+
+ /** . */
+ private final org.gatein.pc.api.Portlet portlet;
+
+ public PortletImpl(org.gatein.pc.api.Portlet portlet, GateInImpl gateIn)
{
- super(id, application, gateIn);
+ super(
+ new Id(portlet.getInfo().getApplicationName(), portlet.getInfo().getName()),
+ "todo?",
+ gateIn);
+
+ //
+ this.portlet = portlet;
}
public Type<Portlet> getType()
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-09-01
17:20:20 UTC (rev 7283)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/WSRPImpl.java 2011-09-01
17:22:57 UTC (rev 7284)
@@ -23,17 +23,26 @@
package org.gatein.portal.api.impl.content;
import org.gatein.api.content.Content;
+import org.gatein.api.content.Portlet;
import org.gatein.api.content.WSRP;
import org.gatein.api.id.Id;
import org.gatein.api.util.Type;
import org.gatein.portal.api.impl.GateInImpl;
+import org.gatein.portal.api.impl.IdentifiableImpl;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public class WSRPImpl extends AbstractPortlet implements WSRP
+public class WSRPImpl extends IdentifiableImpl<WSRP, WSRP.Id> implements WSRP
{
- public WSRPImpl(WSRP.Id id, org.gatein.pc.api.Portlet application, GateInImpl gateIn)
+
+ /** . */
+ private final org.gatein.pc.api.Portlet portlet;
+
+ public WSRPImpl(WSRP.Id id, org.gatein.pc.api.Portlet portlet, GateInImpl gateIn)
{
- super(id, application, gateIn);
+ super(id, "todo???", gateIn);
+
+ //
+ this.portlet = portlet;
}
public Type<WSRP> getType()
Modified:
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/content/ContentRegistryTestCase.java
===================================================================
---
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/content/ContentRegistryTestCase.java 2011-09-01
17:20:20 UTC (rev 7283)
+++
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/content/ContentRegistryTestCase.java 2011-09-01
17:22:57 UTC (rev 7284)
@@ -3,6 +3,7 @@
import org.exoplatform.portal.mop.SiteType;
import org.gatein.api.content.Category;
import org.gatein.api.content.ContentRegistry;
+import org.gatein.api.content.Portlet;
import org.gatein.portal.api.impl.AbstractAPITestCase;
import java.util.Collections;
@@ -32,4 +33,15 @@
Category.Id id = administration.getId();
assertEquals("administration", id.getName());
}
+
+ public void testGetContent()
+ {
+ createSite(SiteType.PORTAL, "classic");
+
+ //
+ ContentRegistry registry = gatein.getDefaultPortal().getContentRegistry();
+
+ //
+ registry.getContent(new Portlet.Id("foo", "bar"));
+ }
}