com.silverpeas.comment.service
Class DefaultCommentService

java.lang.Object
  extended by com.silverpeas.comment.service.CommentActionNotifier
      extended by com.silverpeas.comment.service.DefaultCommentService
All Implemented Interfaces:
CommentService, SilverpeasComponentService<Comment>

@Named(value="commentService")
public class DefaultCommentService
extends CommentActionNotifier
implements CommentService

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
protected DefaultCommentService()
          Constructs a new DefaultCommentService instance.
 
Method Summary
 void createAndIndexComment(Comment cmt)
          Creates and indexes the specified comment into the business layer.
 void createComment(Comment cmt)
          Creates the specified comment into the business layer.
 void deleteAllCommentsByComponentInstanceId(String instanceId)
          Deletes all of the comments by the component instance identifier.
 void deleteAllCommentsOnPublication(String resourceType, WAPrimaryKey pk)
          Deletes all of the comments on the publication identified by the resource type and the specified identifier.
 void deleteComment(Comment comment)
          Deletes the specified comment.
 void deleteComment(CommentPK pk)
          Deletes the comment identified by the specified identifier.
 List<Comment> getAllCommentsOnPublication(String resourceType, WAPrimaryKey pk)
          Gets all of the comments on the publication identified by the resource type and the specified identifier.
 List<CommentedPublicationInfo> getAllMostCommentedPublicationsInfo()
          Gets information about all the commented publications in Silverpeas.
 Comment getComment(CommentPK pk)
          Gets the comment that identified by the specified identifier.
protected  CommentDAO getCommentDAO()
          Gets the comment DAO with wich operations with the underlying data source can be performed.
 int getCommentsCountOnPublication(String resourceType, WAPrimaryKey pk)
          Gets the count of comments on the publication identified by the resource type and the specified identifier.
 ResourceLocator getComponentMessages(String language)
          Gets the localized messages defined in this Silverpeas component.
 ResourceLocator getComponentSettings()
          Gets the settings of this Silverpeas component.
 Comment getContentById(String contentId)
          Gets the content handled by an instance of the component with the specified unique identifier.
 List<Comment> getLastComments(String resourceType, int count)
           
 List<CommentedPublicationInfo> getMostCommentedPublicationsInfo(String resourceType)
          Gets information about the most commented publications of the specified type.
 List<CommentedPublicationInfo> getMostCommentedPublicationsInfo(String resourceType, List<? extends WAPrimaryKey> pks)
          Gets information about the commented publications among the specified ones.
protected  OrganisationController getOrganisationController()
          Gets an organization controller.
 List<SocialInformationComment> getSocialInformationCommentsListByUserId(List<String> resourceTypes, String userId, Period period)
          Get the list of SocialInformationComment added by userId in a period
 List<SocialInformationComment> getSocialInformationCommentsListOfMyContacts(List<String> resourceTypes, List<String> myContactsIds, List<String> instanceIds, Period period)
          Gets the list of SocialInformationComment added by myContactsIds in a period
 void indexAllCommentsOnPublication(String resourceType, WAPrimaryKey pk)
          Indexes all the comments on the publication identified by the resource type and the specified identifier.
 void moveAndReindexComments(String resourceType, WAPrimaryKey fromPK, WAPrimaryKey toPK)
          Moves the comments on the specified publication to the another specified publication and reindexes them.
 void moveComments(String resourceType, WAPrimaryKey fromPK, WAPrimaryKey toPK)
          Moves the comments on the specified publication to the another specified publication.
 void unindexAllCommentsOnPublication(String resourceType, WAPrimaryKey pk)
          Removes the indexes on all the comments of the publication identified by the resource type and the specified identifier.
 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.
 
Methods inherited from class com.silverpeas.comment.service.CommentActionNotifier
notifyCommentAdding, notifyCommentRemoval
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultCommentService

protected DefaultCommentService()
Constructs a new DefaultCommentService instance.

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 void createComment(Comment cmt)
Creates the specified comment into the business layer. Once created, the comment is saved in this layer and can be uniquely identified by an identifier (a primary key). All callback interested by the adding of a comment will be invoked through the CallBackManager. The callback will recieve as invocation parameters respectively the identifier of the commented publication, the component instance name, and the new comment.

Specified by:
createComment in interface CommentService
Parameters:
cmt - the comment to save.

createAndIndexComment

public void createAndIndexComment(Comment cmt)
Creates and indexes the specified comment into the business layer. Once created, the comment is saved in this layer and can be uniquely identified by an identifier (a primary key). It is indexed so that it can be easily retrieved by the search engine of Silverpeas. All callback interested by the adding of a comment will be invoked through the CallBackManager. The callback will recieve as invocation parameters respectively the identifier of the commented publication, the component instance name, and the new comment.

