chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1389574 - in /chemistry/opencmis/trunk: chemistry-opencmis-bridge/chemistry-opencmis-bridge/src/main/webapp/WEB-INF/classes/ chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/WEB-INF/ chemistry-opencmis-server/ch...
Date Mon, 24 Sep 2012 21:00:16 GMT
Author: jens
Date: Mon Sep 24 21:00:15 2012
New Revision: 1389574

URL: http://svn.apache.org/viewvc?rev=1389574&view=rev
Log:
InMemory: start with rendition support (not yet working)

Added:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ImageThumbnailGenerator.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/resources/image.jpg
  (with props)
Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-bridge/chemistry-opencmis-bridge/src/main/webapp/WEB-INF/classes/repository.properties
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/WEB-INF/web.xml
    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/storedobj/api/StoredObject.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/StoreManagerImpl.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/resources/log4j.properties
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-bridge/chemistry-opencmis-bridge/src/main/webapp/WEB-INF/classes/repository.properties
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-bridge/chemistry-opencmis-bridge/src/main/webapp/WEB-INF/classes/repository.properties?rev=1389574&r1=1389573&r2=1389574&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-bridge/chemistry-opencmis-bridge/src/main/webapp/WEB-INF/classes/repository.properties
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-bridge/chemistry-opencmis-bridge/src/main/webapp/WEB-INF/classes/repository.properties
Mon Sep 24 21:00:15 2012
@@ -53,7 +53,7 @@ service.class=org.apache.chemistry.openc
 #
 ###########################################################
 
-forwarding.binding.org.apache.chemistry.opencmis.binding.spi.type=atompub
-forwarding.binding.org.apache.chemistry.opencmis.binding.atompub.url=http://cmis.alfresco.com/cmisatom
+forwarding.binding.org.apache.chemistry.opencmis.binding.spi.type=browser
+forwarding.binding.org.apache.chemistry.opencmis.binding.browser.url=http://localhost:8080/inmemory/browser
 forwarding.binding.org.apache.chemistry.opencmis.binding.compression=true
 forwarding.binding.org.apache.chemistry.opencmis.binding.cookies=true

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/WEB-INF/web.xml?rev=1389574&r1=1389573&r2=1389574&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/WEB-INF/web.xml
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/WEB-INF/web.xml
Mon Sep 24 21:00:15 2012
@@ -118,10 +118,18 @@
 		<servlet-class>org.apache.chemistry.opencmis.server.impl.browser.CmisBrowserBindingServlet</servlet-class>
 		<init-param>
 			<param-name>callContextHandler</param-name>
-			<param-value>org.apache.chemistry.opencmis.server.impl.browser.token.TokenCallContextHandler</param-value>
+			<param-value>org.apache.chemistry.opencmis.server.shared.BasicAuthCallContextHandler</param-value>
+			
 		</init-param>
 		<load-on-startup>2</load-on-startup>
 	</servlet>
+	<servlet>
+		<description>
+		</description>
+		<display-name>FilterBridgeServlet</display-name>
+		<servlet-name>FilterBridgeServlet</servlet-name>
+		<servlet-class>org.apache.chemistry.opencmis.filterbridge.FilterBridgeServlet</servlet-class>
+	</servlet>
 
 	<servlet-mapping>
 		<servlet-name>cmisws</servlet-name>
