RM action framework refactor

* simplifies RM action implementation
  * prevents execution of duplicate code



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@46547 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2013-02-12 23:23:56 +00:00
parent aad0c5b138
commit 607f28c48b
31 changed files with 70 additions and 951 deletions

View File

@@ -392,7 +392,7 @@ public abstract class RMActionExecuterAbstractBase extends ActionExecuterAbstra
*/
public RecordsManagementActionResult execute(NodeRef filePlanComponent, Map<String, Serializable> parameters)
{
isExecutableImpl(filePlanComponent, parameters, true);
//isExecutableImpl(filePlanComponent, parameters, true);
// Create the action
Action action = this.actionService.createAction(name);
@@ -440,21 +440,21 @@ public abstract class RMActionExecuterAbstractBase extends ActionExecuterAbstra
// No parameters
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction#isExecutable(org.alfresco.service.cmr.repository.NodeRef, java.util.Map)
*/
public boolean isExecutable(NodeRef filePlanComponent, Map<String, Serializable> parameters)
{
return isExecutableImpl(filePlanComponent, parameters, false);
}
/**
* @param filePlanComponent
* @param parameters
* @param throwException
* @return
*/
protected abstract boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException);
// /**
// * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction#isExecutable(org.alfresco.service.cmr.repository.NodeRef, java.util.Map)
// */
// public boolean isExecutable(NodeRef filePlanComponent, Map<String, Serializable> parameters)
// {
// return isExecutableImpl(filePlanComponent, parameters, false);
// }
//
// /**
// * @param filePlanComponent
// * @param parameters
// * @param throwException
// * @return
// */
// protected abstract boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException);
/**
* By default, rmActions do not provide an implicit target nodeRef.

View File

@@ -18,9 +18,7 @@
*/
package org.alfresco.module.org_alfresco_module_rm.action;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.alfresco.repo.action.executer.ActionExecuter;
import org.alfresco.service.cmr.action.Action;
@@ -47,16 +45,6 @@ public class RMDelegateAction extends RMActionExecuterAbstractBase
{
this.delegateActionExecuter = delegateActionExecuter;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#isExecutableImpl(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, boolean)
*/
@Override
protected boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException)
{
// always return true as we can't determine anything useful from the delegate action
return true;
}
/**
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)

View File

@@ -18,10 +18,8 @@
*/
package org.alfresco.module.org_alfresco_module_rm.action;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
@@ -89,7 +87,8 @@ public abstract class RMDispositionActionExecuterAbstractBase extends RMActionEx
DispositionSchedule di = checkDispositionActionExecutionValidity(actionedUponNodeRef, nextDispositionActionNodeRef, true);
// Check the eligibility of the action
if (checkEligibility == false || this.dispositionService.isNextDispositionActionEligible(actionedUponNodeRef) == true)
if (checkEligibility == false ||
dispositionService.isNextDispositionActionEligible(actionedUponNodeRef) == true)
{
if (di.isRecordLevelDisposition() == true)
{
@@ -151,7 +150,7 @@ public abstract class RMDispositionActionExecuterAbstractBase extends RMActionEx
}
else
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_EXPECTED_RECORD_LEVEL, getName(), actionedUponNodeRef.toString()));
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NOT_RECORD_FOLDER, getName(), actionedUponNodeRef.toString()));
}
}
@@ -269,122 +268,4 @@ public abstract class RMDispositionActionExecuterAbstractBase extends RMActionEx
}
return result;
}
// @Override
// public Set<QName> getProtectedProperties()
// {
// HashSet<QName> qnames = new HashSet<QName>();
// qnames.add(PROP_DISPOSITION_ACTION_STARTED_AT);
// qnames.add(PROP_DISPOSITION_ACTION_STARTED_BY);
// qnames.add(PROP_DISPOSITION_ACTION_COMPLETED_AT);
// qnames.add(PROP_DISPOSITION_ACTION_COMPLETED_BY);
// return qnames;
// }
@Override
protected boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException)
{
// Check the validity of the action (is it the next action, are we dealing with the correct type of object for
// the disposition level?
//
NodeRef nextDispositionActionNodeRef = getNextDispostionAction(filePlanComponent);
DispositionSchedule di = checkDispositionActionExecutionValidity(filePlanComponent, nextDispositionActionNodeRef, throwException);
if(di == null)
{
if (throwException)
{
throw new AlfrescoRuntimeException("Null disposition");
}
else
{
return false;
}
}
// Check the eligibility of the action
if (checkEligibility == false || this.dispositionService.isNextDispositionActionEligible(filePlanComponent) == true)
{
if (di.isRecordLevelDisposition() == true)
{
// Check that we do indeed have a record
if (recordService.isRecord(filePlanComponent) == true)
{
// Can only execute disposition action on record if declared
if (recordService.isDeclared(filePlanComponent) == true)
{
return true;
}
else
{
if (throwException)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_RECORD_NOT_DECLARED, getName(), filePlanComponent.toString()));
}
else
{
return false;
}
}
}
else
{
if (throwException)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_EXPECTED_RECORD_LEVEL, getName(), filePlanComponent.toString()));
}
else
{
return false;
}
}
}
else
{
if (this.recordsManagementService.isRecordFolder(filePlanComponent) == true)
{
if (this.recordsManagementService.isRecordFolderDeclared(filePlanComponent) == true)
{
return true;
}
else
{
if (throwException)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NOT_ALL_RECORDS_DECLARED, getName(), filePlanComponent.toString()));
}
else
{
return false;
}
}
}
else
{
if (throwException)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NOT_RECORD_FOLDER, getName(), filePlanComponent.toString()));
}
else
{
return false;
}
}
}
}
else
{
if (throwException)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NOT_ELIGIBLE, getName(), filePlanComponent.toString()));
}
else
{
return false;
}
}
}
}

