chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1390644 - in /chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory: ./ server/ storedobj/api/ storedobj/impl/ types/
Date Wed, 26 Sep 2012 18:33:15 GMT
Author: jens
Date: Wed Sep 26 18:33:15 2012
New Revision: 1390644

URL: http://svn.apache.org/viewvc?rev=1390644&view=rev
Log:
InMemory: Rendition support [CMIS-576]

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DataObjectCreator.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.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/StoredObjectImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DataObjectCreator.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/DataObjectCreator.java?rev=1390644&r1=1390643&r2=1390644&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DataObjectCreator.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DataObjectCreator.java
Wed Sep 26 18:33:15 2012
@@ -67,6 +67,7 @@ public class DataObjectCreator {
         boolean isVersioned = so instanceof Version || so instanceof VersionedDocument;
         boolean hasContent = so instanceof Content && ((Content) so).hasContent();
         boolean isRootFolder = isFolder && ((Folder)so).getParent() == null;
+        boolean hasRendition = so.hasRendition(user);
         
         if (so instanceof Version) {
             isCheckedOut = ((Version) so).isPwc();
@@ -135,6 +136,10 @@ public class DataObjectCreator {
                 set.add(Action.CAN_SET_CONTENT_STREAM);
         }
 
+        if (hasRendition) {
+            set.add(Action.CAN_GET_RENDITIONS);
+        }
+        
         allowableActions.setAllowableActions(set);
         return allowableActions;
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.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/InMemoryNavigationServiceImpl.java?rev=1390644&r1=1390643&r2=1390644&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java
Wed Sep 26 18:33:15 2012
@@ -257,7 +257,7 @@ public class InMemoryNavigationServiceIm
 
         result = getObjectParentsIntern(repositoryId, spo, filter, 
         		context.isObjectInfoRequired() ? objectInfos : null, includeAllowableActions, includeRelationships,
-				context.getUsername());
+				renditionFilter, context.getUsername());
 
         // To be able to provide all Atom links in the response we need
         // additional information:
@@ -368,7 +368,7 @@ public class InMemoryNavigationServiceIm
 
     private List<ObjectParentData> getObjectParentsIntern(String repositoryId, Filing
sop, String filter,
             ObjectInfoHandler objectInfos, Boolean includeAllowableActions, 
-            IncludeRelationships includeRelationships, String user) {
+            IncludeRelationships includeRelationships, String renditionFilter, String user)
{
 
         List<ObjectParentData> result = null;
         if (sop instanceof SingleFiling) {
@@ -395,7 +395,7 @@ public class InMemoryNavigationServiceIm
                     ObjectParentDataImpl parentData = new ObjectParentDataImpl();
                     TypeDefinition typeDef = fStoreManager.getTypeById(repositoryId, parent.getTypeId()).getTypeDefinition();
                     ObjectData objData = PropertyCreationHelper.getObjectData(typeDef, parent,
filter, user, includeAllowableActions, 
-                            includeRelationships, "", false, true, null);
+                            includeRelationships, renditionFilter, false, true, null);
 
                     parentData.setObject(objData);
                     parentData.setRelativePathSegment(multiParentObj.getPathSegment());

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=1390644&r1=1390643&r2=1390644&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
Wed Sep 26 18:33:15 2012
@@ -284,6 +284,13 @@ public interface StoredObject {
 	AllowableActions getAllowableActions(String user);
 	
     /**
+     * check if the document can generate a renditions and rendition is visible for user
+     * @return
+     *   true if rendition exists, false if not.
+     */
+    public boolean hasRendition(String user);
+    
+	/**
      * get the rendition this objects supports
      * 
      * @param renditionFilter

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=1390644&r1=1390643&r2=1390644&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
Wed Sep 26 18:33:15 2012
@@ -179,10 +179,12 @@ public class DocumentImpl extends Abstra
     public List<RenditionData> getRenditions(String renditionFilter,
             long maxItems, long skipCount) {
 
-        String tokenizer = "[\\s;]";                        
+        String tokenizer = "[\\s;]";
+        if (null==renditionFilter)
+            renditionFilter = "*";
         String[] formats = renditionFilter.split(tokenizer);
         boolean isImageRendition = testRenditionFilterForImage(formats);
-        if (isImageRendition) {
+        if (isImageRendition && fContent != null && hasRendition(null)) {
             List<RenditionData> renditions = new ArrayList<RenditionData>(1);
             RenditionDataImpl rendition = new RenditionDataImpl();
             rendition.setBigHeight(BigInteger.valueOf(IMG_HEIGHT));
@@ -204,9 +206,18 @@ public class DocumentImpl extends Abstra
         ImageThumbnailGenerator generator = new ImageThumbnailGenerator(getContent(0L, -1L).getStream());
         return generator.getRendition(IMG_WIDTH, IMG_HEIGHT);
     }
+    
+    @Override
+    public boolean hasRendition(String user) {
+        return null != fContent && fContent.getMimeType().startsWith("image/");
+    }
+
 
     protected boolean testRenditionFilterForImage(String[] formats) {
-        return arrayContainsString(formats, "*")  || arrayContainsString(formats, "image/*")

+        if (formats.length == 1 && null != formats[0] && formats[0].equals("cmis:none"))
+            return false;
+        else
+            return arrayContainsString(formats, "*")  || arrayContainsString(formats, "image/*")

                 || arrayContainsString(formats, "image/jpeg") ;
     }
 

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=1390644&r1=1390643&r2=1390644&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
Wed Sep 26 18:33:15 2012
@@ -413,4 +413,8 @@ public class StoredObjectImpl implements
     public ContentStream getRenditionContent(String streamId, long offset, long length) {
         return null;
     }
+
+    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/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=1390644&r1=1390643&r2=1390644&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
Wed Sep 26 18:33:15 2012
@@ -35,6 +35,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.ObjectData;
 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.Choice;
 import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
@@ -344,6 +345,10 @@ public class PropertyCreationHelper {
             od.setAllowableActions(allowableActions);
         }
 
+        List<RenditionData> renditions = so.getRenditions(renditionFilter, 0, 0);
+        if (null != renditions && renditions.size() > 0)
+            od.setRenditions(renditions);
+
         if (null != includeACL && includeACL) {
             Acl acl = so instanceof DocumentVersion ? ((DocumentVersion) so).getParentDocument().getAcl()
: so.getAcl();
             od.setAcl(acl);



Mime
View raw message