use of org.kie.server.services.api.KieServerRuntimeException in project droolsjbpm-integration by kiegroup.
the class DocumentServiceBase method deleteDocument.
public void deleteDocument(String documentId) {
logger.debug("About to delete document with id {}", documentId);
Document document = documentStorageService.getDocument(documentId);
logger.debug("Document found {}", document != null);
if (document == null) {
throw new KieServerRuntimeException("No document found with id " + documentId);
}
documentStorageService.deleteDocument(document);
logger.debug("Document {} deleted successfully", document);
}
use of org.kie.server.services.api.KieServerRuntimeException in project droolsjbpm-integration by kiegroup.
the class DocumentServiceBase method updateDocument.
public void updateDocument(String documentId, String documentPayload, String marshallingType) {
logger.debug("About to unmarshal document payload '{}' with marshaling type {}", documentPayload, marshallingType);
DocumentInstance documentInstance = marshallerHelper.unmarshal(documentPayload, marshallingType, DocumentInstance.class);
logger.debug("Document created from payload {}", documentInstance);
Document document = documentStorageService.getDocument(documentId);
logger.debug("Document found {}", documentInstance != null);
if (document == null) {
throw new KieServerRuntimeException("No document found with id " + documentId);
}
documentStorageService.saveDocument(document, documentInstance.getContent());
logger.debug("Document {} updated successfully", document);
}
use of org.kie.server.services.api.KieServerRuntimeException in project droolsjbpm-integration by kiegroup.
the class DocumentServiceBase method getDocument.
public DocumentInstance getDocument(String documentId) {
logger.debug("About to load document with id {}", documentId);
final Document document = documentStorageService.getDocument(documentId);
logger.debug("Document loaded from repository {}", document);
if (document == null) {
throw new KieServerRuntimeException("No document found with id " + documentId);
}
return convertDocument(document, true);
}
use of org.kie.server.services.api.KieServerRuntimeException 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.services.api.KieServerRuntimeException in project droolsjbpm-integration by kiegroup.
the class DocumentResource method deleteDocument.
@ApiOperation(value = "Deletes a specified document from KIE Server.", response = Void.class, code = 204)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Document with given id not found") })
@DELETE
@Path(DOCUMENT_INSTANCE_DELETE_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response deleteDocument(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "document id of a document that should be deleted", required = true, example = "xxxx-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 {
documentServiceBase.deleteDocument(documentId);
// produce 204 NO_CONTENT response code
return noContent(v, 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