View File

@@ -76,23 +76,7 @@ public interface RecordsManagementAction
* @param parameters action parameters
* @return
*/
public boolean isExecutable(NodeRef filePlanComponent, Map<String, Serializable> parameters);
/**
* Get a set of properties that should only be updated via this or other action.
* These properties will be rejected by updates via the generic public services, such as the NodeService.
*
* @return the set of protected properties
*/
//public Set<QName> getProtectedProperties();
/**
* Get a set of aspects that should be updated via this or other actions.
* The aspect can not be added via public services, such as the NodeService.
* @return
*/
//public Set<QName> getProtectedAspects();
// public boolean isExecutable(NodeRef filePlanComponent, Map<String, Serializable> parameters);
/**
* Some admin-related rmActions execute against a target nodeRef which is not provided

View File

@@ -69,9 +69,16 @@ public class ApplyCustomTypeAction extends RMActionExecuterAbstractBase
logger.debug("Executing action [" + action.getActionDefinitionName() + "] on " + actionedUponNodeRef);
}
// Apply the appropriate aspect and set the properties.
Map<QName, Serializable> aspectProps = getPropertyValues(action);
this.nodeService.addAspect(actionedUponNodeRef, customTypeAspect, aspectProps);
if (recordService.isRecord(actionedUponNodeRef) == true)
{
// Apply the appropriate aspect and set the properties.
Map<QName, Serializable> aspectProps = getPropertyValues(action);
this.nodeService.addAspect(actionedUponNodeRef, customTypeAspect, aspectProps);
}
else if (logger.isWarnEnabled() == true)
{
logger.warn(I18NUtil.getMessage(MSG_ACTIONED_UPON_NOT_RECORD, this.getClass().getSimpleName(), actionedUponNodeRef.toString()));
}
}
/**
@@ -109,27 +116,6 @@ public class ApplyCustomTypeAction extends RMActionExecuterAbstractBase
return result;
}
@Override
public boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException)
{
if (recordService.isRecord(filePlanComponent))
{
return true;
}
else
{
if (throwException)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_ACTIONED_UPON_NOT_RECORD, this.getClass().getSimpleName(), filePlanComponent.toString()));
}
else
{
return false;
}
}
}
@Override
protected synchronized List<ParameterDefinition> getParameterDefintions()
{

View File

@@ -321,16 +321,9 @@ public class BroadcastDispositionActionDefinitionUpdateAction extends RMActionEx
}
}
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
// Intentionally empty
}
@Override
public boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException)
{
return true;
}
}

View File

@@ -18,14 +18,9 @@
*/
package org.alfresco.module.org_alfresco_module_rm.action.impl;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.springframework.extensions.surf.util.I18NUtil;
@@ -60,34 +55,4 @@ public class CloseRecordFolderAction extends RMActionExecuterAbstractBase
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CLOSE_RECORD_FOLDER_NOT_FOLDER, actionedUponNodeRef.toString()));
}
}
/**
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
*/
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
// TODO Auto-generated method stub
}
@Override
protected boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException)
{
if (this.recordsManagementService.isRecordFolder(filePlanComponent))
{
return true;
}
else
{
if (throwException)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CLOSE_RECORD_FOLDER_NOT_FOLDER, filePlanComponent.toString()));
}
else
{
return false;
}
}
}
}

