use of org.kie.server.api.model.instance.DocumentInstance in project droolsjbpm-integration by kiegroup.
the class DocumentResource method getDocument.
@ApiOperation(value = "Returns information about a specified document.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Document with given id not found"), @ApiResponse(code = 200, response = DocumentInstance.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_DOCUMENT_RESPONSE_JSON) })) })
@GET
@Path(DOCUMENT_INSTANCE_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getDocument(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "document id of a document that should be retruned", required = true, example = "xxx-yyy-zzz") @PathParam("documentId") String documentId) {
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 {
DocumentInstance document = documentServiceBase.getDocument(documentId);
return createCorrectVariant(document, headers, Response.Status.OK, conversationIdHeader);
} catch (KieServerRuntimeException e) {
return notFound("Document with id " + documentId + " not found", v, 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.DocumentInstance in project droolsjbpm-integration by kiegroup.
the class DocumentServicesClientImpl method getDocument.
@Override
public DocumentInstance getDocument(String identifier) {
DocumentInstance result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(DOCUMENT_ID, identifier);
result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), DOCUMENT_URI + "/" + DOCUMENT_INSTANCE_GET_URI, valuesMap), DocumentInstance.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("DocumentService", "getDocument", new Object[] { identifier })));
ServiceResponse<DocumentInstance> response = (ServiceResponse<DocumentInstance>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
result = response.getResult();
}
return result;
}
Aggregations