mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fixing a bug in CMISRenditionServiceImpl that was causing test failures.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19130 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -55,4 +55,15 @@ public enum CMISRenditionKind implements EnumLabel
|
|||||||
|
|
||||||
public static EnumFactory<CMISRenditionKind> FACTORY = new EnumFactory<CMISRenditionKind>(CMISRenditionKind.class);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -33,13 +33,16 @@ 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;
|
||||||
|
import org.alfresco.model.RenditionModel;
|
||||||
import org.alfresco.repo.content.transform.magick.ImageResizeOptions;
|
import org.alfresco.repo.content.transform.magick.ImageResizeOptions;
|
||||||
import org.alfresco.repo.content.transform.magick.ImageTransformationOptions;
|
import org.alfresco.repo.content.transform.magick.ImageTransformationOptions;
|
||||||
import org.alfresco.repo.thumbnail.ThumbnailDefinition;
|
import org.alfresco.repo.thumbnail.ThumbnailDefinition;
|
||||||
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.ContentData;
|
import org.alfresco.service.cmr.repository.ContentData;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
import org.alfresco.service.cmr.thumbnail.ThumbnailService;
|
import org.alfresco.service.cmr.thumbnail.ThumbnailService;
|
||||||
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rendition Service Implementation
|
* Rendition Service Implementation
|
||||||
@@ -280,7 +283,7 @@ public class CMISRenditionServiceImpl implements CMISRenditionService
|
|||||||
{
|
{
|
||||||
CMISRenditionImpl rendition = null;
|
CMISRenditionImpl rendition = null;
|
||||||
|
|
||||||
String thumbnailName = (String) nodeService.getProperty(thumbnailNode, ContentModel.PROP_THUMBNAIL_NAME);
|
String thumbnailName = getThumbnailName(thumbnailNode);
|
||||||
CMISRenditionKind kind = thumbnailNamesToKind.get(thumbnailName);
|
CMISRenditionKind kind = thumbnailNamesToKind.get(thumbnailName);
|
||||||
if (thumbnailName != null && kind != null)
|
if (thumbnailName != null && kind != null)
|
||||||
{
|
{
|
||||||
@@ -304,6 +307,19 @@ public class CMISRenditionServiceImpl implements CMISRenditionService
|
|||||||
return rendition;
|
return rendition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getThumbnailName(NodeRef thumbnailNode) {
|
||||||
|
String thumbnailName = null;
|
||||||
|
List<ChildAssociationRef> parentAssocs = nodeService.getParentAssocs(
|
||||||
|
thumbnailNode, RenditionModel.ASSOC_RENDITION,
|
||||||
|
RegexQNamePattern.MATCH_ALL);
|
||||||
|
if (parentAssocs.size() == 1)
|
||||||
|
{
|
||||||
|
ChildAssociationRef parentAssoc = parentAssocs.get(0);
|
||||||
|
thumbnailName = parentAssoc.getQName().getLocalName();
|
||||||
|
}
|
||||||
|
return thumbnailName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get custom renditions.
|
* Get custom renditions.
|
||||||
*
|
*
|
||||||
@@ -363,14 +379,7 @@ 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 = null;
|
CMISRenditionKind kind = CMISRenditionKind.valueOfLabel(entry.getKey());
|
||||||
for (CMISRenditionKind renditionKind : CMISRenditionKind.values())
|
|
||||||
{
|
|
||||||
if (renditionKind.getLabel().equals(entry.getKey()))
|
|
||||||
{
|
|
||||||
kind = renditionKind;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (String thumbnailName : entry.getValue())
|
for (String thumbnailName : entry.getValue())
|
||||||
{
|
{
|
||||||
thumbnailNamesToKind.put(thumbnailName, kind);
|
thumbnailNamesToKind.put(thumbnailName, kind);
|
||||||
|
Reference in New Issue
Block a user