@@ -137,7 +145,6 @@
 		<servlet-name>cmisbrowser</servlet-name>
 		<url-pattern>/browser/*</url-pattern>
 	</servlet-mapping>
-
 	<session-config>
 		<session-timeout>60</session-timeout>
 	</session-config>

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=1389574&r1=1389573&r2=1389574&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 Sep 24 21:00:15 2012
@@ -448,12 +448,16 @@ public class InMemoryObjectServiceImpl e
     public List<RenditionData> getRenditions(CallContext context, String repositoryId,
String objectId,
             String renditionFilter, BigInteger maxItems, BigInteger skipCount, ExtensionsData
extension) {
 
-        // TODO to be completed if renditions are implemented
         LOG.debug("start getRenditions()");
-        validator.getRenditions(context, repositoryId, objectId, extension);
+        StoredObject so = validator.getRenditions(context, repositoryId, objectId, extension);
 
+        if (so == null) {
+            throw new CmisObjectNotFoundException("Unknown object id: " + objectId);
+        }
+
+        List<RenditionData> renditions = so.getRenditions(renditionFilter, maxItems==null
? 0 : maxItems.longValue(), skipCount==null ? 0: skipCount.longValue());
         LOG.debug("stop getRenditions()");
-        return null;
+        return renditions;
     }
 
     public ObjectData moveObject(CallContext context, String repositoryId, Holder<String>
objectId,
@@ -1010,12 +1014,17 @@ public class InMemoryObjectServiceImpl e
     }
 
     private static ContentStream getContentStream(StoredObject so, String streamId, BigInteger
offset, BigInteger length) {
-        if (streamId != null) {
-            return null;
-        }
+        ContentStream csd = null;
         long lOffset = offset == null ? 0 : offset.longValue();
         long lLength = length == null ? -1 : length.longValue();
-        ContentStream csd = ((Content) so).getContent(lOffset, lLength);
+        
+        if (streamId == null) {
+            csd = ((Content) so).getContent(lOffset, lLength);
+            return csd;
+        } else if (streamId.endsWith("-rendition")) {
+            csd = so.getRenditionContent(streamId, lOffset, lLength);
+        }
+        
         return csd;
     }
 

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=1389574&r1=1389573&r2=1389574&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 Sep 24 21:00:15 2012
@@ -25,9 +25,11 @@ import java.util.Map;
 
 import org.apache.chemistry.opencmis.commons.data.Acl;
 import org.apache.chemistry.opencmis.commons.data.AllowableActions;
+import org.apache.chemistry.opencmis.commons.data.ContentStream;
 import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
 import org.apache.chemistry.opencmis.commons.data.ObjectList;
 import org.apache.chemistry.opencmis.commons.data.PropertyData;
+import org.apache.chemistry.opencmis.commons.data.RenditionData;
 import org.apache.chemistry.opencmis.commons.enums.RelationshipDirection;
 import org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory;
 
@@ -40,6 +42,18 @@ import org.apache.chemistry.opencmis.com
  * @author Jens
  */
 
+/**
+ * @author d058463
+ *
+ */
+/**
+ * @author d058463
+ *
+ */
+/**
+ * @author d058463
+ *
+ */
 public interface StoredObject {
 
     /**
@@ -268,5 +282,32 @@ public interface StoredObject {
      * get the allowable actions  of the object
      */
 	AllowableActions getAllowableActions(String user);
+	
+    /**
+     * get the rendition this objects supports
+     * 
+     * @param renditionFilter
+     * @param maxItems
+     * @param skipCount
+     * @param extension
+     * @return
+     *      List of renditions or null if no renditions are available for this object
+     */
+    public 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
+     */
+    public ContentStream getRenditionContent(String streamId, long offset, long length);
 
 }
\ No newline at end of file

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=1389574&r1=1389573&r2=1389574&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 Sep 24 21:00:15 2012
@@ -20,12 +20,16 @@ package org.apache.chemistry.opencmis.in
 
 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.ExtensionsData;
 import org.apache.chemistry.opencmis.commons.data.PropertyData;
+import org.apache.chemistry.opencmis.commons.data.RenditionData;
+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;
@@ -48,6 +52,12 @@ public class DocumentImpl extends Abstra
     private static final Logger LOG = LoggerFactory.getLogger(AbstractSingleFilingImpl.class.getName());
     private final Long MAX_CONTENT_SIZE_KB = ConfigurationSettings.getConfigurationValueAsLong(ConfigConstants.MAX_CONTENT_SIZE_KB);
 
