Feature/rm 5148 create folder and records using auto rename

This commit is contained in:
Ramona Popa
2017-05-19 18:14:38 +01:00
parent 99faac4dbd
commit d34754fb7c
3 changed files with 32 additions and 10 deletions

View File

@@ -49,7 +49,6 @@ import static org.testng.Assert.assertTrue;
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
import org.alfresco.rest.rm.community.model.record.Record;
import org.alfresco.rest.rm.community.model.record.RecordContent;
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild;
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
@@ -393,4 +392,33 @@ public class ElectronicRecordTests extends BaseRMRestTest
assertTrue(unfiledRecordFoldersAPI.getUnfiledRecordFolder(record.getParentId()).getName().equals(unfiledRecordFolderPathEl4));
}
/**
* <pre>
* Given a parent container that is a record folder
* When I try to create a record with name1 and create another one with the same given name
* Then the second record is created with success
* </pre>
*
* @throws Exception
* if record can't be created
*/
@Test(description = "Electronic records can be created in record folder with duplicate name")
@Bug(id ="RM-5116, RM-5012")
public void canCreateElectronicRecordsWithDuplicateName() throws Exception
{
RecordCategoryChild recordFolder = createCategoryFolderInFilePlan();
// Create an electronic record with the name "Record 1"
Record recordModel = Record.builder().name("Record 1").nodeType(CONTENT_TYPE).build();
getRestAPIFactory().getRecordFolderAPI().createRecord(recordModel, recordFolder.getId());
// Verify the status code
assertStatusCode(CREATED);
// Try to create another electronic record with the same name
getRestAPIFactory().getRecordFolderAPI().createRecord(recordModel, recordFolder.getId());
// Verify the status code
assertStatusCode(CREATED);
}
}

View File

@@ -33,9 +33,9 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
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.util.PojoUtility.toJson;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createNonElectronicRecordModel;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createFullNonElectronicUnfiledContainerChildRecordModel;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createFullNonElectronicRecordModel;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createFullNonElectronicUnfiledContainerChildRecordModel;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createNonElectronicRecordModel;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.verifyFullNonElectronicRecord;
import static org.alfresco.utility.constants.UserRole.SiteManager;
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;

View File

@@ -136,12 +136,6 @@ public class FilePlanComponentsApiUtils
RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER,
RecordsManagementModel.TYPE_HOLD_CONTAINER);
public static final List<QName> 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;
@@ -630,7 +624,7 @@ public class FilePlanComponentsApiUtils
QName typeQName = nodes.createQName(nodeType);
// Existing file/folder name handling
if (TYPES_CAN_USE_AUTORENAME.contains(typeQName) && autoRename)
if (autoRename)
{
NodeRef existingNode = nodeService.getChildByName(parentNodeRef, ContentModel.ASSOC_CONTAINS, nodeName);
if (existingNode != null)