Author: hoang_to
Date: 2010-05-14 00:31:14 -0400 (Fri, 14 May 2010)
New Revision: 3088
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/PageNavigationUtils.java
Log:
GTNPORTAL-1110: Update java code
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/PageNavigationUtils.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/PageNavigationUtils.java 2010-05-14
04:07:53 UTC (rev 3087)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/PageNavigationUtils.java 2010-05-14
04:31:14 UTC (rev 3088)
@@ -138,6 +138,7 @@
return null;
}
+ //TODO: Split the uri and use optimzed method
<code>searchParentChildPairByPath</code>
public static ParentChildPair searchParentChildPairUnderNode(PageNode rootNode, String
uri)
{
if(uri.equals(rootNode.getUri()))
@@ -167,6 +168,51 @@
return null;
}
+ /**
+ * Search a pair of page node (specified by the path) and its parent
+ *
+ * @param rootNode
+ * @param path
+ * @return
+ */
+ public static ParentChildPair searchParentChildPairByPath(PageNode rootNode, String[]
path)
+ {
+ if(path.length == 0)
+ {
+ throw new IllegalArgumentException("The input path must have unzero
length");
+ }
+
+ if(!rootNode.getName().equals(path[0]))
+ {
+ return null;
+ }
+ else
+ {
+ if(path.length == 1)
+ {
+ return new ParentChildPair(null, rootNode);
+ }
+
+ PageNode tempNode = rootNode;
+
+ PageNode parentNode = null;
+ PageNode childNode = null;
+ for(int i = 1; i< path.length; i++)
+ {
+ childNode = tempNode.getChild(path[i]);
+ if(childNode == null)
+ {
+ return null;
+ }
+ else
+ {
+ parentNode = tempNode;
+ }
+ }
+
+ return new ParentChildPair(parentNode, childNode);
+ }
+ }
public static PageNode searchPageNodeByUri(PageNode node, String uri)
{
Show replies by date