mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
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:
@@ -65,6 +65,15 @@ public interface QuickShareLinks
|
|||||||
*/
|
*/
|
||||||
BinaryResource readProperty(String sharedId, String renditionId, Parameters parameters) throws EntityNotFoundException;
|
BinaryResource readProperty(String sharedId, String renditionId, Parameters parameters) throws EntityNotFoundException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets information about a rendition of a shared link.
|
||||||
|
*
|
||||||
|
* @param shareId
|
||||||
|
* @param renditionId
|
||||||
|
* @return the {@link Rendition} object
|
||||||
|
*/
|
||||||
|
Rendition getRendition(String shareId, String renditionId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List renditions info - note: only returns available (=> created) renditions.
|
* List renditions info - note: only returns available (=> created) renditions.
|
||||||
*
|
*
|
||||||
|
@@ -386,6 +386,48 @@ public class QuickShareLinksImpl implements QuickShareLinks, RecognizedParamsExt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Parameters getParamsWithCreatedStatus()
|
||||||
|
{
|
||||||
|
String filterStatusCreated = "(" + Renditions.PARAM_STATUS + "='" + Rendition.RenditionStatus.CREATED + "')";
|
||||||
|
Query whereQuery = getWhereClause(filterStatusCreated);
|
||||||
|
Params.RecognizedParams recParams = new Params.RecognizedParams(null, null, null, null, null, null, whereQuery, null, false);
|
||||||
|
Parameters params = Params.valueOf(recParams, null, null, null);
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Rendition getRendition(String sharedId, String renditionId)
|
||||||
|
{
|
||||||
|
checkEnabled();
|
||||||
|
checkValidShareId(sharedId);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Pair<String, NodeRef> pair = quickShareService.getTenantNodeRefFromSharedId(sharedId);
|
||||||
|
|
||||||
|
String networkTenantDomain = pair.getFirst();
|
||||||
|
final NodeRef nodeRef = pair.getSecond();
|
||||||
|
|
||||||
|
return TenantUtil.runAsSystemTenant(() ->
|
||||||
|
{
|
||||||
|
String nodeId = nodeRef.getId();
|
||||||
|
Parameters params = getParamsWithCreatedStatus();
|
||||||
|
return renditions.getRendition(nodeId, renditionId, params);
|
||||||
|
|
||||||
|
}, networkTenantDomain);
|
||||||
|
}
|
||||||
|
catch (InvalidSharedIdException ex)
|
||||||
|
{
|
||||||
|
logger.warn("Unable to find: " + sharedId);
|
||||||
|
throw new EntityNotFoundException(sharedId);
|
||||||
|
}
|
||||||
|
catch (InvalidNodeRefException inre)
|
||||||
|
{
|
||||||
|
logger.warn("Unable to find: " + sharedId + " [" + inre.getNodeRef() + "]");
|
||||||
|
throw new EntityNotFoundException(sharedId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CollectionWithPagingInfo<Rendition> getRenditions(String sharedId)
|
public CollectionWithPagingInfo<Rendition> getRenditions(String sharedId)
|
||||||
{
|
{
|
||||||
@@ -399,15 +441,10 @@ public class QuickShareLinksImpl implements QuickShareLinks, RecognizedParamsExt
|
|||||||
String networkTenantDomain = pair.getFirst();
|
String networkTenantDomain = pair.getFirst();
|
||||||
final NodeRef nodeRef = pair.getSecond();
|
final NodeRef nodeRef = pair.getSecond();
|
||||||
|
|
||||||
return TenantUtil.runAsSystemTenant(() -> {
|
return TenantUtil.runAsSystemTenant(() ->
|
||||||
|
{
|
||||||
String nodeId = nodeRef.getId();
|
String nodeId = nodeRef.getId();
|
||||||
|
Parameters params = getParamsWithCreatedStatus();
|
||||||
// hmm ... can we simplify ?
|
|
||||||
String filterStatusCreated = "(" + Renditions.PARAM_STATUS + "='" + Rendition.RenditionStatus.CREATED + "')";
|
|
||||||
Query whereQuery = getWhereClause(filterStatusCreated);
|
|
||||||
Params.RecognizedParams recParams = new Params.RecognizedParams(null, null, null, null, null, null, whereQuery, null, false);
|
|
||||||
Parameters params = Params.valueOf(recParams, null, null, null);
|
|
||||||
|
|
||||||
return renditions.getRenditions(nodeId, params);
|
return renditions.getRenditions(nodeId, params);
|
||||||
|
|
||||||
}, networkTenantDomain);
|
}, networkTenantDomain);
|
||||||
|
@@ -161,26 +161,12 @@ public class RenditionsImpl implements Renditions, ResourceLoaderAware
|
|||||||
Query query = parameters.getQuery();
|
Query query = parameters.getQuery();
|
||||||
boolean includeCreated = true;
|
boolean includeCreated = true;
|
||||||
boolean includeNotCreated = true;
|
boolean includeNotCreated = true;
|
||||||
if (query != null)
|
String status = getStatus(parameters);
|
||||||
|
if (status != null)
|
||||||
{
|
{
|
||||||
// Filtering via "where" clause
|
includeCreated = RenditionStatus.CREATED.equals(RenditionStatus.valueOf(status));
|
||||||
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;
|
includeNotCreated = !includeCreated;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Rendition> apiRenditions = new TreeMap<>();
|
Map<String, Rendition> apiRenditions = new TreeMap<>();
|
||||||
if (includeNotCreated)
|
if (includeNotCreated)
|
||||||
@@ -226,9 +212,15 @@ public class RenditionsImpl implements Renditions, ResourceLoaderAware
|
|||||||
{
|
{
|
||||||
final NodeRef nodeRef = validateSourceNode(nodeId);
|
final NodeRef nodeRef = validateSourceNode(nodeId);
|
||||||
NodeRef renditionNodeRef = getRenditionByName(nodeRef, renditionId, parameters);
|
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 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);
|
ThumbnailDefinition thumbnailDefinition = thumbnailService.getThumbnailRegistry().getThumbnailDefinition(renditionId);
|
||||||
if (thumbnailDefinition == null)
|
if (thumbnailDefinition == null)
|
||||||
@@ -258,6 +250,11 @@ public class RenditionsImpl implements Renditions, ResourceLoaderAware
|
|||||||
return toApiRendition(thumbnailDefinition);
|
return toApiRendition(thumbnailDefinition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (renditionNodeRef == null)
|
||||||
|
{
|
||||||
|
throw new NotFoundException("The rendition with id: " + renditionId + " was not found.");
|
||||||
|
}
|
||||||
|
|
||||||
return toApiRendition(renditionNodeRef);
|
return toApiRendition(renditionNodeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,5 +468,20 @@ public class RenditionsImpl implements Renditions, ResourceLoaderAware
|
|||||||
ContentData contentData = getContentData(nodeRef, true);
|
ContentData contentData = getContentData(nodeRef, true);
|
||||||
return contentData.getMimetype();
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -47,6 +47,7 @@ import org.springframework.beans.factory.InitializingBean;
|
|||||||
@RelationshipResource(name = "renditions", entityResource = QuickShareLinkEntityResource.class, title = "Node renditions via shared link")
|
@RelationshipResource(name = "renditions", entityResource = QuickShareLinkEntityResource.class, title = "Node renditions via shared link")
|
||||||
public class QuickShareLinkRenditionsRelation implements
|
public class QuickShareLinkRenditionsRelation implements
|
||||||
RelationshipResourceAction.Read<Rendition>,
|
RelationshipResourceAction.Read<Rendition>,
|
||||||
|
RelationshipResourceAction.ReadById<Rendition>,
|
||||||
RelationshipResourceBinaryAction.Read,
|
RelationshipResourceBinaryAction.Read,
|
||||||
InitializingBean
|
InitializingBean
|
||||||
{
|
{
|
||||||
@@ -79,5 +80,13 @@ public class QuickShareLinkRenditionsRelation implements
|
|||||||
{
|
{
|
||||||
return quickShareLinks.getRenditions(sharedId);
|
return quickShareLinks.getRenditions(sharedId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@WebApiDescription(title = "Retrieve rendition information", description = "Retrieve (created) rendition information")
|
||||||
|
@WebApiNoAuth
|
||||||
|
@Override
|
||||||
|
public Rendition readById(String entityResourceId, String id, Parameters parameters)
|
||||||
|
{
|
||||||
|
return quickShareLinks.getRendition(entityResourceId, id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user