public virtual void deleteProcessInstance(bool skipCustomListeners, bool skipIoMappings, bool skipSubprocesses, bool failIfNotExists) { RuntimeService runtimeService = engine.RuntimeService; try { if (failIfNotExists) { runtimeService.deleteProcessInstance(processInstanceId, null, skipCustomListeners, true, skipIoMappings, skipSubprocesses); } else { runtimeService.deleteProcessInstanceIfExists(processInstanceId, null, skipCustomListeners, true, skipIoMappings, skipSubprocesses); } } catch (AuthorizationException e) { throw e; } catch (ProcessEngineException e) { throw new InvalidRequestException(Status.NOT_FOUND, e, "Process instance with id " + processInstanceId + " does not exist"); } }