Class Comment
- java.lang.Object
-
- org.ametys.cms.repository.comment.Comment
-
- All Implemented Interfaces:
ReactionableObject,ReportableObject
public class Comment extends Object implements ReactionableObject, ReportableObject
A comment on a commentable content
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.ametys.cms.repository.ReactionableObject
ReactionableObject.ReactionType
-
-
Field Summary
Fields Modifier and Type Field Description protected ModifiableModelLessComposite_commentCompositeThe node of the commentprotected ModifiableModelLessDataHolder_contentDataHolderThe content to commentprotected String_idThe id of the comment (unique in the content)static StringID_SEPARATORConstants for the separatorstatic StringMETADATA_COMMENT_AUTHOREMAILConstants for author email Metadatastatic StringMETADATA_COMMENT_AUTHOREMAIL_HIDDENConstants for author email hidden Metadatastatic StringMETADATA_COMMENT_AUTHORNAMEConstants for author name Metadatastatic StringMETADATA_COMMENT_AUTHORURLConstants for author url Metadatastatic StringMETADATA_COMMENT_CONTENTConstants for the content Metadatastatic StringMETADATA_COMMENT_CREATIONDATEConstants for creation Metadatastatic StringMETADATA_COMMENT_IS_DELETEDConstants for the is deleted status Metadatastatic StringMETADATA_COMMENT_IS_EDITEDConstants for the is edited status Metadatastatic StringMETADATA_COMMENT_VALIDATEDConstants for the validated status Metadatastatic StringMETADATA_COMMENTSConstants for comments Metadat*static StringMETADATA_COMMENTS_NOTVALIDATEDConstants for comments Metadata validatedstatic StringMETADATA_COMMENTS_VALIDATEDConstants for comments Metadata not validted
-
Constructor Summary
Constructors Constructor Description Comment(Comment comment)Creates a new sub comment of the commentComment(Comment comment, String commentId, ZonedDateTime creationDate)Creates a new sub comment of the comment, with the given id and creation date This method allow to create a sub comment from existing data (ex: data import from archive) The id is not generated here, the source is trusted.Comment(ModifiableModelLessDataHolder contentUnversionedDataHolder)Creates a new comment on the contentComment(ModifiableModelLessDataHolder contentUnversionedDataHolder, String commentId)Retrieves a comment by its idComment(ModifiableModelLessDataHolder contentUnversionedDataHolder, String commentId, ZonedDateTime creationDate)Creates a new comment on the content, with the given id and creation date This method allow to create a comment from existing data (ex: data import from archive) The id is not generated here, the source is trusted.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddReaction(UserIdentity user, ReactionableObject.ReactionType reactionType)Add the user reactionvoidaddReport()Add a report to the objectvoidclearReports()Remove all reports on the objectCommentcreateSubComment()Create sub comment from this commentCommentcreateSubComment(String commentId, ZonedDateTime creationDate)Creates a sub comment from this comment, with the given id and creation date This method allow to create a sub comment from existing data (ex: data import from archive) The id is not generated here, the source is trusted.StringgetAuthorEmail()Get the email of the author.StringgetAuthorName()Get the readable name of the author.StringgetAuthorURL()Get the url given by the author as its personal site url.static CommentgetComment(ModifiableModelLessDataHolder contentUnversionedDataHolder, String commentId)Get a commentprotected StringgetCommentDataPath(String commentId)Retrieves the path of the comment with the given identifierstatic List<Comment>getComments(Comment parentComment, boolean includeNotValidatedComments, boolean includeValidatedComments)Get the comments of a contentstatic List<Comment>getComments(Comment parentComment, boolean includeNotValidatedComments, boolean includeValidatedComments, boolean withSubComment)Get the comments of a contentstatic List<Comment>getComments(ModifiableModelLessDataHolder contentUnversionedDataHolder, boolean includeNotValidatedComments, boolean includeValidatedComments)Get the comments of a contentstatic List<Comment>getComments(ModifiableModelLessDataHolder contentUnversionedDataHolder, boolean includeNotValidatedComments, boolean includeValidatedComments, boolean isRecursive)Get the comments of a contentStringgetContent()Get the content of the comment.ZonedDateTimegetCreationDate()Get the date and time the comment was createdStringgetId()The comment id (unique to the content)List<UserIdentity>getReactionUsers(ReactionableObject.ReactionType reactionType)Get the list of users who reactlonggetReportsCount()Retrieves the number of reports on the objectModifiableRepositoryDatagetRepositoryData()Retrieves the repository data of theCommentList<Comment>getSubComment(boolean includeNotValidatedComments, boolean includeValidatedComments)Get sub comments of the commentbooleanisDeleted()Does the comment is deletedbooleanisEdited()Does the comment is editedbooleanisEmailHidden()Does the email of the authors have to be hidden ?booleanisValidated()Is the comment validatedvoidremove()Remove the comment.voidremoveReaction(UserIdentity user, ReactionableObject.ReactionType reactionType)Remove the user reactionvoidsetAuthorEmail(String email)Set the email of the author.voidsetAuthorName(String name)Set the readable name of the author.voidsetAuthorURL(String url)Set the personal site url of the authorvoidsetContent(String content)Set the content of the comment.voidsetDeleted(boolean isEdited)Set the comment to deleted.voidsetEdited(boolean isEdited)Set the comment to edited.voidsetEmailHiddenStatus(boolean hideEmail)Set the email hidden status.voidsetReportsCount(long reportsCount)Sets the number of reports on the objectvoidsetValidated(boolean validated)Set the validation status of the commentprotected voidupdate()Update the comment tag statistics
-
-
-
Field Detail
-
METADATA_COMMENTS
public static final String METADATA_COMMENTS
Constants for comments Metadat*- See Also:
- Constant Field Values
-
METADATA_COMMENTS_VALIDATED
public static final String METADATA_COMMENTS_VALIDATED
Constants for comments Metadata not validted- See Also:
- Constant Field Values
-
METADATA_COMMENTS_NOTVALIDATED
public static final String METADATA_COMMENTS_NOTVALIDATED
Constants for comments Metadata validated- See Also:
- Constant Field Values
-
METADATA_COMMENT_CREATIONDATE
public static final String METADATA_COMMENT_CREATIONDATE
Constants for creation Metadata- See Also:
- Constant Field Values
-
METADATA_COMMENT_AUTHORNAME
public static final String METADATA_COMMENT_AUTHORNAME
Constants for author name Metadata- See Also:
- Constant Field Values
-
METADATA_COMMENT_AUTHOREMAIL
public static final String METADATA_COMMENT_AUTHOREMAIL
Constants for author email Metadata- See Also:
- Constant Field Values
-
METADATA_COMMENT_AUTHOREMAIL_HIDDEN
public static final String METADATA_COMMENT_AUTHOREMAIL_HIDDEN
Constants for author email hidden Metadata- See Also:
- Constant Field Values
-
METADATA_COMMENT_AUTHORURL
public static final String METADATA_COMMENT_AUTHORURL
Constants for author url Metadata- See Also:
- Constant Field Values
-
METADATA_COMMENT_CONTENT
public static final String METADATA_COMMENT_CONTENT
Constants for the content Metadata- See Also:
- Constant Field Values
-
METADATA_COMMENT_VALIDATED
public static final String METADATA_COMMENT_VALIDATED
Constants for the validated status Metadata- See Also:
- Constant Field Values
-
METADATA_COMMENT_IS_EDITED
public static final String METADATA_COMMENT_IS_EDITED
Constants for the is edited status Metadata- See Also:
- Constant Field Values
-
METADATA_COMMENT_IS_DELETED
public static final String METADATA_COMMENT_IS_DELETED
Constants for the is deleted status Metadata- See Also:
- Constant Field Values
-
ID_SEPARATOR
public static final String ID_SEPARATOR
Constants for the separator- See Also:
- Constant Field Values
-
_contentDataHolder
protected ModifiableModelLessDataHolder _contentDataHolder
The content to comment
-
_commentComposite
protected ModifiableModelLessComposite _commentComposite
The node of the comment
-
-
Constructor Detail
-
Comment
public Comment(ModifiableModelLessDataHolder contentUnversionedDataHolder, String commentId)
Retrieves a comment by its id- Parameters:
contentUnversionedDataHolder- The unversioned data holder of the content hosting the commentcommentId- The id of the comment to retrieve- Throws:
AmetysRepositoryException- if an error occurred
-
Comment
public Comment(ModifiableModelLessDataHolder contentUnversionedDataHolder)
Creates a new comment on the content- Parameters:
contentUnversionedDataHolder- The unversioned data holder of the content where to add the new comment
-
Comment
public Comment(ModifiableModelLessDataHolder contentUnversionedDataHolder, String commentId, ZonedDateTime creationDate)
Creates a new comment on the content, with the given id and creation date This method allow to create a comment from existing data (ex: data import from archive) The id is not generated here, the source is trusted. Be careful using this method- Parameters:
contentUnversionedDataHolder- The unversioned data holder of the content where to add the new commentcommentId- the comment's idcreationDate- the comment's creation date
-
Comment
public Comment(Comment comment)
Creates a new sub comment of the comment- Parameters:
comment- The parent comment
-
Comment
public Comment(Comment comment, String commentId, ZonedDateTime creationDate)
Creates a new sub comment of the comment, with the given id and creation date This method allow to create a sub comment from existing data (ex: data import from archive) The id is not generated here, the source is trusted. Be careful using this method- Parameters:
comment- The parent commentcommentId- the sub comment's idcreationDate- the sub comment's creation date
-
-
Method Detail
-
getCommentDataPath
protected String getCommentDataPath(String commentId)
Retrieves the path of the comment with the given identifier- Parameters:
commentId- the comment identifier- Returns:
- the path of the comment
-
getRepositoryData
public ModifiableRepositoryData getRepositoryData()
Retrieves the repository data of theComment- Returns:
- the repository data of the
Comment
-
getCreationDate
public ZonedDateTime getCreationDate()
Get the date and time the comment was created- Returns:
- The non null date of creation of the comment.
-
getAuthorName
public String getAuthorName()
Get the readable name of the author.- Returns:
- The full name. Can be null.
-
setAuthorName
public void setAuthorName(String name)
Set the readable name of the author.- Parameters:
name- The full name. Can be null to remove the name.
-
getAuthorEmail
public String getAuthorEmail()
Get the email of the author.- Returns:
- The ameil. Can be null.
-
setAuthorEmail
public void setAuthorEmail(String email)
Set the email of the author.- Parameters:
email- The email. Can be null to remove the email.
-
getAuthorURL
public String getAuthorURL()
Get the url given by the author as its personal site url.- Returns:
- The url. Can be null.
-
setAuthorURL
public void setAuthorURL(String url)
Set the personal site url of the author- Parameters:
url- The url. Can be null to remove url.
-
isEmailHidden
public boolean isEmailHidden()
Does the email of the authors have to be hidden ?- Returns:
- true (default value) if the email does not have to appears to others users. Can still be used for administration.
-
setEmailHiddenStatus
public void setEmailHiddenStatus(boolean hideEmail)
Set the email hidden status.- Parameters:
hideEmail- true to set the email as hidden.
-
isEdited
public boolean isEdited()
Does the comment is edited- Returns:
- true the email is edited
-
setEdited
public void setEdited(boolean isEdited)
Set the comment to edited.- Parameters:
isEdited- true to set the comment to edited.
-
isDeleted
public boolean isDeleted()
Does the comment is deleted- Returns:
- true the comment is deleted
-
setDeleted
public void setDeleted(boolean isEdited)
Set the comment to deleted.- Parameters:
isEdited- true to set the comment to deleted.
-
getContent
public String getContent()
Get the content of the comment. A simple String (with \n or \t).- Returns:
- The content. Can be null.
-
setContent
public void setContent(String content)
Set the content of the comment.- Parameters:
content- The content to set. Can be null to remove the content. Have to be a simple String (with \n or \t).
-
isValidated
public boolean isValidated()
Is the comment validated- Returns:
- the status of validation of the comment
-
setValidated
public void setValidated(boolean validated)
Set the validation status of the comment- Parameters:
validated- true the comment is validated
-
addReport
public void addReport()
Description copied from interface:ReportableObjectAdd a report to the object- Specified by:
addReportin interfaceReportableObject
-
setReportsCount
public void setReportsCount(long reportsCount)
Description copied from interface:ReportableObjectSets the number of reports on the object- Specified by:
setReportsCountin interfaceReportableObject- Parameters:
reportsCount- the number of reports to set
-
clearReports
public void clearReports()
Description copied from interface:ReportableObjectRemove all reports on the object- Specified by:
clearReportsin interfaceReportableObject
-
getReportsCount
public long getReportsCount()
Description copied from interface:ReportableObjectRetrieves the number of reports on the object- Specified by:
getReportsCountin interfaceReportableObject- Returns:
- the number of reports
-
remove
public void remove()
Remove the comment.
-
getSubComment
public List<Comment> getSubComment(boolean includeNotValidatedComments, boolean includeValidatedComments)
Get sub comments of the comment- Parameters:
includeNotValidatedComments- True to include the comments that are not validatedincludeValidatedComments- True to include the comments that are validated- Returns:
- the list of comments
-
createSubComment
public Comment createSubComment()
Create sub comment from this comment- Returns:
- the sub comment
-
createSubComment
public Comment createSubComment(String commentId, ZonedDateTime creationDate)
Creates a sub comment from this comment, with the given id and creation date This method allow to create a sub comment from existing data (ex: data import from archive) The id is not generated here, the source is trusted. Be careful using this method- Parameters:
commentId- the comment's idcreationDate- the comment's creation date- Returns:
- the new comment
-
update
protected void update()
Update the comment tag statistics
-
getComment
public static Comment getComment(ModifiableModelLessDataHolder contentUnversionedDataHolder, String commentId) throws AmetysRepositoryException
Get a comment- Parameters:
contentUnversionedDataHolder- the content data holdercommentId- The comment identifier- Returns:
- The comment
- Throws:
AmetysRepositoryException- if the comment does not exist
-
getComments
public static List<Comment> getComments(Comment parentComment, boolean includeNotValidatedComments, boolean includeValidatedComments) throws AmetysRepositoryException
Get the comments of a content- Parameters:
parentComment- The parent commentincludeNotValidatedComments- True to include the comments that are not validatedincludeValidatedComments- True to include the comments that are validated- Returns:
- the list of comments
- Throws:
AmetysRepositoryException- If an error occurred
-
getComments
public static List<Comment> getComments(Comment parentComment, boolean includeNotValidatedComments, boolean includeValidatedComments, boolean withSubComment) throws AmetysRepositoryException
Get the comments of a content- Parameters:
parentComment- The parent commentincludeNotValidatedComments- True to include the comments that are not validatedincludeValidatedComments- True to include the comments that are validatedwithSubComment- true if we want to get all child comments- Returns:
- the list of comments
- Throws:
AmetysRepositoryException- If an error occurred
-
getComments
public static List<Comment> getComments(ModifiableModelLessDataHolder contentUnversionedDataHolder, boolean includeNotValidatedComments, boolean includeValidatedComments) throws AmetysRepositoryException
Get the comments of a content- Parameters:
contentUnversionedDataHolder- The content unversioned data holderincludeNotValidatedComments- True to include the comments that are not validatedincludeValidatedComments- True to include the comments that are validated- Returns:
- the list of comments
- Throws:
AmetysRepositoryException- If an error occurred
-
getComments
public static List<Comment> getComments(ModifiableModelLessDataHolder contentUnversionedDataHolder, boolean includeNotValidatedComments, boolean includeValidatedComments, boolean isRecursive) throws AmetysRepositoryException
Get the comments of a content- Parameters:
contentUnversionedDataHolder- The content unversioned metadata holderincludeNotValidatedComments- True to include the comments that are not validatedincludeValidatedComments- True to include the comments that are validatedisRecursive- true if we want to have sub comments- Returns:
- the list of comments
- Throws:
AmetysRepositoryException- If an error occurred
-
addReaction
public void addReaction(UserIdentity user, ReactionableObject.ReactionType reactionType)
Description copied from interface:ReactionableObjectAdd the user reaction- Specified by:
addReactionin interfaceReactionableObject- Parameters:
user- the userreactionType- the reaction type
-
removeReaction
public void removeReaction(UserIdentity user, ReactionableObject.ReactionType reactionType)
Description copied from interface:ReactionableObjectRemove the user reaction- Specified by:
removeReactionin interfaceReactionableObject- Parameters:
user- the userreactionType- the reaction type
-
getReactionUsers
public List<UserIdentity> getReactionUsers(ReactionableObject.ReactionType reactionType)
Description copied from interface:ReactionableObjectGet the list of users who react- Specified by:
getReactionUsersin interfaceReactionableObject- Parameters:
reactionType- the reaction type- Returns:
- the list of users
-
-