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;
}
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()));
}
}
}
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);
}
}
}
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);
}
Aggregations