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)
126490 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2) 122636 gjames: RA-211: Adding the ResponseCallBack to the Multipart actions git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126834 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -30,6 +30,7 @@ import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartRelation
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rest.framework.webscripts.ResponseCallBack;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.extensions.webscripts.servlet.FormData;
|
||||
@@ -112,7 +113,7 @@ public class NodeChildrenRelation implements RelationshipResourceAction.Read<Nod
|
||||
@Override
|
||||
@WebApiDescription(title = "Upload file content and meta-data into the repository.")
|
||||
@WebApiParam(name = "formData", title = "A single form data", description = "A single form data which holds FormFields.")
|
||||
public Node create(String parentFolderNodeId, FormData formData, Parameters parameters)
|
||||
public Node create(String parentFolderNodeId, FormData formData, Parameters parameters, ResponseCallBack withResponse)
|
||||
{
|
||||
return nodes.upload(parentFolderNodeId, formData, parameters);
|
||||
}
|
||||
|
@@ -27,6 +27,7 @@
|
||||
package org.alfresco.rest.framework.resource.actions.interfaces;
|
||||
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rest.framework.webscripts.ResponseCallBack;
|
||||
import org.springframework.extensions.webscripts.servlet.FormData;
|
||||
|
||||
/**
|
||||
@@ -40,6 +41,6 @@ public interface MultiPartRelationshipResourceAction
|
||||
*/
|
||||
public static interface Create<E> extends ResourceAction
|
||||
{
|
||||
public E create(String entityResourceId, FormData formData, Parameters parameters);
|
||||
public E create(String entityResourceId, FormData formData, Parameters parameters, ResponseCallBack withResponse);
|
||||
}
|
||||
}
|
||||
|
@@ -27,6 +27,7 @@
|
||||
package org.alfresco.rest.framework.resource.actions.interfaces;
|
||||
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rest.framework.webscripts.ResponseCallBack;
|
||||
import org.springframework.extensions.webscripts.servlet.FormData;
|
||||
|
||||
/**
|
||||
@@ -40,6 +41,6 @@ public interface MultiPartResourceAction
|
||||
*/
|
||||
public static interface Create<E> extends ResourceAction
|
||||
{
|
||||
public E create(FormData formData, Parameters parameters);
|
||||
public E create(FormData formData, Parameters parameters, ResponseCallBack withResponse);
|
||||
}
|
||||
}
|
||||
|
@@ -137,7 +137,7 @@ public abstract class ApiWebScript extends AbstractWebScript
|
||||
return true;
|
||||
}
|
||||
});
|
||||
final static ContentInfo DEFAULT_JSON_CONTENT = new ContentInfoImpl(Format.JSON.mimetype(),UTF8, 0, null);
|
||||
public final static ContentInfo DEFAULT_JSON_CONTENT = new ContentInfoImpl(Format.JSON.mimetype(),UTF8, 0, null);
|
||||
|
||||
@Override
|
||||
public void execute(final WebScriptRequest req, final WebScriptResponse res) throws IOException
|
||||
|
@@ -232,7 +232,7 @@ public class ResourceWebScriptPost extends AbstractResourceWebScript implements
|
||||
if (resObj instanceof MultiPartResourceAction.Create<?> && params.getPassedIn() instanceof FormData)
|
||||
{
|
||||
MultiPartResourceAction.Create<Object> creator = (MultiPartResourceAction.Create<Object>) resObj;
|
||||
return creator.create((FormData) params.getPassedIn(), params);
|
||||
return creator.create((FormData) params.getPassedIn(), params, withResponse);
|
||||
|
||||
}
|
||||
else
|
||||
@@ -259,7 +259,7 @@ public class ResourceWebScriptPost extends AbstractResourceWebScript implements
|
||||
if (resObj instanceof MultiPartRelationshipResourceAction.Create<?> && params.getPassedIn() instanceof FormData)
|
||||
{
|
||||
MultiPartRelationshipResourceAction.Create<Object> creator = (MultiPartRelationshipResourceAction.Create<Object>) resObj;
|
||||
return creator.create(params.getEntityId(), (FormData) params.getPassedIn(), params);
|
||||
return creator.create(params.getEntityId(), (FormData) params.getPassedIn(), params, withResponse);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -30,6 +30,7 @@ import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.resource.EntityResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartResourceAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rest.framework.webscripts.ResponseCallBack;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.servlet.FormData;
|
||||
|
||||
@@ -43,7 +44,7 @@ public class MultiPartTestEntityResource
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Creates a multipart", successStatus = Status.STATUS_ACCEPTED)
|
||||
public MultiPartTestResponse create(FormData formData, Parameters parameters)
|
||||
public MultiPartTestResponse create(FormData formData, Parameters parameters, ResponseCallBack withResponse)
|
||||
{
|
||||
return new MultiPartTestResponse(formData.getParameters().get("filename")[0]);
|
||||
}
|
||||
|
@@ -29,6 +29,7 @@ package org.alfresco.rest.framework.tests.api.mocks;
|
||||
import org.alfresco.rest.framework.resource.RelationshipResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartRelationshipResourceAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rest.framework.webscripts.ResponseCallBack;
|
||||
import org.springframework.extensions.webscripts.servlet.FormData;
|
||||
|
||||
/**
|
||||
@@ -41,7 +42,7 @@ public class MultiPartTestRelationshipResource
|
||||
|
||||
@Override
|
||||
public MultiPartTestResponse create(String entityResourceId, FormData formData,
|
||||
Parameters parameters)
|
||||
Parameters parameters, ResponseCallBack withResponse)
|
||||
{
|
||||
return new MultiPartTestResponse(formData.getParameters().get("filename")[0]);
|
||||
}
|
||||
|
@@ -14,7 +14,9 @@ import org.alfresco.rest.framework.resource.EntityResource;
|
||||
import org.alfresco.rest.framework.resource.RelationshipResource;
|
||||
import org.alfresco.rest.framework.resource.parameters.Params;
|
||||
import org.alfresco.rest.framework.webscripts.AbstractResourceWebScript;
|
||||
import org.alfresco.rest.framework.webscripts.ApiWebScript;
|
||||
import org.alfresco.rest.framework.webscripts.ResourceWebScriptHelper;
|
||||
import org.alfresco.rest.framework.webscripts.ResponseCallBack;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.junit.Before;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -22,6 +24,7 @@ import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@@ -49,6 +52,7 @@ public abstract class AbstractContextTest
|
||||
|
||||
static Params NOT_USED = Params.valueOf("notUsed", null, mock(WebScriptRequest.class));
|
||||
static final Params.RecognizedParams NULL_PARAMS = new Params.RecognizedParams(null, null, null, null, null, null, null, false);
|
||||
static final ResponseCallBack callBack = new ResponseCallBack(Status.STATUS_OK, ApiWebScript.DEFAULT_JSON_CONTENT,ApiWebScript.CACHE_NEVER);
|
||||
static Api api = Api.valueOf("alfrescomock", "private", "1");
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@@ -153,7 +153,7 @@ public class SerializeTests extends AbstractContextTest
|
||||
mockRequest.setContent(reqBody.getBody());
|
||||
mockRequest.setContentType(reqBody.getContentType());
|
||||
|
||||
String out = writeResponse(helper.processAdditionsToTheResponse(mock(WebScriptResponse.class), api,null, NOT_USED, resource.create(new FormData(mockRequest), NOT_USED)));
|
||||
String out = writeResponse(helper.processAdditionsToTheResponse(mock(WebScriptResponse.class), api,null, NOT_USED, resource.create(new FormData(mockRequest), NOT_USED, callBack)));
|
||||
assertTrue("There must be json output", StringUtils.startsWith(out, "{\"entry\":"));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user