From 5b2f1b1c0402066d9d72be0b171542cc12896b4e Mon Sep 17 00:00:00 2001 From: rwetherall Date: Mon, 8 May 2017 12:50:46 +1000 Subject: [PATCH 01/18] Add info to README's on how to install lombok plugin for IDEs --- rm-automation/rm-automation-community-rest-api/README | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rm-automation/rm-automation-community-rest-api/README b/rm-automation/rm-automation-community-rest-api/README index 907f41ab0a..b5f976aa8b 100644 --- a/rm-automation/rm-automation-community-rest-api/README +++ b/rm-automation/rm-automation-community-rest-api/README @@ -1,3 +1,8 @@ FIXME: Add more info to the README file -In order to change the value of a property in "config.properties" create a file called "local.properties" under src/test/resources and redefine the property with the new value. \ No newline at end of file +In order to change the value of a property in "config.properties" create a file called "local.properties" under src/test/resources and redefine the property with the new value. + +Install lombok plugin for IDEs: +------------------------------- + +Follow the instructions here http://jnb.ociweb.com/jnb/jnbJan2010.html to install lombok plugin for IDEs. \ No newline at end of file From 9627b8ff7046912e99d40d1f1e5b9b4149c70bb3 Mon Sep 17 00:00:00 2001 From: Sara Aspery Date: Tue, 9 May 2017 14:34:08 +0100 Subject: [PATCH 02/18] RM-5115 Get category children REST API disposition schedule fix --- .../recordcategories/RecordCategoryTests.java | 34 +++++++++++++++++-- .../rm/rest/api/impl/SearchTypesFactory.java | 13 +++++++ .../RecordCategoryChildrenRelation.java | 3 +- 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/RecordCategoryTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/RecordCategoryTests.java index 9d1dfa9a90..5e3122cc2c 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/RecordCategoryTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/RecordCategoryTests.java @@ -52,6 +52,7 @@ import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.NoSuchElementException; @@ -66,7 +67,10 @@ import org.alfresco.rest.rm.community.model.recordfolder.RecordFolder; import org.alfresco.rest.rm.community.requests.gscore.api.FilePlanAPI; import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI; import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI; +import org.alfresco.rest.v0.RecordCategoriesAPI; +import org.alfresco.rest.core.v0.BaseAPI.RETENTION_SCHEDULE; import org.alfresco.utility.report.Bug; +import org.springframework.beans.factory.annotation.Autowired; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -83,6 +87,9 @@ public class RecordCategoryTests extends BaseRMRestTest private static final int NUMBER_OF_CHILDREN = 10; private static final int NUMBER_OF_FOLDERS = 5; + @Autowired + private RecordCategoriesAPI recordCategoriesAPI; + /** * Invalid containers that cannot be deleted with record category end-point */ @@ -287,6 +294,7 @@ public class RecordCategoryTests extends BaseRMRestTest assertEquals(folderProperties.getTitle(), TITLE_PREFIX + RECORD_FOLDER_NAME); assertNotNull(folderProperties.getIdentifier()); } + /** *
      * Given that a record category exists
@@ -294,17 +302,37 @@ public class RecordCategoryTests extends BaseRMRestTest
      * When I ask the API to get me the children of the record category
      * Then I am returned the contained record categories and record folders and their details
      * 
