From 276066fb888be1973d41957e7ffb9e33333ada20 Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Thu, 11 Apr 2013 14:55:30 +0000 Subject: [PATCH] RM-631 (The records management team can create a rule to request information about an undeclared record) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@49119 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../action/impl/RequestInfoAction.java | 16 ++++++++++++- .../alfresco/workflow/RMWorkflowModel.java | 3 +++ .../requestInfo/RequestInfoUtils.java | 24 +++++++++++++++---- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/RequestInfoAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/RequestInfoAction.java index 74d1918638..c9630991bb 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/RequestInfoAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/RequestInfoAction.java @@ -48,6 +48,7 @@ public class RequestInfoAction extends RMActionExecuterAbstractBase /** Parameter names */ public static final String PARAM_REQUESTED_INFO = "requestedInfo"; public static final String PARAM_ASSIGNEES = "assignees"; + public static final String PARAM_RULE_CREATOR = "ruleCreator"; /** Action name */ public static final String NAME = "requestInfo"; @@ -78,6 +79,7 @@ public class RequestInfoAction extends RMActionExecuterAbstractBase parameters.put(WorkflowModel.ASSOC_PACKAGE, getWorkflowPackage(action, actionedUponNodeRef)); parameters.put(RMWorkflowModel.RM_MIXED_ASSIGNEES, getAssignees(action)); parameters.put(RMWorkflowModel.RM_REQUESTED_INFORMATION, getRequestedInformation(action)); + parameters.put(RMWorkflowModel.RM_RULE_CREATOR, getRuleCreator(action)); workflowService.startWorkflow(workflowDefinitionId, parameters); } @@ -90,6 +92,7 @@ public class RequestInfoAction extends RMActionExecuterAbstractBase { paramList.add(new ParameterDefinitionImpl(PARAM_REQUESTED_INFO, DataTypeDefinition.TEXT, true, getParamDisplayLabel(PARAM_REQUESTED_INFO))); paramList.add(new ParameterDefinitionImpl(PARAM_ASSIGNEES, DataTypeDefinition.ANY, true, getParamDisplayLabel(PARAM_ASSIGNEES))); + paramList.add(new ParameterDefinitionImpl(PARAM_RULE_CREATOR, DataTypeDefinition.TEXT, true, getParamDisplayLabel(PARAM_RULE_CREATOR))); } /** @@ -130,11 +133,22 @@ public class RequestInfoAction extends RMActionExecuterAbstractBase * Helper method for getting the requested information from the action * * @param action The request info action - * @return Return the requested information + * @return Returns the requested information */ private Serializable getRequestedInformation(Action action) { return action.getParameterValue(PARAM_REQUESTED_INFO); } + /** + * Helper method for getting the rule creator + * + * @param action The request info action + * @return Returns the rule creator + */ + private Serializable getRuleCreator(Action action) + { + return action.getParameterValue(PARAM_RULE_CREATOR); + } + } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/workflow/RMWorkflowModel.java b/rm-server/source/java/org/alfresco/workflow/RMWorkflowModel.java index d2ebd5f4bf..4bfe22659c 100644 --- a/rm-server/source/java/org/alfresco/workflow/RMWorkflowModel.java +++ b/rm-server/source/java/org/alfresco/workflow/RMWorkflowModel.java @@ -39,4 +39,7 @@ public interface RMWorkflowModel // Requested Information public static QName RM_REQUESTED_INFORMATION = QName.createQName(RM_WORKFLOW_URI, "requestedInformation"); + + // Rule creator + public static QName RM_RULE_CREATOR = QName.createQName(RM_WORKFLOW_URI, "ruleCreator"); } diff --git a/rm-server/source/java/org/alfresco/workflow/requestInfo/RequestInfoUtils.java b/rm-server/source/java/org/alfresco/workflow/requestInfo/RequestInfoUtils.java index 165a9a993c..28accfd706 100644 --- a/rm-server/source/java/org/alfresco/workflow/requestInfo/RequestInfoUtils.java +++ b/rm-server/source/java/org/alfresco/workflow/requestInfo/RequestInfoUtils.java @@ -97,22 +97,36 @@ public class RequestInfoUtils * Helper method to extract the initiator from the task * * @param delegateTask The delegate task - * @return Returns the initiator of the workflow. If the initiator does not exist the admin user name will be returned. + * @return Returns the initiator of the workflow. First it will be checked if + * a rule creator exists, which means the the workflow was started via rule. + * In this case the creator of the rule will receive the review task. + * If a rule creator cannot be found the code will try to find the initiator + * of the workflow. If also this is not the case the admin user will be returned. */ public static String getInitiator(DelegateTask delegateTask) { ParameterCheck.mandatory("delegateTask", delegateTask); String userName = null; - ActivitiScriptNode initiator = (ActivitiScriptNode) delegateTask.getVariable("initiator"); - if (initiator.exists()) + + String ruleCreator = (String) delegateTask.getVariable("rmwf_ruleCreator"); + if (StringUtils.isBlank(ruleCreator) == true) { - userName = (String) initiator.getProperties().get(ContentModel.PROP_USERNAME.toString()); + ActivitiScriptNode initiator = (ActivitiScriptNode) delegateTask.getVariable("initiator"); + if (initiator.exists()) + { + userName = (String) initiator.getProperties().get(ContentModel.PROP_USERNAME.toString()); + } + else + { + userName = AuthenticationUtil.getAdminUserName(); + } } else { - userName = AuthenticationUtil.getAdminUserName(); + userName = ruleCreator; } + return userName; }