You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2010/11/13 18:41:36 UTC

svn commit: r1034817 - in /incubator/chemistry/opencmis/branches/client-api-refactoring: chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ chemistry-opencmis-client/chemistry-opencmis-client...

Author: fmui
Date: Sat Nov 13 17:41:36 2010
New Revision: 1034817

URL: http://svn.apache.org/viewvc?rev=1034817&view=rev
Log:
- added test and a few fixes

Modified:
    incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Document.java
    incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Folder.java
    incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Policy.java
    incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Relationship.java
    incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/CmisBindingFactory.java
    incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/LinkCache.java
    incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractTransientCmisObject.java
    incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java
    incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/FolderImpl.java
    incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PolicyImpl.java
    incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/RelationshipImpl.java
    incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java
    incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/TransientDocumentImpl.java
    incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/TransientFolderImpl.java
    incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java
    incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/AbstractWriteObjectIT.java
    incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/misc/AbstractReadOnlyCreateSessionIT.java

Modified: incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Document.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Document.java?rev=1034817&r1=1034816&r2=1034817&view=diff
==============================================================================
--- incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Document.java (original)
+++ incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Document.java Sat Nov 13 17:41:36 2010
@@ -32,6 +32,8 @@ import org.apache.chemistry.opencmis.com
  */
 public interface Document extends FileableCmisObject {
 
+    TransientDocument getTransientDocument();
+
     // object service
 
     /**

Modified: incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Folder.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Folder.java?rev=1034817&r1=1034816&r2=1034817&view=diff
==============================================================================
--- incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Folder.java (original)
+++ incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Folder.java Sat Nov 13 17:41:36 2010
@@ -28,16 +28,18 @@ import org.apache.chemistry.opencmis.com
 
 /**
  * CMIS Folder.
- *
+ * 
  * Domain Model 2.5
  */
 public interface Folder extends FileableCmisObject {
 
+    TransientFolder getTransientFolder();
+
     // object service
 
     /**
      * Creates a new document in this folder.
-     *
+     * 
      * @return the new document object or <code>null</code> if the parameter
      *         <code>context</code> was set to <code>null</code>
      */
@@ -46,14 +48,14 @@ public interface Folder extends Fileable
 
     /**
      * Creates a new document in this folder.
-     *
+     * 
      * @return the new document object
      */
     Document createDocument(Map<String, ?> properties, ContentStream contentStream, VersioningState versioningState);
 
     /**
      * Creates a new document from a source document in this folder.
-     *
+     * 
      * @return the new document object or <code>null</code> if the parameter
      *         <code>context</code> was set to <code>null</code>
      */
@@ -62,14 +64,14 @@ public interface Folder extends Fileable
 
     /**
      * Creates a new document from a source document in this folder.
-     *
+     * 
      * @return the new document object
      */
     Document createDocumentFromSource(ObjectId source, Map<String, ?> properties, VersioningState versioningState);
 
     /**
      * Creates a new subfolder in this folder.
-     *
+     * 
      * @return the new folder object or <code>null</code> if the parameter
      *         <code>context</code> was set to <code>null</code>
      */
@@ -78,14 +80,14 @@ public interface Folder extends Fileable
 
     /**
      * Creates a new subfolder in this folder.
-     *
+     * 
      * @return the new folder object
      */
     Folder createFolder(Map<String, ?> properties);
 
     /**
      * Creates a new policy in this folder.
-     *
+     * 
      * @return the new policy object or <code>null</code> if the parameter
      *         <code>context</code> was set to <code>null</code>
      */
@@ -94,14 +96,14 @@ public interface Folder extends Fileable
 
     /**
      * Creates a new policy in this folder.
-     *
+     * 
      * @return the new policy object
      */
     Policy createPolicy(Map<String, ?> properties);
 
     /**
      * Deletes this folder and all subfolders.
-     *
+     * 
      * @return a list of object ids which failed to be deleted
      */
     List<String> deleteTree(boolean allversions, UnfileObject unfile, boolean continueOnFailure);
@@ -148,7 +150,7 @@ public interface Folder extends Fileable
 
     /**
      * Gets the parent folder object
-     *
+     * 
      * @return the parent folder object or <code>null</code> if the folder is
      *         the root folder.
      */

Modified: incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Policy.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Policy.java?rev=1034817&r1=1034816&r2=1034817&view=diff
==============================================================================
--- incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Policy.java (original)
+++ incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Policy.java Sat Nov 13 17:41:36 2010
@@ -25,6 +25,8 @@ package org.apache.chemistry.opencmis.cl
  */
 public interface Policy extends FileableCmisObject {
 
+    TransientPolicy getTransientPolicy();
+
     /**
      * Returns the policy text.
      */

Modified: incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Relationship.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Relationship.java?rev=1034817&r1=1034816&r2=1034817&view=diff
==============================================================================
--- incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Relationship.java (original)
+++ incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Relationship.java Sat Nov 13 17:41:36 2010
@@ -25,6 +25,8 @@ package org.apache.chemistry.opencmis.cl
  */
 public interface Relationship extends CmisObject {
 
+    TransientRelationship getTransientRelationship();
+
     // relationship specific properties
 
     /**

Modified: incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/CmisBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/CmisBindingFactory.java?rev=1034817&r1=1034816&r2=1034817&view=diff
==============================================================================
--- incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/CmisBindingFactory.java (original)
+++ incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/CmisBindingFactory.java Sat Nov 13 17:41:36 2010
@@ -199,7 +199,7 @@ public final class CmisBindingFactory {
 
         result.put(SessionParameter.CACHE_SIZE_REPOSITORIES, "10");
         result.put(SessionParameter.CACHE_SIZE_TYPES, "100");
-        result.put(SessionParameter.CACHE_SIZE_OBJECTS, "400");
+        result.put(SessionParameter.CACHE_SIZE_LINKS, "400");
 
         return result;
     }

Modified: incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/LinkCache.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/LinkCache.java?rev=1034817&r1=1034816&r2=1034817&view=diff
==============================================================================
--- incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/LinkCache.java (original)
+++ incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/LinkCache.java Sat Nov 13 17:41:36 2010
@@ -66,7 +66,7 @@ public class LinkCache implements Serial
             typeCount = CACHE_SIZE_TYPES;
         }
 
-        int objCount = session.get(SessionParameter.CACHE_SIZE_OBJECTS, CACHE_SIZE_OBJECTS);
+        int objCount = session.get(SessionParameter.CACHE_SIZE_LINKS, CACHE_SIZE_OBJECTS);
         if (objCount < 1) {
             objCount = CACHE_SIZE_OBJECTS;
         }

Modified: incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractTransientCmisObject.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractTransientCmisObject.java?rev=1034817&r1=1034816&r2=1034817&view=diff
==============================================================================
--- incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractTransientCmisObject.java (original)
+++ incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractTransientCmisObject.java Sat Nov 13 17:41:36 2010
@@ -47,6 +47,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.AllowableActions;
 import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
 import org.apache.chemistry.opencmis.commons.data.Properties;
+import org.apache.chemistry.opencmis.commons.data.PropertyData;
 import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
 import org.apache.chemistry.opencmis.commons.enums.AclPropagation;
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
@@ -378,29 +379,69 @@ public abstract class AbstractTransientC
             return getObjectId();
         }
 
-        String newObjectId = getId();
+        String objectId = getId();
 
-        newObjectId = saveDelete(newObjectId);
-        if (newObjectId == null) {
+        if (saveDelete(objectId)) {
             // object has been deleted, there is nothing else to do
             // ... and there is no object id anymore
             return null;
         }
-
-        newObjectId = saveProperties(newObjectId);
-        newObjectId = savePolicies(newObjectId);
-        newObjectId = saveACL(newObjectId);
+        String newObjectId = saveProperties(getId(), getChangeToken());
+        saveACL(newObjectId);
+        savePolicies(newObjectId);
 
         return getSession().createObjectId(newObjectId);
     }
 
-    protected String saveDelete(String objectId) {
+    /**
+     * Fetches the latest change token of this object from the repository.
+     */
+    protected String getLatestChangeToken(String objectId) {
+        // determine the object id query name
+        PropertyDefinition<?> objectIdPropDef = getCmisObject().getType().getPropertyDefinitions()
+        .get(PropertyIds.OBJECT_ID);
+if (objectIdPropDef == null) {
+    return null;
+}
+
+String objectIdQueryName = objectIdPropDef.getQueryName();
+if (objectIdQueryName == null) {
+    return null;
+}
+        
+        // determine the change token query name
+        PropertyDefinition<?> changeTokenPropDef = getCmisObject().getType().getPropertyDefinitions()
+                .get(PropertyIds.CHANGE_TOKEN);
+        if (changeTokenPropDef == null) {
+            return null;
+        }
+
+        String changeTokenQueryName = changeTokenPropDef.getQueryName();
+        if (changeTokenQueryName == null) {
+            return null;
+        }
+
+        // get the change token property
+        Properties properties = getBinding().getObjectService().getProperties(getRepositoryId(), objectId,
+                objectIdQueryName +","+changeTokenQueryName, null);
+
+        // if a change token is set, return it
+        PropertyData<?> changeToken = properties.getProperties().get(PropertyIds.CHANGE_TOKEN);
+
+        if ((changeToken == null) || (changeToken.getFirstValue() == null)) {
+            return null;
+        }
+
+        return changeToken.getFirstValue().toString();
+    }
+
+    protected boolean saveDelete(String objectId) {
         if (isMarkedForDelete) {
             getBinding().getObjectService().deleteObject(getRepositoryId(), objectId, deleteAllVersions, null);
-            return null;
+            return true;
         }
 
-        return objectId;
+        return false;
     }
 
     protected Properties prepareProperties() {
@@ -425,10 +466,10 @@ public abstract class AbstractTransientC
         return result;
     }
 
-    protected String saveProperties(String objectId) {
+    protected String saveProperties(String objectId, String changeToken) {
         if (isPropertyUpdateRequired) {
             Holder<String> objectIdHolder = new Holder<String>(objectId);
-            Holder<String> changeTokenHolder = new Holder<String>(getChangeToken());
+            Holder<String> changeTokenHolder = new Holder<String>(changeToken);
 
             // convert properties
             Properties props = prepareProperties();
@@ -445,7 +486,7 @@ public abstract class AbstractTransientC
         return objectId;
     }
 
-    protected String savePolicies(String objectId) {
+    protected void savePolicies(String objectId) {
         // add policies
         for (String policyId : addPolicies) {
             getBinding().getPolicyService().applyPolicy(getRepositoryId(), policyId, objectId, null);
@@ -455,8 +496,6 @@ public abstract class AbstractTransientC
         for (String policyId : removePolicies) {
             getBinding().getPolicyService().removePolicy(getRepositoryId(), policyId, objectId, null);
         }
-
-        return objectId;
     }
 
     protected Acl prepareAcl(List<AceChangeHolder> achList) {
@@ -474,7 +513,7 @@ public abstract class AbstractTransientC
         return of.createAcl(aces);
     }
 
-    protected String saveACL(String objectId) {
+    protected void saveACL(String objectId) {
         for (AclPropagation ap : AclPropagation.values()) {
             if (!addAces.containsKey(ap) && !removeAces.containsKey(ap)) {
                 continue;
@@ -488,8 +527,6 @@ public abstract class AbstractTransientC
             getBinding().getAclService().applyAcl(getRepositoryId(), objectId, prepareAcl(addAces.get(null)),
                     prepareAcl(removeAces.get(null)), null, null);
         }
-
-        return objectId;
     }
 
     // --- internal ---

Modified: incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java?rev=1034817&r1=1034816&r2=1034817&view=diff
==============================================================================
--- incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java (original)
+++ incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java Sat Nov 13 17:41:36 2010
@@ -33,6 +33,7 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.client.api.OperationContext;
 import org.apache.chemistry.opencmis.client.api.Policy;
 import org.apache.chemistry.opencmis.client.api.TransientCmisObject;
+import org.apache.chemistry.opencmis.client.api.TransientDocument;
 import org.apache.chemistry.opencmis.commons.PropertyIds;
 import org.apache.chemistry.opencmis.commons.data.Ace;
 import org.apache.chemistry.opencmis.commons.data.ContentStream;
@@ -61,6 +62,10 @@ public class DocumentImpl extends Abstra
         return td;
     }
 
+    public TransientDocument getTransientDocument() {
+        return (TransientDocument) getTransientObject();
+    }
+
     // properties
 
     public String getCheckinComment() {

Modified: incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/FolderImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/FolderImpl.java?rev=1034817&r1=1034816&r2=1034817&view=diff
==============================================================================
--- incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/FolderImpl.java (original)
+++ incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/FolderImpl.java Sat Nov 13 17:41:36 2010
@@ -37,6 +37,7 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.client.api.OperationContext;
 import org.apache.chemistry.opencmis.client.api.Policy;
 import org.apache.chemistry.opencmis.client.api.TransientCmisObject;
+import org.apache.chemistry.opencmis.client.api.TransientFolder;
 import org.apache.chemistry.opencmis.client.api.Tree;
 import org.apache.chemistry.opencmis.client.runtime.util.AbstractPageFetcher;
 import org.apache.chemistry.opencmis.client.runtime.util.CollectionIterable;
@@ -83,6 +84,10 @@ public class FolderImpl extends Abstract
         return tf;
     }
 
+    public TransientFolder getTransientFolder() {
+        return (TransientFolder) getTransientObject();
+    }
+
     public Document createDocument(Map<String, ?> properties, ContentStream contentStream,
             VersioningState versioningState, List<Policy> policies, List<Ace> addAces, List<Ace> removeAces,
             OperationContext context) {

Modified: incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PolicyImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PolicyImpl.java?rev=1034817&r1=1034816&r2=1034817&view=diff
==============================================================================
--- incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PolicyImpl.java (original)
+++ incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PolicyImpl.java Sat Nov 13 17:41:36 2010
@@ -22,6 +22,7 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.client.api.OperationContext;
 import org.apache.chemistry.opencmis.client.api.Policy;
 import org.apache.chemistry.opencmis.client.api.TransientCmisObject;
+import org.apache.chemistry.opencmis.client.api.TransientPolicy;
 import org.apache.chemistry.opencmis.commons.PropertyIds;
 import org.apache.chemistry.opencmis.commons.data.ObjectData;
 
@@ -42,6 +43,10 @@ public class PolicyImpl extends Abstract
         return tp;
     }
 
+    public TransientPolicy getTransientPolicy() {
+        return (TransientPolicy) getTransientObject();
+    }
+
     public String getPolicyText() {
         return getPropertyValue(PropertyIds.POLICY_TEXT);
     }

Modified: incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/RelationshipImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/RelationshipImpl.java?rev=1034817&r1=1034816&r2=1034817&view=diff
==============================================================================
--- incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/RelationshipImpl.java (original)
+++ incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/RelationshipImpl.java Sat Nov 13 17:41:36 2010
@@ -24,6 +24,7 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.client.api.OperationContext;
 import org.apache.chemistry.opencmis.client.api.Relationship;
 import org.apache.chemistry.opencmis.client.api.TransientCmisObject;
+import org.apache.chemistry.opencmis.client.api.TransientRelationship;
 import org.apache.chemistry.opencmis.commons.PropertyIds;
 import org.apache.chemistry.opencmis.commons.data.ObjectData;
 
@@ -44,6 +45,10 @@ public class RelationshipImpl extends Ab
         return tr;
     }
 
+    public TransientRelationship getTransientRelationship() {
+        return (TransientRelationship) getTransientObject();
+    }
+
     public CmisObject getSource() {
         return getSource(getSession().getDefaultContext());
     }

Modified: incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java?rev=1034817&r1=1034816&r2=1034817&view=diff
==============================================================================
--- incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java (original)
+++ incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java Sat Nov 13 17:41:36 2010
@@ -132,7 +132,7 @@ public class SessionImpl implements Sess
     /**
      * required for serialization
      */
-    private static final long serialVersionUID = -4287481628831198383L;
+    private static final long serialVersionUID = 1L;
 
     /**
      * Constructor.
@@ -155,9 +155,11 @@ public class SessionImpl implements Sess
     }
 
     private int determineCacheSize(Map<String, String> parameters) {
-        int size = -1;
-
-        return size;
+        try {
+            return Integer.valueOf(parameters.get(SessionParameter.CACHE_SIZE_OBJECTS));
+        } catch (NumberFormatException e) {
+            return -1;
+        }
     }
 
     private String determineRepositoryId(Map<String, String> parameters) {
@@ -424,9 +426,9 @@ public class SessionImpl implements Sess
             protected AbstractPageFetcher.Page<ObjectType> fetchPage(long skipCount) {
 
                 // fetch the data
-                TypeDefinitionList tdl = repositoryService.getTypeChildren(
-                        SessionImpl.this.getRepositoryId(), typeId, includePropertyDefinitions,
-                        BigInteger.valueOf(this.maxNumItems), BigInteger.valueOf(skipCount), null);
+                TypeDefinitionList tdl = repositoryService.getTypeChildren(SessionImpl.this.getRepositoryId(), typeId,
+                        includePropertyDefinitions, BigInteger.valueOf(this.maxNumItems),
+                        BigInteger.valueOf(skipCount), null);
 
                 // convert type definitions
                 List<ObjectType> page = new ArrayList<ObjectType>(tdl.getList().size());

Modified: incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/TransientDocumentImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/TransientDocumentImpl.java?rev=1034817&r1=1034816&r2=1034817&view=diff
==============================================================================
--- incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/TransientDocumentImpl.java (original)
+++ incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/TransientDocumentImpl.java Sat Nov 13 17:41:36 2010
@@ -70,12 +70,14 @@ public class TransientDocumentImpl exten
         this.contentOverwrite = overwrite;
 
         deleteContent = false;
+        isModified = true;
     }
 
     public void deleteContentStream() {
         deleteContent = true;
 
         contentStream = null;
+        isModified = true;
     }
 
     public Document getObjectOfLatestVersion(boolean major) {
@@ -172,26 +174,36 @@ public class TransientDocumentImpl exten
             return getObjectId();
         }
 
-        String newObjectId = getId();
+        String objectId = getId();
 
-        newObjectId = saveDelete(newObjectId);
-        if (newObjectId == null) {
+        if (saveDelete(objectId)) {
             // object has been deleted, there is nothing else to do
             // ... and there is no object id anymore
             return null;
         }
 
-        newObjectId = saveProperties(newObjectId);
-        newObjectId = saveContent(newObjectId);
-        newObjectId = savePolicies(newObjectId);
-        newObjectId = saveACL(newObjectId);
+        String newObjectId = objectId;
+        String newChangeToken = getChangeToken();
+
+        newObjectId = saveProperties(getId(), newChangeToken);
+
+        if (isPropertyUpdateRequired && ((contentStream != null) || deleteContent)) {
+            // we only need a new change token if the properties have changed
+            // AND the content should be modified
+            newChangeToken = getLatestChangeToken(newObjectId);
+        }
+
+        newObjectId = saveContent(newObjectId, newChangeToken);
+
+        saveACL(newObjectId);
+        savePolicies(newObjectId);
 
         return getSession().createObjectId(newObjectId);
     }
 
-    protected String saveContent(String objectId) {
+    protected String saveContent(String objectId, String changeToken) {
         Holder<String> objectIdHolder = new Holder<String>(objectId);
-        Holder<String> changeTokenHolder = new Holder<String>(getChangeToken());
+        Holder<String> changeTokenHolder = new Holder<String>(changeToken);
 
         if (contentStream != null) {
             getBinding().getObjectService().setContentStream(getRepositoryId(), objectIdHolder, contentOverwrite,

Modified: incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/TransientFolderImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/TransientFolderImpl.java?rev=1034817&r1=1034816&r2=1034817&view=diff
==============================================================================
--- incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/TransientFolderImpl.java (original)
+++ incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/TransientFolderImpl.java Sat Nov 13 17:41:36 2010
@@ -194,7 +194,7 @@ public class TransientFolderImpl extends
                     deleteTreeAllVersions, deleteTreeUnfile, deleteTreeContinueOnFailure, null);
 
             if ((ftd != null) && (!ftd.getIds().isEmpty())) {
-                throw new CmisConstraintException("deleteTree could not delete all folder children!");
+                throw new CmisConstraintException("deleteTree could not delete all folder children: " + ftd.getIds());
             }
 
             return null;

Modified: incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java?rev=1034817&r1=1034816&r2=1034817&view=diff
==============================================================================
--- incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java (original)
+++ incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java Sat Nov 13 17:41:36 2010
@@ -70,9 +70,11 @@ public final class SessionParameter {
      */
     public static final String AUTH_SOAP_USERNAMETOKEN = "org.apache.chemistry.opencmis.binding.auth.soap.usernametoken";
 
+    public static final String CACHE_SIZE_OBJECTS = "org.apache.chemistry.opencmis.cache.size";
+
     public static final String CACHE_SIZE_REPOSITORIES = "org.apache.chemistry.opencmis.binding.cache.repositories.size";
     public static final String CACHE_SIZE_TYPES = "org.apache.chemistry.opencmis.binding.cache.types.size";
-    public static final String CACHE_SIZE_OBJECTS = "org.apache.chemistry.opencmis.binding.cache.objects.size";
+    public static final String CACHE_SIZE_LINKS = "org.apache.chemistry.opencmis.binding.cache.links.size";
 
     // --- session control ---
 
@@ -80,6 +82,5 @@ public final class SessionParameter {
     public static final String LOCALE_ISO3166_COUNTRY = "org.apache.chemistry.opencmis.locale.iso3166";
     public static final String LOCALE_VARIANT = "org.apache.chemistry.opencmis.locale.variant";
 
-    public static final String SESSION_TYPE = "org.apache.chemistry.opencmis.session.type";
     public static final String REPOSITORY_ID = "org.apache.chemistry.opencmis.session.repository.id";
 }

Modified: incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/AbstractWriteObjectIT.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/AbstractWriteObjectIT.java?rev=1034817&r1=1034816&r2=1034817&view=diff
==============================================================================
--- incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/AbstractWriteObjectIT.java (original)
+++ incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/AbstractWriteObjectIT.java Sat Nov 13 17:41:36 2010
@@ -20,8 +20,11 @@ package org.apache.chemistry.opencmis.fi
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
 
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.HashMap;
@@ -30,12 +33,15 @@ import java.util.UUID;
 
 import org.apache.chemistry.opencmis.client.api.Document;
 import org.apache.chemistry.opencmis.client.api.ObjectId;
+import org.apache.chemistry.opencmis.client.api.OperationContext;
 import org.apache.chemistry.opencmis.client.api.Property;
+import org.apache.chemistry.opencmis.client.api.TransientDocument;
 import org.apache.chemistry.opencmis.commons.PropertyIds;
 import org.apache.chemistry.opencmis.commons.data.ContentStream;
 import org.apache.chemistry.opencmis.commons.enums.VersioningState;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisContentAlreadyExistsException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -109,7 +115,7 @@ public abstract class AbstractWriteObjec
         Document doc = (Document) this.session.getObject(id);
         assertNotNull(doc);
 
-        final int size = 1 * 1024 * 1024 * 1024; // 2GB
+        final int size = 1 * 1024 * 1024 * 1024; // 1GB
 
         InputStream in = new InputStream() {
 
@@ -207,9 +213,9 @@ public abstract class AbstractWriteObjec
         assertNotNull("Document not found: " + path, document);
 
         // TODO: adapt test to refactored interface
-        //document.setProperty(PropertyIds.NAME, "Neuer Name");
-        //document.updateProperties();
-        //assertEquals("Neuer Name", document.getName());
+        // document.setProperty(PropertyIds.NAME, "Neuer Name");
+        // document.updateProperties();
+        // assertEquals("Neuer Name", document.getName());
     }
 
     @Test
@@ -422,4 +428,145 @@ public abstract class AbstractWriteObjec
         String content3 = this.getContentAsString(doc.getContentStream());
         assertEquals(content2, content3);
     }
+
+    @Test
+    public void transientUpdate() throws Exception {
+        ObjectId parentId = this.session.createObjectId(this.fixture.getTestRootId());
+        String filename1 = UUID.randomUUID().toString();
+        String typeId = FixtureData.DOCUMENT_TYPE_ID.value();
+
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(PropertyIds.NAME, filename1);
+        properties.put(PropertyIds.OBJECT_TYPE_ID, typeId);
+
+        String mimetype = "text/html; charset=UTF-8";
+        String content1 = "Im Walde rauscht ein Wasserfall. Wenn's nicht mehr rauscht ist's Wasser all.";
+
+        byte[] buf1 = content1.getBytes("UTF-8");
+        ByteArrayInputStream in1 = new ByteArrayInputStream(buf1);
+        ContentStream contentStream1 = this.session.getObjectFactory().createContentStream(filename1, buf1.length,
+                mimetype, in1);
+        assertNotNull(contentStream1);
+
+        ObjectId id = this.session.createDocument(properties, parentId, contentStream1, VersioningState.NONE);
+        assertNotNull(id);
+
+        // prepare new non-cache operation context
+        OperationContext oc = this.session.createOperationContext();
+        oc.setFilterString("*");
+        oc.setCacheEnabled(false);
+
+        // set new name and save
+        Document doc2 = (Document) this.session.getObject(id, oc);
+        TransientDocument tdoc2 = doc2.getTransientDocument();
+
+        assertEquals(filename1, tdoc2.getName());
+
+        ContentStream cs2 = tdoc2.getContentStream();
+        assertNotNull(cs2);
+        assertContent(buf1, readContent(cs2));
+
+        String filename2 = UUID.randomUUID().toString();
+        tdoc2.setName(filename2);
+        assertEquals(filename2, tdoc2.getName());
+
+        ObjectId id2 = tdoc2.save();
+        assertNotNull(id2);
+
+        // set new content and save
+        Document doc3 = (Document) this.session.getObject(id2, oc);
+        TransientDocument tdoc3 = doc3.getTransientDocument();
+
+        assertEquals(filename2, tdoc3.getName());
+
+        ContentStream cs3 = tdoc3.getContentStream();
+        assertNotNull(cs3);
+        assertContent(buf1, readContent(cs3));
+
+        String content3 = "Es rauscht noch.";
+
+        byte[] buf3 = content3.getBytes("UTF-8");
+        ByteArrayInputStream in3 = new ByteArrayInputStream(buf3);
+        ContentStream contentStream3 = this.session.getObjectFactory().createContentStream(tdoc3.getName(),
+                buf3.length, mimetype, in3);
+        assertNotNull(contentStream3);
+
+        tdoc3.setContentStream(contentStream3, true);
+
+        ObjectId id3 = tdoc3.save();
+        assertNotNull(id3);
+
+        // set new name, delete content and save
+        Document doc4 = (Document) this.session.getObject(id3, oc);
+        TransientDocument tdoc4 = doc4.getTransientDocument();
+
+        assertEquals(tdoc3.getName(), tdoc4.getName());
+
+        ContentStream cs4 = tdoc4.getContentStream();
+        assertNotNull(cs4);
+        assertContent(buf3, readContent(cs4));
+
+        String filename4 = UUID.randomUUID().toString();
+        tdoc4.setName(filename4);
+        assertEquals(filename4, tdoc4.getName());
+
+        tdoc4.deleteContentStream();
+
+        ObjectId id4 = tdoc4.save();
+        assertNotNull(id4);
+
+        // delete object
+        Document doc5 = (Document) this.session.getObject(id4, oc);
+        TransientDocument tdoc5 = doc5.getTransientDocument();
+
+        assertEquals(filename4, tdoc5.getName());
+
+        ContentStream cs5 = tdoc4.getContentStream();
+        assertNull(cs5);
+        
+        assertEquals(false, tdoc5.isMarkedForDelete());
+        
+        tdoc5.delete(true);
+
+        assertEquals(true, tdoc5.isMarkedForDelete());       
+
+        ObjectId id5 = tdoc5.save();
+        assertNull(id5);
+        
+        // check
+        try {
+            this.session.getObject(id4, oc);
+            fail("CmisObjectNotFoundException expected!");
+        }
+        catch (CmisObjectNotFoundException e) {
+            // expected
+        }   
+    }
+
+    private byte[] readContent(ContentStream contentStream) throws Exception {
+        assertNotNull(contentStream);
+        assertNotNull(contentStream.getStream());
+
+        InputStream stream = contentStream.getStream();
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+        byte[] buffer = new byte[4096];
+        int b;
+        while ((b = stream.read(buffer)) > -1) {
+            baos.write(buffer, 0, b);
+        }
+
+        return baos.toByteArray();
+    }
+
+    private void assertContent(byte[] expected, byte[] actual) {
+        assertNotNull(expected);
+        assertNotNull(actual);
+
+        assertEquals("Content size:", expected.length, actual.length);
+
+        for (int i = 0; i < expected.length; i++) {
+            assertEquals("Content not equal.", expected[i], actual[i]);
+        }
+    }
 }

Modified: incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/misc/AbstractReadOnlyCreateSessionIT.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/misc/AbstractReadOnlyCreateSessionIT.java?rev=1034817&r1=1034816&r2=1034817&view=diff
==============================================================================
--- incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/misc/AbstractReadOnlyCreateSessionIT.java (original)
+++ incubator/chemistry/opencmis/branches/client-api-refactoring/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/misc/AbstractReadOnlyCreateSessionIT.java Sat Nov 13 17:41:36 2010
@@ -75,7 +75,6 @@ public abstract class AbstractReadOnlyCr
         SessionFactory factory = this.fixture.getSessionFactory();
 
         Hashtable<String, String> parameter = new Hashtable<String, String>(this.fixture.getParamter());
-        parameter.remove(SessionParameter.SESSION_TYPE);
 
         Session s = factory.createSession(parameter);
         Assert.assertNotNull(s);