Class BridgeCommentManager
- java.lang.Object
-
- org.nuxeo.ecm.platform.comment.impl.AbstractCommentManager
-
- org.nuxeo.ecm.platform.comment.impl.BridgeCommentManager
-
- All Implemented Interfaces:
CommentManager
public class BridgeCommentManager extends AbstractCommentManager
- Since:
- 10.3
-
-
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 protected CommentManager
first
protected CommentManager
second
-
Fields inherited from class org.nuxeo.ecm.platform.comment.impl.AbstractCommentManager
COMMENTS_DIRECTORY
-
-
Constructor Summary
Constructors Constructor Description BridgeCommentManager(CommentManager first, CommentManager second)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Comment
createComment(CoreSession session, Comment comment)
Creates a comment.DocumentModel
createComment(DocumentModel docModel, String comment)
Creates a comment.DocumentModel
createComment(DocumentModel docModel, String comment, String author)
Creates a comment document model, filling its properties with given info and linking it to given document.DocumentModel
createComment(DocumentModel docModel, DocumentModel comment)
Creates a comment document model, filling its properties with given info and linking it to given document.DocumentModel
createComment(DocumentModel docModel, DocumentModel parent, DocumentModel child)
Creates a comment document model, filling its properties with given info and linking it to given document.DocumentModel
createLocatedComment(DocumentModel docModel, DocumentModel comment, String path)
Creates a comment document model.void
deleteComment(CoreSession session, String commentId)
Deletes a comment.void
deleteComment(DocumentModel docModel, 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
.protected <T> T
execute(CoreSession s, DocumentRef documentRef, Function<CommentManager,T> function)
Executes the given function for a comment document ref, depending on the types of comment managers.Comment
getComment(CoreSession session, String commentId)
Gets a comment.protected DocumentModel
getCommentedDocument(CoreSession session, DocumentModel commentDoc)
List<Comment>
getComments(CoreSession session, String documentId)
Gets all comments for a document.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 docModel)
Gets comments of a document.List<DocumentModel>
getComments(DocumentModel docModel)
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
.CommentManager
getFirst()
CommentManager
getSecond()
DocumentModel
getThreadForComment(DocumentModel comment)
Gets thread in relation with a given comment (post or comment).protected DocumentModel
getTopLevelDocument(CoreSession session, DocumentModel commentDoc)
DocumentRef
getTopLevelDocumentRef(CoreSession session, DocumentRef commentIdRef)
Gets the top level ancestor document ref for the given document model comment ref.boolean
hasFeature(CommentManager.Feature feature)
Checks if a feature is available.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, 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
-
first
protected final CommentManager first
-
second
protected final CommentManager second
-
-
Constructor Detail
-
BridgeCommentManager
public BridgeCommentManager(CommentManager first, CommentManager second)
-
-
Method Detail
-
getFirst
public CommentManager getFirst()
- Since:
- 11.1
-
getSecond
public CommentManager getSecond()
- Since:
- 11.1
-
getComments
public List<DocumentModel> getComments(DocumentModel docModel)
Description copied from interface:CommentManager
Gets comments of a document.- Specified by:
getComments
in interfaceCommentManager
- Overrides:
getComments
in classAbstractCommentManager
- Parameters:
docModel
- the document model- Returns:
- the list of comments
-
getComments
public List<DocumentModel> getComments(CoreSession session, DocumentModel docModel) throws CommentSecurityException
Description copied from interface:CommentManager
Gets comments of a document.- Parameters:
session
- the core sessiondocModel
- the document model- Returns:
- the list of comments
- Throws:
CommentSecurityException
- if the current user does not have the right permissions on the commented document
-
createComment
public DocumentModel createComment(DocumentModel docModel, String comment)
Description copied from interface:CommentManager
Creates a comment.- Parameters:
docModel
- the document to commentcomment
- the comment content
-
createComment
public DocumentModel createComment(DocumentModel docModel, String comment, 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:
docModel
- the document to commentcomment
- the comment contentauthor
- the comment author- Returns:
- the comment document model.
-
createComment
public DocumentModel createComment(DocumentModel docModel, DocumentModel comment) throws CommentSecurityException
Description copied from interface:CommentManager
Creates a comment document model, filling its properties with given info and linking it to given document.- Parameters:
docModel
- the document to commentcomment
- the comment document model- Returns:
- the created comment document model.
- Throws:
CommentSecurityException
- if the current user does not have the right permissions on the document to comment.
-
createComment
public DocumentModel createComment(DocumentModel docModel, 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:
docModel
- the document to commentparent
- the comment parent document modelchild
- the comment child document model- Returns:
- the created comment document model.
-
deleteComment
public void deleteComment(DocumentModel docModel, DocumentModel comment)
Description copied from interface:CommentManager
Deletes a comment.- Parameters:
docModel
- the comment document modelcomment
- the comment
-
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) throws CommentSecurityException
Description copied from interface:CommentManager
Gets thread in relation with a given comment (post or comment).- Parameters:
comment
- the comment- Returns:
- the thread
- Throws:
CommentSecurityException
- if the current user does not have the right permissions on the commented document.
-
createLocatedComment
public DocumentModel createLocatedComment(DocumentModel docModel, DocumentModel comment, String path) throws CommentSecurityException
Description copied from interface:CommentManager
Creates a comment document model. It gives opportunity to save the comments in a specified location.- Parameters:
docModel
- the document to commentcomment
- the comment contentpath
- the location path- Returns:
- the comment document model.
- Throws:
CommentSecurityException
- if the current user does not have the right permissions on the document to comment.
-
createComment
public Comment createComment(CoreSession session, Comment comment) throws CommentNotFoundException, CommentSecurityException
Description copied from interface:CommentManager
Creates a comment.- Parameters:
session
- the core session- Returns:
- the created comment
- Throws:
CommentNotFoundException
- if the document to comment, i.e. comment's parent, does not exist.CommentSecurityException
- if the current user does not have the right permissions on the document to comment.
-
getComment
public Comment getComment(CoreSession session, String commentId) throws CommentNotFoundException, CommentSecurityException
Description copied from interface:CommentManager
Gets a comment.- Parameters:
session
- the core sessioncommentId
- the comment id- Returns:
- the comment
- Throws:
CommentNotFoundException
- if the comment does not existCommentSecurityException
- if the current user does not have the right permissions on the commented document.
-
getComments
public List<Comment> getComments(CoreSession session, String documentId)
Description copied from interface:CommentManager
Gets all comments for a document.- Specified by:
getComments
in interfaceCommentManager
- Overrides:
getComments
in classAbstractCommentManager
- Parameters:
session
- the core sessiondocumentId
- the document id- Returns:
- the list of comments, ordered ascending by comment's creation date, or an empty list if no comment is found.
-
getComments
public PartialList<Comment> getComments(CoreSession session, String documentId, Long pageSize, Long currentPageIndex, boolean sortAscending) throws CommentSecurityException
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.
- Throws:
CommentSecurityException
- if the current user does not have the right permissions on the commented document.
-
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
-
updateComment
public Comment updateComment(CoreSession session, String commentId, Comment comment) throws CommentNotFoundException, CommentSecurityException
Description copied from interface:CommentManager
Updates a comment.- Parameters:
session
- the core sessioncommentId
- the comment idcomment
- the updated comment- Returns:
- the updated comment
- Throws:
CommentNotFoundException
- if no comment was found with the given id.CommentSecurityException
- if the current user does not have the right permissions on the commented document.
-
deleteComment
public void deleteComment(CoreSession session, String commentId) throws CommentNotFoundException, CommentSecurityException
Description copied from interface:CommentManager
Deletes a comment.- Parameters:
session
- the core sessioncommentId
- the comment id- Throws:
CommentNotFoundException
- if no comment was found with the given id.CommentSecurityException
- if the current user does not have the right permissions on the commented document.
-
getExternalComment
public Comment getExternalComment(CoreSession session, String documentId, String entityId) throws CommentNotFoundException, CommentSecurityException
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
- Throws:
CommentNotFoundException
- if no comment was found with the given external entity idCommentSecurityException
- if the current user does have the right permissions on the commented document.
-
updateExternalComment
public Comment updateExternalComment(CoreSession session, String documentId, String entityId, Comment comment) throws CommentNotFoundException, CommentSecurityException
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
- Throws:
CommentNotFoundException
- if no comment was found with the given external entity idCommentSecurityException
- if the current user does have the right permissions on the commented document.
-
deleteExternalComment
public void deleteExternalComment(CoreSession session, String documentId, String entityId) throws CommentNotFoundException, CommentSecurityException
Description copied from interface:CommentManager
Deletes an external comment by its {code entityId} under the document withdocumentId
.- Throws:
CommentNotFoundException
- if no comment was found with the given external entity idCommentSecurityException
- if the current user does have the right permissions on the commented document.
-
hasFeature
public boolean hasFeature(CommentManager.Feature feature)
Description copied from interface:CommentManager
Checks if a feature is available.
-
getTopLevelDocumentRef
public DocumentRef getTopLevelDocumentRef(CoreSession session, DocumentRef commentIdRef)
Description copied from interface:CommentManager
Gets the top level ancestor document ref for the given document model comment ref. No matter how many levels of comments there is.Given a document fileOne, that we comment with commentOne which we reply on with replyOne
This method will return:
- CommentManager#getAncestorRef(session, commentOne) = fileOne
- CommentManager#getAncestorRef(session, replyOne) = fileOne
- Specified by:
getTopLevelDocumentRef
in interfaceCommentManager
- Overrides:
getTopLevelDocumentRef
in classAbstractCommentManager
- Parameters:
session
- the CoreSessioncommentIdRef
- the comment document model ref- Returns:
- the top level ancestor document ref
-
getTopLevelDocument
protected DocumentModel getTopLevelDocument(CoreSession session, DocumentModel commentDoc)
- Specified by:
getTopLevelDocument
in classAbstractCommentManager
-
getCommentedDocument
protected DocumentModel getCommentedDocument(CoreSession session, DocumentModel commentDoc)
- Specified by:
getCommentedDocument
in classAbstractCommentManager
-
execute
protected <T> T execute(CoreSession s, DocumentRef documentRef, Function<CommentManager,T> function)
Executes the given function for a comment document ref, depending on the types of comment managers.In some cases, leveraging
CommentConstants.COMMENT_PARENT_ID_PROPERTY
is not enough, this is the case when bridge is used withPropertyCommentManager
andTreeCommentManager
.CommentManagerImpl
(or RelationCommentManager): Comments structures are stored in jenaGraphPropertyCommentManager
: All comments are stored under a hidden folder and each comment stores its parent id incomment:parentId
propertyTreeCommentManager
: ACommentConstants.COMMENT_ROOT_DOC_TYPE
document is created under the top level document to store the comments. Replies are then stored directly under their parent (which is a comment)
- Since:
- 11.1
-
-