Merged 5.2.N (5.2.1) to HEAD (5.2)

131302 rmunteanu: REPO-1354: Get Rendition info - implement the API
      - implemented get rendition info by id method


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@132240 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2016-11-03 13:48:04 +00:00
parent 03acdaef03
commit 0deb44526b
4 changed files with 94 additions and 27 deletions

View File

@@ -161,25 +161,11 @@ public class RenditionsImpl implements Renditions, ResourceLoaderAware
Query query = parameters.getQuery();
boolean includeCreated = true;
boolean includeNotCreated = true;
if (query != null)
String status = getStatus(parameters);
if (status != null)
{
// Filtering via "where" clause
MapBasedQueryWalker propertyWalker = new MapBasedQueryWalker(RENDITION_STATUS_COLLECTION_EQUALS_QUERY_PROPERTIES, null);
QueryHelper.walk(query, propertyWalker);
String withStatus = propertyWalker.getProperty(PARAM_STATUS, WhereClauseParser.EQUALS);
if (withStatus != null)
{
try
{
includeCreated = RenditionStatus.CREATED.equals(RenditionStatus.valueOf(withStatus));
}
catch (IllegalArgumentException ex)
{
throw new InvalidArgumentException("Invalid status value: " + withStatus);
}
includeNotCreated = !includeCreated;
}
includeCreated = RenditionStatus.CREATED.equals(RenditionStatus.valueOf(status));
includeNotCreated = !includeCreated;
}
Map<String, Rendition> apiRenditions = new TreeMap<>();
@@ -226,9 +212,15 @@ public class RenditionsImpl implements Renditions, ResourceLoaderAware
{
final NodeRef nodeRef = validateSourceNode(nodeId);
NodeRef renditionNodeRef = getRenditionByName(nodeRef, renditionId, parameters);
boolean includeNotCreated = true;
String status = getStatus(parameters);
if (status != null)
{
includeNotCreated = !RenditionStatus.CREATED.equals(RenditionStatus.valueOf(status));
}
// if there is no rendition, then try to find the available/registered rendition (yet to be created).
if (renditionNodeRef == null)
if (renditionNodeRef == null && includeNotCreated)
{
ThumbnailDefinition thumbnailDefinition = thumbnailService.getThumbnailRegistry().getThumbnailDefinition(renditionId);
if (thumbnailDefinition == null)
@@ -258,6 +250,11 @@ public class RenditionsImpl implements Renditions, ResourceLoaderAware
return toApiRendition(thumbnailDefinition);
}
if (renditionNodeRef == null)
{
throw new NotFoundException("The rendition with id: " + renditionId + " was not found.");
}
return toApiRendition(renditionNodeRef);
}
@@ -471,5 +468,20 @@ public class RenditionsImpl implements Renditions, ResourceLoaderAware
ContentData contentData = getContentData(nodeRef, true);
return contentData.getMimetype();
}
private String getStatus(Parameters parameters)
{
Query query = parameters.getQuery();
String status = null;
if (query != null)
{
// Filtering via "where" clause
MapBasedQueryWalker propertyWalker = new MapBasedQueryWalker(RENDITION_STATUS_COLLECTION_EQUALS_QUERY_PROPERTIES, null);
QueryHelper.walk(query, propertyWalker);
status = propertyWalker.getProperty(PARAM_STATUS, WhereClauseParser.EQUALS);
}
return status;
}
}