mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
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@48973 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -29,3 +29,6 @@ fileTo.createRecordFolder.display-label=Create Record Folder
|
|||||||
reject.title=Reject
|
reject.title=Reject
|
||||||
reject.description=Rejects a record and moves the document to its original location
|
reject.description=Rejects a record and moves the document to its original location
|
||||||
reject.reason.display-label=Reject reason
|
reject.reason.display-label=Reject reason
|
||||||
|
# Request Information
|
||||||
|
requestInfo.title=Request Information
|
||||||
|
requestInfo.description=Starts a workflow for requesting more information for a record
|
||||||
|
@@ -11,23 +11,23 @@
|
|||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- Conditions -->
|
<!-- Conditions -->
|
||||||
|
|
||||||
<bean id="rmCapabilityConditionEvaluator"
|
<bean id="rmCapabilityConditionEvaluator"
|
||||||
parent="action-condition-evaluator"
|
parent="action-condition-evaluator"
|
||||||
abstract="true"
|
abstract="true"
|
||||||
class="org.alfresco.module.org_alfresco_module_rm.action.evaluator.CapabilityConditionEvaluator">
|
class="org.alfresco.module.org_alfresco_module_rm.action.evaluator.CapabilityConditionEvaluator">
|
||||||
<property name="recordsManagementActionService" ref="recordsManagementActionService" />
|
<property name="recordsManagementActionService" ref="recordsManagementActionService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="isDeclared" parent="rmCapabilityConditionEvaluator">
|
<bean id="isDeclared" parent="rmCapabilityConditionEvaluator">
|
||||||
<property name="capabilityCondition" ref="capabilityCondition.declared"/>
|
<property name="capabilityCondition" ref="capabilityCondition.declared"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="isRecordFiled" parent="rmCapabilityConditionEvaluator">
|
<bean id="isRecordFiled" parent="rmCapabilityConditionEvaluator">
|
||||||
<property name="capabilityCondition" ref="capabilityCondition.recordFiled"/>
|
<property name="capabilityCondition" ref="capabilityCondition.recordFiled"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- Actions -->
|
<!-- Actions -->
|
||||||
|
|
||||||
@@ -722,4 +722,19 @@
|
|||||||
<property name="allowParameterSubstitutions" value="true"/>
|
<property name="allowParameterSubstitutions" value="true"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<bean id="requestInfo_proxy" parent="rmProxyAction">
|
||||||
|
<property name="target" ref="requestInfo"/>
|
||||||
|
<property name="interceptorNames">
|
||||||
|
<list>
|
||||||
|
<idref bean="allow_security"/>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="requestInfo" class="org.alfresco.module.org_alfresco_module_rm.action.impl.RequestInfoAction" parent="rmAction">
|
||||||
|
<property name="publicAction" value="true"/>
|
||||||
|
</bean>
|
||||||
|
-->
|
||||||
|
|
||||||
</beans>
|
</beans>
|
@@ -18,13 +18,10 @@
|
|||||||
<value>alfresco/workflow/rmWorkflowModel.xml</value>
|
<value>alfresco/workflow/rmWorkflowModel.xml</value>
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
<!-- FIXME: Use labels -->
|
|
||||||
<!--
|
|
||||||
<property name="labels">
|
<property name="labels">
|
||||||
<list>
|
<list>
|
||||||
<value>alfresco/workflow/workflow-messages</value>
|
<value>alfresco/workflow/rm-workflow-messages</value>
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
-->
|
|
||||||
</bean>
|
</bean>
|
||||||
</beans>
|
</beans>
|
@@ -0,0 +1,5 @@
|
|||||||
|
activitiReviewPooled.workflow.info.requested=Information requested for record
|
||||||
|
activitiReviewPooled.workflow.info.provided=Information provided for record
|
||||||
|
activitiReviewPooled.workflow.email.subject=Information provided for the record
|
||||||
|
activitiReviewPooled.workflow.email.body1=The user
|
||||||
|
activitiReviewPooled.workflow.email.body2=has provided the needed information for the record
|
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.module.org_alfresco_module_rm.action.impl;
|
||||||
|
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||||
|
import org.alfresco.service.cmr.action.Action;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FIXME
|
||||||
|
*
|
||||||
|
* @author Tuna Aksoy
|
||||||
|
* @since 2.1
|
||||||
|
*/
|
||||||
|
public class RequestInfoAction extends RMActionExecuterAbstractBase
|
||||||
|
{
|
||||||
|
/** Action name */
|
||||||
|
public static final String NAME = "requestInfo";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||||
|
{
|
||||||
|
// FIXME
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -24,17 +24,12 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.activiti.engine.delegate.DelegateTask;
|
import org.activiti.engine.delegate.DelegateTask;
|
||||||
import org.activiti.engine.delegate.TaskListener;
|
import org.activiti.engine.delegate.TaskListener;
|
||||||
import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
|
||||||
import org.activiti.engine.impl.context.Context;
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.workflow.activiti.ActivitiConstants;
|
|
||||||
import org.alfresco.repo.workflow.activiti.ActivitiScriptNode;
|
import org.alfresco.repo.workflow.activiti.ActivitiScriptNode;
|
||||||
import org.alfresco.repo.workflow.activiti.ActivitiScriptNodeList;
|
import org.alfresco.repo.workflow.activiti.ActivitiScriptNodeList;
|
||||||
import org.alfresco.service.ServiceRegistry;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
|
||||||
import org.alfresco.util.ParameterCheck;
|
import org.alfresco.util.ParameterCheck;
|
||||||
|
import org.springframework.extensions.surf.util.I18NUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An assignment handler for the request info workflow.
|
* An assignment handler for the request info workflow.
|
||||||
@@ -56,7 +51,7 @@ public class RequestInfoAssignmentHandler implements TaskListener
|
|||||||
ParameterCheck.mandatory("delegateTask", delegateTask);
|
ParameterCheck.mandatory("delegateTask", delegateTask);
|
||||||
|
|
||||||
// Set the workflow description for the task
|
// Set the workflow description for the task
|
||||||
delegateTask.setVariable("bpm_workflowDescription", getWorkflowDescription(delegateTask));
|
delegateTask.setVariable("bpm_workflowDescription", getWorkflowDescription(RequestInfoUtils.getRecordName(delegateTask)));
|
||||||
|
|
||||||
// Get the list of user(s) and/or group(s)
|
// Get the list of user(s) and/or group(s)
|
||||||
ActivitiScriptNodeList usersAndGroups = (ActivitiScriptNodeList) delegateTask.getVariable("rmwf_mixedAssignees");
|
ActivitiScriptNodeList usersAndGroups = (ActivitiScriptNodeList) delegateTask.getVariable("rmwf_mixedAssignees");
|
||||||
@@ -115,42 +110,20 @@ public class RequestInfoAssignmentHandler implements TaskListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getWorkflowDescription(DelegateTask delegateTask)
|
|
||||||
{
|
|
||||||
// FIXME: I18N!!!
|
|
||||||
return "Information requested for record '" + getRecordName(delegateTask) + "'";
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getRecordName(DelegateTask delegateTask)
|
|
||||||
{
|
|
||||||
ActivitiScriptNode scriptNode = (ActivitiScriptNode) delegateTask.getVariable("bpm_package");
|
|
||||||
NodeService nodeService = getServiceRegistry().getNodeService();
|
|
||||||
NodeRef docRef= nodeService.getChildAssocs(scriptNode.getNodeRef()).get(0).getChildRef();
|
|
||||||
return (String) nodeService.getProperty(docRef, ContentModel.PROP_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
//FIXME: Is there a better way to call services?
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method for getting the service registry in order to call services
|
* Helper method for building the workflow description
|
||||||
*
|
*
|
||||||
* @return Returns the service registry
|
* @param recordName The name of the record
|
||||||
|
* @return Returns the workflow description
|
||||||
*/
|
*/
|
||||||
private ServiceRegistry getServiceRegistry()
|
private String getWorkflowDescription(String recordName)
|
||||||
{
|
{
|
||||||
ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration();
|
StringBuilder sb = new StringBuilder();
|
||||||
if (config != null)
|
sb.append(I18NUtil.getMessage("activitiReviewPooled.workflow.info.requested"));
|
||||||
{
|
sb.append(" '");
|
||||||
// Fetch the registry that is injected in the activiti spring-configuration
|
sb.append(recordName);
|
||||||
ServiceRegistry registry = (ServiceRegistry) config.getBeans().get(ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY);
|
sb.append("'");
|
||||||
if (registry == null)
|
return sb.toString();
|
||||||
{
|
|
||||||
throw new RuntimeException(
|
|
||||||
"Service-registry not present in ProcessEngineConfiguration beans, expected ServiceRegistry with key" +
|
|
||||||
ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY);
|
|
||||||
}
|
|
||||||
return registry;
|
|
||||||
}
|
|
||||||
throw new IllegalStateException("No ProcessEngineCOnfiguration found in active context");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -20,18 +20,11 @@ package org.alfresco.workflow.requestInfo;
|
|||||||
|
|
||||||
import org.activiti.engine.delegate.DelegateTask;
|
import org.activiti.engine.delegate.DelegateTask;
|
||||||
import org.activiti.engine.delegate.TaskListener;
|
import org.activiti.engine.delegate.TaskListener;
|
||||||
import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
|
||||||
import org.activiti.engine.impl.context.Context;
|
|
||||||
import org.alfresco.model.ContentModel;
|
|
||||||
import org.alfresco.repo.notification.EMailNotificationProvider;
|
import org.alfresco.repo.notification.EMailNotificationProvider;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.workflow.activiti.ActivitiConstants;
|
|
||||||
import org.alfresco.repo.workflow.activiti.ActivitiScriptNode;
|
|
||||||
import org.alfresco.service.ServiceRegistry;
|
|
||||||
import org.alfresco.service.cmr.notification.NotificationContext;
|
import org.alfresco.service.cmr.notification.NotificationContext;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
|
||||||
import org.alfresco.util.ParameterCheck;
|
import org.alfresco.util.ParameterCheck;
|
||||||
|
import org.springframework.extensions.surf.util.I18NUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request info workflow notifier.
|
* Request info workflow notifier.
|
||||||
@@ -51,11 +44,14 @@ public class RequestInfoNotifier implements TaskListener
|
|||||||
{
|
{
|
||||||
ParameterCheck.mandatory("delegateTask", delegateTask);
|
ParameterCheck.mandatory("delegateTask", delegateTask);
|
||||||
|
|
||||||
|
// Get the record name
|
||||||
|
String recordName = RequestInfoUtils.getRecordName(delegateTask);
|
||||||
|
|
||||||
// Set the workflow description for the task
|
// Set the workflow description for the task
|
||||||
delegateTask.setVariable("bpm_workflowDescription", getWorkflowDescription(delegateTask));
|
delegateTask.setVariable("bpm_workflowDescription", getWorkflowDescription(recordName));
|
||||||
|
|
||||||
// Assign the task to the initiator
|
// Assign the task to the initiator
|
||||||
String initiator = getInitiator(delegateTask);
|
String initiator = RequestInfoUtils.getInitiator(delegateTask);
|
||||||
delegateTask.setAssignee(initiator);
|
delegateTask.setAssignee(initiator);
|
||||||
|
|
||||||
// Create the context and send an email to the initiator
|
// Create the context and send an email to the initiator
|
||||||
@@ -63,71 +59,62 @@ public class RequestInfoNotifier implements TaskListener
|
|||||||
notificationContext.setAsyncNotification(true);
|
notificationContext.setAsyncNotification(true);
|
||||||
notificationContext.setIgnoreNotificationFailure(true);
|
notificationContext.setIgnoreNotificationFailure(true);
|
||||||
notificationContext.addTo(initiator);
|
notificationContext.addTo(initiator);
|
||||||
// FIXME: I18N!!! and get the record name and the user name who provided the information
|
notificationContext.setSubject(getEmailSubject(recordName));
|
||||||
notificationContext.setSubject("Information provided for the record '" + "" + "'.");
|
notificationContext.setBody(getEmailBody(recordName));
|
||||||
notificationContext.setBody("The user '" + "' has provided the needed information for the record '" + "" + "'.");
|
|
||||||
|
|
||||||
// Send the email
|
// Send the email
|
||||||
getServiceRegistry().getNotificationService().sendNotification(EMailNotificationProvider.NAME, notificationContext);
|
RequestInfoUtils.getServiceRegistry().getNotificationService().sendNotification(EMailNotificationProvider.NAME, notificationContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to extract the initiator from the task
|
* Helper method for building the workflow description
|
||||||
*
|
*
|
||||||
* @param delegateTask The delegate task
|
* @param recordName The name of the record
|
||||||
* @return Returns the initiator of the workflow. If the initiator does not exist the admin user will be returned.
|
* @return Returns the workflow description
|
||||||
*/
|
*/
|
||||||
private String getInitiator(DelegateTask delegateTask)
|
private String getWorkflowDescription(String recordName)
|
||||||
{
|
{
|
||||||
String userName = null;
|
StringBuilder sb = new StringBuilder();
|
||||||
ActivitiScriptNode initiator = (ActivitiScriptNode) delegateTask.getVariable("initiator");
|
sb.append(I18NUtil.getMessage("activitiReviewPooled.workflow.info.provided"));
|
||||||
if (initiator.exists())
|
sb.append(" '");
|
||||||
{
|
sb.append(recordName);
|
||||||
userName = (String) initiator.getProperties().get(ContentModel.PROP_USERNAME.toString());
|
sb.append("'");
|
||||||
}
|
return sb.toString();
|
||||||
else
|
|
||||||
{
|
|
||||||
userName = AuthenticationUtil.getAdminUserName();
|
|
||||||
}
|
|
||||||
return userName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getWorkflowDescription(DelegateTask delegateTask)
|
|
||||||
{
|
|
||||||
// FIXME: I18N!!!
|
|
||||||
return "Information provided for record '" + getRecordName(delegateTask) + "'";
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getRecordName(DelegateTask delegateTask)
|
|
||||||
{
|
|
||||||
ActivitiScriptNode scriptNode = (ActivitiScriptNode) delegateTask.getVariable("bpm_package");
|
|
||||||
NodeService nodeService = getServiceRegistry().getNodeService();
|
|
||||||
NodeRef docRef= nodeService.getChildAssocs(scriptNode.getNodeRef()).get(0).getChildRef();
|
|
||||||
return (String) nodeService.getProperty(docRef, ContentModel.PROP_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
//FIXME: Is there a better way to call services?
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method for getting the service registry in order to call services
|
* Helper method for building the email subject
|
||||||
*
|
*
|
||||||
* @return Returns the service registry
|
* @param recordName The name of the record
|
||||||
|
* @return Returns the email subject
|
||||||
*/
|
*/
|
||||||
private ServiceRegistry getServiceRegistry()
|
private String getEmailSubject(String recordName)
|
||||||
{
|
{
|
||||||
ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration();
|
StringBuilder sb = new StringBuilder();
|
||||||
if (config != null)
|
sb.append(I18NUtil.getMessage("activitiReviewPooled.workflow.email.subject"));
|
||||||
{
|
sb.append(" '");
|
||||||
// Fetch the registry that is injected in the activiti spring-configuration
|
sb.append(recordName);
|
||||||
ServiceRegistry registry = (ServiceRegistry) config.getBeans().get(ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY);
|
sb.append("'");
|
||||||
if (registry == null)
|
return sb.toString();
|
||||||
{
|
}
|
||||||
throw new RuntimeException(
|
|
||||||
"Service-registry not present in ProcessEngineConfiguration beans, expected ServiceRegistry with key" +
|
/**
|
||||||
ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY);
|
* Helper method for building the email body
|
||||||
}
|
*
|
||||||
return registry;
|
* @param recordName The name of the record
|
||||||
}
|
* @return Returns the email body
|
||||||
throw new IllegalStateException("No ProcessEngineCOnfiguration found in active context");
|
*/
|
||||||
|
private String getEmailBody(String recordName)
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(I18NUtil.getMessage("activitiReviewPooled.workflow.email.body1"));
|
||||||
|
sb.append(" '");
|
||||||
|
sb.append(AuthenticationUtil.getFullyAuthenticatedUser());
|
||||||
|
sb.append("' ");
|
||||||
|
sb.append(I18NUtil.getMessage("activitiReviewPooled.workflow.email.body2"));
|
||||||
|
sb.append(" '");
|
||||||
|
sb.append(recordName);
|
||||||
|
sb.append("'.");
|
||||||
|
return sb.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,119 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.workflow.requestInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.activiti.engine.delegate.DelegateTask;
|
||||||
|
import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
||||||
|
import org.activiti.engine.impl.context.Context;
|
||||||
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
|
import org.alfresco.repo.workflow.activiti.ActivitiConstants;
|
||||||
|
import org.alfresco.repo.workflow.activiti.ActivitiScriptNode;
|
||||||
|
import org.alfresco.service.ServiceRegistry;
|
||||||
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
|
import org.alfresco.util.ParameterCheck;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Util class for the request info workflow
|
||||||
|
*
|
||||||
|
* @author Tuna Aksoy
|
||||||
|
* @since 2.1
|
||||||
|
*/
|
||||||
|
public class RequestInfoUtils
|
||||||
|
{
|
||||||
|
//FIXME: Is there a better way to call services?
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to get the service registry in order to call services
|
||||||
|
*
|
||||||
|
* @return Returns the service registry
|
||||||
|
*/
|
||||||
|
public static ServiceRegistry getServiceRegistry()
|
||||||
|
{
|
||||||
|
ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration();
|
||||||
|
if (config != null)
|
||||||
|
{
|
||||||
|
// Fetch the registry that is injected in the activiti spring-configuration
|
||||||
|
ServiceRegistry registry = (ServiceRegistry) config.getBeans().get(ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY);
|
||||||
|
if (registry == null)
|
||||||
|
{
|
||||||
|
throw new RuntimeException(
|
||||||
|
"Service-registry not present in ProcessEngineConfiguration beans, expected ServiceRegistry with key" +
|
||||||
|
ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY);
|
||||||
|
}
|
||||||
|
return registry;
|
||||||
|
}
|
||||||
|
throw new IllegalStateException("No ProcessEngineCOnfiguration found in active context");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to extract the record name from the task
|
||||||
|
*
|
||||||
|
* @param delegateTask The delegate task
|
||||||
|
* @return Returns the name of the record or an empty string if the record name could not be found
|
||||||
|
(may be because the record has been deleted in the mean time)
|
||||||
|
*/
|
||||||
|
public static String getRecordName(DelegateTask delegateTask)
|
||||||
|
{
|
||||||
|
ParameterCheck.mandatory("delegateTask", delegateTask);
|
||||||
|
|
||||||
|
String recordName = StringUtils.EMPTY;
|
||||||
|
|
||||||
|
NodeService nodeService = getServiceRegistry().getNodeService();
|
||||||
|
ActivitiScriptNode scriptNode = (ActivitiScriptNode) delegateTask.getVariable("bpm_package");
|
||||||
|
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(scriptNode.getNodeRef());
|
||||||
|
|
||||||
|
if (childAssocs.size() > 0)
|
||||||
|
{
|
||||||
|
NodeRef docRef= childAssocs.get(0).getChildRef();
|
||||||
|
recordName = (String) nodeService.getProperty(docRef, ContentModel.PROP_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
return recordName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
public static String getInitiator(DelegateTask delegateTask)
|
||||||
|
{
|
||||||
|
ParameterCheck.mandatory("delegateTask", delegateTask);
|
||||||
|
|
||||||
|
String userName = null;
|
||||||
|
ActivitiScriptNode initiator = (ActivitiScriptNode) delegateTask.getVariable("initiator");
|
||||||
|
if (initiator.exists())
|
||||||
|
{
|
||||||
|
userName = (String) initiator.getProperties().get(ContentModel.PROP_USERNAME.toString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
userName = AuthenticationUtil.getAdminUserName();
|
||||||
|
}
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user