Search in sources :

Example 16 with DispositionSchedule

use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule in project records-management by Alfresco.

the class UpdateNextDispositionActionTest method createDispositionSchedule.

private void createDispositionSchedule(NodeRef category) {
    DispositionSchedule ds = utils.createDispositionSchedule(category, DEFAULT_DISPOSITION_INSTRUCTIONS, DEFAULT_DISPOSITION_DESCRIPTION, true, false, false);
    // create the properties for CUTOFF action and add it to the disposition action definition
    Map<QName, Serializable> cutOff = new HashMap<QName, Serializable>(3);
    cutOff.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME);
    cutOff.put(PROP_DISPOSITION_DESCRIPTION, generate());
    cutOff.put(PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
    dispositionService.addDispositionActionDefinition(ds, cutOff);
    // create the properties for TRANSFER action and add it to the disposition action definition
    Map<QName, Serializable> transfer = new HashMap<QName, Serializable>(3);
    transfer.put(PROP_DISPOSITION_ACTION_NAME, TransferAction.NAME);
    transfer.put(PROP_DISPOSITION_DESCRIPTION, generate());
    transfer.put(PROP_DISPOSITION_EVENT, (Serializable) Collections.singletonList(DEFAULT_EVENT_NAME));
    dispositionService.addDispositionActionDefinition(ds, transfer);
    // create the properties for DESTROY action and add it to the disposition action definition
    Map<QName, Serializable> destroy = new HashMap<QName, Serializable>(3);
    destroy.put(PROP_DISPOSITION_ACTION_NAME, DestroyAction.NAME);
    destroy.put(PROP_DISPOSITION_DESCRIPTION, generate());
    destroy.put(PROP_DISPOSITION_PERIOD, PERIOD_ONE_WEEK);
    dispositionService.addDispositionActionDefinition(ds, destroy);
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) DispositionSchedule(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule)

Example 17 with DispositionSchedule

use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule in project records-management by Alfresco.

the class RM1008Test method testTransfer.