+ *
+     * Given that a record category with a disposition schedule exists
+     * And contains a number of record categories and record folders
+     * When I ask the API to get me the children of the record category
+     * Then I am returned the contained record categories and record folders but not the disposition schedule
+     * 
*/ @Test - ( - description = "Get children of a record category" - ) + ( + description = "Get children of a record category excluding the disposition schedule" + ) + @Bug (id="RM-5115") public void getRecordCategoryChildren() throws Exception { // Create root level category RecordCategory rootRecordCategory = createRootCategory(getRandomAlphanumeric()); assertNotNull(rootRecordCategory.getId()); + // Create disposition schedule + String userName = getAdminUser().getUsername(); + String userPassword = getAdminUser().getPassword(); + String categoryName = rootRecordCategory.getName(); + recordCategoriesAPI.createRetentionSchedule(userName, userPassword, categoryName); + + // Add disposition schedule cut off step + HashMap cutOffStep = new HashMap<>(); + cutOffStep.put(RETENTION_SCHEDULE.NAME, "cutoff"); + cutOffStep.put(RETENTION_SCHEDULE.RETENTION_PERIOD, "day|2"); + cutOffStep.put(RETENTION_SCHEDULE.DESCRIPTION, "Cut off after 2 days"); + recordCategoriesAPI.addDispositionScheduleSteps(userName, userPassword, categoryName, cutOffStep); + // Add record category children List children = new ArrayList(); for (int i=0; i < NUMBER_OF_CHILDREN; i++) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/SearchTypesFactory.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/SearchTypesFactory.java index 2e103a9874..f45b4a85b9 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/SearchTypesFactory.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/SearchTypesFactory.java @@ -29,6 +29,7 @@ package org.alfresco.rm.rest.api.impl; import java.security.InvalidParameterException; import java.util.Collection; +import java.util.Collections; import java.util.HashSet; import java.util.Set; @@ -198,6 +199,7 @@ public class SearchTypesFactory Boolean isRecordFolder = propertyWalker.getProperty(RecordCategoryChild.PARAM_IS_RECORD_FOLDER, WhereClauseParser.EQUALS, Boolean.class); Boolean isRecordCategory = propertyWalker.getProperty(RecordCategoryChild.PARAM_IS_RECORD_CATEGORY, WhereClauseParser.EQUALS, Boolean.class); + if ((isRecordFolder != null && isRecordFolder.booleanValue()) || (isRecordCategory != null && !isRecordCategory.booleanValue())) { includeRecordFolders = true; @@ -221,6 +223,7 @@ public class SearchTypesFactory if (nodeTypeQNameStr.equals(RecordsManagementModel.TYPE_RECORD_FOLDER)) { includeRecordFolders = true; + } else if (filterNodeTypeQName.equals(RecordsManagementModel.TYPE_RECORD_CATEGORY)) { @@ -249,6 +252,16 @@ public class SearchTypesFactory return searchTypeQNames; } + /** + * Helper method to build association types for categories endpoint + * @return + */ + public Set buildAssocTypesCategoriesEndpoint() + { + Set assocTypeQNames = Collections.singleton(ContentModel.ASSOC_CONTAINS); + return assocTypeQNames; + } + /** * Helper method to build search types for transfer containers endpoint * @return diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java index 7863035e60..992605e605 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java @@ -114,10 +114,11 @@ public class RecordCategoryChildrenRelation implements RelationshipResourceActio // list record categories and record folders Set searchTypeQNames = searchTypesFactory.buildSearchTypesCategoriesEndpoint(parameters, LIST_RECORD_CATEGORY_CHILDREN_EQUALS_QUERY_PROPERTIES); + Set assocTypeQNames = searchTypesFactory.buildAssocTypesCategoriesEndpoint(); List filterProps = apiUtils.getListChildrenFilterProps(parameters, LIST_RECORD_CATEGORY_CHILDREN_EQUALS_QUERY_PROPERTIES); final PagingResults pagingResults = fileFolderService.list(parentNodeRef, - null, + assocTypeQNames, searchTypeQNames, null, apiUtils.getSortProperties(parameters), From e7d5d09829acacee2023f9cc0cb6a65e5efdb213 Mon Sep 17 00:00:00 2001 From: Sara Aspery Date: Wed, 10 May 2017 07:50:33 +0100 Subject: [PATCH 03/18] RM-5115 Changes following review --- .../rm/rest/api/impl/SearchTypesFactory.java | 11 ----------- .../RecordCategoryChildrenRelation.java | 13 ++++--------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/SearchTypesFactory.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/SearchTypesFactory.java index f45b4a85b9..cbaee33f3b 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/SearchTypesFactory.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/SearchTypesFactory.java @@ -29,7 +29,6 @@ package org.alfresco.rm.rest.api.impl; import java.security.InvalidParameterException; import java.util.Collection; -import java.util.Collections; import java.util.HashSet; import java.util.Set; @@ -252,16 +251,6 @@ public class SearchTypesFactory return searchTypeQNames; } - /** - * Helper method to build association types for categories endpoint - * @return - */ - public Set buildAssocTypesCategoriesEndpoint() - { - Set assocTypeQNames = Collections.singleton(ContentModel.ASSOC_CONTAINS); - return assocTypeQNames; - } - /** * Helper method to build search types for transfer containers endpoint * @return diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java index 992605e605..084fc1f0ff 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java @@ -30,15 +30,10 @@ package org.alfresco.rm.rest.api.recordcategories; import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank; import static org.alfresco.util.ParameterCheck.mandatory; -import java.util.AbstractList; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; +import java.util.Collections; +import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.query.PagingResults; import org.alfresco.repo.node.getchildren.FilterProp; @@ -114,7 +109,7 @@ public class RecordCategoryChildrenRelation implements RelationshipResourceActio // list record categories and record folders Set searchTypeQNames = searchTypesFactory.buildSearchTypesCategoriesEndpoint(parameters, LIST_RECORD_CATEGORY_CHILDREN_EQUALS_QUERY_PROPERTIES); - Set assocTypeQNames = searchTypesFactory.buildAssocTypesCategoriesEndpoint(); + Set assocTypeQNames = Collections.singleton(ContentModel.ASSOC_CONTAINS); List filterProps = apiUtils.getListChildrenFilterProps(parameters, LIST_RECORD_CATEGORY_CHILDREN_EQUALS_QUERY_PROPERTIES); final PagingResults pagingResults = fileFolderService.list(parentNodeRef, From fb72bee736a598926f3e17b07bad1538931fd8f7 Mon Sep 17 00:00:00 2001 From: Sara Aspery Date: Wed, 10 May 2017 09:27:10 +0100 Subject: [PATCH 04/18] RM-5115 Fixed IDE import settings following review --- .../recordcategories/RecordCategoryChildrenRelation.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java index 084fc1f0ff..a9d53888a7 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java @@ -30,8 +30,15 @@ package org.alfresco.rm.rest.api.recordcategories; import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank; import static org.alfresco.util.ParameterCheck.mandatory; -import java.util.*; +import java.util.AbstractList; +import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; From 0e39334a1954d855bed4ee6c6ca89a3854621a51 Mon Sep 17 00:00:00 2001 From: Ramona Popa Date: Wed, 10 May 2017 12:05:54 +0100 Subject: [PATCH 05/18] RM-5116 - added support for autoRename parameter --- .../fileplans/FilePlanChildrenRelation.java | 3 +- .../api/impl/FilePlanComponentsApiUtils.java | 91 ++++++++++++++++--- .../alfresco/rm/rest/api/model/RMNode.java | 1 + .../RecordCategoryChildrenRelation.java | 2 +- .../RecordFolderChildrenRelation.java | 4 +- .../UnfiledContainerChildrenRelation.java | 3 +- .../UnfiledRecordFolderChildrenRelation.java | 6 +- 7 files changed, 84 insertions(+), 26 deletions(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanChildrenRelation.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanChildrenRelation.java index 2ed5d321ac..d691641ff8 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanChildrenRelation.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanChildrenRelation.java @@ -184,7 +184,8 @@ public class FilePlanChildrenRelation implements RelationshipResourceAction.Read for (RecordCategory nodeInfo : nodeInfos) { // Create the node - NodeRef newNode = apiUtils.createRMNode(parentNodeRef, nodeInfo.getName(), RECORD_CATEGORY_TYPE, nodeInfo.getProperties(), nodeInfo.getAspectNames()); + nodeInfo.setNodeType(RECORD_CATEGORY_TYPE); + NodeRef newNode = apiUtils.createRMNode(parentNodeRef, nodeInfo, parameters); FileInfo info = fileFolderService.getFileInfo(newNode); result.add(nodesModelFactory.createRecordCategory(info, parameters, mapUserInfo, false)); } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/FilePlanComponentsApiUtils.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/FilePlanComponentsApiUtils.java index 7ba7add131..0b543f10b3 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/FilePlanComponentsApiUtils.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/FilePlanComponentsApiUtils.java @@ -134,6 +134,12 @@ public class FilePlanComponentsApiUtils RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER, RecordsManagementModel.TYPE_HOLD_CONTAINER); + public static final List TYPES_CAN_USE_AUTORENAME = Arrays.asList( + RecordsManagementModel.TYPE_RECORD_CATEGORY, + RecordsManagementModel.TYPE_RECORD_FOLDER, + RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER, + RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER); + /** RM Nodes API */ private Nodes nodes; private FileFolderService fileFolderService; @@ -598,27 +604,43 @@ public class FilePlanComponentsApiUtils * Create an RM node * * @param parentNodeRef the parent of the node - * @param name the name of the new node - * @param type the type of the node - * @param properties properties to set on the new node - * @param aspects aspects to set on the new node + * @param nodeInfo the node infos to create + * @param parameters the object to get the parameters passed into the request * @return the new node */ - public NodeRef createRMNode(NodeRef parentNodeRef, String name, String type, Map properties, List aspects) + public NodeRef createRMNode(NodeRef parentNodeRef, RMNode nodeInfo, Parameters parameters) { mandatory("parentNodeRef", parentNodeRef); - checkNotBlank(RMNode.PARAM_NAME, name); - checkNotBlank(RMNode.PARAM_NODE_TYPE, type); + mandatory("nodeInfo", nodeInfo); + mandatory("parameters", parameters); + + String nodeName = nodeInfo.getName(); + String nodeType = nodeInfo.getNodeType(); + checkNotBlank(RMNode.PARAM_NAME, nodeName); + checkNotBlank(RMNode.PARAM_NODE_TYPE, nodeType); // Create the node NodeRef newNodeRef = null; + boolean autoRename = Boolean.valueOf(parameters.getParameter(RMNode.PARAM_AUTO_RENAME)); + try { - QName typeQName = nodes.createQName(type); - newNodeRef = fileFolderService.create(parentNodeRef, name, typeQName).getNodeRef(); + QName typeQName = nodes.createQName(nodeType); + + // Existing file/folder name handling + if (TYPES_CAN_CREATE.contains(typeQName) && autoRename) + { + NodeRef existingNode = nodeService.getChildByName(parentNodeRef, ContentModel.ASSOC_CONTAINS, nodeName); + if (existingNode != null) + { + // File already exists, find a unique name + nodeName = findUniqueName(parentNodeRef, nodeName); + } + } + newNodeRef = fileFolderService.create(parentNodeRef, nodeName, typeQName).getNodeRef(); // Set the provided properties if any - Map qnameProperties = mapToNodeProperties(properties); + Map qnameProperties = mapToNodeProperties(nodeInfo.getProperties()); if (qnameProperties != null) { nodeService.addProperties(newNodeRef, qnameProperties); @@ -628,18 +650,19 @@ public class FilePlanComponentsApiUtils if (!typeQName.equals(RecordsManagementModel.TYPE_NON_ELECTRONIC_DOCUMENT) && dictionaryService.isSubClass(typeQName, ContentModel.TYPE_CONTENT)) { - writeContent(newNodeRef, name, new ByteArrayInputStream("".getBytes()), false); + writeContent(newNodeRef, nodeName, new ByteArrayInputStream("".getBytes()), false); } // Add the provided aspects if any - if (aspects != null) + List aspectNames = nodeInfo.getAspectNames(); + if (aspectNames != null) { - nodes.addCustomAspects(newNodeRef, aspects, ApiNodesModelFactory.EXCLUDED_ASPECTS); + nodes.addCustomAspects(newNodeRef, aspectNames, ApiNodesModelFactory.EXCLUDED_ASPECTS); } } catch (InvalidTypeException ex) { - throw new InvalidArgumentException("The given type:'" + type + "' is invalid '"); + throw new InvalidArgumentException("The given type:'" + nodeType + "' is invalid '"); } return newNodeRef; @@ -955,7 +978,45 @@ public class FilePlanComponentsApiUtils activityPoster.postFileFolderActivity(activityType, null, TenantUtil.getCurrentDomain(), activityInfo.getSiteId(), activityInfo.getParentNodeRef(), activityInfo.getNodeRef(), activityInfo.getFileName(), Activities.APP_TOOL, Activities.RESTAPI_CLIENT, activityInfo.getFileInfo()); - } } + /** + * Creates a unique file name, if the upload component was configured to + * find a new unique name for clashing filenames. + * + * @param parentNodeRef the parent node + * @param fileName the original fileName + * @return a new file name + */ + private String findUniqueName(NodeRef parentNodeRef, String fileName) + { + int counter = 1; + String tmpFilename; + NodeRef existingFile; + do + { + int dotIndex = fileName.lastIndexOf('.'); + if (dotIndex == 0) + { + // File didn't have a proper 'name' instead it + // had just a suffix and started with a ".", create "1.txt" + tmpFilename = counter + fileName; + } + else if (dotIndex > 0) + { + // Filename contained ".", create "fileName-1.txt" + tmpFilename = fileName.substring(0, dotIndex) + "-" + counter + fileName.substring(dotIndex); + } + else + { + // Filename didn't contain a dot at all, create "fileName-1" + tmpFilename = fileName + "-" + counter; + } + existingFile = nodeService.getChildByName(parentNodeRef, ContentModel.ASSOC_CONTAINS, tmpFilename); + counter++; + + } while (existingFile != null); + + return tmpFilename; + } } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/RMNode.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/RMNode.java index d4d590e3e8..7ddc40ded9 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/RMNode.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/RMNode.java @@ -57,6 +57,7 @@ public abstract class RMNode public static final String PARAM_PROPERTIES = "properties"; public static final String PARAM_PATH = "path"; public static final String PARAM_ALLOWABLE_OPERATIONS = "allowableOperations"; + public static final String PARAM_AUTO_RENAME = "autoRename"; public static final String PARAM_ISPRIMARY = "isPrimary"; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java index 7863035e60..fe5bf6e998 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java @@ -174,7 +174,7 @@ public class RecordCategoryChildrenRelation implements RelationshipResourceActio } // Create the node - NodeRef newNode = apiUtils.createRMNode(nodeParent, nodeInfo.getName(), nodeInfo.getNodeType(), nodeInfo.getProperties(), nodeInfo.getAspectNames()); + NodeRef newNode = apiUtils.createRMNode(nodeParent, nodeInfo, parameters); FileInfo info = fileFolderService.getFileInfo(newNode); result.add(nodesModelFactory.createRecordCategoryChild(info, parameters, mapUserInfo, false)); } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordfolders/RecordFolderChildrenRelation.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordfolders/RecordFolderChildrenRelation.java index 9ba8c695ba..30fb7e7909 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordfolders/RecordFolderChildrenRelation.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordfolders/RecordFolderChildrenRelation.java @@ -31,7 +31,6 @@ import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.c import static org.alfresco.util.ParameterCheck.mandatory; import java.util.AbstractList; -import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -57,7 +56,6 @@ import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils; import org.alfresco.rm.rest.api.impl.SearchTypesFactory; import org.alfresco.rm.rest.api.model.Record; import org.alfresco.rm.rest.api.model.RecordFolder; -import org.alfresco.rm.rest.api.model.UnfiledContainerChild; import org.alfresco.rm.rest.api.model.UploadInfo; import org.alfresco.service.cmr.model.FileFolderService; import org.alfresco.service.cmr.model.FileInfo; @@ -169,7 +167,7 @@ public class RecordFolderChildrenRelation implements RelationshipResourceAction. List createdNodes = new LinkedList<>(); for (Record nodeInfo : nodeInfos) { - NodeRef newNodeRef = apiUtils.createRMNode(parentNodeRef, nodeInfo.getName(), nodeInfo.getNodeType(), nodeInfo.getProperties(), nodeInfo.getAspectNames()); + NodeRef newNodeRef = apiUtils.createRMNode(parentNodeRef, nodeInfo, parameters); createdNodes.add(newNodeRef); } return createdNodes; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/unfiledcontainers/UnfiledContainerChildrenRelation.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/unfiledcontainers/UnfiledContainerChildrenRelation.java index ab419a57ca..36ec2ab187 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/unfiledcontainers/UnfiledContainerChildrenRelation.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/unfiledcontainers/UnfiledContainerChildrenRelation.java @@ -31,7 +31,6 @@ import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.c import static org.alfresco.util.ParameterCheck.mandatory; import java.util.AbstractList; -import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; @@ -187,7 +186,7 @@ public class UnfiledContainerChildrenRelation implements RelationshipResourceAct List createdNodes = new LinkedList<>(); for (UnfiledContainerChild nodeInfo : nodeInfos) { - NodeRef newNodeRef = apiUtils.createRMNode(parentNodeRef, nodeInfo.getName(), nodeInfo.getNodeType(), nodeInfo.getProperties(), nodeInfo.getAspectNames()); + NodeRef newNodeRef = apiUtils.createRMNode(parentNodeRef, nodeInfo, parameters); createdNodes.add(newNodeRef); } return createdNodes; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/unfiledrecordfolders/UnfiledRecordFolderChildrenRelation.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/unfiledrecordfolders/UnfiledRecordFolderChildrenRelation.java index 0a7faf4771..8e4a9a0063 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/unfiledrecordfolders/UnfiledRecordFolderChildrenRelation.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/unfiledrecordfolders/UnfiledRecordFolderChildrenRelation.java @@ -31,7 +31,6 @@ import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.c import static org.alfresco.util.ParameterCheck.mandatory; import java.util.AbstractList; -import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; @@ -60,7 +59,6 @@ import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils; import org.alfresco.rm.rest.api.impl.SearchTypesFactory; import org.alfresco.rm.rest.api.model.RMNode; import org.alfresco.rm.rest.api.model.UnfiledChild; -import org.alfresco.rm.rest.api.model.UnfiledContainerChild; import org.alfresco.rm.rest.api.model.UnfiledRecordFolder; import org.alfresco.rm.rest.api.model.UnfiledRecordFolderChild; import org.alfresco.rm.rest.api.model.UploadInfo; @@ -175,7 +173,7 @@ public class UnfiledRecordFolderChildrenRelation implements RelationshipResource mandatory("parameters", parameters); NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(unfiledRecordFolderId, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER); - + // Create the children RetryingTransactionCallback> callback = new RetryingTransactionCallback>() { @@ -194,7 +192,7 @@ public class UnfiledRecordFolderChildrenRelation implements RelationshipResource nodeParent = parentNodeRef; } - NodeRef newNodeRef = apiUtils.createRMNode(nodeParent, nodeInfo.getName(), nodeInfo.getNodeType(), nodeInfo.getProperties(), nodeInfo.getAspectNames()); + NodeRef newNodeRef = apiUtils.createRMNode(nodeParent, nodeInfo, parameters); createdNodes.add(newNodeRef); } return createdNodes; From 71a144aeab49b28b1d3b020fa096672dae0ff010 Mon Sep 17 00:00:00 2001 From: rwetherall Date: Fri, 12 May 2017 11:25:05 +1000 Subject: [PATCH 06/18] Move information into parent README --- README.txt | 12 +++++++++--- .../rm-automation-community-rest-api/README | 7 +------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.txt b/README.txt index f31803686a..2110ac0c64 100644 --- a/README.txt +++ b/README.txt @@ -95,9 +95,6 @@ Follow these instructions install licence and Outlook plugin: - http://docs.alfresco.com/outlook2.1/tasks/Outlook-install_v2.html - - - SNAPSHOT dependencies: ---------------------- @@ -114,6 +111,7 @@ Code Formatting: This project follows the usual Alfresco Coding Standards. If you use Eclipse or IntelliJ, there are settings inside the ide-config directory for you to import. + Surf build errors: ------------------ @@ -121,3 +119,11 @@ If you get: [ERROR] Failed to execute goal on project alfresco-rm-community-share: Could not resolve dependencies for project org.alfresco:alfresco-rm-community-share:amp:2.6-SNAPSHOT: Failed to collect dependencies at org.alfresco.surf:spring-surf-api:jar:6.3 -> org.alfresco.surf:spring-surf:jar:${dependency.surf.version}: Failed to read artifact descriptor for org.alfresco.surf:spring-surf:jar:${dependency.surf.version}: Could not transfer artifact org.alfresco.surf:spring-surf:pom:${dependency.surf.version} from/to alfresco-internal (https://artifacts.alfresco.com/nexus/content/groups/private): Not authorized , ReasonPhrase:Unauthorized. -> [Help 1] then please re-run with -Ddependency.surf.version=6.3 + + +Install lombok plugin for IDEs: +------------------------------- + +To allow UI automation and benchmark projects to be built within an IDE the lombok 'plugin' needs to be installed. + +Execute lombok.jar (doubleclick it, or run java -jar lombok.jar). Follow instructions. diff --git a/rm-automation/rm-automation-community-rest-api/README b/rm-automation/rm-automation-community-rest-api/README index b5f976aa8b..907f41ab0a 100644 --- a/rm-automation/rm-automation-community-rest-api/README +++ b/rm-automation/rm-automation-community-rest-api/README @@ -1,8 +1,3 @@ FIXME: Add more info to the README file -In order to change the value of a property in "config.properties" create a file called "local.properties" under src/test/resources and redefine the property with the new value. - -Install lombok plugin for IDEs: -------------------------------- - -Follow the instructions here http://jnb.ociweb.com/jnb/jnbJan2010.html to install lombok plugin for IDEs. \ No newline at end of file +In order to change the value of a property in "config.properties" create a file called "local.properties" under src/test/resources and redefine the property with the new value. \ No newline at end of file From 9abc4be3c6f1c53efe1b2c6c90679a9770e7fea1 Mon Sep 17 00:00:00 2001 From: rwetherall Date: Fri, 12 May 2017 15:36:28 +1000 Subject: [PATCH 07/18] Adjust text to ensure all automation projects are included. --- README.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.txt b/README.txt index 2110ac0c64..b46013c3f5 100644 --- a/README.txt +++ b/README.txt @@ -124,6 +124,6 @@ then please re-run with -Ddependency.surf.version=6.3 Install lombok plugin for IDEs: ------------------------------- -To allow UI automation and benchmark projects to be built within an IDE the lombok 'plugin' needs to be installed. +To allow automation and benchmark projects to be built within an IDE the lombok 'plugin' needs to be installed. Execute lombok.jar (doubleclick it, or run java -jar lombok.jar). Follow instructions. From df90b1e1b574d358dab595f8cb843a21ad9353d5 Mon Sep 17 00:00:00 2001 From: Rodica Sutu Date: Fri, 12 May 2017 12:21:39 +0300 Subject: [PATCH 08/18] add tests to create rm types with autoRename parameter (to cover RM-5116) --- .../rest/rm/community/base/TestData.java | 16 ++++++ .../rm/community/fileplans/FilePlanTests.java | 52 +++++++++++++++++++ .../recordcategories/RecordCategoryTests.java | 39 ++++++++++++++ .../UnfiledContainerTests.java | 41 ++++++++++++++- 4 files changed, 146 insertions(+), 2 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/TestData.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/TestData.java index 3c799ebb61..d5a24f5789 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/TestData.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/TestData.java @@ -159,6 +159,22 @@ public interface TestData }; } + /** + * Data Provider with: + * with the object types for creating a Record Category Child + * + * @return record category child type + */ + @DataProvider + public static Object[][] categoryChild() + { + return new String[][] { + { RECORD_FOLDER_TYPE }, + { FOLDER_TYPE }, + { RECORD_CATEGORY_TYPE } + }; + } + /** * Invalid root level types, at unfiled record folder/unfiled containers container level that shouldn't be possible to create */ diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplans/FilePlanTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplans/FilePlanTests.java index 73b1780b84..2feea62f20 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplans/FilePlanTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplans/FilePlanTests.java @@ -45,12 +45,14 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING; import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_MANAGER; import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; +import static org.springframework.http.HttpStatus.CONFLICT; import static org.springframework.http.HttpStatus.CREATED; import static org.springframework.http.HttpStatus.FORBIDDEN; import static org.springframework.http.HttpStatus.NOT_FOUND; import static org.springframework.http.HttpStatus.OK; import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY; import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; @@ -322,6 +324,56 @@ public class FilePlanTests extends BaseRMRestTest assertNotNull(rootRecordCategoryProperties.getIdentifier()); } + /** + *
+     * Given a root category
+     * When I ask the API to create a root category having the same name
+     * Then  the response code received is 409 - name clashes with an existing node
+     *
+ *
+     * Given a root category
+     * When I ask the API to create a root category having the same name  with autoRename parameter on true
+     * Then the record category is created the record category has a unique name by adding an integer suffix
+     * 
+ */ + @Test + @Bug(id = "RM-5116") + public void createDuplicateCategories() throws Exception + { + String categoryName = "Category name " + getRandomAlphanumeric(); + String categoryTitle = "Category title " + getRandomAlphanumeric(); + + + // Create the root record category + RecordCategory recordCategory = RecordCategory.builder() + .name(categoryName) + .properties(RecordCategoryProperties.builder() + .title(categoryTitle) + .build()) + .build(); + // Create the root record category + RecordCategory rootRecordCategory = getRestAPIFactory().getFilePlansAPI().createRootRecordCategory(recordCategory,FILE_PLAN_ALIAS); + + // Verify the status code + assertStatusCode(CREATED); + assertEquals(rootRecordCategory.getName(), categoryName); + + // Create the same root record category + getRestAPIFactory().getFilePlansAPI().createRootRecordCategory(recordCategory, FILE_PLAN_ALIAS); + + // Verify the status code + assertStatusCode(CONFLICT); + + //create the same category with autoRename parameter on true + RecordCategory rootRecordCategoryAutoRename = getRestAPIFactory().getFilePlansAPI() + .createRootRecordCategory(recordCategory, FILE_PLAN_ALIAS,"autoRename=true"); + + // Verify the status code + assertStatusCode(CREATED); + assertNotEquals(rootRecordCategoryAutoRename.getName(), categoryName); + assertTrue(rootRecordCategoryAutoRename.getName().startsWith(categoryName)); + } + @Test public void listFilePlanChildren() throws Exception { diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/RecordCategoryTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/RecordCategoryTests.java index b769d3d572..03359c0bf7 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/RecordCategoryTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/RecordCategoryTests.java @@ -38,8 +38,10 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.TITLE_PREFIX; +import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryChildModel; import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; import static org.springframework.http.HttpStatus.BAD_REQUEST; +import static org.springframework.http.HttpStatus.CONFLICT; import static org.springframework.http.HttpStatus.CREATED; import static org.springframework.http.HttpStatus.NOT_FOUND; import static org.springframework.http.HttpStatus.NO_CONTENT; @@ -47,6 +49,7 @@ import static org.springframework.http.HttpStatus.OK; import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; @@ -294,6 +297,42 @@ public class RecordCategoryTests extends BaseRMRestTest assertEquals(folderProperties.getTitle(), TITLE_PREFIX + RECORD_FOLDER_NAME); assertNotNull(folderProperties.getIdentifier()); } + @Test + ( + dataProviderClass = TestData.class, + dataProvider = "categoryChild" + ) + @Bug(id = "RM-5116") + public void createdDuplicateChild(String childType)throws Exception + { + // create a root category + String rootRecordCategory = createRootCategory(RECORD_CATEGORY_NAME + getRandomAlphanumeric()).getId(); + + // Create the record category child + RecordCategoryChild recordFolder = createRecordCategoryChild(rootRecordCategory, RECORD_FOLDER_NAME, childType); + + // check the response code + assertStatusCode(CREATED); + assertEquals(recordFolder.getName(), RECORD_FOLDER_NAME); + + // Create a record category child with the same name as the exiting one + + RecordCategoryChild recordFolderDuplicate = getRestAPIFactory().getRecordCategoryAPI().createRecordCategoryChild( + createRecordCategoryChildModel(RECORD_FOLDER_NAME, childType), rootRecordCategory); + + // check the response code + assertStatusCode(CONFLICT); + + // Create a record folder with the same name as the exiting one and with the autoRename parameter on true + recordFolderDuplicate = getRestAPIFactory().getRecordCategoryAPI() + .createRecordCategoryChild(createRecordCategoryChildModel(RECORD_FOLDER_NAME, + childType), + rootRecordCategory, "autoRename=true"); + // check the response code + assertStatusCode(CREATED); + assertNotEquals(recordFolderDuplicate.getName(), RECORD_FOLDER_NAME); + assertTrue(recordFolderDuplicate.getName().contains(RECORD_FOLDER_NAME)); + } /** *
diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/unfiledcontainers/UnfiledContainerTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/unfiledcontainers/UnfiledContainerTests.java
index 719d1dddd1..3deeab829c 100644
--- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/unfiledcontainers/UnfiledContainerTests.java
+++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/unfiledcontainers/UnfiledContainerTests.java
@@ -38,10 +38,13 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
 import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createUnfiledContainerChildModel;
 import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
 import static org.springframework.http.HttpStatus.BAD_REQUEST;
+import static org.springframework.http.HttpStatus.CONFLICT;
+import static org.springframework.http.HttpStatus.CREATED;
 import static org.springframework.http.HttpStatus.OK;
 import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotEquals;
 import static org.testng.Assert.assertNotNull;
 import static org.testng.Assert.assertTrue;
 
@@ -59,6 +62,7 @@ import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChi
 import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledRecordFolder;
 import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
 import org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil;
+import org.alfresco.utility.report.Bug;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.DataProvider;
@@ -163,7 +167,7 @@ public class UnfiledContainerTests extends BaseRMRestTest
     public void createUnfiledRecordFolderChild(String folderType) throws Exception
     {
         String unfiledRecordFolderName = "UnfiledRecordFolder-" + getRandomAlphanumeric();
-        UnfiledContainerChild unfiledRecordFolderChild = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, unfiledRecordFolderName, UNFILED_RECORD_FOLDER_TYPE);
+        UnfiledContainerChild unfiledRecordFolderChild = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, unfiledRecordFolderName, folderType);
 
         assertNotNull(unfiledRecordFolderChild.getId());
 
@@ -184,7 +188,40 @@ public class UnfiledContainerTests extends BaseRMRestTest
         assertEquals(unfiledRecordFolder.getParentId(),
                 getRestAPIFactory().getUnfiledContainersAPI().getUnfiledContainer(UNFILED_RECORDS_CONTAINER_ALIAS).getId());
     }
