jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r798890 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
Date Wed, 29 Jul 2009 13:22:56 GMT
Author: stefan
Date: Wed Jul 29 13:22:56 2009
New Revision: 798890

URL: http://svn.apache.org/viewvc?rev=798890&view=rev
Log:
JCR-1608: JSR 283: Workspace Management

fixed bug in Workspace#createWorkspace(String, String) implementation



Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java?rev=798890&r1=798889&r2=798890&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
Wed Jul 29 13:22:56 2009
@@ -25,6 +25,8 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
 import javax.jcr.lock.LockException;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.nodetype.NodeTypeManager;
@@ -208,7 +210,17 @@
             tmpSession = rep.createSession(session.getSubject(), name);
             WorkspaceImpl newWsp = (WorkspaceImpl) tmpSession.getWorkspace();
 
-            newWsp.clone(srcWorkspace, "/", "/", false);
+            // Workspace#clone(String, String, String, booelan) doesn't
+            // allow to clone to "/"...
+            //newWsp.clone(srcWorkspace, "/", "/", false);
+           Node root = session.getRootNode();
+           for (NodeIterator it = root.getNodes(); it.hasNext(); ) {
+               Node child = it.nextNode();
+               // skip nodes that already exist in newly created workspace
+               if (!tmpSession.nodeExists(child.getPath())) {
+                   newWsp.clone(srcWorkspace, child.getPath(), child.getPath(), false);
+               }
+           }
         } finally {
             if (tmpSession != null) {
                 // we don't need the temporary session anymore, logout



Mime
View raw message