Class DefaultCommentService
- java.lang.Object
-
- org.silverpeas.core.comment.service.DefaultCommentService
-
- All Implemented Interfaces:
ComponentInstanceDeletion
,CommentService
@Service @Named("commentService") public class DefaultCommentService extends Object implements CommentService, ComponentInstanceDeletion
A service that provide the features to handle the comments in Silverpeas. Such features are, for example, retrieving comments on a given content, creating a comment into the business layer, indexing them, notifying components interested by the creation or the deletion of a comment, and so on. A comment is text written by users about a content published in Silverpeas. Such comment, as any other contents in Silverpeas, can be indexed in order to be found by the Silverpeas search engine. This service is managed by an IoC container and this be retrieved by dependency injection.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DefaultCommentService()
Constructs a new DefaultCommentService instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Comment
createAndIndexComment(Comment cmt)
Persists and indexes the specified comment and notifies any observers about the comment creation.Comment
createComment(Comment cmt)
Persists the specified comment and notifies any observers about the comment creation.void
delete(String componentInstanceId)
Deletes the resources belonging to the specified component instance.void
deleteAllCommentsOnResource(String resourceType, ResourceReference resourceRef)
Deletes all the comments on the specified resource and notifies any observers about those comments deletion.void
deleteComment(Comment comment)
Deletes the specified comment and notifies about any observers about his deletion.void
deleteComment(CommentId commentId)
Deletes the comment identified by the specified identifier and notifies any observers about the comment deletion.List<Comment>
getAllCommentsOnResource(String resourceType, ResourceReference resourceRef)
Gets all the comments on the resource identified by the resource type and the specified reference.List<CommentedPublicationInfo>
getAllMostCommentedPublicationsInfo()
Gets information about all the commented resources in Silverpeas.Comment
getComment(CommentId commentId)
Gets the comment that identified by the specified identifier.Map<ResourceReference,Integer>
getCommentCountIndexedByResource(String resourceType, String instanceId)
Gets the number of comments by resources of resource type and hosted by the specified component instance.protected CommentDAO
getCommentDAO()
Gets the comment DAO with wich operations with the underlying data source can be performed.int
getCommentsCountOnResource(String resourceType, ResourceReference ref)
Gets the count of comments on the resource identifier by the resource type and the specified reference.org.silverpeas.kernel.bundle.LocalizationBundle
getComponentMessages(String language)
List<Comment>
getLastComments(String resourceType, int count)
List<CommentedPublicationInfo>
getMostCommentedPublicationsInfo(String resourceType)
Gets information about the most commented resources of the specified type.List<CommentedPublicationInfo>
getMostCommentedPublicationsInfo(String resourceType, List<ResourceReference> resourceRefs)
Gets information about the commented resources among the specified ones.protected OrganizationController
getOrganisationController()
Gets an organization controller.List<SocialInformationComment>
getSocialInformationCommentsListByUserId(List<String> resourceTypes, String userId, Period period)
Get the list of SocialInformationComment added by the given user in a specified period.List<SocialInformationComment>
getSocialInformationCommentsListOfMyContacts(List<String> resourceTypes, List<String> myContactsIds, List<String> instanceIds, Period period)
Gets the list of SocialInformationComment added by the specified contacts in the given period.void
indexAllCommentsOnPublication(String resourceType, ResourceReference ref)
Indexes all the comments on the resource identified by the resource type and the specified reference.void
moveAndReindexComments(String resourceType, ResourceReference fromResource, ResourceReference toResource)
Moves the comments on the specified resource to the another specified resource and indexes them again.void
moveComments(String resourceType, ResourceReference fromResource, ResourceReference toResource)
Moves the comments on the specified resource to the another specified resource.void
unindexAllCommentsOnPublication(String resourceType, ResourceReference ref)
Removes the indexes on all the comments of the resource identified by the resource type and the specified reference.void
updateAndIndexComment(Comment cmt)
Updates and indexes the specified comment in the business layer.void
updateComment(Comment cmt)
Updates the specified comment in the business layer.
-
-
-
Method Detail
-
getCommentDAO
protected CommentDAO getCommentDAO()
Gets the comment DAO with wich operations with the underlying data source can be performed.- Returns:
- the DAO on the comments.
-
createComment
public Comment createComment(Comment cmt)
Description copied from interface:CommentService
Persists the specified comment and notifies any observers about the comment creation.- Specified by:
createComment
in interfaceCommentService
- Parameters:
cmt
- the comment to save.- Returns:
- the created comment with its unique identifier.
-
createAndIndexComment
public Comment createAndIndexComment(Comment cmt)
Description copied from interface:CommentService
Persists and indexes the specified comment and notifies any observers about the comment creation.- Specified by:
createAndIndexComment
in interfaceCommentService
- Parameters:
cmt
- the comment to save and to index.- Returns:
- the created comment with its unique identifier.
-
deleteComment
public void deleteComment(CommentId commentId)
Description copied from interface:CommentService
Deletes the comment identified by the specified identifier and notifies any observers about the comment deletion. Any indexes on it are removed. If no such comment exists with the specified identifier, then a CommentRuntimeException is thrown.- Specified by:
deleteComment
in interfaceCommentService
- Parameters:
commentId
- the unique identifier of the comment to remove.
-
deleteAllCommentsOnResource
public void deleteAllCommentsOnResource(String resourceType, ResourceReference resourceRef)
Description copied from interface:CommentService
Deletes all the comments on the specified resource and notifies any observers about those comments deletion. If no such resource exists with the specified identifier then a CommentRuntimeException is thrown.- Specified by:
deleteAllCommentsOnResource
in interfaceCommentService
- Parameters:
resourceType
- the type of the commented resource.resourceRef
- a reference to the resource the comments are on.
-
deleteComment
public void deleteComment(Comment comment)
Description copied from interface:CommentService
Deletes the specified comment and notifies about any observers about his deletion. Any indexes on it are removed. If no such comment exists with the specified identifier, then a CommentRuntimeException is thrown.- Specified by:
deleteComment
in interfaceCommentService
- Parameters:
comment
- the comment to remove.
-
moveComments
public void moveComments(String resourceType, ResourceReference fromResource, ResourceReference toResource)
Description copied from interface:CommentService
Moves the comments on the specified resource to the another specified resource. The resulting operation is that the comments will be on the other resource and all the previous indexes on them are removed. If at least one of the resources doesn't exist then a CommentRuntimeException is thrown.- Specified by:
moveComments
in interfaceCommentService
- Parameters:
resourceType
- the type of the commented resource. Both the source and target resources have to be of the same type.fromResource
- a reference to the source resource.toResource
- a reference to the destination resource.
-
moveAndReindexComments
public void moveAndReindexComments(String resourceType, ResourceReference fromResource, ResourceReference toResource)
Description copied from interface:CommentService
Moves the comments on the specified resource to the another specified resource and indexes them again. The resulting operation is that the comments are on the other resource and they are indexed again (or simply indexed if not already) accordingly to the new resource. If at least one of the resources doesn't exist then a CommentRuntimeException is thrown.- Specified by:
moveAndReindexComments
in interfaceCommentService
- Parameters:
resourceType
- the type of the commented resource. Both the source and target resources have to be of the same type.fromResource
- a reference to the source resource.toResource
- a reference to the destination resource.
-
updateComment
public void updateComment(Comment cmt)
Description copied from interface:CommentService
Updates the specified comment in the business layer. The comment to update is identified by its unique identifier and the update information are carried by the given Comment instance.- Specified by:
updateComment
in interfaceCommentService
- Parameters:
cmt
- the updated comment.
-
updateAndIndexComment
public void updateAndIndexComment(Comment cmt)
Description copied from interface:CommentService
Updates and indexes the specified comment in the business layer. The comment to update in the business layer is identified by its unique identifier and the update information are carried by the given Comment instance.- Specified by:
updateAndIndexComment
in interfaceCommentService
- Parameters:
cmt
- the comment to update and to index.
-
getComment
public Comment getComment(CommentId commentId)
Description copied from interface:CommentService
Gets the comment that identified by the specified identifier. If no such comment exists with the specified identifier, then a CommentRuntimeException is thrown.- Specified by:
getComment
in interfaceCommentService
- Parameters:
commentId
- the identifier of the comment in the business layer.- Returns:
- the comment.
-
getAllCommentsOnResource
public List<Comment> getAllCommentsOnResource(String resourceType, ResourceReference resourceRef)
Description copied from interface:CommentService
Gets all the comments on the resource identified by the resource type and the specified reference. If no such publication exists with the specified resource reference, then a CommentRuntimeException is thrown.- Specified by:
getAllCommentsOnResource
in interfaceCommentService
- Parameters:
resourceType
- the type of the commented resource.resourceRef
- a reference to the resource.- Returns:
- a list of the comments on the given resource. The list is empty if the resource isn't commented.
-
getMostCommentedPublicationsInfo
public List<CommentedPublicationInfo> getMostCommentedPublicationsInfo(String resourceType, List<ResourceReference> resourceRefs)
Description copied from interface:CommentService
Gets information about the commented resources among the specified ones. The resource information are returned ordered down to the lesser commented resource.- Specified by:
getMostCommentedPublicationsInfo
in interfaceCommentService
- Parameters:
resourceType
- the type of the commented resource.resourceRefs
- a collection of reference to the resources to get information and to order by comments count.- Returns:
- an ordered list of information about the most commented resource. The list is sorted by their comments count in a descendent order.
-
getMostCommentedPublicationsInfo
public List<CommentedPublicationInfo> getMostCommentedPublicationsInfo(String resourceType)
Description copied from interface:CommentService
Gets information about the most commented resources of the specified type. The resource information are returned ordered down to the lesser commented resource.- Specified by:
getMostCommentedPublicationsInfo
in interfaceCommentService
- Parameters:
resourceType
- the type of the commented resource.- Returns:
- an ordered list of information about the most commented resources. The list is sorted by their comments count in a descendent order.
-
getAllMostCommentedPublicationsInfo
public List<CommentedPublicationInfo> getAllMostCommentedPublicationsInfo()
Description copied from interface:CommentService
Gets information about all the commented resources in Silverpeas. The resource information are returned ordered down to the lesser commented resource.- Specified by:
getAllMostCommentedPublicationsInfo
in interfaceCommentService
- Returns:
- an ordered list of information about the most commented resources. The list is sorted by their comments count in a descendent order.
-
getCommentsCountOnResource
public int getCommentsCountOnResource(String resourceType, ResourceReference ref)
Description copied from interface:CommentService
Gets the count of comments on the resource identifier by the resource type and the specified reference.- Specified by:
getCommentsCountOnResource
in interfaceCommentService
- Parameters:
resourceType
- the type of the commented resource.ref
- a reference on the resource.- Returns:
- the number of comments on the resource.
-
getCommentCountIndexedByResource
public Map<ResourceReference,Integer> getCommentCountIndexedByResource(String resourceType, String instanceId)
Description copied from interface:CommentService
Gets the number of comments by resources of resource type and hosted by the specified component instance.- Specified by:
getCommentCountIndexedByResource
in interfaceCommentService
- Parameters:
resourceType
- type of the commented publication.instanceId
- identifier of aimed component instance.- Returns:
- a map containing the number of comments by resources.
-
indexAllCommentsOnPublication
public void indexAllCommentsOnPublication(String resourceType, ResourceReference ref)
Description copied from interface:CommentService
Indexes all the comments on the resource identified by the resource type and the specified reference. If no such resource exists with the specified reference, then a CommentRuntimeException is thrown.- Specified by:
indexAllCommentsOnPublication
in interfaceCommentService
- Parameters:
resourceType
- the type of the commented resource.ref
- a reference on the resource.
-
unindexAllCommentsOnPublication
public void unindexAllCommentsOnPublication(String resourceType, ResourceReference ref)
Description copied from interface:CommentService
Removes the indexes on all the comments of the resource identified by the resource type and the specified reference. If no such resource exists with the specified reference, then a CommentRuntimeException is thrown.- Specified by:
unindexAllCommentsOnPublication
in interfaceCommentService
- Parameters:
resourceType
- the type of the commented publication.ref
- a reference on the resource.
-
getOrganisationController
protected OrganizationController getOrganisationController()
Gets an organization controller.- Returns:
- an OrganizationController instance.
-
getComponentMessages
public org.silverpeas.kernel.bundle.LocalizationBundle getComponentMessages(String language)
- Specified by:
getComponentMessages
in interfaceCommentService
-
getLastComments
public List<Comment> getLastComments(String resourceType, int count)
- Specified by:
getLastComments
in interfaceCommentService
-
getSocialInformationCommentsListByUserId
public List<SocialInformationComment> getSocialInformationCommentsListByUserId(List<String> resourceTypes, String userId, Period period)
Description copied from interface:CommentService
Get the list of SocialInformationComment added by the given user in a specified period.- Specified by:
getSocialInformationCommentsListByUserId
in interfaceCommentService
- Parameters:
resourceTypes
- the aimed resources types.userId
- the author of comments.period
- the period into which the comment has been created or modified.- Returns:
- List of
SocialInformation
-
getSocialInformationCommentsListOfMyContacts
public List<SocialInformationComment> getSocialInformationCommentsListOfMyContacts(List<String> resourceTypes, List<String> myContactsIds, List<String> instanceIds, Period period)
Description copied from interface:CommentService
Gets the list of SocialInformationComment added by the specified contacts in the given period.- Specified by:
getSocialInformationCommentsListOfMyContacts
in interfaceCommentService
- Parameters:
resourceTypes
- the aimed resources types.myContactsIds
- the aimed user identifiers of contacts.instanceIds
- the aimed identifiers of component instances.period
- the period into which the comment has been created or modified.- Returns:
- List of
SocialInformation
-
delete
public void delete(String componentInstanceId)
Description copied from interface:ComponentInstanceDeletion
Deletes the resources belonging to the specified component instance. This method is invoked by Silverpeas when a component instance is being deleted.- Specified by:
delete
in interfaceComponentInstanceDeletion
- Parameters:
componentInstanceId
- the unique identifier of a component instance.
-
-