chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1363317 - in /chemistry/opencmis/trunk/chemistry-opencmis-client: chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runti...
Date Thu, 19 Jul 2012 12:45:07 GMT
Author: fmui
Date: Thu Jul 19 12:45:06 2012
New Revision: 1363317

URL: http://svn.apache.org/viewvc?rev=1363317&view=rev
Log:
CMIS-555: shortcuts for delete() and getContentStream()

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/CmisObject.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/AbstractCmisObject.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/SessionImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/CmisObjectMock.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/CmisObject.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/CmisObject.java?rev=1363317&r1=1363316&r2=1363317&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/CmisObject.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/CmisObject.java
Thu Jul 19 12:45:06 2012
@@ -55,10 +55,16 @@ public interface CmisObject extends Obje
     // object service
 
     /**
+     * Deletes this object. If this object is a document, the whole version
+     * series is deleted.
+     */
+    void delete();
+
+    /**
      * Deletes this object.
      * 
      * @param allVersions
-     *            if this object is a document this parameter defines if just
+     *            if this object is a document this parameter defines if only
      *            this version or all versions should be deleted
      */
     void delete(boolean allVersions);

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=1363317&r1=1363316&r2=1363317&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
Thu Jul 19 12:45:06 2012
@@ -19,6 +19,7 @@
 package org.apache.chemistry.opencmis.client.api;
 
 import java.io.Serializable;
+import java.math.BigInteger;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -464,6 +465,55 @@ public interface Session extends Seriali
             RelationshipDirection relationshipDirection, ObjectType type, OperationContext
context);
 
     /**
+     * Deletes an object and, if it is a document, all versions in the version
+     * series.
+     * 
+     * @param objectId
+     *            the id of the object
+     */
+    void delete(ObjectId objectId);
+
+    /**
+     * Deletes an object.
+     * 
+     * @param objectId
+     *            the id of the object
+     * @param allVersions
+     *            if this object is a document this parameter defines if only
+     *            this version or all versions should be deleted
+     */
+    void delete(ObjectId objectId, boolean allVersions);
+
+    /**
+     * Retrieves the main content stream of a document
+     * 
+     * @param docId
+     *            the id of the document
+     * @return the content stream or <code>null</code> if the document has no
+     *         content stream
+     */
+    ContentStream getContentStream(ObjectId docId);
+
+    /**
+     * Retrieves the content stream of a document
+     * 
+     * @param docId
+     *            the id of the document
+     * @param streamId
+     *            the stream id
+     * @param offset
+     *            the offset of the stream or <code>null</code> to read the
+     *            stream from the beginning
+     * @param length
+     *            the maximum length of the stream or <code>null</code> to read
+     *            to the end of the stream
+     * 
+     * @return the content stream or <code>null</code> if the document has no
+     *         content stream
+     */
+    ContentStream getContentStream(ObjectId docId, String streamId, BigInteger offset, BigInteger
length);
+
+    /**
      * Fetches the ACL of an object from the repository.
      */
     Acl getAcl(ObjectId objectId, boolean onlyBasicPermissions);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractCmisObject.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/AbstractCmisObject.java?rev=1363317&r1=1363316&r2=1363317&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractCmisObject.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractCmisObject.java
Thu Jul 19 12:45:06 2012
@@ -261,19 +261,23 @@ public abstract class AbstractCmisObject
         }
     }
 
-    // --- properties ---
+    // --- delete ---
+
+    public void delete() {
+        delete(true);
+    }
 
     public void delete(boolean allVersions) {
         readLock();
         try {
-            String objectId = getObjectId();
-            getBinding().getObjectService().deleteObject(getRepositoryId(), objectId, allVersions,
null);
-            getSession().removeObjectFromCache(this);
+            getSession().delete(this, allVersions);
         } finally {
             readUnlock();
         }
     }
 
