Author: chris.laprun(a)jboss.com
Date: 2011-07-14 10:52:00 -0400 (Thu, 14 Jul 2011)
New Revision: 6871
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/PortalImpl.java
Log:
- Encapsulated calls to RequestLifeCycle so that it can be used more easily by other
implementation classes.
- Started get(Id) implementation.
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-14
11:13:47 UTC (rev 6870)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java 2011-07-14
14:52:00 UTC (rev 6871)
@@ -71,7 +71,7 @@
{
try
{
- RequestLifeCycle.begin(container);
+ begin();
final List<PortalData> portals = dataStorage.find(PORTALS).getAll();
return new PortalIterableResult(portals);
@@ -82,10 +82,15 @@
}
finally
{
- RequestLifeCycle.end();
+ end();
}
}
+ void end()
+ {
+ RequestLifeCycle.end();
+ }
+
public Portal getPortal(Id<Portal> portalId)
{
PortalData portalData = getPortalDataFor(portalId);
@@ -129,7 +134,22 @@
public <T extends Identifiable> T get(Id<T> id)
{
- return null; //To change body of implemented methods use File | Settings | File
Templates.
+ Class<T> type = id.getIdentifiableType();
+
+ Object result;
+
+ // todo: fix the use canonical names to avoid classloader issues?
+ String canonicalName = type.getCanonicalName();
+ if (Portal.class.getCanonicalName().equals(canonicalName))
+ {
+ result = getPortal((Id<Portal>)id);
+ }
+ else
+ {
+ throw new UnsupportedOperationException("Id<" +
type.getSimpleName() + "> not yet supported");
+ }
+
+ return type.cast(result);
}
public <T extends Site> Site getSite(Id<Site> siteId, Site.Type<T>
type)
@@ -203,7 +223,7 @@
ParameterValidation.throwIllegalArgExceptionIfNull(portalId, "Portal
Id");
try
{
- RequestLifeCycle.begin(container);
+ begin();
return dataStorage.getPortalConfig(PortalKey.create(portalId.toString()));
}
@@ -213,10 +233,15 @@
}
finally
{
- RequestLifeCycle.end();
+ end();
}
}
+ void begin()
+ {
+ RequestLifeCycle.begin(container);
+ }
+
private static class PortalIterator implements Iterator<Portal>
{
private int current;
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-14
11:13:47 UTC (rev 6870)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/PortalImpl.java 2011-07-14
14:52:00 UTC (rev 6871)
@@ -58,12 +58,21 @@
public Navigation getNavigation()
{
NavigationService service = getGateInImpl().getNavigationService();
- NavigationContext navigation = service.loadNavigation(SiteKey.portal(getName()));
- //
- NodeContext<?> node = service.loadNode(NodeModel.SELF_MODEL, navigation,
Scope.SINGLE, null).getNode();
+ try
+ {
+ getGateInImpl().begin();
+ NavigationContext navigation =
service.loadNavigation(SiteKey.portal(getName()));
- return new NavigationImpl(node, getGateInImpl());
+ //
+ NodeContext<?> node = service.loadNode(NodeModel.SELF_MODEL, navigation,
Scope.SINGLE, null).getNode();
+
+ return new NavigationImpl(node, getGateInImpl());
+ }
+ finally
+ {
+ getGateInImpl().end();
+ }
}
public Type getType()
Show replies by date