Merge remote-tracking branch 'remotes/origin/feature/RM-6796_DeclareAndFileTests' into feature/RM-6849_CheckForFilingPermission

This commit is contained in:
cagache
2019-05-21 16:55:51 +03:00
4 changed files with 16 additions and 13 deletions

View File

@@ -1036,7 +1036,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
// if optional location not specified, use the unfiledContainer // if optional location not specified, use the unfiledContainer
if (newRecordContainer == null) if (newRecordContainer == null)
{ {
// get the new record container for the file plan // get the unfiled record container node for the file plan
newRecordContainer = AuthenticationUtil.runAsSystem(() -> filePlanService.getUnfiledContainer(checkedFilePlan)); newRecordContainer = AuthenticationUtil.runAsSystem(() -> filePlanService.getUnfiledContainer(checkedFilePlan));
if (newRecordContainer == null) if (newRecordContainer == null)
@@ -1044,12 +1044,13 @@ public class RecordServiceImpl extends BaseBehaviourBean
throw new AlfrescoRuntimeException("Unable to create record, because record container could not be found."); throw new AlfrescoRuntimeException("Unable to create record, because record container could not be found.");
} }
} }
// if optional location supplied, check that it is a valid record folder // if optional location supplied, check that it is a valid record folder, unfiled record container or folder
else else
{ {
QName nodeType = nodeService.getType(newRecordContainer); final QName nodeType = nodeService.getType(newRecordContainer);
if(!(nodeType.equals(RecordsManagementModel.TYPE_RECORD_FOLDER) || if (!(nodeType.equals(RecordsManagementModel.TYPE_RECORD_FOLDER) ||
nodeType.equals(RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER))) nodeType.equals(RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER) ||
nodeType.equals(RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER)))
{ {
throw new AlfrescoRuntimeException("Unable to create record, because container is not a valid type for new record."); throw new AlfrescoRuntimeException("Unable to create record, because container is not a valid type for new record.");
} }

View File

@@ -148,7 +148,7 @@ public class FilesEntityResource implements InitializingBean
{ {
// Get record folder, if provided // Get record folder, if provided
NodeRef targetParent = null; NodeRef targetParent = null;
String targetParentId = parameters.getParameter(RMNode.PARAM_PARENT_ID); final String targetParentId = parameters.getParameter(RMNode.PARAM_PARENT_ID);
if (targetParentId != null) if (targetParentId != null)
{ {
targetParent = apiUtils.lookupAndValidateNodeType(targetParentId, RecordsManagementModel.TYPE_RECORD_FOLDER); targetParent = apiUtils.lookupAndValidateNodeType(targetParentId, RecordsManagementModel.TYPE_RECORD_FOLDER);

View File

@@ -75,6 +75,7 @@ public class RecordServiceImplUnitTest extends BaseUnitTest
private NodeRef nonStandardFilePlanComponent; private NodeRef nonStandardFilePlanComponent;
private NodeRef nonStandardFilePlan; private NodeRef nonStandardFilePlan;
private NodeRef dmNodeRef; private NodeRef dmNodeRef;
private NodeRef unfiledRecordContainer;
private NodeRef unfiledRecordFolder; private NodeRef unfiledRecordFolder;
private ChildAssociationRef parentAssoc; private ChildAssociationRef parentAssoc;
@@ -93,6 +94,7 @@ public class RecordServiceImplUnitTest extends BaseUnitTest
nonStandardFilePlanComponent = generateNodeRef(TYPE_RECORD_CATEGORY); nonStandardFilePlanComponent = generateNodeRef(TYPE_RECORD_CATEGORY);
nonStandardFilePlan = generateNodeRef(TYPE_MY_FILE_PLAN); nonStandardFilePlan = generateNodeRef(TYPE_MY_FILE_PLAN);
dmNodeRef = generateNodeRef(TYPE_CONTENT); dmNodeRef = generateNodeRef(TYPE_CONTENT);
unfiledRecordContainer = generateNodeRef(TYPE_UNFILED_RECORD_CONTAINER);
unfiledRecordFolder = generateNodeRef(TYPE_UNFILED_RECORD_FOLDER); unfiledRecordFolder = generateNodeRef(TYPE_UNFILED_RECORD_FOLDER);
parentAssoc = mock(ChildAssociationRef.class); parentAssoc = mock(ChildAssociationRef.class);
@@ -485,12 +487,12 @@ public class RecordServiceImplUnitTest extends BaseUnitTest
mocksForRecordCreation(); mocksForRecordCreation();
// create the record // create the record
recordService.createRecord(nonStandardFilePlan, dmNodeRef); recordService.createRecord(filePlan, dmNodeRef);
// verify record was created in unfiled record container // verify record was created in unfiled record container
verify(mockedNodeService, times(1)).moveNode( verify(mockedNodeService, times(1)).moveNode(
dmNodeRef, dmNodeRef,
unfiledRecordFolder, unfiledRecordContainer,
ContentModel.ASSOC_CONTAINS, ContentModel.ASSOC_CONTAINS,
parentAssoc.getQName()); parentAssoc.getQName());
} }
@@ -506,12 +508,12 @@ public class RecordServiceImplUnitTest extends BaseUnitTest
mocksForRecordCreation(); mocksForRecordCreation();
// create the record // create the record
recordService.createRecord(filePlan, dmNodeRef, unfiledRecordFolder); recordService.createRecord(filePlan, dmNodeRef, unfiledRecordContainer);
// verify record was created in specified unfiled record container // verify record was created in specified unfiled record container
verify(mockedNodeService, times(1)).moveNode( verify(mockedNodeService, times(1)).moveNode(
dmNodeRef, dmNodeRef,
unfiledRecordFolder, unfiledRecordContainer,
ContentModel.ASSOC_CONTAINS, ContentModel.ASSOC_CONTAINS,
parentAssoc.getQName()); parentAssoc.getQName());
} }
@@ -583,7 +585,7 @@ public class RecordServiceImplUnitTest extends BaseUnitTest
doNothing().when(recordService).invokeBeforeRecordDeclaration(dmNodeRef); doNothing().when(recordService).invokeBeforeRecordDeclaration(dmNodeRef);
doNothing().when(recordService).invokeOnRecordDeclaration(dmNodeRef); doNothing().when(recordService).invokeOnRecordDeclaration(dmNodeRef);
when(mockedFilePlanService.getUnfiledContainer(nonStandardFilePlan)).thenReturn(unfiledRecordFolder); when(mockedFilePlanService.getUnfiledContainer(filePlan)).thenReturn(unfiledRecordContainer);
when(mockedVersionService.getVersionHistory(dmNodeRef)).thenReturn(null); when(mockedVersionService.getVersionHistory(dmNodeRef)).thenReturn(null);
} }

View File

@@ -1873,14 +1873,14 @@ paths:
$ref: '#/definitions/RecordEntry' $ref: '#/definitions/RecordEntry'
'400': '400':
description: | description: |
Invalid parameter: **fileId** is not a valid format Invalid parameter: **fileId** is not a valid format or **parentId** is not a valid format
'401': '401':
description: Authentication failed description: Authentication failed
'403': '403':
description: Current user does not have permission to declare a record description: Current user does not have permission to declare a record
'404': '404':
description: | description: |
**fileId** does not exist **fileId** does not exist or **parentId** does not exist
'422': '422':
description: | description: |
Model integrity exception: the action breaks system's integrity restrictions Model integrity exception: the action breaks system's integrity restrictions