chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1455571 - in /chemistry/opencmis/trunk: chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/ chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/ma...
Date Tue, 12 Mar 2013 15:11:27 GMT
Author: fmui
Date: Tue Mar 12 15:11:26 2013
New Revision: 1455571

URL: http://svn.apache.org/r1455571
Log:
CMIS 1.1 AtomPub: added TCK test to build

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/ObjectServiceImpl.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/CmisAtomPubServlet.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/tck/AbstractTckIT.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/tck/AtomPubTckIT.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/tck/BrowserTckIT.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/tck/WebServicesTckIT.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/ObjectServiceImpl.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/atompub/ObjectServiceImpl.java?rev=1455571&r1=1455570&r2=1455571&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/ObjectServiceImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/ObjectServiceImpl.java
Tue Mar 12 15:11:26 2013
@@ -610,62 +610,7 @@ public class ObjectServiceImpl extends A
 
     public void setContentStream(String repositoryId, Holder<String> objectId, Boolean
overwriteFlag,
             Holder<String> changeToken, ContentStream contentStream, ExtensionsData
extension) {
-        // we need an object id
-        if ((objectId == null) || (objectId.getValue() == null)) {
-            throw new CmisInvalidArgumentException("Object ID must be set!");
-        }
-
-        // we need content
-        if ((contentStream == null) || (contentStream.getStream() == null) || (contentStream.getMimeType()
== null)) {
-            throw new CmisInvalidArgumentException("Content must be set!");
-        }
-
-        // find the link
-        String link = loadLink(repositoryId, objectId.getValue(), Constants.REL_EDITMEDIA,
null);
-
-        if (link == null) {
-            throwLinkException(repositoryId, objectId.getValue(), Constants.REL_EDITMEDIA,
null);
-        }
-
-        UrlBuilder url = new UrlBuilder(link);
-        if (changeToken != null) {
-            url.addParameter(Constants.PARAM_CHANGE_TOKEN, changeToken.getValue());
-        }
-        url.addParameter(Constants.PARAM_OVERWRITE_FLAG, overwriteFlag);
-
-        final InputStream stream = contentStream.getStream();
-
-        // Content-Disposition header for the filename
-        Map<String, String> headers = null;
-        if (contentStream.getFileName() != null) {
-            headers = Collections
-                    .singletonMap(
-                            MimeHelper.CONTENT_DISPOSITION,
-                            MimeHelper.encodeContentDisposition(MimeHelper.DISPOSITION_ATTACHMENT,
-                                    contentStream.getFileName()));
-        }
-
-        // send content
-        Response resp = put(url, contentStream.getMimeType(), headers, new Output() {
-            public void write(OutputStream out) throws Exception {
-                int b;
-                byte[] buffer = new byte[4096];
-
-                while ((b = stream.read(buffer)) > -1) {
-                    out.write(buffer, 0, b);
-                }
-            }
-        });
-
-        // check response code further
-        if ((resp.getResponseCode() != 200) && (resp.getResponseCode() != 201) &&
(resp.getResponseCode() != 204)) {
-            throw convertStatusCode(resp.getResponseCode(), resp.getResponseMessage(), resp.getErrorContent(),
null);
-        }
-
-        objectId.setValue(null);
-        if (changeToken != null) {
-            changeToken.setValue(null);
-        }
+        setOrAppendContent(repositoryId, objectId, overwriteFlag, changeToken, contentStream,
true, false, extension);
     }
 
     public void deleteContentStream(String repositoryId, Holder<String> objectId, Holder<String>
changeToken,
@@ -697,7 +642,7 @@ public class ObjectServiceImpl extends A
 
     public void appendContentStream(String repositoryId, Holder<String> objectId, Holder<String>
changeToken,
             ContentStream contentStream, boolean isLastChunk, ExtensionsData extension) {
-        throw new CmisNotSupportedException("Not supported!");
+        setOrAppendContent(repositoryId, objectId, null, changeToken, contentStream, isLastChunk,
true, extension);
     }
 
     // ---- internal ----
@@ -734,4 +679,74 @@ public class ObjectServiceImpl extends A
             }
         }
     }
