chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1543192 - in /chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src: main/java/org/apache/chemistry/opencmis/inmemory/query/ main/java/org/apache/chemistry/opencmis/inmemory/server/ main/java/org/apache/...
Date Mon, 18 Nov 2013 22:15:00 GMT
Author: jens
Date: Mon Nov 18 22:14:59 2013
New Revision: 1543192

URL: http://svn.apache.org/r1543192
Log:
Improver internal content handling

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/PropertyQueryUtil.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/AtomLinkInfoProvider.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryVersioningServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/Content.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/ObjectStore.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/StoredObject.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/VersionedDocument.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FolderImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoredObjectImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/UnitTestTypeSystemCreator.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java?rev=1543192&r1=1543191&r2=1543192&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java Mon Nov 18 22:14:59 2013
@@ -667,7 +667,7 @@ public class InMemoryQueryProcessor {
             }
 
             if (so instanceof Content && cont.hasContent()) {
-                ContentStreamDataImpl cdi = (ContentStreamDataImpl) cont.getContent(0, -1);
+                ContentStreamDataImpl cdi = (ContentStreamDataImpl) cont.getContent();
                 if (cdi.getMimeType().startsWith("text/")) {
                     byte[] ba = cdi.getBytes();
                     String text;

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/PropertyQueryUtil.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/PropertyQueryUtil.java?rev=1543192&r1=1543191&r2=1543192&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/PropertyQueryUtil.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/PropertyQueryUtil.java Mon Nov 18 22:14:59 2013
@@ -51,7 +51,7 @@ public final class PropertyQueryUtil {
         boolean cmis11 = InMemoryServiceContext.getCallContext().getCmisVersion() != CmisVersion.CMIS_1_0;
 
         if (so instanceof Content) {
-            content = ((Content) so).getContent(0, 0);
+            content = ((Content) so).getContent();
         }
         if (so instanceof DocumentVersion) {
             ver = (DocumentVersion) so;

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/AtomLinkInfoProvider.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/AtomLinkInfoProvider.java?rev=1543192&r1=1543191&r2=1543192&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/AtomLinkInfoProvider.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/AtomLinkInfoProvider.java Mon Nov 18 22:14:59 2013
@@ -21,6 +21,7 @@ package org.apache.chemistry.opencmis.in
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.chemistry.opencmis.commons.data.ContentStream;
 import org.apache.chemistry.opencmis.commons.data.ObjectData;
 import org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer;
 import org.apache.chemistry.opencmis.commons.data.ObjectInFolderData;
@@ -115,10 +116,10 @@ public class AtomLinkInfoProvider {
         }
 
         if (so instanceof Content) {
-            Content cont = ((Content) so);
-            objInfo.setHasContent(cont.getContent(0, -1) != null);
-            objInfo.setContentType(cont.getContent(0, -1) != null ? cont.getContent(0, -1).getMimeType() : null);
-            objInfo.setFileName(cont.getContent(0, -1) != null ? cont.getContent(0, -1).getFileName() : null);
+            ContentStream contentStream = ((Content) so).getContent();
+            objInfo.setHasContent(contentStream != null);
+            objInfo.setContentType(contentStream != null ? contentStream.getMimeType() : null);
+            objInfo.setFileName(contentStream != null ? contentStream.getFileName() : null);
         } else {
             objInfo.setHasContent(false);
             objInfo.setContentType(null);
@@ -133,7 +134,7 @@ public class AtomLinkInfoProvider {
             objInfo.setHasParent(false);
         }
 
-        List<RenditionData> renditions = so.getRenditions("*", 0, 0);
+        List<RenditionData> renditions = objStore.getRenditions(so, "*", 0, 0);
         if (renditions == null || renditions.size() == 0) {
             objInfo.setRenditionInfos(null);
         } else {

Modified: 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/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java?rev=1543192&r1=1543191&r2=1543192&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java Mon Nov 18 22:14:59 2013
@@ -265,7 +265,8 @@ public class InMemoryObjectServiceImpl e
                     + " does not refer to a document, but only documents can have content");
         }
 
-        ((Content) so).setContent(null, true);
+        ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
+        objectStore.setContent(so, null);
         LOG.debug("stop deleteContentStream()");
     }
 
@@ -360,7 +361,8 @@ public class InMemoryObjectServiceImpl e
                     + " does not refer to a document or version, but only those can have content");
         }
 
-        ContentStream csd = getContentStream(so, streamId, offset, length);
+        ObjectStore objStore = fStoreManager.getObjectStore(repositoryId);
+        ContentStream csd = getContentStream(objStore, so, streamId, offset, length);
 
         if (null == csd) {
             throw new CmisConstraintException("Object " + so.getId() + " does not have content.");
@@ -471,7 +473,8 @@ public class InMemoryObjectServiceImpl e
             throw new CmisObjectNotFoundException(UNKNOWN_OBJECT_ID + objectId);
         }
 
-        List<RenditionData> renditions = so.getRenditions(renditionFilter, maxItems == null ? 0 : maxItems.longValue(),
+        ObjectStore objStore = fStoreManager.getObjectStore(repositoryId);
+        List<RenditionData> renditions = objStore.getRenditions(so, renditionFilter, maxItems == null ? 0 : maxItems.longValue(),
                 skipCount == null ? 0 : skipCount.longValue());
         LOG.debug("stop getRenditions()");
         return renditions;
@@ -588,12 +591,13 @@ public class InMemoryObjectServiceImpl e
             throw new IllegalArgumentException("Content cannot be set on this object (must be document or version)");
         }
 
-        if (!overwriteFlag && content.getContent(0, -1) != null) {
+        if (!overwriteFlag && content.hasContent()) {
             throw new CmisContentAlreadyExistsException(
                     "cannot overwrite existing content if overwrite flag is not set");
         }
 
-        content.setContent(contentStream, true);
+        ObjectStore objStore = fStoreManager.getObjectStore(repositoryId);
+        objStore.setContent(so, contentStream);
         so.updateSystemBasePropertiesWhenModified(null, context.getUsername());
         LOG.debug("stop setContentStream()");
     }
@@ -792,7 +796,8 @@ public class InMemoryObjectServiceImpl e
             throw new IllegalArgumentException("Content cannot be set on this object (must be document or version)");
         }
 
