chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1463558 - in /chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr: impl/ util/
Date Tue, 02 Apr 2013 14:18:13 GMT
Author: mduerig
Date: Tue Apr  2 14:18:11 2013
New Revision: 1463558

URL: http://svn.apache.org/r1463558
Log:
CMIS-618: This operation requires that the node be versionable (that is, isNodeType("mix:versionable")
== true) 
applied patch. credits to Ivan Vasyliev

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/impl/DefaultDocumentTypeHandler.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/impl/DefaultUnversionedDocumentTypeHandler.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/util/Util.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/impl/DefaultDocumentTypeHandler.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/impl/DefaultDocumentTypeHandler.java?rev=1463558&r1=1463557&r2=1463558&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/impl/DefaultDocumentTypeHandler.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/impl/DefaultDocumentTypeHandler.java
Tue Apr  2 14:18:11 2013
@@ -24,6 +24,7 @@ import java.io.IOException;
 import javax.jcr.Binary;
 import javax.jcr.Node;
 import javax.jcr.Property;
+import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.version.Version;
@@ -46,6 +47,7 @@ import org.apache.chemistry.opencmis.jcr
 import org.apache.chemistry.opencmis.jcr.JcrVersionBase;
 import org.apache.chemistry.opencmis.jcr.query.IdentifierMap;
 import org.apache.chemistry.opencmis.jcr.type.JcrDocumentTypeHandler;
+import org.apache.chemistry.opencmis.jcr.util.Util;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -96,8 +98,21 @@ public class DefaultDocumentTypeHandler 
     }
 
     public boolean canHandle(Node node) throws RepositoryException {
-        return node.isNodeType(NodeType.NT_FILE) && node.isNodeType(NodeType.MIX_SIMPLE_VERSIONABLE);
+        return node.isNodeType(NodeType.NT_FILE) && node.isNodeType(supportedVersioningType(node));
     }
+    
+    protected String supportedVersioningType(Node node) throws RepositoryException {
+    	if (Util.supportOption(node, Repository.OPTION_SIMPLE_VERSIONING_SUPPORTED)) {
+    		return NodeType.MIX_SIMPLE_VERSIONABLE;
+    	}
+    	
+    	if(Util.supportOption(node, Repository.OPTION_VERSIONING_SUPPORTED)) {
+    		return NodeType.MIX_VERSIONABLE;
+    	}
+    	
+    	throw new RepositoryException("The repository does not support versioning!");
+    }
+
 
     public JcrNode createDocument(JcrFolder parentFolder, String name, Properties properties,
                                   ContentStream contentStream, VersioningState versioningState)
{
@@ -166,7 +181,7 @@ public class DefaultDocumentTypeHandler 
     protected void addFileNodeMixins(Node fileNode, VersioningState versioningState)
             throws RepositoryException {
         if (versioningState != VersioningState.NONE) {
-            fileNode.addMixin(NodeType.MIX_SIMPLE_VERSIONABLE);
+            fileNode.addMixin(supportedVersioningType(fileNode));
         }
     }
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/impl/DefaultUnversionedDocumentTypeHandler.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/impl/DefaultUnversionedDocumentTypeHandler.java?rev=1463558&r1=1463557&r2=1463558&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/impl/DefaultUnversionedDocumentTypeHandler.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/impl/DefaultUnversionedDocumentTypeHandler.java
Tue Apr  2 14:18:11 2013
@@ -72,7 +72,7 @@ public class DefaultUnversionedDocumentT
 
     @Override
     public boolean canHandle(Node node) throws RepositoryException {
-        return node.isNodeType(NodeType.NT_FILE) && !node.isNodeType(NodeType.MIX_SIMPLE_VERSIONABLE);
+        return node.isNodeType(NodeType.NT_FILE) && !node.isNodeType(supportedVersioningType(node));
     }
 
     @Override

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/util/Util.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/util/Util.java?rev=1463558&r1=1463557&r2=1463558&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/util/Util.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-jcr/src/main/java/org/apache/chemistry/opencmis/jcr/util/Util.java
Tue Apr  2 14:18:11 2013
@@ -21,6 +21,9 @@ package org.apache.chemistry.opencmis.jc
 import java.util.Calendar;
 import java.util.GregorianCalendar;
 
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
 /**
  * Miscellaneous utility functions
  */
@@ -90,5 +93,16 @@ public final class Util {
     public static String escape(String path) {
         return replace(path, " ", "_x0020_"); // fixme do more thorough escaping of path
     }
+    
+    /**
+     * The repository's support option definition.
+     * @param node JCR node
+     * @param option requested repository's option
+     * @return true if repository supports option, otherwise false.
+     * @throws RepositoryException thrown when any error with repository was occurred.
+     */
+    public static boolean supportOption(Node node, String option) throws RepositoryException
{
+    	return Boolean.valueOf(node.getSession().getRepository().getDescriptor(option));
+    }
 
 }



Mime
View raw message