+    // --- update properties ---
+
     public CmisObject updateProperties(Map<String, ?> properties) {
         ObjectId objectId = updateProperties(properties, true);
         if (objectId == null) {

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=1363317&r1=1363316&r2=1363317&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
Thu Jul 19 12:45:06 2012
@@ -44,7 +44,6 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
 import org.apache.chemistry.opencmis.commons.enums.Updatability;
 import org.apache.chemistry.opencmis.commons.enums.VersioningState;
-import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
 import org.apache.chemistry.opencmis.commons.spi.Holder;
@@ -351,19 +350,9 @@ public class DocumentImpl extends Abstra
     }
 
     public ContentStream getContentStream(String streamId) {
-        String objectId = getObjectId();
-
         // get the stream
-        ContentStream contentStream;
-        try {
-            contentStream = getBinding().getObjectService().getContentStream(getRepositoryId(),
objectId, streamId,
-                    null, null, null);
-        } catch (CmisConstraintException e) {
-            // no content stream
-            return null;
-        }
+        ContentStream contentStream = getSession().getContentStream(this, streamId, null,
null);
 
-        // handle incompliant repositories
         if (contentStream == null) {
             return null;
         }

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=1363317&r1=1363316&r2=1363317&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
Thu Jul 19 12:45:06 2012
@@ -65,6 +65,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.RelationshipDirection;
 import org.apache.chemistry.opencmis.commons.enums.Updatability;
 import org.apache.chemistry.opencmis.commons.enums.VersioningState;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
 import org.apache.chemistry.opencmis.commons.spi.AuthenticationProvider;
 import org.apache.chemistry.opencmis.commons.spi.CmisBinding;
@@ -705,7 +706,7 @@ public class SessionImpl implements Sess
         return getRepositoryInfo().getId();
     }
 
-    // creates
+    // --- creates ---
 
     public ObjectId createDocument(Map<String, ?> properties, ObjectId folderId, ContentStream
contentStream,
             VersioningState versioningState, List<Policy> policies, List<Ace>
addAces, List<Ace> removeAces) {
@@ -832,6 +833,8 @@ public class SessionImpl implements Sess
         return this.createPolicy(properties, folderId, null, null, null);
     }
 
+    // --- relationships ---
+
     public ObjectId createRelationship(Map<String, ?> properties) {
         return this.createRelationship(properties, null, null, null);
     }
@@ -879,6 +882,47 @@ public class SessionImpl implements Sess
         });
     }
 
+    // --- delete ---
+
+    public void delete(ObjectId objectId) {
+        delete(objectId, true);
+    }
+
+    public void delete(ObjectId objectId, boolean allVersions) {
+        if ((objectId == null) || (objectId.getId() == null)) {
+            throw new IllegalArgumentException("Invalid object id!");
+        }
+
+        getBinding().getObjectService().deleteObject(getRepositoryId(), objectId.getId(),
allVersions, null);
+        removeObjectFromCache(objectId);
+    }
+
+    // --- content stream ---
+
+    public ContentStream getContentStream(ObjectId docId) {
+        return getContentStream(docId, null, null, null);
+    }
+
+    public ContentStream getContentStream(ObjectId docId, String streamId, BigInteger offset,
BigInteger length) {
+        if ((docId == null) || (docId.getId() == null)) {
+            throw new IllegalArgumentException("Invalid document id!");
+        }
+
+        // get the stream
+        ContentStream contentStream = null;
+        try {
+            contentStream = getBinding().getObjectService().getContentStream(getRepositoryId(),
docId.getId(),
+                    streamId, offset, length, null);
+        } catch (CmisConstraintException e) {
+            // no content stream
+            return null;
+        }
+
+        return contentStream;
+    }
+
+    // --- ACL ---
+
     public Acl getAcl(ObjectId objectId, boolean onlyBasicPermissions) {
         if ((objectId == null) || (objectId.getId() == null)) {
             throw new IllegalArgumentException("Invalid object id!");

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/CmisObjectMock.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/CmisObjectMock.java?rev=1363317&r1=1363316&r2=1363317&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/CmisObjectMock.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/CmisObjectMock.java
Thu Jul 19 12:45:06 2012
@@ -66,6 +66,9 @@ public class CmisObjectMock implements C
     public void applyPolicy(ObjectId policyId) {
     }
 
+    public void delete() {
+    }
+    
     public void delete(boolean allVersions) {
     }
 



Mime
View raw message