View File

@@ -28,7 +28,6 @@ import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstrac
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.springframework.extensions.surf.util.I18NUtil;
@@ -108,80 +107,4 @@ public class CompleteEventAction extends RMActionExecuterAbstractBase
}
return result;
}
/**
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
*/
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
// TODO add parameter definitions ....
// eventId, executeBy, executedAt
}
// @Override
// public Set<QName> getProtectedProperties()
// {
// HashSet<QName> qnames = new HashSet<QName>();
// qnames.add(PROP_EVENT_EXECUTION_COMPLETE);
// qnames.add(PROP_EVENT_EXECUTION_COMPLETED_AT);
// qnames.add(PROP_EVENT_EXECUTION_COMPLETED_BY);
// return qnames;
// }
// @Override
// public Set<QName> getProtectedAspects()
// {
// HashSet<QName> qnames = new HashSet<QName>();
// qnames.add(ASPECT_DISPOSITION_LIFECYCLE);
// return qnames;
// }
@Override
protected boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException)
{
String eventName = null;
if(parameters != null)
{
eventName = (String) parameters.get(PARAM_EVENT_NAME);
}
if (this.nodeService.hasAspect(filePlanComponent, ASPECT_DISPOSITION_LIFECYCLE))
{
// Get the next disposition action
DispositionAction da = this.dispositionService.getNextDispositionAction(filePlanComponent);
if (da != null)
{
// Get the disposition event
if(parameters != null)
{
EventCompletionDetails event = getEvent(da, eventName);
if (event != null)
{
return true;
}
else
{
if (throwException)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_EVENT_NO_DISP_LC, eventName));
}
else
{
return false;
}
}
}
else
{
return true;
}
}
}
return false;
}
}

View File

@@ -18,9 +18,6 @@
*/
package org.alfresco.module.org_alfresco_module_rm.action.impl;
import java.io.Serializable;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
@@ -45,29 +42,14 @@ public class CreateDispositionScheduleAction extends RMActionExecuterAbstractBas
@Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
{
// Create the disposition schedule
dispositionService.createDispositionSchedule(actionedUponNodeRef, null);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#isExecutableImpl(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, boolean)
*/
@Override
public boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException)
{
boolean result = true;
if (recordsManagementService.isRecordCategory(filePlanComponent) == false)
if (recordsManagementService.isRecordCategory(actionedUponNodeRef) == true)
{
if (throwException == true)
{
throw new AlfrescoRuntimeException("The disposition schedule could not be created, because the actioned upon node was not a record category.");
}
else
{
result = false;
}
// Create the disposition schedule
dispositionService.createDispositionSchedule(actionedUponNodeRef, null);
}
return result;
}
else
{
throw new AlfrescoRuntimeException("The disposition schedule could not be created, because the actioned upon node was not a record category.");
}
}
}

View File

@@ -24,12 +24,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.springframework.extensions.surf.util.I18NUtil;
/**
* Cut off disposition action
@@ -38,8 +36,6 @@ import org.springframework.extensions.surf.util.I18NUtil;
*/
public class CutOffAction extends RMDispositionActionExecuterAbstractBase
{
private static final String MSG_ERR = "rm.action.close-record-folder-not-folder";
/**
* @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#executeRecordFolderLevelDisposition(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
*/
@@ -89,33 +85,4 @@ public class CutOffAction extends RMDispositionActionExecuterAbstractBase
this.nodeService.addAspect(nodeRef, ASPECT_CUT_OFF, cutOffProps);
}
}
@Override
protected boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException)
{
if(!super.isExecutableImpl(filePlanComponent, parameters, throwException))
{
return false;
}
// duplicates code from close .. it should get the closed action somehow?
if (recordsManagementService.isRecordFolder(filePlanComponent)
|| recordService.isRecord(filePlanComponent))
{
return true;
}
else
{
if (throwException)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_ERR, filePlanComponent.toString()));
}
else
{
return false;
}
}
}
}

View File

