Package org.activiti.engine

Examples of org.activiti.engine.ActivitiIllegalArgumentException


   
  }
 
  protected RestVariable setSimpleVariable(RestVariable restVariable, Execution execution, boolean isNew, String serverRootUrl) {
    if (restVariable.getName() == null) {
      throw new ActivitiIllegalArgumentException("Variable name is required");
    }

    // Figure out scope, revert to local is omitted
    RestVariableScope scope = restVariable.getVariableScope();
    if (scope == null) {
View Full Code Here


      AttachmentRequest attachmentRequest = null;
      try {
        attachmentRequest = objectMapper.readValue(request.getInputStream(), AttachmentRequest.class);
       
      } catch (Exception e) {
        throw new ActivitiIllegalArgumentException("Failed to serialize to a AttachmentRequest instance", e);
      }
     
      if (attachmentRequest == null) {
        throw new ActivitiIllegalArgumentException("AttachmentRequest properties not found in request");
      }
     
      result = createSimpleAttachment(attachmentRequest, task, serverRootUrl);
    }
   
View Full Code Here

 
  protected AttachmentResponse createSimpleAttachment(AttachmentRequest attachmentRequest,
      Task task, String serverRootUrl) {
   
    if (attachmentRequest.getName() == null) {
      throw new ActivitiIllegalArgumentException("Attachment name is required.");
    }

    Attachment createdAttachment = taskService.createAttachment(attachmentRequest.getType(), task.getId(),
        task.getProcessInstanceId(), attachmentRequest.getName(), attachmentRequest.getDescription(), attachmentRequest.getExternalUrl());
View Full Code Here

        }
      }
    }
   
    if (name == null) {
      throw new ActivitiIllegalArgumentException("Attachment name is required.");
    }
   
    if (request.getFileMap().size() == 0) {
      throw new ActivitiIllegalArgumentException("Attachment content is required.");
    }
   
    MultipartFile file = request.getFileMap().values().iterator().next();
   
    if (file == null) {
      throw new ActivitiIllegalArgumentException("Attachment content is required.");
    }
   
    try {
      Attachment createdAttachment = taskService.createAttachment(type, task.getId(), task.getProcessInstanceId(), name,
              description, file.getInputStream());
View Full Code Here

    response.setStatus(HttpStatus.NO_CONTENT.value());
  }
 
  protected void validateIdentityLinkArguments(String identityId, String type) {
    if (identityId == null) {
      throw new ActivitiIllegalArgumentException("IdentityId is required.");
    }
    if (type == null) {
      throw new ActivitiIllegalArgumentException("Type is required.");
    }
  }
View Full Code Here

      if (DelegationState.RESOLVED.name().toLowerCase().equals(delegationState)) {
        return DelegationState.RESOLVED;
      } else if (DelegationState.PENDING.name().toLowerCase().equals(delegationState)) {
        return DelegationState.PENDING;
      } else {
        throw new ActivitiIllegalArgumentException("Illegal value for delegationState: " + delegationState);
      }
    }
    return state;
  }
View Full Code Here

 
  protected void addTaskvariables(TaskQuery taskQuery, List<QueryVariable> variables) {
   
    for (QueryVariable variable : variables) {
      if (variable.getVariableOperation() == null) {
        throw new ActivitiIllegalArgumentException("Variable operation is missing for variable: " + variable.getName());
      }
      if (variable.getValue() == null) {
        throw new ActivitiIllegalArgumentException("Variable value is missing for variable: " + variable.getName());
      }
     
      boolean nameLess = variable.getName() == null;
     
      Object actualValue = restResponseFactory.getVariableValue(variable);
     
      // A value-only query is only possible using equals-operator
      if (nameLess && variable.getVariableOperation() != QueryVariableOperation.EQUALS) {
        throw new ActivitiIllegalArgumentException("Value-only query (without a variable-name) is only supported when using 'equals' operation.");
      }
     
      switch(variable.getVariableOperation()) {
     
      case EQUALS:
        if (nameLess) {
          taskQuery.taskVariableValueEquals(actualValue);
        } else {
          taskQuery.taskVariableValueEquals(variable.getName(), actualValue);
        }
        break;
       
      case EQUALS_IGNORE_CASE:
        if (actualValue instanceof String) {
          taskQuery.taskVariableValueEqualsIgnoreCase(variable.getName(), (String)actualValue);
        } else {
          throw new ActivitiIllegalArgumentException("Only string variable values are supported when ignoring casing, but was: " + actualValue.getClass().getName());
        }
        break;
       
      case NOT_EQUALS:
        taskQuery.taskVariableValueNotEquals(variable.getName(), actualValue);
        break;
       
      case NOT_EQUALS_IGNORE_CASE:
        if (actualValue instanceof String) {
          taskQuery.taskVariableValueNotEqualsIgnoreCase(variable.getName(), (String)actualValue);
        } else {
          throw new ActivitiIllegalArgumentException("Only string variable values are supported when ignoring casing, but was: " + actualValue.getClass().getName());
        }
        break;
       
      case GREATER_THAN:
        taskQuery.taskVariableValueGreaterThan(variable.getName(), actualValue);
        break;
       
      case GREATER_THAN_OR_EQUALS:
        taskQuery.taskVariableValueGreaterThanOrEqual(variable.getName(), actualValue);
        break;
       
      case LESS_THAN:
        taskQuery.taskVariableValueLessThan(variable.getName(), actualValue);
        break;
       
      case LESS_THAN_OR_EQUALS:
        taskQuery.taskVariableValueLessThanOrEqual(variable.getName(), actualValue);
        break;
       
      case LIKE:
        if (actualValue instanceof String) {
          taskQuery.taskVariableValueLike(variable.getName(), (String) actualValue);
        } else {
          throw new ActivitiIllegalArgumentException("Only string variable values are supported using like, but was: " + actualValue.getClass().getName());
        }
        break;
      default:
        throw new ActivitiIllegalArgumentException("Unsupported variable query operation: " + variable.getVariableOperation());
      }
    }
  }