+
+    /**
+     * Sets or appends content.
+     */
+    private void setOrAppendContent(String repositoryId, Holder<String> objectId, Boolean
overwriteFlag,
+            Holder<String> changeToken, ContentStream contentStream, boolean isLastChunk,
boolean append,
+            ExtensionsData extension) {
+        // we need an object id
+        if ((objectId == null) || (objectId.getValue() == null)) {
+            throw new CmisInvalidArgumentException("Object ID must be set!");
+        }
+
+        // we need content
+        if ((contentStream == null) || (contentStream.getStream() == null) || (contentStream.getMimeType()
== null)) {
+            throw new CmisInvalidArgumentException("Content must be set!");
+        }
+
+        // find the link
+        String link = loadLink(repositoryId, objectId.getValue(), Constants.REL_EDITMEDIA,
null);
+
+        if (link == null) {
+            throwLinkException(repositoryId, objectId.getValue(), Constants.REL_EDITMEDIA,
null);
+        }
+
+        UrlBuilder url = new UrlBuilder(link);
+        if (changeToken != null) {
+            url.addParameter(Constants.PARAM_CHANGE_TOKEN, changeToken.getValue());
+        }
+
+        if (append) {
+            url.addParameter(Constants.PARAM_APPEND, Boolean.TRUE);
+            url.addParameter(Constants.PARAM_IS_LAST_CHUNK, isLastChunk);
+        } else {
+            url.addParameter(Constants.PARAM_OVERWRITE_FLAG, overwriteFlag);
+        }
+
+        final InputStream stream = contentStream.getStream();
+
+        // Content-Disposition header for the filename
+        Map<String, String> headers = null;
+        if (contentStream.getFileName() != null) {
+            headers = Collections
+                    .singletonMap(
+                            MimeHelper.CONTENT_DISPOSITION,
+                            MimeHelper.encodeContentDisposition(MimeHelper.DISPOSITION_ATTACHMENT,
+                                    contentStream.getFileName()));
+        }
+
+        // send content
+        Response resp = put(url, contentStream.getMimeType(), headers, new Output() {
+            public void write(OutputStream out) throws Exception {
+                int b;
+                byte[] buffer = new byte[4096];
+
+                while ((b = stream.read(buffer)) > -1) {
+                    out.write(buffer, 0, b);
+                }
+            }
+        });
+
+        // check response code further
+        if ((resp.getResponseCode() != 200) && (resp.getResponseCode() != 201) &&
(resp.getResponseCode() != 204)) {
+            throw convertStatusCode(resp.getResponseCode(), resp.getResponseMessage(), resp.getErrorContent(),
null);
+        }
+
+        objectId.setValue(null);
+        if (changeToken != null) {
+            changeToken.setValue(null);
+        }
+    }
 }

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=1455571&r1=1455570&r2=1455571&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
Tue Mar 12 15:11:26 2013
@@ -171,6 +171,7 @@ public final class Constants {
     public static final String PARAM_ACL = "includeACL";
     public static final String PARAM_ALLOWABLE_ACTIONS = "includeAllowableActions";
     public static final String PARAM_ALL_VERSIONS = "allVersions";
+    public static final String PARAM_APPEND = "append";
     public static final String PARAM_CHANGE_LOG_TOKEN = "changeLogToken";
     public static final String PARAM_CHANGE_TOKEN = "changeToken";
     public static final String PARAM_CHECKIN_COMMENT = "checkinComment";
@@ -183,6 +184,7 @@ public final class Constants {
     public static final String PARAM_SUCCINCT = "succinct";
     public static final String PARAM_FOLDER_ID = "folderId";
     public static final String PARAM_ID = "id";
+    public static final String PARAM_IS_LAST_CHUNK = "isLastChunk";
     public static final String PARAM_MAJOR = "major";
     public static final String PARAM_MAX_ITEMS = "maxItems";
     public static final String PARAM_OBJECT_ID = "objectId";

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.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/CmisAtomPubServlet.java?rev=1455571&r1=1455570&r2=1455571&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
Tue Mar 12 15:11:26 2013
@@ -126,10 +126,6 @@ public class CmisAtomPubServlet extends 
         if (cmisVersionStr != null) {
             try {
                 cmisVersion = CmisVersion.fromValue(cmisVersionStr);
-
-                // !!! As long as CMIS 1.1 is not implemented, we have to set
-                // the CMIS version to 1.0 !!!
-                cmisVersion = CmisVersion.CMIS_1_0;
             } catch (IllegalArgumentException e) {
                 LOG.warn("CMIS version is invalid! Setting it to CMIS 1.0.");
                 cmisVersion = CmisVersion.CMIS_1_0;
@@ -169,7 +165,7 @@ public class CmisAtomPubServlet extends 
             dispatcher.addResource(RESOURCE_OBJECTBYPATH, METHOD_GET, ObjectService.class,
"getObjectByPath");
             dispatcher.addResource(RESOURCE_ALLOWABLEACIONS, METHOD_GET, ObjectService.class,
"getAllowableActions");
             dispatcher.addResource(RESOURCE_CONTENT, METHOD_GET, ObjectService.class, "getContentStream");
-            dispatcher.addResource(RESOURCE_CONTENT, METHOD_PUT, ObjectService.class, "setContentStream");
+            dispatcher.addResource(RESOURCE_CONTENT, METHOD_PUT, ObjectService.class, "setOrAppendContentStream");
             dispatcher.addResource(RESOURCE_CONTENT, METHOD_DELETE, ObjectService.class,
"deleteContentStream");
             dispatcher.addResource(RESOURCE_CHILDREN, METHOD_POST, ObjectService.class, "create");
             dispatcher.addResource(RESOURCE_RELATIONSHIPS, METHOD_POST, ObjectService.class,
"createRelationship");

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.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/ObjectService.java?rev=1455571&r1=1455570&r2=1455571&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java
Tue Mar 12 15:11:26 2013
@@ -209,14 +209,16 @@ public final class ObjectService {
     }
 
     /**
-     * Set content stream.
+     * Set or append content stream.
      */
-    public static void setContentStream(CallContext context, CmisService service, String
repositoryId,
+    public static void setOrAppendContentStream(CallContext context, CmisService service,
String repositoryId,
             HttpServletRequest request, HttpServletResponse response) throws Exception {
         // get parameters
         String objectId = getStringParameter(request, Constants.PARAM_ID);
         String changeToken = getStringParameter(request, Constants.PARAM_CHANGE_TOKEN);
+        Boolean appendFlag = getBooleanParameter(request, Constants.PARAM_APPEND);
         Boolean overwriteFlag = getBooleanParameter(request, Constants.PARAM_OVERWRITE_FLAG);
+        Boolean isLastChunk = getBooleanParameter(request, Constants.PARAM_IS_LAST_CHUNK);
 
         ContentStreamImpl contentStream = new ContentStreamImpl();
         contentStream.setStream(request.getInputStream());
@@ -235,8 +237,13 @@ public final class ObjectService {
 
         // execute
         Holder<String> objectIdHolder = new Holder<String>(objectId);
-        service.setContentStream(repositoryId, objectIdHolder, overwriteFlag, changeToken
== null ? null
-                : new Holder<String>(changeToken), contentStream, null);
+        if (Boolean.TRUE.equals(appendFlag)) {
+            service.appendContentStream(repositoryId, objectIdHolder, changeToken == null
? null : new Holder<String>(
+                    changeToken), contentStream, (Boolean.TRUE.equals(isLastChunk) ? true
: false), null);
+        } else {
+            service.setContentStream(repositoryId, objectIdHolder, overwriteFlag, changeToken
== null ? null
+                    : new Holder<String>(changeToken), contentStream, null);
+        }
 
         // set headers
         String newObjectId = (objectIdHolder.getValue() == null ? objectId : objectIdHolder.getValue());

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/tck/AbstractTckIT.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/tck/AbstractTckIT.java?rev=1455571&r1=1455570&r2=1455571&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/tck/AbstractTckIT.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/tck/AbstractTckIT.java
Tue Mar 12 15:11:26 2013
@@ -27,6 +27,7 @@ import java.util.Map;
 
 import org.apache.chemistry.opencmis.commons.SessionParameter;
 import org.apache.chemistry.opencmis.commons.enums.BindingType;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
 import org.apache.chemistry.opencmis.tck.CmisTest;
 import org.apache.chemistry.opencmis.tck.CmisTestGroup;
 import org.apache.chemistry.opencmis.tck.CmisTestProgressMonitor;
@@ -50,6 +51,8 @@ public abstract class AbstractTckIT exte
 
     public abstract BindingType getBindingType();
 
+    public abstract CmisVersion getCmisVersion();
+
     public Map<String, String> getBaseSessionParameters() {
         Map<String, String> parameters = new HashMap<String, String>();
 
@@ -77,7 +80,7 @@ public abstract class AbstractTckIT exte
 
         CmisTestReport report = new TextReport();
         report.createReport(getParameters(), getGroups(), new File(target, "tck-result-"
+ getBindingType().value()
-                + ".txt"));
+                + "-" + getCmisVersion().value() + ".txt"));
 
         // find failures
         for (CmisTestGroup group : getGroups()) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/tck/AtomPubTckIT.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/tck/AtomPubTckIT.java?rev=1455571&r1=1455570&r2=1455571&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/tck/AtomPubTckIT.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/tck/AtomPubTckIT.java
Tue Mar 12 15:11:26 2013
@@ -22,6 +22,7 @@ import java.util.Map;
 
 import org.apache.chemistry.opencmis.commons.SessionParameter;
 import org.apache.chemistry.opencmis.commons.enums.BindingType;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
 
 public class AtomPubTckIT extends AbstractTckIT {
 
@@ -43,5 +44,10 @@ public class AtomPubTckIT extends Abstra
     public BindingType getBindingType() {
         return BindingType.ATOMPUB;
     }
-
+    
+    @Override
+    public CmisVersion getCmisVersion() {
+        return CmisVersion.CMIS_1_0;
+    }
+    
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/tck/BrowserTckIT.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/tck/BrowserTckIT.java?rev=1455571&r1=1455570&r2=1455571&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/tck/BrowserTckIT.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/tck/BrowserTckIT.java
Tue Mar 12 15:11:26 2013
@@ -22,6 +22,7 @@ import java.util.Map;
 
 import org.apache.chemistry.opencmis.commons.SessionParameter;
 import org.apache.chemistry.opencmis.commons.enums.BindingType;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
 
 public class BrowserTckIT extends AbstractTckIT {
 
@@ -44,4 +45,9 @@ public class BrowserTckIT extends Abstra
         return BindingType.BROWSER;
     }
 
+    @Override
+    public CmisVersion getCmisVersion() {
+        return CmisVersion.CMIS_1_1;
+    }
+
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/tck/WebServicesTckIT.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/tck/WebServicesTckIT.java?rev=1455571&r1=1455570&r2=1455571&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/tck/WebServicesTckIT.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/tck/WebServicesTckIT.java
Tue Mar 12 15:11:26 2013
@@ -22,6 +22,7 @@ import java.util.Map;
 
 import org.apache.chemistry.opencmis.commons.SessionParameter;
 import org.apache.chemistry.opencmis.commons.enums.BindingType;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
 
 public class WebServicesTckIT extends AbstractTckIT {
 
@@ -51,4 +52,10 @@ public class WebServicesTckIT extends Ab
     public BindingType getBindingType() {
         return BindingType.WEBSERVICES;
     }
+
+    @Override
+    public CmisVersion getCmisVersion() {
+        return CmisVersion.CMIS_1_0;
+    }
+
 }



Mime
View raw message