Let git handle line endings for us.

This commit is contained in:
Tom Page
2016-09-23 14:36:49 +01:00
parent 9ecea8d44f
commit 483bb55a13
1219 changed files with 165186 additions and 165157 deletions

View File

@@ -1,54 +1,54 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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/>.
* #L%
*/
package org.alfresco.workflow;
import org.alfresco.service.namespace.QName;
/**
* Workflow Constants for Records Management
*
* @author Tuna Aksoy
* @since 2.1
*/
public interface RMWorkflowModel
{
// Namespace URI
String RM_WORKFLOW_URI = "http://www.alfresco.org/model/rmworkflow/1.0";
// Namespace prefix
String RM_WORKFLOW_PREFIX = "rmwf";
// Mixed Assignees
QName RM_MIXED_ASSIGNEES = QName.createQName(RM_WORKFLOW_URI, "mixedAssignees");
// Requested Information
QName RM_REQUESTED_INFORMATION = QName.createQName(RM_WORKFLOW_URI, "requestedInformation");
// Rule creator
QName RM_RULE_CREATOR = QName.createQName(RM_WORKFLOW_URI, "ruleCreator");
}
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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/>.
* #L%
*/
package org.alfresco.workflow;
import org.alfresco.service.namespace.QName;
/**
* Workflow Constants for Records Management
*
* @author Tuna Aksoy
* @since 2.1
*/
public interface RMWorkflowModel
{
// Namespace URI
String RM_WORKFLOW_URI = "http://www.alfresco.org/model/rmworkflow/1.0";
// Namespace prefix
String RM_WORKFLOW_PREFIX = "rmwf";
// Mixed Assignees
QName RM_MIXED_ASSIGNEES = QName.createQName(RM_WORKFLOW_URI, "mixedAssignees");
// Requested Information
QName RM_REQUESTED_INFORMATION = QName.createQName(RM_WORKFLOW_URI, "requestedInformation");
// Rule creator
QName RM_RULE_CREATOR = QName.createQName(RM_WORKFLOW_URI, "ruleCreator");
}

View File

