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.cmr.version.VersionType;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.namespace.QName;
|
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.Pair;
|
||||||
import org.alfresco.util.PropertyCheck;
|
import org.alfresco.util.PropertyCheck;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
@@ -152,6 +150,7 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
@@ -2447,8 +2446,8 @@ public class NodesImpl implements Nodes
|
|||||||
|
|
||||||
// if requested, make (get or create) path
|
// if requested, make (get or create) path
|
||||||
parentNodeRef = getOrCreatePath(parentNodeRef, relativePath);
|
parentNodeRef = getOrCreatePath(parentNodeRef, relativePath);
|
||||||
|
final QName assocTypeQName = ContentModel.ASSOC_CONTAINS;
|
||||||
QName assocTypeQName = ContentModel.ASSOC_CONTAINS;
|
final Set<String> renditions = getRequestedRenditions(renditionNames);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -2491,7 +2490,7 @@ public class NodesImpl implements Nodes
|
|||||||
// RA-1052
|
// RA-1052
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<ThumbnailDefinition> thumbnailDefs = getThumbnailDefs(renditionNames);
|
List<ThumbnailDefinition> thumbnailDefs = getThumbnailDefs(renditions);
|
||||||
requestRenditions(thumbnailDefs, fileNode);
|
requestRenditions(thumbnailDefs, fileNode);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -2568,11 +2567,11 @@ public class NodesImpl implements Nodes
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ThumbnailDefinition> getThumbnailDefs(String renditionsParam)
|
private List<ThumbnailDefinition> getThumbnailDefs(Set<String> renditionNames)
|
||||||
{
|
{
|
||||||
List<ThumbnailDefinition> thumbnailDefs = null;
|
List<ThumbnailDefinition> thumbnailDefs = null;
|
||||||
|
|
||||||
if (renditionsParam != null)
|
if (renditionNames != null)
|
||||||
{
|
{
|
||||||
// If thumbnail generation has been configured off, then don't bother.
|
// If thumbnail generation has been configured off, then don't bother.
|
||||||
if (!thumbnailService.getThumbnailsEnabled())
|
if (!thumbnailService.getThumbnailsEnabled())
|
||||||
@@ -2580,37 +2579,53 @@ public class NodesImpl implements Nodes
|
|||||||
throw new DisabledServiceException("Thumbnail generation has been disabled.");
|
throw new DisabledServiceException("Thumbnail generation has been disabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] renditionNames = renditionsParam.split(",");
|
thumbnailDefs = new ArrayList<>(renditionNames.size());
|
||||||
|
|
||||||
// Temporary - pending future improvements to thumbnail service to minimise chance of
|
|
||||||
// missing/failed thumbnails (when requested/generated 'concurrently')
|
|
||||||
if (renditionNames.length > 1)
|
|
||||||
{
|
|
||||||
throw new InvalidArgumentException("Please specify one rendition entity id only");
|
|
||||||
}
|
|
||||||
|
|
||||||
thumbnailDefs = new ArrayList<>(renditionNames.length);
|
|
||||||
ThumbnailRegistry registry = thumbnailService.getThumbnailRegistry();
|
ThumbnailRegistry registry = thumbnailService.getThumbnailRegistry();
|
||||||
for (String renditionName : renditionNames)
|
for (String renditionName : renditionNames)
|
||||||
{
|
{
|
||||||
renditionName = renditionName.trim();
|
// Use the thumbnail registry to get the details of the thumbnail
|
||||||
if (!renditionName.isEmpty())
|
ThumbnailDefinition thumbnailDef = registry.getThumbnailDefinition(renditionName);
|
||||||
|
if (thumbnailDef == null)
|
||||||
{
|
{
|
||||||
// Use the thumbnail registry to get the details of the thumbnail
|
throw new NotFoundException(renditionName + " is not registered.");
|
||||||
ThumbnailDefinition thumbnailDef = registry.getThumbnailDefinition(renditionName);
|
|
||||||
if (thumbnailDef == null)
|
|
||||||
{
|
|
||||||
throw new NotFoundException(renditionName + " is not registered.");
|
|
||||||
}
|
|
||||||
|
|
||||||
thumbnailDefs.add(thumbnailDef);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
thumbnailDefs.add(thumbnailDef);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return thumbnailDefs;
|
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
|
||||||
|
// missing/failed thumbnails (when requested/generated 'concurrently')
|
||||||
|
if (renditionNames.length > 1)
|
||||||
|
{
|
||||||
|
throw new InvalidArgumentException("Please specify one rendition entity id only");
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<String> renditions = new LinkedHashSet<>(renditionNames.length);
|
||||||
|
for (String name : renditionNames)
|
||||||
|
{
|
||||||
|
name = name.trim();
|
||||||
|
if (!name.isEmpty())
|
||||||
|
{
|
||||||
|
renditions.add(name.trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return renditions;
|
||||||
|
}
|
||||||
|
|
||||||
private void requestRenditions(List<ThumbnailDefinition> thumbnailDefs, Node fileNode)
|
private void requestRenditions(List<ThumbnailDefinition> thumbnailDefs, Node fileNode)
|
||||||
{
|
{
|
||||||
if (thumbnailDefs != null)
|
if (thumbnailDefs != null)
|
||||||
|
@@ -546,7 +546,7 @@ public class RenditionsTest extends AbstractBaseApiTest
|
|||||||
.setRenditions(Arrays.asList(new String[]{"doclib,imgpreview"}))
|
.setRenditions(Arrays.asList(new String[]{"doclib,imgpreview"}))
|
||||||
.build();
|
.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
|
// Unknown rendition
|
||||||
reqBody = MultiPartBuilder.create()
|
reqBody = MultiPartBuilder.create()
|
||||||
|
Reference in New Issue
Block a user