@@ -174,37 +174,4 @@ public class DeclareRecordAction extends RMActionExecuterAbstractBase
}
missingProperties.add(propDef.getName().toString());
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#isExecutableImpl(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, boolean)
*/
@Override
protected boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException)
{
if (recordService.isRecord(filePlanComponent) == true)
{
if (recordService.isDeclared(filePlanComponent) == false)
{
// Aspect not already defined - check mandatory properties then add
List<String> missingProperties = new ArrayList<String>(10);
if (mandatoryPropertiesSet(filePlanComponent, missingProperties) == true)
{
return true;
}
}
return false;
}
else
{
if (throwException)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_UNDECLARED_ONLY_RECORDS, filePlanComponent.toString()));
}
else
{
return false;
}
}
}
}

View File

@@ -18,16 +18,12 @@
*/
package org.alfresco.module.org_alfresco_module_rm.action.impl;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -74,35 +70,9 @@ public class EditDispositionActionAsOfDateAction extends RMActionExecuterAbstrac
nodeService.setProperty(da.getNodeRef(), PROP_DISPOSITION_AS_OF, asOfDate);
}
}
}
/**
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
*/
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
// Intentionally empty
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#isExecutableImpl(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, boolean)
*/
@Override
protected boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException)
{
boolean result = false;
if (this.nodeService.hasAspect(filePlanComponent, ASPECT_DISPOSITION_LIFECYCLE) == true)
{
result = true;
}
else
{
if (throwException == true)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_DISP_ASOF_LIFECYCLE_APPLIED));
}
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_DISP_ASOF_LIFECYCLE_APPLIED));
}
return result;
}
}

View File

@@ -18,9 +18,6 @@
*/
package org.alfresco.module.org_alfresco_module_rm.action.impl;
import java.io.Serializable;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
@@ -64,28 +61,4 @@ public class EditHoldReasonAction extends RMActionExecuterAbstractBase
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_HOLD_EDIT_TYPE, TYPE_HOLD.toString(), actionedUponNodeRef.toString()));
}
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#isExecutableImpl(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, boolean)
*/
@Override
protected boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException)
{
if (freezeService.isHold(filePlanComponent) == true)
{
return true;
}
else
{
if (throwException)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_HOLD_EDIT_TYPE, TYPE_HOLD.toString(), filePlanComponent.toString()));
}
else
{
return false;
}
}
}
}

View File

@@ -18,15 +18,11 @@
*/
package org.alfresco.module.org_alfresco_module_rm.action.impl;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -70,34 +66,9 @@ public class EditReviewAsOfDateAction extends RMActionExecuterAbstractBase
this.nodeService.setProperty(actionedUponNodeRef, PROP_REVIEW_AS_OF, reviewAsOf);
}
else
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_REVIEW_DETAILS_ONLY));
}
}
/**
*
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
*/
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
// Intentionally empty
}
@Override
protected boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException)
{
boolean result = false;
if (recordService.isRecord(filePlanComponent) == true &&
nodeService.hasAspect(filePlanComponent, ASPECT_VITAL_RECORD) == true)
{
result = true;
}
else
{
if (throwException == true)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_REVIEW_DETAILS_ONLY));
}
}
return result;
}
}

View File

@@ -18,14 +18,9 @@
*/
package org.alfresco.module.org_alfresco_module_rm.action.impl;
import java.io.Serializable;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.repository.NodeRef;
import org.springframework.extensions.surf.util.I18NUtil;
/**
* Freeze Action
@@ -34,9 +29,6 @@ import org.springframework.extensions.surf.util.I18NUtil;
*/
public class FreezeAction extends RMActionExecuterAbstractBase
{
private static final String MSG_FREEZE_NO_REASON = "rm.action.freeze-no-reason";
private static final String MSG_FREEZE_ONLY_RECORDS_FOLDERS = "rm.action.freeze-only-records-folders";
/** Parameter names */
public static final String PARAM_REASON = "reason";
@@ -48,45 +40,4 @@ public class FreezeAction extends RMActionExecuterAbstractBase
{
freezeService.freeze((String) action.getParameterValue(PARAM_REASON), actionedUponNodeRef);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#isExecutableImpl(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, boolean)
*/
@Override
protected boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException)
{
if (this.recordService.isRecord(filePlanComponent) == true ||
this.recordsManagementService.isRecordFolder(filePlanComponent) == true)
{
// Get the property values
if(parameters != null)
{
String reason = (String)parameters.get(PARAM_REASON);
if (reason == null || reason.length() == 0)
{
if(throwException)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_FREEZE_NO_REASON));
}
else
{
return false;
}
}
}
return true;
}
else
{
if(throwException)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_FREEZE_ONLY_RECORDS_FOLDERS));
}
else
{
return false;
}
}
}
}

