Author: julien_viet
Date: 2011-08-15 17:29:37 -0400 (Mon, 15 Aug 2011)
New Revision: 7139
Modified:
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/portal/NavigationImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java
Log:
some work on API
Modified:
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 2011-08-15
20:55:43 UTC (rev 7138)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/IdentifiableImpl.java 2011-08-15
21:29:37 UTC (rev 7139)
@@ -29,10 +29,10 @@
/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
public class IdentifiableImpl<T extends Identifiable<T>, I extends
Id<T>> implements Identifiable<T>
{
- private final I id;
- private final String name;
- private final String displayName;
- private final GateInImpl gateIn;
+ protected final I id;
+ protected final String name;
+ protected final String displayName;
+ protected final GateInImpl gateIn;
public IdentifiableImpl(I id, String name, GateInImpl gateIn)
{
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java 2011-08-15
20:55:43 UTC (rev 7138)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java 2011-08-15
21:29:37 UTC (rev 7139)
@@ -59,17 +59,17 @@
public class NavigationImpl implements Navigation, Identifiable<Navigation>
{
private final NodeContext<NavigationImpl> context;
- private Site.Id site;
+ private Site site;
private Navigation.Id id;
private final GateInImpl gateIn;
private URI uri;
private String displayName;
private ResourceBundle bundle;
- public NavigationImpl(Site.Id siteId, NodeContext<NavigationImpl> context,
GateInImpl gateIn)
+ public NavigationImpl(Site site, NodeContext<NavigationImpl> context, GateInImpl
gateIn)
{
this.context = context;
- this.site = siteId;
+ this.site = site;
this.gateIn = gateIn;
}
@@ -115,8 +115,8 @@
try
{
RequestContext requestContext = RequestContext.getCurrentInstance();
- SiteType siteType = SiteType.valueOf(site.getComponents()[0].toUpperCase());
- String siteName = site.getComponents()[1];
+ SiteType siteType =
SiteType.valueOf(site.getId().getComponents()[0].toUpperCase());
+ String siteName = site.getId().getComponents()[1];
NavigationResource navResource = new NavigationResource(siteType, siteName,
buildURI().toString());
NodeURL nodeURL = requestContext.createURL(NodeURL.TYPE, navResource);
@@ -157,7 +157,7 @@
String pageRef = context.getState().getPageRef();
if (pageRef != null)
{
- return gateIn.get(gateIn.pageId(site, pageRef));
+ return gateIn.get(gateIn.pageId(site.getId(), pageRef));
}
else
{
@@ -177,7 +177,7 @@
public Site getSite()
{
- return getGateIn().get(site);
+ return site;
}
public IterableIdentifiableCollection<Navigation> getAll()
@@ -339,8 +339,8 @@
Locale locale = getUserLocale();
bundle = rbMgr.getNavigationResourceBundle(
locale.getLanguage(),
- site.getComponent(GateInImpl.SITE_TYPE_COMPONENT),
- site.getComponent(GateInImpl.SITE_NAME_COMPONENT));
+ site.getId().getComponent(GateInImpl.SITE_TYPE_COMPONENT),
+ site.getId().getComponent(GateInImpl.SITE_NAME_COMPONENT));
if (bundle == null)
{
@@ -358,12 +358,12 @@
static class NavigationNodeModel implements NodeModel<NavigationImpl>
{
- private final Site.Id siteId;
+ private final Site site;
private final GateInImpl gateIn;
- NavigationNodeModel(Site.Id siteId, GateInImpl gateIn)
+ NavigationNodeModel(Site siteId, GateInImpl gateIn)
{
- this.siteId = siteId;
+ this.site = siteId;
this.gateIn = gateIn;
}
@@ -374,7 +374,7 @@
public NavigationImpl create(NodeContext<NavigationImpl> context)
{
- return new NavigationImpl(siteId, context, gateIn);
+ return new NavigationImpl(site, context, gateIn);
}
}
}
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java 2011-08-15
20:55:43 UTC (rev 7138)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java 2011-08-15
21:29:37 UTC (rev 7139)
@@ -85,7 +85,7 @@
if (navigation != null)
{
- NodeModel<NavigationImpl> nodeModel = new
NavigationImpl.NavigationNodeModel(getId(), gateIn);
+ NodeModel<NavigationImpl> nodeModel = new
NavigationImpl.NavigationNodeModel(this, gateIn);
return service.loadNode(nodeModel, navigation, Scope.CHILDREN,
null).getNode();
}
Modified:
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java
===================================================================
---
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java 2011-08-15
20:55:43 UTC (rev 7138)
+++
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/NavigationTestCase.java 2011-08-15
21:29:37 UTC (rev 7139)
@@ -92,6 +92,7 @@
//
Navigation navigation = site.getNavigation();
+ assertSame(site, navigation.getSite());
assertNotNull(navigation);
Iterator<Navigation> i = navigation.getAll().iterator();
assertFalse(i.hasNext());
@@ -104,17 +105,11 @@
//
Site site = gatein.getPortal(new Site.Id(Site.PORTAL, "classic"));
- assertNotNull(site);
- Site.Id id = site.getId();
- assertEquals(Site.PORTAL, id.getType());
- assertEquals("classic", id.getName());
-
- //
Navigation navigation = site.getNavigation();
- assertNotNull(navigation);
Iterator<Navigation> i = navigation.getAll().iterator();
assertTrue(i.hasNext());
Navigation home = i.next();
+ assertSame(site, home.getSite());
assertEquals("home", home.getName());
assertFalse(i.hasNext());
}