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

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


  public @ResponseBody byte[] getVariableData(@PathVariable("varInstanceId") String varInstanceId,
      HttpServletRequest request, HttpServletResponse response) {
   
    try {
      byte[] result = null;
      RestVariable variable = getVariableFromRequest(true, varInstanceId, 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


  public @ResponseBody byte[] getVariableData(@PathVariable("processInstanceId") String processInstanceId,
      @PathVariable("variableName") String variableName, HttpServletRequest request, HttpServletResponse response) {
   
    try {
      byte[] result = null;
      RestVariable variable = getVariableFromRequest(true, processInstanceId, variableName, 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

      @PathVariable("variableName") String variableName, @RequestParam(value="scope", required=false) String scope,
      HttpServletRequest request, HttpServletResponse response) {
 
    try {
      byte[] result = null;
      RestVariable variable = getVariableFromRequest(true, taskId, variableName, scope, 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

    Execution execution = getProcessInstanceFromRequest(processInstanceId);
   
    String serverRootUrl = request.getRequestURL().toString();
    serverRootUrl = serverRootUrl.substring(0, serverRootUrl.indexOf("/runtime/process-instances/"));
   
    RestVariable result = null;
    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);
    }
View Full Code Here

    Task task = getTaskFromRequest(taskId);
   
    String serverRootUrl = request.getRequestURL().toString();
    serverRootUrl = serverRootUrl.substring(0, serverRootUrl.indexOf("/runtime/tasks/"));
   
    RestVariable result = null;
    if (request instanceof MultipartHttpServletRequest) {
      result = setBinaryVariable((MultipartHttpServletRequest) request, task, 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, task, false, serverRootUrl);
    }
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.