Class AbstractCommentingProvider

    • Field Detail

      • RELATIVE_TARGET_ROOT

        public static final java.lang.String RELATIVE_TARGET_ROOT
        The name of the node holding comment collections below a target.
        See Also:
        Constant Field Values
      • PN_ANNOTATIONDATA

        public static final java.lang.String PN_ANNOTATIONDATA
        The name of the property holding optional annotation data
        See Also:
        Constant Field Values
      • PN_AUTHOR

        public static final java.lang.String PN_AUTHOR
        The property containing the optional creator of a comment
        See Also:
        Constant Field Values
      • PN_MESSAGE

        public static final java.lang.String PN_MESSAGE
        The name of the property holding a comment's message ("comment").
        See Also:
        Constant Field Values
      • SLING_RESOURCE_TYPE

        public static final java.lang.String SLING_RESOURCE_TYPE
        See Also:
        Constant Field Values
    • Constructor Detail

      • AbstractCommentingProvider

        public AbstractCommentingProvider()
    • Method Detail

      • getCommentResources

        public java.util.Iterator<Resource> getCommentResources​(Resource collectionResource)
        Returns an Iterator of Resources, with each resource representing a Comment of the given CommentCollection.
        Parameters:
        collectionResource - The CommentCollection for which to retrieve the comment resources.
        Returns:
        The iterator containing the comment resources, or an empty iterator if no comments are present.
        Throws:
        CommentException - Upon encountering an error retrieving the comments.
      • removeCommentResource

        public void removeCommentResource​(Resource resource)
        Remove (delete) the given Comment from the repository.
        Parameters:
        resource - The comment resource to delete.
        Throws:
        CommentException - Upon encountering an error writing to the repository.
      • removeCollectionResource

        public void removeCollectionResource​(Resource resource)
        Remove (delete) the given CommentCollection from the repository.
        Parameters:
        resource - The collection to delete.
        Throws:
        CommentException - Upon encountering an error writing to the repository.
      • createAttachmentResource

        public final Resource createAttachmentResource​(Resource commentResource,
                                                       java.lang.String name,
                                                       java.io.InputStream inputStream,
                                                       java.lang.String mimeType)
        Add an attachment to the given Comment. The attachment is represented by the given name (file name), an InputStream and the mime type, all of which are mandatory parameters. The relative path with which the attachment is created can be customized via getAttachmentResourcePath(String), also arbitrary properties can be set on the attachment's content node via customizeAttachmentNode(Resource, javax.jcr.Node).
        Parameters:
        commentResource - The comment to which to add the attachment.
        name - The name (file name) for the attachment.
        inputStream - The input stream containing the file data of the attachment.
        mimeType - The mime type of the attachment data.
        Returns:
        The newly created attachment resource.
        Throws:
        CommentException - Upon encountering an error writing to the repository.
      • getAttachmentResource

        public Resource getAttachmentResource​(Resource commentResource,
                                              java.lang.String name)
        Return the attachment of the given Comment as identified by its given name (file name).
        Parameters:
        commentResource - The comment from which to get the attachment.
        name - The name of the attachment.
        Returns:
        The Resource representing the attachment, or null if no attachment with the given name was found.
        Throws:
        CommentException - Upon encountering an error retrieving the attachment.
      • removeAttachmentResource

        public void removeAttachmentResource​(Resource commentResource,
                                             java.lang.String name)
        Remove (delete) the attachment identified by the given name from the given Comment.
        Parameters:
        commentResource - The comment from which to remove the attachment.
        name - The name of the attachment to remove.
        Throws:
        CommentException - Upon encountering an error writing to the repository.
      • getAttachmentMap

        public final java.util.Map<java.lang.String,​Resource> getAttachmentMap​(Resource commentResource)
                                                                              throws CommentException
        Return a Map containing the given Comments attachments. The map key is the attachment's name (file name), the map value holds the Resource representing the attachment.
        Parameters:
        commentResource - The comment for which to retrieve the attachments.
        Returns:
        The map of attachments, or an empty map if no attachments are present.
        Throws:
        CommentException - Upon encountering an error retrieving the attachments.
      • getCollectionResourceType

        public abstract java.lang.String getCollectionResourceType()
        Returns an optional resource type to set for newly created collections.
        Returns:
        The resource type or null if none shall be set.
      • getCommentResourceType

        public abstract java.lang.String getCommentResourceType()
        Returns an optional resource type to set for newly created comments.
        Returns:
        The resource type or null if none shall be set.