use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule in project records-management by Alfresco.
the class RecordServiceImplUnitTest method linkCompatibleDispositions.
/**
* Given that the source record and target record folder have compatible disposition schedules
* When I link
* Then it is successful
*/
@Test
public void linkCompatibleDispositions() {
// create record and record folder
NodeRef record = generateRecord();
NodeRef recordFolder = generateRecordFolder();
makeChildrenOf(generateRecordFolder(), record);
// set the name of the record
String name = generateText();
doReturn(name).when(mockedNodeService).getProperty(record, PROP_NAME);
// set dispositions
DispositionSchedule recordDispositionSchedule = mock(DispositionSchedule.class);
when(recordDispositionSchedule.isRecordLevelDisposition()).thenReturn(true);
when(mockedDispositionService.getDispositionSchedule(record)).thenReturn(recordDispositionSchedule);
DispositionSchedule recordFolderDispositionSchedule = mock(DispositionSchedule.class);
when(recordFolderDispositionSchedule.isRecordLevelDisposition()).thenReturn(true);
when(mockedDispositionService.getDispositionSchedule(recordFolder)).thenReturn(recordFolderDispositionSchedule);
// link
recordService.link(record, recordFolder);
// verify link was created
verify(mockedNodeService, times(1)).addChild(recordFolder, record, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name));
}
use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule in project records-management by Alfresco.
the class RecordServiceImplUnitTest method linkIncompatibleDispositions.
/**
* Given that the source record and target record folder have incompatible disposition schedules
* When I link
* Then I expect a failure
*/
@Test
public void linkIncompatibleDispositions() {
// create record and record folder
NodeRef record = generateRecord();
NodeRef recordFolder = generateRecordFolder();
makeChildrenOf(generateRecordFolder(), record);
// set the name of the record
String name = generateText();
doReturn(name).when(mockedNodeService).getProperty(record, PROP_NAME);
// set dispositions
DispositionSchedule recordDispositionSchedule = mock(DispositionSchedule.class);
when(recordDispositionSchedule.isRecordLevelDisposition()).thenReturn(true);
when(mockedDispositionService.getOriginDispositionSchedule(record)).thenReturn(recordDispositionSchedule);
DispositionSchedule recordFolderDispositionSchedule = mock(DispositionSchedule.class);
when(recordFolderDispositionSchedule.isRecordLevelDisposition()).thenReturn(false);
when(mockedDispositionService.getDispositionSchedule(recordFolder)).thenReturn(recordFolderDispositionSchedule);
// expect exception
exception.expect(RecordLinkRuntimeException.class);
// link
recordService.link(record, recordFolder);
}
use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule in project records-management by Alfresco.
the class BroadcastDispositionActionDefinitionUpdateActionUnitTest method testChangePeriodProperty.
/**
* Check that changing the period property triggers a recalculation of the "disposition as of" date.
* <p>
* Set up a disposition action definition node under a schedule defintion node, under a category node. Create a
* record whose next action is an instance of the action definition. Check that if the "period property" of the
* action definition changes then the "disposition as of" date is recalculated and persisted against the node of the
* next action.
*/
@Test
public void testChangePeriodProperty() {
// Set up the action definition node.
String definitionNodeId = "definitionNodeId";
NodeRef definitionNode = new NodeRef("definition://node/" + definitionNodeId);
DispositionSchedule mockDispositionSchedule = mock(DispositionSchedule.class);
when(mockDispositionSchedule.getNodeRef()).thenReturn(definitionNode);
when(mockNodeService.getType(definitionNode)).thenReturn(TYPE_DISPOSITION_ACTION_DEFINITION);
// Set up the schedule definition node hierarchy.
NodeRef categoryNode = new NodeRef("category://node/");
NodeRef scheduleNode = new NodeRef("schedule://node/");
ChildAssociationRef scheduleDefinitionRelationship = new ChildAssociationRef(null, scheduleNode, null, definitionNode);
when(mockNodeService.getPrimaryParent(definitionNode)).thenReturn(scheduleDefinitionRelationship);
ChildAssociationRef categoryScheduleRelationship = new ChildAssociationRef(null, categoryNode, null, scheduleNode);
when(mockNodeService.getPrimaryParent(scheduleNode)).thenReturn(categoryScheduleRelationship);
// Set up the record/step relationship.
NodeRef recordNode = new NodeRef("record://node/");
NodeRef stepNode = new NodeRef("step://node/");
ChildAssociationRef recordStepRelationship = new ChildAssociationRef(null, recordNode, null, stepNode);
when(mockNodeService.getPrimaryParent(stepNode)).thenReturn(recordStepRelationship);
// Set up the disposition schedule.
when(mockDispositionService.getAssociatedDispositionSchedule(categoryNode)).thenReturn(mockDispositionSchedule);
when(mockDispositionService.getDisposableItems(mockDispositionSchedule)).thenReturn(asList(recordNode));
when(mockDispositionService.getDispositionSchedule(recordNode)).thenReturn(mockDispositionSchedule);
// Set up the record.
when(mockNodeService.hasAspect(recordNode, ASPECT_DISPOSITION_LIFECYCLE)).thenReturn(true);
// Set up the next disposition action.
DispositionAction nextAction = mock(DispositionAction.class);
when(nextAction.getId()).thenReturn(definitionNodeId);
when(nextAction.getNodeRef()).thenReturn(stepNode);
when(mockDispositionService.getNextDispositionAction(recordNode)).thenReturn(nextAction);
DispositionActionDefinition mockActionDefinition = mock(DispositionActionDefinition.class);
when(nextAction.getDispositionActionDefinition()).thenReturn(mockActionDefinition);
// Set up the action so that it looks like the period property has been changed.
Action mockAction = mock(Action.class);
when(mockAction.getParameterValue(CHANGED_PROPERTIES)).thenReturn((Serializable) asList(PROP_DISPOSITION_PERIOD_PROPERTY));
// Set up the expected "as of" date.
Date newAsOfDate = new Date(123456789000L);
when(mockDispositionService.calculateAsOfDate(recordNode, mockActionDefinition)).thenReturn(newAsOfDate);
// Call the method under test.
action.executeImpl(mockAction, definitionNode);
// Check that the "as of" date is updated.
verify(mockNodeService).setProperty(stepNode, PROP_DISPOSITION_AS_OF, newAsOfDate);
}
use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule in project records-management by Alfresco.
the class DataSetServiceImpl method patchLoadedData.
/**
* Temp method to patch AMP'ed data
*/
private void patchLoadedData() {
AuthenticationUtil.RunAsWork<Object> runAsWork = new AuthenticationUtil.RunAsWork<Object>() {
public Object doWork() {
Set<NodeRef> rmRoots = filePlanService.getFilePlans();
logger.info("Bootstraping " + rmRoots.size() + " rm roots ...");
for (NodeRef rmRoot : rmRoots) {
if (permissionService.getInheritParentPermissions(rmRoot)) {
logger.info("Updating permissions for rm root: " + rmRoot);
permissionService.setInheritParentPermissions(rmRoot, false);
}
String allRoleShortName = RMAuthority.ALL_ROLES_PREFIX + rmRoot.getId();
String allRoleGroupName = authorityService.getName(AuthorityType.GROUP, allRoleShortName);
if (!authorityService.authorityExists(allRoleGroupName)) {
logger.info("Creating all roles group for root node: " + rmRoot.toString());
// Create "all" role group for root node
String allRoles = authorityService.createAuthority(AuthorityType.GROUP, allRoleShortName, RMAuthority.ALL_ROLES_DISPLAY_NAME, new HashSet<String>(Arrays.asList(RMAuthority.ZONE_APP_RM)));
// Put all the role groups in it
Set<Role> roles = filePlanRoleService.getRoles(rmRoot);
for (Role role : roles) {
logger.info(" - adding role group " + role.getRoleGroupName() + " to all roles group");
authorityService.addAuthority(allRoles, role.getRoleGroupName());
}
// Set the permissions
permissionService.setPermission(rmRoot, allRoles, RMPermissionModel.READ_RECORDS, true);
}
}
// Make sure all the containers do not inherit permissions
ResultSet rs = searchService.query(SPACES_STORE, SearchService.LANGUAGE_FTS_ALFRESCO, "TYPE:\"rma:recordsManagementContainer\"");
try {
logger.info("Bootstraping " + rs.length() + " record containers ...");
for (NodeRef container : rs.getNodeRefs()) {
String containerName = (String) nodeService.getProperty(container, ContentModel.PROP_NAME);
// Set permissions
if (permissionService.getInheritParentPermissions(container)) {
logger.info("Updating permissions for record container: " + containerName);
permissionService.setInheritParentPermissions(container, false);
}
}
} finally {
rs.close();
}
// fix up the test dataset to fire initial events for
// disposition
// schedules
rs = searchService.query(SPACES_STORE, SearchService.LANGUAGE_FTS_ALFRESCO, "TYPE:\"rma:recordFolder\"");
try {
logger.info("Bootstraping " + rs.length() + " record folders ...");
for (NodeRef recordFolder : rs.getNodeRefs()) {
String folderName = (String) nodeService.getProperty(recordFolder, ContentModel.PROP_NAME);
// Set permissions
if (permissionService.getInheritParentPermissions(recordFolder)) {
logger.info("Updating permissions for record folder: " + folderName);
permissionService.setInheritParentPermissions(recordFolder, false);
}
if (!nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE)) {
// See if the folder has a disposition schedule that
// needs
// to be applied
DispositionSchedule ds = dispositionService.getDispositionSchedule(recordFolder);
if (ds != null) {
// Fire action to "set-up" the folder correctly
logger.info("Setting up bootstraped record folder: " + folderName);
recordFolderService.setupRecordFolder(recordFolder);
}
}
// fixup the search behaviour aspect for the record
// folder
logger.info("Setting up search aspect for record folder: " + folderName);
recordsManagementSearchBehaviour.fixupSearchAspect(recordFolder);
}
} finally {
rs.close();
}
return null;
}
};
AuthenticationUtil.runAs(runAsWork, AuthenticationUtil.getAdminUserName());
}
use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule in project records-management by Alfresco.
the class MoveRecordFolderTest method createRecordCategory.
private NodeRef createRecordCategory(boolean recordLevel) {
NodeRef rc = filePlanService.createRecordCategory(filePlan, GUID.generate());
DispositionSchedule dis = utils.createBasicDispositionSchedule(rc, GUID.generate(), GUID.generate(), recordLevel, false);
Map<QName, Serializable> adParams = new HashMap<QName, Serializable>(3);
adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME);
adParams.put(PROP_DISPOSITION_DESCRIPTION, GUID.generate());
adParams.put(PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
dispositionService.addDispositionActionDefinition(dis, adParams);
return rc;
}
Aggregations