Author: chris.laprun(a)jboss.com
Date: 2011-07-28 15:52:33 -0400 (Thu, 28 Jul 2011)
New Revision: 6944
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java
Log:
- Implemented getURI.
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-07-28
19:09:49 UTC (rev 6943)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java 2011-07-28
19:52:33 UTC (rev 6944)
@@ -41,6 +41,8 @@
import org.gatein.portal.api.impl.GateInImpl;
import org.gatein.portal.api.impl.util.AdaptedIterableIdentifiableCollection;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.Iterator;
import java.util.regex.Pattern;
@@ -51,6 +53,7 @@
private Id<? extends Site> site;
private Id<Navigation> id;
private final GateInImpl gateIn;
+ private URI uri;
private final static Context CONTEXT =
GenericContext.builder().requiredComponent("navigation", Navigation.class,
Pattern.compile("[a-z0-9]+")).build();
@@ -65,7 +68,7 @@
public String toString()
{
String pageRef = context.getState().getPageRef();
- StringBuilder s = new StringBuilder("Navigation(a)").append(getId());
+ StringBuilder s = new
StringBuilder("Navigation(a)").append(getId()).append(" URI:
").append(getURI());
if (pageRef != null)
{
@@ -92,6 +95,46 @@
return context;
}
+ public URI getURI()
+ {
+ if (uri != null)
+ {
+ return uri;
+ }
+ else
+ {
+ try
+ {
+ uri = new URI(buildURI().toString());
+ }
+ catch (URISyntaxException e)
+ {
+ throw new RuntimeException(e);
+ }
+ return uri;
+ }
+ }
+
+
+ private StringBuilder buildURI()
+ {
+ NavigationImpl parent = context.getParentNode();
+ if (parent != null)
+ {
+ StringBuilder builder = parent.buildURI();
+ if (builder.length() > 0)
+ {
+ builder.append('/');
+ }
+ return builder.append(context.getName());
+ }
+ else
+ {
+ return new StringBuilder();
+ }
+ }
+
+
public Page getTargetPage()
{
String pageRef = context.getState().getPageRef();
Show replies by date