-    
+
+    @Test
+    (   description = "Create duplicate unfiled folder child",
+        dataProvider = "unfiledFolderTypes"
+    )
+    @Bug(id ="RM-5116, RM-5148")
+    public void createDuplicateUnfiledFolderChild(String folderType) throws Exception
+    {
+        String unfiledRecordFolderName = "UnfiledRecordFolder-" + getRandomAlphanumeric();
+        UnfiledContainerChild unfiledRecordFolderChild = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS,
+                    unfiledRecordFolderName, folderType);
+
+        // Verify the status code
+        assertStatusCode(CREATED);
+        assertEquals(unfiledRecordFolderChild.getName(), unfiledRecordFolderName);
+		
+		// create the same unfiled folder
+        UnfiledContainerChild unfiledRecordFolderDuplicate = getRestAPIFactory().getUnfiledContainersAPI()
+                    .createUnfiledContainerChild(createUnfiledContainerChildModel(unfiledRecordFolderName, folderType),
+                                UNFILED_RECORDS_CONTAINER_ALIAS);
+
+        // Verify the status code
+        assertStatusCode(CONFLICT);
+
+        // create the same unfiled folder with the autoRename parameter on true
+        unfiledRecordFolderDuplicate = getRestAPIFactory().getUnfiledContainersAPI()
+                    .createUnfiledContainerChild(createUnfiledContainerChildModel(unfiledRecordFolderName, folderType),UNFILED_RECORDS_CONTAINER_ALIAS,"autoRename=true");
+
+        //verify the response status code
+		assertStatusCode(CREATED);
+        assertNotEquals(unfiledRecordFolderDuplicate.getName(), unfiledRecordFolderName);
+        assertTrue(unfiledRecordFolderDuplicate.getName().startsWith(unfiledRecordFolderName));
+
+    }
     /**
      * 
      * Given that an unfiled records container exists

From 00bbe3222918d69d69a22d3e7946e05d571416f4 Mon Sep 17 00:00:00 2001
From: Ramona Popa 
Date: Fri, 12 May 2017 17:39:43 +0300
Subject: [PATCH 09/18] RM-4921 - added new transaction to get the updated node
 in order to get the updated properties

---
 .../RecordCategoriesEntityResource.java                | 10 +++++++++-
 .../api/recordfolders/RecordFolderEntityResource.java  | 10 +++++++++-
 .../rm/rest/api/records/RecordsEntityResource.java     | 10 +++++++++-
 .../TransferContainerEntityResource.java               | 10 +++++++++-
 .../UnfiledContainerChildrenRelation.java              |  2 +-
 .../UnfiledContainerEntityResource.java                | 10 +++++++++-
 .../UnfiledRecordFolderEntityResource.java             | 10 +++++++++-
 7 files changed, 55 insertions(+), 7 deletions(-)

diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoriesEntityResource.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoriesEntityResource.java
index 5ab0005162..27f9cfde29 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoriesEntityResource.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoriesEntityResource.java
@@ -130,7 +130,15 @@ public class RecordCategoriesEntityResource implements
         };
         transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
 
-        FileInfo info = fileFolderService.getFileInfo(nodeRef);
+        RetryingTransactionCallback readCallback = new RetryingTransactionCallback()
+        {
+            public FileInfo execute()
+            {
+                return fileFolderService.getFileInfo(nodeRef);
+            }
+        };
+        FileInfo info = transactionService.getRetryingTransactionHelper().doInTransaction(readCallback, false, true);
+        
         return nodesModelFactory.createRecordCategory(info, parameters, null, false);
     }
 
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordfolders/RecordFolderEntityResource.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordfolders/RecordFolderEntityResource.java
index 6b88373e6f..a97ca9df44 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordfolders/RecordFolderEntityResource.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordfolders/RecordFolderEntityResource.java
@@ -125,7 +125,15 @@ public class RecordFolderEntityResource implements EntityResourceAction.ReadById
         };
         transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
 
-        FileInfo info = fileFolderService.getFileInfo(nodeRef);
+        RetryingTransactionCallback readCallback = new RetryingTransactionCallback()
+        {
+            public FileInfo execute()
+            {
+                return fileFolderService.getFileInfo(nodeRef);
+            }
+        };
+        FileInfo info = transactionService.getRetryingTransactionHelper().doInTransaction(readCallback, false, true);
+
         return nodesModelFactory.createRecordFolder(info, parameters, null, false);
     }
 
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/records/RecordsEntityResource.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/records/RecordsEntityResource.java
index 78dc66df5d..4aef34e7d0 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/records/RecordsEntityResource.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/records/RecordsEntityResource.java
@@ -217,7 +217,15 @@ public class RecordsEntityResource implements BinaryResourceAction.Read,
         transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
 
         // return record state
-        FileInfo info = fileFolderService.getFileInfo(record);
+        RetryingTransactionCallback readCallback = new RetryingTransactionCallback()
+        {
+            public FileInfo execute()
+            {
+                return fileFolderService.getFileInfo(record);
+            }
+        };
+        FileInfo info = transactionService.getRetryingTransactionHelper().doInTransaction(readCallback, false, true);
+        
         apiUtils.postActivity(info, recordInfo.getParentId(), ActivityType.FILE_UPDATED);
         return nodesModelFactory.createRecord(info, parameters, null, false);
     }
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/transfercontainers/TransferContainerEntityResource.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/transfercontainers/TransferContainerEntityResource.java
index 129245007b..f2f7df6cfb 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/transfercontainers/TransferContainerEntityResource.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/transfercontainers/TransferContainerEntityResource.java
@@ -128,7 +128,15 @@ public class TransferContainerEntityResource implements
         };
         transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
 
-        FileInfo info = fileFolderService.getFileInfo(nodeRef);
+        RetryingTransactionCallback readCallback = new RetryingTransactionCallback()
+        {
+            public FileInfo execute()
+            {
+                return fileFolderService.getFileInfo(nodeRef);
+            }
+        };
+        FileInfo info = transactionService.getRetryingTransactionHelper().doInTransaction(readCallback, false, true);
+
         return nodesModelFactory.createTransferContainer(info, parameters, null, false);
     }
 }
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/unfiledcontainers/UnfiledContainerChildrenRelation.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/unfiledcontainers/UnfiledContainerChildrenRelation.java
index 34107358ff..0408de262a 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/unfiledcontainers/UnfiledContainerChildrenRelation.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/unfiledcontainers/UnfiledContainerChildrenRelation.java
@@ -192,7 +192,7 @@ public class UnfiledContainerChildrenRelation implements RelationshipResourceAct
                 return createdNodes;
             }
         };
-        List createdNodes = transactionService.getRetryingTransactionHelper().doInTransaction(callback);
+        List createdNodes = transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
 
         // Get the nodes info
         List result = new LinkedList<>();
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/unfiledcontainers/UnfiledContainerEntityResource.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/unfiledcontainers/UnfiledContainerEntityResource.java
index 551b288a2c..3896a882a3 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/unfiledcontainers/UnfiledContainerEntityResource.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/unfiledcontainers/UnfiledContainerEntityResource.java
@@ -126,7 +126,15 @@ public class UnfiledContainerEntityResource
         };
         transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
 
-        FileInfo info = fileFolderService.getFileInfo(nodeRef);
+        RetryingTransactionCallback readCallback = new RetryingTransactionCallback()
+        {
+            public FileInfo execute()
+            {
+                return fileFolderService.getFileInfo(nodeRef);
+            }
+        };
+        FileInfo info = transactionService.getRetryingTransactionHelper().doInTransaction(readCallback, false, true);
+
         apiUtils.postActivity(info, unfiledContainerInfo.getParentId(), ActivityType.FILE_UPDATED);
         return nodesModelFactory.createUnfiledContainer(info, parameters, null, false);
     }
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/unfiledrecordfolders/UnfiledRecordFolderEntityResource.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/unfiledrecordfolders/UnfiledRecordFolderEntityResource.java
index 651c46ba34..c4aa9a8db2 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/unfiledrecordfolders/UnfiledRecordFolderEntityResource.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/unfiledrecordfolders/UnfiledRecordFolderEntityResource.java
@@ -130,7 +130,15 @@ public class UnfiledRecordFolderEntityResource implements EntityResourceAction.R
         };
         transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
 
-        FileInfo info = fileFolderService.getFileInfo(nodeRef);
+        RetryingTransactionCallback readCallback = new RetryingTransactionCallback()
+        {
+            public FileInfo execute()
+            {
+                return fileFolderService.getFileInfo(nodeRef);
+            }
+        };
+        FileInfo info = transactionService.getRetryingTransactionHelper().doInTransaction(readCallback, false, true);
+
         apiUtils.postActivity(info, unfiledRecordFolderInfo.getParentId(), ActivityType.FILE_UPDATED);
         return nodesModelFactory.createUnfiledRecordFolder(info, parameters, null, false);
     }

From d05d0d211b79c423592b17d0bf4272f45efb537d Mon Sep 17 00:00:00 2001
From: Tuna Aksoy 
Date: Sun, 14 May 2017 19:14:45 +0100
Subject: [PATCH 10/18] RM-4564 (Record upload does not work in integration
 projects)

---
 .../rm/community/model/transfer/Transfer.java |  7 ++-
 .../transfercontainer/TransferContainer.java  |  7 ++-
 .../UnfiledContainerChildProperties.java      | 10 ++--
 .../UnfiledContainerProperties.java           |  7 +--
 .../gscore/api/UnfiledContainerAPI.java       | 17 +++----
 .../gscore/api/UnfiledRecordFolderAPI.java    | 17 +++----
 .../util/UnfiledContainerChildMixin.java      | 49 +++++++++++++++++++
 .../rest/v0/RMRolesAndActionsAPI.java         |  3 --
 .../rm/community/base/BaseRMRestTest.java     | 16 +++++-
 .../rm/rest/api/model/UploadInfo.java         |  3 ++
 10 files changed, 94 insertions(+), 42 deletions(-)
 create mode 100644 rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/UnfiledContainerChildMixin.java

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 c82efad674..7203fb5d84 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())

From dc05c563591e368a44a3ed33f7b2f77dcff0706b Mon Sep 17 00:00:00 2001
From: Rodica Sutu 
Date: Mon, 15 May 2017 08:45:03 +0300
Subject: [PATCH 11/18] add the author property

---
 .../model/fileplancomponents/FilePlanComponentFields.java     | 1 +
 .../rest/rm/community/model/record/RecordProperties.java      | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java
index ac79160c48..723dbf6764 100644
--- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java
+++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java
@@ -48,6 +48,7 @@ public class FilePlanComponentFields
     public static final String PROPERTIES_VITAL_RECORD_INDICATOR = "rma:vitalRecordIndicator";
     public static final String PROPERTIES_REVIEW_PERIOD = "rma:reviewPeriod";
     public static final String PROPERTIES_OWNER = "cm:owner";
+    public static final String PROPERTIES_AUTHOR="cm:author";
 
     /** Common properties for record folders and records */
     public static final String PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE = "rma:recordSearchHasDispositionSchedule";
diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/RecordProperties.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/RecordProperties.java
index e2d0fabdb8..8732533cf2 100644
--- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/RecordProperties.java
+++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/RecordProperties.java
@@ -27,6 +27,7 @@
 
 package org.alfresco.rest.rm.community.model.record;
 
+import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_AUTHOR;
 import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_BOX;
 import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_DATE_FILED;
 import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_DATE_TIME_ORIGINAL;
@@ -200,4 +201,7 @@ public class RecordProperties extends TestModel
 
     @JsonProperty (PROPERTIES_OWNER)
     private Owner owner;
+
+    @JsonProperty(PROPERTIES_AUTHOR)
+    private String author;
 }

From d0c7cdddb8d3dd7b097c42c43971f337dd24425c Mon Sep 17 00:00:00 2001
From: Tuna Aksoy 
Date: Mon, 15 May 2017 11:03:26 +0100
Subject: [PATCH 12/18] RM-4528 (Electronic record using file upload creation
 in invalid parent container returns HTTP 500)

---
 .../api/fileplans/FilePlanChildrenRelation.java  | 16 +++++++++++++---
 .../RecordCategoryChildrenRelation.java          | 13 ++++++++++++-
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanChildrenRelation.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanChildrenRelation.java
index 923b70c636..7051160d40 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanChildrenRelation.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanChildrenRelation.java
@@ -39,22 +39,23 @@ import java.util.Map;
 import java.util.Set;
 
 import org.alfresco.query.PagingResults;
