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
  • Field Details

  • Constructor Details

    • Comment

      public Comment(ModifiableModelLessDataHolder contentUnversionedDataHolder, String commentId)
      Retrieves a comment by its id
      Parameters:
      contentUnversionedDataHolder - The unversioned data holder of the content hosting the comment
      commentId - 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 comment
      commentId - the comment's id
      creationDate - 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 comment
      commentId - the sub comment's id
      creationDate - the sub comment's creation date
  • Method Details

    • 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

      Retrieves the repository data of the Comment
      Returns:
      the repository data of the Comment
    • getId

      public String getId()
      The comment id (unique to the content)
      Returns:
      The id. Cannot be null.
    • getCreationDate

      Get the date and time the comment was created
      Returns:
      The non null date of creation of the comment.
    • 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

      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: ReportableObject
      Add a report to the object
      Specified by:
      addReport in interface ReportableObject
    • setReportsCount

      public void setReportsCount(long reportsCount)
      Description copied from interface: ReportableObject
      Sets the number of reports on the object
      Specified by:
      setReportsCount in interface ReportableObject
      Parameters:
      reportsCount - the number of reports to set
    • clearReports

      public void clearReports()
      Description copied from interface: ReportableObject
      Remove all reports on the object
      Specified by:
      clearReports in interface ReportableObject
    • getReportsCount

      public long getReportsCount()
      Description copied from interface: ReportableObject
      Retrieves the number of reports on the object
      Specified by:
      getReportsCount in interface ReportableObject
      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 validated
      includeValidatedComments - True to include the comments that are validated
      Returns:
      the list of comments
    • 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 id
      creationDate - 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 holder
      commentId - 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 comment
      includeNotValidatedComments - True to include the comments that are not validated
      includeValidatedComments - 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 comment
      includeNotValidatedComments - True to include the comments that are not validated
      includeValidatedComments - True to include the comments that are validated
      withSubComment - 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 holder
      includeNotValidatedComments - True to include the comments that are not validated
      includeValidatedComments - 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 holder
      includeNotValidatedComments - True to include the comments that are not validated
      includeValidatedComments - True to include the comments that are validated
      isRecursive - 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: ReactionableObject
      Add the user reaction
      Specified by:
      addReaction in interface ReactionableObject
      Parameters:
      user - the user
      reactionType - the reaction type
    • removeReaction

      public void removeReaction(UserIdentity user, ReactionableObject.ReactionType reactionType)
      Description copied from interface: ReactionableObject
      Remove the user reaction
      Specified by:
      removeReaction in interface ReactionableObject
      Parameters:
      user - the user
      reactionType - the reaction type
    • getReactionUsers

      Description copied from interface: ReactionableObject
      Get the list of users who react
      Specified by:
      getReactionUsers in interface ReactionableObject
      Parameters:
      reactionType - the reaction type
      Returns:
      the list of users