@@ -1,140 +1,140 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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/>.
* #L%
*/
package org.alfresco.workflow.requestInfo;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.workflow.activiti.ActivitiScriptNode;
import org.alfresco.repo.workflow.activiti.ActivitiScriptNodeList;
import org.alfresco.util.ParameterCheck;
import org.springframework.extensions.surf.util.I18NUtil;
/**
* An assignment handler for the request info workflow.
* An RM manager/admin can select one or more user(s) and/or
* one or more group(s) when starting the request info workflow.
* This assignment handler assigns for everyone a task (it is a pooled task).
*
* @author Tuna Aksoy
* @since 2.1
*/
public class RequestInfoAssignmentHandler implements TaskListener
{
private static final long serialVersionUID = -3179929030094957978L;
/**
* @see org.activiti.engine.delegate.TaskListener#notify(org.activiti.engine.delegate.DelegateTask)
*/
@Override
public void notify(DelegateTask delegateTask)
{
ParameterCheck.mandatory("delegateTask", delegateTask);
// Set the workflow description for the task
delegateTask.setVariable("bpm_workflowDescription", getWorkflowDescription(RequestInfoUtils.getRecordName(delegateTask)));
// Get the list of user(s) and/or group(s)
ActivitiScriptNodeList usersAndGroups = (ActivitiScriptNodeList) delegateTask.getVariable("rmwf_mixedAssignees");
// Check if it was possible to extract the user(s) and/or group(s)
if (usersAndGroups == null)
{
throw new AlfrescoRuntimeException("It was not possible to extract the user(s) and/or group(s)!!!");
}
// Define lists for candidate user(s)/group(s)
List<String> candidateUsers = new ArrayList<String>();
List<String> candidateGroups = new ArrayList<String>();
// Iterate through the list add user(s)/group(s) to the lists
for (ActivitiScriptNode activitiScriptNode : usersAndGroups)
{
// Get the node type
String type = activitiScriptNode.getType();
// Get the properties
Map<String, Object> properties = activitiScriptNode.getProperties();
// Check if it is a user or a group
if (type.equalsIgnoreCase(ContentModel.TYPE_PERSON.toString()))
{
// Add the user
candidateUsers.add((String) properties.get(ContentModel.PROP_USERNAME.toString()));
}
else if (type.equalsIgnoreCase(ContentModel.TYPE_AUTHORITY_CONTAINER.toString()))
{
// Add the group
candidateGroups.add((String) properties.get(ContentModel.PROP_AUTHORITY_NAME.toString()));
}
else
{
throw new AlfrescoRuntimeException("The type '" + type + "' is neither a user nor a group!!!");
}
}
// Check if there is at least one user or one group
if (candidateUsers.size() == 0 && candidateGroups.size() == 0)
{
throw new AlfrescoRuntimeException("Neither a user nor a group was found!!!");
}
// Add the user(s) to the task
if (candidateUsers.size() > 0)
{
delegateTask.addCandidateUsers(candidateUsers);
}
// Add the group(s) to the task
if (candidateGroups.size() > 0)
{
delegateTask.addCandidateGroups(candidateGroups);
}
}
/**
* Helper method for building the workflow description
*
* @param recordName The name of the record
* @return Returns the workflow description
*/
private String getWorkflowDescription(String recordName)
{
StringBuilder sb = new StringBuilder();
sb.append(I18NUtil.getMessage("activitiReviewPooled.workflow.info.requested"));
sb.append(" '");
sb.append(recordName);
sb.append("'");
return sb.toString();
}
}
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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/>.
* #L%
*/
package org.alfresco.workflow.requestInfo;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.workflow.activiti.ActivitiScriptNode;
import org.alfresco.repo.workflow.activiti.ActivitiScriptNodeList;
import org.alfresco.util.ParameterCheck;
import org.springframework.extensions.surf.util.I18NUtil;
/**
* An assignment handler for the request info workflow.
* An RM manager/admin can select one or more user(s) and/or
* one or more group(s) when starting the request info workflow.
* This assignment handler assigns for everyone a task (it is a pooled task).
*
* @author Tuna Aksoy
* @since 2.1
*/
public class RequestInfoAssignmentHandler implements TaskListener
{
private static final long serialVersionUID = -3179929030094957978L;
/**
* @see org.activiti.engine.delegate.TaskListener#notify(org.activiti.engine.delegate.DelegateTask)
*/
@Override
public void notify(DelegateTask delegateTask)
{
ParameterCheck.mandatory("delegateTask", delegateTask);
// Set the workflow description for the task
delegateTask.setVariable("bpm_workflowDescription", getWorkflowDescription(RequestInfoUtils.getRecordName(delegateTask)));
// Get the list of user(s) and/or group(s)
ActivitiScriptNodeList usersAndGroups = (ActivitiScriptNodeList) delegateTask.getVariable("rmwf_mixedAssignees");
// Check if it was possible to extract the user(s) and/or group(s)
if (usersAndGroups == null)
{
throw new AlfrescoRuntimeException("It was not possible to extract the user(s) and/or group(s)!!!");
}
// Define lists for candidate user(s)/group(s)
List<String> candidateUsers = new ArrayList<String>();
List<String> candidateGroups = new ArrayList<String>();
// Iterate through the list add user(s)/group(s) to the lists
for (ActivitiScriptNode activitiScriptNode : usersAndGroups)
{
// Get the node type
String type = activitiScriptNode.getType();
// Get the properties
Map<String, Object> properties = activitiScriptNode.getProperties();
// Check if it is a user or a group
if (type.equalsIgnoreCase(ContentModel.TYPE_PERSON.toString()))
{
// Add the user
candidateUsers.add((String) properties.get(ContentModel.PROP_USERNAME.toString()));
}
else if (type.equalsIgnoreCase(ContentModel.TYPE_AUTHORITY_CONTAINER.toString()))
{
// Add the group
candidateGroups.add((String) properties.get(ContentModel.PROP_AUTHORITY_NAME.toString()));
}
else
{
throw new AlfrescoRuntimeException("The type '" + type + "' is neither a user nor a group!!!");
}
}
// Check if there is at least one user or one group
if (candidateUsers.size() == 0 && candidateGroups.size() == 0)
{
throw new AlfrescoRuntimeException("Neither a user nor a group was found!!!");
}
// Add the user(s) to the task
if (candidateUsers.size() > 0)
{
delegateTask.addCandidateUsers(candidateUsers);
}
// Add the group(s) to the task
if (candidateGroups.size() > 0)
{
delegateTask.addCandidateGroups(candidateGroups);
}
}
/**
* Helper method for building the workflow description
*
* @param recordName The name of the record
* @return Returns the workflow description
*/
private String getWorkflowDescription(String recordName)
{
StringBuilder sb = new StringBuilder();
sb.append(I18NUtil.getMessage("activitiReviewPooled.workflow.info.requested"));
sb.append(" '");
sb.append(recordName);
sb.append("'");
return sb.toString();
}
}

