use of org.jbpm.services.api.DeploymentNotActiveException in project jbpm by kiegroup.
the class ProcessServiceImpl method startProcessFromNodeIds.
@Override
public Long startProcessFromNodeIds(String deploymentId, String processId, CorrelationKey key, Map<String, Object> params, String... nodeIds) {
DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentId);
if (deployedUnit == null) {
throw new DeploymentNotFoundException("No deployments available for " + deploymentId);
}
if (!deployedUnit.isActive()) {
throw new DeploymentNotActiveException("Deployment " + deploymentId + " is not active");
}
RuntimeManager manager = deployedUnit.getRuntimeManager();
params = process(params, ((InternalRuntimeManager) manager).getEnvironment().getClassLoader());
RuntimeEngine engine = manager.getRuntimeEngine(getContext(params));
KieSession ksession = engine.getKieSession();
ProcessInstance pi;
try {
if (key == null) {
pi = ksession.startProcessFromNodeIds(processId, params, nodeIds);
} else {
pi = ((CorrelationAwareProcessRuntime) ksession).startProcessFromNodeIds(processId, key, params, nodeIds);
}
return pi.getId();
} finally {
disposeRuntimeEngine(manager, engine);
}
}
use of org.jbpm.services.api.DeploymentNotActiveException in project jbpm by kiegroup.
the class ProcessServiceImpl method computeProcessOutcome.
@Override
public Map<String, Object> computeProcessOutcome(String deploymentId, String processId, Map<String, Object> params) {
DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentId);
if (deployedUnit == null) {
throw new DeploymentNotFoundException("No deployments available for " + deploymentId);
}
if (!deployedUnit.isActive()) {
throw new DeploymentNotActiveException("Deployment " + deploymentId + " is not active");
}
RuntimeManager manager = deployedUnit.getRuntimeManager();
params = process(params, ((InternalRuntimeManager) manager).getEnvironment().getClassLoader());
RuntimeEngine engine = manager.getRuntimeEngine(getContext(params));
KieSession ksession = engine.getKieSession();
// copy variables
Map<String, Object> vars = params != null ? new HashMap<>(params) : new HashMap<>();
ksession.addEventListener(new DefaultProcessEventListener() {
@Override
public void afterVariableChanged(ProcessVariableChangedEvent event) {
vars.put(event.getVariableId(), event.getNewValue());
}
});
try {
ksession.startProcess(processId, params);
} finally {
disposeRuntimeEngine(manager, engine);
}
return vars;
}
use of org.jbpm.services.api.DeploymentNotActiveException in project jbpm by kiegroup.
the class ProcessServiceImpl method startProcess.
@Override
public Long startProcess(String deploymentId, String processId, CorrelationKey correlationKey, Map<String, Object> params) {
DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentId);
if (deployedUnit == null) {
throw new DeploymentNotFoundException("No deployments available for " + deploymentId);
}
if (!deployedUnit.isActive()) {
throw new DeploymentNotActiveException("Deployment " + deploymentId + " is not active");
}
RuntimeManager manager = deployedUnit.getRuntimeManager();
params = process(params, ((InternalRuntimeManager) manager).getEnvironment().getClassLoader());
RuntimeEngine engine = manager.getRuntimeEngine(getContext(params));
KieSession ksession = engine.getKieSession();
ProcessInstance pi;
try {
pi = ((CorrelationAwareProcessRuntime) ksession).startProcess(processId, correlationKey, params);
return pi.getId();
} finally {
disposeRuntimeEngine(manager, engine);
}
}
use of org.jbpm.services.api.DeploymentNotActiveException in project droolsjbpm-integration by kiegroup.
the class ProcessResource method startSynchronousProcess.
@ApiOperation(value = "Starts a new synchronous process instance of a specified process.")
@ApiResponses(value = { @ApiResponse(code = 201, response = Map.class, message = "Process instance started", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = VAR_MAP_JSON), @ExampleProperty(mediaType = XML, value = VAR_MAP_XML) })), @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Process ID or Container Id not found"), @ApiResponse(code = 403, message = "User does not have permission to access this asset") })
@POST
@Path(COMPUTE_PROCESS_OUTCOME_POST_URI)
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response startSynchronousProcess(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "container id where the process definition resides", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "process id that new instance should be created from", required = true, example = "evaluation") @PathParam(PROCESS_ID) String processId, @ApiParam(value = "optional map of process variables", required = false, examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = VAR_MAP_JSON), @ExampleProperty(mediaType = XML, value = VAR_MAP_XML) })) @DefaultValue("") String payload) {
Variant v = getVariant(headers);
String type = getContentType(headers);
Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
try {
String response = processServiceBase.computeProcessOutcome(containerId, processId, payload, type);
logger.debug("Returning CREATED response with content '{}'", response);
return createResponse(response, v, Response.Status.CREATED, conversationIdHeader);
} catch (DeploymentNotActiveException e) {
return badRequest(e.getMessage(), v);
} catch (DeploymentNotFoundException e) {
return notFound(MessageFormat.format(CONTAINER_NOT_FOUND, containerId), v);
} catch (ProcessDefinitionNotFoundException e) {
return notFound(MessageFormat.format(PROCESS_DEFINITION_NOT_FOUND, processId, containerId), v);
} catch (SecurityException e) {
return forbidden(errorMessage(e, e.getMessage()), v, conversationIdHeader);
} catch (Exception e) {
logger.error("Unexpected error during processing {}", e.getMessage(), e);
return internalServerError(MessageFormat.format(CREATE_RESPONSE_ERROR, e.getMessage()), v);
}
}
use of org.jbpm.services.api.DeploymentNotActiveException in project droolsjbpm-integration by kiegroup.
the class ProcessResource method startProcess.
@ApiOperation(value = "Starts a new process instance of a specified process.")
@ApiResponses(value = { @ApiResponse(code = 201, response = Long.class, message = "Process instance started", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = LONG_RESPONSE_JSON), @ExampleProperty(mediaType = XML, value = LONG_RESPONSE_XML) })), @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Process ID or Container Id not found"), @ApiResponse(code = 403, message = "User does not have permission to access this asset") })
@POST
@Path(START_PROCESS_POST_URI)
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response startProcess(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "container id where the process definition resides", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "process id that new instance should be created from", required = true, example = "evaluation") @PathParam(PROCESS_ID) String processId, @ApiParam(value = "optional map of process variables", required = false, examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = VAR_MAP_JSON), @ExampleProperty(mediaType = XML, value = VAR_MAP_XML) })) @DefaultValue("") String payload) {
Variant v = getVariant(headers);
String type = getContentType(headers);
Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
try {
String response = processServiceBase.startProcess(containerId, processId, payload, type);
logger.debug("Returning CREATED response with content '{}'", response);
return createResponse(response, v, Response.Status.CREATED, conversationIdHeader);
} catch (DeploymentNotActiveException e) {
return badRequest(e.getMessage(), v);
} catch (DeploymentNotFoundException e) {
return notFound(MessageFormat.format(CONTAINER_NOT_FOUND, containerId), v);
} catch (ProcessDefinitionNotFoundException e) {
return notFound(MessageFormat.format(PROCESS_DEFINITION_NOT_FOUND, processId, containerId), v);
} catch (SecurityException e) {
return forbidden(errorMessage(e, e.getMessage()), v, conversationIdHeader);
} catch (Exception e) {
logger.error("Unexpected error during processing {}", e.getMessage(), e);
return internalServerError(MessageFormat.format(CREATE_RESPONSE_ERROR, e.getMessage()), v);
}
}
Aggregations