mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fix ALF-2765: Renditions created via 3.3 RenditionService are not exposed via OpenCMIS rendition API
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@20166 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -89,14 +89,14 @@
|
|||||||
<bean class="org.alfresco.cmis.renditions.CMISRenditionImpl">
|
<bean class="org.alfresco.cmis.renditions.CMISRenditionImpl">
|
||||||
<property name="streamId"><value>alf:icon16</value></property>
|
<property name="streamId"><value>alf:icon16</value></property>
|
||||||
<property name="mimeType"><value>image/gif</value></property>
|
<property name="mimeType"><value>image/gif</value></property>
|
||||||
<property name="kind"><value>ICON16</value></property>
|
<property name="kind"><value>alf:icon16</value></property>
|
||||||
<property name="width"><value>16</value></property>
|
<property name="width"><value>16</value></property>
|
||||||
<property name="height"><value>16</value></property>
|
<property name="height"><value>16</value></property>
|
||||||
</bean>
|
</bean>
|
||||||
<bean class="org.alfresco.cmis.renditions.CMISRenditionImpl">
|
<bean class="org.alfresco.cmis.renditions.CMISRenditionImpl">
|
||||||
<property name="streamId"><value>alf:icon32</value></property>
|
<property name="streamId"><value>alf:icon32</value></property>
|
||||||
<property name="mimeType"><value>image/gif</value></property>
|
<property name="mimeType"><value>image/gif</value></property>
|
||||||
<property name="kind"><value>ICON32</value></property>
|
<property name="kind"><value>alf:icon32</value></property>
|
||||||
<property name="width"><value>32</value></property>
|
<property name="width"><value>32</value></property>
|
||||||
<property name="height"><value>32</value></property>
|
<property name="height"><value>32</value></property>
|
||||||
</bean>
|
</bean>
|
||||||
|
@@ -48,7 +48,7 @@ public interface CMISRendition
|
|||||||
* Get rendition kind.
|
* Get rendition kind.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public CMISRenditionKind getKind();
|
public String getKind();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the height of image. Typically used for ‘image’ renditions (expressed as pixels).
|
* Get the height of image. Typically used for ‘image’ renditions (expressed as pixels).
|
||||||
|
@@ -1,69 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
|
||||||
*
|
|
||||||
* This file is part of Alfresco
|
|
||||||
*
|
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package org.alfresco.cmis;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enumeration of the CMIS Rendition Kinds
|
|
||||||
*
|
|
||||||
* @author Stas Sokolovsky
|
|
||||||
*/
|
|
||||||
public enum CMISRenditionKind implements EnumLabel
|
|
||||||
{
|
|
||||||
THUMBNAIL("cmis:thumbnail"),
|
|
||||||
WEB_PREVIEW("alf:webpreview"),
|
|
||||||
ICON16("alf:icon16"),
|
|
||||||
ICON32("alf:icon32");
|
|
||||||
|
|
||||||
private String label;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct
|
|
||||||
*
|
|
||||||
* @param label
|
|
||||||
*/
|
|
||||||
CMISRenditionKind(String label)
|
|
||||||
{
|
|
||||||
this.label = label;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.alfresco.cmis.EnumLabel#label()
|
|
||||||
*/
|
|
||||||
public String getLabel()
|
|
||||||
{
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EnumFactory<CMISRenditionKind> FACTORY = new EnumFactory<CMISRenditionKind>(CMISRenditionKind.class);
|
|
||||||
|
|
||||||
public static CMISRenditionKind valueOfLabel(String label)
|
|
||||||
{
|
|
||||||
for(CMISRenditionKind kind: CMISRenditionKind.values())
|
|
||||||
{
|
|
||||||
if(kind.getLabel().equals(label))
|
|
||||||
{
|
|
||||||
return kind;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -19,7 +19,6 @@
|
|||||||
package org.alfresco.cmis.renditions;
|
package org.alfresco.cmis.renditions;
|
||||||
|
|
||||||
import org.alfresco.cmis.CMISRendition;
|
import org.alfresco.cmis.CMISRendition;
|
||||||
import org.alfresco.cmis.CMISRenditionKind;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,7 +31,7 @@ public class CMISRenditionImpl implements CMISRendition
|
|||||||
private NodeRef nodeRef;
|
private NodeRef nodeRef;
|
||||||
private String streamId;
|
private String streamId;
|
||||||
private String mimeType;
|
private String mimeType;
|
||||||
private CMISRenditionKind kind;
|
private String kind;
|
||||||
private Integer height;
|
private Integer height;
|
||||||
private Integer width;
|
private Integer width;
|
||||||
private String title;
|
private String title;
|
||||||
@@ -52,7 +51,7 @@ public class CMISRenditionImpl implements CMISRendition
|
|||||||
* @param length the length of the rendition stream in bytes
|
* @param length the length of the rendition stream in bytes
|
||||||
* @param renditionDocumentId the rendition document id
|
* @param renditionDocumentId the rendition document id
|
||||||
*/
|
*/
|
||||||
public CMISRenditionImpl(NodeRef nodeRef, String streamId, String mimeType, CMISRenditionKind kind, Integer height, Integer width, String title, Integer length, String renditionDocumentId)
|
public CMISRenditionImpl(NodeRef nodeRef, String streamId, String mimeType, String kind, Integer height, Integer width, String title, Integer length, String renditionDocumentId)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
this.nodeRef = nodeRef;
|
this.nodeRef = nodeRef;
|
||||||
@@ -113,7 +112,7 @@ public class CMISRenditionImpl implements CMISRendition
|
|||||||
/**
|
/**
|
||||||
* @see org.alfresco.cmis.CMISRendition#getKind()
|
* @see org.alfresco.cmis.CMISRendition#getKind()
|
||||||
*/
|
*/
|
||||||
public CMISRenditionKind getKind()
|
public String getKind()
|
||||||
{
|
{
|
||||||
return kind;
|
return kind;
|
||||||
}
|
}
|
||||||
@@ -123,7 +122,7 @@ public class CMISRenditionImpl implements CMISRendition
|
|||||||
*
|
*
|
||||||
* @param kind rendition kind
|
* @param kind rendition kind
|
||||||
*/
|
*/
|
||||||
public void setKind(CMISRenditionKind kind)
|
public void setKind(String kind)
|
||||||
{
|
{
|
||||||
this.kind = kind;
|
this.kind = kind;
|
||||||
}
|
}
|
||||||
|
@@ -29,7 +29,6 @@ import java.util.Map.Entry;
|
|||||||
|
|
||||||
import org.alfresco.cmis.CMISFilterNotValidException;
|
import org.alfresco.cmis.CMISFilterNotValidException;
|
||||||
import org.alfresco.cmis.CMISRendition;
|
import org.alfresco.cmis.CMISRendition;
|
||||||
import org.alfresco.cmis.CMISRenditionKind;
|
|
||||||
import org.alfresco.cmis.CMISRenditionService;
|
import org.alfresco.cmis.CMISRenditionService;
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
@@ -65,7 +64,7 @@ public class CMISRenditionServiceImpl implements CMISRenditionService
|
|||||||
|
|
||||||
/** Kind to thumbnail mapping */
|
/** Kind to thumbnail mapping */
|
||||||
private Map<String, List<String>> kindToThumbnailNames = new HashMap<String, List<String>>();
|
private Map<String, List<String>> kindToThumbnailNames = new HashMap<String, List<String>>();
|
||||||
private Map<String, CMISRenditionKind> thumbnailNamesToKind = new HashMap<String, CMISRenditionKind>();
|
private Map<String, String> thumbnailNamesToKind = new HashMap<String, String>();
|
||||||
|
|
||||||
/** Custom renditions */
|
/** Custom renditions */
|
||||||
private CustomRenditionsCache customRenditionsCache;
|
private CustomRenditionsCache customRenditionsCache;
|
||||||
@@ -200,17 +199,9 @@ public class CMISRenditionServiceImpl implements CMISRenditionService
|
|||||||
for (String filterElement : filterElements)
|
for (String filterElement : filterElements)
|
||||||
{
|
{
|
||||||
filterElement = filterElement.trim();
|
filterElement = filterElement.trim();
|
||||||
if (isRenditionKind(filterElement))
|
if (filterElement.indexOf('/') == -1)
|
||||||
{
|
{
|
||||||
CMISRenditionKind kind = null;
|
result.getKinds().add(filterElement);
|
||||||
for (CMISRenditionKind renditionKind : CMISRenditionKind.values())
|
|
||||||
{
|
|
||||||
if (renditionKind.getLabel().equals(filterElement))
|
|
||||||
{
|
|
||||||
kind = renditionKind;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result.getKinds().add(kind);
|
|
||||||
List<String> thumbnails = kindToThumbnailNames.get(filterElement);
|
List<String> thumbnails = kindToThumbnailNames.get(filterElement);
|
||||||
if (thumbnails != null)
|
if (thumbnails != null)
|
||||||
{
|
{
|
||||||
@@ -255,23 +246,6 @@ public class CMISRenditionServiceImpl implements CMISRenditionService
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param filterElement filter element
|
|
||||||
* @return true if filter element is rendition kind
|
|
||||||
*/
|
|
||||||
private boolean isRenditionKind(String filterElement)
|
|
||||||
{
|
|
||||||
boolean result = false;
|
|
||||||
for (CMISRenditionKind renditionKind : CMISRenditionKind.values())
|
|
||||||
{
|
|
||||||
if (renditionKind.getLabel().equals(filterElement))
|
|
||||||
{
|
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create CMISRendition by thumbnailNode and documentNode.
|
* Create CMISRendition by thumbnailNode and documentNode.
|
||||||
*
|
*
|
||||||
@@ -283,42 +257,40 @@ public class CMISRenditionServiceImpl implements CMISRenditionService
|
|||||||
{
|
{
|
||||||
CMISRenditionImpl rendition = null;
|
CMISRenditionImpl rendition = null;
|
||||||
|
|
||||||
String thumbnailName = getThumbnailName(thumbnailNode);
|
String thumbnailName = getThumbnailName(thumbnailNode);
|
||||||
CMISRenditionKind kind = thumbnailNamesToKind.get(thumbnailName);
|
String kind = thumbnailNamesToKind.get(thumbnailName);
|
||||||
if (thumbnailName != null && kind != null)
|
kind = (kind == null) ? thumbnailName : kind;
|
||||||
{
|
|
||||||
rendition = new CMISRenditionImpl();
|
rendition = new CMISRenditionImpl();
|
||||||
ContentData contentData = (ContentData) nodeService.getProperty(thumbnailNode, ContentModel.PROP_CONTENT);
|
ContentData contentData = (ContentData) nodeService.getProperty(thumbnailNode, ContentModel.PROP_CONTENT);
|
||||||
rendition.setNodeRef(thumbnailNode);
|
rendition.setNodeRef(thumbnailNode);
|
||||||
rendition.setStreamId(thumbnailNode.toString());
|
rendition.setStreamId(thumbnailNode.toString());
|
||||||
rendition.setRenditionDocumentId(documentNode.toString());
|
rendition.setRenditionDocumentId(documentNode.toString());
|
||||||
rendition.setTitle(thumbnailName);
|
rendition.setTitle(thumbnailName);
|
||||||
rendition.setKind(kind);
|
rendition.setKind(kind);
|
||||||
rendition.setMimeType(contentData.getMimetype());
|
rendition.setMimeType(contentData.getMimetype());
|
||||||
rendition.setLength((int) contentData.getSize());
|
rendition.setLength((int) contentData.getSize());
|
||||||
|
|
||||||
ImageResizeOptions imageAttributes = getImageAttributes(thumbnailName);
|
ImageResizeOptions imageAttributes = getImageAttributes(thumbnailName);
|
||||||
if (imageAttributes != null)
|
if (imageAttributes != null)
|
||||||
{
|
{
|
||||||
rendition.setWidth(imageAttributes.getWidth());
|
rendition.setWidth(imageAttributes.getWidth());
|
||||||
rendition.setHeight(imageAttributes.getHeight());
|
rendition.setHeight(imageAttributes.getHeight());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return rendition;
|
return rendition;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getThumbnailName(NodeRef thumbnailNode) {
|
private String getThumbnailName(NodeRef thumbnailNode)
|
||||||
String thumbnailName = null;
|
{
|
||||||
List<ChildAssociationRef> parentAssocs = nodeService.getParentAssocs(
|
String thumbnailName = null;
|
||||||
thumbnailNode, RenditionModel.ASSOC_RENDITION,
|
List<ChildAssociationRef> parentAssocs = nodeService.getParentAssocs(thumbnailNode,
|
||||||
RegexQNamePattern.MATCH_ALL);
|
RenditionModel.ASSOC_RENDITION, RegexQNamePattern.MATCH_ALL);
|
||||||
if (parentAssocs.size() == 1)
|
if (parentAssocs.size() == 1) {
|
||||||
{
|
ChildAssociationRef parentAssoc = parentAssocs.get(0);
|
||||||
ChildAssociationRef parentAssoc = parentAssocs.get(0);
|
thumbnailName = parentAssoc.getQName().getLocalName();
|
||||||
thumbnailName = parentAssoc.getQName().getLocalName();
|
}
|
||||||
}
|
return thumbnailName;
|
||||||
return thumbnailName;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get custom renditions.
|
* Get custom renditions.
|
||||||
@@ -337,7 +309,7 @@ public class CMISRenditionServiceImpl implements CMISRenditionService
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (CMISRenditionKind kind : filter.getKinds())
|
for (String kind : filter.getKinds())
|
||||||
{
|
{
|
||||||
List<CMISRendition> renditions = customRenditionsCache.getRenditionsByKind(kind);
|
List<CMISRendition> renditions = customRenditionsCache.getRenditionsByKind(kind);
|
||||||
if (renditions != null)
|
if (renditions != null)
|
||||||
@@ -379,10 +351,9 @@ public class CMISRenditionServiceImpl implements CMISRenditionService
|
|||||||
this.kindToThumbnailNames = renditionKinds;
|
this.kindToThumbnailNames = renditionKinds;
|
||||||
for (Entry<String, List<String>> entry : renditionKinds.entrySet())
|
for (Entry<String, List<String>> entry : renditionKinds.entrySet())
|
||||||
{
|
{
|
||||||
CMISRenditionKind kind = CMISRenditionKind.valueOfLabel(entry.getKey());
|
|
||||||
for (String thumbnailName : entry.getValue())
|
for (String thumbnailName : entry.getValue())
|
||||||
{
|
{
|
||||||
thumbnailNamesToKind.put(thumbnailName, kind);
|
thumbnailNamesToKind.put(thumbnailName, entry.getKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -422,7 +393,7 @@ public class CMISRenditionServiceImpl implements CMISRenditionService
|
|||||||
*/
|
*/
|
||||||
private class CustomRenditionsCache
|
private class CustomRenditionsCache
|
||||||
{
|
{
|
||||||
private Map<CMISRenditionKind, List<CMISRendition>> renditionsByKind;
|
private Map<String, List<CMISRendition>> renditionsByKind;
|
||||||
private Map<String, List<CMISRendition>> renditionsByMimeType;
|
private Map<String, List<CMISRendition>> renditionsByMimeType;
|
||||||
private Map<String, List<CMISRendition>> renditionsByBaseMimeType;
|
private Map<String, List<CMISRendition>> renditionsByBaseMimeType;
|
||||||
private List<CMISRendition> allRenditions;
|
private List<CMISRendition> allRenditions;
|
||||||
@@ -430,7 +401,7 @@ public class CMISRenditionServiceImpl implements CMISRenditionService
|
|||||||
public CustomRenditionsCache(List<CMISRendition> renditions)
|
public CustomRenditionsCache(List<CMISRendition> renditions)
|
||||||
{
|
{
|
||||||
allRenditions = renditions;
|
allRenditions = renditions;
|
||||||
renditionsByKind = new HashMap<CMISRenditionKind, List<CMISRendition>>(renditions.size());
|
renditionsByKind = new HashMap<String, List<CMISRendition>>(renditions.size());
|
||||||
renditionsByMimeType = new HashMap<String, List<CMISRendition>>(renditions.size());
|
renditionsByMimeType = new HashMap<String, List<CMISRendition>>(renditions.size());
|
||||||
renditionsByBaseMimeType = new HashMap<String, List<CMISRendition>>(renditions.size());
|
renditionsByBaseMimeType = new HashMap<String, List<CMISRendition>>(renditions.size());
|
||||||
for (CMISRendition rendition : renditions)
|
for (CMISRendition rendition : renditions)
|
||||||
@@ -454,7 +425,7 @@ public class CMISRenditionServiceImpl implements CMISRenditionService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CMISRendition> getRenditionsByKind(CMISRenditionKind kind)
|
public List<CMISRendition> getRenditionsByKind(String kind)
|
||||||
{
|
{
|
||||||
return renditionsByKind.get(kind);
|
return renditionsByKind.get(kind);
|
||||||
}
|
}
|
||||||
@@ -494,7 +465,7 @@ public class CMISRenditionServiceImpl implements CMISRenditionService
|
|||||||
*/
|
*/
|
||||||
private class ThumbnailFilter
|
private class ThumbnailFilter
|
||||||
{
|
{
|
||||||
private List<CMISRenditionKind> kinds = new ArrayList<CMISRenditionKind>();
|
private List<String> kinds = new ArrayList<String>();
|
||||||
|
|
||||||
private List<String> thumbnailNames = new ArrayList<String>();
|
private List<String> thumbnailNames = new ArrayList<String>();
|
||||||
|
|
||||||
@@ -512,7 +483,7 @@ public class CMISRenditionServiceImpl implements CMISRenditionService
|
|||||||
return mimetypes;
|
return mimetypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CMISRenditionKind> getKinds()
|
public List<String> getKinds()
|
||||||
{
|
{
|
||||||
return kinds;
|
return kinds;
|
||||||
}
|
}
|
||||||
|
@@ -27,7 +27,6 @@ import java.util.Locale;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.cmis.CMISRendition;
|
import org.alfresco.cmis.CMISRendition;
|
||||||
import org.alfresco.cmis.CMISRenditionKind;
|
|
||||||
import org.alfresco.cmis.mapping.BaseCMISTest;
|
import org.alfresco.cmis.mapping.BaseCMISTest;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
@@ -43,12 +42,12 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
|||||||
public class CMISRenditionServiceTest extends BaseCMISTest
|
public class CMISRenditionServiceTest extends BaseCMISTest
|
||||||
{
|
{
|
||||||
private static final String[] THUMBNAIL_NAMES = new String[] { "doclib", "webpreview", "imgpreview" };
|
private static final String[] THUMBNAIL_NAMES = new String[] { "doclib", "webpreview", "imgpreview" };
|
||||||
private static final CMISRenditionKind[] THUMBNAIL_KINDS = new CMISRenditionKind[] { CMISRenditionKind.THUMBNAIL, CMISRenditionKind.WEB_PREVIEW, CMISRenditionKind.WEB_PREVIEW };
|
private static final String[] THUMBNAIL_KINDS = new String[] { "cmis:thumbnail", "alf:webpreview", "alf:webpreview" };
|
||||||
|
|
||||||
private NodeRef document;
|
private NodeRef document;
|
||||||
private List<CMISRendition> documentRenditions = new ArrayList<CMISRendition>();
|
private List<CMISRendition> documentRenditions = new ArrayList<CMISRendition>();
|
||||||
private CMISRendition icon16Rendition = new CMISRenditionImpl(null, "alf:icon16", "image/gif", CMISRenditionKind.ICON16, 16, 16, null, null, null);
|
private CMISRendition icon16Rendition = new CMISRenditionImpl(null, "alf:icon16", "image/gif", "alf:icon16", 16, 16, null, null, null);
|
||||||
private CMISRendition icon32Rendition = new CMISRenditionImpl(null, "alf:icon32", "image/gif", CMISRenditionKind.ICON32, 32, 32, null, null, null);
|
private CMISRendition icon32Rendition = new CMISRenditionImpl(null, "alf:icon32", "image/gif", "alf:icon32", 32, 32, null, null, null);
|
||||||
|
|
||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
@@ -78,13 +77,13 @@ public class CMISRenditionServiceTest extends BaseCMISTest
|
|||||||
|
|
||||||
public void testGetRenditionsByKind() throws Exception
|
public void testGetRenditionsByKind() throws Exception
|
||||||
{
|
{
|
||||||
testGetRenditionsByKind(CMISRenditionKind.THUMBNAIL);
|
testGetRenditionsByKind("cmis:thumbnail");
|
||||||
testGetRenditionsByKind(CMISRenditionKind.WEB_PREVIEW);
|
testGetRenditionsByKind("alf:webpreview");
|
||||||
testGetRenditionsByKind(CMISRenditionKind.ICON16);
|
testGetRenditionsByKind("alf:icon16");
|
||||||
testGetRenditionsByKind(CMISRenditionKind.ICON32);
|
testGetRenditionsByKind("alf:icon32");
|
||||||
|
|
||||||
testGetRenditionsByKind(CMISRenditionKind.WEB_PREVIEW, CMISRenditionKind.ICON32);
|
testGetRenditionsByKind("alf:webpreview", "alf:icon32");
|
||||||
testGetRenditionsByKind(CMISRenditionKind.THUMBNAIL, CMISRenditionKind.WEB_PREVIEW, CMISRenditionKind.ICON16, CMISRenditionKind.ICON32);
|
testGetRenditionsByKind("cmis:thumbnail", "alf:webpreview", "alf:icon16", "alf:icon32");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetRenditionsByMimetype() throws Exception
|
public void testGetRenditionsByMimetype() throws Exception
|
||||||
@@ -136,12 +135,12 @@ public class CMISRenditionServiceTest extends BaseCMISTest
|
|||||||
testGetRenditions(null, mimetypes);
|
testGetRenditions(null, mimetypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testGetRenditionsByKind(CMISRenditionKind... kinds) throws Exception
|
private void testGetRenditionsByKind(String... kinds) throws Exception
|
||||||
{
|
{
|
||||||
testGetRenditions(kinds, null);
|
testGetRenditions(kinds, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testGetRenditions(CMISRenditionKind[] kinds, String[] mimetypes) throws Exception
|
private void testGetRenditions(String[] kinds, String[] mimetypes) throws Exception
|
||||||
{
|
{
|
||||||
String filter = createFilter(kinds, mimetypes);
|
String filter = createFilter(kinds, mimetypes);
|
||||||
List<CMISRendition> receivedRenditions = cmisRenditionService.getRenditions(document, filter);
|
List<CMISRendition> receivedRenditions = cmisRenditionService.getRenditions(document, filter);
|
||||||
@@ -149,7 +148,7 @@ public class CMISRenditionServiceTest extends BaseCMISTest
|
|||||||
List<CMISRendition> expectedRenditions = new ArrayList<CMISRendition>();
|
List<CMISRendition> expectedRenditions = new ArrayList<CMISRendition>();
|
||||||
if (kinds != null)
|
if (kinds != null)
|
||||||
{
|
{
|
||||||
for (CMISRenditionKind kind : kinds)
|
for (String kind : kinds)
|
||||||
{
|
{
|
||||||
expectedRenditions.addAll(getRenditionsByKind(kind));
|
expectedRenditions.addAll(getRenditionsByKind(kind));
|
||||||
}
|
}
|
||||||
@@ -171,7 +170,7 @@ public class CMISRenditionServiceTest extends BaseCMISTest
|
|||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
private CMISRendition createRendition(NodeRef nodeRef, String thumbnailName, CMISRenditionKind kind)
|
private CMISRendition createRendition(NodeRef nodeRef, String thumbnailName, String kind)
|
||||||
{
|
{
|
||||||
ThumbnailDefinition details = thumbnailService.getThumbnailRegistry().getThumbnailDefinition(thumbnailName);
|
ThumbnailDefinition details = thumbnailService.getThumbnailRegistry().getThumbnailDefinition(thumbnailName);
|
||||||
NodeRef thumbnailNodeRef = thumbnailService.createThumbnail(nodeRef, ContentModel.PROP_CONTENT, details.getMimetype(), details.getTransformationOptions(), details
|
NodeRef thumbnailNodeRef = thumbnailService.createThumbnail(nodeRef, ContentModel.PROP_CONTENT, details.getMimetype(), details.getTransformationOptions(), details
|
||||||
@@ -260,7 +259,7 @@ public class CMISRenditionServiceTest extends BaseCMISTest
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private List<CMISRendition> getRenditionsByKind(CMISRenditionKind kind)
|
private List<CMISRendition> getRenditionsByKind(String kind)
|
||||||
{
|
{
|
||||||
return getRenditions(kind, null);
|
return getRenditions(kind, null);
|
||||||
}
|
}
|
||||||
@@ -270,7 +269,7 @@ public class CMISRenditionServiceTest extends BaseCMISTest
|
|||||||
return getRenditions(null, mimetype);
|
return getRenditions(null, mimetype);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<CMISRendition> getRenditions(CMISRenditionKind kind, String mimetype)
|
private List<CMISRendition> getRenditions(String kind, String mimetype)
|
||||||
{
|
{
|
||||||
List<CMISRendition> result = new ArrayList<CMISRendition>();
|
List<CMISRendition> result = new ArrayList<CMISRendition>();
|
||||||
|
|
||||||
@@ -287,7 +286,7 @@ public class CMISRenditionServiceTest extends BaseCMISTest
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isRenditionSatisfyConditions(CMISRendition rendition, CMISRenditionKind kind, String mimetype)
|
private boolean isRenditionSatisfyConditions(CMISRendition rendition, String kind, String mimetype)
|
||||||
{
|
{
|
||||||
if (kind != null)
|
if (kind != null)
|
||||||
{
|
{
|
||||||
@@ -338,14 +337,14 @@ public class CMISRenditionServiceTest extends BaseCMISTest
|
|||||||
return baseMymetype;
|
return baseMymetype;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String createFilter(CMISRenditionKind[] kinds, String[] mimetypes)
|
private String createFilter(String[] kinds, String[] mimetypes)
|
||||||
{
|
{
|
||||||
StringBuilder filter = new StringBuilder();
|
StringBuilder filter = new StringBuilder();
|
||||||
if (kinds != null)
|
if (kinds != null)
|
||||||
{
|
{
|
||||||
for (CMISRenditionKind kind : kinds)
|
for (String kind : kinds)
|
||||||
{
|
{
|
||||||
filter.append(kind.getLabel());
|
filter.append(kind);
|
||||||
filter.append(",");
|
filter.append(",");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user