portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r326394 - in /portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed: om/folder/impl/FolderImpl.java om/page/impl/FragmentImpl.java om/page/impl/PageImpl.java page/document/impl/NodeSetImpl.java
Date Wed, 19 Oct 2005 05:07:24 GMT
Author: rwatler
Date: Tue Oct 18 22:07:20 2005
New Revision: 326394

URL: http://svn.apache.org/viewcvs?rev=326394&view=rev
Log:
checkpoint DB PageManager om implementation

Modified:
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/folder/impl/FolderImpl.java
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentImpl.java
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageImpl.java
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/document/impl/NodeSetImpl.java

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/folder/impl/FolderImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/folder/impl/FolderImpl.java?rev=326394&r1=326393&r2=326394&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/folder/impl/FolderImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/folder/impl/FolderImpl.java
Tue Oct 18 22:07:20 2005
@@ -15,6 +15,7 @@
  */
 package org.apache.jetspeed.om.folder.impl;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.jetspeed.om.folder.Folder;
@@ -30,6 +31,7 @@
 import org.apache.jetspeed.page.document.NodeException;
 import org.apache.jetspeed.page.document.NodeSet;
 import org.apache.jetspeed.page.document.impl.NodeImpl;
+import org.apache.jetspeed.page.document.impl.NodeSetImpl;
 
 /**
  * FolderImpl
@@ -42,6 +44,10 @@
     private List folders;
     private List pages;
 
+    private NodeSet allNodeSet;
+    private NodeSet foldersNodeSet;
+    private NodeSet pagesNodeSet;
+
     /* (non-Javadoc)
      * @see org.apache.jetspeed.om.folder.Folder#getDefaultPage(boolean)
      */
@@ -79,7 +85,18 @@
      */
     public NodeSet getFolders() throws FolderNotFoundException, DocumentException
     {
-        return null; // NYI
+        if (foldersNodeSet != null)
+        {
+            if (folders != null)
+            {
+                foldersNodeSet = new NodeSetImpl(folders);
+            }
+            else
+            {
+                foldersNodeSet = new NodeSetImpl();
+            }
+        }
+        return foldersNodeSet;
     }
     
     /* (non-Javadoc)
@@ -87,7 +104,12 @@
      */
     public Folder getFolder(String name) throws FolderNotFoundException, DocumentException
     {
-        return null; // NYI
+        Folder folder = (Folder)getFolders().get(name);
+        if (folder == null)
+        {
+            throw new FolderNotFoundException("Folder not found: " + name);
+        }
+        return folder;
     }
     
     /* (non-Javadoc)
@@ -95,7 +117,18 @@
      */
     public NodeSet getPages() throws NodeException
     {
-        return null; // NYI
+        if (pagesNodeSet != null)
+        {
+            if (pages != null)
+            {
+                pagesNodeSet = new NodeSetImpl(pages);
+            }
+            else
+            {
+                pagesNodeSet = new NodeSetImpl();
+            }
+        }
+        return pagesNodeSet;
     }
     
     /* (non-Javadoc)
@@ -103,7 +136,12 @@
      */
     public Page getPage(String name) throws PageNotFoundException, NodeException
     {
-        return null; // NYI
+        Page page = (Page)getPages().get(name);
+        if (page == null)
+        {
+            throw new PageNotFoundException("Page not found: " + name);
+        }
+        return page;
     }
     
     /* (non-Javadoc)
@@ -135,7 +173,27 @@
      */
     public NodeSet getAll() throws FolderNotFoundException, DocumentException
     {
-        return null; // NYI
+        if (allNodeSet == null)
+        {
+            List all = new ArrayList();
+            if (folders != null)
+            {
+                all.addAll(folders);
+            }
+            if (pages != null)
+            {
+                all.addAll(pages);
+            }
+            if (!all.isEmpty())
+            {
+                allNodeSet = new NodeSetImpl(all);
+            }
+            else
+            {
+                allNodeSet = new NodeSetImpl();
+            }
+        }
+        return allNodeSet;
     }
     
     /* (non-Javadoc)

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentImpl.java?rev=326394&r1=326393&r2=326394&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentImpl.java
Tue Oct 18 22:07:20 2005
@@ -15,6 +15,7 @@
  */
 package org.apache.jetspeed.om.page.impl;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.jetspeed.om.page.Fragment;
@@ -110,7 +111,12 @@
      */
     public List getFragments()
     {
-        return null; // NYI
+        // fragments collection must be defined
+        if (fragments == null)
+        {
+            fragments = new ArrayList();
+        }
+        return fragments;
     }
     
     /* (non-Javadoc)

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageImpl.java?rev=326394&r1=326393&r2=326394&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageImpl.java
Tue Oct 18 22:07:20 2005
@@ -15,7 +15,10 @@
  */
 package org.apache.jetspeed.om.page.impl;
 