View File

@@ -1,81 +1,81 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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/>.
* #L%
*/
package org.alfresco.workflow.requestInfo;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
import org.alfresco.util.ParameterCheck;
import org.springframework.extensions.surf.util.I18NUtil;
/**
* Request info workflow notifier.
* After the pooled task has been finished the initiator of the workflow will
* get a task to verify the information. The initiator will also receive an email.
*
* @author Tuna Aksoy
* @since 2.1
*/
public class RequestInfoNotifier implements TaskListener
{
private static final long serialVersionUID = -7169400062409052556L;
/**
* @see org.activiti.engine.delegate.TaskListener#notify(org.activiti.engine.delegate.DelegateTask)
*/
@Override
public void notify(DelegateTask delegateTask)
{
ParameterCheck.mandatory("delegateTask", delegateTask);
// Get the record name
String recordName = RequestInfoUtils.getRecordName(delegateTask);
// Set the workflow description for the task
delegateTask.setVariable("bpm_workflowDescription", getWorkflowDescription(recordName));
// Assign the task to the initiator
String initiator = RequestInfoUtils.getInitiator(delegateTask);
delegateTask.setAssignee(initiator);
}
/**
* Helper method for building the workflow description
*
* @param recordName The name of the record
* @return Returns the workflow description
*/
private String getWorkflowDescription(String recordName)
{
StringBuilder sb = new StringBuilder();
sb.append(I18NUtil.getMessage("activitiReviewPooled.workflow.info.provided"));
sb.append(" '");
sb.append(recordName);
sb.append("'");
return sb.toString();
}
}
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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/>.
* #L%
*/
package org.alfresco.workflow.requestInfo;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
import org.alfresco.util.ParameterCheck;
import org.springframework.extensions.surf.util.I18NUtil;
/**
* Request info workflow notifier.
* After the pooled task has been finished the initiator of the workflow will
* get a task to verify the information. The initiator will also receive an email.
*
* @author Tuna Aksoy
* @since 2.1
*/
public class RequestInfoNotifier implements TaskListener
{
private static final long serialVersionUID = -7169400062409052556L;
/**
* @see org.activiti.engine.delegate.TaskListener#notify(org.activiti.engine.delegate.DelegateTask)
*/
@Override
public void notify(DelegateTask delegateTask)
{
ParameterCheck.mandatory("delegateTask", delegateTask);
// Get the record name
String recordName = RequestInfoUtils.getRecordName(delegateTask);
// Set the workflow description for the task
delegateTask.setVariable("bpm_workflowDescription", getWorkflowDescription(recordName));
// Assign the task to the initiator
String initiator = RequestInfoUtils.getInitiator(delegateTask);
delegateTask.setAssignee(initiator);
}
/**
* Helper method for building the workflow description
*
* @param recordName The name of the record
* @return Returns the workflow description
*/
private String getWorkflowDescription(String recordName)
{
StringBuilder sb = new StringBuilder();
sb.append(I18NUtil.getMessage("activitiReviewPooled.workflow.info.provided"));
sb.append(" '");
sb.append(recordName);
sb.append("'");
return sb.toString();
}
}

