@Override public Comment createComment(CoreSession session, Comment comment) throws CommentNotFoundException, CommentSecurityException { return second.createComment(session, comment); }
@Override public DocumentModel createComment(DocumentModel docModel, String comment) { return second.createComment(docModel, comment); }
@Override public DocumentModel createComment(DocumentModel docModel, DocumentModel comment) throws CommentSecurityException { return second.createComment(docModel, comment); }
@Override public DocumentModel createComment(DocumentModel docModel, String comment, String author) { return second.createComment(docModel, comment, author); }
@Override public DocumentModel createComment(DocumentModel docModel, DocumentModel parent, DocumentModel child) { return second.createComment(docModel, parent, child); }
/** * Can be overwritten to allow creation of localized comment. Defaults to create comment in comments root. * * @param session the core session * @param target commented document * @param comment comment itself * @return the comment created */ protected DocumentModel createCommentDocument(CoreSession session, DocumentModel target, DocumentModel comment) { return getCommentManager().createComment(target, comment); }
@POST public Response createComment(Comment comment) { CommentManager commentManager = Framework.getService(CommentManager.class); Comment result = commentManager.createComment(getContext().getCoreSession(), comment); return Response.status(Response.Status.CREATED).entity(result).build(); }
@SuppressWarnings("unchecked") public DocumentModel addComment(DocumentModel parent, DocumentModel comment) { comment.setPropertyValue(COMMENT_PARENT_ID, parent.getId()); return commentManager.createComment(parent, comment); }
@Override public Annotation createAnnotation(CoreSession session, Annotation annotation) throws CommentSecurityException { String parentId = annotation.getParentId(); if (!session.hasPermission(new IdRef(parentId), SecurityConstants.READ)) { throw new CommentSecurityException("The user " + session.getPrincipal().getName() + " can not create annotations on document " + parentId); } return CoreInstance.doPrivileged(session, s -> { // Create base comment in the annotation DocumentModel docToAnnotate = s.getDocument(new IdRef(annotation.getParentId())); DocumentModel annotationModel = s.createDocumentModel(ANNOTATION_DOC_TYPE); Comments.annotationToDocumentModel(annotation, annotationModel); if (annotation instanceof ExternalEntity) { annotationModel.addFacet(EXTERNAL_ENTITY_FACET); Comments.externalEntityToDocumentModel((ExternalEntity) annotation, annotationModel); } annotationModel = Framework.getService(CommentManager.class).createComment(docToAnnotate, annotationModel); return Comments.newAnnotation(annotationModel); }); }