From 6e2fbe27e3aa372aab2b8014525a5e80c366e4b8 Mon Sep 17 00:00:00 2001 From: Jamal Kaabi-Mofrad Date: Tue, 10 May 2016 11:09:33 +0000 Subject: [PATCH] Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2) 122594 jvonka: REST api fwk: pass through query params for DELETE method - also update REST api test fwk RA-837 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@126483 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../webscripts/ResourceWebScriptDelete.java | 9 ++++--- .../rest/api/tests/AbstractBaseApiTest.java | 7 +++++- .../api/tests/client/PublicApiClient.java | 25 ++++++++++++++++++- .../api/tests/client/PublicApiHttpClient.java | 7 +++--- 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/source/java/org/alfresco/rest/framework/webscripts/ResourceWebScriptDelete.java b/source/java/org/alfresco/rest/framework/webscripts/ResourceWebScriptDelete.java index a386fab608..987c0ac5da 100644 --- a/source/java/org/alfresco/rest/framework/webscripts/ResourceWebScriptDelete.java +++ b/source/java/org/alfresco/rest/framework/webscripts/ResourceWebScriptDelete.java @@ -37,6 +37,7 @@ public class ResourceWebScriptDelete extends AbstractResourceWebScript implement { String entityId = req.getServiceMatch().getTemplateVars().get(ResourceLocator.ENTITY_ID); String relationshipId = req.getServiceMatch().getTemplateVars().get(ResourceLocator.RELATIONSHIP_ID); + final Params.RecognizedParams params = ResourceWebScriptHelper.getRecognizedParams(req); switch (resourceMeta.getType()) { @@ -47,7 +48,7 @@ public class ResourceWebScriptDelete extends AbstractResourceWebScript implement } else { - return Params.valueOf(entityId, relationshipId, req); + return Params.valueOf(params, entityId, relationshipId, req); } case RELATIONSHIP: @@ -58,7 +59,7 @@ public class ResourceWebScriptDelete extends AbstractResourceWebScript implement } else { - return Params.valueOf(entityId, relationshipId, req); + return Params.valueOf(params, entityId, relationshipId, req); } case PROPERTY: final String resourceName = req.getServiceMatch().getTemplateVars().get(ResourceLocator.RELATIONSHIP_RESOURCE); @@ -68,11 +69,11 @@ public class ResourceWebScriptDelete extends AbstractResourceWebScript implement { if (StringUtils.isNotBlank(propertyName)) { - return Params.valueOf(entityId, relationshipId, null, null, propertyName, null, null, req); + return Params.valueOf(entityId, relationshipId, null, null, propertyName, params, null, req); } else { - return Params.valueOf(entityId, null, null, null, resourceName, null, null, req); + return Params.valueOf(entityId, null, null, null, resourceName, params, null, req); } } //Fall through to unsupported. diff --git a/source/test-java/org/alfresco/rest/api/tests/AbstractBaseApiTest.java b/source/test-java/org/alfresco/rest/api/tests/AbstractBaseApiTest.java index 5eed7315ea..199a79d1ec 100644 --- a/source/test-java/org/alfresco/rest/api/tests/AbstractBaseApiTest.java +++ b/source/test-java/org/alfresco/rest/api/tests/AbstractBaseApiTest.java @@ -194,10 +194,15 @@ public abstract class AbstractBaseApiTest extends EnterpriseTestApi } protected HttpResponse delete(String url, String runAsUser, String entityId, int expectedStatus) throws Exception + { + return delete(url, runAsUser, entityId, null, expectedStatus); + } + + protected HttpResponse delete(String url, String runAsUser, String entityId, Map params, int expectedStatus) throws Exception { publicApiClient.setRequestContext(new RequestContext(runAsUser)); - HttpResponse response = publicApiClient.delete(getScope(), url, entityId, null, null); + HttpResponse response = publicApiClient.delete(getScope(), 1, url, entityId, null, null, params); checkStatus(expectedStatus, response.getStatusCode()); return response; diff --git a/source/test-java/org/alfresco/rest/api/tests/client/PublicApiClient.java b/source/test-java/org/alfresco/rest/api/tests/client/PublicApiClient.java index f3456df8a2..6d66099b2d 100644 --- a/source/test-java/org/alfresco/rest/api/tests/client/PublicApiClient.java +++ b/source/test-java/org/alfresco/rest/api/tests/client/PublicApiClient.java @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2005-2016 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ package org.alfresco.rest.api.tests.client; import static org.junit.Assert.assertNotNull; @@ -552,7 +570,12 @@ public class PublicApiClient public HttpResponse delete(String scope, String entityCollectionName, Object entityId, String relationCollectionName, Object relationshipEntityId) throws IOException { - HttpResponse response = client.delete(getRequestContext(), scope, entityCollectionName, entityId, relationCollectionName, relationshipEntityId); + return delete(scope, 1, entityCollectionName, entityId, relationCollectionName, relationshipEntityId, null); + } + + public HttpResponse delete(String scope, int version, String entityCollectionName, Object entityId, String relationCollectionName, Object relationshipEntityId, Map params) throws IOException + { + HttpResponse response = client.delete(getRequestContext(), scope, version, entityCollectionName, entityId, relationCollectionName, relationshipEntityId, params); logger.debug(response.toString()); diff --git a/source/test-java/org/alfresco/rest/api/tests/client/PublicApiHttpClient.java b/source/test-java/org/alfresco/rest/api/tests/client/PublicApiHttpClient.java index 75025c3e43..ae7603a3f5 100644 --- a/source/test-java/org/alfresco/rest/api/tests/client/PublicApiHttpClient.java +++ b/source/test-java/org/alfresco/rest/api/tests/client/PublicApiHttpClient.java @@ -16,7 +16,6 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ - package org.alfresco.rest.api.tests.client; import java.io.BufferedInputStream; @@ -545,14 +544,14 @@ public class PublicApiHttpClient public HttpResponse delete(final RequestContext rq, final String scope, final String entityCollectionName, final Object entityId, final String relationCollectionName, final Object relationshipEntityId) throws IOException { - return delete(rq, scope, 1, entityCollectionName, entityId, relationCollectionName, relationshipEntityId); + return delete(rq, scope, 1, entityCollectionName, entityId, relationCollectionName, relationshipEntityId, null); } public HttpResponse delete(final RequestContext rq, final String scope, final int version, final String entityCollectionName, final Object entityId, - final String relationCollectionName, final Object relationshipEntityId) throws IOException + final String relationCollectionName, final Object relationshipEntityId, final Map params) throws IOException { RestApiEndpoint endpoint = new RestApiEndpoint(rq.getNetworkId(), scope, version, entityCollectionName, entityId, relationCollectionName, - relationshipEntityId, null); + relationshipEntityId, params); String url = endpoint.getUrl(); DeleteMethod req = new DeleteMethod(url);