use of org.kie.server.services.api.KieServerRuntimeException in project droolsjbpm-integration by kiegroup.
the class DocumentResource method updateDocument.
@ApiOperation(value = "Updates a specified document in KIE Server.", response = Void.class, code = 201)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Document with given id not found") })
@PUT
@Path(DOCUMENT_INSTANCE_PUT_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response updateDocument(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "document id of a document that should be updated", required = true, example = "xxx-yyy-zzz") @PathParam("documentId") String documentId, @ApiParam(value = "document content represented as DocumentInstance", required = true, type = "DocumentInstance", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = DOCUMENT_JSON), @ExampleProperty(mediaType = XML, value = DOCUMENT_XML) })) String payload) {
Variant v = getVariant(headers);
String type = getContentType(headers);
// no container id available so only used to transfer conversation id if given by client
Header conversationIdHeader = buildConversationIdHeader("", context, headers);
try {
documentServiceBase.updateDocument(documentId, payload, type);
return createCorrectVariant("", headers, Response.Status.CREATED, 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);
}
}
Aggregations