mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD (5.2) to 5.2.N (5.2.1)
127617 jkaabimofrad: Merged API-STRIKES-BACK (5.2.0) to HEAD (5.2) 127512 jkaabimofrad: REPO-47: Per peer review, changed the upload API to throw an exception when requesting multiple renditions. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@127724 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -129,8 +129,6 @@ import org.alfresco.service.cmr.version.VersionService;
|
||||
import org.alfresco.service.cmr.version.VersionType;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.namespace.QNamePattern;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.util.PropertyCheck;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -152,6 +150,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@@ -2447,8 +2446,8 @@ public class NodesImpl implements Nodes
|
||||
|
||||
// if requested, make (get or create) path
|
||||
parentNodeRef = getOrCreatePath(parentNodeRef, relativePath);
|
||||
|
||||
QName assocTypeQName = ContentModel.ASSOC_CONTAINS;
|
||||
final QName assocTypeQName = ContentModel.ASSOC_CONTAINS;
|
||||
final Set<String> renditions = getRequestedRenditions(renditionNames);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -2491,7 +2490,7 @@ public class NodesImpl implements Nodes
|
||||
// RA-1052
|
||||
try
|
||||
{
|
||||
List<ThumbnailDefinition> thumbnailDefs = getThumbnailDefs(renditionNames);
|
||||
List<ThumbnailDefinition> thumbnailDefs = getThumbnailDefs(renditions);
|
||||
requestRenditions(thumbnailDefs, fileNode);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -2568,11 +2567,11 @@ public class NodesImpl implements Nodes
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<ThumbnailDefinition> getThumbnailDefs(String renditionsParam)
|
||||
private List<ThumbnailDefinition> getThumbnailDefs(Set<String> renditionNames)
|
||||
{
|
||||
List<ThumbnailDefinition> thumbnailDefs = null;
|
||||
|
||||
if (renditionsParam != null)
|
||||
if (renditionNames != null)
|
||||
{
|
||||
// If thumbnail generation has been configured off, then don't bother.
|
||||
if (!thumbnailService.getThumbnailsEnabled())
|
||||
@@ -2580,6 +2579,32 @@ public class NodesImpl implements Nodes
|
||||
throw new DisabledServiceException("Thumbnail generation has been disabled.");
|
||||
}
|
||||
|
||||
thumbnailDefs = new ArrayList<>(renditionNames.size());
|
||||
ThumbnailRegistry registry = thumbnailService.getThumbnailRegistry();
|
||||
for (String renditionName : renditionNames)
|
||||
{
|
||||
// Use the thumbnail registry to get the details of the thumbnail
|
||||
ThumbnailDefinition thumbnailDef = registry.getThumbnailDefinition(renditionName);
|
||||
if (thumbnailDef == null)
|
||||
{
|
||||
throw new NotFoundException(renditionName + " is not registered.");
|
||||
}
|
||||
|
||||
thumbnailDefs.add(thumbnailDef);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return thumbnailDefs;
|
||||
}
|
||||
|
||||
private Set<String> getRequestedRenditions(String renditionsParam)
|
||||
{
|
||||
if (renditionsParam == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
String[] renditionNames = renditionsParam.split(",");
|
||||
|
||||
// Temporary - pending future improvements to thumbnail service to minimise chance of
|
||||
@@ -2589,26 +2614,16 @@ public class NodesImpl implements Nodes
|
||||
throw new InvalidArgumentException("Please specify one rendition entity id only");
|
||||
}
|
||||
|
||||
thumbnailDefs = new ArrayList<>(renditionNames.length);
|
||||
ThumbnailRegistry registry = thumbnailService.getThumbnailRegistry();
|
||||
for (String renditionName : renditionNames)
|
||||
Set<String> renditions = new LinkedHashSet<>(renditionNames.length);
|
||||
for (String name : renditionNames)
|
||||
{
|
||||
renditionName = renditionName.trim();
|
||||
if (!renditionName.isEmpty())
|
||||
name = name.trim();
|
||||
if (!name.isEmpty())
|
||||
{
|
||||
// Use the thumbnail registry to get the details of the thumbnail
|
||||
ThumbnailDefinition thumbnailDef = registry.getThumbnailDefinition(renditionName);
|
||||
if (thumbnailDef == null)
|
||||
{
|
||||
throw new NotFoundException(renditionName + " is not registered.");
|
||||
}
|
||||
|
||||
thumbnailDefs.add(thumbnailDef);
|
||||
renditions.add(name.trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return thumbnailDefs;
|
||||
return renditions;
|
||||
}
|
||||
|
||||
private void requestRenditions(List<ThumbnailDefinition> thumbnailDefs, Node fileNode)
|
||||
|
@@ -546,7 +546,7 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
.setRenditions(Arrays.asList(new String[]{"doclib,imgpreview"}))
|
||||
.build();
|
||||
|
||||
post(getNodeChildrenUrl(folder_Id), userId, reqBody.getBody(), null, reqBody.getContentType(), 201);
|
||||
post(getNodeChildrenUrl(folder_Id), userId, reqBody.getBody(), null, reqBody.getContentType(), 400);
|
||||
|
||||
// Unknown rendition
|
||||
reqBody = MultiPartBuilder.create()
|
||||
|
Reference in New Issue
Block a user