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)
122418 gjames: RA-827 Supporting custom status codes git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@126473 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -2,6 +2,9 @@ package org.alfresco.rest.framework;
|
||||
|
||||
import static java.lang.annotation.ElementType.METHOD;
|
||||
|
||||
import org.alfresco.rest.framework.core.ResourceOperation;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
@@ -16,5 +19,6 @@ import java.lang.annotation.Target;
|
||||
public @interface WebApiDescription {
|
||||
String title();
|
||||
String description() default "";
|
||||
int successStatus() default ResourceOperation.UNSET_STATUS;
|
||||
}
|
||||
|
||||
|
@@ -56,6 +56,7 @@ import org.alfresco.util.Pair;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
@@ -286,14 +287,40 @@ public class ResourceInspector
|
||||
Map<String, Object> annotAttribs = AnnotationUtils.getAnnotationAttributes(annot);
|
||||
String title = String.valueOf(annotAttribs.get("title"));
|
||||
String desc = String.valueOf(annotAttribs.get("description"));
|
||||
return new ResourceOperation(httpMethod, title, desc, parameters);
|
||||
Integer success = (Integer) annotAttribs.get("successStatus");
|
||||
return new ResourceOperation(httpMethod, title, desc, parameters, validSuccessCode(httpMethod,success));
|
||||
}
|
||||
else {
|
||||
return new ResourceOperation(httpMethod,
|
||||
"Missing @WebApiDescription annotation", "This method should be annotated with @WebApiDescription", parameters);
|
||||
"Missing @WebApiDescription annotation",
|
||||
"This method should be annotated with @WebApiDescription", parameters, validSuccessCode(httpMethod, ResourceOperation.UNSET_STATUS));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static int validSuccessCode(HttpMethod httpMethod, int success)
|
||||
{
|
||||
if (!(ResourceOperation.UNSET_STATUS == success))
|
||||
{
|
||||
//The status has been set by the api implementor so use it.
|
||||
return success;
|
||||
}
|
||||
|
||||
switch (httpMethod)
|
||||
{
|
||||
case GET:
|
||||
return Status.STATUS_OK;
|
||||
case POST:
|
||||
return Status.STATUS_CREATED;
|
||||
case PUT:
|
||||
return Status.STATUS_OK;
|
||||
case DELETE:
|
||||
return Status.STATUS_NO_CONTENT;
|
||||
default:
|
||||
return Status.STATUS_OK;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Inspects the Method to find any @WebApiParameters and @WebApiParam
|
||||
* @param resource the class
|
||||
|
@@ -47,7 +47,8 @@ public class ResourceLookupDictionary implements ResourceLocator
|
||||
ResourceWithMetadata resource = apiResources.get(propertyResourceKey);
|
||||
if (resource != null)
|
||||
{
|
||||
if (!resource.getMetaData().supports(httpMethod)) { throw new UnsupportedResourceOperationException(); }
|
||||
ResourceOperation op = resource.getMetaData().getOperation(httpMethod);
|
||||
if (op == null) { throw new UnsupportedResourceOperationException(); }
|
||||
return resource;
|
||||
}
|
||||
|
||||
@@ -79,7 +80,8 @@ public class ResourceLookupDictionary implements ResourceLocator
|
||||
resource = apiResources.get(resourceKey);
|
||||
if (resource != null)
|
||||
{
|
||||
if (!resource.getMetaData().supports(httpMethod)) { throw new UnsupportedResourceOperationException(); }
|
||||
ResourceOperation op = resource.getMetaData().getOperation(httpMethod);
|
||||
if (op == null) { throw new UnsupportedResourceOperationException(); }
|
||||
return resource;
|
||||
}
|
||||
}
|
||||
@@ -88,7 +90,8 @@ public class ResourceLookupDictionary implements ResourceLocator
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!resource.getMetaData().supports(httpMethod)) { throw new UnsupportedResourceOperationException(); }
|
||||
ResourceOperation op = resource.getMetaData().getOperation(httpMethod);
|
||||
if (op == null) { throw new UnsupportedResourceOperationException(); }
|
||||
return resource;
|
||||
}
|
||||
}
|
||||
|
@@ -65,17 +65,17 @@ public class ResourceMetadata
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if this resource can support the specified HTTPMethod
|
||||
* Gets the operation for the specified HTTPMethod
|
||||
* @param supportedMethod HttpMethod
|
||||
* @return true if can support it
|
||||
* @return null if the operation is not supported
|
||||
*/
|
||||
public boolean supports(HttpMethod supportedMethod)
|
||||
public ResourceOperation getOperation(HttpMethod supportedMethod)
|
||||
{
|
||||
for (ResourceOperation ops : operations)
|
||||
{
|
||||
if (ops.getHttpMethod().equals(supportedMethod)) return true;
|
||||
if (ops.getHttpMethod().equals(supportedMethod)) return ops;
|
||||
}
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,23 +84,17 @@ public class ResourceMetadata
|
||||
* @return true if can support it
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Class getObjectType(HttpMethod supportedMethod)
|
||||
public Class getObjectType(ResourceOperation operation)
|
||||
{
|
||||
for (ResourceOperation ops : operations)
|
||||
for (ResourceParameter param : operation.getParameters())
|
||||
{
|
||||
if (ops.getHttpMethod().equals(supportedMethod))
|
||||
{
|
||||
for (ResourceParameter param : ops.getParameters())
|
||||
{
|
||||
if (ResourceParameter.KIND.HTTP_BODY_OBJECT.equals(param.getParamType())) {
|
||||
return param.getDataType();
|
||||
}
|
||||
}
|
||||
if (ResourceParameter.KIND.HTTP_BODY_OBJECT.equals(param.getParamType())) {
|
||||
return param.getDataType();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Indicates if this resource action is no longer supported.
|
||||
* @param resourceAction Class<? extends ResourceAction>
|
||||
@@ -203,20 +197,6 @@ public class ResourceMetadata
|
||||
// }
|
||||
// return Collections.emptyList();
|
||||
// }
|
||||
//
|
||||
/**
|
||||
* Gets the parameters for the specified http method.
|
||||
* Matches the first operation.
|
||||
* @param httpMethod HttpMethod
|
||||
* @return If not found returns an empty list
|
||||
*/
|
||||
public List<ResourceParameter> getParameters(HttpMethod httpMethod)
|
||||
{
|
||||
for (ResourceOperation ops : operations)
|
||||
{
|
||||
if (ops.getHttpMethod().equals(httpMethod))return ops.getParameters();
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
//
|
||||
|
||||
}
|
||||
|
@@ -11,24 +11,28 @@ import org.springframework.http.HttpMethod;
|
||||
*/
|
||||
public class ResourceOperation
|
||||
{
|
||||
public static final int UNSET_STATUS = -1;
|
||||
private final HttpMethod httpMethod;
|
||||
private final String title;
|
||||
private final String description;
|
||||
private final List<ResourceParameter> parameters;
|
||||
private final int successStatus;
|
||||
|
||||
/**
|
||||
* @param httpMethod HttpMethod
|
||||
* @param title String
|
||||
* @param description String
|
||||
* @param parameters List<ResourceParameter>
|
||||
* @param successStatus HTTP status
|
||||
*/
|
||||
public ResourceOperation(HttpMethod httpMethod, String title, String description, List<ResourceParameter> parameters)
|
||||
public ResourceOperation(HttpMethod httpMethod, String title, String description, List<ResourceParameter> parameters, int successStatus)
|
||||
{
|
||||
super();
|
||||
this.httpMethod = httpMethod;
|
||||
this.title = title;
|
||||
this.description = description;
|
||||
this.parameters = parameters;
|
||||
this.successStatus = successStatus;
|
||||
}
|
||||
|
||||
public HttpMethod getHttpMethod()
|
||||
@@ -51,6 +55,11 @@ public class ResourceOperation
|
||||
return this.parameters;
|
||||
}
|
||||
|
||||
public int getSuccessStatus()
|
||||
{
|
||||
return successStatus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
@@ -59,6 +68,8 @@ public class ResourceOperation
|
||||
builder.append(this.httpMethod);
|
||||
builder.append(", title=");
|
||||
builder.append(this.title);
|
||||
builder.append(", status=");
|
||||
builder.append(this.successStatus);
|
||||
builder.append(", description=");
|
||||
builder.append(this.description);
|
||||
builder.append(", parameters=");
|
||||
|
@@ -4,6 +4,7 @@ import org.alfresco.rest.framework.core.HttpMethodSupport;
|
||||
import org.alfresco.rest.framework.core.ResourceWithMetadata;
|
||||
import org.alfresco.rest.framework.resource.content.ContentInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Params;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
|
||||
/**
|
||||
* Executes an action in the system
|
||||
@@ -29,7 +30,7 @@ public interface ActionExecutor extends HttpMethodSupport
|
||||
*/
|
||||
public interface ExecutionCallback<R>
|
||||
{
|
||||
public void onSuccess(R result, ContentInfo contentInfo);
|
||||
public void onSuccess(R result, ContentInfo contentInfo, int statusCode);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -92,11 +92,4 @@ public interface Parameters
|
||||
* @return BasicContentInfo the content info
|
||||
*/
|
||||
BasicContentInfo getContentInfo();
|
||||
|
||||
/**
|
||||
* Gets Web Script status
|
||||
*
|
||||
* @return {@link Status}
|
||||
*/
|
||||
public Status getStatus();
|
||||
}
|
||||
|
@@ -30,7 +30,6 @@ public class Params implements Parameters
|
||||
private final RecognizedParams recognizedParams;
|
||||
private final String addressedProperty;
|
||||
private final BasicContentInfo contentInfo;
|
||||
private final Status status;
|
||||
|
||||
//Constants
|
||||
private static final RecognizedParams NULL_PARAMS = new RecognizedParams(null, null, null, null, null, null, null, false);
|
||||
@@ -46,7 +45,6 @@ public class Params implements Parameters
|
||||
this.recognizedParams = recognizedParams;
|
||||
this.addressedProperty = addressedProperty;
|
||||
this.contentInfo = contentInfo==null?DEFAULT_CONTENT_INFO:contentInfo;
|
||||
this.status = new Status();
|
||||
}
|
||||
|
||||
public static Params valueOf(BeanPropertiesFilter paramFilter, String entityId)
|
||||
@@ -216,12 +214,6 @@ public class Params implements Parameters
|
||||
return contentInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* A formal set of params that any rest service could potentially have passed in as request params
|
||||
*/
|
||||
|
@@ -93,7 +93,7 @@ public abstract class AbstractResourceWebScript extends ApiWebScript implements
|
||||
executor.execute(resource, params, new ExecutionCallback()
|
||||
{
|
||||
@Override
|
||||
public void onSuccess(Object result, ContentInfo contentInfo)
|
||||
public void onSuccess(Object result, ContentInfo contentInfo, int statusCode)
|
||||
{
|
||||
respons.put("toSerialize", result);
|
||||
respons.put("contentInfo", contentInfo);
|
||||
@@ -108,14 +108,9 @@ public abstract class AbstractResourceWebScript extends ApiWebScript implements
|
||||
}
|
||||
}
|
||||
|
||||
if (params.getStatus().getRedirect())
|
||||
{
|
||||
res.setStatus(params.getStatus().getCode());
|
||||
}
|
||||
else
|
||||
{
|
||||
setSuccessResponseStatus(res);
|
||||
}
|
||||
// The response status must be set before the response is written by Jackson (which will by default close and commit the response).
|
||||
// In a r/w txn, web script buffered responses ensure that it doesn't really matter but for r/o txns this is important.
|
||||
res.setStatus(statusCode);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -210,17 +205,6 @@ public abstract class AbstractResourceWebScript extends ApiWebScript implements
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The response status must be set before the response is written by Jackson (which will by default close and commit the response).
|
||||
* In a r/w txn, web script buffered responses ensure that it doesn't really matter but for r/o txns this is important.
|
||||
* @param res WebScriptResponse
|
||||
*/
|
||||
protected void setSuccessResponseStatus(final WebScriptResponse res)
|
||||
{
|
||||
// default for GET, HEAD, OPTIONS, PUT, TRACE
|
||||
res.setStatus(Status.STATUS_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the action executor to execute actions on.
|
||||
* @param httpMethod - the http method
|
||||
|
@@ -3,6 +3,7 @@ package org.alfresco.rest.framework.webscripts;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.rest.framework.core.ResourceLocator;
|
||||
import org.alfresco.rest.framework.core.ResourceMetadata;
|
||||
import org.alfresco.rest.framework.core.ResourceOperation;
|
||||
import org.alfresco.rest.framework.core.ResourceWithMetadata;
|
||||
import org.alfresco.rest.framework.core.exceptions.DeletedResourceException;
|
||||
import org.alfresco.rest.framework.core.exceptions.UnsupportedResourceOperationException;
|
||||
@@ -87,7 +88,7 @@ public class ResourceWebScriptDelete extends AbstractResourceWebScript implement
|
||||
* @param params parameters to use
|
||||
* @return anObject the result of the execute
|
||||
*/
|
||||
private Object executeInternal(ResourceWithMetadata resource, Params params)
|
||||
private void executeInternal(ResourceWithMetadata resource, Params params)
|
||||
{
|
||||
switch (resource.getMetaData().getType())
|
||||
{
|
||||
@@ -99,7 +100,7 @@ public class ResourceWebScriptDelete extends AbstractResourceWebScript implement
|
||||
EntityResourceAction.Delete entityDeleter = (EntityResourceAction.Delete) resource.getResource();
|
||||
entityDeleter.delete(params.getEntityId(), params);
|
||||
//Don't pass anything to the callback - its just successful
|
||||
return null;
|
||||
return;
|
||||
case RELATIONSHIP:
|
||||
if (resource.getMetaData().isDeleted(RelationshipResourceAction.Delete.class))
|
||||
{
|
||||
@@ -108,7 +109,7 @@ public class ResourceWebScriptDelete extends AbstractResourceWebScript implement
|
||||
RelationshipResourceAction.Delete relationDeleter = (RelationshipResourceAction.Delete) resource.getResource();
|
||||
relationDeleter.delete(params.getEntityId(), params.getRelationshipId(), params);
|
||||
//Don't pass anything to the callback - its just successful
|
||||
return null;
|
||||
return;
|
||||
case PROPERTY:
|
||||
if (BinaryResourceAction.Delete.class.isAssignableFrom(resource.getResource().getClass()))
|
||||
{
|
||||
@@ -119,7 +120,7 @@ public class ResourceWebScriptDelete extends AbstractResourceWebScript implement
|
||||
BinaryResourceAction.Delete binDeleter = (BinaryResourceAction.Delete) resource.getResource();
|
||||
binDeleter.deleteProperty(params.getEntityId(), params);
|
||||
//Don't pass anything to the callback - its just successful
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
if (RelationshipResourceBinaryAction.Delete.class.isAssignableFrom(resource.getResource().getClass()))
|
||||
{
|
||||
@@ -130,7 +131,7 @@ public class ResourceWebScriptDelete extends AbstractResourceWebScript implement
|
||||
RelationshipResourceBinaryAction.Delete binDeleter = (RelationshipResourceBinaryAction.Delete) resource.getResource();
|
||||
binDeleter.deleteProperty(params.getEntityId(), params.getRelationshipId(), params);
|
||||
//Don't pass anything to the callback - its just successful
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
default:
|
||||
throw new UnsupportedResourceOperationException("DELETE not supported for Actions");
|
||||
@@ -146,17 +147,12 @@ public class ResourceWebScriptDelete extends AbstractResourceWebScript implement
|
||||
@Override
|
||||
public Void execute() throws Throwable
|
||||
{
|
||||
final ResourceOperation operation = resource.getMetaData().getOperation(HttpMethod.DELETE);
|
||||
executeInternal(resource, params); //ignore return result
|
||||
executionCallback.onSuccess(null, DEFAULT_JSON_CONTENT);
|
||||
executionCallback.onSuccess(null, DEFAULT_JSON_CONTENT, operation.getSuccessStatus());
|
||||
return null;
|
||||
}
|
||||
}, false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setSuccessResponseStatus(WebScriptResponse res)
|
||||
{
|
||||
res.setStatus(Status.STATUS_NO_CONTENT);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@ import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransacti
|
||||
import org.alfresco.rest.framework.core.ResourceInspector;
|
||||
import org.alfresco.rest.framework.core.ResourceLocator;
|
||||
import org.alfresco.rest.framework.core.ResourceMetadata;
|
||||
import org.alfresco.rest.framework.core.ResourceOperation;
|
||||
import org.alfresco.rest.framework.core.ResourceWithMetadata;
|
||||
import org.alfresco.rest.framework.core.exceptions.DeletedResourceException;
|
||||
import org.alfresco.rest.framework.core.exceptions.UnsupportedResourceOperationException;
|
||||
@@ -40,6 +41,7 @@ import org.alfresco.rest.framework.resource.parameters.Params.RecognizedParams;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
@@ -227,6 +229,7 @@ public class ResourceWebScriptGet extends AbstractResourceWebScript implements P
|
||||
@Override
|
||||
public Void execute() throws Throwable
|
||||
{
|
||||
final ResourceOperation operation = resource.getMetaData().getOperation(HttpMethod.GET);
|
||||
Object result = executeInternal(resource, params);
|
||||
if (result instanceof BinaryResource)
|
||||
{
|
||||
@@ -235,11 +238,11 @@ public class ResourceWebScriptGet extends AbstractResourceWebScript implements P
|
||||
{
|
||||
ci = ((NodeBinaryResource)result).getContentInfo();
|
||||
}
|
||||
executionCallback.onSuccess(result, ci);
|
||||
executionCallback.onSuccess(result, ci, operation.getSuccessStatus());
|
||||
}
|
||||
else
|
||||
{
|
||||
executionCallback.onSuccess(helper.processAdditionsToTheResponse(resource.getMetaData().getApi(), entityCollectionName, params, result), DEFAULT_JSON_CONTENT);
|
||||
executionCallback.onSuccess(helper.processAdditionsToTheResponse(resource.getMetaData().getApi(), entityCollectionName, params, result), DEFAULT_JSON_CONTENT, operation.getSuccessStatus());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@@ -627,7 +627,7 @@ public class ResourceWebScriptHelper
|
||||
executor.execute(resource, executionParams, new ExecutionCallback()
|
||||
{
|
||||
@Override
|
||||
public void onSuccess(Object result, ContentInfo contentInfo)
|
||||
public void onSuccess(Object result, ContentInfo contentInfo, int statusCode)
|
||||
{
|
||||
resultOfExecution[0] = result;
|
||||
}
|
||||
|
@@ -28,6 +28,7 @@ import org.alfresco.rest.framework.core.ResourceInspector;
|
||||
import org.alfresco.rest.framework.core.ResourceInspectorUtil;
|
||||
import org.alfresco.rest.framework.core.ResourceLocator;
|
||||
import org.alfresco.rest.framework.core.ResourceMetadata;
|
||||
import org.alfresco.rest.framework.core.ResourceOperation;
|
||||
import org.alfresco.rest.framework.core.ResourceParameter;
|
||||
import org.alfresco.rest.framework.core.ResourceWithMetadata;
|
||||
import org.alfresco.rest.framework.core.exceptions.DeletedResourceException;
|
||||
@@ -69,6 +70,7 @@ public class ResourceWebScriptPost extends AbstractResourceWebScript implements
|
||||
final RecognizedParams params = ResourceWebScriptHelper.getRecognizedParams(req);
|
||||
final String entityId = req.getServiceMatch().getTemplateVars().get(ResourceLocator.ENTITY_ID);
|
||||
final String relationshipId = req.getServiceMatch().getTemplateVars().get(ResourceLocator.RELATIONSHIP_ID);
|
||||
final ResourceOperation operation = resourceMeta.getOperation(HttpMethod.POST);
|
||||
|
||||
switch (resourceMeta.getType())
|
||||
{
|
||||
@@ -80,7 +82,7 @@ public class ResourceWebScriptPost extends AbstractResourceWebScript implements
|
||||
}
|
||||
else
|
||||
{
|
||||
Object postedObj = processRequest(resourceMeta, req);
|
||||
Object postedObj = processRequest(resourceMeta, operation, req);
|
||||
return Params.valueOf(null, params, postedObj);
|
||||
}
|
||||
case RELATIONSHIP:
|
||||
@@ -90,7 +92,7 @@ public class ResourceWebScriptPost extends AbstractResourceWebScript implements
|
||||
}
|
||||
else
|
||||
{
|
||||
Object postedRel = processRequest(resourceMeta, req);
|
||||
Object postedRel = processRequest(resourceMeta, operation, req);
|
||||
return Params.valueOf(entityId, params, postedRel);
|
||||
}
|
||||
case OPERATION:
|
||||
@@ -99,7 +101,7 @@ public class ResourceWebScriptPost extends AbstractResourceWebScript implements
|
||||
|
||||
if (StringUtils.isNotBlank(entityId) && StringUtils.isNotBlank(operationName))
|
||||
{
|
||||
Class objectType = resourceMeta.getObjectType(HttpMethod.POST);
|
||||
Class objectType = resourceMeta.getObjectType(operation);
|
||||
Object postedObj = null;
|
||||
if (objectType!= null)
|
||||
{
|
||||
@@ -127,14 +129,14 @@ public class ResourceWebScriptPost extends AbstractResourceWebScript implements
|
||||
* returns the {@link FormData}, otherwise it tries to extract the required
|
||||
* object from the JSON payload.
|
||||
*/
|
||||
private Object processRequest(ResourceMetadata resourceMeta, WebScriptRequest req)
|
||||
private Object processRequest(ResourceMetadata resourceMeta, ResourceOperation operation, WebScriptRequest req)
|
||||
{
|
||||
if (WebScriptRequestImpl.MULTIPART_FORM_DATA.equals(req.getContentType()))
|
||||
{
|
||||
return (FormData) req.parseContent();
|
||||
}
|
||||
|
||||
return extractObjFromJson(resourceMeta, req);
|
||||
return extractObjFromJson(resourceMeta, operation, req);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,10 +146,10 @@ public class ResourceWebScriptPost extends AbstractResourceWebScript implements
|
||||
* @param req WebScriptRequest
|
||||
* @return Either an object
|
||||
*/
|
||||
private Object extractObjFromJson(ResourceMetadata resourceMeta, WebScriptRequest req)
|
||||
private Object extractObjFromJson(ResourceMetadata resourceMeta, ResourceOperation operation, WebScriptRequest req)
|
||||
{
|
||||
List<ResourceParameter> params = resourceMeta.getParameters(HttpMethod.POST);
|
||||
Class<?> objType = resourceMeta.getObjectType(HttpMethod.POST);
|
||||
List<ResourceParameter> params = operation.getParameters();
|
||||
Class<?> objType = resourceMeta.getObjectType(operation);
|
||||
|
||||
if (!params.isEmpty())
|
||||
{
|
||||
@@ -212,6 +214,7 @@ public class ResourceWebScriptPost extends AbstractResourceWebScript implements
|
||||
private Object executeInternal(ResourceWithMetadata resource, Params params) throws Throwable
|
||||
{
|
||||
final Object resObj = resource.getResource();
|
||||
|
||||
switch (resource.getMetaData().getType())
|
||||
{
|
||||
case ENTITY:
|
||||
@@ -296,17 +299,13 @@ public class ResourceWebScriptPost extends AbstractResourceWebScript implements
|
||||
@Override
|
||||
public Void execute() throws Throwable
|
||||
{
|
||||
final ResourceOperation operation = resource.getMetaData().getOperation(HttpMethod.POST);
|
||||
Object result = executeInternal(resource, params);
|
||||
executionCallback.onSuccess(helper.processAdditionsToTheResponse(resource.getMetaData().getApi(), entityCollectionName, params, result), DEFAULT_JSON_CONTENT);
|
||||
executionCallback.onSuccess(helper.processAdditionsToTheResponse(resource.getMetaData().getApi(), entityCollectionName, params, result),
|
||||
DEFAULT_JSON_CONTENT, operation.getSuccessStatus());
|
||||
return null;
|
||||
}
|
||||
}, false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setSuccessResponseStatus(WebScriptResponse res)
|
||||
{
|
||||
res.setStatus(Status.STATUS_CREATED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -28,6 +28,7 @@ import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransacti
|
||||
import org.alfresco.rest.framework.core.ResourceInspector;
|
||||
import org.alfresco.rest.framework.core.ResourceLocator;
|
||||
import org.alfresco.rest.framework.core.ResourceMetadata;
|
||||
import org.alfresco.rest.framework.core.ResourceOperation;
|
||||
import org.alfresco.rest.framework.core.ResourceWithMetadata;
|
||||
import org.alfresco.rest.framework.core.exceptions.DeletedResourceException;
|
||||
import org.alfresco.rest.framework.core.exceptions.UnsupportedResourceOperationException;
|
||||
@@ -43,6 +44,7 @@ import org.alfresco.rest.framework.resource.parameters.Params.RecognizedParams;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.springframework.extensions.webscripts.WrappingWebScriptRequest;
|
||||
import org.springframework.extensions.webscripts.servlet.WebScriptServletRequest;
|
||||
@@ -72,7 +74,8 @@ public class ResourceWebScriptPut extends AbstractResourceWebScript implements P
|
||||
final String relationshipId = req.getServiceMatch().getTemplateVars().get(ResourceLocator.RELATIONSHIP_ID);
|
||||
final String entityId = req.getServiceMatch().getTemplateVars().get(ResourceLocator.ENTITY_ID);
|
||||
final RecognizedParams params = ResourceWebScriptHelper.getRecognizedParams(req);
|
||||
|
||||
final ResourceOperation operation = resourceMeta.getOperation(HttpMethod.PUT);
|
||||
|
||||
switch (resourceMeta.getType())
|
||||
{
|
||||
case ENTITY:
|
||||
@@ -82,7 +85,7 @@ public class ResourceWebScriptPut extends AbstractResourceWebScript implements P
|
||||
} else
|
||||
{
|
||||
|
||||
Object putEnt = ResourceWebScriptHelper.extractJsonContent(req, jsonHelper, resourceMeta.getObjectType(HttpMethod.PUT));
|
||||
Object putEnt = ResourceWebScriptHelper.extractJsonContent(req, jsonHelper, resourceMeta.getObjectType(operation));
|
||||
return Params.valueOf(entityId,params,putEnt);
|
||||
}
|
||||
case RELATIONSHIP:
|
||||
@@ -91,7 +94,7 @@ public class ResourceWebScriptPut extends AbstractResourceWebScript implements P
|
||||
throw new UnsupportedResourceOperationException("PUT is executed against the instance URL");
|
||||
} else
|
||||
{
|
||||
Object putRel = ResourceWebScriptHelper.extractJsonContent(req, jsonHelper, resourceMeta.getObjectType(HttpMethod.PUT));
|
||||
Object putRel = ResourceWebScriptHelper.extractJsonContent(req, jsonHelper, resourceMeta.getObjectType(operation));
|
||||
ResourceWebScriptHelper.setUniqueId(putRel,relationshipId);
|
||||
return Params.valueOf(entityId, params, putRel);
|
||||
}
|
||||
@@ -231,8 +234,10 @@ public class ResourceWebScriptPut extends AbstractResourceWebScript implements P
|
||||
@Override
|
||||
public Void execute() throws Throwable
|
||||
{
|
||||
final ResourceOperation operation = resource.getMetaData().getOperation(HttpMethod.PUT);
|
||||
Object result = executeInternal(resource, params);
|
||||
executionCallback.onSuccess(helper.processAdditionsToTheResponse(resource.getMetaData().getApi(), entityCollectionName, params, result), DEFAULT_JSON_CONTENT);
|
||||
executionCallback.onSuccess(helper.processAdditionsToTheResponse(resource.getMetaData().getApi(), entityCollectionName, params, result),
|
||||
DEFAULT_JSON_CONTENT, operation.getSuccessStatus());
|
||||
return null;
|
||||
}
|
||||
}, false, true);
|
||||
|
@@ -41,7 +41,7 @@ public class ExecutionTests extends AbstractContextTest
|
||||
AbstractResourceWebScript executor = (AbstractResourceWebScript) applicationContext.getBean("executorOfGets");
|
||||
executor.execute(entityResource, Params.valueOf((String)null, null), new ActionExecutor.ExecutionCallback<CollectionWithPagingInfo>(){
|
||||
@Override
|
||||
public void onSuccess(CollectionWithPagingInfo result, ContentInfo contentInfo)
|
||||
public void onSuccess(CollectionWithPagingInfo result, ContentInfo contentInfo, int statusCode)
|
||||
{
|
||||
assertNotNull(result);
|
||||
}});
|
||||
@@ -50,14 +50,14 @@ public class ExecutionTests extends AbstractContextTest
|
||||
executor = (AbstractResourceWebScript) applicationContext.getBean("executorOfGets");
|
||||
executor.execute(baa, Params.valueOf("4", null), new ActionExecutor.ExecutionCallback<CollectionWithPagingInfo>(){
|
||||
@Override
|
||||
public void onSuccess(CollectionWithPagingInfo result, ContentInfo contentInfo)
|
||||
public void onSuccess(CollectionWithPagingInfo result, ContentInfo contentInfo, int statusCode )
|
||||
{
|
||||
assertNotNull(result);
|
||||
}});
|
||||
|
||||
executor.execute(baa, Params.valueOf("4", "45"), new ActionExecutor.ExecutionCallback<ExecutionResult>(){
|
||||
@Override
|
||||
public void onSuccess(ExecutionResult result, ContentInfo contentInfo)
|
||||
public void onSuccess(ExecutionResult result, ContentInfo contentInfo, int statusCode )
|
||||
{
|
||||
assertNotNull(result);
|
||||
}});
|
||||
@@ -65,7 +65,7 @@ public class ExecutionTests extends AbstractContextTest
|
||||
ResourceWithMetadata baaPhoto = locator.locateRelationResource(api,"sheep/{entityId}/baaahh", "photo", HttpMethod.GET);
|
||||
executor.execute(baaPhoto, Params.valueOf("4", "45"), new ActionExecutor.ExecutionCallback<CollectionWithPagingInfo>(){
|
||||
@Override
|
||||
public void onSuccess(CollectionWithPagingInfo result, ContentInfo contentInfo)
|
||||
public void onSuccess(CollectionWithPagingInfo result, ContentInfo contentInfo, int statusCode )
|
||||
{
|
||||
assertNull(result);
|
||||
}});
|
||||
@@ -81,7 +81,7 @@ public class ExecutionTests extends AbstractContextTest
|
||||
final Sheep aSheep = new Sheep("xyz");
|
||||
executor.execute(resource, Params.valueOf("654", null, NULL_PARAMS, Arrays.asList(aSheep)), new ActionExecutor.ExecutionCallback<ExecutionResult>(){
|
||||
@Override
|
||||
public void onSuccess(ExecutionResult result, ContentInfo contentInfo)
|
||||
public void onSuccess(ExecutionResult result, ContentInfo contentInfo, int statusCode )
|
||||
{
|
||||
assertNotNull(result);
|
||||
assertEquals(aSheep,result.getRoot());
|
||||
@@ -91,7 +91,7 @@ public class ExecutionTests extends AbstractContextTest
|
||||
final Grass grr = new Grass("grr");
|
||||
executor.execute(grassResource, Params.valueOf("654", null, NULL_PARAMS, Arrays.asList(grr)), new ActionExecutor.ExecutionCallback<ExecutionResult>(){
|
||||
@Override
|
||||
public void onSuccess(ExecutionResult result, ContentInfo contentInfo)
|
||||
public void onSuccess(ExecutionResult result, ContentInfo contentInfo, int statusCode )
|
||||
{
|
||||
assertEquals(grr,result.getRoot());
|
||||
}});
|
||||
@@ -99,7 +99,7 @@ public class ExecutionTests extends AbstractContextTest
|
||||
ResourceWithMetadata entityResource = locator.locateRelationResource(api,"grass", "grow", HttpMethod.POST);
|
||||
executor.execute(entityResource, Params.valueOf("654", null, NULL_PARAMS, grr), new ActionExecutor.ExecutionCallback<String>(){
|
||||
@Override
|
||||
public void onSuccess(String result, ContentInfo contentInfo)
|
||||
public void onSuccess(String result, ContentInfo contentInfo, int statusCode )
|
||||
{
|
||||
assertEquals("Growing well",result);
|
||||
}});
|
||||
@@ -113,14 +113,14 @@ public class ExecutionTests extends AbstractContextTest
|
||||
AbstractResourceWebScript executor = (AbstractResourceWebScript) applicationContext.getBean("executorOfDelete");
|
||||
executor.execute(grassResource, Params.valueOf("4", null), new ActionExecutor.ExecutionCallback<Object>(){
|
||||
@Override
|
||||
public void onSuccess(Object result, ContentInfo contentInfo)
|
||||
public void onSuccess(Object result, ContentInfo contentInfo, int statusCode )
|
||||
{
|
||||
assertNull(result);
|
||||
}});
|
||||
ResourceWithMetadata resource = locator.locateRelationResource(api, "sheep", "blacksheep", HttpMethod.DELETE);
|
||||
executor.execute(resource, Params.valueOf("4", null), new ActionExecutor.ExecutionCallback<Object>(){
|
||||
@Override
|
||||
public void onSuccess(Object result, ContentInfo contentInfo)
|
||||
public void onSuccess(Object result, ContentInfo contentInfo, int statusCode )
|
||||
{
|
||||
assertNull(result);
|
||||
}});
|
||||
@@ -128,7 +128,7 @@ public class ExecutionTests extends AbstractContextTest
|
||||
ResourceWithMetadata goatDelete = locator.locateRelationResource(api3,"goat/{entityId}/herd", "content", HttpMethod.DELETE);
|
||||
executor.execute(goatDelete, Params.valueOf("4", "56"), new ActionExecutor.ExecutionCallback<Object>(){
|
||||
@Override
|
||||
public void onSuccess(Object result, ContentInfo contentInfo)
|
||||
public void onSuccess(Object result, ContentInfo contentInfo, int statusCode )
|
||||
{
|
||||
assertNull(result);
|
||||
}});
|
||||
@@ -143,7 +143,7 @@ public class ExecutionTests extends AbstractContextTest
|
||||
final Sheep aSheep = new Sheep("xyz");
|
||||
executor.execute(entityResource, Params.valueOf("654", null, NULL_PARAMS, aSheep), new ActionExecutor.ExecutionCallback<ExecutionResult>(){
|
||||
@Override
|
||||
public void onSuccess(ExecutionResult result, ContentInfo contentInfo)
|
||||
public void onSuccess(ExecutionResult result, ContentInfo contentInfo, int statusCode )
|
||||
{
|
||||
assertNotNull(result);
|
||||
assertEquals(aSheep,result.getRoot());
|
||||
@@ -152,7 +152,7 @@ public class ExecutionTests extends AbstractContextTest
|
||||
ResourceWithMetadata resource = locator.locateRelationResource(api, "sheep", "blacksheep", HttpMethod.PUT);
|
||||
executor.execute(resource, Params.valueOf("654", null, NULL_PARAMS, aSheep), new ActionExecutor.ExecutionCallback<ExecutionResult>(){
|
||||
@Override
|
||||
public void onSuccess(ExecutionResult result, ContentInfo contentInfo)
|
||||
public void onSuccess(ExecutionResult result, ContentInfo contentInfo, int statusCode )
|
||||
{
|
||||
assertNotNull(result);
|
||||
assertEquals(aSheep,result.getRoot());
|
||||
@@ -160,7 +160,7 @@ public class ExecutionTests extends AbstractContextTest
|
||||
ResourceWithMetadata baaPhoto = locator.locateRelationResource(api,"sheep/{entityId}/baaahh", "photo", HttpMethod.PUT);
|
||||
executor.execute(baaPhoto, Params.valueOf("4", "56"), new ActionExecutor.ExecutionCallback<Object>(){
|
||||
@Override
|
||||
public void onSuccess(Object result, ContentInfo contentInfo)
|
||||
public void onSuccess(Object result, ContentInfo contentInfo, int statusCode )
|
||||
{
|
||||
assertNull(result);
|
||||
}});
|
||||
|
@@ -52,6 +52,7 @@ import org.alfresco.rest.framework.tests.api.mocks3.SheepEntityResourceWithDelet
|
||||
import org.alfresco.rest.framework.tests.api.mocks3.SlimGoat;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.junit.Test;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
/**
|
||||
@@ -69,11 +70,12 @@ public class InspectorTests
|
||||
assertTrue("Must be one ResourceMetadata",metainfo.size()==1);
|
||||
ResourceMetadata metaData = metainfo.get(0);
|
||||
assertNotNull(metaData);
|
||||
assertTrue("SheepEntityResource supports GET", metaData.supports(HttpMethod.GET));
|
||||
assertTrue("SheepEntityResource supports PUT", metaData.supports(HttpMethod.PUT));
|
||||
assertTrue("SheepEntityResource supports DELETE", metaData.supports(HttpMethod.DELETE));
|
||||
assertTrue("SheepEntityResource does not support POST", !metaData.supports(HttpMethod.POST));
|
||||
assertTrue("SheepEntityResource must support Sheep", Sheep.class.equals(metaData.getObjectType(HttpMethod.PUT)));
|
||||
assertNotNull("SheepEntityResource supports GET", metaData.getOperation(HttpMethod.GET));
|
||||
assertNotNull("SheepEntityResource supports PUT", metaData.getOperation(HttpMethod.PUT));
|
||||
assertNotNull("SheepEntityResource supports DELETE", metaData.getOperation(HttpMethod.DELETE));
|
||||
assertNull("SheepEntityResource does not support POST", metaData.getOperation(HttpMethod.POST));
|
||||
ResourceOperation op = metaData.getOperation(HttpMethod.PUT);
|
||||
assertTrue("SheepEntityResource must support Sheep", Sheep.class.equals(metaData.getObjectType(op)));
|
||||
|
||||
metainfo = ResourceInspector.inspect(SheepNoActionEntityResource.class);
|
||||
assertTrue("SheepNoActionEntityResource has no actions.",metainfo.isEmpty());
|
||||
@@ -82,28 +84,30 @@ public class InspectorTests
|
||||
assertTrue("Must be one ResourceMetadata",metainfo.size()==1);
|
||||
metaData = metainfo.get(0);
|
||||
assertNotNull(metaData);
|
||||
assertTrue("GoatEntityResource supports GET", metaData.supports(HttpMethod.GET));
|
||||
List<ResourceParameter> params = metaData.getParameters(HttpMethod.GET);
|
||||
assertNotNull("GoatEntityResource supports GET", metaData.getOperation(HttpMethod.GET));
|
||||
op = metaData.getOperation(HttpMethod.GET);
|
||||
List<ResourceParameter> params = op.getParameters();
|
||||
assertTrue("readById method should have 1 url param", params.size() == 1);
|
||||
|
||||
metainfo = ResourceInspector.inspect(FlockEntityResource.class);
|
||||
assertTrue("Must be one ResourceMetadata",metainfo.size()==1);
|
||||
metaData = metainfo.get(0);
|
||||
assertNotNull(metaData);
|
||||
assertTrue("FlockEntityResource supports GET", metaData.supports(HttpMethod.GET));
|
||||
assertTrue("FlockEntityResource supports PUT", metaData.supports(HttpMethod.PUT));
|
||||
assertTrue("FlockEntityResource supports DELETE", metaData.supports(HttpMethod.DELETE));
|
||||
assertTrue("FlockEntityResource does not support POST", !metaData.supports(HttpMethod.POST));
|
||||
assertNotNull("FlockEntityResource supports GET", metaData.getOperation(HttpMethod.GET));
|
||||
assertNotNull("FlockEntityResource supports PUT", metaData.getOperation(HttpMethod.PUT));
|
||||
assertNotNull("FlockEntityResource supports DELETE", metaData.getOperation(HttpMethod.DELETE));
|
||||
assertNull("FlockEntityResource does not support POST", metaData.getOperation(HttpMethod.POST));
|
||||
|
||||
metainfo = ResourceInspector.inspect(MultiPartTestEntityResource.class);
|
||||
assertTrue("Must be one ResourceMetadata",metainfo.size()==1);
|
||||
metaData = metainfo.get(0);
|
||||
assertNotNull(metaData);
|
||||
assertTrue("MultiPartTestEntityResource support POST", metaData.supports(HttpMethod.POST));
|
||||
assertFalse("MultiPartTestEntityResource does not supports GET", metaData.supports(HttpMethod.GET));
|
||||
assertFalse("MultiPartTestEntityResource does not supports PUT", metaData.supports(HttpMethod.PUT));
|
||||
assertFalse("MultiPartTestEntityResource does not supports DELETE", metaData.supports(HttpMethod.DELETE));
|
||||
assertTrue("MultiPartTestEntityResource must support MultiPartTestResponse", MultiPartTestResponse.class.equals(metaData.getObjectType(HttpMethod.POST)));
|
||||
assertNotNull("MultiPartTestEntityResource support POST", metaData.getOperation(HttpMethod.POST));
|
||||
assertNull("MultiPartTestEntityResource does not supports GET", metaData.getOperation(HttpMethod.GET));
|
||||
assertNull("MultiPartTestEntityResource does not supports PUT", metaData.getOperation(HttpMethod.PUT));
|
||||
assertNull("MultiPartTestEntityResource does not supports DELETE", metaData.getOperation(HttpMethod.DELETE));
|
||||
op = metaData.getOperation(HttpMethod.POST);
|
||||
assertTrue("MultiPartTestEntityResource must support MultiPartTestResponse", MultiPartTestResponse.class.equals(metaData.getObjectType(op)));
|
||||
|
||||
}
|
||||
|
||||
@@ -114,15 +118,18 @@ public class InspectorTests
|
||||
assertTrue("Must be one ResourceMetadata",metainfo.size()==1);
|
||||
ResourceMetadata metaData = metainfo.get(0);
|
||||
assertNotNull(metaData);
|
||||
assertTrue("SheepBlackSheepResource supports GET", metaData.supports(HttpMethod.GET));
|
||||
List<ResourceParameter> params = metaData.getParameters(HttpMethod.GET);
|
||||
assertNotNull("SheepBlackSheepResource supports GET", metaData.getOperation(HttpMethod.GET));
|
||||
ResourceOperation op = metaData.getOperation(HttpMethod.GET);
|
||||
List<ResourceParameter> params = op.getParameters();
|
||||
assertTrue("readAll method should have 1 url param and 3 query params", params.size() == 4);
|
||||
assertTrue("SheepBlackSheepResource supports PUT", metaData.supports(HttpMethod.PUT));
|
||||
params = metaData.getParameters(HttpMethod.PUT);
|
||||
assertNotNull("SheepBlackSheepResource supports PUT", metaData.getOperation(HttpMethod.PUT));
|
||||
op = metaData.getOperation(HttpMethod.PUT);
|
||||
params = op.getParameters();
|
||||
assertTrue("update method should have 2 url params and 1 HTTP_OBJECT param ", params.size() == 3);
|
||||
assertTrue("SheepBlackSheepResource supports POST", metaData.supports(HttpMethod.POST));
|
||||
assertTrue("SheepBlackSheepResource must support Sheep", Sheep.class.equals(metaData.getObjectType(HttpMethod.POST)));
|
||||
params = metaData.getParameters(HttpMethod.POST);
|
||||
assertNotNull("SheepBlackSheepResource supports POST", metaData.getOperation(HttpMethod.POST));
|
||||
op = metaData.getOperation(HttpMethod.POST);
|
||||
params = op.getParameters();
|
||||
assertTrue("SheepBlackSheepResource must support Sheep", Sheep.class.equals(metaData.getObjectType(op)));
|
||||
assertTrue("create method should have 1 url param and 1 HTTP_OBJECT param ", params.size() == 2);
|
||||
assertNotNull(params);
|
||||
for (ResourceParameter resourceParameter : params)
|
||||
@@ -132,19 +139,21 @@ public class InspectorTests
|
||||
assertFalse(resourceParameter.isAllowMultiple()); //set to not allow multiple
|
||||
}
|
||||
}
|
||||
assertTrue("SheepBlackSheepResource supports DELETE", metaData.supports(HttpMethod.DELETE));
|
||||
params = metaData.getParameters(HttpMethod.DELETE);
|
||||
assertNotNull("SheepBlackSheepResource supports DELETE", metaData.getOperation(HttpMethod.DELETE));
|
||||
op = metaData.getOperation(HttpMethod.DELETE);
|
||||
params = op.getParameters();
|
||||
assertTrue("DELETE method on a relations should have 2 url params.", params.size() == 2);
|
||||
|
||||
metainfo = ResourceInspector.inspect(MultiPartTestRelationshipResource.class);
|
||||
assertTrue("Must be one ResourceMetadata",metainfo.size()==1);
|
||||
metaData = metainfo.get(0);
|
||||
assertNotNull(metaData);
|
||||
assertTrue("MultiPartTestRelationshipResource support POST", metaData.supports(HttpMethod.POST));
|
||||
assertFalse("MultiPartTestRelationshipResource does not supports GET", metaData.supports(HttpMethod.GET));
|
||||
assertFalse("MultiPartTestRelationshipResource does not supports PUT", metaData.supports(HttpMethod.PUT));
|
||||
assertFalse("MultiPartTestRelationshipResource does not supports DELETE", metaData.supports(HttpMethod.DELETE));
|
||||
assertTrue("MultiPartTestRelationshipResource must support MultiPartTestResponse", MultiPartTestResponse.class.equals(metaData.getObjectType(HttpMethod.POST)));
|
||||
assertNotNull("MultiPartTestRelationshipResource support POST", metaData.getOperation(HttpMethod.POST));
|
||||
assertNull("MultiPartTestRelationshipResource does not supports GET", metaData.getOperation(HttpMethod.GET));
|
||||
assertNull("MultiPartTestRelationshipResource does not supports PUT", metaData.getOperation(HttpMethod.PUT));
|
||||
assertNull("MultiPartTestRelationshipResource does not supports DELETE", metaData.getOperation(HttpMethod.DELETE));
|
||||
op = metaData.getOperation(HttpMethod.POST);
|
||||
assertTrue("MultiPartTestRelationshipResource must support MultiPartTestResponse", MultiPartTestResponse.class.equals(metaData.getObjectType(op)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -171,7 +180,8 @@ public class InspectorTests
|
||||
assertTrue("Must be one ResourceMetadata",metainfo.size()==1);
|
||||
ResourceMetadata metaData = metainfo.get(0);
|
||||
assertNotNull(metaData);
|
||||
assertTrue("NodeCommentsRelation must support Comment", Comment.class.equals(metaData.getObjectType(HttpMethod.POST)));
|
||||
ResourceOperation op = metaData.getOperation(HttpMethod.POST);
|
||||
assertTrue("NodeCommentsRelation must support Comment", Comment.class.equals(metaData.getObjectType(op)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -425,17 +435,19 @@ public class InspectorTests
|
||||
switch (resourceMetadata.getUniqueId())
|
||||
{
|
||||
case "/-root-/{id}/grow":
|
||||
assertTrue("GrassEntityResource supports POST", resourceMetadata.supports(HttpMethod.POST));
|
||||
assertFalse("GrassEntityResource does not support DELETE", resourceMetadata.supports(HttpMethod.DELETE));
|
||||
Class paramType = resourceMetadata.getObjectType(HttpMethod.POST);
|
||||
assertNotNull("GrassEntityResource supports POST", resourceMetadata.getOperation(HttpMethod.POST));
|
||||
assertNull("GrassEntityResource does not support DELETE", resourceMetadata.getOperation(HttpMethod.DELETE));
|
||||
ResourceOperation op = resourceMetadata.getOperation(HttpMethod.POST);
|
||||
Class paramType = resourceMetadata.getObjectType(op);
|
||||
Object paramObj = paramType.newInstance();
|
||||
result = (String) ResourceInspectorUtil.invokeMethod(actionMethod,grassEntityResource, "xyz", paramObj, Params.valueOf("notUsed", null));
|
||||
assertEquals("Growing well",result);
|
||||
break;
|
||||
case "/-root-/{id}/cut":
|
||||
assertTrue("GrassEntityResource supports POST", resourceMetadata.supports(HttpMethod.POST));
|
||||
assertFalse("GrassEntityResource does not support GET", resourceMetadata.supports(HttpMethod.GET));
|
||||
assertNull(resourceMetadata.getObjectType(HttpMethod.POST));
|
||||
assertNotNull("GrassEntityResource supports POST", resourceMetadata.getOperation(HttpMethod.POST));
|
||||
assertNull("GrassEntityResource does not support GET", resourceMetadata.getOperation(HttpMethod.GET));
|
||||
op = resourceMetadata.getOperation(HttpMethod.POST);
|
||||
assertNull(resourceMetadata.getObjectType(op));
|
||||
result = (String) ResourceInspectorUtil.invokeMethod(actionMethod,grassEntityResource, "xyz", null, Params.valueOf("notUsed", null));
|
||||
assertEquals("All done",result);
|
||||
break;
|
||||
@@ -458,10 +470,10 @@ public class InspectorTests
|
||||
switch (resourceMetadata.getUniqueId())
|
||||
{
|
||||
case "/goat/{entityId}/herd":
|
||||
assertTrue("GoatRelationshipResource supports GET", resourceMetadata.supports(HttpMethod.GET));
|
||||
assertNotNull("GoatRelationshipResource supports GET", resourceMetadata.getOperation(HttpMethod.GET));
|
||||
break;
|
||||
case "/goat/{entityId}/herd/{id}/content":
|
||||
assertTrue("GoatRelationshipResource supports GET", resourceMetadata.supports(HttpMethod.GET));
|
||||
assertNotNull("GoatRelationshipResource supports GET", resourceMetadata.getOperation(HttpMethod.GET));
|
||||
break;
|
||||
default:
|
||||
fail("Invalid information.");
|
||||
@@ -480,9 +492,9 @@ public class InspectorTests
|
||||
ResourceMetadata metaData = metainfo.get(0);
|
||||
assertEquals("/myroot/{id}/photo",metaData.getUniqueId());
|
||||
assertTrue(metaData.getOperations().size()==3);
|
||||
assertTrue("FlockEntityResource supports GET", metaData.supports(HttpMethod.GET));
|
||||
assertTrue("FlockEntityResource supports PUT", metaData.supports(HttpMethod.PUT));
|
||||
assertTrue("FlockEntityResource supports DELETE", metaData.supports(HttpMethod.DELETE));
|
||||
assertNotNull("FlockEntityResource supports GET", metaData.getOperation(HttpMethod.GET));
|
||||
assertNotNull("FlockEntityResource supports PUT", metaData.getOperation(HttpMethod.PUT));
|
||||
assertNotNull("FlockEntityResource supports DELETE", metaData.getOperation(HttpMethod.DELETE));
|
||||
|
||||
metainfo.clear();
|
||||
ResourceInspector.inspectAddressedProperties(api, FlocketEntityResource.class, "myroot", metainfo);
|
||||
@@ -493,19 +505,19 @@ public class InspectorTests
|
||||
// switch (resourceMetadata.getUniqueId())
|
||||
// {
|
||||
// case "/myroot/photo":
|
||||
// assertTrue("FlocketEntityResource supports GET", resourceMetadata.supports(HttpMethod.GET));
|
||||
// assertTrue("FlocketEntityResource supports PUT", resourceMetadata.supports(HttpMethod.PUT));
|
||||
// assertTrue("FlocketEntityResource supports DELETE", resourceMetadata.supports(HttpMethod.DELETE));
|
||||
// assertTrue("FlocketEntityResource supports GET", resourcemetaData.getOperation(HttpMethod.GET));
|
||||
// assertTrue("FlocketEntityResource supports PUT", resourcemetaData.getOperation(HttpMethod.PUT));
|
||||
// assertTrue("FlocketEntityResource supports DELETE", resourcemetaData.getOperation(HttpMethod.DELETE));
|
||||
// break;
|
||||
// case "/myroot/album":
|
||||
// assertTrue("FlocketEntityResource supports GET", resourceMetadata.supports(HttpMethod.GET));
|
||||
// assertTrue("FlocketEntityResource supports PUT", resourceMetadata.supports(HttpMethod.PUT));
|
||||
// assertTrue("FlocketEntityResource does not support DELETE", !resourceMetadata.supports(HttpMethod.DELETE));
|
||||
// assertTrue("FlocketEntityResource supports GET", resourcemetaData.getOperation(HttpMethod.GET));
|
||||
// assertTrue("FlocketEntityResource supports PUT", resourcemetaData.getOperation(HttpMethod.PUT));
|
||||
// assertTrue("FlocketEntityResource does not support DELETE", !resourcemetaData.getOperation(HttpMethod.DELETE));
|
||||
// break;
|
||||
// case "/myroot/madeUpProp":
|
||||
// assertTrue("FlocketEntityResource supports GET", resourceMetadata.supports(HttpMethod.GET));
|
||||
// assertTrue("FlocketEntityResource does not supports PUT", !resourceMetadata.supports(HttpMethod.PUT));
|
||||
// assertTrue("FlocketEntityResource does not support DELETE", !resourceMetadata.supports(HttpMethod.DELETE));
|
||||
// assertTrue("FlocketEntityResource supports GET", resourcemetaData.getOperation(HttpMethod.GET));
|
||||
// assertTrue("FlocketEntityResource does not supports PUT", !resourcemetaData.getOperation(HttpMethod.PUT));
|
||||
// assertTrue("FlocketEntityResource does not support DELETE", !resourcemetaData.getOperation(HttpMethod.DELETE));
|
||||
// break;
|
||||
// default:
|
||||
// fail("Invalid address property information.");
|
||||
@@ -513,25 +525,25 @@ public class InspectorTests
|
||||
|
||||
if ("/myroot/{id}/photo".equals(resourceMetadata.getUniqueId()))
|
||||
{
|
||||
assertTrue("FlocketEntityResource supports GET", resourceMetadata.supports(HttpMethod.GET));
|
||||
assertTrue("FlocketEntityResource supports PUT", resourceMetadata.supports(HttpMethod.PUT));
|
||||
assertTrue("FlocketEntityResource supports DELETE", resourceMetadata.supports(HttpMethod.DELETE));
|
||||
assertNotNull("FlocketEntityResource supports GET", resourceMetadata.getOperation(HttpMethod.GET));
|
||||
assertNotNull("FlocketEntityResource supports PUT", resourceMetadata.getOperation(HttpMethod.PUT));
|
||||
assertNotNull("FlocketEntityResource supports DELETE", resourceMetadata.getOperation(HttpMethod.DELETE));
|
||||
}
|
||||
else
|
||||
{
|
||||
if ("/myroot/{id}/album".equals(resourceMetadata.getUniqueId()))
|
||||
{
|
||||
assertTrue("FlocketEntityResource supports GET", resourceMetadata.supports(HttpMethod.GET));
|
||||
assertTrue("FlocketEntityResource supports PUT", resourceMetadata.supports(HttpMethod.PUT));
|
||||
assertTrue("FlocketEntityResource does not support DELETE", !resourceMetadata.supports(HttpMethod.DELETE));
|
||||
assertNotNull("FlocketEntityResource supports GET", resourceMetadata.getOperation(HttpMethod.GET));
|
||||
assertNotNull("FlocketEntityResource supports PUT", resourceMetadata.getOperation(HttpMethod.PUT));
|
||||
assertNull("FlocketEntityResource does not support DELETE", resourceMetadata.getOperation(HttpMethod.DELETE));
|
||||
}
|
||||
else
|
||||
{
|
||||
if ("/myroot/{id}/madeUpProp".equals(resourceMetadata.getUniqueId()))
|
||||
{
|
||||
assertTrue("FlocketEntityResource supports GET", resourceMetadata.supports(HttpMethod.GET));
|
||||
assertTrue("FlocketEntityResource does not supports PUT", !resourceMetadata.supports(HttpMethod.PUT));
|
||||
assertTrue("FlocketEntityResource does not support DELETE", !resourceMetadata.supports(HttpMethod.DELETE));
|
||||
assertNotNull("FlocketEntityResource supports GET", resourceMetadata.getOperation(HttpMethod.GET));
|
||||
assertNull("FlocketEntityResource does not supports PUT", resourceMetadata.getOperation(HttpMethod.PUT));
|
||||
assertNull("FlocketEntityResource does not support DELETE", resourceMetadata.getOperation(HttpMethod.DELETE));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -550,20 +562,35 @@ public class InspectorTests
|
||||
assertTrue("Must be at least one ResourceMetadata",metainfo.size()>0);
|
||||
ResourceMetadata metaData = metainfo.get(0);
|
||||
assertNotNull(metaData);
|
||||
assertTrue("GrassEntityResourceNowDeleted all methods deleted", !metaData.supports(HttpMethod.GET));
|
||||
assertTrue("GrassEntityResourceNowDeleted all methods deleted", !metaData.supports(HttpMethod.PUT));
|
||||
assertTrue("GrassEntityResourceNowDeleted all methods deleted", !metaData.supports(HttpMethod.DELETE));
|
||||
assertTrue("GrassEntityResourceNowDeleted all methods deleted", !metaData.supports(HttpMethod.POST));
|
||||
assertNull("GrassEntityResourceNowDeleted all methods deleted", metaData.getObjectType(HttpMethod.POST));
|
||||
assertNull("GrassEntityResourceNowDeleted all methods deleted", metaData.getOperation(HttpMethod.GET));
|
||||
assertNull("GrassEntityResourceNowDeleted all methods deleted", metaData.getOperation(HttpMethod.PUT));
|
||||
assertNull("GrassEntityResourceNowDeleted all methods deleted", metaData.getOperation(HttpMethod.DELETE));
|
||||
assertNull("GrassEntityResourceNowDeleted all methods deleted", metaData.getOperation(HttpMethod.POST));
|
||||
|
||||
metainfo = ResourceInspector.inspect(SheepBlackSheepResourceIsNoMore.class);
|
||||
assertTrue("Must be at least one ResourceMetadata",metainfo.size()>0);
|
||||
metaData = metainfo.get(0);
|
||||
assertNotNull(metaData);
|
||||
assertTrue("SheepBlackSheepResourceIsNoMore all methods deleted", !metaData.supports(HttpMethod.GET));
|
||||
assertTrue("SheepBlackSheepResourceIsNoMore all methods deleted", !metaData.supports(HttpMethod.PUT));
|
||||
assertTrue("SheepBlackSheepResourceIsNoMore all methods deleted", !metaData.supports(HttpMethod.DELETE));
|
||||
assertTrue("SheepBlackSheepResourceIsNoMore all methods deleted", !metaData.supports(HttpMethod.POST));
|
||||
assertNull("SheepBlackSheepResourceIsNoMore all methods deleted", metaData.getObjectType(HttpMethod.POST));
|
||||
assertNull("SheepBlackSheepResourceIsNoMore all methods deleted", metaData.getOperation(HttpMethod.GET));
|
||||
assertNull("SheepBlackSheepResourceIsNoMore all methods deleted", metaData.getOperation(HttpMethod.PUT));
|
||||
assertNull("SheepBlackSheepResourceIsNoMore all methods deleted", metaData.getOperation(HttpMethod.DELETE));
|
||||
assertNull("SheepBlackSheepResourceIsNoMore all methods deleted", metaData.getOperation(HttpMethod.POST));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidSuccessCode()
|
||||
{
|
||||
//Test defaults
|
||||
assertEquals(Status.STATUS_OK,ResourceInspector.validSuccessCode(HttpMethod.GET, ResourceOperation.UNSET_STATUS));
|
||||
assertEquals(Status.STATUS_CREATED,ResourceInspector.validSuccessCode(HttpMethod.POST, ResourceOperation.UNSET_STATUS));
|
||||
assertEquals(Status.STATUS_OK,ResourceInspector.validSuccessCode(HttpMethod.PUT, ResourceOperation.UNSET_STATUS));
|
||||
assertEquals(Status.STATUS_NO_CONTENT,ResourceInspector.validSuccessCode(HttpMethod.DELETE, ResourceOperation.UNSET_STATUS));
|
||||
|
||||
//Test custom values
|
||||
assertEquals(Status.STATUS_ACCEPTED,ResourceInspector.validSuccessCode(HttpMethod.GET, Status.STATUS_ACCEPTED));
|
||||
assertEquals(Status.STATUS_FOUND,ResourceInspector.validSuccessCode(HttpMethod.POST, Status.STATUS_FOUND));
|
||||
assertEquals(Status.STATUS_ACCEPTED,ResourceInspector.validSuccessCode(HttpMethod.PUT, Status.STATUS_ACCEPTED));
|
||||
assertEquals(Status.STATUS_NOT_MODIFIED,ResourceInspector.validSuccessCode(HttpMethod.DELETE, Status.STATUS_NOT_MODIFIED));
|
||||
}
|
||||
}
|
||||
|
@@ -1,11 +1,13 @@
|
||||
package org.alfresco.rest.framework.tests.core;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.any;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.notNull;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -23,6 +25,7 @@ import org.alfresco.rest.api.tests.util.MultiPartBuilder.FileData;
|
||||
import org.alfresco.rest.api.tests.util.MultiPartBuilder.MultiPartRequest;
|
||||
import org.alfresco.rest.framework.core.ResourceLocator;
|
||||
import org.alfresco.rest.framework.core.ResourceMetadata;
|
||||
import org.alfresco.rest.framework.core.ResourceOperation;
|
||||
import org.alfresco.rest.framework.core.exceptions.UnsupportedResourceOperationException;
|
||||
import org.alfresco.rest.framework.jacksonextensions.BeanPropertiesFilter;
|
||||
import org.alfresco.rest.framework.jacksonextensions.JacksonHelper;
|
||||
@@ -255,9 +258,6 @@ public class ParamsExtractorTests
|
||||
FormData formData = (FormData) passed;
|
||||
assertTrue(formData.getIsMultiPart());
|
||||
|
||||
assertNotNull(params.getStatus());
|
||||
assertFalse(params.getStatus().getRedirect());
|
||||
|
||||
// No entity id for POST
|
||||
templateVars.put(ResourceLocator.ENTITY_ID, "1234");
|
||||
try
|
||||
@@ -446,9 +446,10 @@ public class ParamsExtractorTests
|
||||
private static ResourceMetadata mockEntity()
|
||||
{
|
||||
ResourceMetadata resourceMock = mock(ResourceMetadata.class);
|
||||
ResourceOperation resourceOperation = mock(ResourceOperation.class);
|
||||
when(resourceMock.getType()).thenReturn(ResourceMetadata.RESOURCE_TYPE.ENTITY);
|
||||
when(resourceMock.getObjectType(HttpMethod.PUT)).thenReturn(Farmer.class);
|
||||
when(resourceMock.getObjectType(HttpMethod.POST)).thenReturn(Farmer.class);
|
||||
when(resourceMock.getOperation(notNull(HttpMethod.class))).thenReturn(resourceOperation);
|
||||
when(resourceMock.getObjectType(notNull(ResourceOperation.class))).thenReturn(Farmer.class);
|
||||
return resourceMock;
|
||||
}
|
||||
|
||||
@@ -483,9 +484,10 @@ public class ParamsExtractorTests
|
||||
private static ResourceMetadata mockRelationship()
|
||||
{
|
||||
ResourceMetadata resourceMock = mock(ResourceMetadata.class);
|
||||
ResourceOperation resourceOperation = mock(ResourceOperation.class);
|
||||
when(resourceMock.getOperation(notNull(HttpMethod.class))).thenReturn(resourceOperation);
|
||||
when(resourceMock.getType()).thenReturn(ResourceMetadata.RESOURCE_TYPE.RELATIONSHIP);
|
||||
when(resourceMock.getObjectType(HttpMethod.PUT)).thenReturn(Farmer.class);
|
||||
when(resourceMock.getObjectType(HttpMethod.POST)).thenReturn(Farmer.class);
|
||||
when(resourceMock.getObjectType(notNull(ResourceOperation.class))).thenReturn(Farmer.class);
|
||||
return resourceMock;
|
||||
}
|
||||
|
||||
|
@@ -19,6 +19,7 @@ import org.alfresco.rest.framework.core.ResourceInspector;
|
||||
import org.alfresco.rest.framework.core.ResourceLocator;
|
||||
import org.alfresco.rest.framework.core.ResourceLookupDictionary;
|
||||
import org.alfresco.rest.framework.core.ResourceMetadata;
|
||||
import org.alfresco.rest.framework.core.ResourceOperation;
|
||||
import org.alfresco.rest.framework.core.ResourceWithMetadata;
|
||||
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
||||
import org.alfresco.rest.framework.core.exceptions.UnsupportedResourceOperationException;
|
||||
@@ -104,20 +105,20 @@ public class ResourceLocatorTests
|
||||
templateVars.put(ResourceLocator.COLLECTION_RESOURCE, "sheep");
|
||||
ResourceWithMetadata collResource = locator.locateResource(api, templateVars, HttpMethod.GET);
|
||||
assertNotNull(collResource);
|
||||
assertTrue(collResource.getMetaData().supports(HttpMethod.GET));
|
||||
assertNotNull(collResource.getMetaData().getOperation(HttpMethod.GET));
|
||||
|
||||
collResource = locator.locateResource(api, templateVars, HttpMethod.POST);
|
||||
assertNotNull(collResource);
|
||||
assertTrue(collResource.getMetaData().supports(HttpMethod.POST));
|
||||
assertNotNull(collResource.getMetaData().getOperation(HttpMethod.POST));
|
||||
|
||||
templateVars.put(ResourceLocator.ENTITY_ID, "farmersUniqueId");
|
||||
ResourceWithMetadata entityResource = locator.locateResource(api,templateVars, HttpMethod.GET);
|
||||
assertNotNull(entityResource);
|
||||
assertTrue(entityResource.getMetaData().supports(HttpMethod.GET));
|
||||
assertNotNull(entityResource.getMetaData().getOperation(HttpMethod.GET));
|
||||
|
||||
entityResource = locator.locateResource(api, templateVars, HttpMethod.PUT);
|
||||
assertNotNull(entityResource);
|
||||
assertTrue(entityResource.getMetaData().supports(HttpMethod.PUT));
|
||||
assertNotNull(entityResource.getMetaData().getOperation(HttpMethod.PUT));
|
||||
|
||||
templateVars.clear();
|
||||
templateVars.put(ResourceLocator.COLLECTION_RESOURCE, "sheepnoaction");
|
||||
@@ -167,7 +168,7 @@ public class ResourceLocatorTests
|
||||
templateVars.put(ResourceLocator.RELATIONSHIP_RESOURCE, "photo");
|
||||
ResourceWithMetadata collResource = locator.locateResource(api3, templateVars, HttpMethod.GET);
|
||||
assertNotNull(collResource);
|
||||
assertTrue(collResource.getMetaData().supports(HttpMethod.GET));
|
||||
assertNotNull(collResource.getMetaData().getOperation(HttpMethod.GET));
|
||||
assertEquals(FlockEntityResource.class, collResource.getResource().getClass());
|
||||
|
||||
templateVars.put(ResourceLocator.COLLECTION_RESOURCE, "flocket");
|
||||
@@ -192,7 +193,7 @@ public class ResourceLocatorTests
|
||||
}
|
||||
collResource = locator.locateResource(api3, templateVars, HttpMethod.GET);
|
||||
assertNotNull(collResource);
|
||||
assertTrue(collResource.getMetaData().supports(HttpMethod.GET));
|
||||
assertNotNull(collResource.getMetaData().getOperation(HttpMethod.GET));
|
||||
assertEquals(FlocketEntityResource.class, collResource.getResource().getClass());
|
||||
|
||||
templateVars.put(ResourceLocator.RELATIONSHIP_RESOURCE, "album");
|
||||
@@ -207,11 +208,11 @@ public class ResourceLocatorTests
|
||||
}
|
||||
collResource = locator.locateResource(api3, templateVars, HttpMethod.GET);
|
||||
assertNotNull(collResource);
|
||||
assertTrue(collResource.getMetaData().supports(HttpMethod.GET));
|
||||
assertNotNull(collResource.getMetaData().getOperation(HttpMethod.GET));
|
||||
assertEquals(FlocketEntityResource.class, collResource.getResource().getClass());
|
||||
collResource = locator.locateResource(api3, templateVars, HttpMethod.PUT);
|
||||
assertNotNull(collResource);
|
||||
assertTrue(collResource.getMetaData().supports(HttpMethod.PUT));
|
||||
assertNotNull(collResource.getMetaData().getOperation(HttpMethod.PUT));
|
||||
assertEquals(FlocketEntityResource.class, collResource.getResource().getClass());
|
||||
}
|
||||
|
||||
@@ -238,7 +239,7 @@ public class ResourceLocatorTests
|
||||
templateVars.put(ResourceLocator.PROPERTY, "content");
|
||||
collResource = locator.locateResource(api3, templateVars, HttpMethod.GET);
|
||||
assertNotNull(collResource);
|
||||
assertTrue(collResource.getMetaData().supports(HttpMethod.GET));
|
||||
assertNotNull(collResource.getMetaData().getOperation(HttpMethod.GET));
|
||||
|
||||
templateVars = new HashMap<String, String>();
|
||||
templateVars.put(ResourceLocator.COLLECTION_RESOURCE, "sheep");
|
||||
@@ -260,9 +261,9 @@ public class ResourceLocatorTests
|
||||
templateVars.put(ResourceLocator.PROPERTY, "photo");
|
||||
collResource = locator.locateResource(api, templateVars, HttpMethod.GET);
|
||||
assertNotNull(collResource);
|
||||
assertTrue(collResource.getMetaData().supports(HttpMethod.GET));
|
||||
assertTrue(collResource.getMetaData().supports(HttpMethod.PUT));
|
||||
assertTrue(collResource.getMetaData().supports(HttpMethod.DELETE));
|
||||
assertNotNull(collResource.getMetaData().getOperation(HttpMethod.GET));
|
||||
assertNotNull(collResource.getMetaData().getOperation(HttpMethod.PUT));
|
||||
assertNotNull(collResource.getMetaData().getOperation(HttpMethod.DELETE));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -403,7 +403,7 @@ public class SerializeTests extends AbstractContextTest
|
||||
AbstractResourceWebScript executor = (AbstractResourceWebScript) applicationContext.getBean("executorOfGets");
|
||||
executor.execute(propResource, Params.valueOf("234", null), new ExecutionCallback<BinaryResource>(){
|
||||
@Override
|
||||
public void onSuccess(BinaryResource result, ContentInfo contentInfo)
|
||||
public void onSuccess(BinaryResource result, ContentInfo contentInfo, int statusCode)
|
||||
{
|
||||
assertNotNull(result);
|
||||
}});
|
||||
|
Reference in New Issue
Block a user