View File

@@ -1,146 +1,146 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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/>.
* #L%
*/
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.error.AlfrescoRuntimeException;
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 final class RequestInfoUtils
{
private RequestInfoUtils()
{
// Will not be called
}
/**
* 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 AlfrescoRuntimeException(
"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. 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;
String ruleCreator = (String) delegateTask.getVariable("rmwf_ruleCreator");
if (StringUtils.isBlank(ruleCreator))
{
ActivitiScriptNode initiator = (ActivitiScriptNode) delegateTask.getVariable("initiator");
if (initiator.exists())
{
userName = (String) initiator.getProperties().get(ContentModel.PROP_USERNAME.toString());
}
else
{
userName = AuthenticationUtil.getAdminUserName();
}
}
else
{
userName = ruleCreator;
}
return userName;
}
}
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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/>.
* #L%
*/
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.error.AlfrescoRuntimeException;
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 final class RequestInfoUtils
{
private RequestInfoUtils()
{
// Will not be called
}
/**
* 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 AlfrescoRuntimeException(
"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. 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;
String ruleCreator = (String) delegateTask.getVariable("rmwf_ruleCreator");
if (StringUtils.isBlank(ruleCreator))
{
ActivitiScriptNode initiator = (ActivitiScriptNode) delegateTask.getVariable("initiator");
if (initiator.exists())
{
userName = (String) initiator.getProperties().get(ContentModel.PROP_USERNAME.toString());
}
else
{
userName = AuthenticationUtil.getAdminUserName();
}
}
else
{
userName = ruleCreator;
}
return userName;
}
}

View File

@@ -1,59 +1,59 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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/>.
* #L%
*/
package org.alfresco.workflow.requestInfo;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
import org.alfresco.util.ParameterCheck;
/**
* A variable handler for saving the task variables to the execution context.
* Some of the information will be needed in other tasks (e.g. "rmwf_message").
* This variable handler saves the local task variable to the execution context.
*
* @author Tuna Aksoy
* @since 2.1
*/
public class RequestInfoVariableHandler implements TaskListener
{
private static final long serialVersionUID = -1759557028641631768L;
/**
* @see org.activiti.engine.delegate.TaskListener#notify(org.activiti.engine.delegate.DelegateTask)
*/
@Override
public void notify(DelegateTask delegateTask)
{
ParameterCheck.mandatory("delegateTask", delegateTask);
// Save the variable from the task
DelegateExecution execution = delegateTask.getExecution();
execution.setVariable("rmwf_message", delegateTask.getVariable("rmwf_message"));
}
}
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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/>.
* #L%
*/
package org.alfresco.workflow.requestInfo;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
import org.alfresco.util.ParameterCheck;
/**
* A variable handler for saving the task variables to the execution context.
* Some of the information will be needed in other tasks (e.g. "rmwf_message").
* This variable handler saves the local task variable to the execution context.
*
* @author Tuna Aksoy
* @since 2.1
*/
public class RequestInfoVariableHandler implements TaskListener
{
private static final long serialVersionUID = -1759557028641631768L;
/**
* @see org.activiti.engine.delegate.TaskListener#notify(org.activiti.engine.delegate.DelegateTask)
*/
@Override
public void notify(DelegateTask delegateTask)
{
ParameterCheck.mandatory("delegateTask", delegateTask);
// Save the variable from the task
DelegateExecution execution = delegateTask.getExecution();
execution.setVariable("rmwf_message", delegateTask.getVariable("rmwf_message"));
}
}