+    public static final int IMG_HEIGHT = 100;
+    public static final int IMG_WIDTH = 100;
+    public static final String RENDITION_MIME_TYPE = "image/jpeg";
+    public static final String RENDITION_SUFFIX = "-rendition"
+            ;
+
     DocumentImpl(ObjectStoreImpl objStore) { // visibility should be package
         super(objStore);
     }
@@ -165,4 +175,48 @@ public class DocumentImpl extends Abstra
         return null != fContent;
     }
 
+    @Override
+    public List<RenditionData> getRenditions(String renditionFilter,
+            long maxItems, long skipCount) {
+
+        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(IMG_HEIGHT));
+            rendition.setBigWidth(BigInteger.valueOf(IMG_WIDTH));
+            rendition.setKind("cmis:thumbnail");
+            rendition.setMimeType(RENDITION_MIME_TYPE);
+            rendition.setRenditionDocumentId(getId());
+            rendition.setStreamId(getId() + RENDITION_SUFFIX);
+            rendition.setBigLength(BigInteger.valueOf(-1L));
+            renditions.add(rendition);
+            return renditions;
+        } else {
+            return null;
+        }
+    }
+
+    @Override
+    public ContentStream getRenditionContent(String streamId, long offset, long length) {
       
+        ImageThumbnailGenerator generator = new ImageThumbnailGenerator(getContent(0L, -1L).getStream());
+        return generator.getRendition(IMG_WIDTH, IMG_HEIGHT);
+    }
+
+    protected boolean testRenditionFilterForImage(String[] formats) {
+        return arrayContainsString(formats, "*")  || arrayContainsString(formats, "image/*")

+                || arrayContainsString(formats, "image/jpeg") ;
+    }
+
+    private boolean arrayContainsString(String[] formats, String val) {
+        for (String s : formats) {
+            if (val.equals(s))
+                return true;            
+        }
+        return false;
+    }
+
+
 }

Added: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ImageThumbnailGenerator.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/ImageThumbnailGenerator.java?rev=1389574&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ImageThumbnailGenerator.java
(added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ImageThumbnailGenerator.java
Mon Sep 24 21:00:15 2012
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.inmemory.storedobj.impl;
+
+import java.awt.AlphaComposite;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigInteger;
+
+import javax.imageio.ImageIO;
+
+import org.apache.chemistry.opencmis.commons.data.ContentStream;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl;
+
+public class ImageThumbnailGenerator {
+
+    private static final String RENDITION_MIME_TYPE = "image/jpeg";;
+    private InputStream image;
+
+    public ImageThumbnailGenerator(InputStream imageContent) {
+        this.image = imageContent;
+    }
+
+    public ContentStream getRendition(int width, int height) {
+        byte[] thumbnail;
+        try {
+            thumbnail = scaleImage(image, width, height);
+            ContentStreamImpl cs = new ContentStreamImpl();
+            cs.setFileName("thumbnail.jpg");
+            cs.setMimeType(RENDITION_MIME_TYPE);
+            cs.setStream(new ByteArrayInputStream(thumbnail));
+            cs.setLength(BigInteger.valueOf(thumbnail.length));
+            return cs;
+        } catch (IOException e) {
+            throw new CmisRuntimeException("Failed to generate thumbnail", e);
+        }
+    }
+
+    private byte[] scaleImage(InputStream stream, int width, int height) throws IOException
{
+        
+        BufferedImage originalImage = ImageIO.read(stream);
+
+        BufferedImage resizedImage = new BufferedImage(width, height, originalImage.getType());

+        //        ColorSpace.TYPE_RGB);
+        Graphics2D g = resizedImage.createGraphics();
+
+        g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
+        g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+     
+        g.drawImage(originalImage, 0, 0, width, height, null);
+        g.dispose();    
+        g.setComposite(AlphaComposite.Src);
+     
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        boolean ok = ImageIO.write(resizedImage, "JPG", os);
+        if (ok)
+            return os.toByteArray();
+        else
+            return null;
+    }
+
+}

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.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/StoreManagerImpl.java?rev=1389574&r1=1389573&r2=1389574&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java
Mon Sep 24 21:00:15 2012
@@ -353,7 +353,7 @@ public class StoreManagerImpl implements
         caps.setCapabilityContentStreamUpdates(CapabilityContentStreamUpdates.ANYTIME);
         caps.setCapabilityJoin(CapabilityJoin.NONE);
         caps.setCapabilityQuery(CapabilityQuery.BOTHCOMBINED);
-        caps.setCapabilityRendition(CapabilityRenditions.NONE);
+        caps.setCapabilityRendition(CapabilityRenditions.READ);
         caps.setIsPwcSearchable(false);
         caps.setIsPwcUpdatable(true);
         caps.setSupportsGetDescendants(true);

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=1389574&r1=1389573&r2=1389574&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 Sep 24 21:00:15 2012
@@ -24,17 +24,17 @@ import java.util.GregorianCalendar;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.TimeZone;
 import java.util.Map.Entry;
+import java.util.TimeZone;
 
 import org.apache.chemistry.opencmis.commons.PropertyIds;
 import org.apache.chemistry.opencmis.commons.data.Acl;
 import org.apache.chemistry.opencmis.commons.data.AllowableActions;
+import org.apache.chemistry.opencmis.commons.data.ContentStream;
 import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
 import org.apache.chemistry.opencmis.commons.data.ObjectList;
 import org.apache.chemistry.opencmis.commons.data.PropertyData;
-import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
-import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+import org.apache.chemistry.opencmis.commons.data.RenditionData;
 import org.apache.chemistry.opencmis.commons.enums.RelationshipDirection;
 import org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory;
 import org.apache.chemistry.opencmis.inmemory.DataObjectCreator;
@@ -398,7 +398,6 @@ public class StoredObjectImpl implements
 			String filter, Boolean includeAllowableActions,
 			BigInteger maxItems, BigInteger skipCount,
 			ExtensionsData extension, String user) {
-		// TODO Auto-generated method stub
 		return null;
 	}
 
