Interface CommentingProvider

  • All Known Implementing Classes:
    AbstractCommentingProvider

    @ConsumerType
    public interface CommentingProvider
    A CommentingProvider represents a "configuration" used by the CommentManager service to create and store Comments and CommentCollections. In this way, multiple comment collections for the same target can be supported (e.g. target-located author-comments/annotations vs. user-generated comments stored in /content/usergenerated). A provider operates on a target-specific resource. Providers must register themselves as OSGi-components and service on this interface in order for them to be automatically picked up by the CommentManager. A provider also must announce the types of comments and collections it supports via the mandatory OSGi service properties PROPERTY_COMMENT_TYPES and PROPERTY_COLLECTION_TYPES. A provider announces the supported types like this:
         \@Properties({
     \@Property(name = CommentingProvider.PROPERTY_COMMENT_TYPES, classValue = MyComment.class),
     \@Property(name = CommentingProvider.PROPERTY_COLLECTION_TYPES, classValue = MyCommentCollection.class)
     })
     
    Implementations should implement AdapterFactory and provide the following adaptations for their respectively supported comment and collection types:
    • Adapt a target resource to any of the supported comment collections
    • Adapt an actual comment collection resource to a supported comment collection
    • Adapt an actual comment resource to a supported comment
    For example:
    • Target (e.g. /content/geometrixx/en): resource.adaptTo(CommentCollection.class)
    • Collection Resource (e.g. /content/geometrixx/en/jcr:content/comments): resource.adaptTo(CommentCollection.class)
    • Comment Resource (e.g. /content/geometrixx/en/jcr:content/comments/my_comment): resource.adaptTo(Comment.class)
    • Field Detail

      • PROPERTY_COLLECTION_TYPES

        static final java.lang.String PROPERTY_COLLECTION_TYPES
        The name of the OSGi service property that holds an array of classes this provider supports for collections.
        See Also:
        Constant Field Values
      • PROPERTY_COMMENT_TYPES

        static final java.lang.String PROPERTY_COMMENT_TYPES
        The name of the OSGi service property that holds an array of classes this provider supports for comments.
        See Also:
        Constant Field Values
    • Method Detail

      • getCollection

        <C extends CommentCollection> C getCollection​(Resource target,
                                                      java.lang.Class<C> collectionType)
        Retrieves a CommentCollection of the given collectionType for the given target.
        Type Parameters:
        C - A collection type, extending CommentCollection.
        Parameters:
        target - The target the collection belongs to.
        collectionType - The type of the collection.
        Returns:
        An existing collection object of the given type, or null if no collection exists.
        Throws:
        CommentException - If target does not have collection of given collectionType.
      • createCollection

        <C extends CommentCollection> C createCollection​(Resource target,
                                                         java.lang.Class<C> collectionType)
        Instantiates a new CommentCollection of the given collectionType for the given target.
        Type Parameters:
        C - A collection type, extending CommentCollection.
        Parameters:
        target - The target the collection belongs to.
        collectionType - The type of the collection.
        Returns:
        A new collection object of the given type.
        Throws:
        CommentException - If a collection already exists for on the target-specific root resource, or upon encountering an error persisting.