View File

@@ -18,14 +18,9 @@
*/
package org.alfresco.module.org_alfresco_module_rm.action.impl;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.springframework.extensions.surf.util.I18NUtil;
@@ -45,6 +40,7 @@ public class OpenRecordFolderAction extends RMActionExecuterAbstractBase
@Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
{
// TODO move re-open logic into a service method
// TODO check that the user in question has the correct permission to re-open a records folder
if (this.recordsManagementService.isRecordFolder(actionedUponNodeRef) == true)
@@ -60,34 +56,4 @@ public class OpenRecordFolderAction extends RMActionExecuterAbstractBase
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NO_OPEN_RECORD_FOLDER, actionedUponNodeRef.toString()));
}
}
/**
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
*/
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
// TODO Auto-generated method stub
}
@Override
protected boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException)
{
if (this.recordsManagementService.isRecordFolder(filePlanComponent) == true)
{
return true;
}
else
{
if (throwException)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NO_OPEN_RECORD_FOLDER, filePlanComponent.toString()));
}
else
{
return false;
}
}
}
}

View File

@@ -18,15 +18,9 @@
*/
package org.alfresco.module.org_alfresco_module_rm.action.impl;
import java.io.Serializable;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.repository.NodeRef;
import org.apache.commons.lang.StringUtils;
import org.springframework.extensions.surf.util.I18NUtil;
/**
* Reject action for an unfiled record
@@ -36,10 +30,6 @@ import org.springframework.extensions.surf.util.I18NUtil;
*/
public class RejectAction extends RMActionExecuterAbstractBase
{
/** Message properties */
private static final String MSG_REJECT_NO_REASON = "rm.action.reject-no-reason";
private static final String MSG_REJECT_ONLY_UNFILED_RECORDS = "rm.action.reject-only-unfiled-records";
/** Parameter names */
public static final String PARAM_REASON = "reason";
@@ -54,42 +44,4 @@ public class RejectAction extends RMActionExecuterAbstractBase
{
recordService.rejectRecord(actionedUponNodeRef, (String) action.getParameterValue(PARAM_REASON));
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#isExecutableImpl(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, boolean)
*/
@Override
protected boolean isExecutableImpl(NodeRef filePlanComponent,
Map<String, Serializable> parameters, boolean throwException)
{
if (recordService.isRecord(filePlanComponent) == true && recordService.isFiled(filePlanComponent) == false)
{
if (parameters != null && StringUtils.isNotBlank((String) parameters.get(PARAM_REASON)))
{
return true;
}
else
{
if (throwException)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_REJECT_NO_REASON));
}
else
{
return false;
}
}
}
else
{
if (throwException)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_REJECT_ONLY_UNFILED_RECORDS));
}
else
{
return false;
}
}
}
}

View File

@@ -18,9 +18,6 @@
*/
package org.alfresco.module.org_alfresco_module_rm.action.impl;
import java.io.Serializable;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
@@ -52,28 +49,4 @@ public class RelinquishHoldAction extends RMActionExecuterAbstractBase
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NOT_HOLD_TYPE, TYPE_HOLD.toString(), actionedUponNodeRef.toString()));
}
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#isExecutableImpl(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, boolean)
*/
@Override
protected boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException)
{
if (freezeService.isHold(filePlanComponent) == true)
{
return true;
}
else
{
if (throwException)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NOT_HOLD_TYPE, TYPE_HOLD.toString(), filePlanComponent.toString()));
}
else
{
return false;
}
}
}
}

View File

