portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r326411 - in /portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed: om/folder/impl/FolderImpl.java page/impl/DatabasePageManager.java
Date Wed, 19 Oct 2005 06:21:56 GMT
Author: rwatler
Date: Tue Oct 18 23:21:53 2005
New Revision: 326411

URL: http://svn.apache.org/viewcvs?rev=326411&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/page/impl/DatabasePageManager.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=326411&r1=326410&r2=326411&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 23:21:53 2005
@@ -24,6 +24,7 @@
 import org.apache.jetspeed.om.page.Link;
 import org.apache.jetspeed.om.page.Page;
 import org.apache.jetspeed.om.page.PageSecurity;
+import org.apache.jetspeed.om.page.impl.PageImpl;
 import org.apache.jetspeed.page.PageNotFoundException;
 import org.apache.jetspeed.page.document.DocumentException;
 import org.apache.jetspeed.page.document.DocumentNotFoundException;
@@ -47,6 +48,88 @@
     private NodeSet allNodeSet;
     private NodeSet foldersNodeSet;
     private NodeSet pagesNodeSet;
+
+    /**
+     * addFolder
+     *
+     * Adds a folder to the persistent collection and resets cached node sets.
+     *
+     * @param folder new folder impl
+     */
+    public void addFolder(FolderImpl newFolder)
+    {
+        // add to folders collection
+        if (folders == null)
+        {
+            folders = new ArrayList();
+        }
+        folders.add(newFolder);
+
+        // reset cached node sets
+        allNodeSet = null;
+        foldersNodeSet = null;
+    }
+    
+    /**
+     * removeFolder
+     *
+     * Removes a folder to the persistent collection and resets cached node sets.
+     *
+     * @param folder remove folder impl
+     */
+    public void removeFolder(FolderImpl removeFolder)
+    {
+        // remove from folders collection
+        if (folders != null)
+        {
+            folders.remove(removeFolder);
+        }
+
+        // reset cached node sets
+        allNodeSet = null;
+        foldersNodeSet = null;
+    }
+
+    /**
+     * addPage
+     *
+     * Adds a page to the persistent collection and resets cached node sets.
+     *
+     * @param page new page impl
+     */
+    public void addPage(PageImpl newPage)
+    {
+        // add to pages collection
+        if (pages == null)
+        {
+            pages = new ArrayList();
+        }
+        pages.add(newPage);
+
+        // reset cached node sets
+        allNodeSet = null;
+        pagesNodeSet = null;
+    }
+    
+    /**
+     * removePage
+     *
+     * Removes a page to the persistent collection and resets cached node sets.
+     *
+     * @param page remove page impl
+     */
+    public void removePage(PageImpl removePage)
+    {
+        // remove from pages collection
+        if (pages != null)
+        {
+            pages.remove(removePage);
+        }
+
+        // reset cached node sets
+        allNodeSet = null;
+        pagesNodeSet = null;
+    }
 
     /* (non-Javadoc)
      * @see org.apache.jetspeed.om.folder.Folder#getDefaultPage(boolean)

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManager.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManager.java?rev=326411&r1=326410&r2=326411&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManager.java
(original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManager.java
Tue Oct 18 23:21:53 2005
@@ -265,7 +265,39 @@
             PageNotUpdatedException
     {
         System.out.println("storing page " + page.getPath());
-        getPersistenceBrokerTemplate().store(page);
+
+        // look up and set parent folder if necessary
+        if (page.getParent() == null)
+        {
+            // access folder by path
+            String pagePath = page.getPath();
+            String parentPath = pagePath.substring(0, pagePath.lastIndexOf(Folder.PATH_SEPARATOR));
+            if (parentPath.length() == 0)
+            {
+                parentPath = Folder.PATH_SEPARATOR;
+            }
+            FolderImpl parent = null;
+            try
+            {
+                parent = (FolderImpl)getFolder(parentPath);
+            }
+            catch (FolderNotFoundException fnfe)
+            {
+                throw new PageNotUpdatedException("Missing parent folder: " + parentPath);
+            }
+
+            // update page and parent folder
+            parent.addPage((PageImpl)page);
+            page.setParent(parent);
+            getPersistenceBrokerTemplate().store(parent);
+            getPersistenceBrokerTemplate().store(page);
+        }
+        else
+        {
+            // update page
+            getPersistenceBrokerTemplate().store(page);
+        }
+
         System.out.println("**** stored page " + page.getPath());        
     }
 
@@ -276,7 +308,22 @@
             PageNotRemovedException
     {
         System.out.println("deleting page " + page.getPath());
-        getPersistenceBrokerTemplate().delete(page);
+
+        // look up and update parent folder if necessary
+        if (page.getParent() != null)
+        {
+            // delete page and update parent folder
+            FolderImpl parent = (FolderImpl)page.getParent();
+            parent.removePage((PageImpl)page);
+            getPersistenceBrokerTemplate().store(parent);
+            getPersistenceBrokerTemplate().delete(page);
+        }
+        else
+        {
+            // delete page
+            getPersistenceBrokerTemplate().delete(page);
+        }
+
         System.out.println("**** deleted page " + page.getPath());        
     }
 
@@ -287,7 +334,39 @@
             FolderNotUpdatedException
     {
         System.out.println("storing folder " + folder.getPath());
-        getPersistenceBrokerTemplate().store(folder);
+
+        // look up and set parent folder if necessary
+        if ((folder.getParent() == null) && !folder.getPath().equals(Folder.PATH_SEPARATOR))
+        {
+            // access folder by path
+            String folderPath = folder.getPath();
+            String parentPath = folderPath.substring(0, folderPath.lastIndexOf(Folder.PATH_SEPARATOR));
+            if (parentPath.length() == 0)
+            {
+                parentPath = Folder.PATH_SEPARATOR;
+            }
+            FolderImpl parent = null;
+            try
+            {
+                parent = (FolderImpl)getFolder(parentPath);
+            }
+            catch (FolderNotFoundException fnfe)
+            {
+                throw new FolderNotUpdatedException("Missing parent folder: " + parentPath);
+            }
+
+            // update folder and parent folder
+            parent.addFolder((FolderImpl)folder);
+            folder.setParent(parent);
+            getPersistenceBrokerTemplate().store(parent);
+            getPersistenceBrokerTemplate().store(folder);
+        }
+        else
+        {
+            // update folder
+            getPersistenceBrokerTemplate().store(folder);
+        }
+
         System.out.println("**** stored folder " + folder.getPath());        
     }
 
@@ -298,7 +377,22 @@
             FolderNotRemovedException
     {
         System.out.println("deleting folder " + folder.getPath());
-        getPersistenceBrokerTemplate().delete(folder);
+
+        // look up and update parent folder if necessary
+        if (folder.getParent() != null)
+        {
+            // delete folder and update parent folder
+            FolderImpl parent = (FolderImpl)folder.getParent();
+            parent.removeFolder((FolderImpl)folder);
+            getPersistenceBrokerTemplate().store(parent);
+            getPersistenceBrokerTemplate().delete(folder);
+        }
+        else
+        {
+            // delete folder
+            getPersistenceBrokerTemplate().delete(folder);
+        }
+
         System.out.println("**** deleted folder " + folder.getPath());        
     }
 



---------------------------------------------------------------------
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