chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fguilla...@apache.org
Subject svn commit: r888506 - in /incubator/chemistry/trunk/chemistry: chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/ chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/ chemistry-commons/src/test/java/org/apache/chem...
Date Tue, 08 Dec 2009 18:35:55 GMT
Author: fguillaume
Date: Tue Dec  8 18:35:54 2009
New Revision: 888506

URL: http://svn.apache.org/viewvc?rev=888506&view=rev
Log:
CMIS-67: don't crash on AtomPub entries with no atom:content or cmisra:content

Modified:
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleContentStream.java
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java?rev=888506&r1=888505&r2=888506&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
Tue Dec  8 18:35:54 2009
@@ -353,8 +353,9 @@
             switch (baseType) {
             case DOCUMENT:
                 String filename = (String) posted.properties.get(Property.CONTENT_STREAM_FILE_NAME);
-                ContentStream contentStream = new SimpleContentStream(
-                        posted.stream, posted.mimeType, filename);
+                ContentStream contentStream = posted.stream == null ? null
+                        : new SimpleContentStream(posted.stream,
+                                posted.mimeType, filename);
                 VersioningState versioningState = null; // TODO
                 objectId = spi.createDocument(posted.properties, folderId,
                         contentStream, versioningState);
@@ -422,8 +423,9 @@
                 if (filename == null) {
                     filename = (String) object.getValue(Property.CONTENT_STREAM_FILE_NAME);
                 }
-                ContentStream contentStream = new SimpleContentStream(
-                        put.stream, put.mimeType, filename);
+                ContentStream contentStream = put.stream == null ? null
+                        : new SimpleContentStream(put.stream, put.mimeType,
+                                filename);
                 spi.setContentStream(object, true, contentStream);
             }
 

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleContentStream.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleContentStream.java?rev=888506&r1=888505&r2=888506&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleContentStream.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleContentStream.java
Tue Dec  8 18:35:54 2009
@@ -47,8 +47,8 @@
             String filename) throws IOException {
         this.mimeType = mimeType;
         this.filename = filename;
-        bytes = getBytes(stream);
-        length = bytes.length;
+        bytes = stream == null ? null : getBytes(stream);
+        length = bytes == null ? 0 : bytes.length;
     }
 
     protected static byte[] getBytes(InputStream stream) throws IOException {
@@ -74,7 +74,7 @@
     }
 
     public InputStream getStream() {
-        return new ByteArrayInputStream(bytes);
+        return bytes == null ? null : new ByteArrayInputStream(bytes);
     }
 
 }

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java?rev=888506&r1=888505&r2=888506&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java
Tue Dec  8 18:35:54 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.chemistry.impl.simple;
 
+import java.io.InputStream;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
@@ -201,6 +202,10 @@
 
         byte[] bytes = SimpleContentStream.getBytes(cs.getStream());
         assertEquals(string, new String(bytes, "UTF-8"));
+
+        InputStream stream = null;
+        cs = new SimpleContentStream(stream, null, "empty.txt");
+        assertNull(cs.getStream());
     }
 
     public void testRemoveDocument() throws Exception {



Mime
View raw message