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 2015/06/03 15:15:37 UTC

svn commit: r1683320 - in /chemistry/opencmis/trunk: chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/c...

Author: fmui
Date: Wed Jun  3 13:15:36 2015
New Revision: 1683320

URL: http://svn.apache.org/r1683320
Log:
CMIS-918: fixed applyPolicy and removePolicy (+ TCK and Workbench improvements)

Added:
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/JsonReport.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeletePolicyTest.java
Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/CmisObject.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/FormDataWriter.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/PolicyServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractCmisObject.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/CmisObjectMock.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Constants.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/PolicyService.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/AbstractBrowserServiceCall.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/PolicyService.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/TestParameters.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/TextReport.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/XmlReport.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/runner/CmisTckAntTask.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CRUDTestGroup.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteItemTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/AppendContentStreamPanel.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/ApplyPolicyPanel.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/DeleteContentStreamPanel.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/RemovePolicyPanel.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/SetContentStreamPanel.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/checks/SwingReport.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/CmisObject.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/CmisObject.java?rev=1683320&r1=1683319&r2=1683320&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/CmisObject.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/CmisObject.java Wed Jun  3 13:15:36 2015
@@ -41,6 +41,10 @@ public interface CmisObject extends Obje
     /**
      * Returns the allowable actions if they have been fetched for this object.
      * 
+     * @return the allowable actions or {@code null} if the allowable actions
+     *         have not been requested or no allowable actions are returned by
+     *         the repository
+     * 
      * @cmis 1.0
      */
     AllowableActions getAllowableActions();
@@ -64,6 +68,10 @@ public interface CmisObject extends Obje
     /**
      * Returns the relationships if they have been fetched for this object.
      * 
+     * @return the relationships to or from this object or {@code null} if the
+     *         relationships have not been requested or no relationships are
+     *         returned by the repository
+     * 
      * @cmis 1.0
      */
     List<Relationship> getRelationships();
@@ -186,6 +194,9 @@ public interface CmisObject extends Obje
     /**
      * Returns the renditions if they have been fetched for this object.
      * 
+     * @return the renditions of this object or {@code null} if the renditions
+     *         have not been requested or no renditions exist for this object
+     * 
      * @cmis 1.0
      */
     List<Rendition> getRenditions();
@@ -203,6 +214,19 @@ public interface CmisObject extends Obje
     void applyPolicy(ObjectId... policyIds);
 
     /**
+     * Applies the provided policy.
+     * 
+     * @param policyId
+     *            the ID of the policy to be applied
+     * @param refresh
+     *            {@code true} if this object should be refreshed after the
+     *            update, {@code false} if not
+     * 
+     * @cmis 1.0
+     */
+    void applyPolicy(ObjectId policyId, boolean refresh);
+
+    /**
      * Removes the provided policies and refreshes this object afterwards.
      * 
      * @param policyIds
@@ -213,8 +237,25 @@ public interface CmisObject extends Obje
     void removePolicy(ObjectId... policyIds);
 
     /**
+     * Removes the provided policy.
+     * 
+     * @param policyId
+     *            the ID of the policy to be removed
+     * @param refresh
+     *            {@code true} if this object should be refreshed after the
+     *            update, {@code false} if not
+     * 
+     * @cmis 1.0
+     */
+    void removePolicy(ObjectId policyId, boolean refresh);
+
+    /**
      * Returns the applied policies if they have been fetched for this object.
      * 
+     * @return the list of policies applied to this object or {@code null} if
+     *         the policies have not been requested or no policies are applied
+     *         to this object
+     * 
      * @cmis 1.0
      */
     List<Policy> getPolicies();

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/FormDataWriter.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/FormDataWriter.java?rev=1683320&r1=1683319&r2=1683320&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/FormDataWriter.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/FormDataWriter.java Wed Jun  3 13:15:36 2015
@@ -127,6 +127,14 @@ public final class FormDataWriter {
         }
     }
 
