Search in sources :

Example 6 with KieServerRuntimeException

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);
    }
}
Also used : RestUtils.getVariant(org.kie.server.remote.rest.common.util.RestUtils.getVariant) RestUtils.createCorrectVariant(org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant) Variant(javax.ws.rs.core.Variant) KieServerRuntimeException(org.kie.server.services.api.KieServerRuntimeException) Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) ResponseHeader(io.swagger.annotations.ResponseHeader) WebApplicationException(javax.ws.rs.WebApplicationException) KieServerRuntimeException(org.kie.server.services.api.KieServerRuntimeException) IOException(java.io.IOException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses) PUT(javax.ws.rs.PUT)

Aggregations

KieServerRuntimeException (org.kie.server.services.api.KieServerRuntimeException)6 ApiOperation (io.swagger.annotations.ApiOperation)3 ApiResponses (io.swagger.annotations.ApiResponses)3 ResponseHeader (io.swagger.annotations.ResponseHeader)3 IOException (java.io.IOException)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 WebApplicationException (javax.ws.rs.WebApplicationException)3 Variant (javax.ws.rs.core.Variant)3 Document (org.jbpm.document.Document)3 Header (org.kie.server.remote.rest.common.Header)3 RestUtils.buildConversationIdHeader (org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader)3 RestUtils.createCorrectVariant (org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant)3 RestUtils.getVariant (org.kie.server.remote.rest.common.util.RestUtils.getVariant)3 DocumentInstance (org.kie.server.api.model.instance.DocumentInstance)2 Consumes (javax.ws.rs.Consumes)1 DELETE (javax.ws.rs.DELETE)1 GET (javax.ws.rs.GET)1 PUT (javax.ws.rs.PUT)1