From c3282977ec16fd793d515741cb573a0719fdc045 Mon Sep 17 00:00:00 2001 From: Ancuta Morarasu Date: Wed, 11 May 2016 11:48:09 +0000 Subject: [PATCH] Merged HEAD (5.2) to 5.2.N (5.2.1) 126513 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2) 122834 jkaabimofrad: RA-678: Modified the response, to return 409 rather than 400 when the rendition requested already exists. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126857 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- source/java/org/alfresco/rest/api/impl/RenditionsImpl.java | 3 ++- .../test-java/org/alfresco/rest/api/tests/RenditionsTest.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/source/java/org/alfresco/rest/api/impl/RenditionsImpl.java b/source/java/org/alfresco/rest/api/impl/RenditionsImpl.java index 927b01f7ef..8cb5aa09d4 100644 --- a/source/java/org/alfresco/rest/api/impl/RenditionsImpl.java +++ b/source/java/org/alfresco/rest/api/impl/RenditionsImpl.java @@ -32,6 +32,7 @@ import org.alfresco.rest.api.model.ContentInfo; import org.alfresco.rest.api.model.Rendition; import org.alfresco.rest.api.model.Rendition.RenditionStatus; import org.alfresco.rest.framework.core.exceptions.ApiException; +import org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException; import org.alfresco.rest.framework.core.exceptions.DisabledServiceException; import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException; import org.alfresco.rest.framework.core.exceptions.NotFoundException; @@ -257,7 +258,7 @@ public class RenditionsImpl implements Renditions, ResourceLoaderAware final NodeRef renditionNodeRef = getRenditionByName(sourceNodeRef, rendition.getId(), parameters); if (renditionNodeRef != null) { - throw new InvalidArgumentException(rendition.getId() + " rendition already exists."); + throw new ConstraintViolatedException(rendition.getId() + " rendition already exists."); } // Use the thumbnail registry to get the details of the thumbnail diff --git a/source/test-java/org/alfresco/rest/api/tests/RenditionsTest.java b/source/test-java/org/alfresco/rest/api/tests/RenditionsTest.java index 7ed67e761b..dbae120bd7 100644 --- a/source/test-java/org/alfresco/rest/api/tests/RenditionsTest.java +++ b/source/test-java/org/alfresco/rest/api/tests/RenditionsTest.java @@ -362,14 +362,14 @@ public class RenditionsTest extends AbstractBaseApiTest // -ve Tests // The rendition requested already exists - response = post(getRenditionsUrl(contentNodeId), userOneN1.getId(), toJsonAsString(new Rendition().setId("imgpreview")), 400); + response = post(getRenditionsUrl(contentNodeId), userOneN1.getId(), toJsonAsString(new Rendition().setId("imgpreview")), 409); ExpectedErrorResponse errorResponse = RestApiUtil.parseErrorResponse(response.getJsonResponse()); assertNotNull(errorResponse); assertNotNull(errorResponse.getErrorKey()); assertNotNull(errorResponse.getBriefSummary()); assertNotNull(errorResponse.getStackTrace()); assertNotNull(errorResponse.getDescriptionURL()); - assertEquals(400, errorResponse.getStatusCode()); + assertEquals(409, errorResponse.getStatusCode()); // Create 'doclib' rendition request Rendition renditionRequest = new Rendition().setId("doclib");