mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-21 18:09:20 +00:00
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/HEAD/root@126490 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.actions.interfaces.RelationshipResourceAction;
|
||||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||||
|
import org.alfresco.rest.framework.webscripts.ResponseCallBack;
|
||||||
import org.alfresco.util.ParameterCheck;
|
import org.alfresco.util.ParameterCheck;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
import org.springframework.extensions.webscripts.servlet.FormData;
|
import org.springframework.extensions.webscripts.servlet.FormData;
|
||||||
@@ -112,7 +113,7 @@ public class NodeChildrenRelation implements RelationshipResourceAction.Read<Nod
|
|||||||
@Override
|
@Override
|
||||||
@WebApiDescription(title = "Upload file content and meta-data into the repository.")
|
@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.")
|
@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);
|
return nodes.upload(parentFolderNodeId, formData, parameters);
|
||||||
}
|
}
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
package org.alfresco.rest.framework.resource.actions.interfaces;
|
package org.alfresco.rest.framework.resource.actions.interfaces;
|
||||||
|
|
||||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||||
|
import org.alfresco.rest.framework.webscripts.ResponseCallBack;
|
||||||
import org.springframework.extensions.webscripts.servlet.FormData;
|
import org.springframework.extensions.webscripts.servlet.FormData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,6 +34,6 @@ public interface MultiPartRelationshipResourceAction
|
|||||||
*/
|
*/
|
||||||
public static interface Create<E> extends ResourceAction
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
package org.alfresco.rest.framework.resource.actions.interfaces;
|
package org.alfresco.rest.framework.resource.actions.interfaces;
|
||||||
|
|
||||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||||
|
import org.alfresco.rest.framework.webscripts.ResponseCallBack;
|
||||||
import org.springframework.extensions.webscripts.servlet.FormData;
|
import org.springframework.extensions.webscripts.servlet.FormData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,6 +34,6 @@ public interface MultiPartResourceAction
|
|||||||
*/
|
*/
|
||||||
public static interface Create<E> extends ResourceAction
|
public static interface Create<E> extends ResourceAction
|
||||||
{
|
{
|
||||||
public E create(FormData formData, Parameters parameters);
|
public E create(FormData formData, Parameters parameters, ResponseCallBack withResponse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -130,7 +130,7 @@ public abstract class ApiWebScript extends AbstractWebScript
|
|||||||
return true;
|
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
|
@Override
|
||||||
public void execute(final WebScriptRequest req, final WebScriptResponse res) throws IOException
|
public void execute(final WebScriptRequest req, final WebScriptResponse res) throws IOException
|
||||||
|
@@ -226,7 +226,7 @@ public class ResourceWebScriptPost extends AbstractResourceWebScript implements
|
|||||||
if (resObj instanceof MultiPartResourceAction.Create<?> && params.getPassedIn() instanceof FormData)
|
if (resObj instanceof MultiPartResourceAction.Create<?> && params.getPassedIn() instanceof FormData)
|
||||||
{
|
{
|
||||||
MultiPartResourceAction.Create<Object> creator = (MultiPartResourceAction.Create<Object>) resObj;
|
MultiPartResourceAction.Create<Object> creator = (MultiPartResourceAction.Create<Object>) resObj;
|
||||||
return creator.create((FormData) params.getPassedIn(), params);
|
return creator.create((FormData) params.getPassedIn(), params, withResponse);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -253,7 +253,7 @@ public class ResourceWebScriptPost extends AbstractResourceWebScript implements
|
|||||||
if (resObj instanceof MultiPartRelationshipResourceAction.Create<?> && params.getPassedIn() instanceof FormData)
|
if (resObj instanceof MultiPartRelationshipResourceAction.Create<?> && params.getPassedIn() instanceof FormData)
|
||||||
{
|
{
|
||||||
MultiPartRelationshipResourceAction.Create<Object> creator = (MultiPartRelationshipResourceAction.Create<Object>) resObj;
|
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
|
else
|
||||||
{
|
{
|
||||||
|
@@ -5,6 +5,7 @@ import org.alfresco.rest.framework.WebApiDescription;
|
|||||||
import org.alfresco.rest.framework.resource.EntityResource;
|
import org.alfresco.rest.framework.resource.EntityResource;
|
||||||
import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartResourceAction;
|
import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartResourceAction;
|
||||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
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.Status;
|
||||||
import org.springframework.extensions.webscripts.servlet.FormData;
|
import org.springframework.extensions.webscripts.servlet.FormData;
|
||||||
|
|
||||||
@@ -18,7 +19,7 @@ public class MultiPartTestEntityResource
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@WebApiDescription(title = "Creates a multipart", successStatus = Status.STATUS_ACCEPTED)
|
@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]);
|
return new MultiPartTestResponse(formData.getParameters().get("filename")[0]);
|
||||||
}
|
}
|
||||||
|
@@ -4,6 +4,7 @@ package org.alfresco.rest.framework.tests.api.mocks;
|
|||||||
import org.alfresco.rest.framework.resource.RelationshipResource;
|
import org.alfresco.rest.framework.resource.RelationshipResource;
|
||||||
import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartRelationshipResourceAction;
|
import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartRelationshipResourceAction;
|
||||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||||
|
import org.alfresco.rest.framework.webscripts.ResponseCallBack;
|
||||||
import org.springframework.extensions.webscripts.servlet.FormData;
|
import org.springframework.extensions.webscripts.servlet.FormData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -16,7 +17,7 @@ public class MultiPartTestRelationshipResource
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MultiPartTestResponse create(String entityResourceId, FormData formData,
|
public MultiPartTestResponse create(String entityResourceId, FormData formData,
|
||||||
Parameters parameters)
|
Parameters parameters, ResponseCallBack withResponse)
|
||||||
{
|
{
|
||||||
return new MultiPartTestResponse(formData.getParameters().get("filename")[0]);
|
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.RelationshipResource;
|
||||||
import org.alfresco.rest.framework.resource.parameters.Params;
|
import org.alfresco.rest.framework.resource.parameters.Params;
|
||||||
import org.alfresco.rest.framework.webscripts.AbstractResourceWebScript;
|
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.ResourceWebScriptHelper;
|
||||||
|
import org.alfresco.rest.framework.webscripts.ResponseCallBack;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@@ -22,6 +24,7 @@ import org.mockito.invocation.InvocationOnMock;
|
|||||||
import org.mockito.stubbing.Answer;
|
import org.mockito.stubbing.Answer;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.extensions.webscripts.Status;
|
||||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
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 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 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");
|
static Api api = Api.valueOf("alfrescomock", "private", "1");
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@@ -146,7 +146,7 @@ public class SerializeTests extends AbstractContextTest
|
|||||||
mockRequest.setContent(reqBody.getBody());
|
mockRequest.setContent(reqBody.getBody());
|
||||||
mockRequest.setContentType(reqBody.getContentType());
|
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\":"));
|
assertTrue("There must be json output", StringUtils.startsWith(out, "{\"entry\":"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user