@@ -407,4 +406,11 @@ public class StoredObjectImpl implements
 		return actions;
 	}
 
+    public List<RenditionData> getRenditions(String renditionFilter, long maxItems,
long skipCount) {
+        return null;
+    }
+
+    public ContentStream getRenditionContent(String streamId, long offset, long length) {
+        return null;
+    }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/resources/log4j.properties
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/resources/log4j.properties?rev=1389574&r1=1389573&r2=1389574&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/resources/log4j.properties
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/resources/log4j.properties
Mon Sep 24 21:00:15 2012
@@ -35,5 +35,5 @@ log4j.appender.O.layout=org.apache.log4j
 log4j.appender.R.layout.ConversionPattern=%d{ISO8601} %-5p [%t] %c: %m%n
 log4j.appender.O.layout.ConversionPattern=%d{ISO8601} %-5p [%t] %c: %m%n
 
-log4j.logger.org.apache.chemistry.opencmis.util=INFO
-log4j.logger.org.apache.chemistry.opencmis.server.support.filter=INFO
\ No newline at end of file
+# log4j.logger.org.apache.chemistry.opencmis.inmemory=DEBUG
+# log4j.logger.org.apache.chemistry.opencmis.server.support.filter=INFO
\ No newline at end of file

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=1389574&r1=1389573&r2=1389574&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 Sep 24 21:00:15 2012
@@ -25,6 +25,10 @@ import static org.junit.Assert.assertNul
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+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.HashMap;
@@ -43,6 +47,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.ObjectParentData;
 import org.apache.chemistry.opencmis.commons.data.Properties;
 import org.apache.chemistry.opencmis.commons.data.PropertyData;
+import org.apache.chemistry.opencmis.commons.data.RenditionData;
 import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.enums.Action;
