Return-Path: Delivered-To: apmail-incubator-chemistry-commits-archive@minotaur.apache.org Received: (qmail 83351 invoked from network); 9 Mar 2010 15:29:51 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 9 Mar 2010 15:29:51 -0000 Received: (qmail 40145 invoked by uid 500); 9 Mar 2010 15:29:24 -0000 Delivered-To: apmail-incubator-chemistry-commits-archive@incubator.apache.org Received: (qmail 40120 invoked by uid 500); 9 Mar 2010 15:29:24 -0000 Mailing-List: contact chemistry-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: chemistry-dev@incubator.apache.org Delivered-To: mailing list chemistry-commits@incubator.apache.org Received: (qmail 40112 invoked by uid 99); 9 Mar 2010 15:29:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Mar 2010 15:29:24 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.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; Tue, 09 Mar 2010 15:29:18 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id C56622388978; Tue, 9 Mar 2010 15:28:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r920921 - in /incubator/chemistry/trunk/opencmis/opencmis-client: opencmis-client-api/src/main/java/org/apache/opencmis/client/api/ opencmis-client-api/src/main/java/org/apache/opencmis/client/api/repository/ opencmis-client-impl/src/main/j... Date: Tue, 09 Mar 2010 15:28:56 -0000 To: chemistry-commits@incubator.apache.org From: fmui@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100309152856.C56622388978@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: fmui Date: Tue Mar 9 15:28:56 2010 New Revision: 920921 URL: http://svn.apache.org/viewvc?rev=920921&view=rev Log: implemented create* - not tested yet Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/Document.java incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/Folder.java incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/Session.java incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/repository/ObjectFactory.java incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentDocumentImpl.java incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentFolderImpl.java incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentSessionImpl.java incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/SessionUtil.java incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/repository/PersistentObjectFactoryImpl.java Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/Document.java URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/Document.java?rev=920921&r1=920920&r2=920921&view=diff ============================================================================== --- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/Document.java (original) +++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/Document.java Tue Mar 9 15:28:56 2010 @@ -18,7 +18,6 @@ */ package org.apache.opencmis.client.api; -import java.math.BigInteger; import java.util.List; import org.apache.opencmis.commons.enums.VersioningState; @@ -32,9 +31,9 @@ public interface Document extends Fileab ContentStream getContentStream(); - void setContentStream(boolean overwrite, ContentStream contentStream); + String setContentStream(boolean overwrite, ContentStream contentStream); - void deleteContentStream(); + String deleteContentStream(); // versioning service @@ -78,14 +77,13 @@ public interface Document extends Fileab String getCheckinComment(); // cmis:checkinComment long getContentStreamLength(); // cmis:contentStreamLength - + String getContentStreamMimeType(); // cmis:contentStreamMimeType - + String getContentStreamFileName(); // cmis:contentStreamFileName - + String getContentStreamId(); // cmis:contentStreamId - - + /** * Shortcut for ObjectFactory.createDocumentFromSource(this, ...). * Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/Folder.java URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/Folder.java?rev=920921&r1=920920&r2=920921&view=diff ============================================================================== --- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/Folder.java (original) +++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/Folder.java Tue Mar 9 15:28:56 2010 @@ -32,21 +32,19 @@ import org.apache.opencmis.commons.enums public interface Folder extends FileableCmisObject { // object service - Document createDocument(String name, String typeId); - - Document createDocument(List> properties, ContentStream contentstream, - VersioningState versioningState, List policies, List addACEs, - List removeACEs); + Document createDocument(List> properties, ContentStream contentStream, + VersioningState versioningState, List policies, List addAces, + List removeAces, OperationContext context); Document createDocumentFromSource(Document source, List> properties, - VersioningState versioningState, List policies, List addACEs, - List removeACEs); + VersioningState versioningState, List policies, List addAces, + List removeAces, OperationContext context); - Folder createFolder(List> properties, List policies, List addACEs, - List removeACEs); + Folder createFolder(List> properties, List policies, List addAces, + List removeAces, OperationContext context); - Policy createPolicy(List> properties, List policies, List addACEs, - List removeACEs); + Policy createPolicy(List> properties, List policies, List addAces, + List removeAces, OperationContext context); /** * @return list of object ids which failed to be deleted @@ -68,7 +66,7 @@ public interface Folder extends Fileable PagingList getChildren(OperationContext context, int itemsPerPage); boolean isRootFolder(); - + Folder getFolderParent(); String getPath(); Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/Session.java URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/Session.java?rev=920921&r1=920920&r2=920921&view=diff ============================================================================== --- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/Session.java (original) +++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/Session.java Tue Mar 9 15:28:56 2010 @@ -29,6 +29,7 @@ import org.apache.opencmis.client.api.re import org.apache.opencmis.client.api.util.Container; import org.apache.opencmis.client.api.util.PagingList; import org.apache.opencmis.commons.enums.IncludeRelationships; +import org.apache.opencmis.commons.enums.VersioningState; import org.apache.opencmis.commons.provider.CmisProvider; /** @@ -163,4 +164,22 @@ public interface Session { */ PagingList getContentChanges(String changeLogToken, int itemsPerPage); + // create + + String createDocument(List> properties, String folderId, ContentStream contentStream, + VersioningState versioningState, List policies, List addAces, + List removeAces); + + String createDocumentFromSource(Document source, List> properties, String folderId, + VersioningState versioningState, List policies, List addAces, + List removeAces); + + String createFolder(List> properties, String folderId, List policies, + List addAces, List removeAces); + + String createPolicy(List> properties, String folderId, List policies, + List addAces, List removeAces); + + String createRelationship(List> properties, List policies, List addAces, + List removeAces); } Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/repository/ObjectFactory.java URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/repository/ObjectFactory.java?rev=920921&r1=920920&r2=920921&view=diff ============================================================================== --- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/repository/ObjectFactory.java (original) +++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/repository/ObjectFactory.java Tue Mar 9 15:28:56 2010 @@ -57,26 +57,6 @@ public interface ObjectFactory { // object service - // shortcut - Document createDocument(Folder parentfolder, String name); - - Document createDocument(List> properties, Folder parentfolder, - ContentStream contentstream, VersioningState versioningState, List policies, - List addACEs, List removeACEs); - - Document createDocumentFromSource(Document source, List> properties, - Folder parentfolder, VersioningState versioningState, List policies, - List addACEs, List removeACEs); - - Relationship createRelationship(List> properties, List policies, - List addACEs, List removeACEs); - - Policy createPolicy(List> properties, Folder parentfolder, List policies, - List addACEs, List removeACEs); - - Folder createFolder(Folder parent, List> properties, List policies, - List addACEs, List removeACEs); - CmisObject convertObject(ObjectData objectData, OperationContext context); QueryResult convertQueryResult(ObjectData objectData); Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentDocumentImpl.java URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentDocumentImpl.java?rev=920921&r1=920920&r2=920921&view=diff ============================================================================== --- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentDocumentImpl.java (original) +++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentDocumentImpl.java Tue Mar 9 15:28:56 2010 @@ -35,6 +35,7 @@ import org.apache.opencmis.commons.Prope import org.apache.opencmis.commons.enums.VersioningState; import org.apache.opencmis.commons.exceptions.CmisRuntimeException; import org.apache.opencmis.commons.provider.ContentStreamData; +import org.apache.opencmis.commons.provider.Holder; import org.apache.opencmis.commons.provider.ObjectData; public class PersistentDocumentImpl extends AbstractPersistentFilableCmisObject implements Document { @@ -91,17 +92,17 @@ public class PersistentDocumentImpl exte public long getContentStreamLength() { BigInteger bigInt = getPropertyValue(PropertyIds.CMIS_CONTENT_STREAM_LENGTH); - return (bigInt == null) ? (long)-1 : bigInt.longValue(); + return (bigInt == null) ? (long) -1 : bigInt.longValue(); } - + public String getContentStreamMimeType() { return getPropertyValue(PropertyIds.CMIS_CONTENT_STREAM_MIME_TYPE); } - + public String getContentStreamFileName() { return getPropertyValue(PropertyIds.CMIS_CONTENT_STREAM_FILE_NAME); } - + public String getContentStreamId() { return getPropertyValue(PropertyIds.CMIS_CONTENT_STREAM_ID); } @@ -156,8 +157,8 @@ public class PersistentDocumentImpl exte String objectId = getObjectId(); List versions = getProvider().getVersioningService().getAllVersions( - getRepositoryId(), objectId, context.getFilterString(), context.isIncludeAllowableActions(), - null); + getRepositoryId(), objectId, context.getFilterString(), + context.isIncludeAllowableActions(), null); ObjectFactory objectFactory = getSession().getObjectFactory(); @@ -213,11 +214,40 @@ public class PersistentDocumentImpl exte contentStream.getMimeType(), contentStream.getStream()); } - public void setContentStream(boolean overwrite, ContentStream contentStream) { - throw new CmisRuntimeException("not implemented"); + /* + * (non-Javadoc) + * + * @see org.apache.opencmis.client.api.Document#setContentStream(boolean, + * org.apache.opencmis.client.api.ContentStream) + */ + public String setContentStream(boolean overwrite, ContentStream contentStream) { + String objectId = getObjectId(); + Holder objectIdHolder = new Holder(objectId); + + String changeToken = getPropertyValue(PropertyIds.CMIS_CHANGE_TOKEN); + Holder changeTokenHolder = new Holder(changeToken); + + getProvider().getObjectService().setContentStream(getRepositoryId(), objectIdHolder, overwrite, + changeTokenHolder, SessionUtil.convertContentStream(getSession(), contentStream), null); + + return objectIdHolder.getValue(); } - public void deleteContentStream() { - throw new CmisRuntimeException("not implemented"); + /* + * (non-Javadoc) + * + * @see org.apache.opencmis.client.api.Document#deleteContentStream() + */ + public String deleteContentStream() { + String objectId = getObjectId(); + Holder objectIdHolder = new Holder(objectId); + + String changeToken = getPropertyValue(PropertyIds.CMIS_CHANGE_TOKEN); + Holder changeTokenHolder = new Holder(changeToken); + + getProvider().getObjectService().deleteContentStream(getRepositoryId(), objectIdHolder, + changeTokenHolder, null); + + return objectIdHolder.getValue(); } } Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentFolderImpl.java URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentFolderImpl.java?rev=920921&r1=920920&r2=920921&view=diff ============================================================================== --- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentFolderImpl.java (original) +++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentFolderImpl.java Tue Mar 9 15:28:56 2010 @@ -68,37 +68,132 @@ public class PersistentFolderImpl extend initialize(session, objectType, objectData, context); } - public PersistentFolderImpl(PersistentSessionImpl session) { - initialize(session, null, null, null); - } + /* + * (non-Javadoc) + * + * @see org.apache.opencmis.client.api.Folder#createDocument(java.util.List, + * org.apache.opencmis.client.api.ContentStream, + * org.apache.opencmis.commons.enums.VersioningState, java.util.List, java.util.List, + * java.util.List, org.apache.opencmis.client.api.OperationContext) + */ + public Document createDocument(List> properties, ContentStream contentStream, + VersioningState versioningState, List policies, List addAces, + List removeAces, OperationContext context) { + String objectId = getObjectId(); - public Document createDocument(String name, String typeId) { - throw new CmisRuntimeException("not implemented"); - } + String newId = getProvider().getObjectService().createDocument(getRepositoryId(), + SessionUtil.convertProperties(getSession(), properties), objectId, + SessionUtil.convertContentStream(getSession(), contentStream), versioningState, + SessionUtil.convertPolicies(policies), SessionUtil.convertAces(getSession(), addAces), + SessionUtil.convertAces(getSession(), removeAces), null); - public Document createDocument(List> properties, ContentStream contentstream, - VersioningState versioningState, List policies, List addACEs, - List removeACEs) { - throw new CmisRuntimeException("not implemented"); + // if no context is provided the object will not be fetched + if (context == null) { + return null; + } + + // get the new object + CmisObject object = getSession().getObject(newId, context); + if (!(object instanceof Document)) { + throw new CmisRuntimeException("Newly created object is not a document! New id: " + newId); + } + + return (Document) object; } + /* + * (non-Javadoc) + * + * @see + * org.apache.opencmis.client.api.Folder#createDocumentFromSource(org.apache.opencmis.client.api + * .Document, java.util.List, org.apache.opencmis.commons.enums.VersioningState, java.util.List, + * java.util.List, java.util.List, org.apache.opencmis.client.api.OperationContext) + */ public Document createDocumentFromSource(Document source, List> properties, - VersioningState versioningState, List policies, List addACEs, - List removeACEs) { - throw new CmisRuntimeException("not implemented"); + VersioningState versioningState, List policies, List addAces, + List removeAces, OperationContext context) { + String objectId = getObjectId(); + + if ((source == null) || (source.getId() == null)) { + throw new IllegalArgumentException("Source document has no id!"); + } + + String newId = getProvider().getObjectService().createDocumentFromSource(getRepositoryId(), + source.getId(), SessionUtil.convertProperties(getSession(), properties), objectId, + versioningState, SessionUtil.convertPolicies(policies), + SessionUtil.convertAces(getSession(), addAces), + SessionUtil.convertAces(getSession(), removeAces), null); + + // if no context is provided the object will not be fetched + if (context == null) { + return null; + } + + // get the new object + CmisObject object = getSession().getObject(newId, context); + if (!(object instanceof Document)) { + throw new CmisRuntimeException("Newly created object is not a document! New id: " + newId); + } + + return (Document) object; } + /* + * (non-Javadoc) + * + * @see org.apache.opencmis.client.api.Folder#createFolder(java.util.List, java.util.List, + * java.util.List, java.util.List, org.apache.opencmis.client.api.OperationContext) + */ public Folder createFolder(List> properties, List policies, - List addACEs, List removeACEs) { + List addAces, List removeAces, OperationContext context) { + String objectId = getObjectId(); + + String newId = getProvider().getObjectService().createFolder(getRepositoryId(), + SessionUtil.convertProperties(getSession(), properties), objectId, + SessionUtil.convertPolicies(policies), SessionUtil.convertAces(getSession(), addAces), + SessionUtil.convertAces(getSession(), removeAces), null); + + // if no context is provided the object will not be fetched + if (context == null) { + return null; + } + + // get the new object + CmisObject object = getSession().getObject(newId, context); + if (!(object instanceof Folder)) { + throw new CmisRuntimeException("Newly created object is not a folder! New id: " + newId); + } - Folder f = getSession().getObjectFactory().createFolder(this, properties, policies, addACEs, - removeACEs); - return f; + return (Folder) object; } + /* + * (non-Javadoc) + * + * @see org.apache.opencmis.client.api.Folder#createPolicy(java.util.List, java.util.List, + * java.util.List, java.util.List, org.apache.opencmis.client.api.OperationContext) + */ public Policy createPolicy(List> properties, List policies, - List addACEs, List removeACEs) { - throw new CmisRuntimeException("not implemented"); + List addAces, List removeAces, OperationContext context) { + String objectId = getObjectId(); + + String newId = getProvider().getObjectService().createPolicy(getRepositoryId(), + SessionUtil.convertProperties(getSession(), properties), objectId, + SessionUtil.convertPolicies(policies), SessionUtil.convertAces(getSession(), addAces), + SessionUtil.convertAces(getSession(), removeAces), null); + + // if no context is provided the object will not be fetched + if (context == null) { + return null; + } + + // get the new object + CmisObject object = getSession().getObject(newId, context); + if (!(object instanceof Policy)) { + throw new CmisRuntimeException("Newly created object is not a policy! New id: " + newId); + } + + return (Policy) object; } /* Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentSessionImpl.java URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentSessionImpl.java?rev=920921&r1=920920&r2=920921&view=diff ============================================================================== --- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentSessionImpl.java (original) +++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentSessionImpl.java Tue Mar 9 15:28:56 2010 @@ -29,13 +29,16 @@ import java.util.UUID; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.opencmis.client.api.Ace; import org.apache.opencmis.client.api.ChangeEvent; import org.apache.opencmis.client.api.CmisObject; +import org.apache.opencmis.client.api.ContentStream; import org.apache.opencmis.client.api.Document; import org.apache.opencmis.client.api.ExtensionHandler; import org.apache.opencmis.client.api.Folder; import org.apache.opencmis.client.api.OperationContext; import org.apache.opencmis.client.api.PersistentSession; +import org.apache.opencmis.client.api.Policy; import org.apache.opencmis.client.api.Property; import org.apache.opencmis.client.api.QueryResult; import org.apache.opencmis.client.api.Session; @@ -62,6 +65,7 @@ import org.apache.opencmis.commons.enums import org.apache.opencmis.commons.enums.CmisProperties; import org.apache.opencmis.commons.enums.IncludeRelationships; import org.apache.opencmis.commons.enums.UnfileObjects; +import org.apache.opencmis.commons.enums.VersioningState; import org.apache.opencmis.commons.exceptions.CmisRuntimeException; import org.apache.opencmis.commons.impl.dataobjects.PropertyIdDefinitionImpl; import org.apache.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl; @@ -674,7 +678,7 @@ public class PersistentSessionImpl imple objectTypeIdPropertyType, folderTypeId); properties.add(typeProperty); - this.testRootFolder = rootFolder.createFolder(properties, null, null, null); + this.testRootFolder = rootFolder.createFolder(properties, null, null, null, getDefaultContext()); og.setContentSizeInKB(10); og.setDocumentTypeId(documentTypeId); @@ -769,4 +773,84 @@ public class PersistentSessionImpl imple public String getRepositoryId() { return this.getRepositoryInfo().getId(); } + + // creates + + /* + * (non-Javadoc) + * + * @see org.apache.opencmis.client.api.Session#createDocument(java.util.List, java.lang.String, + * org.apache.opencmis.client.api.ContentStream, + * org.apache.opencmis.commons.enums.VersioningState, java.util.List, java.util.List, + * java.util.List) + */ + public String createDocument(List> properties, String folderId, + ContentStream contentStream, VersioningState versioningState, List policies, + List addAces, List removeAces) { + return getProvider().getObjectService().createDocument(getRepositoryId(), + SessionUtil.convertProperties(this, properties), folderId, + SessionUtil.convertContentStream(this, contentStream), versioningState, + SessionUtil.convertPolicies(policies), SessionUtil.convertAces(this, addAces), + SessionUtil.convertAces(this, removeAces), null); + } + + /* + * (non-Javadoc) + * + * @see + * org.apache.opencmis.client.api.Session#createDocumentFromSource(org.apache.opencmis.client. + * api.Document, java.util.List, java.lang.String, + * org.apache.opencmis.commons.enums.VersioningState, java.util.List, java.util.List, + * java.util.List) + */ + public String createDocumentFromSource(Document source, List> properties, + String folderId, VersioningState versioningState, List policies, List addAces, + List removeAces) { + return getProvider().getObjectService().createDocumentFromSource(getRepositoryId(), + source.getId(), SessionUtil.convertProperties(this, properties), folderId, versioningState, + SessionUtil.convertPolicies(policies), SessionUtil.convertAces(this, addAces), + SessionUtil.convertAces(this, removeAces), null); + } + + /* + * (non-Javadoc) + * + * @see org.apache.opencmis.client.api.Session#createFolder(java.util.List, java.lang.String, + * java.util.List, java.util.List, java.util.List) + */ + public String createFolder(List> properties, String folderId, List policies, + List addAces, List removeAces) { + return getProvider().getObjectService().createFolder(getRepositoryId(), + SessionUtil.convertProperties(this, properties), folderId, + SessionUtil.convertPolicies(policies), SessionUtil.convertAces(this, addAces), + SessionUtil.convertAces(this, removeAces), null); + } + + /* + * (non-Javadoc) + * + * @see org.apache.opencmis.client.api.Session#createPolicy(java.util.List, java.lang.String, + * java.util.List, java.util.List, java.util.List) + */ + public String createPolicy(List> properties, String folderId, List policies, + List addAces, List removeAces) { + return getProvider().getObjectService().createPolicy(getRepositoryId(), + SessionUtil.convertProperties(this, properties), folderId, + SessionUtil.convertPolicies(policies), SessionUtil.convertAces(this, addAces), + SessionUtil.convertAces(this, removeAces), null); + } + + /* + * (non-Javadoc) + * + * @see org.apache.opencmis.client.api.Session#createRelationship(java.util.List, java.util.List, + * java.util.List, java.util.List) + */ + public String createRelationship(List> properties, List policies, + List addAces, List removeAces) { + + return getProvider().getObjectService().createRelationship(getRepositoryId(), + SessionUtil.convertProperties(this, properties), SessionUtil.convertPolicies(policies), + SessionUtil.convertAces(this, addAces), SessionUtil.convertAces(this, removeAces), null); + } } Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/SessionUtil.java URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/SessionUtil.java?rev=920921&r1=920920&r2=920921&view=diff ============================================================================== --- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/SessionUtil.java (original) +++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/SessionUtil.java Tue Mar 9 15:28:56 2010 @@ -30,6 +30,8 @@ import java.util.Map; import org.apache.opencmis.client.api.Ace; import org.apache.opencmis.client.api.Acl; import org.apache.opencmis.client.api.AllowableActions; +import org.apache.opencmis.client.api.ContentStream; +import org.apache.opencmis.client.api.Policy; import org.apache.opencmis.client.api.Property; import org.apache.opencmis.client.api.QueryProperty; import org.apache.opencmis.client.api.Rendition; @@ -59,6 +61,7 @@ import org.apache.opencmis.commons.excep import org.apache.opencmis.commons.provider.AccessControlEntry; import org.apache.opencmis.commons.provider.AccessControlList; import org.apache.opencmis.commons.provider.AllowableActionsData; +import org.apache.opencmis.commons.provider.ContentStreamData; import org.apache.opencmis.commons.provider.ObjectData; import org.apache.opencmis.commons.provider.PropertiesData; import org.apache.opencmis.commons.provider.PropertyData; @@ -298,6 +301,25 @@ public final class SessionUtil { } /** + * Converts policies. + */ + public static List convertPolicies(List policies) { + if (policies == null) { + return null; + } + + List result = new ArrayList(); + + for (Policy policy : policies) { + if ((policy != null) && (policy.getId() != null)) { + result.add(policy.getId()); + } + } + + return result; + } + + /** * Converts rendition. */ public static Rendition convertRendition(Session session, String objectId, RenditionData rendition) { @@ -316,6 +338,23 @@ public final class SessionUtil { } /** + * Converts a content stream. + */ + public static ContentStreamData convertContentStream(Session session, ContentStream contentStream) { + if (contentStream == null) { + return null; + } + + ProviderObjectFactory pof = session.getProvider().getObjectFactory(); + + BigInteger length = (contentStream.getLength() < 0 ? null : BigInteger.valueOf(contentStream + .getLength())); + + return pof.createContentStream(length, contentStream.getMimeType(), + contentStream.getFileName(), contentStream.getStream()); + } + + /** * Extracts the type information from the given object data and returns the object type or * null if there is no type information. */ Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/repository/PersistentObjectFactoryImpl.java URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/repository/PersistentObjectFactoryImpl.java?rev=920921&r1=920920&r2=920921&view=diff ============================================================================== --- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/repository/PersistentObjectFactoryImpl.java (original) +++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/repository/PersistentObjectFactoryImpl.java Tue Mar 9 15:28:56 2010 @@ -27,13 +27,8 @@ import org.apache.opencmis.client.api.Ac import org.apache.opencmis.client.api.AllowableActions; import org.apache.opencmis.client.api.CmisObject; import org.apache.opencmis.client.api.ContentStream; -import org.apache.opencmis.client.api.Document; -import org.apache.opencmis.client.api.Folder; import org.apache.opencmis.client.api.OperationContext; -import org.apache.opencmis.client.api.Policy; -import org.apache.opencmis.client.api.Property; import org.apache.opencmis.client.api.QueryResult; -import org.apache.opencmis.client.api.Relationship; import org.apache.opencmis.client.api.objecttype.ObjectType; import org.apache.opencmis.client.api.repository.ObjectFactory; import org.apache.opencmis.client.runtime.AceImpl; @@ -47,7 +42,6 @@ import org.apache.opencmis.client.runtim import org.apache.opencmis.client.runtime.PersistentSessionImpl; import org.apache.opencmis.client.runtime.QueryResultImpl; import org.apache.opencmis.client.runtime.SessionUtil; -import org.apache.opencmis.commons.enums.VersioningState; import org.apache.opencmis.commons.exceptions.CmisRuntimeException; import org.apache.opencmis.commons.provider.ObjectData; @@ -80,44 +74,7 @@ public class PersistentObjectFactoryImpl InputStream stream) { return new ContentStreamImpl(filename, length, mimetype, stream); } - - public Document createDocument(Folder parentfolder, String name) { - throw new CmisRuntimeException("not implemented"); - } - - public Document createDocument(List> properties, Folder parentfolder, - ContentStream contentstream, VersioningState versioningState, List policies, - List addACEs, List removeACEs) { - throw new CmisRuntimeException("not implemented"); - } - - public Document createDocumentFromSource(Document source, List> properties, - Folder parentfolder, VersioningState versioningState, List policies, - List addACEs, List removeACEs) { - throw new CmisRuntimeException("not implemented"); - } - - public Folder createFolder(Folder parent, List> properties, List policies, - List addACEs, List removeACEs) { - - PersistentFolderImpl f = new PersistentFolderImpl(this.session); - - /* create folder in backend */ - f.create(parent, properties, policies, addACEs, removeACEs); - - return f; - } - - public Policy createPolicy(List> properties, Folder parentfolder, - List policies, List addACEs, List removeACEs) { - throw new CmisRuntimeException("not implemented"); - } - - public Relationship createRelationship(List> properties, List policies, - List addACEs, List removeACEs) { - throw new CmisRuntimeException("not implemented"); - } - + /** * Converts object data into an API object. */