+    public void addPolicyIdParameter(String policyId) {
+        if (policyId == null) {
+            return;
+        }
+
+        addParameter(Constants.CONTROL_POLICY_ID, policyId);
+    }
+
     public void addAddAcesParameters(Acl acl) {
         addAcesParameters(acl, Constants.CONTROL_ADD_ACE_PRINCIPAL, Constants.CONTROL_ADD_ACE_PERMISSION);
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/PolicyServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/PolicyServiceImpl.java?rev=1683320&r1=1683319&r2=1683320&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/PolicyServiceImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/PolicyServiceImpl.java Wed Jun  3 13:15:36 2015
@@ -20,7 +20,6 @@ package org.apache.chemistry.opencmis.cl
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.Collections;
 import java.util.List;
 
 import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
@@ -52,7 +51,7 @@ public class PolicyServiceImpl extends A
 
         // prepare form data
         final FormDataWriter formData = new FormDataWriter(Constants.CMISACTION_APPLY_POLICY);
-        formData.addPoliciesParameters(Collections.singletonList(policyId));
+        formData.addPolicyIdParameter(policyId);
 
         // send
         postAndConsume(url, formData.getContentType(), new Output() {
@@ -68,7 +67,7 @@ public class PolicyServiceImpl extends A
 
         // prepare form data
         final FormDataWriter formData = new FormDataWriter(Constants.CMISACTION_REMOVE_POLICY);
-        formData.addPoliciesParameters(Collections.singletonList(policyId));
+        formData.addPolicyIdParameter(policyId);
 
         // send
         postAndConsume(url, formData.getContentType(), new Output() {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractCmisObject.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractCmisObject.java?rev=1683320&r1=1683319&r2=1683320&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractCmisObject.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractCmisObject.java Wed Jun  3 13:15:36 2015
@@ -139,6 +139,8 @@ public abstract class AbstractCmisObject
                     }
                 }
             }
+        } else {
+            secondaryTypes = null;
         }
 
         // handle properties
@@ -147,16 +149,20 @@ public abstract class AbstractCmisObject
 
         // handle allowable actions
         if (objectData.getAllowableActions() != null) {
-            this.allowableActions = objectData.getAllowableActions();
+            allowableActions = objectData.getAllowableActions();
             extensions.put(ExtensionLevel.ALLOWABLE_ACTIONS, objectData.getAllowableActions().getExtensions());
+        } else {
+            allowableActions = null;
         }
 
         // handle renditions
-        if (objectData.getRenditions() != null) {
-            this.renditions = new ArrayList<Rendition>();
+        if (objectData.getRenditions() != null && !objectData.getRenditions().isEmpty()) {
+            renditions = new ArrayList<Rendition>();
             for (RenditionData rd : objectData.getRenditions()) {
-                this.renditions.add(of.convertRendition(getId(), rd));
+                renditions.add(of.convertRendition(getId(), rd));
             }
+        } else {
+            renditions = null;
         }
 
         // handle ACL
@@ -190,22 +196,30 @@ public abstract class AbstractCmisObject
                     }
                 };
             }
+        } else {
+            acl = null;
         }
 
         // handle policies