Specified by:
createAndIndexComment in interface CommentService
Parameters:
cmt - the comment to save.

deleteComment

public void deleteComment(CommentPK pk)
Deletes the comment identified by the specified identifier. Any indexes on it are removed. All callback interested by the deletion of a comment will be invoked through the CallBackManager. The callback will recieve as invocation parameters respectively the identifier of the commented publication, the component instance name, and the deleted comment. If no such comment exists with the specified identifier, then a CommentRuntimeException is thrown.

Specified by:
deleteComment in interface CommentService
Parameters:
pk - the unique identifier of the comment to remove from the business layer (the primary key).

deleteAllCommentsOnPublication

public void deleteAllCommentsOnPublication(String resourceType,
                                           WAPrimaryKey pk)
Deletes all of the comments on the publication identified by the resource type and the specified identifier. Any indexes on it are removed. All callback interested by the deletion of a comment will be invoked through the CallBackManager. The callback will recieve as invocation parameters respectively the identifier of the commented publication, the component instance name, and the deleted comment. If no such publication exists with the specified identifier, then a CommentRuntimeException is thrown.

Specified by:
deleteAllCommentsOnPublication in interface CommentService
Parameters:
resourceType - the type of the commented publication.
pk - the identifier of the publication the comments are on.

deleteAllCommentsByComponentInstanceId

public void deleteAllCommentsByComponentInstanceId(String instanceId)
Deletes all of the comments by the component instance identifier. Any indexes on it are removed. All callback interested by the deletion of a comment will be invoked through the CallBackManager. The callback will recieve as invocation parameters respectively the identifier of the commented publication, the component instance name, and the deleted comment. If no such publication exists with the specified identifier, then a CommentRuntimeException is thrown.

Specified by:
deleteAllCommentsByComponentInstanceId in interface CommentService
Parameters:
instanceId -

deleteComment

public void deleteComment(Comment comment)
Deletes the specified comment. Any indexes on it are removed. If no such comment exists with the specified identifier, then a CommentRuntimeException is thrown. All callback interested by the deletion of a comment will be invoked through the CallBackManager. The callback will recieve as invocation parameters respectively the identifier of the commented publication, the component instance name, and the deleted comment.

Specified by:
deleteComment in interface CommentService
Parameters:
comment - the comment to remove.

moveComments

public void moveComments(String resourceType,
                         WAPrimaryKey fromPK,
                         WAPrimaryKey toPK)
Moves the comments on the specified publication to the another specified publication. The resulting operation is that the comments will be on the another publication and all the previous indexes on them are removed. If at least one of the publications doesn't exist with the specified identifier, then a CommentRuntimeException is thrown.

Specified by:
moveComments in interface CommentService
Parameters:
resourceType - the type of the commented publication.
fromPK - the identifier of the source publication.
toPK - the identifier of the destination publication.

moveAndReindexComments

public void moveAndReindexComments(String resourceType,
                                   WAPrimaryKey fromPK,
                                   WAPrimaryKey toPK)
Moves the comments on the specified publication to the another specified publication and reindexes them. The resulting operation is that the comments are on the another publication and they are reindexed (or simply indexed if not already) accordingly to the new publication. If at least one of the publications doesn't exist with the specified identifier, then a CommentRuntimeException is thrown.

Specified by:
moveAndReindexComments in interface CommentService
Parameters:
resourceType - the type of the commented publication.
fromPK - the identifier of the source publication.
toPK - the identifier of the destination publication.

updateComment

public void updateComment(Comment cmt)
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 interface CommentService
Parameters:
cmt - the updated comment.

updateAndIndexComment

public void updateAndIndexComment(Comment cmt)
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 interface CommentService
Parameters:
cmt - the comment to update and to index.

getComment

public Comment getComment(CommentPK pk)
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 interface CommentService
Parameters:
pk - the identifier of the comment in the business layer.
Returns:
the comment.

getAllCommentsOnPublication

public List<Comment> getAllCommentsOnPublication(String resourceType,
                                                 WAPrimaryKey pk)
Gets all of the comments on the publication identified by the resource type and the specified identifier. If no such publication exists with the specified identifier, then a CommentRuntimeException is thrown.

Specified by:
getAllCommentsOnPublication in interface CommentService
Parameters:
resourceType - the type of the commented publication.
pk - the identifier of the publication.
Returns:
a list of the comments on the given publication. The list is empty if the publication isn't commented.

