Package org.activiti.engine

Examples of org.activiti.engine.ActivitiIllegalArgumentException


  @Override
  public Object getVariableValue(RestVariable result) {
    if(result.getValue() != null) {
      if(!(result.getValue() instanceof Number)) {
        throw new ActivitiIllegalArgumentException("Converter can only convert integers");
      }
      return ((Number) result.getValue()).intValue();
    }
    return null;
  }
View Full Code Here


  @Override
  public void convertVariableValue(Object variableValue, RestVariable result) {
    if(variableValue != null) {
      if(!(variableValue instanceof Integer)) {
        throw new ActivitiIllegalArgumentException("Converter can only convert integers");
      }
      result.setValue(variableValue);
    } else {
      result.setValue(null);
    }
View Full Code Here

  @Override
  public Object getVariableValue(RestVariable result) {
    if(result.getValue() != null) {
      if(!(result.getValue() instanceof Number)) {
        throw new ActivitiIllegalArgumentException("Converter can only convert doubles");
      }
      return ((Number) result.getValue()).doubleValue();
    }
    return null;
  }
View Full Code Here

  @Override
  public void convertVariableValue(Object variableValue, RestVariable result) {
    if(variableValue != null) {
      if(!(variableValue instanceof Double)) {
        throw new ActivitiIllegalArgumentException("Converter can only convert doubles");
      }
      result.setValue(variableValue);
    } else {
      result.setValue(null);
    }
View Full Code Here

  }
 
  protected void addVariables(HistoricVariableInstanceQuery variableInstanceQuery, 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) {
        throw new ActivitiIllegalArgumentException("Value-only query (without a variable-name) is not supported");
      }

      switch (variable.getVariableOperation()) {

      case EQUALS:
        variableInstanceQuery.variableValueEquals(variable.getName(), actualValue);
        break;

      default:
        throw new ActivitiIllegalArgumentException("Unsupported variable query operation: " + variable.getVariableOperation());
      }
    }
  }
View Full Code Here

     
    } else if (TaskActionRequest.ACTION_RESOLVE.equals(actionRequest.getAction())) {
      resolveTask(task, actionRequest);
     
    } else {
      throw new ActivitiIllegalArgumentException("Invalid action: '" + actionRequest.getAction() + "'.");
    }
  }
View Full Code Here

  protected void completeTask(Task task, TaskActionRequest actionRequest) {
    if(actionRequest.getVariables() != null) {
      Map<String, Object> variablesToSet = new HashMap<String, Object>();
      for(RestVariable var : actionRequest.getVariables()) {
        if(var.getName() == null) {
          throw new ActivitiIllegalArgumentException("Variable name is required");
        }
       
        Object actualVariableValue = restResponseFactory.getVariableValue(var);
        variablesToSet.put(var.getName(), actualVariableValue);
      }
View Full Code Here

    taskService.resolveTask(task.getId());
  }

  protected void delegateTask(Task task, TaskActionRequest actionRequest) {
    if (actionRequest.getAssignee() == null) {
      throw new ActivitiIllegalArgumentException("An assignee is required when delegating a task.");
    }
    taskService.delegateTask(task.getId(), actionRequest.getAssignee());
  }
View Full Code Here

      @RequestBody RestIdentityLink identityLink, HttpServletRequest request, HttpServletResponse response) {
   
    Task task = getTaskFromRequest(taskId);
   
    if (identityLink.getGroup() == null && identityLink.getUser() == null) {
      throw new ActivitiIllegalArgumentException("A group or a user is required to create an identity link.");
    }
   
    if (identityLink.getGroup() != null && identityLink.getUser() != null) {
      throw new ActivitiIllegalArgumentException("Only one of user or group can be used to create an identity link.");
    }
   
    if (identityLink.getType() == null) {
      throw new ActivitiIllegalArgumentException("The identity link type is required.");
    }

    if (identityLink.getGroup() != null) {
      taskService.addGroupIdentityLink(task.getId(), identityLink.getGroup(), identityLink.getType());
    } else {
View Full Code Here

  protected RestVariable setBinaryVariable(MultipartHttpServletRequest request, Task task,
      boolean isNew, String serverRootUrl) {
   
    // Validate input and set defaults
    if (request.getFileMap().size() == 0) {
      throw new ActivitiIllegalArgumentException("No file content was found in request body.");
    }
   
    // Get first file in the map, ignore possible other files
    MultipartFile file = request.getFile(request.getFileMap().keySet().iterator().next());
   
    if (file == null) {
      throw new ActivitiIllegalArgumentException("No file content was found in request body.");
    }
   
    String variableScope = null;
    String variableName = null;
    String variableType = null;
   
    Map<String, String[]> paramMap = request.getParameterMap();
    for (String parameterName : paramMap.keySet()) {
     
      if (paramMap.get(parameterName).length > 0) {
     
        if (parameterName.equalsIgnoreCase("scope")) {
          variableScope = paramMap.get(parameterName)[0];
         
        } else if (parameterName.equalsIgnoreCase("name")) {
          variableName = paramMap.get(parameterName)[0];
         
        } else if (parameterName.equalsIgnoreCase("type")) {
          variableType = paramMap.get(parameterName)[0];
        }
      }
    }
   
    try {
     
      if (variableName == null) {
        throw new ActivitiIllegalArgumentException("No variable name was found in request body.");
      }
     
      if (variableType != null) {
        if (!RestResponseFactory.BYTE_ARRAY_VARIABLE_TYPE.equals(variableType) && !RestResponseFactory.SERIALIZABLE_VARIABLE_TYPE.equals(variableType)) {
          throw new ActivitiIllegalArgumentException("Only 'binary' and 'serializable' are supported as variable type.");
        }
      } else {
        variableType = RestResponseFactory.BYTE_ARRAY_VARIABLE_TYPE;
      }
     
      RestVariableScope scope = RestVariableScope.LOCAL;
      if (variableScope != null) {
        scope = RestVariable.getScopeFromString(variableScope);
      }
     
      if (variableType.equals(RestResponseFactory.BYTE_ARRAY_VARIABLE_TYPE)) {
        // Use raw bytes as variable value
        byte[] variableBytes = IOUtils.toByteArray(file.getInputStream());
        setVariable(task, variableName, variableBytes, scope, isNew);
       
      } else {
        // Try deserializing the object
        ObjectInputStream stream = new ObjectInputStream(file.getInputStream());
        Object value = stream.readObject();
        setVariable(task, variableName, value, scope, isNew);
        stream.close();
      }
     
      return restResponseFactory.createBinaryRestVariable(variableName, scope, variableType, task.getId(), null, null, serverRootUrl);
     
    } catch (IOException ioe) {
      throw new ActivitiIllegalArgumentException("Error getting binary variable", ioe);
    } catch (ClassNotFoundException ioe) {
      throw new ActivitiContentNotSupportedException("The provided body contains a serialized object for which the class is nog found: " + ioe.getMessage());
    }
   
  }
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.