View Full Code Here

  }
 
  protected void addProcessvariables(TaskQuery taskQuery, List<QueryVariable> variables) {
    for (QueryVariable variable : variables) {
      if (variable.getVariableOperation() == null) {
        throw new ActivitiIllegalArgumentException("Variable operation is missing for variable: " + variable.getName());
      }
      if (variable.getValue() == null) {
        throw new ActivitiIllegalArgumentException("Variable value is missing for variable: " + variable.getName());
      }
     
      boolean nameLess = variable.getName() == null;
     
      Object actualValue = restResponseFactory.getVariableValue(variable);
     
      // A value-only query is only possible using equals-operator
      if (nameLess && variable.getVariableOperation() != QueryVariableOperation.EQUALS) {
        throw new ActivitiIllegalArgumentException("Value-only query (without a variable-name) is only supported when using 'equals' operation.");
      }
     
      switch(variable.getVariableOperation()) {
     
        case EQUALS:
          if (nameLess) {
            taskQuery.processVariableValueEquals(actualValue);
          } else {
            taskQuery.processVariableValueEquals(variable.getName(), actualValue);
          }
          break;
         
        case EQUALS_IGNORE_CASE:
          if (actualValue instanceof String) {
            taskQuery.processVariableValueEqualsIgnoreCase(variable.getName(), (String)actualValue);
          } else {
            throw new ActivitiIllegalArgumentException("Only string variable values are supported when ignoring casing, but was: " + actualValue.getClass().getName());
          }
          break;
         
        case NOT_EQUALS:
          taskQuery.processVariableValueNotEquals(variable.getName(), actualValue);
          break;
         
        case NOT_EQUALS_IGNORE_CASE:
          if (actualValue instanceof String) {
            taskQuery.processVariableValueNotEqualsIgnoreCase(variable.getName(), (String)actualValue);
          } else {
            throw new ActivitiIllegalArgumentException("Only string variable values are supported when ignoring casing, but was: " + actualValue.getClass().getName());
          }
          break;
         
        case GREATER_THAN:
          taskQuery.processVariableValueGreaterThan(variable.getName(), actualValue);
          break;
         
        case GREATER_THAN_OR_EQUALS:
          taskQuery.processVariableValueGreaterThanOrEqual(variable.getName(), actualValue);
          break;
         
        case LESS_THAN:
          taskQuery.processVariableValueLessThan(variable.getName(), actualValue);
          break;
         
        case LESS_THAN_OR_EQUALS:
          taskQuery.processVariableValueLessThanOrEqual(variable.getName(), actualValue);
          break;
         
        case LIKE:
          if (actualValue instanceof String) {
            taskQuery.processVariableValueLike(variable.getName(), (String) actualValue);
          } else {
            throw new ActivitiIllegalArgumentException("Only string variable values are supported using like, but was: " + actualValue.getClass().getName());
          }
          break;
         
        default:
          throw new ActivitiIllegalArgumentException("Unsupported variable query operation: " + variable.getVariableOperation());
      }
    }
  }
