Package org.activiti.rest.service.api.engine.variable

Examples of org.activiti.rest.service.api.engine.variable.RestVariable


  }
 
  public RestVariable createBinaryRestVariable(String name, RestVariableScope scope, String type, String taskId,
      String executionId, String processInstanceId, String serverRootUrl) {
   
    RestVariable restVar = new RestVariable();
    restVar.setVariableScope(scope);
    restVar.setName(name);
    restVar.setType(type);
   
    if (taskId != null) {
      restVar.setValueUrl(formatUrl(serverRootUrl, RestUrls.URL_TASK_VARIABLE_DATA, taskId, name));
    }
    if (executionId != null) {
      restVar.setValueUrl(formatUrl(serverRootUrl, RestUrls.URL_EXECUTION_VARIABLE_DATA, executionId, name));
    }
    if (processInstanceId != null) {
      restVar.setValueUrl(formatUrl(serverRootUrl, RestUrls.URL_PROCESS_INSTANCE_VARIABLE_DATA, processInstanceId, name));
    }
   
    return restVar;
  }
View Full Code Here


      }
      if(converter == null) {
        throw new ActivitiIllegalArgumentException("Variable '" + restVariable.getName() + "' has unsupported type: '" + restVariable.getType() + "'.");
      }
     
      RestVariable temp = new RestVariable();
      temp.setValue(restVariable.getValue());
      temp.setType(restVariable.getType());
      temp.setName(restVariable.getName());
      value = converter.getVariableValue(temp);
     
    } else {
      // Revert to type determined by REST-to-Java mapping when no explicit type has been provided
      value = restVariable.getValue();
View Full Code Here

     
      try {
        @SuppressWarnings("unchecked")
        List<Object> variableObjects = (List<Object>) objectMapper.readValue(request.getInputStream(), List.class);
        for (Object restObject : variableObjects) {
          RestVariable restVariable = objectMapper.convertValue(restObject, RestVariable.class);
          inputVariables.add(restVariable);
        }
      } catch (Exception e) {
        throw new ActivitiIllegalArgumentException("Failed to serialize to a RestVariable instance", e);
      }
View Full Code Here

 
  public RestVariable createRestVariable(String name, Object value, RestVariableScope scope,
      String id, int variableType, boolean includeBinaryValue, String serverRootUrl) {
   
    RestVariableConverter converter = null;
    RestVariable restVar = new RestVariable();
    restVar.setVariableScope(scope);
    restVar.setName(name);
   
    if (value != null) {
      // Try converting the value
      for (RestVariableConverter c : variableConverters) {
        if (c.getVariableType().isAssignableFrom(value.getClass())) {
          converter = c;
          break;
        }
      }
     
      if (converter != null) {
        converter.convertVariableValue(value, restVar);
        restVar.setType(converter.getRestTypeName());
      } else {
        // Revert to default conversion, which is the serializable/byte-array form
        if (value instanceof Byte[] || value instanceof byte[]) {
          restVar.setType(BYTE_ARRAY_VARIABLE_TYPE);
        } else {
          restVar.setType(SERIALIZABLE_VARIABLE_TYPE);
        }
       
        if (includeBinaryValue) {
          restVar.setValue(value);
        }
       
        if (variableType == VARIABLE_TASK) {
          restVar.setValueUrl(formatUrl(serverRootUrl, RestUrls.URL_TASK_VARIABLE_DATA, id, name));
        } else if (variableType == VARIABLE_EXECUTION) {
          restVar.setValueUrl(formatUrl(serverRootUrl, RestUrls.URL_EXECUTION_VARIABLE_DATA, id, name));
        } else if (variableType == VARIABLE_PROCESS) {
          restVar.setValueUrl(formatUrl(serverRootUrl, RestUrls.URL_PROCESS_INSTANCE_VARIABLE_DATA, id, name));
        } else if (variableType == VARIABLE_HISTORY_TASK) {
          restVar.setValueUrl(formatUrl(serverRootUrl, RestUrls.URL_HISTORIC_TASK_INSTANCE_VARIABLE_DATA, id, name));
        } else if (variableType == VARIABLE_HISTORY_PROCESS) {
          restVar.setValueUrl(formatUrl(serverRootUrl, RestUrls.URL_HISTORIC_PROCESS_INSTANCE_VARIABLE_DATA, id, name));
        } else if (variableType == VARIABLE_HISTORY_VARINSTANCE) {
          restVar.setValueUrl(formatUrl(serverRootUrl, RestUrls.URL_HISTORIC_VARIABLE_INSTANCE_DATA, id));
        } else if (variableType == VARIABLE_HISTORY_DETAIL) {
          restVar.setValueUrl(formatUrl(serverRootUrl, RestUrls.URL_HISTORIC_DETAIL_VARIABLE_DATA, id));
        }
      }
    }
    return restVar;
  }
View Full Code Here

     
      String serverRootUrl = request.getRequestURL().toString();
      serverRootUrl = serverRootUrl.substring(0, serverRootUrl.indexOf("/runtime/executions/"));
     
      Execution execution = getExecutionFromRequest(executionId);
      RestVariable variable = getVariableFromRequest(execution, variableName, scope, true, serverRootUrl);
      if (RestResponseFactory.BYTE_ARRAY_VARIABLE_TYPE.equals(variable.getType())) {
        result = (byte[]) variable.getValue();
        response.setContentType("application/octet-stream");
       
      } else if(RestResponseFactory.SERIALIZABLE_VARIABLE_TYPE.equals(variable.getType())) {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutputStream outputStream = new ObjectOutputStream(buffer);
        outputStream.writeObject(variable.getValue());
        outputStream.close();
        result = buffer.toByteArray();
        response.setContentType("application/x-java-serialized-object");
       
      } else {
View Full Code Here

      HttpServletResponse response, String serverRootUrl) {
   
    try {
      byte[] result = null;
     
      RestVariable variable = getVariableFromRequest(execution, variableName, scope, true, serverRootUrl);
      if (RestResponseFactory.BYTE_ARRAY_VARIABLE_TYPE.equals(variable.getType())) {
        result = (byte[]) variable.getValue();
        response.setContentType("application/octet-stream");
       
      } else if (RestResponseFactory.SERIALIZABLE_VARIABLE_TYPE.equals(variable.getType())) {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutputStream outputStream = new ObjectOutputStream(buffer);
        outputStream.writeObject(variable.getValue());
        outputStream.close();
        result = buffer.toByteArray();
        response.setContentType("application/x-java-serialized-object");
       
      } else {
View Full Code Here

 
  @RequestMapping(value="/history/historic-detail/{detailId}/data", method = RequestMethod.GET)
  public @ResponseBody byte[] getVariableData(@PathVariable("detailId") String detailId, HttpServletRequest request, HttpServletResponse response) {
    try {
      byte[] result = null;
      RestVariable variable = getVariableFromRequest(true, detailId, request);
      if (RestResponseFactory.BYTE_ARRAY_VARIABLE_TYPE.equals(variable.getType())) {
        result = (byte[]) variable.getValue();
        response.setContentType("application/octet-stream");
     
      } else if(RestResponseFactory.SERIALIZABLE_VARIABLE_TYPE.equals(variable.getType())) {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutputStream outputStream = new ObjectOutputStream(buffer);
        outputStream.writeObject(variable.getValue());
        outputStream.close();
        result = buffer.toByteArray();
        response.setContentType("application/x-java-serialized-object");
       
      } else {
View Full Code Here

     
      try {
        @SuppressWarnings("unchecked")
        List<Object> variableObjects = (List<Object>) objectMapper.readValue(request.getInputStream(), List.class);
        for (Object restObject : variableObjects) {
          RestVariable restVariable = objectMapper.convertValue(restObject, RestVariable.class);
          inputVariables.add(restVariable);
        }
      } catch (Exception e) {
        throw new ActivitiIllegalArgumentException("Failed to serialize to a RestVariable instance", e);
      }
View Full Code Here

    Execution execution = getExecutionFromRequest(executionId);
   
    String serverRootUrl = request.getRequestURL().toString();
    serverRootUrl = serverRootUrl.substring(0, serverRootUrl.indexOf("/runtime/executions/"));
   
    RestVariable result = null;
    if (request instanceof MultipartHttpServletRequest) {
      result = setBinaryVariable((MultipartHttpServletRequest) request, execution,
          RestResponseFactory.VARIABLE_EXECUTION, 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("Error converting request body to RestVariable instance", e);
      }
     
      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);
    }
View Full Code Here

      byte[] result = null;
     
      String serverRootUrl = request.getRequestURL().toString();
      serverRootUrl = serverRootUrl.substring(0, serverRootUrl.indexOf("/runtime/tasks/"));
     
      RestVariable variable = getVariableFromRequest(taskId, variableName, scope, true, serverRootUrl);
      if (RestResponseFactory.BYTE_ARRAY_VARIABLE_TYPE.equals(variable.getType())) {
        result = (byte[]) variable.getValue();
        response.setContentType("application/octet-stream");
       
      } else if(RestResponseFactory.SERIALIZABLE_VARIABLE_TYPE.equals(variable.getType())) {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutputStream outputStream = new ObjectOutputStream(buffer);
        outputStream.writeObject(variable.getValue());
        outputStream.close();
        result = buffer.toByteArray();
        response.setContentType("application/x-java-serialized-object");
       
      } else {
View Full Code Here

TOP

Related Classes of org.activiti.rest.service.api.engine.variable.RestVariable

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.