diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/transfer/Transfer.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/transfer/Transfer.java index 098f04a6a9..7df99b898c 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/transfer/Transfer.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/transfer/Transfer.java @@ -29,12 +29,11 @@ package org.alfresco.rest.rm.community.model.transfer; import java.util.List; -import org.alfresco.rest.model.RestByUserModel; -import org.alfresco.rest.rm.community.model.common.Path; -import org.alfresco.utility.model.TestModel; - import com.fasterxml.jackson.annotation.JsonProperty; +import org.alfresco.rest.model.RestByUserModel; +import org.alfresco.utility.model.TestModel; + import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/transfercontainer/TransferContainer.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/transfercontainer/TransferContainer.java index 6ae938db2b..5c56bd3eea 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/transfercontainer/TransferContainer.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/transfercontainer/TransferContainer.java @@ -29,12 +29,11 @@ package org.alfresco.rest.rm.community.model.transfercontainer; import java.util.List; -import org.alfresco.rest.model.RestByUserModel; -import org.alfresco.rest.rm.community.model.common.Path; -import org.alfresco.utility.model.TestModel; - import com.fasterxml.jackson.annotation.JsonProperty; +import org.alfresco.rest.model.RestByUserModel; +import org.alfresco.utility.model.TestModel; + import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/unfiledcontainer/UnfiledContainerChildProperties.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/unfiledcontainer/UnfiledContainerChildProperties.java index 0eaff5eaa1..0708472d86 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/unfiledcontainer/UnfiledContainerChildProperties.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/unfiledcontainer/UnfiledContainerChildProperties.java @@ -58,13 +58,11 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_X_RESOLUTION; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_Y_RESOLUTION; -import org.alfresco.rest.rm.community.model.common.Owner; -import org.alfresco.rest.rm.community.model.common.ReviewPeriod; -import org.alfresco.rest.rm.community.util.ReviewPeriodSerializer; -import org.alfresco.utility.model.TestModel; - import com.fasterxml.jackson.annotation.JsonProperty; +import org.alfresco.rest.rm.community.model.common.Owner; +import org.alfresco.utility.model.TestModel; + import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -159,7 +157,7 @@ public class UnfiledContainerChildProperties extends TestModel @JsonProperty (PROPERTIES_Y_RESOLUTION) private Double yResolution; - + @JsonProperty (PROPERTIES_ORIGINAL_NAME) private String originalName; diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/unfiledcontainer/UnfiledContainerProperties.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/unfiledcontainer/UnfiledContainerProperties.java index aa3aaa7180..ed16dde7de 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/unfiledcontainer/UnfiledContainerProperties.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/unfiledcontainer/UnfiledContainerProperties.java @@ -28,15 +28,12 @@ package org.alfresco.rest.rm.community.model.unfiledcontainer; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_IDENTIFIER; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_ID_IS_TEMPORARILY_EDITABLE; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_OWNER; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_ROOT_NODE_REF; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE; - -import org.alfresco.rest.rm.community.model.common.Owner; -import org.alfresco.utility.model.TestModel; import com.fasterxml.jackson.annotation.JsonProperty; +import org.alfresco.utility.model.TestModel; + import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/gscore/api/UnfiledContainerAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/gscore/api/UnfiledContainerAPI.java index 916b2488fa..9abf0e2664 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/gscore/api/UnfiledContainerAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/gscore/api/UnfiledContainerAPI.java @@ -41,19 +41,18 @@ import static org.testng.Assert.fail; import java.io.File; import java.util.Iterator; -import org.alfresco.rest.core.RMRestWrapper; -import org.alfresco.rest.rm.community.model.record.Record; -import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainer; -import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild; -import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildCollection; -import org.alfresco.rest.rm.community.requests.RMModelRequest; -import org.alfresco.rest.rm.community.util.FilePlanComponentMixIn; - import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.jayway.restassured.builder.RequestSpecBuilder; import com.jayway.restassured.http.ContentType; +import org.alfresco.rest.core.RMRestWrapper; +import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainer; +import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild; +import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildCollection; +import org.alfresco.rest.rm.community.requests.RMModelRequest; +import org.alfresco.rest.rm.community.util.UnfiledContainerChildMixin; + /** * Unfiled Container REST API Wrapper * @@ -209,7 +208,7 @@ public class UnfiledContainerAPI extends RMModelRequest * to the request. */ RequestSpecBuilder builder = getRmRestWrapper().configureRequestSpec(); - JsonNode root = new ObjectMapper().readTree(toJson(unfiledContainerChildModel, Record.class, FilePlanComponentMixIn.class)); + JsonNode root = new ObjectMapper().readTree(toJson(unfiledContainerChildModel, UnfiledContainerChild.class, UnfiledContainerChildMixin.class)); // add request fields Iterator fieldNames = root.fieldNames(); while (fieldNames.hasNext()) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/gscore/api/UnfiledRecordFolderAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/gscore/api/UnfiledRecordFolderAPI.java index b13a564329..6a2048c00d 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/gscore/api/UnfiledRecordFolderAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/gscore/api/UnfiledRecordFolderAPI.java @@ -42,19 +42,18 @@ import static org.testng.Assert.fail; import java.io.File; import java.util.Iterator; -import org.alfresco.rest.core.RMRestWrapper; -import org.alfresco.rest.rm.community.model.record.Record; -import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild; -import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildCollection; -import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledRecordFolder; -import org.alfresco.rest.rm.community.requests.RMModelRequest; -import org.alfresco.rest.rm.community.util.FilePlanComponentMixIn; - import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.jayway.restassured.builder.RequestSpecBuilder; import com.jayway.restassured.http.ContentType; +import org.alfresco.rest.core.RMRestWrapper; +import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild; +import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildCollection; +import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledRecordFolder; +import org.alfresco.rest.rm.community.requests.RMModelRequest; +import org.alfresco.rest.rm.community.util.UnfiledContainerChildMixin; + /** * Unfiled Record Folders REST API Wrapper * @@ -209,7 +208,7 @@ public class UnfiledRecordFolderAPI extends RMModelRequest * to the request. */ RequestSpecBuilder builder = getRmRestWrapper().configureRequestSpec(); - JsonNode root = new ObjectMapper().readTree(toJson(unfiledRecordFolderChildModel, Record.class, FilePlanComponentMixIn.class)); + JsonNode root = new ObjectMapper().readTree(toJson(unfiledRecordFolderChildModel, UnfiledContainerChild.class, UnfiledContainerChildMixin.class)); // add request fields Iterator fieldNames = root.fieldNames(); while (fieldNames.hasNext()) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/UnfiledContainerChildMixin.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/UnfiledContainerChildMixin.java new file mode 100644 index 0000000000..bcf238d6d9 --- /dev/null +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/UnfiledContainerChildMixin.java @@ -0,0 +1,49 @@ +/* + * #%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.util; + +import com.fasterxml.jackson.annotation.JsonUnwrapped; + +import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildProperties; + +/** + * Mix class for Record POJO class + * Mix-in annotations are: a way to associate annotations with classes + * without modifying (target) classes themselves. + * + * @author Tuna Aksoy + * @since 2.6 + */ +public abstract class UnfiledContainerChildMixin +{ + /** + * Annotation used to indicate that a property should be serialized "unwrapped" + * Its properties are instead included as properties of its containing Object + */ + @JsonUnwrapped + abstract UnfiledContainerChildProperties getProperties(); +} diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java index 6d33a69c12..10d971d9f0 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java @@ -54,7 +54,6 @@ import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Component; /** @@ -77,8 +76,6 @@ public class RMRolesAndActionsAPI extends BaseAPI @Autowired private AlfrescoHttpClientFactory alfrescoHttpClientFactory; - private ApplicationContext applicationContext; - /** user service */ @Autowired private UserService userService; 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 21c14ea732..38d4b2959d 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 @@ -28,6 +28,7 @@ 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; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS; @@ -35,10 +36,11 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_CATEGORY_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_TYPE; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_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.utils.FilePlanComponentsUtil.createRecordCategoryChildModel; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryModel; +import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createTempFile; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createUnfiledContainerChildModel; import static org.alfresco.rest.rm.community.utils.RMSiteUtil.createStandardRMSiteModel; import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; @@ -52,6 +54,7 @@ import java.util.List; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestAPIFactory; 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; import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory; import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild; @@ -334,8 +337,17 @@ public class BaseRMRestTest extends RestTest */ public UnfiledContainerChild createUnfiledContainerChild(UserModel user, String parentId, String childName, String nodeType) throws Exception { + UnfiledContainerChild child = null; UnfiledContainerChild childModel = createUnfiledContainerChildModel(childName, nodeType); - UnfiledContainerChild child = getRestAPIFactory().getUnfiledContainersAPI(user).createUnfiledContainerChild(childModel, parentId); + + if (FilePlanComponentType.CONTENT_TYPE.equals(nodeType)) + { + child = getRestAPIFactory().getUnfiledContainersAPI(user).uploadRecord(childModel, parentId, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME)); + } + else + { + child = getRestAPIFactory().getUnfiledContainersAPI(user).createUnfiledContainerChild(childModel, parentId); + } assertStatusCode(CREATED); return child; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/UploadInfo.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/UploadInfo.java index bca3e81c29..376d9cc238 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/UploadInfo.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/UploadInfo.java @@ -26,6 +26,7 @@ */ package org.alfresco.rm.rest.api.model; +import java.util.HashMap; import java.util.Map; import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException; @@ -50,6 +51,8 @@ public class UploadInfo public UploadInfo(FormData formData) { + properties = new HashMap<>(); + for (FormData.FormField field : formData.getFields()) { switch (field.getName().toLowerCase())