Package org.activiti.engine

Examples of org.activiti.engine.ActivitiException


    this.executionId = executionId;
  }

  public List<String> execute(CommandContext commandContext) {
    if(executionId == null) {
      throw new ActivitiException("executionId is null");
    }
   
    ExecutionEntity execution = commandContext
      .getExecutionManager()
      .findExecutionById(executionId);
   
    if (execution==null) {
      throw new ActivitiException("execution "+executionId+" doesn't exist");
    }
   
    return execution.findActiveActivityIds();
  }
View Full Code Here


    ProcessDefinitionEntity processDefinition = Context
      .getProcessEngineConfiguration()
      .getDeploymentCache()
      .findDeployedProcessDefinitionById(processDefinitionId);
    if (processDefinition == null) {
      throw new ActivitiException("Process Definition '" + processDefinitionId +"' not found");
    }
    StartFormHandler startFormHandler = processDefinition.getStartFormHandler();
    if (startFormHandler == null) {
      return null;
    }
   
    FormEngine formEngine = Context
      .getProcessEngineConfiguration()
      .getFormEngines()
      .get(formEngineName);
   
    if (formEngine==null) {
      throw new ActivitiException("No formEngine '" + formEngineName +"' defined process engine configuration");
    }
   
    StartFormData startForm = startFormHandler.createStartFormData(processDefinition);
   
    return formEngine.renderStartForm(startForm);
View Full Code Here

    if(authenticate() == false) return null;
   
    String attachmentId = (String) getRequest().getAttributes().get("attachmentId");
   
    if(attachmentId == null) {
      throw new ActivitiException("No attachment id provided");
    }

    Attachment attachment = ActivitiUtil.getTaskService().getAttachment(attachmentId);
    if(attachment == null) {
      throw new ActivitiException("No attachment found for " + attachmentId);
    }
   
    String contentType = attachment.getType();
    MediaType mediatType = MediaType.IMAGE_PNG;
    if(contentType != null) {
View Full Code Here

  public void deleteAttachment(Representation entity) {
    if(authenticate() == false) return;
    String attachmentId = (String) getRequest().getAttributes().get("attachmentId");
   
    if(attachmentId == null) {
      throw new ActivitiException("No attachment id provided");
    }
   
    ActivitiUtil.getTaskService().deleteAttachment(attachmentId);
  }
View Full Code Here

    ObjectNode responseJSON = new ObjectMapper().createObjectNode();
   
    String processInstanceId = (String) getRequest().getAttributes().get("processInstanceId");

    if (processInstanceId == null) {
      throw new ActivitiException("No process instance is provided");
    }
   
    try {
      // check authentication
      if (authenticate() == false)
        return null;
     
      // extract request parameters
      Map<String, Object> variables = new HashMap<String, Object>();
      String startParams = entity.getText();
      if (StringUtils.isNotEmpty(startParams)) {
        JsonNode startJSON = new ObjectMapper().readTree(startParams);
        variables.putAll(retrieveVariables(startJSON));
      }

      // extract activity id
      String activityId = (String) variables.remove("activityId");

      if(activityId == null){
        responseJSON.put("success", false);
        responseJSON.put("failureReason", "Request is missing activity id");
        return responseJSON;
      }
       
      RuntimeService runtimeService = ActivitiUtil.getRuntimeService();
      Execution execution = runtimeService.createExecutionQuery()
            .processInstanceId(processInstanceId)
            .activityId(activityId)
            .singleResult();
     
      // signal receive task and attach variables if available
      if (variables.size() > 0) {
        runtimeService.signal(execution.getId(), variables);
      } else {
        runtimeService.signal(execution.getId());
      }

      // set up and return response message
      responseJSON.put("success", true);
      return responseJSON;
    } catch (Exception e) {
      throw new ActivitiException("Failed to signal receive task for process instance id " + processInstanceId, e);
    }

  }
