jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r515081 - /jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
Date Tue, 06 Mar 2007 11:34:55 GMT
Author: angela
Date: Tue Mar  6 03:34:42 2007
New Revision: 515081

URL: http://svn.apache.org/viewvc?view=rev&rev=515081
Log:
clone, copy: 
- srcPath cannot be determined by using the destination-SessionInfo.
- add private method to build destinationPath

Modified:
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java

Modified: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java?view=diff&rev=515081&r1=515080&r2=515081
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
Tue Mar  6 03:34:42 2007
@@ -392,22 +392,20 @@
         final SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
         executeWithLocalEvents(new Callable() {
             public Object run() throws RepositoryException {
-                String srcPath = pathForId(srcNodeId, sInfo);
-                StringBuffer destPath = new StringBuffer(pathForId(destParentNodeId, sInfo));
-                try {
-                    if (destPath.length() > 1) {
-                        destPath.append("/");
-                    }
-                    destPath.append(NameFormat.format(destName, sInfo.getNamespaceResolver()));
-                } catch (NoPrefixDeclaredException e) {
-                    throw new RepositoryException(e.getMessage(), e);
-                }
                 Workspace ws = sInfo.getSession().getWorkspace();
-                if (sInfo.getWorkspaceName().equals(srcWorkspaceName)) {
+                String destPath = getDestinationPath(destParentNodeId, destName, sInfo);
+                if (ws.getName().equals(srcWorkspaceName)) {
                     // inner-workspace copy
-                    ws.copy(srcPath, destPath.toString());
+                    String srcPath = pathForId(srcNodeId, sInfo);
+                    ws.copy(srcPath, destPath);
                 } else {
-                    ws.copy(srcWorkspaceName, srcPath, destPath.toString());
+                    SessionInfoImpl srcInfo = getSessionInfoImpl(obtain(sInfo, srcWorkspaceName));
+                    try {
+                        String srcPath = pathForId(srcNodeId, srcInfo);
+                        ws.copy(srcWorkspaceName, srcPath, destPath);
+                    } finally {
+                        dispose(srcInfo);
+                    }
                 }
                 return null;
             }
@@ -442,18 +440,16 @@
         final SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
         executeWithLocalEvents(new Callable() {
             public Object run() throws RepositoryException {
-                String srcPath = pathForId(srcNodeId, sInfo);
-                StringBuffer destPath = new StringBuffer(pathForId(destParentNodeId, sInfo));
+                SessionInfoImpl srcInfo = getSessionInfoImpl(obtain(sessionInfo, srcWorkspaceName));
                 try {
-                    if (destPath.length() > 1) {
-                        destPath.append("/");
-                    }
-                    destPath.append(NameFormat.format(destName, sInfo.getNamespaceResolver()));
-                } catch (NoPrefixDeclaredException e) {
-                    throw new RepositoryException(e.getMessage(), e);
+                String srcPath = pathForId(srcNodeId, srcInfo);
+                String destPath = getDestinationPath(destParentNodeId, destName, sInfo);
+
+                Workspace wsp = sInfo.getSession().getWorkspace();
+                wsp.clone(srcWorkspaceName, srcPath, destPath, removeExisting);
+                } finally {
+                    dispose(srcInfo);
                 }
-                sInfo.getSession().getWorkspace().clone(srcWorkspaceName, srcPath,
-                        destPath.toString(), removeExisting);
                 return null;
             }
         }, sInfo);
@@ -1112,6 +1108,19 @@
             throw new RepositoryException("Unknown SessionInfo implementation: "
                     + sessionInfo.getClass().getName());
         }
+    }
+
+    private String getDestinationPath(NodeId destParentNodeId, QName destName, SessionInfoImpl
sessionInfo) throws RepositoryException {
+        StringBuffer destPath = new StringBuffer(pathForId(destParentNodeId, sessionInfo));
+        try {
+            if (destPath.length() > 1) {
+                destPath.append("/");
+            }
+            destPath.append(NameFormat.format(destName, sessionInfo.getNamespaceResolver()));
+        } catch (NoPrefixDeclaredException e) {
+            throw new RepositoryException(e.getMessage(), e);
+        }
+        return destPath.toString();
     }
 
     private String pathForId(ItemId id, SessionInfoImpl sessionInfo)



Mime
View raw message