Search in sources :

Example 11 with DispositionSchedule

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));
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) DispositionSchedule(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest) Test(org.junit.Test)

Example 12 with DispositionSchedule

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);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) DispositionSchedule(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest) Test(org.junit.Test)

Example 13 with DispositionSchedule

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);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Action(org.alfresco.service.cmr.action.Action) DispositionAction(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction) DispositionSchedule(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule) DispositionActionDefinition(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) DispositionAction(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction) Date(java.util.Date) Test(org.junit.Test)

Example 14 with DispositionSchedule

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());
}
Also used : Role(org.alfresco.module.org_alfresco_module_rm.role.Role) NodeRef(org.alfresco.service.cmr.repository.NodeRef) AuthenticationUtil(org.alfresco.repo.security.authentication.AuthenticationUtil) ResultSet(org.alfresco.service.cmr.search.ResultSet) DispositionSchedule(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule)

Example 15 with DispositionSchedule

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;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Serializable(java.io.Serializable) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) DispositionSchedule(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule)

Aggregations

DispositionSchedule (org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule)34 NodeRef (org.alfresco.service.cmr.repository.NodeRef)16 DispositionActionDefinition (org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition)10 QName (org.alfresco.service.namespace.QName)9 HashMap (java.util.HashMap)8 Serializable (java.io.Serializable)7 Date (java.util.Date)4 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 Test (org.junit.Test)3 WebScriptException (org.springframework.extensions.webscripts.WebScriptException)3 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 OutputStreamWriter (java.io.OutputStreamWriter)2 Writer (java.io.Writer)2 List (java.util.List)2 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)2 DispositionAction (org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction)2 DispositionScheduleImpl (org.alfresco.module.org_alfresco_module_rm.disposition.DispositionScheduleImpl)2