mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2)
124207 jvonka: RA-893: Fix "Multi-part update content appears to work but doesn't" - throw 415 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@126553 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -146,6 +146,7 @@
|
||||
<entry key="org.alfresco.rest.framework.core.exceptions.DisabledServiceException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_NOT_IMPLEMENTED}" />
|
||||
<entry key="org.alfresco.rest.framework.core.exceptions.InsufficientStorageException" value="507" />
|
||||
<entry key="org.alfresco.repo.node.integrity.IntegrityException" value="422" />
|
||||
<entry key="org.alfresco.rest.framework.core.exceptions.UnsupportedMediaTypeException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_UNSUPPORTED_MEDIA_TYPE}" />
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
@@ -72,6 +72,7 @@ import org.alfresco.rest.framework.core.exceptions.InsufficientStorageException;
|
||||
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
||||
import org.alfresco.rest.framework.core.exceptions.PermissionDeniedException;
|
||||
import org.alfresco.rest.framework.core.exceptions.RequestEntityTooLargeException;
|
||||
import org.alfresco.rest.framework.core.exceptions.UnsupportedMediaTypeException;
|
||||
import org.alfresco.rest.framework.resource.content.BasicContentInfo;
|
||||
import org.alfresco.rest.framework.resource.content.BinaryResource;
|
||||
import org.alfresco.rest.framework.resource.content.ContentInfoImpl;
|
||||
@@ -1796,6 +1797,11 @@ public class NodesImpl implements Nodes
|
||||
@Override
|
||||
public Node updateContent(String fileNodeId, BasicContentInfo contentInfo, InputStream stream, Parameters parameters)
|
||||
{
|
||||
if (contentInfo.getMimeType().toLowerCase().startsWith("multipart"))
|
||||
{
|
||||
throw new UnsupportedMediaTypeException("Cannot update using "+contentInfo.getMimeType());
|
||||
}
|
||||
|
||||
final NodeRef nodeRef = validateNode(fileNodeId);
|
||||
|
||||
if (! nodeMatches(nodeRef, Collections.singleton(ContentModel.TYPE_CONTENT), null, false))
|
||||
|
@@ -0,0 +1,26 @@
|
||||
package org.alfresco.rest.framework.core.exceptions;
|
||||
|
||||
/**
|
||||
* The media type is unsupported.
|
||||
*
|
||||
* @author janv
|
||||
*/
|
||||
public class UnsupportedMediaTypeException extends ApiException
|
||||
{
|
||||
public static String DEFAULT_MESSAGE_ID = "framework.exception.UnsupportedMediaType";
|
||||
|
||||
public UnsupportedMediaTypeException()
|
||||
{
|
||||
super(DEFAULT_MESSAGE_ID);
|
||||
}
|
||||
|
||||
public UnsupportedMediaTypeException(String msgId)
|
||||
{
|
||||
super(msgId);
|
||||
}
|
||||
|
||||
public UnsupportedMediaTypeException(String msgId, Object[] msgParams)
|
||||
{
|
||||
super(msgId, msgParams);
|
||||
}
|
||||
}
|
@@ -2558,6 +2558,10 @@ public class NodeApiTest extends AbstractBaseApiTest
|
||||
// Download the file
|
||||
response = getSingle(url, user1, null, 200);
|
||||
assertNotNull(content, response.getResponse());
|
||||
|
||||
// -ve - try to update content using multi-part form data
|
||||
payload = new BinaryPayload(txtFile, "multipart/form-data", null);
|
||||
putBinary(url, user1, payload, null, null, 415);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user