mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged WEBAPP-API (5.2.1) to 5.2.N (5.2.1)
135229 jkaabimofrad: APPSREPO-136: Updated the API framework so that WebApiNoAuth annotation can be used with operations. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@135565 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* #%L
|
||||
* Alfresco Remote API
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
@@ -27,6 +27,7 @@ package org.alfresco.rest.framework.tests.api.mocks;
|
||||
|
||||
import org.alfresco.rest.framework.Operation;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.WebApiNoAuth;
|
||||
import org.alfresco.rest.framework.WebApiParam;
|
||||
import org.alfresco.rest.framework.core.ResourceParameter;
|
||||
import org.alfresco.rest.framework.resource.EntityResource;
|
||||
@@ -73,4 +74,11 @@ public class GrassEntityResource implements EntityResourceAction.ReadById<Grass>
|
||||
{
|
||||
//I did a delete
|
||||
}
|
||||
|
||||
@Operation("cut-noAuth")
|
||||
@WebApiNoAuth
|
||||
@WebApiDescription(title = "Cut the grass",successStatus = Status.STATUS_NOT_IMPLEMENTED)
|
||||
public String cutLawnWithoutAuth(String id, Void notused, Parameters parameters, WithResponse withResponse) {
|
||||
return "All done without Auth";
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* #%L
|
||||
* Alfresco Remote API
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
@@ -41,7 +41,6 @@ import java.util.Map;
|
||||
|
||||
import org.alfresco.rest.api.model.Comment;
|
||||
import org.alfresco.rest.api.nodes.NodeCommentsRelation;
|
||||
import org.alfresco.rest.api.nodes.NodesEntityResource;
|
||||
import org.alfresco.rest.framework.Api;
|
||||
import org.alfresco.rest.framework.core.OperationResourceMetaData;
|
||||
import org.alfresco.rest.framework.core.ResourceInspector;
|
||||
@@ -76,9 +75,7 @@ import org.alfresco.rest.framework.tests.api.mocks3.GrassEntityResourceNowDelete
|
||||
import org.alfresco.rest.framework.tests.api.mocks3.SheepBlackSheepResourceIsNoMore;
|
||||
import org.alfresco.rest.framework.tests.api.mocks3.SheepEntityResourceWithDeletedMethods;
|
||||
import org.alfresco.rest.framework.tests.api.mocks3.SlimGoat;
|
||||
import org.alfresco.rest.framework.tools.ApiAssistant;
|
||||
import org.alfresco.rest.framework.tools.ResponseWriter;
|
||||
import org.alfresco.rest.framework.webscripts.ApiWebScript;
|
||||
import org.alfresco.rest.framework.webscripts.WithResponse;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.junit.Test;
|
||||
@@ -459,7 +456,7 @@ public class InspectorTests
|
||||
|
||||
GrassEntityResource grassEntityResource = new GrassEntityResource();
|
||||
ResourceInspector.inspectOperations(api, GrassEntityResource.class,"-root-", metainfo);
|
||||
assertTrue(metainfo.size()==2);
|
||||
assertEquals(3, metainfo.size());
|
||||
|
||||
for (ResourceMetadata resourceMetadata : metainfo)
|
||||
{
|
||||
@@ -480,6 +477,7 @@ public class InspectorTests
|
||||
Object paramObj = paramType.newInstance();
|
||||
result = (String) ResourceInspectorUtil.invokeMethod(actionMethod,grassEntityResource, "xyz", paramObj, Params.valueOf("notUsed", null, mock(WebScriptRequest.class)), wr);
|
||||
assertEquals("Growing well",result);
|
||||
assertFalse(operationResourceMetaData.isNoAuth(null));
|
||||
break;
|
||||
case "/-root-/{id}/cut":
|
||||
assertNotNull("GrassEntityResource supports POST", resourceMetadata.getOperation(HttpMethod.POST));
|
||||
@@ -489,6 +487,16 @@ public class InspectorTests
|
||||
assertEquals("cut should return ACCEPTED", Status.STATUS_NOT_IMPLEMENTED, op.getSuccessStatus());
|
||||
result = (String) ResourceInspectorUtil.invokeMethod(actionMethod,grassEntityResource, "xyz", null, Params.valueOf("notUsed", null, mock(WebScriptRequest.class)), wr);
|
||||
assertEquals("All done",result);
|
||||
assertFalse(operationResourceMetaData.isNoAuth(null));
|
||||
break;
|
||||
case "/-root-/{id}/cut-noAuth":
|
||||
assertNotNull("GrassEntityResource supports POST", resourceMetadata.getOperation(HttpMethod.POST));
|
||||
op = resourceMetadata.getOperation(HttpMethod.POST);
|
||||
assertNull(resourceMetadata.getObjectType(op));
|
||||
assertEquals("cut should return ACCEPTED", Status.STATUS_NOT_IMPLEMENTED, op.getSuccessStatus());
|
||||
result = (String) ResourceInspectorUtil.invokeMethod(actionMethod,grassEntityResource, "xyz", null, Params.valueOf("notUsed", null, mock(WebScriptRequest.class)), wr);
|
||||
assertEquals("All done without Auth",result);
|
||||
assertTrue(operationResourceMetaData.isNoAuth(null));
|
||||
break;
|
||||
default:
|
||||
fail("Invalid action information.");
|
||||
|
Reference in New Issue
Block a user