Author: fmui
Date: Fri Jul 29 09:54:12 2016
New Revision: 1754492
URL: http://svn.apache.org/viewvc?rev=1754492&view=rev
Log:
OpenCMIS client: more convenience around versioning
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Document.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Folder.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Item.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Policy.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Relationship.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Session.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/FolderImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/ItemImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PolicyImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/RelationshipImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Document.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Document.java?rev=1754492&r1=1754491&r2=1754492&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Document.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Document.java
Fri Jul 29 09:54:12 2016
@@ -35,6 +35,28 @@ import org.apache.chemistry.opencmis.com
*/
public interface Document extends FileableCmisObject, DocumentProperties {
+ /**
+ * Returns the object type as a document type.
+ *
+ * @return the document type
+ *
+ * @throws ClassCastException
+ * if the object type is not a document type
+ *
+ * @cmis 1.0
+ */
+ DocumentType getDocumentType();
+
+ /**
+ * Returns whether the document is versionable or not.
+ *
+ * @return {@code true} if the document is versionable, {@code false} if
the
+ * document is not versionable or if it's unknown
+ *
+ * @cmis 1.0
+ */
+ boolean isVersionable();
+
// object service
/**
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Folder.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Folder.java?rev=1754492&r1=1754491&r2=1754492&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Folder.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Folder.java
Fri Jul 29 09:54:12 2016
@@ -33,6 +33,18 @@ import org.apache.chemistry.opencmis.com
*/
public interface Folder extends FileableCmisObject, FolderProperties {
+ /**
+ * Returns the object type as a folder type.
+ *
+ * @return the folder type
+ *
+ * @throws ClassCastException
+ * if the object type is not a folder type
+ *
+ * @cmis 1.0
+ */
+ FolderType getFolderType();
+
// object service
/**
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Item.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Item.java?rev=1754492&r1=1754491&r2=1754492&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Item.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Item.java
Fri Jul 29 09:54:12 2016
@@ -25,4 +25,16 @@ package org.apache.chemistry.opencmis.cl
*/
public interface Item extends FileableCmisObject {
+ /**
+ * Returns the object type as an item type.
+ *
+ * @return the item type
+ *
+ * @throws ClassCastException
+ * if the object type is not an item type
+ *
+ * @cmis 1.1
+ */
+ ItemType getItemType();
+
}
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Policy.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Policy.java?rev=1754492&r1=1754491&r2=1754492&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Policy.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Policy.java
Fri Jul 29 09:54:12 2016
@@ -25,4 +25,16 @@ package org.apache.chemistry.opencmis.cl
*/
public interface Policy extends FileableCmisObject, PolicyProperties {
+ /**
+ * Returns the object type as a policy type.
+ *
+ * @return the policy type
+ *
+ * @throws ClassCastException
+ * if the object type is not a policy type
+ *
+ * @cmis 1.0
+ */
+ PolicyType getPolicyType();
+
}
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Relationship.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Relationship.java?rev=1754492&r1=1754491&r2=1754492&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Relationship.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Relationship.java
Fri Jul 29 09:54:12 2016
@@ -26,26 +26,46 @@ package org.apache.chemistry.opencmis.cl
public interface Relationship extends CmisObject, RelationshipProperties {
/**
- * Gets the source object. If the source object ID is invalid,
- * {@code null} will be returned.
+ * Returns the object type as a relationship type.
+ *
+ * @return the relationship type
+ *
+ * @throws ClassCastException
+ * if the object type is not a relationship type
+ *
+ * @cmis 1.0
+ */
+ RelationshipType getRelationshipType();
+
+ /**
+ * Gets the source object. If the source object ID is invalid, {@code null}
+ * will be returned.
+ *
+ * @cmis 1.0
*/
CmisObject getSource();
/**
* Gets the source object using the given {@link OperationContext}. If the
* source object ID is invalid, {@code null} will be returned.
+ *
+ * @cmis 1.0
*/
CmisObject getSource(OperationContext context);
/**
- * Gets the target object. If the target object ID is invalid,
- * {@code null} will be returned.
+ * Gets the target object. If the target object ID is invalid, {@code null}
+ * will be returned.
+ *
+ * @cmis 1.0
*/
CmisObject getTarget();
/**
* Gets the target object using the given {@link OperationContext}. If the
* target object ID is invalid, {@code null} will be returned.
+ *
+ * @cmis 1.0
*/
CmisObject getTarget(OperationContext context);
}
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Session.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Session.java?rev=1754492&r1=1754491&r2=1754492&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Session.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Session.java
Fri Jul 29 09:54:12 2016
@@ -544,6 +544,10 @@ public interface Session extends Seriali
/**
* Returns the latest version in a version series.
*
+ * Some repositories throw an exception if the document is not versionable;
+ * others just return the unversioned document. To avoid surprises, check
+ * first whether the document is versionable or not.
+ *
* @param objectId
* the document ID of an arbitrary version in the version series
*
@@ -556,6 +560,10 @@ public interface Session extends Seriali
/**
* Returns the latest version in a version series.
*
+ * Some repositories throw an exception if the document is not versionable;
+ * others just return the unversioned document. To avoid surprises, check
+ * first whether the document is versionable or not.
+ *
* @param objectId
* the document ID of an arbitrary version in the version series
* @param context
@@ -570,6 +578,14 @@ public interface Session extends Seriali
/**
* Returns the latest version in a version series.
*
+ * Some repositories throw an exception if the document is not versionable;
+ * others just return the unversioned document. To avoid surprises, check
+ * first whether the document is versionable or not.
+ *
+ * If {@code major} == {@code true} and the version series doesn't contain
a
+ * major version, the repository is supposed to throw a
+ * {@link CmisObjectNotFoundException}.
+ *
* @param objectId
* the document ID of an arbitrary version in the version series
* @param major
@@ -585,7 +601,11 @@ public interface Session extends Seriali
Document getLatestDocumentVersion(ObjectId objectId, boolean major,
OperationContext context);
/**
- * /** Returns the latest version in a version series.
+ * Returns the latest version in a version series.
+ *
+ * Some repositories throw an exception if the document is not versionable;
+ * others just return the unversioned document. To avoid surprises, check
+ * first whether the document is versionable or not.
*
* @param objectId
* the document ID of an arbitrary version in the version series
@@ -599,6 +619,10 @@ public interface Session extends Seriali
/**
* Returns the latest version in a version series.
*
+ * Some repositories throw an exception if the document is not versionable;
+ * others just return the unversioned document. To avoid surprises, check
+ * first whether the document is versionable or not.
+ *
* @param objectId
* the document ID of an arbitrary version in the version series
* @param context
@@ -613,6 +637,14 @@ public interface Session extends Seriali
/**
* Returns the latest version in a version series.
*
+ * Some repositories throw an exception if the document is not versionable;
+ * others just return the unversioned document. To avoid surprises, check
+ * first whether the document is versionable or not.
+ *
+ * If {@code major} == {@code true} and the version series doesn't contain
a
+ * major version, the repository is supposed to throw a
+ * {@link CmisObjectNotFoundException}.
+ *
* @param objectId
* the document ID of an arbitrary version in the version series
* @param major
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java?rev=1754492&r1=1754491&r2=1754492&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java
Fri Jul 29 09:54:12 2016
@@ -33,6 +33,7 @@ import java.util.Set;
import org.apache.chemistry.opencmis.client.api.CmisObject;
import org.apache.chemistry.opencmis.client.api.Document;
+import org.apache.chemistry.opencmis.client.api.DocumentType;
import org.apache.chemistry.opencmis.client.api.ObjectFactory;
import org.apache.chemistry.opencmis.client.api.ObjectId;
import org.apache.chemistry.opencmis.client.api.ObjectType;
@@ -67,6 +68,21 @@ public class DocumentImpl extends Abstra
initialize(session, objectType, objectData, context);
}
+ @Override
+ public DocumentType getDocumentType() {
+ ObjectType objectType = super.getType();
+ if (objectType instanceof DocumentType) {
+ return (DocumentType) objectType;
+ } else {
+ throw new ClassCastException("Object type is not a document
type.");
+ }
+ }
+
+ @Override
+ public boolean isVersionable() {
+ return Boolean.TRUE.equals(getDocumentType().isVersionable());
+ }
+
// properties
@Override
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/FolderImpl.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/FolderImpl.java?rev=1754492&r1=1754491&r2=1754492&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/FolderImpl.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/FolderImpl.java
Fri Jul 29 09:54:12 2016
@@ -30,6 +30,7 @@ import org.apache.chemistry.opencmis.cli
import org.apache.chemistry.opencmis.client.api.Document;
import org.apache.chemistry.opencmis.client.api.FileableCmisObject;
import org.apache.chemistry.opencmis.client.api.Folder;
+import org.apache.chemistry.opencmis.client.api.FolderType;
import org.apache.chemistry.opencmis.client.api.Item;
import org.apache.chemistry.opencmis.client.api.ItemIterable;
import org.apache.chemistry.opencmis.client.api.ObjectFactory;
@@ -70,6 +71,16 @@ public class FolderImpl extends Abstract
}
@Override
+ public FolderType getFolderType() {
+ ObjectType objectType = super.getType();
+ if (objectType instanceof FolderType) {
+ return (FolderType) objectType;
+ } else {
+ throw new ClassCastException("Object type is not a folder type.");
+ }
+ }
+
+ @Override
public Document createDocument(Map<String, ?> properties, ContentStream
contentStream,
VersioningState versioningState, List<Policy> policies, List<Ace>
addAces, List<Ace> removeAces,
OperationContext context) {
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/ItemImpl.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/ItemImpl.java?rev=1754492&r1=1754491&r2=1754492&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/ItemImpl.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/ItemImpl.java
Fri Jul 29 09:54:12 2016
@@ -19,6 +19,7 @@
package org.apache.chemistry.opencmis.client.runtime;
import org.apache.chemistry.opencmis.client.api.Item;
+import org.apache.chemistry.opencmis.client.api.ItemType;
import org.apache.chemistry.opencmis.client.api.ObjectType;
import org.apache.chemistry.opencmis.client.api.OperationContext;
import org.apache.chemistry.opencmis.commons.data.ObjectData;
@@ -34,4 +35,14 @@ public class ItemImpl extends AbstractFi
initialize(session, objectType, objectData, context);
}
+ @Override
+ public ItemType getItemType() {
+ ObjectType objectType = super.getType();
+ if (objectType instanceof ItemType) {
+ return (ItemType) objectType;
+ } else {
+ throw new ClassCastException("Object type is not an item type.");
+ }
+ }
+
}
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PolicyImpl.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PolicyImpl.java?rev=1754492&r1=1754491&r2=1754492&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PolicyImpl.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PolicyImpl.java
Fri Jul 29 09:54:12 2016
@@ -21,6 +21,7 @@ package org.apache.chemistry.opencmis.cl
import org.apache.chemistry.opencmis.client.api.ObjectType;
import org.apache.chemistry.opencmis.client.api.OperationContext;
import org.apache.chemistry.opencmis.client.api.Policy;
+import org.apache.chemistry.opencmis.client.api.PolicyType;
import org.apache.chemistry.opencmis.commons.PropertyIds;
import org.apache.chemistry.opencmis.commons.data.ObjectData;
@@ -36,8 +37,17 @@ public class PolicyImpl extends Abstract
}
@Override
+ public PolicyType getPolicyType() {
+ ObjectType objectType = super.getType();
+ if (objectType instanceof PolicyType) {
+ return (PolicyType) objectType;
+ } else {
+ throw new ClassCastException("Object type is not a policy type.");
+ }
+ }
+
+ @Override
public String getPolicyText() {
return getPropertyValue(PropertyIds.POLICY_TEXT);
}
-
}
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/RelationshipImpl.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/RelationshipImpl.java?rev=1754492&r1=1754491&r2=1754492&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/RelationshipImpl.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/RelationshipImpl.java
Fri Jul 29 09:54:12 2016
@@ -23,6 +23,7 @@ import org.apache.chemistry.opencmis.cli
import org.apache.chemistry.opencmis.client.api.ObjectType;
import org.apache.chemistry.opencmis.client.api.OperationContext;
import org.apache.chemistry.opencmis.client.api.Relationship;
+import org.apache.chemistry.opencmis.client.api.RelationshipType;
import org.apache.chemistry.opencmis.commons.PropertyIds;
import org.apache.chemistry.opencmis.commons.data.ObjectData;
@@ -38,6 +39,16 @@ public class RelationshipImpl extends Ab
}
@Override
+ public RelationshipType getRelationshipType() {
+ ObjectType objectType = super.getType();
+ if (objectType instanceof RelationshipType) {
+ return (RelationshipType) objectType;
+ } else {
+ throw new ClassCastException("Object type is not a relationship
type.");
+ }
+ }
+
+ @Override
public CmisObject getSource() {
return getSource(getSession().getDefaultContext());
}
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java?rev=1754492&r1=1754491&r2=1754492&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java
Fri Jul 29 09:54:12 2016
@@ -37,6 +37,7 @@ import org.apache.chemistry.opencmis.cli
import org.apache.chemistry.opencmis.client.api.ChangeEvents;
import org.apache.chemistry.opencmis.client.api.CmisObject;
import org.apache.chemistry.opencmis.client.api.Document;
+import org.apache.chemistry.opencmis.client.api.DocumentType;
import org.apache.chemistry.opencmis.client.api.Folder;
import org.apache.chemistry.opencmis.client.api.ItemIterable;
import org.apache.chemistry.opencmis.client.api.ObjectFactory;
@@ -646,16 +647,30 @@ public class SessionImpl implements Sess
// first attempt: if we got a Document object, try getting the version
// series ID from it
if (objectId instanceof Document) {
- versionSeriesId = ((Document) objectId).getVersionSeriesId();
+ Document sourceDoc = (Document) objectId;
+
+ if (!sourceDoc.isVersionable()) {
+ // if it is not versionable, a getObject() is sufficient
+ return (Document) getObject(sourceDoc, context);
+ }
+
+ versionSeriesId = sourceDoc.getVersionSeriesId();
}
// second attempt: if we have a Document object in the cache, retrieve
// the version series ID form there
if (versionSeriesId == null) {
if (context.isCacheEnabled()) {
- CmisObject sourceDoc = cache.getById(objectId.getId(),
context.getCacheKey());
- if (sourceDoc instanceof Document) {
- versionSeriesId = ((Document)
sourceDoc).getVersionSeriesId();
+ CmisObject sourceObj = cache.getById(objectId.getId(),
context.getCacheKey());
+ if (sourceObj instanceof Document) {
+ Document sourceDoc = (Document) sourceObj;
+
+ if (!sourceDoc.isVersionable()) {
+ // if it is not versionable, a getObject() is
sufficient
+ return (Document) getObject(sourceDoc, context);
+ }
+
+ versionSeriesId = sourceDoc.getVersionSeriesId();
}
}
}
@@ -670,11 +685,20 @@ public class SessionImpl implements Sess
// get the document to find the version series ID
ObjectData sourceObjectData =
binding.getObjectService().getObject(getRepositoryId(), objectId.getId(),
- PropertyIds.OBJECT_ID + "," +
PropertyIds.VERSION_SERIES_ID, false, IncludeRelationships.NONE,
- "cmis:none", false, false, null);
+ PropertyIds.OBJECT_ID + "," +
PropertyIds.OBJECT_TYPE_ID + "," + PropertyIds.VERSION_SERIES_ID,
+ false, IncludeRelationships.NONE, "cmis:none", false,
false, null);
+
+ String objectTypeId = null;
if (sourceObjectData.getProperties() != null
&& sourceObjectData.getProperties().getProperties() !=
null) {
+
+ PropertyData<?> objectTypeIdProp =
sourceObjectData.getProperties().getProperties()
+ .get(PropertyIds.OBJECT_TYPE_ID);
+ if (objectTypeIdProp != null &&
objectTypeIdProp.getFirstValue() instanceof String) {
+ objectTypeId = (String)
objectTypeIdProp.getFirstValue();
+ }
+
PropertyData<?> verionsSeriesIdProp =
sourceObjectData.getProperties().getProperties()
.get(PropertyIds.VERSION_SERIES_ID);
if (verionsSeriesIdProp != null &&
verionsSeriesIdProp.getFirstValue() instanceof String) {
@@ -682,8 +706,16 @@ public class SessionImpl implements Sess
}
}
- // the Web Services binding needs the version series ID -> fail
+ // the Web Services binding needs the version series ID
if (versionSeriesId == null) {
+
+ ObjectType type = getTypeDefinition(objectTypeId);
+ if (type instanceof DocumentType &&
Boolean.FALSE.equals(((DocumentType) type).isVersionable())) {
+ // if the document is not versionable, we don't need a
+ // version series ID
+ return (Document) getObject(objectId, context);
+ }
+
throw new IllegalArgumentException("Object is not a
document or not versionable!");
}
}