portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r345864 - in /portals/jetspeed-2/trunk: components/page-manager/src/java/org/apache/jetspeed/page/ components/page-manager/src/java/org/apache/jetspeed/page/impl/ jetspeed-api/src/java/org/apache/jetspeed/page/
Date Mon, 21 Nov 2005 07:45:56 GMT
Author: taylor
Date: Sun Nov 20 23:45:54 2005
New Revision: 345864

URL: http://svn.apache.org/viewcvs?rev=345864&view=rev
Log:
deepCopy implemented for PageManagers

Modified:
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManager.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/page/PageManager.java

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java?rev=345864&r1=345863&r2=345864&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java
(original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java
Sun Nov 20 23:45:54 2005
@@ -29,6 +29,7 @@
 import org.apache.jetspeed.om.common.SecurityConstraint;
 import org.apache.jetspeed.om.common.SecurityConstraints;
 import org.apache.jetspeed.om.folder.Folder;
+import org.apache.jetspeed.om.folder.FolderNotFoundException;
 import org.apache.jetspeed.om.folder.MenuDefinition;
 import org.apache.jetspeed.om.folder.MenuExcludeDefinition;
 import org.apache.jetspeed.om.folder.MenuIncludeDefinition;
@@ -786,6 +787,88 @@
         }
         
         return copy;
+    }
+
+    /**
+     * Deep copy a folder
+     *  
+     * @param source source folder
+     * @param dest destination folder
+     */
+    public void deepCopyFolder(Folder srcFolder, String destinationPath)
+    throws JetspeedException, PageNotUpdatedException
+    {
+        boolean found = true;
+        try
+        {
+            Folder check = this.getFolder(destinationPath);
+        }
+        catch (FolderNotFoundException e)
+        {
+            found = false;
+        }
+        if (found)
+        {
+            throw new JetspeedException("Destination already exists");
+        }
+        Folder dstFolder = this.copyFolder(srcFolder, destinationPath);
+        this.updateFolder(dstFolder);
+        
+        Iterator pages = srcFolder.getPages().iterator();
+        while (pages.hasNext())
+        {
+            Page srcPage = (Page)pages.next();
+            Page dstPage = this.copyPage(srcPage, srcPage.getPath());
+            this.updatePage(dstPage);
+        }
+     
+        // TODO: LINKS
+        
+        Iterator folders = srcFolder.getFolders().iterator();
+        while (folders.hasNext())
+        {
+            Folder folder = (Folder)folders.next();
+            String newPath = concatenatePaths(destinationPath, folder.getName()); 
+            deepCopyFolder(folder, newPath);
+        }        
+    }
+        
+    protected String concatenatePaths(String base, String path)
+    {
+        String result = "";
+        if (base == null)
+        {
+            if (path == null)
+            {
+                return result;
+            }
+            return path;
+        }
+        else
+        {
+            if (path == null)
+            {
+                return base;
+            }
+        }
+        if (base.endsWith(Folder.PATH_SEPARATOR)) 
+        {
+            if (path.startsWith(Folder.PATH_SEPARATOR))
+            {
+                result = base.concat(path.substring(1));
+                return result;
+            }
+        
+        }
+        else
+        {
+            if (!path.startsWith(Folder.PATH_SEPARATOR)) 
+            {
+                result = base.concat(Folder.PATH_SEPARATOR).concat(path);
+                return result;
+            }
+        }
+        return base.concat(path);
     }
     
 }

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=345864&r1=345863&r2=345864&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
Sun Nov 20 23:45:54 2005
@@ -61,7 +61,6 @@
 import org.apache.jetspeed.page.document.NodeException;
 import org.apache.jetspeed.page.document.UnsupportedDocumentTypeException;
 import org.apache.jetspeed.page.document.impl.NodeImpl;
-import org.apache.ojb.broker.PersistenceBroker;
 import org.apache.ojb.broker.core.proxy.ProxyHelper;
 import org.apache.ojb.broker.query.Criteria;
 import org.apache.ojb.broker.query.QueryByCriteria;
@@ -904,6 +903,12 @@
     throws JetspeedException
     {
         return this.delegator.copyPageSecurity(source);
+    }
+
+    public void deepCopyFolder(Folder srcFolder, String destinationPath)
+    throws JetspeedException, PageNotUpdatedException
+    {
+        this.delegator.deepCopyFolder(srcFolder, destinationPath);
     }
     
 }

Modified: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/page/PageManager.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/page/PageManager.java?rev=345864&r1=345863&r2=345864&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/page/PageManager.java
(original)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/page/PageManager.java
Sun Nov 20 23:45:54 2005
@@ -355,4 +355,14 @@
     public PageSecurity copyPageSecurity(PageSecurity source) 
         throws JetspeedException;
         
+    /**
+     * Deep copy a folder. Copies a folder and all subcontents including
+     * other folders, subpages, links, menus, security, fragments. 
+     *  
+     * @param source source folder
+     * @param dest destination folder
+     */
+    public void deepCopyFolder(Folder srcFolder, String destinationPath)
+    throws JetspeedException, PageNotUpdatedException;
+    
 }



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