Return-Path: X-Original-To: apmail-chemistry-commits-archive@www.apache.org Delivered-To: apmail-chemistry-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 98CDFC07C for ; Thu, 19 Jul 2012 12:45:35 +0000 (UTC) Received: (qmail 44965 invoked by uid 500); 19 Jul 2012 12:45:35 -0000 Delivered-To: apmail-chemistry-commits-archive@chemistry.apache.org Received: (qmail 44886 invoked by uid 500); 19 Jul 2012 12:45:33 -0000 Mailing-List: contact commits-help@chemistry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@chemistry.apache.org Delivered-To: mailing list commits@chemistry.apache.org Received: (qmail 44842 invoked by uid 99); 19 Jul 2012 12:45:31 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Jul 2012 12:45:31 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Jul 2012 12:45:28 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id B48F3238897A; Thu, 19 Jul 2012 12:45:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@chemistry.apache.org From: fmui@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120719124507.B48F3238897A@eris.apache.org> 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 null 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 null to read the + * stream from the beginning + * @param length + * the maximum length of the stream or null to read + * to the end of the stream + * + * @return the content stream or null 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 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 properties, ObjectId folderId, ContentStream contentStream, VersioningState versioningState, List policies, List addAces, List removeAces) { @@ -832,6 +833,8 @@ public class SessionImpl implements Sess return this.createPolicy(properties, folderId, null, null, null); } + // --- relationships --- + public ObjectId createRelationship(Map 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) { }