-        content.appendContent(contentStream);
+        ObjectStore objStore = fStoreManager.getObjectStore(repositoryId);
+        objStore.appendContent(so, contentStream);
         so.updateSystemBasePropertiesWhenModified(null, context.getUsername());
     }
 
@@ -925,8 +930,7 @@ public class InMemoryObjectServiceImpl e
             so = version; // return the version and not the version series to
                           // caller
         } else {
-            Document doc = objectStore.createDocument(name, propMap, user, folder, policies, aclAdd, aclRemove);
-            doc.setContent(contentStreamNew, false);
+            Document doc = objectStore.createDocument(propMap, user, folder, contentStreamNew, policies, aclAdd, aclRemove);
             so = doc;
         }
 
@@ -1236,17 +1240,16 @@ public class InMemoryObjectServiceImpl e
         return true;
     }
 
-    private static ContentStream getContentStream(StoredObject so, String streamId, BigInteger offset, 
+    private static ContentStream getContentStream(ObjectStore objStore, StoredObject so, String streamId, BigInteger offset, 
             BigInteger length) {
         ContentStream csd = null;
         long lOffset = offset == null ? 0 : offset.longValue();
         long lLength = length == null ? -1 : length.longValue();
 
         if (streamId == null) {
-            csd = ((Content) so).getContent(lOffset, lLength);
-            return csd;
+            csd =  objStore.getContent(so, lOffset, lLength);
         } else if (streamId.endsWith("-rendition")) {
-            csd = so.getRenditionContent(streamId, lOffset, lLength);
+            csd = objStore.getRenditionContent(so, streamId, lOffset, lLength);
         }
 
         return csd;

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryVersioningServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryVersioningServiceImpl.java?rev=1543192&r1=1543191&r2=1543192&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryVersioningServiceImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryVersioningServiceImpl.java Mon Nov 18 22:14:59 2013
@@ -38,6 +38,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.server.ObjectInfoHandler;
 import org.apache.chemistry.opencmis.commons.spi.Holder;
 import org.apache.chemistry.opencmis.inmemory.FilterParser;
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.Content;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Document;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.DocumentVersion;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStore;
@@ -90,14 +91,19 @@ public class InMemoryVersioningServiceIm
 
         // check if the contentStream is a usable object or ignore it otherwise
         // Note Browser binding sets an empty object
+        ObjectStore objStore = fStoreManager.getObjectStore(repositoryId);
         ContentStream contentStream = contentStreamParam;
-        if (contentStream != null && contentStream.getStream() == null) {
-            contentStream = null;
+        if (contentStream != null) {
+            if (contentStream.getStream() == null) {
+                contentStream = null;
+            } else {
+                objStore.setContent(so, contentStream);
+            }
         }
 
         boolean major = (null == majorParam ? true : majorParam);
 
-        verDoc.checkIn(major, properties, contentStream, checkinComment, policies, user);
+        verDoc.checkIn(major, properties, ((Content)so).getContent(), checkinComment, policies, user);
         verDoc.updateSystemBasePropertiesWhenModified(null, context.getUsername());
         // To be able to provide all Atom links in the response we need
         // additional information:
@@ -127,11 +133,12 @@ public class InMemoryVersioningServiceIm
 
         ContentStream content = null;
 
+        ObjectStore objStore = fStoreManager.getObjectStore(repositoryId);
         if (so instanceof DocumentVersion) {
-            // get document the version is contained in to c
-            content = ((DocumentVersion) so).getContent(0, -1);
+            content = objStore.getContent(so, 0, -1);
         } else {
-            content = ((VersionedDocument) so).getLatestVersion(false).getContent(0, -1);
+            DocumentVersion latestVer = ((VersionedDocument) so).getLatestVersion(false);
+            content = objStore.getContent(latestVer, 0, -1);
         }
 
         if (verDoc.isCheckedOut()) {
@@ -141,7 +148,8 @@ public class InMemoryVersioningServiceIm
         String user = context.getUsername();
         checkHasUser(user);
 
-        DocumentVersion pwc = verDoc.checkOut(content, user);
+        DocumentVersion pwc = verDoc.checkOut(user);
+        objectStore.setContent(pwc, content);
         objectStore.storeVersion(pwc);
         objectId.setValue(pwc.getId()); // return the id of the created pwc
         if (null != contentCopied) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/Content.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/Content.java?rev=1543192&r1=1543191&r2=1543192&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/Content.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/Content.java Mon Nov 18 22:14:59 2013
@@ -30,7 +30,7 @@ public interface Content {
      * return true if this object has content or false if there is no content
      * attached.
      * 
-     * @return true if hast content otherwise false
+     * @return true if has content otherwise false
      */
     boolean hasContent();
 
@@ -44,7 +44,7 @@ public interface Content {
      * 
      * @return object containing mime-type, length and a stream with content
      */
-    ContentStream getContent(long offset, long length);
+    ContentStream getContent();
 
     /**
      * Assign content to a document. Existing content gets overwritten. The
@@ -52,18 +52,6 @@ public interface Content {
      * 
      * @param content
      *            content to be assigned to the document.
-     * @param mustPersist
-     *            persist document (set to false if content is set during
-     *            creation of a document)
      */
-    void setContent(ContentStream content, boolean mustPersist);
-
-    /**
-     * Append content to an existing content stream. The document is persisted
-     * in the new state.
-     * 
-     * @param content
-     *            content to be assigned to the document.
-     */
-    void appendContent(ContentStream content);
+    void setContent(ContentStream content);
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/ObjectStore.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/ObjectStore.java?rev=1543192&r1=1543191&r2=1543192&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/ObjectStore.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/ObjectStore.java Mon Nov 18 22:14:59 2013
@@ -24,6 +24,7 @@ import java.util.Map;
 import org.apache.chemistry.opencmis.commons.data.Acl;
 import org.apache.chemistry.opencmis.commons.data.ContentStream;
 import org.apache.chemistry.opencmis.commons.data.PropertyData;
+import org.apache.chemistry.opencmis.commons.data.RenditionData;
 import org.apache.chemistry.opencmis.commons.enums.AclPropagation;
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
 import org.apache.chemistry.opencmis.commons.enums.RelationshipDirection;
@@ -124,14 +125,14 @@ public interface ObjectStore {
      * call additional actions can take place (like assigning properties and a
      * type) before it is persisted.
      * 
-     * @param name
-     *            name of the document
      * @param propMap
      *            map of properties
      * @param user
      *            the user who creates the document
      * @param folder
      *            the parent folder
+     * @param contentStream
+     *            the content of the document
      * @param policies
      *            list of policies to apply
      * @param addACEs
@@ -140,8 +141,8 @@ public interface ObjectStore {
      *            aces that are removed
      * @return document object
      */
-    Document createDocument(String name, Map<String, PropertyData<?>> propMap, String user, Folder folder,
-            List<String> policies, Acl addACEs, Acl removeACEs);
+    Document createDocument(Map<String, PropertyData<?>> propMap, String user, Folder folder,
+            ContentStream contentStream, List<String> policies, Acl addACEs, Acl removeACEs);
 
     /**
      * Create a folder as initial step. The folder is created but still
@@ -491,4 +492,73 @@ public interface ObjectStore {
      */
     void removeParent(StoredObject so, Folder parent);
 
-}
\ No newline at end of file
+    /**
+     * Retrieve the content of a document.
+     * 
+     * @param so
+     *            object to get content from
+     * @param offset
+     *            offset in content stream
+     * @param length
+     *            length of content to return
+     * 
+     * @return object containing mime-type, length and a stream with content
+     */
+    ContentStream getContent(StoredObject so, long offset, long length);
+
+    /**
+     * Write content and attach it to a document. Existing content gets overwritten. 
+     * 
+     * @param so
+     *            object to set content to
+     * @param content
+     *            content to be assigned to the document. If null any existing 
+     *            content is deleted
+     * @return
+     *             the created content stream
+     */
+    ContentStream setContent(StoredObject so, ContentStream content);
+
+    /**
+     * Append content to an existing content stream.
+     * 
+     * @param so
+     *            object to append content to
+     * @param content
+     *            content to be assigned to the document.
+     */
+    void appendContent(StoredObject so, ContentStream content);
+
+    /**
+     * get the rendition this objects supports.
+     * 
+     * @param so
+     *            object to get renditions from
+     * @param renditionFilter
+     *            filter of renditions to return
+     * @param maxItems
+     *            max nubmer of items to return
+     * @param skipCount
+     *            number of objects to skip in result
+     * @return List of renditions or null if no renditions are available for
+     *         this object
+     */
+    List<RenditionData> getRenditions(StoredObject so, String renditionFilter, long maxItems, long skipCount);
+
+    /**
+     * get the rendition of this object.
+     * 
+     * @param so
+     *            object to get renditions from
+     * @param streamId
+     *            stream if of rendition
+     * @param offset
+     *            offset in rendition content
+     * @param length
+     *            length of rendition content
+     * @return ContentStream containing the rendition
+     */
+    ContentStream getRenditionContent(StoredObject so, String streamId, long offset, long length);
+
+}
+

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/StoredObject.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/StoredObject.java?rev=1543192&r1=1543191&r2=1543192&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/StoredObject.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/StoredObject.java Mon Nov 18 22:14:59 2013
@@ -295,33 +295,6 @@ public interface StoredObject {
     boolean hasRendition(String user);
 
     /**
-     * get the rendition this objects supports.
-     * 
-     * @param renditionFilter
-     *            filter of renditions to return
-     * @param maxItems
-     *            max nubmer of items to return
-     * @param skipCount
-     *            number of objects to skip in result
-     * @return List of renditions or null if no renditions are available for
-     *         this object
-     */
-    List<RenditionData> getRenditions(String renditionFilter, long maxItems, long skipCount);
-
-    /**
-     * get the rendition of this object.
-     * 
-     * @param streamId
-     *            stream if of rendition
-     * @param offset
-     *            offset in rendition content
-     * @param length
-     *            length of rendition content
-     * @return ContentStream containing the rendition
-     */
-    ContentStream getRenditionContent(String streamId, long offset, long length);
-
-    /**
      * get applied policies of this object.
      * 
      * @return list of ids of policies applied to this object

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/VersionedDocument.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/VersionedDocument.java?rev=1543192&r1=1543191&r2=1543192&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/VersionedDocument.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/VersionedDocument.java Mon Nov 18 22:14:59 2013
@@ -34,17 +34,15 @@ import org.apache.chemistry.opencmis.com
 public interface VersionedDocument extends Filing, StoredObject {
 
     /**
-     * Add a version to this document.
+     * Add a new version to this document.
      * 
-     * @param content
-     *            content stream of new version
      * @param verState
      *            versioning state of new version
      * @param user
      *            user adding the new vesion
      * @return document version added
      */
-    DocumentVersion addVersion(ContentStream content, VersioningState verState, String user);
+    DocumentVersion addVersion(VersioningState verState, String user);
 
     /**
      * Delete a version from this object, throw exception if document is checked
@@ -75,13 +73,11 @@ public interface VersionedDocument exten
     /**
      * Perform a check-out operation.
      * 
-     * @param content
-     *            content stream of object
      * @param user
      *            user who checks-out
      * @return document version beinf the new private working copy
      */
-    DocumentVersion checkOut(ContentStream content, String user);
+    DocumentVersion checkOut(String user);
 
     /**
      * Check in a private working copy.

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentImpl.java?rev=1543192&r1=1543191&r2=1543192&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentImpl.java Mon Nov 18 22:14:59 2013
@@ -18,22 +18,13 @@
  */
 package org.apache.chemistry.opencmis.inmemory.storedobj.impl;
 
-import java.io.IOException;
-import java.math.BigInteger;
-import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
 import org.apache.chemistry.opencmis.commons.PropertyIds;
 import org.apache.chemistry.opencmis.commons.data.ContentStream;
 import org.apache.chemistry.opencmis.commons.data.PropertyData;
-import org.apache.chemistry.opencmis.commons.data.RenditionData;
-import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
-import org.apache.chemistry.opencmis.commons.exceptions.CmisStorageException;
-import org.apache.chemistry.opencmis.commons.impl.dataobjects.RenditionDataImpl;
 import org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory;
-import org.apache.chemistry.opencmis.inmemory.ConfigConstants;
-import org.apache.chemistry.opencmis.inmemory.ConfigurationSettings;
 import org.apache.chemistry.opencmis.inmemory.FilterParser;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Document;
 import org.slf4j.Logger;
@@ -45,68 +36,22 @@ import org.slf4j.LoggerFactory;
  */
 
 public class DocumentImpl extends FilingImpl implements Document {
-    private ContentStreamDataImpl fContent;
+    private ContentStream fContent;
 
     private static final Logger LOG = LoggerFactory.getLogger(DocumentImpl.class.getName());
-    private static final Long MAX_CONTENT_SIZE_KB = ConfigurationSettings
-            .getConfigurationValueAsLong(ConfigConstants.MAX_CONTENT_SIZE_KB);
-
-    public static final int THUMBNAIL_SIZE = 100;
 
     public DocumentImpl() { // visibility should be package
         super();
     }
 
     @Override
-    public ContentStream getContent(long offset, long length) {
-        if (null == fContent) {
-            return null;
-        } else if (offset <= 0 && length < 0) {
-            return fContent;
-        } else {
-            return fContent.getCloneWithLimits(offset, length);
-        }
-    }
-
-    @Override
-    public void setContent(ContentStream content, boolean mustPersist) {
-        if (null == content) {
-            fContent = null;
-        } else {
-            fContent = new ContentStreamDataImpl(MAX_CONTENT_SIZE_KB == null ? 0 : MAX_CONTENT_SIZE_KB);
-            String fileName = content.getFileName();
-            if (null == fileName || fileName.length() <= 0) {
-                fileName = getName(); // use name of document as fallback
-            }
-            fContent.setFileName(fileName);
-            String mimeType = content.getMimeType();
-            if (null == mimeType || mimeType.length() <= 0) {
-                mimeType = "application/octet-stream"; // use as fallback
-            }
-            fContent.setMimeType(mimeType);
-            fContent.setLastModified(getModifiedAt());
-            try {
-                fContent.setContent(content.getStream());
-            } catch (IOException e) {
-                throw new CmisRuntimeException("Failed to get content from InputStream", e);
-            }
-        }
+    public ContentStream getContent() {
+        return fContent;
     }
 
     @Override
-    public void appendContent(ContentStream content) {
-        if (null == content) {
-            return;
-        }
-        if (null == fContent) {
-            setContent(content, true);
-        } else {
-            try {
-                fContent.appendContent(content.getStream());
-            } catch (IOException e) {
-                throw new CmisStorageException("Failed to append content: IO Exception", e);
-            }
-        }
+    public void setContent(ContentStream content) {
+        fContent = content;
     }
 
     @Override
@@ -195,129 +140,11 @@ public class DocumentImpl extends Filing
     public boolean hasContent() {
         return null != fContent;
     }
-
-    @Override
-    public List<RenditionData> getRenditions(String renditionFilter, long maxItems, long skipCount) {
-
-        String tokenizer = "[\\s;]";
-        if (null == renditionFilter) {
-            return null;
-        }
-        String[] formats = renditionFilter.split(tokenizer);
-        boolean isImageRendition = testRenditionFilterForImage(formats);
-
-        if (isImageRendition && fContent != null && hasRendition(null)) {
-            List<RenditionData> renditions = new ArrayList<RenditionData>(1);
-            String mimeType = fContent.getMimeType();
-            RenditionDataImpl rendition = new RenditionDataImpl();
-            if (mimeType.equals("image/jpeg")) {
-                rendition.setBigHeight(BigInteger.valueOf(THUMBNAIL_SIZE));
-                rendition.setBigWidth(BigInteger.valueOf(THUMBNAIL_SIZE));
-                rendition.setMimeType(RENDITION_MIME_TYPE_JPEG);
-            } else {
-                rendition.setBigHeight(BigInteger.valueOf(ICON_SIZE));
-                rendition.setBigWidth(BigInteger.valueOf(ICON_SIZE));
-                rendition.setMimeType(RENDITION_MIME_TYPE_PNG);
-            }
-            rendition.setKind("cmis:thumbnail");
-            rendition.setRenditionDocumentId(getId());
-            rendition.setStreamId(getId() + RENDITION_SUFFIX);
-            rendition.setBigLength(BigInteger.valueOf(-1L));
-            rendition.setTitle(getName());
-            renditions.add(rendition);
-            return renditions;
-        } else {
-            return null;
-        }
-    }
-
-    @Override
-    public ContentStream getRenditionContent(String streamId, long offset, long length) {
-        if (null == fContent) {
-            return null;
-        }
-
-        String mimeType = fContent.getMimeType();
-
-        try {
-            if (isImage(mimeType)) {
-                ImageThumbnailGenerator generator = new ImageThumbnailGenerator(getContent(0L, -1L).getStream());
-                return generator.getRendition(THUMBNAIL_SIZE, 0);
-            } else if (isAudio(mimeType)) {
-                return getIconFromResourceDir("/audio-x-generic.png");
-            } else if (isVideo(mimeType)) {
-                return getIconFromResourceDir("/video-x-generic.png");
-            } else if (isPDF(mimeType)) {
-                return getIconFromResourceDir("/application-pdf.png");
-            } else if (isWord(mimeType)) {
-                return getIconFromResourceDir("/application-msword.png");
-            } else if (isPowerpoint(mimeType)) {
-                return getIconFromResourceDir("/application-vnd.ms-powerpoint.png");
-            } else if (isExcel(mimeType)) {
-                return getIconFromResourceDir("/application-vnd.ms-excel.png");
-            } else if (isHtml(mimeType)) {
-                return getIconFromResourceDir("/text-html.png");
-            } else if (isPlainText(mimeType)) {
-                return getIconFromResourceDir("/text-x-generic.png");
-            } else {
-                return null;
-            }
-        } catch (IOException e) {
-            LOG.error("Failed to generate rendition: ", e);
-            throw new CmisRuntimeException("Failed to generate rendition: " + e);
-        }
-    }
-
+    
     @Override
     public boolean hasRendition(String user) {
-        if (null == fContent) {
-            return false;
-        }
-
-        String mimeType = fContent.getMimeType();
-
-        return isImage(mimeType) || isAudio(mimeType) || isVideo(mimeType) || isPDF(mimeType) || isPowerpoint(mimeType)
-                || isExcel(mimeType) || isWord(mimeType) || isHtml(mimeType) || isPlainText(mimeType);
-    }
-
-    private boolean isImage(String mimeType) {
-        return mimeType.startsWith("image/");
-    }
-
-    private boolean isWord(String mimeType) {
-        return mimeType.equals("application/vnd.openxmlformats-officedocument.wordprocessingml.document")
-                || mimeType.equals("application/ms-word");
-    }
-
-    private boolean isExcel(String mimeType) {
-        return mimeType.equals("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
-                || mimeType.equals("application/vnd.ms-excel");
-    }
-
-    private boolean isPowerpoint(String mimeType) {
-        return mimeType.equals("application/vnd.openxmlformats-officedocument.presentationml.slideshow")
-                || mimeType.equals("application/vnd.openxmlformats-officedocument.presentationml.presentation")
-                || mimeType.equals("application/vnd.ms-powerpoint");
+        return RenditionUtil.hasRendition(this, user);
     }
 
-    private boolean isPDF(String mimeType) {
-        return mimeType.equals("application/pdf");
-    }
-
-    private boolean isHtml(String mimeType) {
-        return mimeType.equals("text/html");
-    }
-
-    private boolean isAudio(String mimeType) {
-        return mimeType.startsWith("audio/");
-    }
-
-    private boolean isVideo(String mimeType) {
-        return mimeType.startsWith("video/");
-    }
-
-    private boolean isPlainText(String mimeType) {
-        return mimeType.equals("text/plain");
-    }
 
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java?rev=1543192&r1=1543191&r2=1543192&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java Mon Nov 18 22:14:59 2013
@@ -46,19 +46,17 @@ public class DocumentVersionImpl extends
     private static final Long MAX_CONTENT_SIZE_KB = ConfigurationSettings
             .getConfigurationValueAsLong(ConfigConstants.MAX_CONTENT_SIZE_KB);
 
-    private ContentStreamDataImpl fContent;
+    private ContentStream fContent;
     private final VersionedDocumentImpl fContainer; // the document this version
                                                     // belongs to
     private String fComment; // checkin comment
     private boolean fIsMajor;
     private boolean fIsPwc; // true if this is the PWC
 
-    public DocumentVersionImpl(String repositoryId, VersionedDocument container, ContentStream content,
-            VersioningState verState) {
+    public DocumentVersionImpl(String repositoryId, VersionedDocument container, VersioningState verState) {
         super();
         setRepositoryId(repositoryId);
         fContainer = (VersionedDocumentImpl) container;
-        setContentIntern(content);
         fIsMajor = verState == VersioningState.MAJOR || verState == null;
         fIsPwc = verState == VersioningState.CHECKEDOUT;
         fProperties = new HashMap<String, PropertyData<?>>();
@@ -72,40 +70,12 @@ public class DocumentVersionImpl extends
     }
 
     @Override
-    public void setContent(ContentStream content, boolean mustPersist) {
+    public void setContent(ContentStream content) {
         setContentIntern(content);
     }
 
     private void setContentIntern(ContentStream content) {
-        if (null == content) {
-            fContent = null;
-        } else {
-            fContent = new ContentStreamDataImpl(MAX_CONTENT_SIZE_KB == null ? 0 : MAX_CONTENT_SIZE_KB);
-            fContent.setFileName(content.getFileName());
-            fContent.setMimeType(content.getMimeType());
-            fContent.setLastModified(getModifiedAt());
-            try {
-                fContent.setContent(content.getStream());
-            } catch (IOException e) {
-                throw new CmisRuntimeException("Failed to get content from InputStream", e);
-            }
-        }
-    }
-
-    @Override
-    public void appendContent(ContentStream content) {
-        if (null == content) {
-            return;
-        }
-        if (null == fContent) {
-            setContent(content, true);
-        } else {
-            try {
-                fContent.appendContent(content.getStream());
-            } catch (IOException e) {
-                throw new CmisStorageException("Failed to append content: IO Exception", e);
-            }
-        }
+        fContent = content;
     }
 
     @Override
@@ -154,12 +124,8 @@ public class DocumentVersionImpl extends
     }
 
     @Override
-    public ContentStream getContent(long offset, long length) {
-        if (offset <= 0 && length < 0) {
-            return fContent;
-        } else {
-            return fContent.getCloneWithLimits(offset, length);
-        }
+    public ContentStream getContent() {
+        return fContent;
     }
 
     @Override

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FolderImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FolderImpl.java?rev=1543192&r1=1543191&r2=1543192&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FolderImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FolderImpl.java Mon Nov 18 22:14:59 2013
@@ -82,44 +82,6 @@ public class FolderImpl extends StoredOb
     }
 
     @Override
-    public List<RenditionData> getRenditions(String renditionFilter, long maxItems, long skipCount) {
-        if (null == renditionFilter) {
-            return null;
-        }
-        String tokenizer = "[\\s;]";
-        String[] formats = renditionFilter.split(tokenizer);
-        boolean isImageRendition = testRenditionFilterForImage(formats);
-
-        if (isImageRendition) {
-            List<RenditionData> renditions = new ArrayList<RenditionData>(1);
-            RenditionDataImpl rendition = new RenditionDataImpl();
-            rendition.setBigHeight(BigInteger.valueOf(ICON_SIZE));
-            rendition.setBigWidth(BigInteger.valueOf(ICON_SIZE));
-            rendition.setKind("cmis:thumbnail");
-            rendition.setMimeType(RENDITION_MIME_TYPE_PNG);
-            rendition.setRenditionDocumentId(getId());
-            rendition.setStreamId(getId() + RENDITION_SUFFIX);
-            rendition.setBigLength(BigInteger.valueOf(-1L));
-            rendition.setTitle(getName());
-            rendition.setRenditionDocumentId(getId());
-            renditions.add(rendition);
-            return renditions;
-        } else {
-            return null;
-        }
-    }
-
-    @Override
-    public ContentStream getRenditionContent(String streamId, long offset, long length) {
-        try {
-            return getIconFromResourceDir("/folder.png");
-        } catch (IOException e) {
-            LOG.error("Failed to generate rendition: ", e);
-            throw new CmisRuntimeException("Failed to generate rendition: " + e);
-        }
-    }
-
-    @Override
     public boolean hasRendition(String user) {
         return true;
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java?rev=1543192&r1=1543191&r2=1543192&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java Mon Nov 18 22:14:59 2013
@@ -18,9 +18,15 @@
  */
 package org.apache.chemistry.opencmis.inmemory.storedobj.impl;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
+import java.util.GregorianCalendar;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -32,7 +38,9 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.Ace;
 import org.apache.chemistry.opencmis.commons.data.Acl;
 import org.apache.chemistry.opencmis.commons.data.ContentStream;
+import org.apache.chemistry.opencmis.commons.data.LastModifiedContentStream;
 import org.apache.chemistry.opencmis.commons.data.PropertyData;
+import org.apache.chemistry.opencmis.commons.data.RenditionData;
 import org.apache.chemistry.opencmis.commons.enums.AclPropagation;
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
@@ -43,6 +51,13 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.exceptions.CmisNameConstraintViolationException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisStorageException;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.RenditionDataImpl;
+import org.apache.chemistry.opencmis.inmemory.ConfigConstants;
+import org.apache.chemistry.opencmis.inmemory.ConfigurationSettings;
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.Content;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Document;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.DocumentVersion;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Fileable;
@@ -53,6 +68,8 @@ import org.apache.chemistry.opencmis.inm
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Relationship;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoredObject;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.VersionedDocument;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * The object store is the central core of the in-memory repository. It is based
@@ -86,7 +103,10 @@ import org.apache.chemistry.opencmis.inm
  */
 public class ObjectStoreImpl implements ObjectStore {
 
+    private static final Logger LOG = LoggerFactory.getLogger(ObjectStoreImpl.class.getName());
     private static final int FIRST_ID = 100;
+    private static final Long MAX_CONTENT_SIZE_KB = ConfigurationSettings
+            .getConfigurationValueAsLong(ConfigConstants.MAX_CONTENT_SIZE_KB);
 
     /**
      * User id for administrator always having all rights.
@@ -268,8 +288,9 @@ public class ObjectStoreImpl implements 
     }
 
     @Override
-    public Document createDocument(String name, Map<String, PropertyData<?>> propMap, String user, Folder folder,
-            List<String> policies, Acl addACEs, Acl removeACEs) {
+    public Document createDocument(Map<String, PropertyData<?>> propMap, String user, Folder folder,
+            ContentStream contentStream, List<String> policies, Acl addACEs, Acl removeACEs) {
+        String name = (String) propMap.get(PropertyIds.NAME).getFirstValue();
         DocumentImpl doc = new DocumentImpl();
         doc.createSystemBasePropertiesWhenCreated(propMap, user);
         doc.setCustomProperties(propMap);
@@ -282,6 +303,8 @@ public class ObjectStoreImpl implements 
             }
             doc.addParentId(folder.getId());
         }
+        ContentStream content = setContent(doc, contentStream);
+        doc.setContent(content);
         int aclId = getAclId(((FolderImpl) folder), addACEs, removeACEs);
         doc.setAclId(aclId);
         if (null != policies) {
@@ -330,7 +353,8 @@ public class ObjectStoreImpl implements 
         doc.setName(name);
         String id = storeObject(doc);
         doc.setId(id);
-        DocumentVersion version = doc.addVersion(contentStream, versioningState, user);
+        DocumentVersion version = doc.addVersion(versioningState, user);
+        setContent(version, contentStream);
         version.createSystemBasePropertiesWhenCreated(propMap, user);
         version.setCustomProperties(propMap);
         if (null != folder) {
@@ -1027,4 +1051,87 @@ public class ObjectStoreImpl implements 
         Collections.sort(list, new FolderComparator());
     }
 
+    @Override
+    public ContentStream getContent(StoredObject so, long offset, long length) {
+        if (so instanceof Content) {
+            Content content = (Content) so;
+            ContentStream contentStream = content.getContent();
+            if (null == contentStream) {
+                return null;
+            } else if (offset <= 0 && length < 0) {
+                return contentStream;
+            } else {
+                return ((ContentStreamDataImpl)contentStream).getCloneWithLimits(offset, length);
+            }
+        } else {
+            throw new CmisInvalidArgumentException("Cannot set content, object does not implement interface Content.");
+        }
+    }
+
+    @Override
+    public ContentStream setContent(StoredObject so, ContentStream contentStream) {
+        if (so instanceof Content) {
+            ContentStreamDataImpl newContent;
+            Content content = (Content) so;
+
+            if (null == contentStream) {
+                newContent = null;
+            } else {
+                newContent = new ContentStreamDataImpl(MAX_CONTENT_SIZE_KB == null ? 0 : MAX_CONTENT_SIZE_KB);
+                String fileName = contentStream.getFileName();
+                if (null == fileName || fileName.length() <= 0) {
+                    fileName = so.getName(); // use name of document as fallback
+                }
+                newContent.setFileName(fileName);
+                String mimeType = contentStream.getMimeType();
+                if (null == mimeType || mimeType.length() <= 0) {
+                    mimeType = "application/octet-stream"; // use as fallback
+                }
+                newContent.setMimeType(mimeType);
+                newContent.setLastModified(new GregorianCalendar());
+                try {
+                    newContent.setContent(contentStream.getStream());
+                } catch (IOException e) {
+                    throw new CmisRuntimeException("Failed to get content from InputStream", e);
+                }
+            }
+            content.setContent(newContent);
+            return newContent;
+
+        } else {
+            throw new CmisInvalidArgumentException("Cannot set content, object does not implement interface Content.");
+        }
+    }
+
+    @Override
+    public void appendContent(StoredObject so, ContentStream contentStream) {
+        if (so instanceof Content) {
+            Content content = (Content) so;
+            ContentStreamDataImpl newContent = (ContentStreamDataImpl) content.getContent();
+
+            if (null == newContent) {
+                content.setContent(null);
+            } else {
+                try {
+                    newContent.appendContent(contentStream.getStream());
+                } catch (IOException e) {
+                    throw new CmisStorageException("Failed to append content: IO Exception", e);
+                }
+            }
+        } else {
+            throw new CmisInvalidArgumentException("Cannot set content, object does not implement interface Content.");
+        }
+    }
+    
+    @Override
+    public List<RenditionData> getRenditions(StoredObject so, String renditionFilter, long maxItems, long skipCount) {
+
+        return RenditionUtil.getRenditions(so, renditionFilter, maxItems, skipCount);
+    }
+
+    @Override
+    public ContentStream getRenditionContent(StoredObject so, String streamId, long offset, long length) {
+        return RenditionUtil.getRenditionContent(so, streamId, offset, length);
+    }
+
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoredObjectImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoredObjectImpl.java?rev=1543192&r1=1543191&r2=1543192&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoredObjectImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoredObjectImpl.java Mon Nov 18 22:14:59 2013
@@ -52,10 +52,6 @@ public class StoredObjectImpl implements
 
     private static final int BUFFER_SIZE = 65536;
     private static final String UNKNOWN_USER = "unknown";
-    public static final String RENDITION_MIME_TYPE_JPEG = "image/jpeg";
-    public static final String RENDITION_MIME_TYPE_PNG = "image/png";
-    public static final String RENDITION_SUFFIX = "-rendition";
-    public static final int ICON_SIZE = 32;
 
     protected String fId;
     protected String fName;
@@ -505,16 +501,6 @@ public class StoredObjectImpl implements
     }
 
     @Override
-    public List<RenditionData> getRenditions(String renditionFilter, long maxItems, long skipCount) {
-        return null;
-    }
-
-    @Override
-    public ContentStream getRenditionContent(String streamId, long offset, long length) {
-        return null;
-    }
-
-    @Override
     public boolean hasRendition(String user) {
         return false;
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java?rev=1543192&r1=1543191&r2=1543192&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java Mon Nov 18 22:14:59 2013
@@ -47,13 +47,13 @@ public class VersionedDocumentImpl exten
     }
 
     @Override
-    public DocumentVersion addVersion(ContentStream content, VersioningState verState, String user) {
+    public DocumentVersion addVersion(VersioningState verState, String user) {
 
         if (isCheckedOut()) {
             throw new CmisConstraintException("Cannot add a version to document, document is checked out.");
         }
 
-        DocumentVersionImpl ver = new DocumentVersionImpl(fRepositoryId, this, content, verState);
+        DocumentVersionImpl ver = new DocumentVersionImpl(fRepositoryId, this, verState);
         ver.setSystemBasePropertiesWhenCreatedDirect(getName(), getTypeId(), user); // copy
         // name and type id from version series.
         fVersions.add(ver);
@@ -110,7 +110,7 @@ public class VersionedDocumentImpl exten
         DocumentVersion pwc = getPwc();
 
         if (null != content) {
-            pwc.setContent(content, false);
+            pwc.setContent(content);
         }
 
         if (null != properties && null != properties.getProperties()) {
@@ -125,14 +125,14 @@ public class VersionedDocumentImpl exten
     }
 
     @Override
-    public DocumentVersion checkOut(ContentStream content, String user) {
+    public DocumentVersion checkOut(String user) {
         if (fIsCheckedOut) {
             throw new CmisConstraintException("Error: Can't checkout, Document " + getId() 
                     + " is already checked out.");
         }
 
         // create PWC
-        DocumentVersion pwc = addVersion(content, VersioningState.CHECKEDOUT, user); // will
+        DocumentVersion pwc = addVersion(VersioningState.CHECKEDOUT, user); // will
         // set check-out flag
         return pwc;
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java?rev=1543192&r1=1543191&r2=1543192&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java Mon Nov 18 22:14:59 2013
@@ -424,7 +424,7 @@ public final class PropertyCreationHelpe
             od.setAllowableActions(allowableActions);
         }
 
-        List<RenditionData> renditions = so.getRenditions(renditionFilter, 0, 0);
+        List<RenditionData> renditions = objectStore.getRenditions(so, renditionFilter, 0, 0);
         if (null != renditions && renditions.size() > 0) {
             od.setRenditions(renditions);
         }
@@ -486,7 +486,7 @@ public final class PropertyCreationHelpe
             od.setRelationships(DataObjectCreator.fillRelationships(tm, objectStore, includeRelationships, so, user));
         }
 
-        List<RenditionData> renditions = so.getRenditions(renditionFilter, 0, 0);
+        List<RenditionData> renditions = objectStore.getRenditions(so, renditionFilter, 0, 0);
         if (null != renditions && renditions.size() > 0) {
             od.setRenditions(renditions);
         }

Modified: 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/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java?rev=1543192&r1=1543191&r2=1543192&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java Mon Nov 18 22:14:59 2013
@@ -82,6 +82,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.spi.Holder;
 import org.apache.chemistry.opencmis.inmemory.storedobj.impl.ContentStreamDataImpl;
 import org.apache.chemistry.opencmis.inmemory.storedobj.impl.DocumentImpl;
+import org.apache.chemistry.opencmis.inmemory.storedobj.impl.RenditionUtil;
 import org.apache.chemistry.opencmis.inmemory.storedobj.impl.StoredObjectImpl;
 import org.apache.chemistry.opencmis.inmemory.types.DocumentTypeCreationHelper;
 import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
@@ -1026,8 +1027,8 @@ public class ObjectServiceTest extends A
             assertEquals(id, rd.getRenditionDocumentId());
             assertNotNull(rd.getBigHeight());
             assertNotNull(rd.getBigWidth());
-            assertEquals(DocumentImpl.THUMBNAIL_SIZE, rd.getBigHeight().longValue());
-            assertEquals(DocumentImpl.THUMBNAIL_SIZE, rd.getBigWidth().longValue());
+            assertEquals(RenditionUtil.THUMBNAIL_SIZE, rd.getBigHeight().longValue());
+            assertEquals(RenditionUtil.THUMBNAIL_SIZE, rd.getBigWidth().longValue());
             assertNotNull(rd.getStreamId());
             ContentStream renditionContent = fObjSvc.getContentStream(fRepositoryId, id, rd.getStreamId(), null, null,
                     null);
@@ -1064,8 +1065,8 @@ public class ObjectServiceTest extends A
             assertEquals(id, rd.getRenditionDocumentId());
             assertNotNull(rd.getBigHeight());
             assertNotNull(rd.getBigWidth());
-            assertEquals(StoredObjectImpl.ICON_SIZE, rd.getBigHeight().longValue());
-            assertEquals(StoredObjectImpl.ICON_SIZE, rd.getBigWidth().longValue());
+            assertEquals(RenditionUtil.ICON_SIZE, rd.getBigHeight().longValue());
+            assertEquals(RenditionUtil.ICON_SIZE, rd.getBigWidth().longValue());
             assertNotNull(rd.getStreamId());
             ContentStream renditionContent = fObjSvc.getContentStream(fRepositoryId, id, rd.getStreamId(), null, null,
                     null);
@@ -1101,8 +1102,8 @@ public class ObjectServiceTest extends A
             assertEquals(id, rd.getRenditionDocumentId());
             assertNotNull(rd.getBigHeight());
             assertNotNull(rd.getBigWidth());
-            assertEquals(StoredObjectImpl.ICON_SIZE, rd.getBigHeight().longValue());
-            assertEquals(StoredObjectImpl.ICON_SIZE, rd.getBigWidth().longValue());
+            assertEquals(RenditionUtil.ICON_SIZE, rd.getBigHeight().longValue());
+            assertEquals(RenditionUtil.ICON_SIZE, rd.getBigWidth().longValue());
             assertNotNull(rd.getStreamId());
             ContentStream renditionContent = fObjSvc.getContentStream(fRepositoryId, id, rd.getStreamId(), null, null,
                     null);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/UnitTestTypeSystemCreator.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/UnitTestTypeSystemCreator.java?rev=1543192&r1=1543191&r2=1543192&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/UnitTestTypeSystemCreator.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/UnitTestTypeSystemCreator.java Mon Nov 18 22:14:59 2013
@@ -46,6 +46,7 @@ import org.apache.chemistry.opencmis.inm
 import org.apache.chemistry.opencmis.server.support.TypeDefinitionFactory;
 
 public class UnitTestTypeSystemCreator implements TypeCreator {
+    private static final String PROP_ID_PICK_LIST = "PickListProp";
     public static final List<TypeDefinition> singletonTypes = buildTypesList();
     public static final String COMPLEX_TYPE = "ComplexType";
     public static final String TOPLEVEL_TYPE = "DocumentTopLevel";
@@ -279,7 +280,7 @@ public class UnitTestTypeSystemCreator i
                     "Sample Uri multi-value Property", Updatability.READONLY);
             cmisComplexType.addPropertyDefinition(prop8);
 
-            PropertyStringDefinitionImpl prop9 = PropertyCreationHelper.createStringDefinition("PickListProp",
+            PropertyStringDefinitionImpl prop9 = PropertyCreationHelper.createStringDefinition(PROP_ID_PICK_LIST,
                     "Sample Pick List Property", Updatability.READONLY);
             List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
             ChoiceImpl<String> elem = new ChoiceImpl<String>();



Mime
View raw message