chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1380712 - in /chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr: JcrPrivateWorkingCopy.java JcrRepository.java JcrVersion.java
Date Tue, 04 Sep 2012 16:03:34 GMT
Author: mduerig
Date: Tue Sep  4 16:03:34 2012
New Revision: 1380712

URL: http://svn.apache.org/viewvc?rev=1380712&view=rev
Log:
CMIS-557: Issues with JcrRepository.getJcrNode and ID format
thanks Ivan Vasiliev for the patch (slightly edited)

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrPrivateWorkingCopy.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrRepository.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrVersion.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrPrivateWorkingCopy.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrPrivateWorkingCopy.java?rev=1380712&r1=1380711&r2=1380712&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrPrivateWorkingCopy.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrPrivateWorkingCopy.java
Tue Sep  4 16:03:34 2012
@@ -19,14 +19,14 @@
 
 package org.apache.chemistry.opencmis.jcr;
 
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
 import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
 import org.apache.chemistry.opencmis.jcr.type.JcrTypeHandlerManager;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
 /**
  * Instances of this class represent a private working copy of a cmis:document backed by
an underlying
  * JCR <code>Node</code>.
@@ -59,7 +59,7 @@ public class JcrPrivateWorkingCopy exten
      * @see JcrPrivateWorkingCopy#PWC_NAME
      */
     public static boolean isPwc(String objectId) {
-        return objectId.endsWith('/' + PWC_NAME);   
+        return objectId.equals(PWC_NAME);   
     }
 
     //------------------------------------------< protected >---
@@ -82,7 +82,7 @@ public class JcrPrivateWorkingCopy exten
 
     @Override
     protected String getObjectId() throws RepositoryException {
-        return getVersionSeriesId() + '/' + PWC_NAME;
+        return getVersionSeriesId();
     }
 
     @Override

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrRepository.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrRepository.java?rev=1380712&r1=1380711&r2=1380712&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrRepository.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrRepository.java
Tue Sep  4 16:03:34 2012
@@ -339,7 +339,16 @@ public class JcrRepository {
 
         // get the node
         JcrNode jcrNode = getJcrNode(session, objectId);
-        jcrNode.delete(Boolean.TRUE.equals(allVersions), JcrPrivateWorkingCopy.isPwc(objectId));

+        try {
+            // check on private copy
+            boolean isPwc = jcrNode.isVersionable()
+                    && JcrPrivateWorkingCopy.isPwc(jcrNode.asVersion().getVersionLabel());
+            jcrNode.delete(Boolean.TRUE.equals(allVersions), isPwc);
+        }
+        catch(RepositoryException rex) {
+            log.debug(rex.getMessage(), rex);
+            throw new CmisRuntimeException(rex.getMessage(), rex);
+        }
     }
 
     /**
@@ -993,24 +1002,21 @@ public class JcrRepository {
                 return typeHandlerManager.create(getRootNode(session));
             }
 
-            int k = id.indexOf('/');
-            if (k >= 0) {
-                String nodeId = id.substring(0, k);
-                String versionName = id.substring(k + 1);
-
-                Node node = session.getNodeByIdentifier(nodeId);
-
-                JcrNode jcrNode = typeHandlerManager.create(node);
-                if (JcrPrivateWorkingCopy.denotesPwc(versionName)) {
-                    return jcrNode.asVersion().getPwc();
-                }
-                else {
-                    return jcrNode.asVersion().getVersion(versionName);
-                }
+            Node node = session.getNodeByIdentifier(id);
+            JcrNode jcrNode = typeHandlerManager.create(node);
+            
+            // if node isn't under versioning, then return retrieved object 
+            if (!jcrNode.isVersionable()) {
+            	return jcrNode;
+            }
+            
+            JcrVersionBase versionNode = jcrNode.asVersion();
+            if (JcrPrivateWorkingCopy.denotesPwc(versionNode.getVersionLabel())) {
+                return versionNode.getPwc();
             }
             else {
-                Node node = session.getNodeByIdentifier(id);
-                return typeHandlerManager.create(node);
+               JcrVersion version = versionNode.getVersion(((JcrVersion) versionNode).getVersionName());
+               return version;
             }
 
         }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrVersion.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrVersion.java?rev=1380712&r1=1380711&r2=1380712&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrVersion.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/JcrVersion.java
Tue Sep  4 16:03:34 2012
@@ -19,13 +19,14 @@
 
 package org.apache.chemistry.opencmis.jcr;
 
-import org.apache.chemistry.opencmis.jcr.type.JcrTypeHandlerManager;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.version.Version;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+
+import org.apache.chemistry.opencmis.jcr.type.JcrTypeHandlerManager;
 
 /**
  * Instances of this class represent a specific version of a cmis:document backed by an underlying
@@ -60,7 +61,7 @@ public class JcrVersion extends JcrVersi
     
     @Override
     protected String getObjectId() throws RepositoryException {
-        return getVersionSeriesId() + '/' + version.getName();
+        return getVersionSeriesId();
     }
 
     @Override
@@ -94,7 +95,7 @@ public class JcrVersion extends JcrVersi
         // todo set checkinComment
         return "";
     }
-
+    
     //------------------------------------------< private >---
 
     private static String parseVersion(String name, int group) {
@@ -104,5 +105,13 @@ public class JcrVersion extends JcrVersi
                 : null;
     }
 
+    /**
+     * Retrieve version name.
+     * @return version name
+     * @throws RepositoryException
+     */
+    public String getVersionName() throws RepositoryException {
+    	return version.getName();
+    }
 
 }



Mime
View raw message