@Test public void _testCommentsStructureOnPlaceless() { DocumentModel placeless = session.createDocumentModel(null, "placeless", "File"); placeless = session.createDocument(placeless); transactionalFeature.nextTransaction(); Comment c1 = commentManager.createComment(session, newComment(placeless.getId(), "I am a comment!")); Comment c2 = commentManager.createComment(session, newComment(c1.getId(), "I am a reply!")); Comment c3 = commentManager.createComment(session, newComment(c2.getId(), "Me too!")); DocumentModel commentContainerDocModel = session.getChild(placeless.getRef(), COMMENTS_DIRECTORY); DocumentRef[] c3ParentDocRefs = session.getParentDocumentRefs(c3.getDocument().getRef()); assertEquals(c2.getDocument().getRef(), c3ParentDocRefs[0]); assertEquals(c1.getDocument().getRef(), c3ParentDocRefs[1]); assertEquals(commentContainerDocModel.getRef(), c3ParentDocRefs[2]); assertEquals(placeless.getRef(), c3ParentDocRefs[3]); assertEquals("placeless", placeless.getPathAsString()); assertEquals("placeless/Comments", commentContainerDocModel.getPathAsString()); assertEquals("placeless/Comments/comment", c1.getDocument().getPathAsString()); assertEquals("placeless/Comments/comment/comment", c2.getDocument().getPathAsString()); assertEquals("placeless/Comments/comment/comment/comment", c3.getDocument().getPathAsString()); }
@Override public Comment createComment(CoreSession session, Comment comment) { var parentRef = new IdRef(comment.getParentId()); checkCreateCommentPermissions(session, parentRef); fillCommentForCreation(session, comment); return CoreInstance.doPrivileged(session, s -> { DocumentModel commentedDoc = s.getDocument(parentRef); DocumentRef locationDocRef = getLocationRefOfCommentCreation(s, commentedDoc); DocumentModel commentDoc = s.newDocumentModel(locationDocRef, COMMENT_NAME, comment.getDocument().getType()); if (comment.getDocument().hasFacet(EXTERNAL_ENTITY_FACET)) { commentDoc.addFacet(EXTERNAL_ENTITY_FACET); } applyDirtyPropertyValues(comment.getDocument(), commentDoc); commentDoc.setPropertyValue(COMMENT_ANCESTOR_IDS_PROPERTY, computeAncestorIds(session, comment.getParentId())); commentDoc = s.createDocument(commentDoc); Comment createdComment = commentDoc.getAdapter(Comment.class); DocumentModel topLevelDoc = getTopLevelDocument(s, commentDoc); manageRelatedTextOfTopLevelDocument(s, topLevelDoc, createdComment.getId(), createdComment.getText()); handleNotificationAutoSubscriptions(s, topLevelDoc, commentDoc); notifyEvent(s, CommentEvents.COMMENT_ADDED, commentedDoc, commentDoc); return createdComment; }); }
TreeCommentManager extends AbstractCommentManager { @Override public Comment createComment(CoreSession session, Comment comment) { var parentRef = new IdRef(comment.getParentId()); checkCreateCommentPermissions(session, parentRef); fillCommentForCreation(session, comment); return CoreInstance.doPrivileged(session, s -> { DocumentModel commentedDoc = s.getDocument(parentRef); DocumentRef locationDocRef = getLocationRefOfCommentCreation(s, commentedDoc); DocumentModel commentDoc = s.newDocumentModel(locationDocRef, COMMENT_NAME, comment.getDocument().getType()); if (comment.getDocument().hasFacet(EXTERNAL_ENTITY_FACET)) { commentDoc.addFacet(EXTERNAL_ENTITY_FACET); } applyDirtyPropertyValues(comment.getDocument(), commentDoc); commentDoc.setPropertyValue(COMMENT_ANCESTOR_IDS_PROPERTY, computeAncestorIds(session, comment.getParentId())); commentDoc = s.createDocument(commentDoc); Comment createdComment = commentDoc.getAdapter(Comment.class); DocumentModel topLevelDoc = getTopLevelDocument(s, commentDoc); manageRelatedTextOfTopLevelDocument(s, topLevelDoc, createdComment.getId(), createdComment.getText()); handleNotificationAutoSubscriptions(s, topLevelDoc, commentDoc); notifyEvent(s, CommentEvents.COMMENT_ADDED, commentedDoc, commentDoc); return createdComment; }); } }
TreeCommentManager extends AbstractCommentManager { @Override public Comment createComment(CoreSession session, Comment comment) { var parentRef = new IdRef(comment.getParentId()); checkCreateCommentPermissions(session, parentRef); fillCommentForCreation(session, comment); return CoreInstance.doPrivileged(session, s -> { DocumentModel commentedDoc = s.getDocument(parentRef); DocumentRef locationDocRef = getLocationRefOfCommentCreation(s, commentedDoc); DocumentModel commentDoc = s.newDocumentModel(locationDocRef, COMMENT_NAME, comment.getDocument().getType()); if (comment.getDocument().hasFacet(EXTERNAL_ENTITY_FACET)) { commentDoc.addFacet(EXTERNAL_ENTITY_FACET); } applyDirtyPropertyValues(comment.getDocument(), commentDoc); commentDoc.setPropertyValue(COMMENT_ANCESTOR_IDS_PROPERTY, computeAncestorIds(session, comment.getParentId())); commentDoc = s.createDocument(commentDoc); Comment createdComment = commentDoc.getAdapter(Comment.class); DocumentModel topLevelDoc = getTopLevelDocument(s, commentDoc); manageRelatedTextOfTopLevelDocument(s, topLevelDoc, createdComment.getId(), createdComment.getText()); handleNotificationAutoSubscriptions(s, topLevelDoc, commentDoc); notifyEvent(s, CommentEvents.COMMENT_ADDED, commentedDoc, commentDoc); return createdComment; }); }  }
TreeCommentManager extends AbstractCommentManager { @Override public Comment createComment(CoreSession session, Comment comment) { var parentRef = new IdRef(comment.getParentId()); checkCreateCommentPermissions(session, parentRef); fillCommentForCreation(session, comment); return CoreInstance.doPrivileged(session, s -> { DocumentModel commentedDoc = s.getDocument(parentRef); DocumentRef locationDocRef = getLocationRefOfCommentCreation(s, commentedDoc); DocumentModel commentDoc = s.newDocumentModel(locationDocRef, COMMENT_NAME, comment.getDocument().getType()); if (comment.getDocument().hasFacet(EXTERNAL_ENTITY_FACET)) { commentDoc.addFacet(EXTERNAL_ENTITY_FACET); } applyDirtyPropertyValues(comment.getDocument(), commentDoc); commentDoc.setPropertyValue(COMMENT_ANCESTOR_IDS_PROPERTY, computeAncestorIds(session, comment.getParentId())); commentDoc = s.createDocument(commentDoc); Comment createdComment = commentDoc.getAdapter(Comment.class); DocumentModel topLevelDoc = getTopLevelDocument(s, commentDoc); manageRelatedTextOfTopLevelDocument(s, topLevelDoc, createdComment.getId(), createdComment.getText()); handleNotificationAutoSubscriptions(s, topLevelDoc, commentDoc); notifyEvent(s, CommentEvents.COMMENT_ADDED, commentedDoc, commentDoc); return createdComment; }); }  @Override List<DocumentModel> getComments(CoreSession session, DocumentModel doc); @Override Comment getComment(CoreSession session, String commentId); @Override PartialList<Comment> getComments(CoreSession session, String documentId, Long pageSize,
            Long currentPageIndex, boolean sortAscending); @Override List<Comment> getComments(CoreSession session, Collection<String> documentIds); @Override @SuppressWarnings("removal") List<DocumentModel> getDocumentsForComment(DocumentModel comment); @Override DocumentModel getThreadForComment(DocumentModel comment); @Override Comment getExternalComment(CoreSession session, String documentId, String entityId); @Override Comment createComment(CoreSession session, Comment comment); @Override DocumentModel createComment(DocumentModel commentedDoc, DocumentModel commentDoc); @Override DocumentModel createLocatedComment(DocumentModel doc, DocumentModel comment, String path); @Override DocumentModel createComment(DocumentModel doc, String text); @Override @SuppressWarnings("removal") DocumentModel createComment(DocumentModel doc, String text, String author); @Override @SuppressWarnings("removal") DocumentModel createComment(DocumentModel doc, DocumentModel parent, DocumentModel child); @Override Comment updateComment(CoreSession session, String commentId, Comment comment); @Override Comment updateExternalComment(CoreSession session, String documentId, String entityId, Comment comment); @Override void deleteExternalComment(CoreSession session, String documentId, String entityId); @Override void deleteComment(CoreSession s, String commentId); @Override @SuppressWarnings("removal") void deleteComment(DocumentModel doc, DocumentModel comment); @Override boolean hasFeature(Feature feature); }