View Full Code Here

  @RequestMapping(value="/runtime/process-instances", method = RequestMethod.POST, produces="application/json")
  public ProcessInstanceResponse createProcessInstance(@RequestBody ProcessInstanceCreateRequest request,
      HttpServletRequest httpRequest, HttpServletResponse response) {
   
    if (request.getProcessDefinitionId() == null && request.getProcessDefinitionKey() == null && request.getMessage() == null) {
      throw new ActivitiIllegalArgumentException("Either processDefinitionId, processDefinitionKey or message is required.");
    }
   
    int paramsSet = ((request.getProcessDefinitionId() != null) ? 1 : 0)
            + ((request.getProcessDefinitionKey() != null) ? 1 : 0)
            + ((request.getMessage() != null) ? 1 : 0);
   
    if (paramsSet > 1) {
      throw new ActivitiIllegalArgumentException("Only one of processDefinitionId, processDefinitionKey or message should be set.");
    }
   
    if (request.isCustomTenantSet()) {
      // Tenant-id can only be used with either key or message
      if(request.getProcessDefinitionId() != null) {
        throw new ActivitiIllegalArgumentException("TenantId can only be used with either processDefinitionKey or message.");
      }
    }
   
    Map<String, Object> startVariables = null;
    if (request.getVariables() != null) {
      startVariables = new HashMap<String, Object>();
      for (RestVariable variable : request.getVariables()) {
        if (variable.getName() == null) {
          throw new ActivitiIllegalArgumentException("Variable name is required.");
        }
        startVariables.put(variable.getName(), restResponseFactory.getVariableValue(variable));
      }
    }
   
    // Actually start the instance based on key or id
    try {
      ProcessInstance instance = null;
      if (request.getProcessDefinitionId() != null) {
        instance = runtimeService.startProcessInstanceById(
                request.getProcessDefinitionId(), request.getBusinessKey(), startVariables);
      } else if (request.getProcessDefinitionKey() != null) {
        if (request.isCustomTenantSet()) {
          instance = runtimeService.startProcessInstanceByKeyAndTenantId(
              request.getProcessDefinitionKey(), request.getBusinessKey(), startVariables, request.getTenantId());
        } else {
          instance = runtimeService.startProcessInstanceByKey(
              request.getProcessDefinitionKey(), request.getBusinessKey(), startVariables);
        }
      } else {
        if (request.isCustomTenantSet()) {
          instance = runtimeService.startProcessInstanceByMessageAndTenantId(
              request.getMessage(), request.getBusinessKey(), startVariables, request.getTenantId());
        } else {
          instance = runtimeService.startProcessInstanceByMessage(
              request.getMessage(), request.getBusinessKey(), startVariables);
        }
      }
     
      response.setStatus(HttpStatus.CREATED.value());
     
      String serverRootUrl = httpRequest.getRequestURL().toString().replace("/runtime/process-instances", "");
     
      //Added by Ryan Johnston
      if (request.getReturnVariables()) {
        Map<String, Object> runtimeVariableMap = null;
        List<HistoricVariableInstance> historicVariableList = null;
        if (instance.isEnded()) {
          historicVariableList = historyService.createHistoricVariableInstanceQuery()
              .processInstanceId(instance.getId())
              .list();
        } else {
          runtimeVariableMap = runtimeService.getVariables(instance.getId());
        }
        return restResponseFactory.createProcessInstanceResponse(instance, true,
            runtimeVariableMap, historicVariableList, serverRootUrl);
       
      } else {
        return restResponseFactory.createProcessInstanceResponse(instance, serverRootUrl);
      }
      //End Added by Ryan Johnston
     
      //Removed by Ryan Johnston (obsolete given the above).
      //return factory.createProcessInstanceResponse(this, instance);
    } catch(ActivitiObjectNotFoundException aonfe) {
      throw new ActivitiIllegalArgumentException(aonfe.getMessage(), aonfe);
    }
  }
View Full Code Here

    if (request instanceof MultipartHttpServletRequest) {
      result = setBinaryVariable((MultipartHttpServletRequest) request, execution,
          RestResponseFactory.VARIABLE_PROCESS, false, serverRootUrl);
     
      if (!result.getName().equals(variableName)) {
        throw new ActivitiIllegalArgumentException("Variable name in the body should be equal to the name used in the requested URL.");
      }
     
    } else {
      RestVariable restVariable = null;
      try {
        restVariable = objectMapper.readValue(request.getInputStream(), RestVariable.class);
      } catch (Exception e) {
        throw new ActivitiIllegalArgumentException("request body could not be transformed to a RestVariable instance.");
      }
     
      if (restVariable == null) {
        throw new ActivitiException("Invalid body was supplied");
      }
      if (!restVariable.getName().equals(variableName)) {
        throw new ActivitiIllegalArgumentException("Variable name in the body should be equal to the name used in the requested URL.");
      }
     
      result = setSimpleVariable(restVariable, execution, false, serverRootUrl);
    }
    return result;
View Full Code Here

TOP

Related Classes of org.activiti.engine.ActivitiIllegalArgumentException

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.