public void testTransfer() {
    final NodeRef transferFolder = doTestInTransaction(new Test<NodeRef>() {

        @Override
        public NodeRef run() {
            NodeRef transferCat = filePlanService.createRecordCategory(filePlan, "transferCat");
            Map<QName, Serializable> dsProps = new HashMap<QName, Serializable>(3);
            dsProps.put(PROP_DISPOSITION_AUTHORITY, "test");
            dsProps.put(PROP_DISPOSITION_INSTRUCTIONS, "test");
            dsProps.put(PROP_RECORD_LEVEL_DISPOSITION, false);
            DispositionSchedule dispositionSchedule = dispositionService.createDispositionSchedule(transferCat, dsProps);
            Map<QName, Serializable> adParams = new HashMap<QName, Serializable>(3);
            adParams.put(PROP_DISPOSITION_ACTION_NAME, "cutoff");
            adParams.put(PROP_DISPOSITION_DESCRIPTION, "test");
            adParams.put(PROP_DISPOSITION_PERIOD, "immediately|0");
            dispositionService.addDispositionActionDefinition(dispositionSchedule, adParams);
            adParams = new HashMap<QName, Serializable>(3);
            adParams.put(PROP_DISPOSITION_ACTION_NAME, "transfer");
            adParams.put(PROP_DISPOSITION_DESCRIPTION, "test");
            adParams.put(PROP_DISPOSITION_PERIOD, "immediately|0");
            dispositionService.addDispositionActionDefinition(dispositionSchedule, adParams);
            return recordFolderService.createRecordFolder(transferCat, "transferFolder");
        }
    });
    final NodeRef transfer = doTestInTransaction(new Test<NodeRef>() {

        @Override
        public NodeRef run() {
            rmActionService.executeRecordsManagementAction(transferFolder, "cutoff");
            rmActionService.executeRecordsManagementAction(transferFolder, "transfer");
            NodeRef transferContainer = filePlanService.getTransferContainer(filePlan);
            List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(transferContainer, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
            return childAssocs.get(0).getChildRef();
        }

        @Override
        public void test(NodeRef result) throws Exception {
            assertNotNull(result);
            assertEquals(TYPE_TRANSFER, nodeService.getType(result));
        }
    });
    doTestInTransaction(new Test<Void>() {

        @Override
        public Void run() {
            Capability viewRecords = capabilityService.getCapability("ViewRecords");
            assertNotNull(viewRecords);
            assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(transfer));
            assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(transfer, RMPermissionModel.FILING));
            return null;
        }
    }, ADMIN_USER);
    doTestInTransaction(new Test<Void>() {

        @Override
        public Void run() {
            Capability viewRecords = capabilityService.getCapability("ViewRecords");
            assertNotNull(viewRecords);
            assertEquals(AccessStatus.DENIED, viewRecords.hasPermission(transfer));
            assertEquals(AccessStatus.DENIED, permissionService.hasPermission(transfer, RMPermissionModel.FILING));
            return null;
        }
    }, myUser);
    doTestInTransaction(new Test<Void>() {

        @Override
        public Void run() {
            filePlanPermissionService.setPermission(filePlan, myUser, FILING);
            return null;
        }
    }, ADMIN_USER);
    doTestInTransaction(new Test<Void>() {

        @Override
        public Void run() {
            Capability viewRecords = capabilityService.getCapability("ViewRecords");
            assertNotNull(viewRecords);
            assertEquals(AccessStatus.DENIED, viewRecords.hasPermission(transfer));
            assertEquals(AccessStatus.DENIED, permissionService.hasPermission(transfer, RMPermissionModel.READ_RECORDS));
            assertEquals(AccessStatus.DENIED, permissionService.hasPermission(transfer, RMPermissionModel.FILING));
            return null;
        }
    }, myUser);
    doTestInTransaction(new Test<Void>() {

        @Override
        public Void run() {
            filePlanPermissionService.deletePermission(filePlan, myUser, FILING);
            return null;
        }
    }, ADMIN_USER);
    doTestInTransaction(new Test<Void>() {

        @Override
        public Void run() {
            Capability viewRecords = capabilityService.getCapability("ViewRecords");
            assertNotNull(viewRecords);
            assertEquals(AccessStatus.DENIED, viewRecords.hasPermission(transfer));
            assertEquals(AccessStatus.DENIED, permissionService.hasPermission(transfer, RMPermissionModel.FILING));
            return null;
        }
    }, myUser);
}
Also used : Serializable(java.io.Serializable) Capability(org.alfresco.module.org_alfresco_module_rm.capability.Capability) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) DispositionSchedule(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule) NodeRef(org.alfresco.service.cmr.repository.NodeRef) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 18 with DispositionSchedule

use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule in project records-management by Alfresco.

the class IsClassifiedCapabilityCondition method evaluateImpl.

/**
 * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef)
 */
@Override
public boolean evaluateImpl(NodeRef nodeRef) {
    boolean result = false;
    DispositionSchedule dispositionSchedule = dispositionService.getDispositionSchedule(nodeRef);
    if (dispositionSchedule != null) {
        result = true;
    }
    return result;
}
Also used : DispositionSchedule(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule)

Example 19 with DispositionSchedule

use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule in project records-management by Alfresco.

the class DispositionActionDefinitionDelete method executeImpl.

/*
     * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
     */
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
    // parse the request to retrieve the schedule object
    DispositionSchedule schedule = parseRequestForSchedule(req);
    // parse the request to retrieve the action definition object
    DispositionActionDefinition actionDef = parseRequestForActionDefinition(req, schedule);
    // remove the action definition from the schedule
    removeDispositionActionDefinitions(schedule, actionDef);
    // return the disposition schedule model
    return getDispositionScheduleModel(req);
}
Also used : DispositionSchedule(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule) DispositionActionDefinition(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition)

Example 20 with DispositionSchedule

use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule in project records-management by Alfresco.

the class MayBeScheduledCapabilityCondition method evaluateImpl.

/**
 * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef)
 */
@Override
public boolean evaluateImpl(NodeRef nodeRef) {
    boolean result = false;
    DispositionSchedule dispositionSchedule = dispositionService.getDispositionSchedule(nodeRef);
    if (dispositionSchedule != null && checkDispositionLevel(nodeRef, dispositionSchedule)) {
        for (DispositionActionDefinition dispositionActionDefinition : dispositionSchedule.getDispositionActionDefinitions()) {
            if (dispositionActionDefinition.getName().equals(dispositionAction)) {
                result = true;
                break;
            }
        }
    }
    return result;
}
Also used : DispositionSchedule(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule) DispositionActionDefinition(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition)

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