-        if ((objectData.getPolicyIds() != null) && (objectData.getPolicyIds().getPolicyIds() != null)) {
-            policies = new ArrayList<Policy>();
-            for (String pid : objectData.getPolicyIds().getPolicyIds()) {
-                CmisObject policy = session.getObject(pid);
-                if (policy instanceof Policy) {
-                    policies.add((Policy) policy);
+        if (objectData.getPolicyIds() != null && objectData.getPolicyIds().getPolicyIds() != null) {
+            if (objectData.getPolicyIds().getPolicyIds().isEmpty()) {
+                policies = null;
+            } else {
+                policies = new ArrayList<Policy>();
+                for (String pid : objectData.getPolicyIds().getPolicyIds()) {
+                    CmisObject policy = session.getObject(pid);
+                    if (policy instanceof Policy) {
+                        policies.add((Policy) policy);
+                    }
                 }
             }
             extensions.put(ExtensionLevel.POLICIES, objectData.getPolicyIds().getExtensions());
+        } else {
+            policies = null;
         }
 
         // handle relationships
-        if (objectData.getRelationships() != null) {
+        if (objectData.getRelationships() != null && !objectData.getRelationships().isEmpty()) {
             relationships = new ArrayList<Relationship>();
             for (ObjectData rod : objectData.getRelationships()) {
                 CmisObject relationship = of.convertObject(rod, this.creationContext);
@@ -213,6 +227,8 @@ public abstract class AbstractCmisObject
                     relationships.add((Relationship) relationship);
                 }
             }
+        } else {
+            relationships = null;
         }
 
         extensions.put(ExtensionLevel.OBJECT, objectData.getExtensions());
@@ -518,7 +534,7 @@ public abstract class AbstractCmisObject
     public List<SecondaryType> getSecondaryTypes() {
         readLock();
         try {
-            return this.secondaryTypes;
+            return secondaryTypes;
         } finally {
             readUnlock();
         }
@@ -621,7 +637,7 @@ public abstract class AbstractCmisObject
     public Acl getAcl() {
         readLock();
         try {
-            return this.acl;
+            return acl;
         } finally {
             readUnlock();
         }
@@ -670,6 +686,19 @@ public abstract class AbstractCmisObject
         refresh();
     }
 
+    public void applyPolicy(ObjectId policyId, boolean refresh) {
+        readLock();
+        try {
+            getSession().applyPolicy(this, policyId);
+        } finally {
+            readUnlock();
+        }
+
+        if (refresh) {
+            refresh();
+        }
+    }
+
     public void removePolicy(ObjectId... policyIds) {
         readLock();
         try {
@@ -681,10 +710,23 @@ public abstract class AbstractCmisObject
         refresh();
     }
 
+    public void removePolicy(ObjectId policyId, boolean refresh) {
+        readLock();
+        try {
+            getSession().removePolicy(this, policyId);
+        } finally {
+            readUnlock();
+        }
+
+        if (refresh) {
+            refresh();
+        }
+    }
+
     public List<Policy> getPolicies() {
         readLock();
         try {
-            return this.policies;
+            return policies;
         } finally {
             readUnlock();
         }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/CmisObjectMock.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/CmisObjectMock.java?rev=1683320&r1=1683319&r2=1683320&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/CmisObjectMock.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/CmisObjectMock.java Wed Jun  3 13:15:36 2015
@@ -220,12 +220,17 @@ public class CmisObjectMock implements C
     }
 
     public void applyPolicy(ObjectId... policyIds) {
+    }
 
+    public void applyPolicy(ObjectId policyId, boolean refresh) {
     }
 
     public void removePolicy(ObjectId... policyIds) {
     }
 
+    public void removePolicy(ObjectId policyId, boolean refresh) {
+    }
+
     public String getId() {
         return this.id;
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Constants.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Constants.java?rev=1683320&r1=1683319&r2=1683320&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Constants.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Constants.java Wed Jun  3 13:15:36 2015
@@ -148,6 +148,7 @@ public final class Constants {
     public static final String CONTROL_PROP_ID = "propertyId";
     public static final String CONTROL_PROP_VALUE = "propertyValue";
     public static final String CONTROL_POLICY = "policy";
+    public static final String CONTROL_POLICY_ID = "policyId";
     public static final String CONTROL_ADD_ACE_PRINCIPAL = "addACEPrincipal";
     public static final String CONTROL_ADD_ACE_PERMISSION = "addACEPermission";
     public static final String CONTROL_REMOVE_ACE_PRINCIPAL = "removeACEPrincipal";

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/PolicyService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/PolicyService.java?rev=1683320&r1=1683319&r2=1683320&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/PolicyService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/PolicyService.java Wed Jun  3 13:15:36 2015
@@ -173,30 +173,28 @@ public class PolicyService {
                 parser.release();
             }
 
-            ObjectInfo objectInfo = service.getObjectInfo(repositoryId, parser.getId());
+            ObjectInfo objectInfo = service.getObjectInfo(repositoryId, objectId);
             if (objectInfo == null) {
                 throw new CmisRuntimeException("Object Info is missing!");
             }
 
-            ObjectData policy = objectInfo.getObject();
-            if (policy == null) {
-                throw new CmisRuntimeException("Policy is null!");
+            ObjectData object = objectInfo.getObject();
+            if (object == null) {
+                throw new CmisRuntimeException("Object is null!");
             }
 
             // set headers
             UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
-            UrlBuilder location = compileUrlBuilder(baseUrl, RESOURCE_POLICIES, objectId);
-            location.addParameter(Constants.PARAM_POLICY_ID, policy.getId());
 
             response.setStatus(HttpServletResponse.SC_CREATED);
             response.setContentType(Constants.MEDIATYPE_ENTRY);
-            response.setHeader("Content-Location", location.toString());
-            response.setHeader("Location", location.toString());
+            response.setHeader("Location", compileUrl(baseUrl, RESOURCE_ENTRY, object.getId()));
 
             // write XML
             AtomEntry entry = new AtomEntry();
             entry.startDocument(response.getOutputStream(), getNamespaces(service));
-            writePolicyEntry(service, entry, objectId, policy, repositoryId, baseUrl, context.getCmisVersion());
+            writeObjectEntry(service, entry, object, null, repositoryId, null, null, baseUrl, true,
+                    context.getCmisVersion());
             entry.endDocument();
         }
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/AbstractBrowserServiceCall.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/AbstractBrowserServiceCall.java?rev=1683320&r1=1683319&r2=1683320&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/AbstractBrowserServiceCall.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/AbstractBrowserServiceCall.java Wed Jun  3 13:15:36 2015
@@ -18,7 +18,7 @@
  */
 package org.apache.chemistry.opencmis.server.impl.browser;
 
-import static org.apache.chemistry.opencmis.commons.impl.CollectionsHelper.*;
+import static org.apache.chemistry.opencmis.commons.impl.CollectionsHelper.isNotEmpty;
 
 import java.io.IOException;
 import java.io.PrintWriter;
@@ -467,4 +467,8 @@ public abstract class AbstractBrowserSer
 
         return result;
     }
+
+    public String getPolicyId(ControlParser controlParser) {
+        return controlParser.getValue(Constants.CONTROL_POLICY_ID);
+    }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/PolicyService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/PolicyService.java?rev=1683320&r1=1683319&r2=1683320&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/PolicyService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/PolicyService.java Wed Jun  3 13:15:36 2015
@@ -19,7 +19,6 @@
 package org.apache.chemistry.opencmis.server.impl.browser;
 
 import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_FILTER;
-import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_POLICY_ID;
 
 import java.util.List;
 
@@ -99,11 +98,13 @@ public class PolicyService {
 
             // get parameters
             String objectId = ((BrowserCallContextImpl) context).getObjectId();
-            String policyId = getStringParameter(request, PARAM_POLICY_ID);
             boolean succinct = getBooleanParameter(request, Constants.CONTROL_SUCCINCT, false);
             DateTimeFormat dateTimeFormat = getDateTimeFormatParameter(request);
 
             // execute
+            ControlParser cp = new ControlParser(request);
+            String policyId = getPolicyId(cp);
+
             if (stopBeforeService(service)) {
                 return;
             }
@@ -144,13 +145,23 @@ public class PolicyService {
 
             // get parameters
             String objectId = ((BrowserCallContextImpl) context).getObjectId();
-            String policyId = getStringParameter(request, PARAM_POLICY_ID);
             boolean succinct = getBooleanParameter(request, Constants.CONTROL_SUCCINCT, false);
             DateTimeFormat dateTimeFormat = getDateTimeFormatParameter(request);
 
             // execute
+            ControlParser cp = new ControlParser(request);
+            String policyId = getPolicyId(cp);
+
+            if (stopBeforeService(service)) {
+                return;
+            }
+
             service.removePolicy(repositoryId, policyId, objectId, null);
 
+            if (stopAfterService(service)) {
+                return;
+            }
+
             ObjectData object = getSimpleObject(service, repositoryId, objectId);
             if (object == null) {
                 throw new CmisRuntimeException("Object is null!");

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java?rev=1683320&r1=1683319&r2=1683320&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java Wed Jun  3 13:15:36 2015
@@ -205,6 +205,24 @@ public abstract class AbstractSessionTes
         return objectTypeId;
     }
 
+    protected String getRelationshipTestTypeId() {
+        String objectTypeId = getParameters().get(TestParameters.DEFAULT_RELATIONSHIP_TYPE);
+        if (objectTypeId == null) {
+            objectTypeId = TestParameters.DEFAULT_RELATIONSHIP_TYPE_VALUE;
+        }
+
+        return objectTypeId;
+    }
+
+    protected String getPolicyTestTypeId() {
+        String objectTypeId = getParameters().get(TestParameters.DEFAULT_POLICY_TYPE);
+        if (objectTypeId == null) {
+            objectTypeId = TestParameters.DEFAULT_POLICY_TYPE_VALUE;
+        }
+
+        return objectTypeId;
+    }
+
     protected String getItemTestTypeId() {
         String objectTypeId = getParameters().get(TestParameters.DEFAULT_ITEM_TYPE);
         if (objectTypeId == null) {
@@ -534,11 +552,7 @@ public abstract class AbstractSessionTes
      * Creates a relationship.
      */
     protected Relationship createRelationship(Session session, String name, ObjectId source, ObjectId target) {
-        String objectTypeId = getParameters().get(TestParameters.DEFAULT_RELATIONSHIP_TYPE);
-        if (objectTypeId == null) {
-            objectTypeId = TestParameters.DEFAULT_RELATIONSHIP_TYPE_VALUE;
-        }
-
+        String objectTypeId = getRelationshipTestTypeId();
         return createRelationship(session, name, source, target, objectTypeId);
     }
 
@@ -601,6 +615,105 @@ public abstract class AbstractSessionTes
     }
 
     /**
+     * Creates a policy.
+     */
+    protected Policy createPolicy(Session session, Folder parent, String name, String policyText) {
+        return createPolicy(session, parent, name, policyText, getPolicyTestTypeId());
+    }
+
+    /**
+     * Creates a policy.
+     */
+    protected Policy createPolicy(Session session, Folder parent, String name, String policyText, String objectTypeId) {
+        if (parent == null) {
+            throw new IllegalArgumentException("Parent is not set!");
+        }
+        if (name == null) {
+            throw new IllegalArgumentException("Name is not set!");
+        }
+        if (objectTypeId == null) {
+            throw new IllegalArgumentException("Object Type ID is not set!");
+        }
+
+        // check type
+        ObjectType type;
+        try {
+            type = session.getTypeDefinition(objectTypeId);
+        } catch (CmisObjectNotFoundException e) {
+            addResult(createResult(UNEXPECTED_EXCEPTION,
+                    "Policy type '" + objectTypeId + "' is not available: " + e.getMessage(), e, true));
+            return null;
+        }
+
+        if (Boolean.FALSE.equals(type.isCreatable())) {
+            addResult(createResult(SKIPPED, "Policy type '" + objectTypeId + "' is not creatable!", true));
+            return null;
+        }
+
+        boolean isFilable = Boolean.TRUE.equals(type.isFileable());
+
+        addResult(createResult(INFO, "Policy type '" + objectTypeId + "' is " + (isFilable ? "" : "not ") + "filable."));
+
+        // create
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(PropertyIds.NAME, name);
+        properties.put(PropertyIds.OBJECT_TYPE_ID, objectTypeId);
+        if (policyText != null) {
+            properties.put(PropertyIds.POLICY_TEXT, policyText);
+        }
+
+        Policy result = null;
+        try {
+            // create the item
+            if (isFilable) {
+                result = parent.createPolicy(properties, null, null, null, SELECT_ALL_NO_CACHE_OC);
+            } else {
+                ObjectId policyId = session.createPolicy(properties, null, null, null, null);
+                result = (Policy) session.getObject(policyId, SELECT_ALL_NO_CACHE_OC);
+            }
+        } catch (CmisBaseException e) {
+            addResult(createResult(UNEXPECTED_EXCEPTION, "Policy could not be created! Exception: " + e.getMessage(),
+                    e, true));
+            return null;
+        }
+
+        CmisTestResult f;
+        try {
+            // check item name
+            f = createResult(FAILURE, "Policy name does not match!", false);
+            addResult(assertEquals(name, result.getName(), null, f));
+
+            addResult(checkObject(session, result, getAllProperties(result), "New policy object spec compliance"));
+        } catch (CmisBaseException e) {
+            addResult(createResult(UNEXPECTED_EXCEPTION,
+                    "Newly created policy is invalid! Exception: " + e.getMessage(), e, true));
+        }
+
+        // check parents
+        List<Folder> parents = result.getParents(SELECT_ALL_NO_CACHE_OC);
+
+        if (isFilable) {
+            boolean found = false;
+            for (Folder folder : parents) {
+                if (parent.getId().equals(folder.getId())) {
+                    found = true;
+                    break;
+                }
+            }
+
+            if (!found) {
+                addResult(createResult(FAILURE,
+                        "The folder the item has been created in is not in the list of the item parents!"));
+            }
+        } else {
+            f = createResult(FAILURE, "Policy is not filable but has a parent!", false);
+            addResult(assertIsTrue(parents.isEmpty(), null, f));
+        }
+
+        return result;
+    }
+
+    /**
      * Creates a item.
      */
     protected Item createItem(Session session, Folder parent, String name) {
@@ -660,7 +773,7 @@ public abstract class AbstractSessionTes
 
             addResult(checkObject(session, result, getAllProperties(result), "New item object spec compliance"));
         } catch (CmisBaseException e) {
-            addResult(createResult(UNEXPECTED_EXCEPTION, "Newly created Item is invalid! Exception: " + e.getMessage(),
+            addResult(createResult(UNEXPECTED_EXCEPTION, "Newly created item is invalid! Exception: " + e.getMessage(),
                     e, true));
         }
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/TestParameters.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/TestParameters.java?rev=1683320&r1=1683319&r2=1683320&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/TestParameters.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/TestParameters.java Wed Jun  3 13:15:36 2015
@@ -29,6 +29,9 @@ public final class TestParameters {
     public static final String DEFAULT_RELATIONSHIP_TYPE = "org.apache.chemistry.opencmis.tck.default.relationshipType";
     public static final String DEFAULT_RELATIONSHIP_TYPE_VALUE = "cmis:relationship";
 
+    public static final String DEFAULT_POLICY_TYPE = "org.apache.chemistry.opencmis.tck.default.policyType";
+    public static final String DEFAULT_POLICY_TYPE_VALUE = "cmis:policy";
+
     public static final String DEFAULT_ITEM_TYPE = "org.apache.chemistry.opencmis.tck.default.itemType";
     public static final String DEFAULT_ITEM_TYPE_VALUE = "cmis:item";
 

Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/JsonReport.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/JsonReport.java?rev=1683320&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/JsonReport.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/JsonReport.java Wed Jun  3 13:15:36 2015
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.tck.report;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
+import org.apache.chemistry.opencmis.commons.impl.json.JSONArray;
+import org.apache.chemistry.opencmis.commons.impl.json.JSONObject;
+import org.apache.chemistry.opencmis.tck.CmisTest;
+import org.apache.chemistry.opencmis.tck.CmisTestGroup;
+import org.apache.chemistry.opencmis.tck.CmisTestResult;
+import org.apache.chemistry.opencmis.tck.CmisTestResultStatus;
+
+/**
+ * JSON Report.
+ */
+public class JsonReport extends AbstractCmisTestReport {
+
+    public JsonReport() {
+    }
+
+    @Override
+    public void createReport(Map<String, String> parameters, List<CmisTestGroup> groups, Writer writer)
+            throws IOException {
+
+        JSONObject jsonReport = new JSONObject();
+
+        JSONObject jsonParameters = new JSONObject();
+        jsonReport.put("parameters", jsonParameters);
+
+        if (parameters != null) {
+            for (Map.Entry<String, String> p : (new TreeMap<String, String>(parameters)).entrySet()) {
+                jsonParameters.put(p.getKey(), p.getValue());
+            }
+        }
+
+        if (groups != null) {
+            JSONArray jsonGroups = new JSONArray();
+            jsonReport.put("groups", jsonGroups);
+
+            for (CmisTestGroup group : groups) {
+                printGroupResults(group, jsonGroups);
+            }
+        }
+
+        jsonReport.writeJSONString(writer);
+        writer.flush();
+    }
+
+    private void printGroupResults(CmisTestGroup group, JSONArray jsonGroups) throws IOException {
+        if (!group.isEnabled()) {
+            return;
+        }
+
+        JSONObject jsonGroup = new JSONObject();
+        jsonGroups.add(jsonGroup);
+
+        jsonGroup.put("name", group.getName());
+
+        if (group.getTests() != null && !group.getTests().isEmpty()) {
+            JSONArray jsonTests = new JSONArray();
+            jsonGroup.put("tests", jsonTests);
+
+            for (CmisTest test : group.getTests()) {
+                printTestResults(test, jsonTests);
+            }
+        }
+    }
+
+    private void printTestResults(CmisTest test, JSONArray jsonTests) throws IOException {
+        if (!test.isEnabled()) {
+            return;
+        }
+
+        JSONObject jsonTest = new JSONObject();
+        jsonTests.add(jsonTest);
+
+        jsonTest.put("name", test.getName());
+        jsonTest.put("time", test.getTime());
+
+        if (test.getResults() != null && !test.getResults().isEmpty()) {
+            JSONArray jsonResults = new JSONArray();
+            jsonTest.put("results", jsonResults);
+
+            for (CmisTestResult result : test.getResults()) {
+                printResult(result, jsonResults);
+            }
+        }
+    }
+
+    private void printResult(CmisTestResult result, JSONArray results) throws IOException {
+        JSONObject jsonResult = new JSONObject();
+        results.add(jsonResult);
+
+        jsonResult.put("status", result.getStatus().toString());
+        jsonResult.put("message", result.getMessage());
+
+        if (result.getStackTrace() != null && result.getStackTrace().length > 0) {
+            jsonResult.put("file",
+                    result.getStackTrace()[0].getFileName() + ":" + result.getStackTrace()[0].getLineNumber());
+        }
+
+        if (result.getStatus() == CmisTestResultStatus.UNEXPECTED_EXCEPTION && result.getException() != null) {
+            StringWriter sw = new StringWriter();
+            PrintWriter pw = new PrintWriter(sw);
+            result.getException().printStackTrace(pw);
+
+            jsonResult.put("stacktrace", sw.toString());
+
+            if (result.getException() instanceof CmisBaseException) {
+                CmisBaseException cbe = (CmisBaseException) result.getException();
+                if (cbe.getErrorContent() != null) {
+                    jsonResult.put("errorcontent", cbe.getErrorContent());
+                }
+            }
+        }
+
+        if (result.getException() != null) {
+            jsonResult.put("exception", result.getException().getMessage());
+        }
+
+        if (result.getRequest() != null) {
+            jsonResult.put("request", result.getRequest());
+        }
+
+        if (result.getRequest() != null) {
+            jsonResult.put("response", result.getResponse());
+        }
+
+        if (!result.getChildren().isEmpty()) {
+            JSONArray nextLevel = new JSONArray();
+            jsonResult.put("results", nextLevel);
+
+            for (CmisTestResult child : result.getChildren()) {
+                printResult(child, nextLevel);
+            }
+        }
+    }
+}

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/TextReport.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/TextReport.java?rev=1683320&r1=1683319&r2=1683320&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/TextReport.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/TextReport.java Wed Jun  3 13:15:36 2015
@@ -39,7 +39,6 @@ public class TextReport extends Abstract
     public static final String NL = System.getProperty("line.separator");
 
     public TextReport() {
-
     }
 
     @Override
@@ -104,7 +103,7 @@ public class TextReport extends Abstract
         printIntend(level, writer);
         writer.write(result.getStatus() + ": " + result.getMessage());
 
-        if ((result.getStackTrace() != null) && (result.getStackTrace().length > 0)) {
+        if (result.getStackTrace() != null && result.getStackTrace().length > 0) {
             writer.write(" (" + result.getStackTrace()[0].getFileName() + ":"
                     + result.getStackTrace()[0].getLineNumber() + ")");
         }
@@ -134,9 +133,9 @@ public class TextReport extends Abstract
             writer.write("Request: " + result.getRequest() + NL);
         }
 
-        if (result.getRequest() != null) {
+        if (result.getResponse() != null) {
             printIntend(level, writer);
-            writer.write("Response: " + result.getRequest() + NL);
+            writer.write("Response: " + result.getResponse() + NL);
         }
 
         for (CmisTestResult child : result.getChildren()) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/XmlReport.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/XmlReport.java?rev=1683320&r1=1683319&r2=1683320&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/XmlReport.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/XmlReport.java Wed Jun  3 13:15:36 2015
@@ -114,7 +114,7 @@ public class XmlReport extends AbstractC
 
         xml.writeStartElement(TAG_TEST);
         xml.writeAttribute(ATTR_NAME, test.getName());
-        xml.writeAttribute(ATTR_TIME, "" + test.getTime());
+        xml.writeAttribute(ATTR_TIME, String.valueOf(test.getTime()));
 
         if (test.getResults() != null) {
             for (CmisTestResult result : test.getResults()) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/runner/CmisTckAntTask.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/runner/CmisTckAntTask.java?rev=1683320&r1=1683319&r2=1683320&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/runner/CmisTckAntTask.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/runner/CmisTckAntTask.java Wed Jun  3 13:15:36 2015
@@ -26,6 +26,7 @@ import org.apache.chemistry.opencmis.tck
 import org.apache.chemistry.opencmis.tck.CmisTestProgressMonitor;
 import org.apache.chemistry.opencmis.tck.CmisTestReport;
 import org.apache.chemistry.opencmis.tck.report.HtmlReport;
+import org.apache.chemistry.opencmis.tck.report.JsonReport;
 import org.apache.chemistry.opencmis.tck.report.TextReport;
 import org.apache.chemistry.opencmis.tck.report.XmlReport;
 import org.apache.tools.ant.BuildException;
@@ -39,6 +40,7 @@ public class CmisTckAntTask extends Task
     private static final String REPORT_TEXT = "text";
     private static final String REPORT_XML = "xml";
     private static final String REPORT_HTML = "html";
+    private static final String REPORT_JSON = "json";
 
     private static final String DEFAULT_REPORT_NAME = "cmis-tck-report";
 
@@ -108,6 +110,11 @@ public class CmisTckAntTask extends Task
                     if (output == null) {
                         output = new File(DEFAULT_REPORT_NAME + ".xml");
                     }
+                } else if (REPORT_JSON.equals(format)) {
+                    report = new JsonReport();
+                    if (output == null) {
+                        output = new File(DEFAULT_REPORT_NAME + ".json");
+                    }
                 } else if (REPORT_HTML.equals(format)) {
                     report = new HtmlReport();
                     if (output == null) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CRUDTestGroup.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CRUDTestGroup.java?rev=1683320&r1=1683319&r2=1683320&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CRUDTestGroup.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CRUDTestGroup.java Wed Jun  3 13:15:36 2015
@@ -41,6 +41,7 @@ public class CRUDTestGroup extends Abstr
         addTest(new NameCharsetTest());
         addTest(new WhitespaceInNameTest());
         addTest(new CreateAndDeleteRelationshipTest());
+        addTest(new CreateAndDeletePolicyTest());
         addTest(new CreateAndDeleteItemTest());
         addTest(new PropertyFilterTest());
         addTest(new UpdateSmokeTest());

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteItemTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteItemTest.java?rev=1683320&r1=1683319&r2=1683320&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteItemTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteItemTest.java Wed Jun  3 13:15:36 2015
@@ -44,7 +44,7 @@ public class CreateAndDeleteItemTest ext
     public void init(Map<String, String> parameters) {
         super.init(parameters);
         setName("Create and Delete Item Test");
-        setDescription("Creates a few items, checks the newly created itens and their parent and finally deletes the created item.");
+        setDescription("Creates a few items, checks the newly created items and their parent and finally deletes the created items.");
     }
 
     @Override

Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeletePolicyTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeletePolicyTest.java?rev=1683320&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeletePolicyTest.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeletePolicyTest.java Wed Jun  3 13:15:36 2015
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.tck.tests.crud;
+
+import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.FAILURE;
+import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.SKIPPED;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.chemistry.opencmis.client.api.Document;
+import org.apache.chemistry.opencmis.client.api.Folder;
+import org.apache.chemistry.opencmis.client.api.Policy;
+import org.apache.chemistry.opencmis.client.api.Session;
+import org.apache.chemistry.opencmis.commons.data.ObjectData;
+import org.apache.chemistry.opencmis.tck.CmisTestResult;
+import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
+
+/**
+ * Simple folder test.
+ */
+public class CreateAndDeletePolicyTest extends AbstractSessionTest {
+
+    @Override
+    public void init(Map<String, String> parameters) {
+        super.init(parameters);
+        setName("Create and Delete Policy Test");
+        setDescription("Creates a policy object, checks the newly created policy object, applys and removes it from a document, and finally deletes the created policy object.");
+    }
+
+    @Override
+    public void run(Session session) {
+
+        if (hasPolicies(session)) {
+            CmisTestResult f;
+
+            // create a test folder
+            Folder testFolder = createTestFolder(session);
+
+            try {
+                // create policy object
+                Policy policy = createPolicy(session, testFolder, "testPolicy", "TCK Test Policy");
+
+                // create document and apply policy
+                Document doc = createDocument(session, testFolder, "testDocument", "Policy Test");
+                doc.applyPolicy(policy);
+
+                // check if policy has been applied
+                List<Policy> policies1 = doc.getPolicies();
+                boolean found1 = false;
+                for (Policy p : policies1) {
+                    if (p.getId().equals(policy.getId())) {
+                        found1 = true;
+                        break;
+                    }
+                }
+
+                f = createResult(FAILURE, "Policy has not been applied to document! Policy Id: " + policy.getId()
+                        + ", Doc Id: " + doc.getId());
+                addResult(assertIsTrue(found1, null, f));
+
+                // get the policies
+                List<ObjectData> policiesData2 = session.getBinding().getPolicyService()
+                        .getAppliedPolicies(session.getRepositoryInfo().getId(), doc.getId(), "*", null);
+
+                boolean found2 = false;
+                if (policiesData2 != null && !policiesData2.isEmpty()) {
+                    for (ObjectData p : policiesData2) {
+                        if (p.getId().equals(policy.getId())) {
+                            found2 = true;
+                            break;
+                        }
+                    }
+                }
+
+                f = createResult(FAILURE,
+                        "Applied policy is not returned by the repository! Policy Id: " + policy.getId() + ", Doc Id: "
+                                + doc.getId());
+                addResult(assertIsTrue(found2, null, f));
+
+                // remove policy
+                doc.removePolicy(policy);
+
+                // check if policy has been applied
+                List<Policy> policies3 = doc.getPolicies();
+                if (policies3 != null) {
+                    boolean found3 = false;
+                    for (Policy p : policies3) {
+                        if (p.getId().equals(policy.getId())) {
+                            found3 = true;
+                            break;
+                        }
+                    }
+
+                    f = createResult(FAILURE, "Policy has not been removed from document! Policy Id: " + policy.getId()
+                            + ", Doc Id: " + doc.getId());
+                    addResult(assertIsFalse(found3, null, f));
+                }
+
+                // delete document
+                deleteObject(doc);
+
+                // delete policy object
+                deleteObject(policy);
+
+            } finally {
+                // delete the test folder
+                deleteTestFolder();
+            }
+        } else {
+            addResult(createResult(SKIPPED, "Policies not supported. Test skipped!"));
+        }
+    }
+}

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java?rev=1683320&r1=1683319&r2=1683320&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java Wed Jun  3 13:15:36 2015
@@ -210,6 +210,10 @@ public class TckDialog {
                     BaseTypeId.CMIS_RELATIONSHIP.value(), TestParameters.DEFAULT_RELATIONSHIP_TYPE_VALUE, true);
             configPanel.add(Box.createRigidArea(WorkbenchScale.scaleDimension(new Dimension(1, 10))));
 
+            final JComboBox<String> policyComboBox = addComboBox(configPanel, "Test policy type:",
+                    BaseTypeId.CMIS_POLICY.value(), TestParameters.DEFAULT_POLICY_TYPE_VALUE, true);
+            configPanel.add(Box.createRigidArea(WorkbenchScale.scaleDimension(new Dimension(1, 10))));
+
             final JComboBox<String> itemComboBox = addComboBox(configPanel, "Test item type:",
                     BaseTypeId.CMIS_ITEM.value(), TestParameters.DEFAULT_ITEM_TYPE_VALUE, true);
             configPanel.add(Box.createRigidArea(WorkbenchScale.scaleDimension(new Dimension(1, 10))));
@@ -256,6 +260,10 @@ public class TckDialog {
                             parameters.put(TestParameters.DEFAULT_RELATIONSHIP_TYPE,
                                     (String) relationshipComboBox.getSelectedItem());
                         }
+                        if (policyComboBox.isEnabled()) {
+                            parameters.put(TestParameters.DEFAULT_POLICY_TYPE,
+                                    (String) policyComboBox.getSelectedItem());
+                        }
                         if (itemComboBox.isEnabled()) {
                             parameters.put(TestParameters.DEFAULT_ITEM_TYPE, (String) itemComboBox.getSelectedItem());
                         }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/AppendContentStreamPanel.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/AppendContentStreamPanel.java?rev=1683320&r1=1683319&r2=1683320&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/AppendContentStreamPanel.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/AppendContentStreamPanel.java Wed Jun  3 13:15:36 2015
@@ -74,7 +74,7 @@ public class AppendContentStreamPanel ex
         ContentStream content = getClientModel().createContentStream(filenameField.getText());
 
         try {
-            ((Document) getObject()).appendContentStream(content, isLastChunkBox.isSelected());
+            ((Document) getObject()).appendContentStream(content, isLastChunkBox.isSelected(), false);
         } finally {
             IOUtils.closeQuietly(content);
         }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/ApplyPolicyPanel.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/ApplyPolicyPanel.java?rev=1683320&r1=1683319&r2=1683320&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/ApplyPolicyPanel.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/ApplyPolicyPanel.java Wed Jun  3 13:15:36 2015
@@ -69,7 +69,7 @@ public class ApplyPolicyPanel extends Ac
 
     @Override
     public boolean doAction() {
-        getObject().applyPolicy(new ObjectIdImpl(policyField.getText()));
+        getObject().applyPolicy(new ObjectIdImpl(policyField.getText()), false);
         return true;
     }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/DeleteContentStreamPanel.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/DeleteContentStreamPanel.java?rev=1683320&r1=1683319&r2=1683320&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/DeleteContentStreamPanel.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/DeleteContentStreamPanel.java Wed Jun  3 13:15:36 2015
@@ -51,7 +51,7 @@ public class DeleteContentStreamPanel ex
 
     @Override
     public boolean doAction() {
-        ((Document) getObject()).deleteContentStream();
+        ((Document) getObject()).deleteContentStream(false);
         return true;
     }
 }
\ No newline at end of file

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/RemovePolicyPanel.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/RemovePolicyPanel.java?rev=1683320&r1=1683319&r2=1683320&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/RemovePolicyPanel.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/RemovePolicyPanel.java Wed Jun  3 13:15:36 2015
@@ -69,7 +69,7 @@ public class RemovePolicyPanel extends A
 
     @Override
     public boolean doAction() {
-        getObject().removePolicy(new ObjectIdImpl(policyField.getText()));
+        getObject().removePolicy(new ObjectIdImpl(policyField.getText()), false);
         return true;
     }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/SetContentStreamPanel.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/SetContentStreamPanel.java?rev=1683320&r1=1683319&r2=1683320&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/SetContentStreamPanel.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/SetContentStreamPanel.java Wed Jun  3 13:15:36 2015
@@ -69,7 +69,7 @@ public class SetContentStreamPanel exten
         ContentStream content = getClientModel().createContentStream(filenameField.getText());
 
         try {
-            ((Document) getObject()).setContentStream(content, overwriteBox.isSelected());
+            ((Document) getObject()).setContentStream(content, overwriteBox.isSelected(), false);
         } finally {
             if (content != null) {
                 IOUtils.closeQuietly(content);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/checks/SwingReport.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/checks/SwingReport.java?rev=1683320&r1=1683319&r2=1683320&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/checks/SwingReport.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/checks/SwingReport.java Wed Jun  3 13:15:36 2015
@@ -52,6 +52,7 @@ import org.apache.chemistry.opencmis.tck
 import org.apache.chemistry.opencmis.tck.CmisTestResult;
 import org.apache.chemistry.opencmis.tck.report.AbstractCmisTestReport;
 import org.apache.chemistry.opencmis.tck.report.HtmlReport;
+import org.apache.chemistry.opencmis.tck.report.JsonReport;
 import org.apache.chemistry.opencmis.tck.report.TextReport;
 import org.apache.chemistry.opencmis.tck.report.XmlReport;
 import org.apache.chemistry.opencmis.workbench.ClientHelper;
@@ -138,7 +139,7 @@ public class SwingReport extends Abstrac
 
             final JPanel reportPanel = new JPanel();
             reportPanel.add(new JLabel("Open report as "));
-            final JComboBox<String> reportType = new JComboBox<String>(new String[] { "HTML", "Text", "XML" });
+            final JComboBox<String> reportType = new JComboBox<String>(new String[] { "HTML", "Text", "XML", "JSON" });
             reportPanel.add(reportType);
             final JButton reportButton = new JButton("go");
             reportPanel.add(reportButton);
@@ -159,6 +160,10 @@ public class SwingReport extends Abstrac
                             tempReportFile = File.createTempFile("cmistck", ".xml");
                             report = new XmlReport();
                             break;
+                        case 3:
+                            tempReportFile = File.createTempFile("cmistck", ".json");
+                            report = new JsonReport();
+                            break;
                         default:
                             tempReportFile = File.createTempFile("cmistck", ".html");
                             report = new HtmlReport();