diff --git a/pom.xml b/pom.xml index 1bb212c144..c982bf4e60 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 alfresco-remote-api Alfresco Remote API - 6.19-TOKEN-AUTH-SNAPSHOT + 6.21-TOKEN-AUTH-SNAPSHOT jar @@ -35,9 +35,9 @@ ${project.build.directory}/alf_data convert - 6.30 - 7.0 - 8.1 + 6.36 + 7.1 + 8.2 1.1 2.8.10 diff --git a/src/main/java/org/alfresco/rest/api/groups/GroupMembersRelation.java b/src/main/java/org/alfresco/rest/api/groups/GroupMembersRelation.java index 6deefd2481..dfef446cc1 100644 --- a/src/main/java/org/alfresco/rest/api/groups/GroupMembersRelation.java +++ b/src/main/java/org/alfresco/rest/api/groups/GroupMembersRelation.java @@ -70,7 +70,7 @@ public class GroupMembersRelation @Override @WebApiDescription(title = "Create group membership.") - @WebApiParam(name = "entity", title = "A single group member", description = "A single group member, multiple groups members are not supported.", kind = ResourceParameter.KIND.HTTP_BODY_OBJECT, allowMultiple = false) + @WebApiParam(name = "entity", title = "A single group member", description = "A single group member, multiple groups members are not supported.", kind = ResourceParameter.KIND.HTTP_BODY_OBJECT, allowMultiple = false, required = true) public List create(String groupId, List entity, Parameters params) { List result = new ArrayList<>(1); diff --git a/src/main/java/org/alfresco/rest/api/groups/GroupsEntityResource.java b/src/main/java/org/alfresco/rest/api/groups/GroupsEntityResource.java index 93cf94052e..bd6ecc71de 100644 --- a/src/main/java/org/alfresco/rest/api/groups/GroupsEntityResource.java +++ b/src/main/java/org/alfresco/rest/api/groups/GroupsEntityResource.java @@ -80,7 +80,7 @@ public class GroupsEntityResource implements EntityResourceAction.Read, E @Override @WebApiDescription(title="Create group", description="Create group") @WebApiParam(name="entity", title="A single group", description="A single group, multiple groups are not supported.", - kind= ResourceParameter.KIND.HTTP_BODY_OBJECT, allowMultiple=false) + kind= ResourceParameter.KIND.HTTP_BODY_OBJECT, allowMultiple=false, required = true) public List create(List entity, Parameters parameters) { List result = new ArrayList<>(1); diff --git a/src/main/java/org/alfresco/rest/api/impl/SiteMembershipRequestsImpl.java b/src/main/java/org/alfresco/rest/api/impl/SiteMembershipRequestsImpl.java index 73422c483d..846f96ac1d 100644 --- a/src/main/java/org/alfresco/rest/api/impl/SiteMembershipRequestsImpl.java +++ b/src/main/java/org/alfresco/rest/api/impl/SiteMembershipRequestsImpl.java @@ -597,6 +597,8 @@ public class SiteMembershipRequestsImpl implements SiteMembershipRequests throw new PermissionDeniedException(); } + // Workflow doesn't allow changing the role, so a new update may be required if + // approval role differs from default one. if (siteMembershipApproval != null && !(siteMembershipApproval.getRole() == null || siteMembershipApproval.getRole().isEmpty())) { String role = siteMembershipApproval.getRole(); diff --git a/src/main/java/org/alfresco/rest/api/nodes/NodeRatingsRelation.java b/src/main/java/org/alfresco/rest/api/nodes/NodeRatingsRelation.java index 14d63ffad1..3381d6d7d2 100644 --- a/src/main/java/org/alfresco/rest/api/nodes/NodeRatingsRelation.java +++ b/src/main/java/org/alfresco/rest/api/nodes/NodeRatingsRelation.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Remote API - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * 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 . - * #L% - */ +/* + * #%L + * Alfresco Remote API + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * 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 . + * #L% + */ package org.alfresco.rest.api.nodes; import java.util.Collections; @@ -73,7 +73,7 @@ RelationshipResourceAction.Create, InitializingBean @Override @WebApiDescription(title="Rate a node for 'nodeId'.") @WebApiParam(name="ratingEntity", title="A single rating", description="A single node rating, multiple ratings are not supported.", - kind=ResourceParameter.KIND.HTTP_BODY_OBJECT, allowMultiple=false) + kind=ResourceParameter.KIND.HTTP_BODY_OBJECT, allowMultiple=false, required = true) public List create(String nodeId, List ratingEntity, Parameters parameters) { //There will always be 1 value because allowMultiple=false diff --git a/src/main/java/org/alfresco/rest/api/people/PeopleEntityResource.java b/src/main/java/org/alfresco/rest/api/people/PeopleEntityResource.java index bf5af1df97..114098121f 100644 --- a/src/main/java/org/alfresco/rest/api/people/PeopleEntityResource.java +++ b/src/main/java/org/alfresco/rest/api/people/PeopleEntityResource.java @@ -100,8 +100,8 @@ public class PeopleEntityResource implements EntityResourceAction.ReadById create(List persons, Parameters parameters) { Person p = persons.get(0); diff --git a/src/main/java/org/alfresco/rest/api/sites/SiteEntityResource.java b/src/main/java/org/alfresco/rest/api/sites/SiteEntityResource.java index accd3d40ae..3e90c68b4e 100644 --- a/src/main/java/org/alfresco/rest/api/sites/SiteEntityResource.java +++ b/src/main/java/org/alfresco/rest/api/sites/SiteEntityResource.java @@ -112,7 +112,7 @@ public class SiteEntityResource implements EntityResourceAction.Read, @Override @WebApiDescription(title="Create site", description="Create the default/functional Share site") @WebApiParam(name="entity", title="A single site", description="A single site, multiple sites are not supported.", - kind= ResourceParameter.KIND.HTTP_BODY_OBJECT, allowMultiple=false) + kind= ResourceParameter.KIND.HTTP_BODY_OBJECT, allowMultiple=false, required = true) public List create(List entity, Parameters parameters) { List result = new ArrayList<>(1); diff --git a/src/test/java/org/alfresco/rest/api/tests/RepoService.java b/src/test/java/org/alfresco/rest/api/tests/RepoService.java index b8490309bb..0a36470384 100644 --- a/src/test/java/org/alfresco/rest/api/tests/RepoService.java +++ b/src/test/java/org/alfresco/rest/api/tests/RepoService.java @@ -63,7 +63,6 @@ import org.alfresco.repo.invitation.InvitationSearchCriteriaImpl; import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory; import org.alfresco.repo.model.filefolder.HiddenAspect; import org.alfresco.repo.model.filefolder.HiddenAspect.Visibility; -import org.alfresco.repo.node.index.NodeIndexer; import org.alfresco.repo.security.authentication.AuthenticationException; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; @@ -201,7 +200,6 @@ public class RepoService protected InvitationService invitationService; protected LockService lockService; protected CMISConnector cmisConnector; - protected NodeIndexer nodeIndexer; protected HiddenAspect hiddenAspect; protected NetworksService networksService; protected NamespaceService namespaceService; @@ -257,7 +255,6 @@ public class RepoService this.invitationService = (InvitationService)applicationContext.getBean("InvitationService"); this.lockService = (LockService)applicationContext.getBean("LockService"); this.cmisConnector = (CMISConnector)applicationContext.getBean("CMISConnector"); - this.nodeIndexer = (NodeIndexer)applicationContext.getBean("nodeIndexer"); this.activities = (Activities)applicationContext.getBean("activities"); this.hiddenAspect = (HiddenAspect)applicationContext.getBean("hiddenAspect"); this.networksService = (NetworksService)applicationContext.getBean("networksService"); @@ -315,11 +312,6 @@ public class RepoService return allPeople.get(username.toLowerCase()); } - public void disableInTxnIndexing() - { - nodeIndexer.setDisabled(true); - } - public int getClientVisibilityMask(Client client, Visibility visibility) { return hiddenAspect.getClientVisibilityMask(client, visibility); diff --git a/src/test/java/org/alfresco/rest/api/tests/TestFavourites.java b/src/test/java/org/alfresco/rest/api/tests/TestFavourites.java index 299309d56e..a2963cef5a 100644 --- a/src/test/java/org/alfresco/rest/api/tests/TestFavourites.java +++ b/src/test/java/org/alfresco/rest/api/tests/TestFavourites.java @@ -94,8 +94,6 @@ import com.google.common.base.Predicate; import com.google.common.collect.Collections2; import com.google.common.collect.Lists; -import junit.framework.Assert; - /** * * @author steveglover @@ -145,9 +143,6 @@ public class TestFavourites extends AbstractBaseApiTest final Iterator networksIt = getTestFixture().networksIterator(); - // Workaround for domain name mismatch in lucene indexing that occurs when this test runs. - repoService.disableInTxnIndexing(); - transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() { @SuppressWarnings("synthetic-access") diff --git a/src/test/java/org/alfresco/rest/framework/tests/api/mocks/GrassEntityResource.java b/src/test/java/org/alfresco/rest/framework/tests/api/mocks/GrassEntityResource.java index cc2c7d0a4b..7659970f0c 100644 --- a/src/test/java/org/alfresco/rest/framework/tests/api/mocks/GrassEntityResource.java +++ b/src/test/java/org/alfresco/rest/framework/tests/api/mocks/GrassEntityResource.java @@ -64,11 +64,12 @@ public class GrassEntityResource implements EntityResourceAction.ReadById @Override @WebApiDescription(title = "Create some grass") + @WebApiParam(name = "entity", title = "The grass.", kind = ResourceParameter.KIND.HTTP_BODY_OBJECT, required=false, allowMultiple = false) public List create(List entity, Parameters parameters) { return entity; } - + @Override public void delete(String id, Parameters parameters) { diff --git a/src/test/java/org/alfresco/rest/framework/tests/core/JsonJacksonTests.java b/src/test/java/org/alfresco/rest/framework/tests/core/JsonJacksonTests.java index 9cc5529f7c..10bb2d9a2e 100644 --- a/src/test/java/org/alfresco/rest/framework/tests/core/JsonJacksonTests.java +++ b/src/test/java/org/alfresco/rest/framework/tests/core/JsonJacksonTests.java @@ -65,6 +65,7 @@ public class JsonJacksonTests static JacksonHelper jsonHelper = null; public static final String FARMER_JSON = "{\"name\":\"Giles\",\"created\":\"2012-03-23T15:56:18.552+0000\",\"age\":54,\"id\":\"1234A3\",\"farm\":\"LARGE\"}"; + public static final String GRASS_JSON = "{\"id\":\"grass\",\"color\":\"green\"}"; public static final String COLLECTION_START = "[ "; public static final String COLLECTION_END = " ]"; public static final String FARMERS_COLLECTION_JSON = COLLECTION_START + FARMER_JSON + "," + FARMER_JSON + "," + FARMER_JSON + COLLECTION_END; diff --git a/src/test/java/org/alfresco/rest/framework/tests/core/ParamsExtractorTests.java b/src/test/java/org/alfresco/rest/framework/tests/core/ParamsExtractorTests.java index f3301f0395..6019fa8b42 100644 --- a/src/test/java/org/alfresco/rest/framework/tests/core/ParamsExtractorTests.java +++ b/src/test/java/org/alfresco/rest/framework/tests/core/ParamsExtractorTests.java @@ -25,7 +25,6 @@ */ 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; @@ -40,6 +39,7 @@ import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.io.StringReader; +import java.lang.reflect.Method; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -48,16 +48,20 @@ import org.alfresco.repo.content.MimetypeMap; import org.alfresco.rest.api.tests.util.MultiPartBuilder; import org.alfresco.rest.api.tests.util.MultiPartBuilder.FileData; import org.alfresco.rest.api.tests.util.MultiPartBuilder.MultiPartRequest; +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.ResourceParameter; import org.alfresco.rest.framework.core.exceptions.UnsupportedResourceOperationException; import org.alfresco.rest.framework.jacksonextensions.BeanPropertiesFilter; import org.alfresco.rest.framework.jacksonextensions.JacksonHelper; import org.alfresco.rest.framework.jacksonextensions.RestJsonModule; +import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction; import org.alfresco.rest.framework.resource.parameters.Paging; import org.alfresco.rest.framework.resource.parameters.Params; import org.alfresco.rest.framework.tests.api.mocks.Farmer; +import org.alfresco.rest.framework.tests.api.mocks.GrassEntityResource; import org.alfresco.rest.framework.tools.ApiAssistant; import org.alfresco.rest.framework.webscripts.ParamsExtractor; import org.alfresco.rest.framework.webscripts.ResourceWebScriptDelete; @@ -234,6 +238,27 @@ public class ParamsExtractorTests assertNotNull(uoe); //Must throw this exception } testExtractOperationParams(templateVars, request, extractor); + + templateVars.clear(); + Method aMethod = ResourceInspector.findMethod(EntityResourceAction.Create.class, GrassEntityResource.class); + ResourceOperation op = ResourceInspector.inspectOperation(GrassEntityResource.class, aMethod, HttpMethod.POST); + List metainfo = ResourceInspector.inspect(GrassEntityResource.class); + assertNotNull(op); + assertTrue("Create method should have two params", op.getParameters().size() == 2); + ResourceParameter singleParam = op.getParameters().get(0); + assertTrue(ResourceParameter.KIND.HTTP_BODY_OBJECT.equals(singleParam.getParamType())); + assertFalse("Create grass does not support multiple grass creations", singleParam.isAllowMultiple()); + assertFalse(singleParam.isRequired()); + + // Test context when the request body is null and 'required' webApiParam is false + when(request.getHeader("content-length")).thenReturn("0"); + params = extractor.extractParams(metainfo.get(0), request); + assertNotNull(params); + + // Test context when the request body is provided and 'required' property is false + when(content.getReader()).thenReturn(new StringReader(JsonJacksonTests.GRASS_JSON)); + params = extractor.extractParams(metainfo.get(0), request); + assertNotNull(params); } private Params testExtractOperationParams(Map templateVars, WebScriptRequest request, ParamsExtractor extractor)