Merge branch 'feature/RM-6852_FixInconsistenciesV1ResponeCodes' into 'feature/RM-6851_DeclareAndFileRecInHoldFolder'

Resolve RM-6852 "Feature/ fixinconsistenciesv1responsecodes"

See merge request records-management/records-management!1179
This commit is contained in:
Sara Aspery
2019-05-23 21:24:40 +01:00
3 changed files with 20 additions and 2 deletions

View File

@@ -85,7 +85,7 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
private final static String DESTINATION_PATH_NOT_FOUND_EXC = "Unable to execute create-record action, because the destination path could not be found."; private final static String DESTINATION_PATH_NOT_FOUND_EXC = "Unable to execute create-record action, because the destination path could not be found.";
private final static String INVALID_DESTINATION_PATH_EXC = "Unable to execute create-record action, because the destination path is invalid."; private final static String INVALID_DESTINATION_PATH_EXC = "Unable to execute create-record action, because the destination path is invalid.";
private final static String DESTINATION_PATH_NOT_RECORD_FOLDER_EXC = "Unable to execute create-record action, because the destination path is not a record folder."; private final static String DESTINATION_PATH_NOT_RECORD_FOLDER_EXC = "Unable to execute create-record action, because the destination path is not a record folder.";
private final static String CLOSED_RECORD_FOLDER_EXC = "Unable to create record, because container is closed"; private final static String CLOSED_RECORD_FOLDER_EXC = "You can't add new items to a closed record folder.";
private final static String HOLD_NAME = "holdName"; private final static String HOLD_NAME = "holdName";
private UserModel userFillingPermission, userReadOnlyPermission; private UserModel userFillingPermission, userReadOnlyPermission;

View File

@@ -164,6 +164,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
private static final String FINAL_DESCRIPTION = "rm.service.final-version-description"; private static final String FINAL_DESCRIPTION = "rm.service.final-version-description";
private static final String MSG_UNDECLARED_ONLY_RECORDS = "rm.action.undeclared-only-records"; private static final String MSG_UNDECLARED_ONLY_RECORDS = "rm.action.undeclared-only-records";
private static final String MSG_NO_DECLARE_MAND_PROP = "rm.action.no-declare-mand-prop"; private static final String MSG_NO_DECLARE_MAND_PROP = "rm.action.no-declare-mand-prop";
private static final String MSG_CANNOT_CREATE_CHILDREN_IN_CLOSED_RECORD_FOLDER = "rm.service.add-children-to-closed-record-folder";
/** Always edit property array */ /** Always edit property array */
private static final QName[] ALWAYS_EDIT_PROPERTIES = new QName[] private static final QName[] ALWAYS_EDIT_PROPERTIES = new QName[]
@@ -1058,7 +1059,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
Boolean isClosed = (Boolean) nodeService.getProperty(newRecordContainer, PROP_IS_CLOSED); Boolean isClosed = (Boolean) nodeService.getProperty(newRecordContainer, PROP_IS_CLOSED);
if (isClosed != null && isClosed) if (isClosed != null && isClosed)
{ {
throw new AlfrescoRuntimeException("Unable to create record, because container is closed."); throw new IntegrityException(I18NUtil.getMessage(MSG_CANNOT_CREATE_CHILDREN_IN_CLOSED_RECORD_FOLDER), null);
} }
if (extendedPermissionService.hasPermission(newRecordContainer, RMPermissionModel.FILING) == AccessStatus.DENIED) if (extendedPermissionService.hasPermission(newRecordContainer, RMPermissionModel.FILING) == AccessStatus.DENIED)

View File

@@ -78,6 +78,7 @@ public class RecordServiceImplUnitTest extends BaseUnitTest
private NodeRef dmNodeRef; private NodeRef dmNodeRef;
private NodeRef unfiledRecordContainer; private NodeRef unfiledRecordContainer;
private NodeRef frozenRecordFolder; private NodeRef frozenRecordFolder;
private NodeRef closedRecordFolder;
private ChildAssociationRef parentAssoc; private ChildAssociationRef parentAssoc;
private static QName TYPE_MY_FILE_PLAN = generateQName(); private static QName TYPE_MY_FILE_PLAN = generateQName();
@@ -97,6 +98,7 @@ public class RecordServiceImplUnitTest extends BaseUnitTest
dmNodeRef = generateNodeRef(TYPE_CONTENT); dmNodeRef = generateNodeRef(TYPE_CONTENT);
unfiledRecordContainer = generateNodeRef(TYPE_UNFILED_RECORD_CONTAINER); unfiledRecordContainer = generateNodeRef(TYPE_UNFILED_RECORD_CONTAINER);
frozenRecordFolder = generateNodeRef(TYPE_RECORD_FOLDER); frozenRecordFolder = generateNodeRef(TYPE_RECORD_FOLDER);
closedRecordFolder = generateNodeRef(TYPE_RECORD_FOLDER);
parentAssoc = mock(ChildAssociationRef.class); parentAssoc = mock(ChildAssociationRef.class);
// set-up node service // set-up node service
@@ -600,6 +602,20 @@ public class RecordServiceImplUnitTest extends BaseUnitTest
recordService.createRecord(filePlan, dmNodeRef, frozenRecordFolder); recordService.createRecord(filePlan, dmNodeRef, frozenRecordFolder);
} }
/**
* Given a file that is not yet a record
* When I create the record specifying a closed destination record folder
* Then an exception is thrown
*/
@Test(expected= IntegrityException.class)
public void createRecordIntoClosedRecordFolder()
{
mocksForRecordCreation();
// create the record
recordService.createRecord(filePlan, dmNodeRef, closedRecordFolder);
}
/* Helper method to set up the mocks for record creation */ /* Helper method to set up the mocks for record creation */
private void mocksForRecordCreation() private void mocksForRecordCreation()
{ {
@@ -613,6 +629,7 @@ public class RecordServiceImplUnitTest extends BaseUnitTest
when(mockedFilePlanService.isFilePlan(nonStandardFilePlan)).thenReturn(true); when(mockedFilePlanService.isFilePlan(nonStandardFilePlan)).thenReturn(true);
when(mockedFreezeService.isFrozen(recordFolder)).thenReturn(false); when(mockedFreezeService.isFrozen(recordFolder)).thenReturn(false);
when(mockedFreezeService.isFrozen(frozenRecordFolder)).thenReturn(true); when(mockedFreezeService.isFrozen(frozenRecordFolder)).thenReturn(true);
when(mockedNodeService.getProperty(closedRecordFolder, PROP_IS_CLOSED)).thenReturn(true);
// mocks for policies // mocks for policies
doNothing().when(recordService).invokeBeforeRecordDeclaration(dmNodeRef); doNothing().when(recordService).invokeBeforeRecordDeclaration(dmNodeRef);