mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
REPO-1713: V1 REST API - simplify exception handling for multi-part upload
- was: exceptions from behaviour beans are being returned as 500 during upload (as per RM extended use-case) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@133603 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -136,9 +136,7 @@
|
||||
<property name="exceptionMappings">
|
||||
<map>
|
||||
<entry key="org.alfresco.rest.framework.core.exceptions.ApiException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_INTERNAL_SERVER_ERROR}" />
|
||||
<entry key="java.lang.NullPointerException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_INTERNAL_SERVER_ERROR}" />
|
||||
<entry key="java.lang.IndexOutOfBoundsException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_INTERNAL_SERVER_ERROR}" />
|
||||
<entry key="java.lang.OutOfMemoryError" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_INTERNAL_SERVER_ERROR}" />
|
||||
<entry key="java.lang.Throwable" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_INTERNAL_SERVER_ERROR}" />
|
||||
<entry key="java.lang.IllegalArgumentException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_BAD_REQUEST}" />
|
||||
<entry key="org.alfresco.service.cmr.repository.CyclicChildRelationshipException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_BAD_REQUEST}" />
|
||||
<entry key="org.alfresco.rest.framework.core.exceptions.InvalidArgumentException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_BAD_REQUEST}" />
|
||||
|
@@ -2937,25 +2937,16 @@ public class NodesImpl implements Nodes
|
||||
// Do not clean formData temp files to allow for retries.
|
||||
// Temp files will be deleted later when GC call DiskFileItem#finalize() method or by temp file cleaner.
|
||||
}
|
||||
catch (ApiException apiEx)
|
||||
{
|
||||
// As this is an public API fwk exception, there is no need to convert it, so just throw it.
|
||||
throw apiEx;
|
||||
}
|
||||
catch (AccessDeniedException ade)
|
||||
{
|
||||
throw new PermissionDeniedException(ade.getMessage());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
/*
|
||||
* NOTE: Do not clean formData temp files to allow for retries. It's
|
||||
* possible for a temp file to remain if max retry attempts are
|
||||
* made, but this is rare, so leave to usual temp file cleanup.
|
||||
*/
|
||||
|
||||
throw new ApiException("Unexpected error occurred during upload of new content.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private NodeRef createNewFile(NodeRef parentNodeRef, String fileName, QName nodeType, Content content, Map<QName, Serializable> props, QName assocTypeQName, Parameters params,
|
||||
|
@@ -1389,6 +1389,14 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
|
||||
.setRelativePath("userTwoFolder1/userTwoFolder2")
|
||||
.build();
|
||||
post(getNodeChildrenUrl(folderA_id), reqBody.getBody(), null, reqBody.getContentType(), 403);
|
||||
|
||||
// -ve test: integrity error
|
||||
setRequestContext(user1);
|
||||
reqBody = MultiPartBuilder.create()
|
||||
.setFileData(new FileData("invalid:name", file))
|
||||
.build();
|
||||
// 422 -> invalid name (includes a ':' in this example)
|
||||
post(getNodeChildrenUrl(coolFolder.getId()), reqBody.getBody(), null, reqBody.getContentType(), 422);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user