@Override public void deleteComment(DocumentModel docModel, DocumentModel comment) { if (comment.getPropertyValue(COMMENT_PARENT_ID) != null) { second.deleteComment(docModel, comment); } else { first.deleteComment(docModel, comment); } }
@DELETE @Path("{commentId}") public Response deleteComment(@PathParam("commentId") String commentId) { CommentManager commentManager = Framework.getService(CommentManager.class); commentManager.deleteComment(getContext().getCoreSession(), commentId); return Response.noContent().build(); }
public void removeComment(DocumentModel comment) { commentManager.deleteComment(docModel.getCoreSession(), comment.getId()); }
@Override public void deleteComment(CoreSession session, String commentId) throws CommentNotFoundException, CommentSecurityException { DocumentRef commentRef = new IdRef(commentId); if (!session.exists(commentRef)) { throw new CommentNotFoundException("The comment " + commentId + " does not exist"); } if (session.getDocument(commentRef).getPropertyValue(COMMENT_PARENT_ID) != null) { second.deleteComment(session, commentId); } else { first.deleteComment(session, commentId); } }
/** * Can be overwritten to allow workflow. Defaults to delete right away. * * @param target commented document * @param comment comment itself */ protected void deleteComment(DocumentModel target, DocumentModel comment) { getCommentManager().deleteComment(target.getCoreSession(), comment.getId()); }
/** * Can be overwritten to allow workflow. Defaults to reject and delete right away. * * @param target commented document * @param comment comment itself */ protected void rejectComment(CoreSession session, DocumentModel target, DocumentModel comment) { getCommentsModerationService().rejectComment(session, target, comment.getId()); getCommentManager().deleteComment(target.getCoreSession(), comment.getId()); }
@Override public void deleteExternalAnnotation(CoreSession session, String entityId) throws CommentNotFoundException, CommentSecurityException { DocumentModel annotationModel = getAnnotationModel(session, entityId); if (annotationModel == null) { throw new CommentNotFoundException("The external annotation " + entityId + " does not exist."); } NuxeoPrincipal principal = session.getPrincipal(); String parentId = (String) annotationModel.getPropertyValue(COMMENT_PARENT_ID); if (!principal.isAdministrator() && !annotationModel.getPropertyValue(COMMENT_AUTHOR).equals(principal.getName()) && !session.hasPermission(new IdRef(parentId), SecurityConstants.EVERYTHING)) { throw new CommentSecurityException( "The user " + principal.getName() + " can not delete annotations of document " + parentId); } Framework.getService(CommentManager.class).deleteComment(session, annotationModel.getId()); }
@Override public void deleteAnnotation(CoreSession session, String annotationId) throws CommentNotFoundException { NuxeoPrincipal principal = session.getPrincipal(); CoreInstance.doPrivileged(session, s -> { try { DocumentModel annotation = s.getDocument(new IdRef(annotationId)); String parentId = (String) annotation.getPropertyValue(COMMENT_PARENT_ID); DocumentRef parentRef = new IdRef(parentId); if (!principal.isAdministrator() && !annotation.getPropertyValue(COMMENT_AUTHOR).equals(principal.getName()) && !s.hasPermission(principal, parentRef, SecurityConstants.EVERYTHING)) { throw new CommentSecurityException( "The user " + principal.getName() + " can not delete annotations of document " + parentId); } } catch (DocumentNotFoundException e) { throw new CommentNotFoundException(e); } Framework.getService(CommentManager.class).deleteComment(s, annotationId); }); }