getMostCommentedPublicationsInfo

public List<CommentedPublicationInfo> getMostCommentedPublicationsInfo(String resourceType,
                                                                       List<? extends WAPrimaryKey> pks)
Gets information about the commented publications among the specified ones. The publication information are returned ordered down to the lesser comment publication.

Specified by:
getMostCommentedPublicationsInfo in interface CommentService
Parameters:
resourceType - the type of the commented publication.
pks - a collection of primary keys refering the publications to get information and to order by comments count.
Returns:
an ordered list of information about the most commented publication. The list is sorted by their comments count in a descendent order.

getMostCommentedPublicationsInfo

public List<CommentedPublicationInfo> getMostCommentedPublicationsInfo(String resourceType)
Gets information about the most commented publications of the specified type. The publication information are returned ordered down to the lesser comment publication.

Specified by:
getMostCommentedPublicationsInfo in interface CommentService
Parameters:
resourceType - the type of the commented publication.
Returns:
an ordered list of information about the most commented publication. The list is sorted by their comments count in a descendent order.

getAllMostCommentedPublicationsInfo

public List<CommentedPublicationInfo> getAllMostCommentedPublicationsInfo()
Gets information about all the commented publications in Silverpeas. The publication information are returned ordered down to the lesser comment publication.

Specified by:
getAllMostCommentedPublicationsInfo in interface CommentService
Returns:
an ordered list of information about the most commented publication. The list is sorted by their comments count in a descendent order.

getCommentsCountOnPublication

public int getCommentsCountOnPublication(String resourceType,
                                         WAPrimaryKey pk)
Gets the count of comments on the publication identified by the resource type and the specified identifier.

Specified by:
getCommentsCountOnPublication in interface CommentService
Parameters:
resourceType - the type of the commented publication.
pk - the identifier of the publication.
Returns:
the number of comments on the publication.

indexAllCommentsOnPublication

public void indexAllCommentsOnPublication(String resourceType,
                                          WAPrimaryKey pk)
Indexes all the comments on the publication identified by the resource type and the specified identifier. If no such publication exists with the specified identifier, then a CommentRuntimeException is thrown.

Specified by:
indexAllCommentsOnPublication in interface CommentService
Parameters:
resourceType - the type of the commented publication.
pk - the identifier of the publication.

unindexAllCommentsOnPublication

public void unindexAllCommentsOnPublication(String resourceType,
                                            WAPrimaryKey pk)
Removes the indexes on all the comments of the publication identified by the resource type and the specified identifier. If no such publication exists with the specified identifier, then a CommentRuntimeException is thrown.

Specified by:
unindexAllCommentsOnPublication in interface CommentService
Parameters:
resourceType - the type of the commented publication.
pk - the identifier of the publication.

getOrganisationController

protected OrganisationController getOrganisationController()
Gets an organization controller.

Returns:
an OrganizationController instance.

getContentById

public Comment getContentById(String contentId)
Description copied from interface: SilverpeasComponentService
Gets the content handled by an instance of the component with the specified unique identifier.

Specified by:
getContentById in interface SilverpeasComponentService<Comment>
Parameters:
contentId - the unique identifier of the content to get.
Returns:
a Silverpeas content.

getComponentSettings

public ResourceLocator getComponentSettings()
Description copied from interface: SilverpeasComponentService
Gets the settings of this Silverpeas component.

Specified by:
getComponentSettings in interface SilverpeasComponentService<Comment>
Returns:
a ResourceLocator instance giving access the settings.

getComponentMessages

public ResourceLocator getComponentMessages(String language)
Description copied from interface: SilverpeasComponentService
Gets the localized messages defined in this Silverpeas component.

Specified by:
getComponentMessages in interface SilverpeasComponentService<Comment>
Parameters:
language - the language in which the messages has to be localized. If empty or null, then the bundle with default messages is returned.
Returns:
a ResourceLocator instance giving access the localized messages.

getLastComments

public List<Comment> getLastComments(String resourceType,
                                     int count)
Specified by:
getLastComments in interface CommentService

getSocialInformationCommentsListByUserId

public List<SocialInformationComment> getSocialInformationCommentsListByUserId(List<String> resourceTypes,
                                                                               String userId,
                                                                               Period period)
Get the list of SocialInformationComment added by userId in a period

Specified by:
getSocialInformationCommentsListByUserId in interface CommentService
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)
Gets the list of SocialInformationComment added by myContactsIds in a period

Specified by:
getSocialInformationCommentsListOfMyContacts in interface CommentService
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


Copyright © 2016 Silverpeas. All Rights Reserved.