Java Code Examples for org.alfresco.service.cmr.workflow.WorkflowInstance#isActive()
The following examples show how to use
org.alfresco.service.cmr.workflow.WorkflowInstance#isActive() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WorkflowServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public List<WorkflowInstance> getWorkflowsForContent(NodeRef packageItem, boolean active) { List<String> workflowIds = workflowPackageComponent.getWorkflowIdsForContent(packageItem); List<WorkflowInstance> workflowInstances = new ArrayList<WorkflowInstance>(workflowIds.size()); for (String workflowId : workflowIds) { try { String engineId = BPMEngineRegistry.getEngineId(workflowId); WorkflowComponent component = getWorkflowComponent(engineId); WorkflowInstance instance = component.getWorkflowById(workflowId); if (instance != null && instance.isActive() == active) { workflowInstances.add(instance); } } catch (WorkflowException componentForEngineNotRegistered) { String message = componentForEngineNotRegistered.getMessage(); logger.debug(message + ". Ignored workflow on " + packageItem); } } return workflowInstances; }
Example 2
Source File: ResetPasswordServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * This method ensures that the id refers to an in-progress workflow and that the key matches * that stored in the workflow. * * @throws WebScriptException a 404 if any of the above is not true. */ private void validateIdAndKey(String id, String key, String userId) { ParameterCheck.mandatory("id", id); ParameterCheck.mandatory("key", key); ParameterCheck.mandatory("userId", userId); WorkflowInstance workflowInstance = null; try { workflowInstance = workflowService.getWorkflowById(id); } catch (WorkflowException ignored) { // Intentionally empty. } if (workflowInstance == null) { throw new ResetPasswordWorkflowNotFoundException("The reset password workflow instance with the id [" + id + "] is not found."); } String recoveredKey; String username; if (workflowInstance.isActive()) { // If the workflow is active we will be able to read the path properties. Map<QName, Serializable> pathProps = workflowService.getPathProperties(id); username = (String) pathProps.get(WorkflowModelResetPassword.WF_PROP_USERNAME); recoveredKey = (String) pathProps.get(WorkflowModelResetPassword.WF_PROP_KEY); } else { throw new InvalidResetPasswordWorkflowException("The reset password workflow instance with the id [" + id + "] is not active (it might be expired or has already been used)."); } if (username == null || recoveredKey == null || !recoveredKey.equals(key)) { String msg; if (username == null) { msg = "The recovered user name is null for the reset password workflow instance with the id [" + id + "]"; } else if (recoveredKey == null) { msg = "The recovered key is null for the reset password workflow instance with the id [" + id + "]"; } else { msg = "The recovered key [" + recoveredKey + "] does not match the given workflow key [" + key + "] for the reset password workflow instance with the id [" + id + "]"; } throw new InvalidResetPasswordWorkflowException(msg); } else if (!username.equals(userId)) { throw new InvalidResetPasswordWorkflowException("The given user id [" + userId + "] does not match the person's user id [" + username + "] who requested the password reset."); } }
Example 3
Source File: ResetPasswordServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
private boolean isActive(String workflowId) { WorkflowInstance workflowInstance = workflowService.getWorkflowById(workflowId); assertNotNull(workflowInstance); return workflowInstance.isActive(); }