View Full Code Here

  }

  public ProcessInstance execute(CommandContext commandContext) {
   
    if(messageName == null) {
      throw new ActivitiException("Cannot start process instance by message: message name is null");
    }
   
    MessageEventSubscriptionEntity messageEventSubscription = commandContext.getEventSubscriptionManager()
      .findMessageStartEventSubscriptionByName(messageName);
   
    if(messageEventSubscription == null) {
      throw new ActivitiException("Cannot start process instance by message: no subscription to message with name '"+messageName+"' found.");
    }
   
    String processDefinitionId = messageEventSubscription.getConfiguration();
    if(processDefinitionId == null) {
      throw new ActivitiException("Cannot start process instance by message: subscription to message with name '"+messageName+"' is not a message start event.");
    }
       
    DeploymentCache deploymentCache = Context
            .getProcessEngineConfiguration()
            .getDeploymentCache();
         
    ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
    if (processDefinition == null) {
        throw new ActivitiException("No process definition found for id '" + processDefinitionId + "'");
    }
 
    ActivityImpl startActivity = processDefinition.findActivity(messageEventSubscription.getActivityId());
    ExecutionEntity processInstance = processDefinition.createProcessInstance(businessKey, startActivity);
View Full Code Here

    if(authenticate() == false) return null;
   
    String processInstanceId = (String) getRequest().getAttributes().get("processInstanceId");
   
    if(processInstanceId == null) {
      throw new ActivitiException("No process instance id provided");
    }

    ExecutionEntity pi =
        (ExecutionEntity) ActivitiUtil.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();

    if (pi == null) {
      throw new ActivitiException("Process instance with id" + processInstanceId + " could not be found");
    }

    ProcessDefinitionEntity pde = (ProcessDefinitionEntity) ((RepositoryServiceImpl) ActivitiUtil.getRepositoryService())
        .getDeployedProcessDefinition(pi.getProcessDefinitionId());

    if (pde != null && pde.isGraphicalNotationDefined()) {
      InputStream resource = ProcessDiagramGenerator.generateDiagram(pde, "png", ActivitiUtil.getRuntimeService().getActiveActivityIds(processInstanceId));

      InputRepresentation output = new InputRepresentation(resource, MediaType.IMAGE_PNG);
      return output;
     
    } else {
      throw new ActivitiException("Process instance with id " + processInstanceId + " has no graphic description");
    }
  }
View Full Code Here

 
  public static class SuspensionStateUtil{
   
    public static void setSuspensionState(ProcessDefinitionEntity processDefinitionEntity, SuspensionState state) {
      if(processDefinitionEntity.getSuspensionState() == state.getStateCode()) {
        throw new ActivitiException("Cannot set suspension state '"+state+"' for "+processDefinitionEntity+"': already in state '"+state+"'.");
      }
      processDefinitionEntity.setSuspensionState(state.getStateCode());
    }
View Full Code Here

      processDefinitionEntity.setSuspensionState(state.getStateCode());
    }
   
    public static void setSuspensionState(ExecutionEntity executionEntity, SuspensionState state) {
      if(executionEntity.getSuspensionState() == state.getStateCode()) {
        throw new ActivitiException("Cannot set suspension state '"+state+"' for "+executionEntity+"': already in state '"+state+"'.");
      }
      executionEntity.setSuspensionState(state.getStateCode());
    }
View Full Code Here

      executionEntity.setSuspensionState(state.getStateCode());
    }
   
    public static void setSuspensionState(TaskEntity taskEntity, SuspensionState state) {
      if (taskEntity.getSuspensionState() == state.getStateCode()) {
        throw new ActivitiException("Cannot set suspension state '"+state+"' for " + taskEntity + "': already in state '"+state+"'.");
      }
      taskEntity.setSuspensionState(state.getStateCode());
    }
View Full Code Here

TOP

Related Classes of org.activiti.engine.ActivitiException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.