Search in sources :

Example 31 with DispositionSchedule

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

the class RMDispositionActionExecuterAbstractBase method checkDispositionActionExecutionValidity.

/**
 * @param nodeRef
 * @return
 */
protected DispositionSchedule checkDispositionActionExecutionValidity(NodeRef nodeRef, NodeRef nextDispositionActionNodeRef, boolean throwError) {
    // Check the node has associated disposition instructions
    DispositionSchedule di = getDispositionService().getDispositionSchedule(nodeRef);
    if (di == null) {
        if (throwError) {
            throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NO_DISPOITION_INSTRUCTIONS, getName(), nodeRef.toString()));
        } else {
            return null;
        }
    }
    // Check the node has the disposition schedule aspect applied
    if (!getNodeService().hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE)) {
        if (throwError) {
            throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NO_DIS_LIFECYCLE_SET, getName(), nodeRef.toString()));
        } else {
            return null;
        }
    }
    if (checkNextDispositionAction(nodeRef)) {
        // Check this the next disposition action
        NodeRef nextDispositionAction = nextDispositionActionNodeRef;
        if (nextDispositionAction == null) {
            if (throwError) {
                throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NEXT_DISP_NOT_SET, getName(), nodeRef.toString()));
            } else {
                return null;
            }
        }
        String actionName = (String) getNodeService().getProperty(nextDispositionAction, PROP_DISPOSITION_ACTION);
        if (actionName == null || !actionName.equals(getName())) {
            if (throwError) {
                throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NOT_NEXT_DISP, getName(), nodeRef.toString()));
            } else {
                return null;
            }
        }
    }
    return di;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) DispositionSchedule(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException)

Example 32 with DispositionSchedule

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

the class RMDispositionActionExecuterAbstractBase method executeImpl.

/**
 * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action,
 *      org.alfresco.service.cmr.repository.NodeRef)
 */
@Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {
    NodeRef nextDispositionActionNodeRef = getNextDispostionAction(actionedUponNodeRef);
    // determine whether we should be raising errors during state checking or not
    boolean checkError = true;
    Boolean checkErrorValue = (Boolean) action.getParameterValue(PARAM_NO_ERROR_CHECK);
    if (checkErrorValue != null) {
        checkError = checkErrorValue.booleanValue();
    }
    // Check the validity of the action (is it the next action, are we dealing with the correct type of object for
    // the disposition level?
    DispositionSchedule di = checkDispositionActionExecutionValidity(actionedUponNodeRef, nextDispositionActionNodeRef, checkError);
    if (di != null) {
        // Check the eligibility of the action
        if (!checkEligibility(actionedUponNodeRef) || getDispositionService().isNextDispositionActionEligible(actionedUponNodeRef)) {
            if (di.isRecordLevelDisposition()) {
                // Check that we do indeed have a record
                if (getRecordService().isRecord(actionedUponNodeRef)) {
                    // Can only execute disposition action on record if declared
                    if (getRecordService().isDeclared(actionedUponNodeRef)) {
                        // Indicate that the disposition action is underway
                        getNodeService().setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_STARTED_AT, new Date());
                        getNodeService().setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_STARTED_BY, AuthenticationUtil.getRunAsUser());
                        // Execute record level disposition
                        executeRecordLevelDisposition(action, actionedUponNodeRef);
                        if (getNodeService().exists(nextDispositionActionNodeRef) && getSetDispositionActionComplete()) {
                            getNodeService().setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_AT, new Date());
                            getNodeService().setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_BY, AuthenticationUtil.getRunAsUser());
                        }
                    } else {
                        throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_RECORD_NOT_DECLARED, getName(), actionedUponNodeRef.toString()));
                    }
                } else {
                    throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_EXPECTED_RECORD_LEVEL, getName(), actionedUponNodeRef.toString()));
                }
            } else {
                if (getRecordFolderService().isRecordFolder(actionedUponNodeRef)) {
                    if (getRecordFolderService().isRecordFolderDeclared(actionedUponNodeRef)) {
                        // Indicate that the disposition action is underway
                        getNodeService().setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_STARTED_AT, new Date());
                        getNodeService().setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_STARTED_BY, AuthenticationUtil.getRunAsUser());
                        executeRecordFolderLevelDisposition(action, actionedUponNodeRef);
                        // Indicate that the disposition action is compelte
                        if (getNodeService().exists(nextDispositionActionNodeRef) && getSetDispositionActionComplete()) {
                            getNodeService().setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_AT, new Date());
                            getNodeService().setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_BY, AuthenticationUtil.getRunAsUser());
                        }
                    } else {
                        throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NOT_ALL_RECORDS_DECLARED, getName(), actionedUponNodeRef.toString()));
                    }
                } else {
                    throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NOT_RECORD_FOLDER, getName(), actionedUponNodeRef.toString()));
                }
            }
            if (getNodeService().exists(actionedUponNodeRef) && getSetDispositionActionComplete()) {
                // Update the disposition schedule
                getDispositionService().updateNextDispositionAction(actionedUponNodeRef);
            }
        } else {
            throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NOT_ELIGIBLE, getName(), actionedUponNodeRef.toString()));
        }
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) DispositionSchedule(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) Date(java.util.Date)

Example 33 with DispositionSchedule

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

the class RMv22GhostOnDestroyDispositionActionPatch method getDispositionSchedules.

/**
 * Add the disposition schedule associated with the node ref to the passed
 * set of disposition schedule then call this method recursively for this
 * node's children
 *
 * @param nodeRef
 * @param dispositionSchedules
 */
private void getDispositionSchedules(NodeRef nodeRef, Set<DispositionSchedule> dispositionSchedules) {
    if (filePlanService.isRecordCategory(nodeRef)) {
        DispositionSchedule dispositionSchedule = this.dispositionService.getDispositionSchedule(nodeRef);
        if (dispositionSchedule != null) {
            dispositionSchedules.add(dispositionSchedule);
        }
        List<ChildAssociationRef> children = nodeService.getChildAssocs(nodeRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
        for (ChildAssociationRef childAssoc : children) {
            getDispositionSchedules(childAssoc.getChildRef(), dispositionSchedules);
        }
    }
}
Also used : DispositionSchedule(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Example 34 with DispositionSchedule

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

the class DispositionServiceImplTest method updateDispositionScheduleOnContainer.

private void updateDispositionScheduleOnContainer(NodeRef nodeRef) {
    Map<QName, Serializable> updateProps = new HashMap<QName, Serializable>(3);
    updateProps.put(PROP_DISPOSITION_PERIOD, "week|1");
    updateProps.put(PROP_DISPOSITION_EVENT, (Serializable) Arrays.asList(CommonRMTestUtils.DEFAULT_EVENT_NAME, "abolished"));
    DispositionSchedule ds = dispositionService.getDispositionSchedule(nodeRef);
    DispositionActionDefinition dad = ds.getDispositionActionDefinitionByName("cutoff");
    dispositionService.updateDispositionActionDefinition(dad, updateProps);
    publishDispositionActionDefinitionChange(dad);
}
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) 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