From do-not-reply at jboss.org Tue Aug 16 03:08:44 2011
Content-Type: multipart/mixed; boundary="===============5811495262000399305=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: gatein-commits at lists.jboss.org
Subject: [gatein-commits] gatein SVN: r7143 - in
portal/branches/api/component/api-impl/src:
test/java/org/gatein/portal/api/impl/portal and 1 other directory.
Date: Tue, 16 Aug 2011 03:08:43 -0400
Message-ID: <201108160708.p7G78hKR005272@svn01.web.mwc.hst.phx2.redhat.com>
--===============5811495262000399305==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: julien_viet
Date: 2011-08-16 03:08:43 -0400 (Tue, 16 Aug 2011)
New Revision: 7143
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/a=
pi/impl/portal/NavigationImpl.java
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/a=
pi/impl/portal/NavigationTestCase.java
Log:
more work about API
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/p=
ortal/api/impl/portal/NavigationImpl.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/=
api/impl/portal/NavigationImpl.java 2011-08-16 06:45:32 UTC (rev 7142)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/=
api/impl/portal/NavigationImpl.java 2011-08-16 07:08:43 UTC (rev 7143)
@@ -37,25 +37,22 @@
import org.exoplatform.web.url.navigation.NavigationResource;
import org.exoplatform.web.url.navigation.NodeURL;
import org.gatein.api.GateIn;
-import org.gatein.api.id.Identifiable;
import org.gatein.api.portal.Navigation;
import org.gatein.api.portal.Page;
import org.gatein.api.portal.Site;
-import org.gatein.api.util.IterableIdentifiableCollection;
-import org.gatein.common.NotYetImplemented;
import org.gatein.common.text.EntityEncoder;
import org.gatein.common.util.EmptyResourceBundle;
import org.gatein.portal.api.impl.GateInImpl;
-import org.gatein.portal.api.impl.util.AdaptedIterableIdentifiableCollecti=
on;
=
import java.net.URI;
import java.net.URISyntaxException;
+import java.util.Collection;
import java.util.Iterator;
import java.util.Locale;
import java.util.ResourceBundle;
=
/** @author Chris Laprun */
-public class NavigationImpl implements Navigation, Identifiable
+public class NavigationImpl implements Navigation
{
private final NodeContext context;
private SiteImpl site;
@@ -83,7 +80,7 @@
s.append("-target->").append(pageRef);
}
=
- if (size() !=3D 0)
+ if (context.getNodeCount() !=3D 0)
{
loadChildrenIfNeeded();
s.append("\n|");
@@ -98,11 +95,6 @@
return s.toString();
}
=
- public NodeContext getContext()
- {
- return context;
- }
-
public URI getURI()
{
if (uri !=3D null)
@@ -131,7 +123,6 @@
}
}
=
-
private StringBuilder buildURI()
{
NavigationImpl parent =3D context.getParentNode();
@@ -150,7 +141,6 @@
}
}
=
-
public Page getTargetPage()
{
String pageRef =3D context.getState().getPageRef();
@@ -195,22 +185,10 @@
return site;
}
=
- public IterableIdentifiableCollection getAll()
+ public Collection extends Navigation> getChildren()
{
loadChildrenIfNeeded();
-
- return new AdaptedIterableIdentifiableCollection(size(), context.iterator())
- {
- public Navigation adapt(NavigationImpl old)
- {
- return old;
- }
-
- public boolean contains(org.gatein.api.id.Id id)
- {
- return NavigationImpl.this.contains(id);
- }
- };
+ return context.getNodes();
}
=
private void loadChildrenIfNeeded()
@@ -230,64 +208,19 @@
}
}
=
- public int size()
+ public Navigation getChild(String name)
{
- return context.getNodeSize();
- }
-
- public boolean contains(String key)
- {
- return contains(getIdForChild(key));
- }
-
- public boolean contains(org.gatein.api.id.Id navigationId)
- {
- loadChildrenIfNeeded();
-
- return getChild(navigationId) !=3D null;
- }
-
- private NodeContext getChild(org.gatein.api.id.Id navigationId)
- {
-// return context.get(navigationId.getComponent(GateInImpl.NAVIGATION=
_COMPONENT));
- throw new UnsupportedOperationException();
- }
-
- public Navigation createAndAdd(String key)
- {
- return createAndAdd(getIdForChild(key));
- }
-
- public Navigation createAndAdd(org.gatein.api.id.Id navigat=
ionId)
- {
- throw new NotYetImplemented(); // TODO
- }
-
- public Navigation get(String key)
- {
- return context.getNode(key);
- }
-
- public Navigation get(org.gatein.api.id.Id navigationId)
- {
- if (navigationId =3D=3D null)
+ if (name =3D=3D null)
{
return null;
}
else
{
loadChildrenIfNeeded();
- final NodeContext child =3D getChild(navigationId=
);
- return child !=3D null ? child.getNode() : null;
+ return context.getNode(name);
}
}
=
- public Navigation.Id getIdForChild(String key)
- {
-// return site.getIdForChild(key);
- throw new UnsupportedOperationException();
- }
-
public Navigation.Id getId()
{
if (id =3D=3D null)
@@ -344,7 +277,6 @@
return RequestContext.getCurrentInstance().getLocale();
}
=
-
public ResourceBundle getBundle()
{
if (bundle =3D=3D null)
Modified: portal/branches/api/component/api-impl/src/test/java/org/gatein/p=
ortal/api/impl/portal/NavigationTestCase.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/=
api/impl/portal/NavigationTestCase.java 2011-08-16 06:45:32 UTC (rev 7142)
+++ portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/=
api/impl/portal/NavigationTestCase.java 2011-08-16 07:08:43 UTC (rev 7143)
@@ -99,7 +99,7 @@
Navigation rootNav =3D site.getNavigation();
assertSame(site, rootNav.getSite());
assertNotNull(rootNav);
- Iterator i =3D rootNav.getAll().iterator();
+ Iterator extends Navigation> i =3D rootNav.getChildren().iterator(=
);
assertFalse(i.hasNext());
}
=
@@ -111,18 +111,18 @@
//
Site site =3D gatein.getPortal(new Site.Id(Site.PORTAL, "classic"));
Navigation rootNav =3D site.getNavigation();
- Iterator i =3D rootNav.getAll().iterator();
+ Iterator extends Navigation> i =3D rootNav.getChildren().iterator(=
);
assertTrue(i.hasNext());
Navigation homeNav =3D i.next();
assertSame(site, homeNav.getSite());
assertEquals("home", homeNav.getName());
- assertSame(homeNav, rootNav.get("home"));
+ assertSame(homeNav, rootNav.getChild("home"));
assertFalse(i.hasNext());
}
=
public void testPage()
{
- NodeContext home =3D root.add(null, "home");
+ root.add(null, "home");
navService.saveNode(root, null);
=
//
@@ -133,13 +133,13 @@
=
//
Navigation rootNav =3D site.getNavigation();
- Navigation homeNav =3D rootNav.get("home");
+ Navigation homeNav =3D rootNav.getChild("home");
assertNull(homeNav.getTargetPage());
homeNav.setTargetPage(homePage);
assertSame(homePage, homeNav.getTargetPage());
=
//
- homeNav.setTargetPage((Page)null);
+ homeNav.setTargetPage(null);
assertNull(null, homeNav.getTargetPage());
}
}
--===============5811495262000399305==--