use of org.xwiki.annotation.rest.model.jaxb.AnnotationResponse in project xwiki-platform by xwiki.
the class SingleAnnotationRESTResource method doDelete.
/**
* Deletes the specified annotation.
*
* @param space the space of the document to delete the annotation from
* @param page the name of the document to delete the annotation from
* @param wiki the wiki of the document to delete the annotation from
* @param id the id of the annotation to delete
* @param request the annotation request to configure the returned annotated content after the execution of the
* operation
* @return a annotation response for which the response code will be 0 in case of success and non-zero otherwise
* @throws XWikiRestException when failing to parse space
*/
@DELETE
public AnnotationResponse doDelete(@PathParam("spaceName") String space, @PathParam("pageName") String page, @PathParam("wikiName") String wiki, @PathParam("id") String id, AnnotationRequest request) throws XWikiRestException {
try {
DocumentReference documentReference = new DocumentReference(wiki, parseSpaceSegments(space), page);
// Initialize the context with the correct value.
updateContext(documentReference);
String documentName = referenceSerializer.serialize(documentReference);
// check access to this function
if (!annotationRightService.canEditAnnotation(id, documentName, getXWikiUser())) {
throw new WebApplicationException(Status.UNAUTHORIZED);
}
// remove the annotation
annotationService.removeAnnotation(documentName, id);
// and then return the annotated content, as specified by the annotation request
AnnotationResponse response = getSuccessResponseWithAnnotatedContent(documentName, request);
return response;
} catch (XWikiException e) {
getLogger().error(e.getMessage(), e);
return getErrorResponse(e);
} catch (AnnotationServiceException e) {
getLogger().error(e.getMessage(), e);
return getErrorResponse(e);
}
}
Aggregations