@PUT
  @Path(PROCESS_INSTANCE_WORK_ITEM_ABORT_PUT_URI)
  @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
  public Response abortWorkItem(
      @javax.ws.rs.core.Context HttpHeaders headers,
      @PathParam("id") String containerId,
      @PathParam("pInstanceId") Long processInstanceId,
      @PathParam("workItemId") Long workItemId) {
    Variant v = getVariant(headers);
    Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
    try {

      processServiceBase.abortWorkItem(containerId, processInstanceId, workItemId);

      return createResponse("", v, Response.Status.CREATED, conversationIdHeader);

    } catch (ProcessInstanceNotFoundException e) {
      return notFound(
          MessageFormat.format(PROCESS_INSTANCE_NOT_FOUND, processInstanceId),
          v,
          conversationIdHeader);
    } catch (DeploymentNotFoundException e) {
      return notFound(
          MessageFormat.format(CONTAINER_NOT_FOUND, containerId), v, conversationIdHeader);
    } catch (Exception e) {
      logger.error("Unexpected error during processing {}", e.getMessage(), e);
      return internalServerError(
          MessageFormat.format(UNEXPECTED_ERROR, e.getMessage()), v, conversationIdHeader);
    }
  }
  @GET
  @Path(PROCESS_INSTANCE_WORK_ITEMS_BY_PROC_INST_ID_GET_URI)
  @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
  public Response getWorkItemByProcessInstance(
      @javax.ws.rs.core.Context HttpHeaders headers,
      @PathParam("id") String containerId,
      @PathParam("pInstanceId") Long processInstanceId) {
    Variant v = getVariant(headers);
    String type = getContentType(headers);
    Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
    try {

      String response =
          processServiceBase.getWorkItemByProcessInstance(containerId, processInstanceId, type);

      logger.debug("Returning OK response with content '{}'", response);
      return createResponse(response, v, Response.Status.OK, conversationIdHeader);
    } catch (ProcessInstanceNotFoundException e) {
      return notFound(
          MessageFormat.format(PROCESS_INSTANCE_NOT_FOUND, processInstanceId),
          v,
          conversationIdHeader);
    } catch (DeploymentNotFoundException e) {
      return notFound(
          MessageFormat.format(CONTAINER_NOT_FOUND, containerId), v, conversationIdHeader);
    } catch (Exception e) {
      logger.error("Unexpected error during processing {}", e.getMessage(), e);
      return internalServerError(
          MessageFormat.format(UNEXPECTED_ERROR, e.getMessage()), v, conversationIdHeader);
    }
  }
  @POST
  @Path(PROCESS_INSTANCE_VARS_POST_URI)
  @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
  @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
  public Response setProcessVariables(
      @javax.ws.rs.core.Context HttpHeaders headers,
      @PathParam("id") String containerId,
      @PathParam("pInstanceId") Long processInstanceId,
      String variablePayload) {
    Variant v = getVariant(headers);
    String type = getContentType(headers);
    Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
    try {

      processServiceBase.setProcessVariables(containerId, processInstanceId, variablePayload, type);
      return createResponse("", v, Response.Status.OK, conversationIdHeader);

    } catch (ProcessInstanceNotFoundException e) {
      return notFound(
          MessageFormat.format(PROCESS_INSTANCE_NOT_FOUND, processInstanceId),
          v,
          conversationIdHeader);
    } catch (DeploymentNotFoundException e) {
      return notFound(
          MessageFormat.format(CONTAINER_NOT_FOUND, containerId), v, conversationIdHeader);
    } catch (Exception e) {
      logger.error("Unexpected error during processing {}", e.getMessage(), e);
      return internalServerError(
          MessageFormat.format(UNEXPECTED_ERROR, e.getMessage()), v, conversationIdHeader);
    }
  }
 @DELETE
 @Path(ABORT_PROCESS_INSTANCES_DEL_URI)
 @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
 public Response abortProcessInstances(
     @javax.ws.rs.core.Context HttpHeaders headers,
     @PathParam("id") String containerId,
     @QueryParam("instanceId") List<Long> processInstanceIds) {
   Variant v = getVariant(headers);
   Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
   try {
     processServiceBase.abortProcessInstances(containerId, processInstanceIds);
     // produce 204 NO_CONTENT response code
     return noContent(v, conversationIdHeader);
   } catch (ProcessInstanceNotFoundException e) {
     return notFound(
         MessageFormat.format(PROCESS_INSTANCE_NOT_FOUND, processInstanceIds),
         v,
         conversationIdHeader);
   } catch (DeploymentNotFoundException e) {
     return notFound(
         MessageFormat.format(CONTAINER_NOT_FOUND, containerId), v, conversationIdHeader);
   } catch (Exception e) {
     logger.error("Unexpected error during processing {}", e.getMessage(), e);
     return internalServerError(
         MessageFormat.format(UNEXPECTED_ERROR, e.getMessage()), v, conversationIdHeader);
   }
 }
  @POST
  @Path(START_PROCESS_WITH_CORRELATION_KEY_POST_URI)
  @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
  @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
  public Response startProcessWithCorrelation(
      @javax.ws.rs.core.Context HttpHeaders headers,
      @PathParam("id") String containerId,
      @PathParam("pId") String processId,
      @PathParam("correlationKey") String correlationKey,
      @DefaultValue("") String payload) {
    Variant v = getVariant(headers);
    String type = getContentType(headers);

    try {
      String response =
          processServiceBase.startProcessWithCorrelation(
              containerId, processId, correlationKey, payload, type);

      logger.debug("Returning CREATED response with content '{}'", response);
      Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
      return createResponse(response, v, Response.Status.CREATED, conversationIdHeader);
    } catch (Exception e) {
      logger.error("Unexpected error during processing {}", e.getMessage(), e);
      return internalServerError(MessageFormat.format(CREATE_RESPONSE_ERROR, e.getMessage()), v);
    }
  }
  @POST
  @Path(SIGNAL_PROCESS_INSTANCES_PORT_URI)
  @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
  @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
  public Response signalProcessInstances(
      @javax.ws.rs.core.Context HttpHeaders headers,
      @PathParam("id") String containerId,
      @QueryParam("instanceId") List<Long> processInstanceIds,
      @PathParam("sName") String signalName,
      String eventPayload) {
    Variant v = getVariant(headers);
    String type = getContentType(headers);
    Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
    try {
      if (processInstanceIds != null && !processInstanceIds.isEmpty()) {
        logger.debug("Signaling given process instances - {}", processInstanceIds);
        processServiceBase.signalProcessInstances(
            containerId, processInstanceIds, signalName, eventPayload, type);
      } else {
        logger.debug("No process instances given, signal container..");
        processServiceBase.signal(containerId, signalName, eventPayload, type);
      }

      return createResponse("", v, Response.Status.OK, conversationIdHeader);

    } catch (ProcessInstanceNotFoundException e) {
      return notFound(
          MessageFormat.format(PROCESS_INSTANCE_NOT_FOUND, processInstanceIds),
          v,
          conversationIdHeader);
    } catch (DeploymentNotFoundException e) {
      return notFound(
          MessageFormat.format(CONTAINER_NOT_FOUND, containerId), v, conversationIdHeader);
    } catch (Exception e) {
      logger.error("Unexpected error during processing {}", e.getMessage(), e);
      return internalServerError(
          MessageFormat.format(UNEXPECTED_ERROR, e.getMessage()), v, conversationIdHeader);
    }
  }
  @GET
  @Path(PROCESS_INSTANCE_GET_URI)
  @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
  public Response getProcessInstance(
      @javax.ws.rs.core.Context HttpHeaders headers,
      @PathParam("id") String containerId,
      @PathParam("pInstanceId") Long processInstanceId,
      @QueryParam("withVars") boolean withVars) {
    Variant v = getVariant(headers);
    String type = getContentType(headers);
    try {

      String response =
          processServiceBase.getProcessInstance(containerId, processInstanceId, withVars, type);

      logger.debug("Returning OK response with content '{}'", response);
      Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
      return createResponse(response, v, Response.Status.OK, conversationIdHeader);

    } catch (Exception e) {
      logger.error("Unexpected error during processing {}", e.getMessage(), e);
      return internalServerError(MessageFormat.format(UNEXPECTED_ERROR, e.getMessage()), v);
    }
  }