Class TreeCommentManager
- java.lang.Object
-
- org.nuxeo.ecm.platform.comment.impl.AbstractCommentManager
-
- org.nuxeo.ecm.platform.comment.impl.TreeCommentManager
-
- All Implemented Interfaces:
CommentManager
public class TreeCommentManager extends AbstractCommentManager
Comment service implementation. The comments are linked together as a tree under a folder related to the root document that we comment.- Since:
- 11.1
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.nuxeo.ecm.platform.comment.api.CommentManager
CommentManager.Feature
-
-
Field Summary
Fields Modifier and Type Field Description static String
AUTOSUBSCRIBE_CONFIG_KEY
The key to the config turning on or off autosubscription.protected static String
COMMENT_NAME
static String
COMMENT_RELATED_TEXT_ID
protected static String
GET_COMMENT_PAGE_PROVIDER_NAME
Deprecated.since 11.1, useGET_EXTERNAL_COMMENT_PAGE_PROVIDER_NAME
insteadprotected static String
GET_COMMENTS_FOR_DOCUMENT_PAGE_PROVIDER_NAME
protected static String
GET_COMMENTS_FOR_DOCUMENTS_PAGE_PROVIDER_NAME
protected static String
GET_EXTERNAL_COMMENT_PAGE_PROVIDER_NAME
protected static String
QUERY_GET_COMMENTS_UUID_BY_COMMENT_ANCESTOR
Counts how many comments where made on a specific document.protected static String
QUERY_GET_COMMENTS_UUID_BY_COMMENT_ANCESTOR_AND_AUTHOR
Counts how many comments where made by a specific user on a specific document.protected static String
SERVICE_WITHOUT_IMPLEMENTATION_MESSAGE
-
Fields inherited from class org.nuxeo.ecm.platform.comment.impl.AbstractCommentManager
COMMENTS_DIRECTORY
-
-
Constructor Summary
Constructors Constructor Description TreeCommentManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkCreateCommentPermissions(CoreSession session, DocumentRef documentRef)
Checks if the user related to thesession
can comments the document linked to thedocumentRef
.Comment
createComment(CoreSession session, Comment comment)
Creates a comment.DocumentModel
createComment(DocumentModel doc, String text)
Creates a comment.DocumentModel
createComment(DocumentModel doc, String text, String author)
Creates a comment document model, filling its properties with given info and linking it to given document.DocumentModel
createComment(DocumentModel commentedDoc, DocumentModel commentDoc)
Creates a comment document model, filling its properties with given info and linking it to given document.DocumentModel
createComment(DocumentModel doc, DocumentModel parent, DocumentModel child)
Creates a comment document model, filling its properties with given info and linking it to given document.DocumentModel
createLocatedComment(DocumentModel doc, DocumentModel comment, String path)
Creates a comment document model.void
deleteComment(CoreSession s, String commentId)
Deletes a comment.void
deleteComment(DocumentModel doc, DocumentModel comment)
Deletes a comment.void
deleteExternalComment(CoreSession session, String documentId, String entityId)
Deletes an external comment by its {code entityId} under the document withdocumentId
.Comment
getComment(CoreSession session, String commentId)
Gets a comment.protected DocumentModel
getCommentDocumentModel(CoreSession session, String id)
protected PartialList<DocumentModel>
getCommentDocuments(CoreSession session, String documentId, Long pageSize, Long currentPageIndex, boolean sortAscending)
protected DocumentModel
getCommentedDocument(CoreSession session, DocumentModel commentDoc)
PartialList<Comment>
getComments(CoreSession session, String documentId, Long pageSize, Long currentPageIndex, boolean sortAscending)
Gets all comments for a document.List<Comment>
getComments(CoreSession session, Collection<String> documentIds)
Gets all comments for a collection of documents.List<DocumentModel>
getComments(CoreSession session, DocumentModel doc)
Gets comments of a document.List<DocumentModel>
getDocumentsForComment(DocumentModel comment)
Gets documents in relation with a particular comment.Comment
getExternalComment(CoreSession session, String documentId, String entityId)
Gets an external comment by itsentityId
under the document withdocumentId
.protected DocumentModel
getExternalCommentModel(CoreSession session, String documentId, String entityId)
protected DocumentRef
getLocationRefOfCommentCreation(CoreSession session, DocumentModel commentedDoc)
Returns theDocumentRef
of the comments location in repository for the given commented document model.DocumentModel
getThreadForComment(DocumentModel comment)
Gets thread in relation with a given comment (post or comment).protected DocumentModel
getTopLevelDocument(CoreSession session, DocumentModel commentDoc)
protected void
handleNotificationAutoSubscriptions(CoreSession session, DocumentModel topLevelDoc, DocumentModel commentDoc)
protected boolean
hasComments(CoreSession session, DocumentModel document)
Returnstrue
if the document has comments.protected boolean
hasComments(CoreSession session, DocumentModel document, String user)
Returnstrue
if the documents has comments from the given user.boolean
hasFeature(CommentManager.Feature feature)
Checks if a feature is available.protected void
manageRelatedTextOfTopLevelDocument(CoreSession session, DocumentModel topLevelDoc, String commentId, String commentText)
Manages (Add, Update or Remove) the related textFacetNames.HAS_RELATED_TEXT
of the top level document ancestorAbstractCommentManager.getTopLevelDocumentRef(CoreSession, DocumentRef)
for the given comment / annotation.protected void
removeComment(CoreSession session, DocumentRef documentRef)
Remove the comment of the givendocumentRef
protected void
subscribeToNotifications(DocumentModel document, NuxeoPrincipal user)
Subscribes a user to notifications on the document.protected Comment
update(CoreSession session, Comment comment, DocumentModel commentDoc)
Comment
updateComment(CoreSession session, String commentId, Comment comment)
Updates a comment.Comment
updateExternalComment(CoreSession session, String documentId, String entityId, Comment comment)
Updates an external comment by itsentityId
under the document withdocumentId
.-
Methods inherited from class org.nuxeo.ecm.platform.comment.impl.AbstractCommentManager
computeAncestorIds, fillCommentForCreation, getAuthor, getComments, getComments, getComments, getComments, getComments, getTopLevelDocumentRef, notifyEvent, notifyEvent, notifyEvent, setCommentPermissions, setFolderPermissions
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.ecm.platform.comment.api.CommentManager
deleteExternalComment, getExternalComment, updateExternalComment
-
-
-
-
Field Detail
-
COMMENT_RELATED_TEXT_ID
public static final String COMMENT_RELATED_TEXT_ID
- See Also:
- Constant Field Values
-
AUTOSUBSCRIBE_CONFIG_KEY
public static final String AUTOSUBSCRIBE_CONFIG_KEY
The key to the config turning on or off autosubscription.- See Also:
- Constant Field Values
-
COMMENT_NAME
protected static final String COMMENT_NAME
- See Also:
- Constant Field Values
-
GET_COMMENT_PAGE_PROVIDER_NAME
@Deprecated(since="11.1") protected static final String GET_COMMENT_PAGE_PROVIDER_NAME
Deprecated.since 11.1, useGET_EXTERNAL_COMMENT_PAGE_PROVIDER_NAME
instead- See Also:
- Constant Field Values
-
GET_EXTERNAL_COMMENT_PAGE_PROVIDER_NAME
protected static final String GET_EXTERNAL_COMMENT_PAGE_PROVIDER_NAME
- See Also:
- Constant Field Values
-
GET_COMMENTS_FOR_DOCUMENT_PAGE_PROVIDER_NAME
protected static final String GET_COMMENTS_FOR_DOCUMENT_PAGE_PROVIDER_NAME
- See Also:
- Constant Field Values
-
GET_COMMENTS_FOR_DOCUMENTS_PAGE_PROVIDER_NAME
protected static final String GET_COMMENTS_FOR_DOCUMENTS_PAGE_PROVIDER_NAME
- See Also:
- Constant Field Values
-
SERVICE_WITHOUT_IMPLEMENTATION_MESSAGE
protected static final String SERVICE_WITHOUT_IMPLEMENTATION_MESSAGE
- See Also:
- Constant Field Values
-
QUERY_GET_COMMENTS_UUID_BY_COMMENT_ANCESTOR
protected static final String QUERY_GET_COMMENTS_UUID_BY_COMMENT_ANCESTOR
Counts how many comments where made on a specific document.- See Also:
- Constant Field Values
-
QUERY_GET_COMMENTS_UUID_BY_COMMENT_ANCESTOR_AND_AUTHOR
protected static final String QUERY_GET_COMMENTS_UUID_BY_COMMENT_ANCESTOR_AND_AUTHOR
Counts how many comments where made by a specific user on a specific document.- See Also:
- Constant Field Values
-
-
Method Detail
-
getComments
public List<DocumentModel> getComments(CoreSession session, DocumentModel doc)
Description copied from interface:CommentManager
Gets comments of a document.- Parameters:
session
- the core sessiondoc
- the document model- Returns:
- the list of comments
-
getComment
public Comment getComment(CoreSession session, String commentId)
Description copied from interface:CommentManager
Gets a comment.- Parameters:
session
- the core sessioncommentId
- the comment id- Returns:
- the comment
-
getComments
public PartialList<Comment> getComments(CoreSession session, String documentId, Long pageSize, Long currentPageIndex, boolean sortAscending)
Description copied from interface:CommentManager
Gets all comments for a document.- Parameters:
session
- the core sessiondocumentId
- the document idpageSize
- the page size to query, give null or 0 to disable paginationcurrentPageIndex
- the page index to query, give null or 0 to disable paginationsortAscending
- whether to sort ascending or descending- Returns:
- the list of comments, ordered by comment's creation date and according to sortAscending parameter, or an empty list if no comment is found.
-
getComments
public List<Comment> getComments(CoreSession session, Collection<String> documentIds)
Description copied from interface:CommentManager
Gets all comments for a collection of documents.- Parameters:
session
- the core sessiondocumentIds
- the document ids- Returns:
- the list of comments
-
getDocumentsForComment
public List<DocumentModel> getDocumentsForComment(DocumentModel comment)
Description copied from interface:CommentManager
Gets documents in relation with a particular comment.- Parameters:
comment
- the comment- Returns:
- the list of documents
-
getThreadForComment
public DocumentModel getThreadForComment(DocumentModel comment)
Description copied from interface:CommentManager
Gets thread in relation with a given comment (post or comment).- Parameters:
comment
- the comment- Returns:
- the thread
-
getExternalComment
public Comment getExternalComment(CoreSession session, String documentId, String entityId)
Description copied from interface:CommentManager
Gets an external comment by itsentityId
under the document withdocumentId
.- Returns:
- the comment with given
entityId
under the document with givendocumentId
-
createComment
public Comment createComment(CoreSession session, Comment comment)
Description copied from interface:CommentManager
Creates a comment.- Parameters:
session
- the core session- Returns:
- the created comment
-
createComment
public DocumentModel createComment(DocumentModel commentedDoc, DocumentModel commentDoc)
Description copied from interface:CommentManager
Creates a comment document model, filling its properties with given info and linking it to given document.- Parameters:
commentedDoc
- the document to commentcommentDoc
- the comment document model- Returns:
- the created comment document model.
-
createLocatedComment
public DocumentModel createLocatedComment(DocumentModel doc, DocumentModel comment, String path)
Description copied from interface:CommentManager
Creates a comment document model. It gives opportunity to save the comments in a specified location.- Parameters:
doc
- the document to commentcomment
- the comment contentpath
- the location path- Returns:
- the comment document model.
-
createComment
public DocumentModel createComment(DocumentModel doc, String text)
Description copied from interface:CommentManager
Creates a comment.- Parameters:
doc
- the document to commenttext
- the comment content
-
createComment
public DocumentModel createComment(DocumentModel doc, String text, String author)
Description copied from interface:CommentManager
Creates a comment document model, filling its properties with given info and linking it to given document.- Parameters:
doc
- the document to commenttext
- the comment contentauthor
- the comment author- Returns:
- the comment document model.
-
createComment
public DocumentModel createComment(DocumentModel doc, DocumentModel parent, DocumentModel child)
Description copied from interface:CommentManager
Creates a comment document model, filling its properties with given info and linking it to given document.- Parameters:
doc
- the document to commentparent
- the comment parent document modelchild
- the comment child document model- Returns:
- the created comment document model.
-
updateComment
public Comment updateComment(CoreSession session, String commentId, Comment comment)
Description copied from interface:CommentManager
Updates a comment.- Parameters:
session
- the core sessioncommentId
- the comment idcomment
- the updated comment- Returns:
- the updated comment
-
updateExternalComment
public Comment updateExternalComment(CoreSession session, String documentId, String entityId, Comment comment)
Description copied from interface:CommentManager
Updates an external comment by itsentityId
under the document withdocumentId
.- Returns:
- the updated comment with given
entityId
under the document with givendocumentId
-
update
protected Comment update(CoreSession session, Comment comment, DocumentModel commentDoc)
- Parameters:
session
- the user session, in order to check permissionscomment
- the comment holding new datacommentDoc
- theDocumentModel
just retrieved from DB
-
deleteExternalComment
public void deleteExternalComment(CoreSession session, String documentId, String entityId)
Description copied from interface:CommentManager
Deletes an external comment by its {code entityId} under the document withdocumentId
.
-
deleteComment
public void deleteComment(CoreSession s, String commentId)
Description copied from interface:CommentManager
Deletes a comment.- Parameters:
s
- the core sessioncommentId
- the comment id
-
deleteComment
public void deleteComment(DocumentModel doc, DocumentModel comment)
Description copied from interface:CommentManager
Deletes a comment.- Parameters:
doc
- the comment document modelcomment
- the comment
-
getLocationRefOfCommentCreation
protected DocumentRef getLocationRefOfCommentCreation(CoreSession session, DocumentModel commentedDoc)
Returns theDocumentRef
of the comments location in repository for the given commented document model.- Parameters:
session
- the session needs to be privileged- Returns:
- the document model container of the comments of the given
commentedDoc
- Since:
- 11.1
-
hasFeature
public boolean hasFeature(CommentManager.Feature feature)
Description copied from interface:CommentManager
Checks if a feature is available.
-
getTopLevelDocument
protected DocumentModel getTopLevelDocument(CoreSession session, DocumentModel commentDoc)
- Specified by:
getTopLevelDocument
in classAbstractCommentManager
-
checkCreateCommentPermissions
protected void checkCreateCommentPermissions(CoreSession session, DocumentRef documentRef)
Checks if the user related to thesession
can comments the document linked to thedocumentRef
.
-
getExternalCommentModel
protected DocumentModel getExternalCommentModel(CoreSession session, String documentId, String entityId)
- Parameters:
session
- the user session, in order to implicitly check permissions- Returns:
- the external document model for the given
entityId
, if it exists, otherwise throws aCommentNotFoundException
-
removeComment
protected void removeComment(CoreSession session, DocumentRef documentRef)
Remove the comment of the givendocumentRef
- Parameters:
session
- the user session, in order to check permissionsdocumentRef
- the documentRef of the comment document model to delete
-
getCommentDocumentModel
protected DocumentModel getCommentDocumentModel(CoreSession session, String id)
- Parameters:
session
- the user session, in order to implicitly check permissions- Returns:
- the comment document model of the given
documentRef
if it exists, otherwise throws aCommentNotFoundException
-
getCommentDocuments
protected PartialList<DocumentModel> getCommentDocuments(CoreSession session, String documentId, Long pageSize, Long currentPageIndex, boolean sortAscending)
- Returns:
- the page provider current page
-
manageRelatedTextOfTopLevelDocument
protected void manageRelatedTextOfTopLevelDocument(CoreSession session, DocumentModel topLevelDoc, String commentId, String commentText)
Manages (Add, Update or Remove) the related textFacetNames.HAS_RELATED_TEXT
of the top level document ancestorAbstractCommentManager.getTopLevelDocumentRef(CoreSession, DocumentRef)
for the given comment / annotation. Each action of adding, updating or removing the comment / annotation text will call this method, which allow us to make the right action on the related text of the top level document.- Add a new Comment / Annotation will create a separate entry
- Update a text Comment / Annotation will update this specific entry
- Remove a Comment / Annotation will remove this specific entry
- Since:
- 11.1
-
getCommentedDocument
protected DocumentModel getCommentedDocument(CoreSession session, DocumentModel commentDoc)
- Specified by:
getCommentedDocument
in classAbstractCommentManager
-
hasComments
protected boolean hasComments(CoreSession session, DocumentModel document)
Returnstrue
if the document has comments.- Since:
- 11.1
-
hasComments
protected boolean hasComments(CoreSession session, DocumentModel document, String user)
Returnstrue
if the documents has comments from the given user.- Since:
- 11.1
-
handleNotificationAutoSubscriptions
protected void handleNotificationAutoSubscriptions(CoreSession session, DocumentModel topLevelDoc, DocumentModel commentDoc)
-
subscribeToNotifications
protected void subscribeToNotifications(DocumentModel document, NuxeoPrincipal user)
Subscribes a user to notifications on the document.- Since:
- 11.1
-
-