-import org.alfresco.repo.activities.ActivityType;
 import org.alfresco.repo.node.getchildren.FilterProp;
+import org.alfresco.repo.node.integrity.IntegrityException;
 import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
 import org.alfresco.rest.api.impl.Util;
 import org.alfresco.rest.api.model.UserInfo;
 import org.alfresco.rest.framework.WebApiDescription;
 import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
 import org.alfresco.rest.framework.resource.RelationshipResource;
+import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartRelationshipResourceAction;
 import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
 import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
 import org.alfresco.rest.framework.resource.parameters.Parameters;
+import org.alfresco.rest.framework.webscripts.WithResponse;
 import org.alfresco.rm.rest.api.impl.ApiNodesModelFactory;
 import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils;
 import org.alfresco.rm.rest.api.impl.SearchTypesFactory;
 import org.alfresco.rm.rest.api.model.FilePlan;
-import org.alfresco.rm.rest.api.model.Record;
 import org.alfresco.rm.rest.api.model.RecordCategory;
 import org.alfresco.service.cmr.model.FileFolderService;
 import org.alfresco.service.cmr.model.FileInfo;
@@ -63,6 +64,7 @@ import org.alfresco.service.namespace.QName;
 import org.alfresco.service.transaction.TransactionService;
 import org.alfresco.util.ParameterCheck;
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.extensions.webscripts.servlet.FormData;
 
 /**
  * File plan children relation
@@ -72,7 +74,9 @@ import org.springframework.beans.factory.InitializingBean;
  */
 @RelationshipResource(name="categories", entityResource = FilePlanEntityResource.class, title = "Category children of file plan")
 public class FilePlanChildrenRelation implements RelationshipResourceAction.Read,