+import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Stack;
 
 import org.apache.jetspeed.om.page.Defaults;
 import org.apache.jetspeed.om.page.Fragment;
@@ -79,7 +82,12 @@
      */
     public Fragment getRootFragment()
     {
-        return null; //NYI
+        // get singleton fragment
+        if ((fragments != null) && !fragments.isEmpty())
+        {
+            return (Fragment)fragments.get(0);
+        }
+        return null;
     }
     
     /* (non-Javadoc)
@@ -87,7 +95,26 @@
      */
     public void setRootFragment(Fragment fragment)
     {
-        // NYI
+        // delete existing fragments if required
+        if ((fragments != null) && !fragments.isEmpty())
+        {
+            Iterator removeIter = fragments.iterator();
+            while (removeIter.hasNext())
+            {
+                removeIter.next();
+                removeIter.remove();
+            }
+        }
+
+        // add new singleton fragment
+        if (fragment != null)
+        {
+            if (fragments == null)
+            {
+                fragments = new ArrayList(1);
+            }
+            fragments.add(fragment);
+        }
     }
 
     /* (non-Javadoc)
@@ -95,7 +122,34 @@
      */
     public Fragment getFragmentById(String id)
     {
-        return null; // NYI
+        // search for fragment recursively from
+        // root singleton fragment using a local stack
+        Stack stack = new Stack();
+        Fragment fragment = getRootFragment();
+        while ((fragment != null) && !fragment.getId().equals(id))
+        {
+            // push any fragment fragments onto the local stack
+            List fragments = fragment.getFragments();
+            if (!fragments.isEmpty())
+            {
+                Iterator pushIter = fragments.iterator();
+                while (pushIter.hasNext())
+                {
+                    stack.push(pushIter.next());
+                }
+            }
+
+            // pop next fragment from local stack if available
+            if (stack.size() > 0)
+            {
+                fragment = (Fragment) stack.pop();
+            }
+            else
+            {
+                fragment = null;
+            }
+        }
+        return fragment;
     }
 
     /* (non-Javadoc)

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/document/impl/NodeSetImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/document/impl/NodeSetImpl.java?rev=326394&r1=326393&r2=326394&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/document/impl/NodeSetImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/document/impl/NodeSetImpl.java
Tue Oct 18 22:07:20 2005
@@ -15,7 +15,11 @@
  */
 package org.apache.jetspeed.page.document.impl;
 
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
 import org.apache.jetspeed.page.document.Node;
 import org.apache.jetspeed.page.document.NodeSet;
@@ -28,12 +32,43 @@
  */
 public class NodeSetImpl implements NodeSet
 {
+    private List nodes;
+    private Map nodesByName;
+
+    public NodeSetImpl()
+    {
+    }
+    public NodeSetImpl(List nodes)
+    {
+        this.nodes = new ArrayList(nodes.size());
+        this.nodesByName = new HashMap((nodes.size() / 2) + 1);
+        Iterator addIter = nodes.iterator();
+        while (addIter.hasNext())
+        {
+            Node node = (Node)addIter.next();
+            this.nodes.add(node);
+            if (!this.nodesByName.containsKey(node.getName()))
+            {
+                this.nodesByName.put(node.getName(), node);
+            }
+        }
+    }
+
     /* (non-Javadoc)
      * @see org.apache.jetspeed.page.document.NodeSet#add(org.apache.jetspeed.page.document.Node)
      */
     public void add(Node node)
     {
-        // NYI
+        if (nodes != null)
+        {
+            nodes = new ArrayList(8);
+            nodesByName = new HashMap(5);
+        }
+        nodes.add(node);
+        if (!nodesByName.containsKey(node.getName()))
+        {
+            nodesByName.put(node.getName(), node);
+        }
     }
     
     /* (non-Javadoc)
@@ -41,7 +76,11 @@
      */
     public Node get(String name)
     {
-        return null; // NYI
+        if (nodesByName != null)
+        {
+            return (Node)nodesByName.get(name);
+        }
+        return null;
     }
     
     /* (non-Javadoc)
@@ -49,7 +88,11 @@
      */
     public Iterator iterator()
     {
-        return null; // NYI
+        if (nodes != null)
+        {
+            return nodes.iterator();
+        }
+        return null;
     }
     
     /* (non-Javadoc)
@@ -81,7 +124,11 @@
      */
     public int size()
     {
-        return -1; // NYI
+        if (nodes != null)
+        {
+            return nodes.size();
+        }
+        return 0;
     }
     
     /* (non-Javadoc)
@@ -89,7 +136,11 @@
      */
     public boolean contains(Node node)
     {
-        return false; // NYI
+        if (nodes != null)
+        {
+            return nodes.contains(node);
+        }
+        return false;
     }
     
     /* (non-Javadoc)
@@ -97,6 +148,10 @@
      */
     public boolean isEmpty()
     {
-        return true; // NYI
+        if (nodes != null)
+        {
+            return nodes.isEmpty();
+        }
+        return true;
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message