@@ -169,37 +169,6 @@ public class SplitEmailAction extends RMActionExecuterAbstractBase
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_EMAIL_NOT_RECORD, actionedUponNodeRef.toString()));
}
}
@Override
protected boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException)
{
if (recordService.isRecord(filePlanComponent) == true)
{
if (recordService.isDeclared(filePlanComponent))
{
if (throwException)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_EMAIL_DECLARED, filePlanComponent.toString()));
}
else
{
return false;
}
}
}
else
{
if (throwException)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_EMAIL_NOT_RECORD, filePlanComponent.toString()));
}
else
{
return false;
}
}
return true;
}
/**
* Create attachment from Mime Message Part

View File

@@ -51,7 +51,7 @@ public class TransferAction extends RMDispositionActionExecuterAbstractBase
public static final String KEY_TRANSFER_NODEREF = "transferNodeRef";
/** I18N */
public static final String MSG_NODE_ALREADY_TRANSFER = "rm.action.node-already-transfer";
private static final String MSG_NODE_ALREADY_TRANSFER = "rm.action.node-already-transfer";
/** Indicates whether the transfer is an accession or not */
private boolean isAccession = false;
@@ -139,6 +139,19 @@ public class TransferAction extends RMDispositionActionExecuterAbstractBase
// Bind the hold node reference to the transaction
AlfrescoTransactionSupport.bindResource(KEY_TRANSFER_NODEREF, transferNodeRef);
}
else
{
// ensure this node has not already in the process of being transferred
List<ChildAssociationRef> transferredAlready = nodeService.getChildAssocs(transferNodeRef, ASSOC_TRANSFERRED, ASSOC_TRANSFERRED);
for(ChildAssociationRef car : transferredAlready)
{
if(car.getChildRef().equals(dispositionLifeCycleNodeRef) == true)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NODE_ALREADY_TRANSFER, dispositionLifeCycleNodeRef.toString()));
}
}
}
// Link the record to the trasnfer object
this.nodeService.addChild(transferNodeRef,
@@ -182,38 +195,4 @@ public class TransferAction extends RMDispositionActionExecuterAbstractBase
}
}
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#isExecutableImpl(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, boolean)
*/
@Override
protected boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException)
{
if(!super.isExecutableImpl(filePlanComponent, parameters, throwException))
{
// super will throw ...
return false;
}
NodeRef transferNodeRef = (NodeRef)AlfrescoTransactionSupport.getResource(KEY_TRANSFER_NODEREF);
if (transferNodeRef != null)
{
List<ChildAssociationRef> transferredAlready = nodeService.getChildAssocs(transferNodeRef, ASSOC_TRANSFERRED, ASSOC_TRANSFERRED);
for(ChildAssociationRef car : transferredAlready)
{
if(car.getChildRef().equals(filePlanComponent))
{
if (throwException)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NODE_ALREADY_TRANSFER, filePlanComponent.toString()));
}
else
{
return false;
}
}
}
}
return true;
}
}

View File

@@ -18,10 +18,8 @@
*/
package org.alfresco.module.org_alfresco_module_rm.action.impl;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
@@ -44,25 +42,6 @@ public class TransferCompleteAction extends RMActionExecuterAbstractBase
{
/** I18N */
private static final String MSG_NODE_NOT_TRANSFER = "rm.action.node-not-transfer";
/**
* @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#isExecutableImpl(org.alfresco.service.cmr.repository.NodeRef,
* java.util.Map, boolean)
*/
@Override
protected boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException)
{
QName className = this.nodeService.getType(filePlanComponent);
if (this.dictionaryService.isSubClass(className, TYPE_TRANSFER) == true)
{
return true;
}
else
{
List<ChildAssociationRef> assocs = this.nodeService.getParentAssocs(filePlanComponent, ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL);
return assocs.size() > 0;
}
}
/**
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action,

View File

@@ -18,9 +18,7 @@
*/
package org.alfresco.module.org_alfresco_module_rm.action.impl;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
@@ -85,44 +83,5 @@ public class UnCutoffAction extends RMActionExecuterAbstractBase
}
}
}
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#isExecutableImpl(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, boolean)
*/
@Override
protected boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException)
{
boolean result = true;
if (nodeService.hasAspect(filePlanComponent, ASPECT_DISPOSITION_LIFECYCLE) == true &&
nodeService.hasAspect(filePlanComponent, ASPECT_CUT_OFF) == true)
{
// Get the last disposition action
DispositionAction da = dispositionService.getLastCompletedDispostionAction(filePlanComponent);
// Check that the last disposition action was a cutoff
if (da == null || da.getName().equals("cutoff") == false)
{
if (throwException == true)
{
// Can not undo cut off since cut off was not the last thing done
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_UNDO_NOT_LAST));
}
result = false;
}
}
else
{
if (throwException == true)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_UNDO_NOT_LAST));
}
result = false;
}
return result;
}
}
}

View File