-                                                 RelationshipResourceAction.Create, InitializingBean
+                                                 RelationshipResourceAction.Create,
+                                                 MultiPartRelationshipResourceAction.Create,
+                                                 InitializingBean
 {
     /** Record category type */
     public static final String RECORD_CATEGORY_TYPE = "rma:recordCategory";
@@ -218,4 +222,10 @@ public class FilePlanChildrenRelation implements RelationshipResourceAction.Read
 
         return result;
     }
+
+    @Override
+    public FilePlan create(String entityResourceId, FormData formData, Parameters parameters, WithResponse withResponse)
+    {
+        throw new IntegrityException("Uploading records into file plan root is not allowed.", null);
+    }
 }
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java
index e1bdb8a680..e9fa2147f0 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java
@@ -45,15 +45,18 @@ import org.alfresco.model.ContentModel;
 import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
 import org.alfresco.query.PagingResults;
 import org.alfresco.repo.node.getchildren.FilterProp;
+import org.alfresco.repo.node.integrity.IntegrityException;
 import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
 import org.alfresco.rest.api.Nodes;
 import org.alfresco.rest.api.impl.Util;
 import org.alfresco.rest.api.model.UserInfo;
 import org.alfresco.rest.framework.WebApiDescription;
 import org.alfresco.rest.framework.resource.RelationshipResource;
+import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartRelationshipResourceAction;
 import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
 import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
 import org.alfresco.rest.framework.resource.parameters.Parameters;
+import org.alfresco.rest.framework.webscripts.WithResponse;
 import org.alfresco.rm.rest.api.impl.ApiNodesModelFactory;
 import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils;
 import org.alfresco.rm.rest.api.impl.SearchTypesFactory;
@@ -66,6 +69,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
 import org.alfresco.service.namespace.QName;
 import org.alfresco.service.transaction.TransactionService;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.extensions.webscripts.servlet.FormData;
 
 /**
  * Record category children relation
@@ -76,7 +80,8 @@ import org.apache.commons.lang3.StringUtils;
  */
 @RelationshipResource(name="children", entityResource = RecordCategoriesEntityResource.class, title = "Children of a record category")
 public class RecordCategoryChildrenRelation implements RelationshipResourceAction.Read,