@@ -62,15 +67,17 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
 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.types.InMemoryDocumentTypeDefinition;
 import org.apache.chemistry.opencmis.inmemory.types.InMemoryFolderTypeDefinition;
 import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
 import org.apache.chemistry.opencmis.util.repository.ObjectGenerator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.omg.CORBA_2_3.portable.OutputStream;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * @author Jens
@@ -972,7 +979,82 @@ public class ObjectServiceTest extends A
         }
     }
 
+    @Test
+    public void testRendition() {
+        // upload an image as JPEG picture
+        log.info("starting testRendition() ...");
+        final String JPEG = "image/jpeg";
+        
+        try {
+            InputStream imageStream = this.getClass().getResourceAsStream("/image.jpg");
+            assertNotNull("Test setup failure no 'image.jpg' in test resources, getResourceAsStream
failed", imageStream);
+            String id = createDocumentFromStream("TestJpegImage", fRootFolderId, DOCUMENT_TYPE_ID,
imageStream,
+                    JPEG);            
+
+            assertNotNull (id);
+            String renditionFilter = "*";
+            List<RenditionData> renditions = fObjSvc.getRenditions(fRepositoryId, id,
renditionFilter, null, null, null);
+            assertNotNull(renditions);
+            assertEquals(1, renditions.size());
+            RenditionData rd = renditions.get(0);
+            assertEquals(JPEG, rd.getMimeType());
+            assertEquals("cmis:thumbnail", rd.getKind());
+            assertEquals(id, rd.getRenditionDocumentId());
+            assertNotNull(rd.getBigHeight());
+            assertNotNull(rd.getBigWidth());
+            assertEquals(DocumentImpl.IMG_HEIGHT, rd.getBigHeight().longValue());
+            assertEquals(DocumentImpl.IMG_WIDTH, rd.getBigWidth().longValue());
+            assertNotNull(rd.getStreamId());
+            ContentStream renditionContent = fObjSvc.getContentStream(fRepositoryId, id,
rd.getStreamId(), null, null, null);
+            assertEquals(rd.getMimeType(), renditionContent.getMimeType());
+            readThumbnailStream(renditionContent.getStream());
+        } catch (Exception e) {
+            log.error("testRendition failed with exception ", e);
+            fail("testRendition failed with exceetion " + e);
+        }
+        log.info("... testRendition finished.");
+   
+    }
+
+    protected String createDocumentFromStream(String name, String folderId, String typeId,
InputStream is,
+            String contentType) throws IOException {
+
+        Properties props = createDocumentProperties(name, typeId);
+
+        ContentStreamDataImpl content = new ContentStreamDataImpl(0);
+        content.setFileName(name);
+        content.setMimeType(contentType);
+
+        ByteArrayOutputStream ba = new ByteArrayOutputStream();
+        byte[] buffer = new byte [65536];
+        int noBytesRead = 0;
+
+        while ((noBytesRead = is.read(buffer)) >=0 ) {
+            ba.write(buffer, 0, noBytesRead);
+        }
+        
+        content.setContent(new ByteArrayInputStream(ba.toByteArray()));
+
+        String id = fObjSvc.createDocument(fRepositoryId, props, folderId, content, VersioningState.NONE,
null,
+                null, null, null);
+        return id;
+    }
 
+    private void readThumbnailStream(InputStream stream) {
+        
+        byte[] buffer = new byte [65536];
+        int noBytesRead = 0;
+        int count = 0;
+        try {
+            while ((noBytesRead = stream.read(buffer)) >=0 ) {
+                count += noBytesRead;
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+            fail("Reading rendition stream failed with exception " + e);
+        }
+        assertTrue(count > 0);
+    }
 
     private static void verifyAllowableActionsDocument(Set<Action> actions, boolean
isVersioned, boolean hasContent) {
         assertTrue(actions.contains(Action.CAN_DELETE_OBJECT));

Added: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/resources/image.jpg
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/resources/image.jpg?rev=1389574&view=auto
==============================================================================
Binary file - no diff available.

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/resources/image.jpg
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



Mime
View raw message