chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
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 GMT
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<Property<?>> properties, ContentStream contentstream,
-      VersioningState versioningState, List<Policy> policies, List<Ace> addACEs,
-      List<Ace> removeACEs);
+  Document createDocument(List<Property<?>> properties, ContentStream contentStream,
+      VersioningState versioningState, List<Policy> policies, List<Ace> addAces,
+      List<Ace> removeAces, OperationContext context);
 
   Document createDocumentFromSource(Document source, List<Property<?>> properties,
-      VersioningState versioningState, List<Policy> policies, List<Ace> addACEs,
-      List<Ace> removeACEs);
+      VersioningState versioningState, List<Policy> policies, List<Ace> addAces,
+      List<Ace> removeAces, OperationContext context);
 
-  Folder createFolder(List<Property<?>> properties, List<Policy> policies,
List<Ace> addACEs,
-      List<Ace> removeACEs);
+  Folder createFolder(List<Property<?>> properties, List<Policy> policies,
List<Ace> addAces,
+      List<Ace> removeAces, OperationContext context);
 
-  Policy createPolicy(List<Property<?>> properties, List<Policy> policies,
List<Ace> addACEs,
-      List<Ace> removeACEs);
+  Policy createPolicy(List<Property<?>> properties, List<Policy> policies,
List<Ace> addAces,
+      List<Ace> removeAces, OperationContext context);
 
   /**
    * @return list of object ids which failed to be deleted
@@ -68,7 +66,7 @@ public interface Folder extends Fileable
   PagingList<CmisObject> 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<ChangeEvent> getContentChanges(String changeLogToken, int itemsPerPage);
 
+  // create
+
+  String createDocument(List<Property<?>> properties, String folderId, ContentStream
contentStream,
+      VersioningState versioningState, List<Policy> policies, List<Ace> addAces,
+      List<Ace> removeAces);
+
+  String createDocumentFromSource(Document source, List<Property<?>> properties,
String folderId,
+      VersioningState versioningState, List<Policy> policies, List<Ace> addAces,
+      List<Ace> removeAces);
+
+  String createFolder(List<Property<?>> properties, String folderId, List<Policy>
policies,
+      List<Ace> addAces, List<Ace> removeAces);
+
+  String createPolicy(List<Property<?>> properties, String folderId, List<Policy>
policies,
+      List<Ace> addAces, List<Ace> removeAces);
+
+  String createRelationship(List<Property<?>> properties, List<Policy>
policies, List<Ace> addAces,
+      List<Ace> 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<Property<?>> properties, Folder parentfolder,
-      ContentStream contentstream, VersioningState versioningState, List<Policy> policies,
-      List<Ace> addACEs, List<Ace> removeACEs);
-
-  Document createDocumentFromSource(Document source, List<Property<?>> properties,
-      Folder parentfolder, VersioningState versioningState, List<Policy> policies,
-      List<Ace> addACEs, List<Ace> removeACEs);
-
-  Relationship createRelationship(List<Property<?>> properties, List<Policy>
policies,
-      List<Ace> addACEs, List<Ace> removeACEs);
-
-  Policy createPolicy(List<Property<?>> properties, Folder parentfolder, List<Policy>
policies,
-      List<Ace> addACEs, List<Ace> removeACEs);
-
-  Folder createFolder(Folder parent, List<Property<?>> properties, List<Policy>
policies,
-      List<Ace> addACEs, List<Ace> 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<ObjectData> 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<String> objectIdHolder = new Holder<String>(objectId);
+
+    String changeToken = getPropertyValue(PropertyIds.CMIS_CHANGE_TOKEN);
+    Holder<String> changeTokenHolder = new Holder<String>(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<String> objectIdHolder = new Holder<String>(objectId);
+
+    String changeToken = getPropertyValue(PropertyIds.CMIS_CHANGE_TOKEN);
+    Holder<String> changeTokenHolder = new Holder<String>(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<Property<?>> properties, ContentStream
contentStream,
+      VersioningState versioningState, List<Policy> policies, List<Ace> addAces,
+      List<Ace> 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<Property<?>> properties, ContentStream
contentstream,
-      VersioningState versioningState, List<Policy> policies, List<Ace> addACEs,
-      List<Ace> 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<Property<?>>
properties,
-      VersioningState versioningState, List<Policy> policies, List<Ace> addACEs,
-      List<Ace> removeACEs) {
-    throw new CmisRuntimeException("not implemented");
+      VersioningState versioningState, List<Policy> policies, List<Ace> addAces,
+      List<Ace> 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<Property<?>> properties, List<Policy>
policies,
-      List<Ace> addACEs, List<Ace> removeACEs) {
+      List<Ace> addAces, List<Ace> 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<Property<?>> properties, List<Policy>
policies,
-      List<Ace> addACEs, List<Ace> removeACEs) {
-    throw new CmisRuntimeException("not implemented");
+      List<Ace> addAces, List<Ace> 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<Property<?>> properties, String folderId,
+      ContentStream contentStream, VersioningState versioningState, List<Policy> policies,
+      List<Ace> addAces, List<Ace> 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<Property<?>> properties,
+      String folderId, VersioningState versioningState, List<Policy> policies, List<Ace>
addAces,
+      List<Ace> 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<Property<?>> properties, String folderId, List<Policy>
policies,
+      List<Ace> addAces, List<Ace> 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<Property<?>> properties, String folderId, List<Policy>
policies,
+      List<Ace> addAces, List<Ace> 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<Property<?>> properties, List<Policy>
policies,
+      List<Ace> addAces, List<Ace> 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<String> convertPolicies(List<Policy> policies) {
+    if (policies == null) {
+      return null;
+    }
+
+    List<String> result = new ArrayList<String>();
+
+    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
    * <code>null</code> 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<Property<?>> properties, Folder parentfolder,
-      ContentStream contentstream, VersioningState versioningState, List<Policy> policies,
-      List<Ace> addACEs, List<Ace> removeACEs) {
-    throw new CmisRuntimeException("not implemented");
-  }
-
-  public Document createDocumentFromSource(Document source, List<Property<?>>
properties,
-      Folder parentfolder, VersioningState versioningState, List<Policy> policies,
-      List<Ace> addACEs, List<Ace> removeACEs) {
-    throw new CmisRuntimeException("not implemented");
-  }
-
-  public Folder createFolder(Folder parent, List<Property<?>> properties, List<Policy>
policies,
-      List<Ace> addACEs, List<Ace> removeACEs) {
-
-    PersistentFolderImpl f = new PersistentFolderImpl(this.session);
-
-    /* create folder in backend */
-    f.create(parent, properties, policies, addACEs, removeACEs);
-
-    return f;
-  }
-
-  public Policy createPolicy(List<Property<?>> properties, Folder parentfolder,
-      List<Policy> policies, List<Ace> addACEs, List<Ace> removeACEs) {
-    throw new CmisRuntimeException("not implemented");
-  }
-
-  public Relationship createRelationship(List<Property<?>> properties, List<Policy>
policies,
-      List<Ace> addACEs, List<Ace> removeACEs) {
-    throw new CmisRuntimeException("not implemented");
-  }
-
+  
   /**
    * Converts object data into an API object.
    */



Mime
View raw message