-                                                 RelationshipResourceAction.Create
+                                                 RelationshipResourceAction.Create,
+                                                 MultiPartRelationshipResourceAction.Create
 {
     private final static Set LIST_RECORD_CATEGORY_CHILDREN_EQUALS_QUERY_PROPERTIES = new HashSet<>(Arrays
             .asList(new String[] { RecordCategoryChild.PARAM_IS_RECORD_CATEGORY, RecordCategoryChild.PARAM_IS_RECORD_FOLDER,
@@ -208,4 +213,10 @@ public class RecordCategoryChildrenRelation implements RelationshipResourceActio
 
         return result;
     }
+
+    @Override
+    public RecordCategoryChild create(String entityResourceId, FormData formData, Parameters parameters, WithResponse withResponse)
+    {
+        throw new IntegrityException("Uploading records into record categories is not allowed.", null);
+    }
 }

From f360cb47a530d807f3d310bc950be89649bb97bf Mon Sep 17 00:00:00 2001
From: Tuna Aksoy 
Date: Mon, 15 May 2017 22:05:44 +0100
Subject: [PATCH 13/18] Reverted changes for RM-4528

---
 .../api/fileplans/FilePlanChildrenRelation.java  | 16 +++-------------
 .../RecordCategoryChildrenRelation.java          | 13 +------------
 2 files changed, 4 insertions(+), 25 deletions(-)

diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanChildrenRelation.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanChildrenRelation.java
index 7051160d40..923b70c636 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanChildrenRelation.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanChildrenRelation.java
@@ -39,23 +39,22 @@ import java.util.Map;
 import java.util.Set;
 
 import org.alfresco.query.PagingResults;
+import org.alfresco.repo.activities.ActivityType;
 import org.alfresco.repo.node.getchildren.FilterProp;
-import org.alfresco.repo.node.integrity.IntegrityException;
 import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
 import org.alfresco.rest.api.impl.Util;
 import org.alfresco.rest.api.model.UserInfo;
 import org.alfresco.rest.framework.WebApiDescription;
 import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
 import org.alfresco.rest.framework.resource.RelationshipResource;
-import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartRelationshipResourceAction;
 import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
 import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
 import org.alfresco.rest.framework.resource.parameters.Parameters;
-import org.alfresco.rest.framework.webscripts.WithResponse;
 import org.alfresco.rm.rest.api.impl.ApiNodesModelFactory;
 import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils;
 import org.alfresco.rm.rest.api.impl.SearchTypesFactory;
 import org.alfresco.rm.rest.api.model.FilePlan;
+import org.alfresco.rm.rest.api.model.Record;
 import org.alfresco.rm.rest.api.model.RecordCategory;
 import org.alfresco.service.cmr.model.FileFolderService;
 import org.alfresco.service.cmr.model.FileInfo;
@@ -64,7 +63,6 @@ import org.alfresco.service.namespace.QName;
 import org.alfresco.service.transaction.TransactionService;
 import org.alfresco.util.ParameterCheck;
 import org.springframework.beans.factory.InitializingBean;
-import org.springframework.extensions.webscripts.servlet.FormData;
 
 /**
  * File plan children relation
@@ -74,9 +72,7 @@ import org.springframework.extensions.webscripts.servlet.FormData;
  */
 @RelationshipResource(name="categories", entityResource = FilePlanEntityResource.class, title = "Category children of file plan")
 public class FilePlanChildrenRelation implements RelationshipResourceAction.Read,
-                                                 RelationshipResourceAction.Create,
-                                                 MultiPartRelationshipResourceAction.Create,
-                                                 InitializingBean
+                                                 RelationshipResourceAction.Create, InitializingBean
 {
     /** Record category type */
     public static final String RECORD_CATEGORY_TYPE = "rma:recordCategory";
@@ -222,10 +218,4 @@ public class FilePlanChildrenRelation implements RelationshipResourceAction.Read
 
         return result;
     }
-
-    @Override
-    public FilePlan create(String entityResourceId, FormData formData, Parameters parameters, WithResponse withResponse)
-    {
-        throw new IntegrityException("Uploading records into file plan root is not allowed.", null);
-    }
 }
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java
index e9fa2147f0..e1bdb8a680 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java
@@ -45,18 +45,15 @@ import org.alfresco.model.ContentModel;
 import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
 import org.alfresco.query.PagingResults;
 import org.alfresco.repo.node.getchildren.FilterProp;
-import org.alfresco.repo.node.integrity.IntegrityException;
 import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
 import org.alfresco.rest.api.Nodes;
 import org.alfresco.rest.api.impl.Util;
 import org.alfresco.rest.api.model.UserInfo;
 import org.alfresco.rest.framework.WebApiDescription;
 import org.alfresco.rest.framework.resource.RelationshipResource;
-import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartRelationshipResourceAction;
 import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
 import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
 import org.alfresco.rest.framework.resource.parameters.Parameters;
-import org.alfresco.rest.framework.webscripts.WithResponse;
 import org.alfresco.rm.rest.api.impl.ApiNodesModelFactory;
 import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils;
 import org.alfresco.rm.rest.api.impl.SearchTypesFactory;
@@ -69,7 +66,6 @@ import org.alfresco.service.cmr.repository.NodeRef;
 import org.alfresco.service.namespace.QName;
 import org.alfresco.service.transaction.TransactionService;
 import org.apache.commons.lang3.StringUtils;
-import org.springframework.extensions.webscripts.servlet.FormData;
 
 /**
  * Record category children relation
@@ -80,8 +76,7 @@ import org.springframework.extensions.webscripts.servlet.FormData;
  */
 @RelationshipResource(name="children", entityResource = RecordCategoriesEntityResource.class, title = "Children of a record category")
 public class RecordCategoryChildrenRelation implements RelationshipResourceAction.Read,
-                                                 RelationshipResourceAction.Create,
-                                                 MultiPartRelationshipResourceAction.Create
+                                                 RelationshipResourceAction.Create
 {
     private final static Set LIST_RECORD_CATEGORY_CHILDREN_EQUALS_QUERY_PROPERTIES = new HashSet<>(Arrays
             .asList(new String[] { RecordCategoryChild.PARAM_IS_RECORD_CATEGORY, RecordCategoryChild.PARAM_IS_RECORD_FOLDER,
@@ -213,10 +208,4 @@ public class RecordCategoryChildrenRelation implements RelationshipResourceActio
 
         return result;
     }
-
-    @Override
-    public RecordCategoryChild create(String entityResourceId, FormData formData, Parameters parameters, WithResponse withResponse)
-    {
-        throw new IntegrityException("Uploading records into record categories is not allowed.", null);
-    }
 }

From 8163c6753a619db49f5d1de28b1b7bb09b4a16f9 Mon Sep 17 00:00:00 2001
From: Tuna Aksoy 
Date: Mon, 15 May 2017 22:29:33 +0100
Subject: [PATCH 14/18] RM-4528 (Electronic record using file upload creation
 in invalid parent container returns HTTP 500)

---
 .../api/fileplans/FilePlanEntityResource.java    | 16 ++++++++++++++--
 .../RecordCategoryChildrenRelation.java          | 14 +++++++++++++-
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanEntityResource.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanEntityResource.java
index 5593a55a2a..dbba7749bf 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanEntityResource.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanEntityResource.java
@@ -30,13 +30,16 @@ package org.alfresco.rm.rest.api.fileplans;
 import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank;
 import static org.alfresco.util.ParameterCheck.mandatory;
 
+import org.alfresco.repo.node.integrity.IntegrityException;
 import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
 import org.alfresco.rest.framework.WebApiDescription;
 import org.alfresco.rest.framework.WebApiParam;
 import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
 import org.alfresco.rest.framework.resource.EntityResource;
 import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction;
+import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartRelationshipResourceAction;
 import org.alfresco.rest.framework.resource.parameters.Parameters;
+import org.alfresco.rest.framework.webscripts.WithResponse;
 import org.alfresco.rm.rest.api.impl.ApiNodesModelFactory;
 import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils;
 import org.alfresco.rm.rest.api.model.FilePlan;
@@ -47,6 +50,7 @@ import org.alfresco.service.namespace.QName;
 import org.alfresco.service.transaction.TransactionService;
 import org.alfresco.util.ParameterCheck;
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.extensions.webscripts.servlet.FormData;
 
 /**
  * File plan entity resource
@@ -55,8 +59,10 @@ import org.springframework.beans.factory.InitializingBean;
  * @since 2.6
  */
 @EntityResource(name = "file-plans", title = "File plans")
-public class FilePlanEntityResource
-        implements EntityResourceAction.ReadById, EntityResourceAction.Update, InitializingBean
+public class FilePlanEntityResource implements EntityResourceAction.ReadById,
+                                                EntityResourceAction.Update,
+                                                MultiPartRelationshipResourceAction.Create,
+                                                InitializingBean
 {
 
     private FilePlanComponentsApiUtils apiUtils;
@@ -147,4 +153,10 @@ public class FilePlanEntityResource
 
         return nodesModelFactory.createFilePlan(info, parameters, null, false);
     }
+
+    @Override
+    public FilePlan create(String entityResourceId, FormData formData, Parameters parameters, WithResponse withResponse)
+    {
+        throw new IntegrityException("Uploading records into file plan root is not allowed.", null);
+    }
 }
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java
index e1bdb8a680..66b2b8b71d 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/recordcategories/RecordCategoryChildrenRelation.java
@@ -45,15 +45,18 @@ import org.alfresco.model.ContentModel;
 import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
 import org.alfresco.query.PagingResults;
 import org.alfresco.repo.node.getchildren.FilterProp;
+import org.alfresco.repo.node.integrity.IntegrityException;
 import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
 import org.alfresco.rest.api.Nodes;
 import org.alfresco.rest.api.impl.Util;
 import org.alfresco.rest.api.model.UserInfo;
 import org.alfresco.rest.framework.WebApiDescription;
 import org.alfresco.rest.framework.resource.RelationshipResource;
+import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartRelationshipResourceAction;
 import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
 import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
 import org.alfresco.rest.framework.resource.parameters.Parameters;
+import org.alfresco.rest.framework.webscripts.WithResponse;
 import org.alfresco.rm.rest.api.impl.ApiNodesModelFactory;
 import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils;
 import org.alfresco.rm.rest.api.impl.SearchTypesFactory;
@@ -66,6 +69,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
 import org.alfresco.service.namespace.QName;
 import org.alfresco.service.transaction.TransactionService;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.extensions.webscripts.servlet.FormData;
 
 /**
  * Record category children relation
@@ -76,7 +80,8 @@ import org.apache.commons.lang3.StringUtils;
  */
 @RelationshipResource(name="children", entityResource = RecordCategoriesEntityResource.class, title = "Children of a record category")
 public class RecordCategoryChildrenRelation implements RelationshipResourceAction.Read,
-                                                 RelationshipResourceAction.Create
+                                                    RelationshipResourceAction.Create,
+                                                    MultiPartRelationshipResourceAction.Create
 {
     private final static Set LIST_RECORD_CATEGORY_CHILDREN_EQUALS_QUERY_PROPERTIES = new HashSet<>(Arrays
             .asList(new String[] { RecordCategoryChild.PARAM_IS_RECORD_CATEGORY, RecordCategoryChild.PARAM_IS_RECORD_FOLDER,
@@ -208,4 +213,11 @@ public class RecordCategoryChildrenRelation implements RelationshipResourceActio
 
         return result;
     }
+
+    @Override
+    public RecordCategoryChild create(String entityResourceId, FormData formData, Parameters parameters,
+        WithResponse withResponse)
+    {
+        throw new IntegrityException("Uploading records into record categories is not allowed.", null);
+    }
 }

From 6971d06fc0e668fba6a466db20cce937868970a0 Mon Sep 17 00:00:00 2001
From: Tuna Aksoy 
Date: Tue, 16 May 2017 09:59:43 +0100
Subject: [PATCH 15/18] RM-4528 (Electronic record using file upload creation
 in invalid parent container returns HTTP 500)

---
 .../fileplans/FilePlanChildrenRelation.java   | 20 ++++++++++++++++---
 .../api/fileplans/FilePlanEntityResource.java | 11 ----------
 .../RecordCategoryChildrenRelation.java       |  3 +--
 3 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanChildrenRelation.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanChildrenRelation.java
index 923b70c636..f89c5bf6f1 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanChildrenRelation.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanChildrenRelation.java
@@ -39,23 +39,25 @@ import java.util.Map;
 import java.util.Set;
 
 import org.alfresco.query.PagingResults;
-import org.alfresco.repo.activities.ActivityType;
 import org.alfresco.repo.node.getchildren.FilterProp;
+import org.alfresco.repo.node.integrity.IntegrityException;
 import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
 import org.alfresco.rest.api.impl.Util;
 import org.alfresco.rest.api.model.UserInfo;
 import org.alfresco.rest.framework.WebApiDescription;
 import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
 import org.alfresco.rest.framework.resource.RelationshipResource;
+import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartRelationshipResourceAction;
 import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
 import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
 import org.alfresco.rest.framework.resource.parameters.Parameters;
+import org.alfresco.rest.framework.webscripts.WithResponse;
 import org.alfresco.rm.rest.api.impl.ApiNodesModelFactory;
 import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils;
 import org.alfresco.rm.rest.api.impl.SearchTypesFactory;
 import org.alfresco.rm.rest.api.model.FilePlan;
-import org.alfresco.rm.rest.api.model.Record;
 import org.alfresco.rm.rest.api.model.RecordCategory;
+import org.alfresco.rm.rest.api.model.RecordCategoryChild;
 import org.alfresco.service.cmr.model.FileFolderService;
 import org.alfresco.service.cmr.model.FileInfo;
 import org.alfresco.service.cmr.repository.NodeRef;
@@ -63,6 +65,7 @@ import org.alfresco.service.namespace.QName;
 import org.alfresco.service.transaction.TransactionService;
 import org.alfresco.util.ParameterCheck;
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.extensions.webscripts.servlet.FormData;
 
 /**
  * File plan children relation
@@ -72,7 +75,9 @@ import org.springframework.beans.factory.InitializingBean;
  */
 @RelationshipResource(name="categories", entityResource = FilePlanEntityResource.class, title = "Category children of file plan")
 public class FilePlanChildrenRelation implements RelationshipResourceAction.Read,
-                                                 RelationshipResourceAction.Create, InitializingBean
+                                                 RelationshipResourceAction.Create,
+                                                 MultiPartRelationshipResourceAction.Create,
+                                                 InitializingBean
 {
     /** Record category type */
     public static final String RECORD_CATEGORY_TYPE = "rma:recordCategory";
@@ -218,4 +223,13 @@ public class FilePlanChildrenRelation implements RelationshipResourceAction.Read
 
         return result;
     }
+
+    /**
+     * @see org.alfresco.rest.framework.resource.actions.interfaces.MultiPartRelationshipResourceAction.Create#create(java.lang.String, org.springframework.extensions.webscripts.servlet.FormData, org.alfresco.rest.framework.resource.parameters.Parameters, org.alfresco.rest.framework.webscripts.WithResponse)
+     */
+    @Override
+    public RecordCategoryChild create(String entityResourceId, FormData formData, Parameters parameters, WithResponse withResponse)
+    {
+        throw new IntegrityException("Uploading records into file plan root is not allowed.", null);
+    }
 }
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanEntityResource.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanEntityResource.java
index dbba7749bf..76df9f5308 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanEntityResource.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanEntityResource.java
@@ -30,16 +30,13 @@ package org.alfresco.rm.rest.api.fileplans;
 import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank;
 import static org.alfresco.util.ParameterCheck.mandatory;
 
-import org.alfresco.repo.node.integrity.IntegrityException;
 import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
 import org.alfresco.rest.framework.WebApiDescription;
 import org.alfresco.rest.framework.WebApiParam;
 import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
 import org.alfresco.rest.framework.resource.EntityResource;
 import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction;
-import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartRelationshipResourceAction;
 import org.alfresco.rest.framework.resource.parameters.Parameters;
-import org.alfresco.rest.framework.webscripts.WithResponse;
 import org.alfresco.rm.rest.api.impl.ApiNodesModelFactory;
 import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils;
 import org.alfresco.rm.rest.api.model.FilePlan;
@@ -50,7 +47,6 @@ import org.alfresco.service.namespace.QName;
 import org.alfresco.service.transaction.TransactionService;
 import org.alfresco.util.ParameterCheck;
 import org.springframework.beans.factory.InitializingBean;
-import org.springframework.extensions.webscripts.servlet.FormData;
 
 /**
  * File plan entity resource
@@ -61,7 +57,6 @@ import org.springframework.extensions.webscripts.servlet.FormData;
 @EntityResource(name = "file-plans", title = "File plans")
 public class FilePlanEntityResource implements EntityResourceAction.ReadById,
                                                 EntityResourceAction.Update,
-                                                MultiPartRelationshipResourceAction.Create,
                                                 InitializingBean
 {
 
@@ -153,10 +148,4 @@ public class FilePlanEntityResource implements EntityResourceAction.ReadById
Date: Tue, 16 May 2017 12:54:14 +0100
Subject: [PATCH 16/18] RM-4528 (Electronic record using file upload creation
 in invalid parent container returns HTTP 500)

---
 .../rm/rest/api/fileplans/FilePlanChildrenRelation.java      | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanChildrenRelation.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanChildrenRelation.java
index f89c5bf6f1..d8c3e20dab 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanChildrenRelation.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/fileplans/FilePlanChildrenRelation.java
@@ -57,7 +57,6 @@ import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils;
 import org.alfresco.rm.rest.api.impl.SearchTypesFactory;
 import org.alfresco.rm.rest.api.model.FilePlan;
 import org.alfresco.rm.rest.api.model.RecordCategory;
-import org.alfresco.rm.rest.api.model.RecordCategoryChild;
 import org.alfresco.service.cmr.model.FileFolderService;
 import org.alfresco.service.cmr.model.FileInfo;
 import org.alfresco.service.cmr.repository.NodeRef;
@@ -76,7 +75,7 @@ import org.springframework.extensions.webscripts.servlet.FormData;
 @RelationshipResource(name="categories", entityResource = FilePlanEntityResource.class, title = "Category children of file plan")
 public class FilePlanChildrenRelation implements RelationshipResourceAction.Read,
                                                  RelationshipResourceAction.Create,
-                                                 MultiPartRelationshipResourceAction.Create,
+                                                 MultiPartRelationshipResourceAction.Create,
                                                  InitializingBean
 {
     /** Record category type */
@@ -228,7 +227,7 @@ public class FilePlanChildrenRelation implements RelationshipResourceAction.Read
      * @see org.alfresco.rest.framework.resource.actions.interfaces.MultiPartRelationshipResourceAction.Create#create(java.lang.String, org.springframework.extensions.webscripts.servlet.FormData, org.alfresco.rest.framework.resource.parameters.Parameters, org.alfresco.rest.framework.webscripts.WithResponse)
      */
     @Override
-    public RecordCategoryChild create(String entityResourceId, FormData formData, Parameters parameters, WithResponse withResponse)
+    public RecordCategory create(String entityResourceId, FormData formData, Parameters parameters, WithResponse withResponse)
     {
         throw new IntegrityException("Uploading records into file plan root is not allowed.", null);
     }

From 7748487b32a6d07d08bfbcfd520636bc63870c11 Mon Sep 17 00:00:00 2001
From: Rodica Sutu 
Date: Tue, 16 May 2017 15:18:24 +0300
Subject: [PATCH 17/18] tests updates, remove FIXME notes add a check for the
 issue RM-4372

---
 .../rm/community/model/record/RecordProperties.java    |  2 ++
 .../org/alfresco/rest/rm/community/base/TestData.java  |  4 +++-
 .../rm/community/recordfolders/RecordFolderTests.java  | 10 +++-------
 .../unfiledcontainers/UnfiledContainerTests.java       |  3 ++-
 .../UnfiledRecordsFolderTests.java                     |  6 ++++--
 5 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/RecordProperties.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/RecordProperties.java
index 8732533cf2..5e7a08322e 100644
--- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/RecordProperties.java
+++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/RecordProperties.java
@@ -64,6 +64,7 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
 import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_ORIGINATING_USER_ID;
 import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_ORIGINATING_CREATION_DATE;
 
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import com.fasterxml.jackson.annotation.JsonProperty;
 
 import org.alfresco.rest.rm.community.model.common.Owner;
@@ -86,6 +87,7 @@ import lombok.NoArgsConstructor;
 @EqualsAndHashCode(callSuper = true)
 @NoArgsConstructor
 @AllArgsConstructor
+@JsonIgnoreProperties(ignoreUnknown = true)
 public class RecordProperties extends TestModel
 {
     /*************************/
diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/TestData.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/TestData.java
index d5a24f5789..a1ebcb2d11 100644
--- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/TestData.java
+++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/TestData.java
@@ -187,7 +187,9 @@ public interface TestData
                         { RECORD_CATEGORY_TYPE },
                         { RECORD_FOLDER_TYPE },
                         { TRANSFER_CONTAINER_TYPE },
-                        { UNFILED_CONTAINER_TYPE }
+                        { TRANSFER_TYPE },
+                        { UNFILED_CONTAINER_TYPE },
+
                 };
     }
 }
diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordfolders/RecordFolderTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordfolders/RecordFolderTests.java
index 6381fe88f9..8a7209340a 100644
--- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordfolders/RecordFolderTests.java
+++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordfolders/RecordFolderTests.java
@@ -34,6 +34,7 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
 import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.IS_CLOSED;
 import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
 import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.FILE_PLAN_TYPE;
+import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.FOLDER_TYPE;
 import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_TYPE;
 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;
@@ -105,7 +106,8 @@ public class RecordFolderTests extends BaseRMRestTest
                 { UNFILED_CONTAINER_TYPE },
                 { UNFILED_RECORD_FOLDER_TYPE },
                 { TRANSFER_TYPE },
-                { RECORD_CATEGORY_TYPE }
+                { RECORD_CATEGORY_TYPE },
+                { FOLDER_TYPE }
         };
     }
 
