Author: jens
Date: Tue Jun 22 08:26:40 2010
New Revision: 956812

URL: http://svn.apache.org/viewvc?rev=956812&view=rev
Log:
InMemoryServer: Fix exception type on getContent() if document has no content

Modified:
    
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
    
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java

Modified: 
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java?rev=956812&r1=956811&r2=956812&view=diff
==============================================================================
--- 
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
 (original)
+++ 
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
 Tue Jun 22 08:26:40 2010
@@ -339,10 +339,14 @@ public class InMemoryObjectServiceImpl e
             throw new CmisObjectNotFoundException("Unknown object id: " + 
objectId);
 
         if (!(so instanceof Content))
-            throw new CmisObjectNotFoundException("Id" + objectId
+            throw new CmisConstraintException("Id" + objectId
                     + " does not refer to a document or version, but only 
those can have content");
 
         ContentStream csd = getContentStream(so, streamId, offset, length);
+        
+        if (null == csd)
+            throw new CmisConstraintException("Object " + so.getId() + " does 
not have content."); 
+
         LOG.debug("stop getContentStream()");
         return csd;
     }

Modified: 
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java
URL: 
http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java?rev=956812&r1=956811&r2=956812&view=diff
==============================================================================
--- 
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java
 (original)
+++ 
incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java
 Tue Jun 22 08:26:40 2010
@@ -216,10 +216,13 @@ public class ObjectServiceTest extends A
         // delete content again
         Holder<String> idHolder = new Holder<String>(id);
         fObjSvc.deleteContentStream(fRepositoryId, idHolder, null, null);
-        sd = fObjSvc.getContentStream(fRepositoryId, id, null, 
BigInteger.valueOf(-1) /* offset */, BigInteger
-                .valueOf(-1) /* length */, null);
-        assertNull(sd);
-
+        try {
+            sd = fObjSvc.getContentStream(fRepositoryId, id, null, 
BigInteger.valueOf(-1) /* offset */, BigInteger
+                    .valueOf(-1) /* length */, null);
+            fail("getContentStream with non existing content should raise a 
CmisConstraintException");
+        } catch (Exception e) {
+            assertTrue(e instanceof CmisConstraintException);
+        }
         // create content again in a second call
         ContentStream contentStream = createContent();
         fObjSvc.setContentStream(fRepositoryId, idHolder, true, null, 
contentStream, null);


Reply via email to