@POST
  @Produces(MediaType.APPLICATION_XML)
  @Path("/withvars/process/instance/{procInstId: [0-9]+}/signal")
  public JaxbProcessInstanceWithVariablesResponse signalProcessInstanceWithVars(
      @PathParam("procInstId") Long procInstId) {
    Map<String, List<String>> params = getRequestParams(request);
    String eventType = getStringParam("eventType", true, params, "signal");
    Object event = getObjectParam("event", false, params, "signal");
    Command<?> cmd = new SignalEventCommand(procInstId, eventType, event);
    String errorMsg = "Unable to signal process instance " + procInstId;
    if (eventType == null) {
      errorMsg += " with empty signal";
    } else {
      errorMsg += " with signal type '" + eventType + "'";
    }
    if (event != null) {
      errorMsg += " and event '" + event + "'";
    }
    internalDoKieSessionOperation(cmd, errorMsg);

    cmd = new GetProcessInstanceCommand(procInstId);
    ((GetProcessInstanceCommand) cmd).setReadOnly(true);
    Object result =
        internalDoKieSessionOperation(cmd, "Unable to get process instance " + procInstId);
    ProcessInstance processInstance = (ProcessInstance) result;

    Map<String, String> vars = getVariables(processInstance.getId());

    return new JaxbProcessInstanceWithVariablesResponse(processInstance, vars);
  }
  private ProcessInstance getProcessInstance(long procInstId) {
    Command<?> cmd = new GetProcessInstanceCommand(procInstId);
    ((GetProcessInstanceCommand) cmd).setReadOnly(true);
    Object procInstResult =
        processRequestBean.doKieSessionOperation(
            cmd,
            deploymentId,
            procInstId,
            "Unable to get process instance with id id '" + procInstId + "'");

    if (procInstResult == null) {
      throw RestOperationException.notFound(
          "This method can only be used on processes that are still active.");
    }
    return (ProcessInstance) procInstResult;
  }
  @GET
  @Produces(MediaType.APPLICATION_XML)
  @Path("/process/instance/{procInstId: [0-9]+}")
  public JaxbProcessInstanceResponse getProcessInstanceDetails(
      @PathParam("procInstId") Long procInstId) {
    Command<?> cmd = new GetProcessInstanceCommand(procInstId);
    ((GetProcessInstanceCommand) cmd).setReadOnly(true);

    Object result =
        internalDoKieSessionOperation(cmd, "Unable to get process instance " + procInstId);
    if (result != null) {
      return new JaxbProcessInstanceResponse((ProcessInstance) result);
    } else {
      throw new BadRequestException(
          "Unable to retrieve process instance "
              + procInstId
              + " which may have been completed. Please see the history operations.");
    }
  }
  @GET
  @Produces(MediaType.APPLICATION_XML)
  @Path("/withvars/process/instance/{procInstId: [0-9]+}")
  public JaxbProcessInstanceWithVariablesResponse getProcessInstanceWithVars(
      @PathParam("procInstId") Long procInstId) {
    Command<?> cmd = new GetProcessInstanceCommand(procInstId);
    ((GetProcessInstanceCommand) cmd).setReadOnly(true);

    Object result =
        internalDoKieSessionOperation(cmd, "Unable to get process instance " + procInstId);
    if (result != null) {
      ProcessInstance procInst = (ProcessInstance) result;
      Map<String, String> vars = getVariables(procInstId);
      return new JaxbProcessInstanceWithVariablesResponse(procInst, vars, request);
    } else {
      throw new BadRequestException(
          "Unable to retrieve process instance "
              + procInstId
              + " since it has been completed. Please see the history operations.");
    }
  }
  @GET
  @Path("/process/instance/{procInstId: [0-9]+}")
  public Response process_instance_procInstId(@PathParam("procInstId") Long procInstId) {
    Command<?> cmd = new GetProcessInstanceCommand(procInstId);
    ((GetProcessInstanceCommand) cmd).setReadOnly(true);

    Object result =
        processRequestBean.doKieSessionOperation(
            cmd, deploymentId, procInstId, "Unable to get process instance " + procInstId);

    Object responseObj = null;
    if (result != null) {
      responseObj = new JaxbProcessInstanceResponse((ProcessInstance) result);
      return createCorrectVariant(responseObj, headers);
    } else {
      throw RestOperationException.notFound(
          "Unable to retrieve process instance "
              + procInstId
              + " which may have been completed. Please see the history operations.");
    }
  }