TreeCommentManager extends AbstractCommentManager { @Override public Comment createComment(CoreSession session, Comment comment) { var parentRef = new IdRef(comment.getParentId()); checkCreateCommentPermissions(session, parentRef); fillCommentForCreation(session, comment); return CoreInstance.doPrivileged(session, s -> { DocumentModel commentedDoc = s.getDocument(parentRef); DocumentRef locationDocRef = getLocationRefOfCommentCreation(s, commentedDoc); DocumentModel commentDoc = s.newDocumentModel(locationDocRef, COMMENT_NAME, comment.getDocument().getType()); if (comment.getDocument().hasFacet(EXTERNAL_ENTITY_FACET)) { commentDoc.addFacet(EXTERNAL_ENTITY_FACET); } applyDirtyPropertyValues(comment.getDocument(), commentDoc); commentDoc.setPropertyValue(COMMENT_ANCESTOR_IDS_PROPERTY, computeAncestorIds(session, comment.getParentId())); commentDoc = s.createDocument(commentDoc); Comment createdComment = commentDoc.getAdapter(Comment.class); DocumentModel topLevelDoc = getTopLevelDocument(s, commentDoc); manageRelatedTextOfTopLevelDocument(s, topLevelDoc, createdComment.getId(), createdComment.getText()); handleNotificationAutoSubscriptions(s, topLevelDoc, commentDoc); notifyEvent(s, CommentEvents.COMMENT_ADDED, commentedDoc, commentDoc); return createdComment; }); }  @Override List<DocumentModel> getComments(CoreSession session, DocumentModel doc); @Override Comment getComment(CoreSession session, String commentId); @Override PartialList<Comment> getComments(CoreSession session, String documentId, Long pageSize,
            Long currentPageIndex, boolean sortAscending); @Override List<Comment> getComments(CoreSession session, Collection<String> documentIds); @Override @SuppressWarnings("removal") List<DocumentModel> getDocumentsForComment(DocumentModel comment); @Override DocumentModel getThreadForComment(DocumentModel comment); @Override Comment getExternalComment(CoreSession session, String documentId, String entityId); @Override Comment createComment(CoreSession session, Comment comment); @Override DocumentModel createComment(DocumentModel commentedDoc, DocumentModel commentDoc); @Override DocumentModel createLocatedComment(DocumentModel doc, DocumentModel comment, String path); @Override DocumentModel createComment(DocumentModel doc, String text); @Override @SuppressWarnings("removal") DocumentModel createComment(DocumentModel doc, String text, String author); @Override @SuppressWarnings("removal") DocumentModel createComment(DocumentModel doc, DocumentModel parent, DocumentModel child); @Override Comment updateComment(CoreSession session, String commentId, Comment comment); @Override Comment updateExternalComment(CoreSession session, String documentId, String entityId, Comment comment); @Override void deleteExternalComment(CoreSession session, String documentId, String entityId); @Override void deleteComment(CoreSession s, String commentId); @Override @SuppressWarnings("removal") void deleteComment(DocumentModel doc, DocumentModel comment); @Override boolean hasFeature(Feature feature); static final String COMMENT_RELATED_TEXT_ID; static final String AUTOSUBSCRIBE_CONFIG_KEY; }