@@ -18,9 +18,6 @@
*/
package org.alfresco.module.org_alfresco_module_rm.action.impl;
import java.io.Serializable;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
@@ -55,31 +52,5 @@ public class UndeclareRecordAction extends RMActionExecuterAbstractBase
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_RECORDS_ONLY_UNDECLARED));
}
}
@Override
protected boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException)
{
if (recordService.isRecord(filePlanComponent) == true)
{
if (recordService.isDeclared(filePlanComponent) == true)
{
return true;
}
return false;
}
else
{
if(throwException)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_RECORDS_ONLY_UNDECLARED));
}
else
{
return false;
}
}
}
}
}

View File

@@ -84,7 +84,7 @@ public class UndoEventAction extends RMActionExecuterAbstractBase
}
/**
* Get the event from the dispostion action
* Get the event from the disposition action
*
* @param da
* @param eventName
@@ -153,47 +153,5 @@ public class UndoEventAction extends RMActionExecuterAbstractBase
// TODO add parameter definitions ....
// eventName
}
@Override
protected boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException)
{
String eventName = null;
if(parameters != null)
{
eventName = (String)parameters.get(PARAM_EVENT_NAME);
}
if (this.nodeService.hasAspect(filePlanComponent, ASPECT_DISPOSITION_LIFECYCLE) == true)
{
// Get the next disposition action
DispositionAction da = this.dispositionService.getNextDispositionAction(filePlanComponent);
if (da != null)
{
// Get the disposition event
if(parameters != null)
{
EventCompletionDetails event = getEvent(da, eventName);
if (event != null)
{
return true;
}
else
{
if(throwException)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_EVENT_NOT_DONE, eventName));
}
}
}
else
{
return true;
}
}
}
return false;
}
}
}

View File

@@ -18,9 +18,6 @@
*/
package org.alfresco.module.org_alfresco_module_rm.action.impl;
import java.io.Serializable;
import java.util.Map;
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -40,14 +37,4 @@ public class UnfreezeAction extends RMActionExecuterAbstractBase
{
freezeService.unFreeze(actionedUponNodeRef);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#isExecutableImpl(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, boolean)
*/
@Override
protected boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException)
{
return freezeService.isFrozen(filePlanComponent);
}
}

View File

@@ -21,7 +21,6 @@ package org.alfresco.module.org_alfresco_module_rm.job;
import java.util.List;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
@@ -114,19 +113,10 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
ChildAssociationRef parent = nodeService.getPrimaryParent(currentNode);
if (parent.getTypeQName().equals(RecordsManagementModel.ASSOC_NEXT_DISPOSITION_ACTION))
{
// Check that the action is executable
RecordsManagementAction rmAction = recordsManagementActionService.getDispositionAction(dispAction);
if (rmAction.isExecutable(parent.getParentRef(), null) == true)
recordsManagementActionService.executeRecordsManagementAction(parent.getParentRef(), dispAction);
if (logger.isDebugEnabled())
{
recordsManagementActionService.executeRecordsManagementAction(parent.getParentRef(), dispAction);
if (logger.isDebugEnabled())
{
logger.debug("Processed action: " + dispAction + "on" + parent);
}
}
else
{
logger.debug("The disposition action " + dispAction + " is not executable.");
logger.debug("Processed action: " + dispAction + "on" + parent);
}
}
return null;

View File

@@ -27,7 +27,6 @@ import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.Period;
@@ -55,14 +54,10 @@ public class BroadcastVitalRecordDefinitionAction extends RMActionExecuterAbstra
}
/**
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
* Propagates the changes to the children of the node specified.
*
* @param actionedUponNodeRef actioned upon node reference
*/
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
// Intentionally empty
}
private void propagateChangeToChildrenOf(NodeRef actionedUponNodeRef)
{
Map<QName, Serializable> parentProps = nodeService.getProperties(actionedUponNodeRef);
@@ -106,10 +101,4 @@ public class BroadcastVitalRecordDefinitionAction extends RMActionExecuterAbstra
}
}
}
@Override
public boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException)
{
return true;
}
}

View File

@@ -18,14 +18,10 @@
*/
package org.alfresco.module.org_alfresco_module_rm.vital;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -91,20 +87,4 @@ public class ReviewedAction extends RMActionExecuterAbstractBase
//TODO And record previous review date, time, user
}
}
/**
*
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
*/
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
// Intentionally empty
}
@Override
protected boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException)
{
return true;
}
}