use of org.kie.server.api.model.instance.RequestInfoInstanceList in project droolsjbpm-integration by kiegroup.
the class ExecutorResource method getRequestsByStatus.
// queries
@ApiOperation(value = "Retrieves asynchronous jobs filtered by status")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = RequestInfoInstanceList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_REQUESTS_RESPONSE_JSON) })) })
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getRequestsByStatus(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "optional job status (QUEUED, DONE, CANCELLED, ERROR, RETRYING, RUNNING)", required = true, allowableValues = "QUEUED,DONE,CANCELLED,ERROR,RETRYING,RUNNING") @QueryParam("status") List<String> statuses, @ApiParam(value = "optional pagination - at which page to start, defaults to 0 (meaning first)", required = false) @QueryParam("page") @DefaultValue("0") Integer page, @ApiParam(value = "optional pagination - size of the result, defaults to 10", required = false) @QueryParam("pageSize") @DefaultValue("10") Integer pageSize) {
Variant v = getVariant(headers);
// no container id available so only used to transfer conversation id if given by client
Header conversationIdHeader = buildConversationIdHeader("", context, headers);
try {
RequestInfoInstanceList result = executorServiceBase.getRequestsByStatus(statuses, page, pageSize);
return createCorrectVariant(result, headers, Response.Status.OK, conversationIdHeader);
} catch (Exception e) {
logger.error("Unexpected error during processing {}", e.getMessage(), e);
return internalServerError(errorMessage(e), v, conversationIdHeader);
}
}
use of org.kie.server.api.model.instance.RequestInfoInstanceList in project droolsjbpm-integration by kiegroup.
the class ExecutorResource method getRequestsByProcessInstance.
@ApiOperation(value = "Returns jobs for specified process instance.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = RequestInfoInstanceList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_REQUESTS_RESPONSE_JSON) })) })
@GET
@Path(JOB_INSTANCES_BY_PROCESS_INSTANCE_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getRequestsByProcessInstance(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "identifier of the process instance that asynchornous jobs should be found for", required = true, example = "123") @PathParam(PROCESS_INST_ID) Long processInstanceId, @ApiParam(value = "optional job status (QUEUED, DONE, CANCELLED, ERROR, RETRYING, RUNNING)", required = false, allowableValues = "QUEUED,DONE,CANCELLED,ERROR,RETRYING,RUNNING") @QueryParam("status") List<String> statuses, @ApiParam(value = "optional pagination - at which page to start, defaults to 0 (meaning first)", required = false) @QueryParam("page") @DefaultValue("0") Integer page, @ApiParam(value = "optional pagination - size of the result, defaults to 10", required = false) @QueryParam("pageSize") @DefaultValue("10") Integer pageSize) {
Variant v = getVariant(headers);
// no container id available so only used to transfer conversation id if given by client
Header conversationIdHeader = buildConversationIdHeader("", context, headers);
try {
RequestInfoInstanceList result = executorServiceBase.getRequestsByProcessInstance(processInstanceId, statuses, page, pageSize);
return createCorrectVariant(result, headers, Response.Status.OK, conversationIdHeader);
} catch (Exception e) {
logger.error("Unexpected error during processing {}", e.getMessage(), e);
return internalServerError(errorMessage(e), v, conversationIdHeader);
}
}
use of org.kie.server.api.model.instance.RequestInfoInstanceList in project droolsjbpm-integration by kiegroup.
the class ExecutorResource method getRequestsByBusinessKey.
@ApiOperation(value = "Returns information about a job with a specified business key.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = RequestInfoInstanceList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_REQUESTS_RESPONSE_JSON) })) })
@GET
@Path(JOB_INSTANCES_BY_KEY_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getRequestsByBusinessKey(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "identifier of the business key that asynchornous jobs should be found for", required = true, example = "custom-job") @PathParam("key") String businessKey, @ApiParam(value = "optional job status (QUEUED, DONE, CANCELLED, ERROR, RETRYING, RUNNING)", required = false, allowableValues = "QUEUED,DONE,CANCELLED,ERROR,RETRYING,RUNNING") @QueryParam("status") List<String> statuses, @ApiParam(value = "optional pagination - at which page to start, defaults to 0 (meaning first)", required = false) @QueryParam("page") @DefaultValue("0") Integer page, @ApiParam(value = "optional pagination - size of the result, defaults to 10", required = false) @QueryParam("pageSize") @DefaultValue("10") Integer pageSize) {
Variant v = getVariant(headers);
// no container id available so only used to transfer conversation id if given by client
Header conversationIdHeader = buildConversationIdHeader("", context, headers);
try {
RequestInfoInstanceList result = null;
if (statuses == null || statuses.isEmpty()) {
result = executorServiceBase.getRequestsByBusinessKey(businessKey, page, pageSize);
} else {
result = executorServiceBase.getRequestsByBusinessKey(businessKey, statuses, page, pageSize);
}
return createCorrectVariant(result, headers, Response.Status.OK, conversationIdHeader);
} catch (Exception e) {
logger.error("Unexpected error during processing {}", e.getMessage(), e);
return internalServerError(errorMessage(e), v, conversationIdHeader);
}
}
use of org.kie.server.api.model.instance.RequestInfoInstanceList in project droolsjbpm-integration by kiegroup.
the class KieClientServicesIntegrationTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
KieServerInfo info = new KieServerInfo("mock", "1.2.3");
List<String> capabilities = Arrays.asList(KieServerConstants.CAPABILITY_BPM, KieServerConstants.CAPABILITY_BPM_UI, KieServerConstants.CAPABILITY_BRM, KieServerConstants.CAPABILITY_BRP, KieServerConstants.CAPABILITY_CASE, KieServerConstants.CAPABILITY_DMN);
info.setCapabilities(capabilities);
ServiceResponse<KieServerInfo> response = new ServiceResponse<KieServerInfo>(ResponseType.SUCCESS, "Kie Server info");
response.setResult(info);
stubFor(get(urlEqualTo("/")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml").withBody(toXML(response, KieServerInfo.class, ServiceResponse.class))));
// case mock response
ProcessDefinitionList caseResponse = new ProcessDefinitionList();
caseResponse.setProcesses(new ProcessDefinition[] { new ProcessDefinition() });
stubFor(get(urlMatching("/queries/cases/processes.*")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml").withBody(toXML(caseResponse, ProcessDefinitionList.class, ProcessDefinition.class))));
// document mock response
DocumentInstance documentResponse = new DocumentInstance();
documentResponse.setIdentifier("1234");
stubFor(get(urlMatching("/documents/1234")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml").withBody(toXML(documentResponse, DocumentInstance.class))));
// job service mock response
RequestInfoInstanceList jobResponse = new RequestInfoInstanceList();
stubFor(get(urlMatching("/jobs.*")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml").withBody(toXML(jobResponse, RequestInfoInstanceList.class))));
// query service mock response
NodeInstanceList queryResponse = new NodeInstanceList();
stubFor(get(urlMatching("/queries/processes/instances/100/nodes/instances.*")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml").withBody(toXML(queryResponse, NodeInstanceList.class))));
// solver service mock response
SolverInstanceList solverResponse = new SolverInstanceList();
stubFor(get(urlMatching("/containers/my-container/solvers")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml").withBody(toXML(solverResponse, SolverInstanceList.class))));
// ui service mock response
stubFor(get(urlMatching("/containers/my-container/forms/processes/my-process.*")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml").withBody("my form")));
// user task mock response
TaskSummaryList userTaskResponse = new TaskSummaryList();
stubFor(get(urlMatching("/queries/tasks/instances.*")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml").withBody(toXML(userTaskResponse, TaskSummaryList.class))));
return new RouteBuilder() {
@Override
public void configure() {
from("direct:start").to("kie:" + getAuthenticadUrl("admin", "admin")).to("mock:result");
}
};
}
use of org.kie.server.api.model.instance.RequestInfoInstanceList in project droolsjbpm-integration by kiegroup.
the class JobServicesClientImpl method getRequestsByCommand.
@Override
public List<RequestInfoInstance> getRequestsByCommand(String command, Integer page, Integer pageSize) {
RequestInfoInstanceList list = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(JOB_CMD_NAME, command);
String queryString = getPagingQueryString("", page, pageSize);
list = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), JOB_URI + "/" + JOB_INSTANCES_BY_CMD_GET_URI, valuesMap) + queryString, RequestInfoInstanceList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("JobService", "getRequestsByCommand", new Object[] { command, page, pageSize })));
ServiceResponse<RequestInfoInstanceList> response = (ServiceResponse<RequestInfoInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
list = response.getResult();
}
if (list != null && list.getRequestInfoInstances() != null) {
return Arrays.asList(list.getRequestInfoInstances());
}
return Collections.emptyList();
}
Aggregations