public abstract class AbstractCommentingProvider extends java.lang.Object implements CommentingProvider
AbstractCommentingProvider
provides a default implementation for storing Comment
s and CommentCollection
s. CommentingProvider
s are recommended to extend this abstract implementation and override
where necessary.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
JCR_CREATED_BY |
static java.lang.String |
PN_ANNOTATIONDATA
The name of the property holding optional annotation data
|
static java.lang.String |
PN_AUTHOR
The property containing the optional creator of a comment
|
static java.lang.String |
PN_MESSAGE
The name of the property holding a comment's message ("comment").
|
static java.lang.String |
RELATIVE_TARGET_ROOT
The name of the node holding comment collections below a target.
|
static java.lang.String |
SLING_RESOURCE_TYPE |
PROPERTY_COLLECTION_TYPES, PROPERTY_COMMENT_TYPES
Constructor and Description |
---|
AbstractCommentingProvider() |
Modifier and Type | Method and Description |
---|---|
Resource |
createAttachmentResource(Resource commentResource,
java.lang.String name,
java.io.InputStream inputStream,
java.lang.String mimeType)
Add an attachment to the given
Comment . |
Resource |
createCollectionResource(Resource target)
Create the root of a
CommentCollection for the given target Resource . |
Resource |
createCommentResource(Resource collectionResource,
java.lang.String message,
java.lang.String author,
java.lang.String annotationData)
Add a
Comment resource to the given CommentCollection resource, set the given
message on the comment. |
java.util.Map<java.lang.String,Resource> |
getAttachmentMap(Resource commentResource)
Return a
Map containing the given Comment s attachments. |
Resource |
getAttachmentResource(Resource commentResource,
java.lang.String name)
Return the attachment of the given
Comment as identified by its given name (file name). |
abstract java.lang.String |
getCollectionResourceType()
Returns an optional resource type to set for newly created collections.
|
java.util.Iterator<Resource> |
getCommentResources(Resource collectionResource)
Returns an
Iterator of Resource s, with each resource representing a Comment of the given
CommentCollection . |
abstract java.lang.String |
getCommentResourceType()
Returns an optional resource type to set for newly created comments.
|
void |
removeAttachmentResource(Resource commentResource,
java.lang.String name)
Remove (delete) the attachment identified by the given
name from the given Comment . |
void |
removeCollectionResource(Resource resource)
Remove (delete) the given
CommentCollection from the repository. |
void |
removeCommentResource(Resource resource)
Remove (delete) the given
Comment from the repository. |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createCollection, getCollection
public static final java.lang.String RELATIVE_TARGET_ROOT
public static final java.lang.String PN_ANNOTATIONDATA
public static final java.lang.String PN_AUTHOR
public static final java.lang.String PN_MESSAGE
public static final java.lang.String JCR_CREATED_BY
public static final java.lang.String SLING_RESOURCE_TYPE
public final Resource createCollectionResource(Resource target)
CommentCollection
for the given target Resource
. Node creation may be
overridden via #createCollectionNode(String, javax.jcr.Session)
. If not already present on the node, this
method also will set the JCR_CREATED_BY
and JcrConstants.JCR_CREATED
properties. The last
modified mixin will maintain the last modified date. Custom properties may be set on the collection node via
#customizeCollectionNode(Resource, javax.jcr.Node)
.target
- The target resource for which to create a collection root.CommentException
- If a collection already exists for the given target, or upon encountering an error
writing to the repository.public final Resource createCommentResource(Resource collectionResource, java.lang.String message, java.lang.String author, java.lang.String annotationData)
Comment
resource to the given CommentCollection
resource, set the given
message
on the comment. Comment node creation may be overridden via #createCommentNode(String, javax.jcr.Node, javax.jcr.Session)
. This method will forcibly set a SLING_RESOURCE_TYPE
property (if defined by getCommentResourceType()
()}), the PN_MESSAGE
property. If not already present on the node, this method also will set the JCR_CREATED_BY
and JcrConstants.JCR_CREATED
properties. Custom properties may be set on the comment resource via #customizeCommentNode(Resource, javax.jcr.Node)
(javax.jcr.Node)}.collectionResource
- The collection within which to create the comment.message
- The message to store in the comment.author
- The author to store in the comment.annotationData
- The annotation data to store in the comment.Resource
.CommentException
- Upon encountering an error writing to the repository.public java.util.Iterator<Resource> getCommentResources(Resource collectionResource)
Iterator
of Resource
s, with each resource representing a Comment
of the given
CommentCollection
.collectionResource
- The CommentCollection
for which to retrieve the comment resources.CommentException
- Upon encountering an error retrieving the comments.public void removeCommentResource(Resource resource)
Comment
from the repository.resource
- The comment resource to delete.CommentException
- Upon encountering an error writing to the repository.public void removeCollectionResource(Resource resource)
CommentCollection
from the repository.resource
- The collection to delete.CommentException
- Upon encountering an error writing to the repository.public final Resource createAttachmentResource(Resource commentResource, java.lang.String name, java.io.InputStream inputStream, java.lang.String mimeType)
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)
.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.CommentException
- Upon encountering an error writing to the repository.public Resource getAttachmentResource(Resource commentResource, java.lang.String name)
Comment
as identified by its given name
(file name).commentResource
- The comment from which to get the attachment.name
- The name of the attachment.Resource
representing the attachment, or null
if no attachment with the given
name was found.CommentException
- Upon encountering an error retrieving the attachment.public void removeAttachmentResource(Resource commentResource, java.lang.String name)
name
from the given Comment
.commentResource
- The comment from which to remove the attachment.name
- The name of the attachment to remove.CommentException
- Upon encountering an error writing to the repository.public final java.util.Map<java.lang.String,Resource> getAttachmentMap(Resource commentResource) throws CommentException
Map
containing the given Comment
s attachments. The map key is the attachment's name
(file name), the map value holds the Resource
representing the attachment.commentResource
- The comment for which to retrieve the attachments.CommentException
- Upon encountering an error retrieving the attachments.public abstract java.lang.String getCollectionResourceType()
null
if none shall be set.public abstract java.lang.String getCommentResourceType()
null
if none shall be set."Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"