diff --git a/rm-automation/rm-automation-community-rest-api/pom.xml b/rm-automation/rm-automation-community-rest-api/pom.xml index 0fc4781ef4..a3a94a7b55 100644 --- a/rm-automation/rm-automation-community-rest-api/pom.xml +++ b/rm-automation/rm-automation-community-rest-api/pom.xml @@ -15,7 +15,7 @@ 1.8 alfresco-rm-community-share alfresco-rm-community-repo - 5.2.0-9 + 5.2.0-10 2.0.0 diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/common/Owner.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/common/Owner.java index db8973d980..76a80f6ed6 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/common/Owner.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/common/Owner.java @@ -26,11 +26,12 @@ */ package org.alfresco.rest.rm.community.model.common; -import org.alfresco.utility.model.TestModel; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.Builder; import lombok.Data; import lombok.EqualsAndHashCode; +import org.alfresco.utility.model.TestModel; /** * POJO for owner parameter @@ -43,6 +44,7 @@ import lombok.EqualsAndHashCode; @EqualsAndHashCode(callSuper = true) //@NoArgsConstructor //@AllArgsConstructor +@JsonIgnoreProperties (ignoreUnknown = true) public class Owner extends TestModel { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/Record.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/Record.java index 0d221fa967..83d12daea8 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/Record.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/Record.java @@ -30,7 +30,10 @@ import java.util.List; import com.fasterxml.jackson.annotation.JsonProperty; +import org.alfresco.rest.core.IRestModel; +import org.alfresco.rest.core.assertion.ModelAssertion; import org.alfresco.rest.model.RestByUserModel; +import org.alfresco.rest.model.RestNodeModel; import org.alfresco.rest.rm.community.model.common.Path; import org.alfresco.utility.model.TestModel; @@ -51,7 +54,7 @@ import lombok.NoArgsConstructor; @EqualsAndHashCode(callSuper = true) @NoArgsConstructor @AllArgsConstructor -public class Record extends TestModel +public class Record extends TestModel implements IRestModel { public final static String CONTENT_NODE_TYPE = "cm:content"; @@ -102,4 +105,25 @@ public class Record extends TestModel @JsonProperty private Path path; + + @Override + public ModelAssertion assertThat() + { + return new ModelAssertion(this); + } + + @Override + public ModelAssertion and() + { + return assertThat(); + } + + @JsonProperty (value = "entry") + RestNodeModel model; + + @Override + public RestNodeModel onModel() + { + return model; + } } diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordsAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordsAPI.java index 4c68f65eef..ca51c60200 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordsAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordsAPI.java @@ -114,6 +114,35 @@ public class RecordsAPI extends BaseAPI } + /** + * Reject the record given as parameter + * + * @param user the user declaring the document as record + * @param password the user's password + * @param recordName the record name + * @param reason reject reason + * @return true if the action completed successfully + */ + public boolean rejectRecord(String user, String password, String recordName, String reason) + { + String recNodeRef = getNodeRefSpacesStore() + contentService.getNodeRef(user, password, RM_SITE_ID, recordName); + + try + { + JSONObject requestParams = new JSONObject(); + requestParams.put("name", "reject"); + requestParams.put("nodeRef", recNodeRef); + requestParams.put("params",new JSONObject() + .put("reason",reason)); + + return doPostJsonRequest(user, password, requestParams, RM_ACTIONS_API); + } + catch (JSONException error) + { + LOGGER.error("Unable to extract response parameter", error); + } + return false; + } /** * Declare document version as record * @@ -316,4 +345,30 @@ public class RecordsAPI extends BaseAPI return new Pair<>(false, String.valueOf(response.getJSONObject("status").getInt("code"))); } + /** + * Hide in place record + * + * @param user the user + * @param password the user's password + * @param nodeId the in place record node id + * @return true if the action was successful + */ + public boolean hideRecord(String user, String password, String nodeId) + { + String docNodeRef = getNodeRefSpacesStore() + nodeId; + + try + { + JSONObject requestParams = new JSONObject(); + requestParams.put("actionedUponNode", docNodeRef); + requestParams.put("actionDefinitionName", "hide-record"); + + return doPostJsonRequest(user, password, requestParams, ACTIONS_API); + } catch (JSONException error) + { + LOGGER.error("Unable to extract response parameter", error); + } + return false; + } + } diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java index 124df6907a..43178fdb4d 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java @@ -27,7 +27,6 @@ package org.alfresco.rest.rm.community.base; import static lombok.AccessLevel.PROTECTED; - import static org.alfresco.rest.rm.community.base.TestData.ELECTRONIC_RECORD_NAME; import static org.alfresco.rest.rm.community.base.TestData.RECORD_CATEGORY_TITLE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS; @@ -39,8 +38,6 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_CONTAINER_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE; -import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING; -import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_USER; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryChildModel; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryModel; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createTempFile; @@ -54,10 +51,12 @@ import static org.testng.Assert.assertTrue; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; import org.alfresco.dataprep.ContentService; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestAPIFactory; +import org.alfresco.rest.model.RestNodeModel; import org.alfresco.rest.rm.community.model.fileplan.FilePlan; import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType; import org.alfresco.rest.rm.community.model.record.Record; @@ -77,6 +76,7 @@ import org.alfresco.rest.search.SearchNodeModel; import org.alfresco.rest.search.SearchRequest; import org.alfresco.rest.v0.RMRolesAndActionsAPI; import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.ContentModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; @@ -615,4 +615,39 @@ public class BaseRMRestTest extends RestTest } return names; } + + /** + * Helper method to return site document library content model + * + * @return ContentModel + * @throws Exception + */ + public ContentModel getDocumentLibrary(UserModel usermodel, SiteModel testSite) throws Exception + { + ContentModel siteModel = new ContentModel(); + siteModel.setNodeRef(testSite.getGuid()); + + restClient.authenticateUser(usermodel); + + List nodes = restClient.withCoreAPI().usingNode(siteModel) + .listChildren().getEntries().stream().collect(Collectors.toList()); + ContentModel documentLibrary = new ContentModel(); + documentLibrary.setName(nodes.get(0).onModel().getName()); + documentLibrary.setNodeRef(nodes.get(0).onModel().getId()); + return documentLibrary; + } + + /** + * Helper method to create a Content Model + * + * @return ContentModel + * @throws Exception + */ + public ContentModel toContentModel(String nodeId) + { + ContentModel node = new ContentModel(); + node.setNodeRef(nodeId); + return node; + } + } diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/utils/CoreUtil.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/utils/CoreUtil.java new file mode 100644 index 0000000000..a67c6aa26d --- /dev/null +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/utils/CoreUtil.java @@ -0,0 +1,56 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * 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 + * 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.rm.community.utils; + +import org.alfresco.rest.model.RestNodeBodyMoveCopyModel; + +/** + * Utility class for core components models + * + * @author Rodica Sutu + * @since 2.6 + */ +public class CoreUtil +{ + private CoreUtil() + { + // Intentionally blank + } + + /** + * Creates a body model for move/copy with the given the target node id + * + * @param nodeId The node id + * @return The {@link RestNodeBodyMoveCopyModel} with for the given node id + */ + public static RestNodeBodyMoveCopyModel createBodyForMoveCopy(String nodeId) + { + RestNodeBodyMoveCopyModel moveDestinationInfo = new RestNodeBodyMoveCopyModel(); + moveDestinationInfo.setTargetParentId(nodeId); + return moveDestinationInfo; + } +}