@@ -370,9 +372,6 @@ public class RecordFolderTests extends BaseRMRestTest
         // Make a request to close the record folder
         RecordFolder updatedRecordFolder = recordFolderAPI.updateRecordFolder(recordFolderModel, recordFolder.getId());
 
-        //FIXME - remove this workaround after RM-4921 is fixed.
-        updatedRecordFolder = recordFolderAPI.getRecordFolder(updatedRecordFolder.getId());
-
         // Verify that the record folder is closed now
         assertTrue(updatedRecordFolder.getProperties().getIsClosed());
 
@@ -386,9 +385,6 @@ public class RecordFolderTests extends BaseRMRestTest
         // Make a request to reopen the record folder
         updatedRecordFolder = recordFolderAPI.updateRecordFolder(recordFolderModel, recordFolder.getId());
 
-        //FIXME - remove this workaround after RM-4921 is fixed.
-        updatedRecordFolder = recordFolderAPI.getRecordFolder(updatedRecordFolder.getId());
-
         // Verify that the record folder is open now
         assertFalse(updatedRecordFolder.getProperties().getIsClosed());
     }
diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/unfiledcontainers/UnfiledContainerTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/unfiledcontainers/UnfiledContainerTests.java
index 3deeab829c..c384ecb206 100644
--- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/unfiledcontainers/UnfiledContainerTests.java
+++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/unfiledcontainers/UnfiledContainerTests.java
@@ -431,7 +431,8 @@ public class UnfiledContainerTests extends BaseRMRestTest
         try
         {
             getRestAPIFactory().getUnfiledContainersAPI().createUnfiledContainerChild(unfiledFolderModel, UNFILED_RECORDS_CONTAINER_ALIAS);
-        } catch (Exception error)
+        }
+        catch (Exception error)
         {
         }
         // Verify the status code
diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/unfiledrecordfolders/UnfiledRecordsFolderTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/unfiledrecordfolders/UnfiledRecordsFolderTests.java
index 7e6c18b500..e640e9d86a 100644
--- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/unfiledrecordfolders/UnfiledRecordsFolderTests.java
+++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/unfiledrecordfolders/UnfiledRecordsFolderTests.java
@@ -487,8 +487,10 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
                 assertTrue(record.getName().equals(createdComponent.getName()),
                             "The record name "+ record.getName()+" is not equal with the record name returned when creating the record " + createdComponent
                                         .getName());
-
-                assertTrue(record.getName().equals(record.getProperties().getIdentifier()));
+                String identifier = " \\(" + record.getProperties().getIdentifier() + "\\)";
+                String regex= "(" + NONELECTRONIC_RECORD_NAME + "|" + ELECTRONIC_RECORD_NAME + ")" + "[0-9]+" + identifier;
+                assertTrue(record.getName().matches(regex),
+                            "The record name :" + record.getName() +"doesn't match the expression " + regex);
                 assertTrue(createdComponent.getName().contains(createdComponent.getProperties().getIdentifier()));
                 assertEquals(createdComponent.getNodeType(), record.getNodeType());
 

From 5fec31e164c25f4df1881d2d4f370bedc69cd930 Mon Sep 17 00:00:00 2001
From: Rodica Sutu 
Date: Wed, 17 May 2017 09:44:46 +0300
Subject: [PATCH 18/18] minor indentation

---
 .../unfiledrecordfolders/UnfiledRecordsFolderTests.java         | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/unfiledrecordfolders/UnfiledRecordsFolderTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/unfiledrecordfolders/UnfiledRecordsFolderTests.java
index e640e9d86a..4e09cee2e7 100644
--- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/unfiledrecordfolders/UnfiledRecordsFolderTests.java
+++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/unfiledrecordfolders/UnfiledRecordsFolderTests.java
@@ -490,7 +490,7 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
                 String identifier = " \\(" + record.getProperties().getIdentifier() + "\\)";
                 String regex= "(" + NONELECTRONIC_RECORD_NAME + "|" + ELECTRONIC_RECORD_NAME + ")" + "[0-9]+" + identifier;
                 assertTrue(record.getName().matches(regex),
-                            "The record name :" + record.getName() +"doesn't match the expression " + regex);
+                            "The record name:" + record.getName() + " doesn't match the expression " + regex);
                 assertTrue(createdComponent.getName().contains(createdComponent.getProperties().getIdentifier()));
                 assertEquals(createdComponent.getNodeType(), record.getNodeType());