Class DefaultForumService

  • All Implemented Interfaces:
    ForumService

    @Service
    public class DefaultForumService
    extends Object
    implements ForumService
    Forums service layer which manage forums application
    • Constructor Detail

      • DefaultForumService

        public DefaultForumService()
    • Method Detail

      • getForumRootList

        public Collection<Forum> getForumRootList​(String instanceId)
        Gets all the forums of the specified component instance that don't have a parent forum.
        Specified by:
        getForumRootList in interface ForumService
        Parameters:
        instanceId - the unique identifier of a component instance.
        Returns:
        a collection of forums.
      • getForumCreatorId

        public String getForumCreatorId​(int forumId)
      • getForumDetail

        public ForumDetail getForumDetail​(ForumPK forumPK)
        Specified by:
        getForumDetail in interface ForumService
        Parameters:
        forumPK - forum primary key
        Returns:
        a ForumDetail from the forum primary key identifier
      • lockForum

        public void lockForum​(ForumPK forumPK,
                              int level)
        Locks recursively in writing the tree of a given forum.
        Specified by:
        lockForum in interface ForumService
        Parameters:
        forumPK - the unique identifier of the forum.
        level - the locking level.
      • unlockForum

        public int unlockForum​(ForumPK forumPK,
                               int level)
        Deverrouille recursivement un forum en ecriture a partir de sa primary key
        Specified by:
        unlockForum in interface ForumService
        Parameters:
        forumPK - la primary key du forum
        level - le niveau de verrouillage
        Returns:
        int le code d'erreur
      • deleteForum

        public void deleteForum​(ForumPK forumPK)
        Supprime un forum et tous ses sous-forums a partir de sa primary key
        Specified by:
        deleteForum in interface ForumService
        Parameters:
        forumPK - la primary key du forum
      • createForum

        public int createForum​(ForumPK forumPK,
                               String forumName,
                               String forumDescription,
                               String forumCreator,
                               int forumParent,
                               String categoryId,
                               String keywords)
        Creates a new forum.
        Specified by:
        createForum in interface ForumService
        Parameters:
        forumPK - the global identifier of the forum to create
        forumName - the name of the forum
        forumDescription - a short description of the forum.
        forumCreator - the unique identifier of the creator.
        forumParent - the unique identifier of a parent forum (if any).
        categoryId - the unique identifier of the category for which the forum will be created
        keywords - keywords
        Returns:
        the unique identifier of the forum.
      • updateForum

        public void updateForum​(ForumPK forumPK,
                                String forumName,
                                String forumDescription,
                                int forumParent,
                                String categoryId,
                                String keywords)
        Met a jour les informations sur un forum dans la datasource
        Specified by:
        updateForum in interface ForumService
        Parameters:
        forumPK - la primary key du forum
        forumName - nom du forum
        forumDescription - description du forum
        forumParent - l'id du forum parent
        categoryId - l'id de la catégorie
        keywords - the keywords associated to this forum.
      • getLastMessage

        public Message getLastMessage​(ForumPK forumPK,
                                      String status)
        Gets the last message posted into the given forum.
        Specified by:
        getLastMessage in interface ForumService
        Parameters:
        forumPK - the unique identifier of the forum.
        status - the status of the message to get.
        Returns:
        the last message in the forum with the specified status.
      • isNewMessageByForum

        public boolean isNewMessageByForum​(String userId,
                                           ForumPK forumPK,
                                           String status)
        Is there any non read messages with the given status in the specified forum?
        Specified by:
        isNewMessageByForum in interface ForumService
        Parameters:
        userId - the unique identifier of a user
        forumPK - the unique identifier of the forum
        status - the status of the non read messages (validated, waiting, ...)
        Returns:
        true if there is at least one message with the given status non read by the user. False otherwise.
      • setLastVisit

        public void setLastVisit​(String userId,
                                 int messageId)
        enregistre la date de la dernière visite d'un utilisateur sur un forum
        Specified by:
        setLastVisit in interface ForumService
        Parameters:
        messageId - l'id du message
        userId - l'id de l'utilisateur
      • createMessage

        public int createMessage​(MessagePK messagePK,
                                 String title,
                                 String authorId,
                                 Date creationDate,
                                 int forumId,
                                 int parentId,
                                 String content,
                                 String keywords,
                                 String status)
        Create new forum message
        Specified by:
        createMessage in interface ForumService
        Parameters:
        messagePK - message primary key identifier
        title - message title
        authorId - message author identifier
        creationDate - creation date
        forumId - forum identifier
        parentId - parent message identifier
        content - message content
        keywords - the message keywords
        status - the message status
        Returns:
        new message identifier
      • deleteMessage

        public void deleteMessage​(MessagePK messagePK)
        Supprime un message et tous ses sous-messages a partir de sa primary key
        Specified by:
        deleteMessage in interface ForumService
        Parameters:
        messagePK - la primary key du message
        Since:
        04 Octobre 2000
      • subscribeMessage

        public void subscribeMessage​(MessagePK messagePK,
                                     String userId)
        Subscribe the given user to the given forum message.
        Specified by:
        subscribeMessage in interface ForumService
        Parameters:
        messagePK - the unique identifier of the message.
        userId - the unique identifier of the user to subscribe.
      • unsubscribeMessage

        public void unsubscribeMessage​(MessagePK messagePK,
                                       String userId)
        Unsubscribe the given user to the given forum message.
        Specified by:
        unsubscribeMessage in interface ForumService
        Parameters:
        messagePK - the unique identifier of the message.
        userId - the unique identifier of the user to unsubscribe.
      • subscribeForum

        public void subscribeForum​(ForumPK forumPK,
                                   String userId)
        Subscribe the given user to the given forum.
        Specified by:
        subscribeForum in interface ForumService
        Parameters:
        forumPK - the unique identifier of the forum.
        userId - the unique identifier of the user to subscribe.
      • unsubscribeForum

        public void unsubscribeForum​(ForumPK forumPK,
                                     String userId)
        Unsubscribe the given user to the given forum.
        Specified by:
        unsubscribeForum in interface ForumService
        Parameters:
        forumPK - the unique identifier of the forum.
        userId - the unique identifier of the user to unsubscribe.
      • listAllSubscribers

        public org.silverpeas.core.subscription.util.SubscriptionSubscriberList listAllSubscribers​(MessagePK messagePK)
        Gets the list of subscribers related to the given forum message.
        Specified by:
        listAllSubscribers in interface ForumService
        Parameters:
        messagePK - the unique identifier of the message.
        Returns:
        a list of subscribers.
      • listAllSubscribers

        public org.silverpeas.core.subscription.util.SubscriptionSubscriberList listAllSubscribers​(ForumPK forumPK)
        Gets the list of subscribers related to the given forum.
        Specified by:
        listAllSubscribers in interface ForumService
        Parameters:
        forumPK - the unique identifier of the forum.
        Returns:
        a list of subscribers.
      • listAllSubscribers

        public org.silverpeas.core.subscription.util.SubscriptionSubscriberList listAllSubscribers​(String instanceId)
        Gets the list of subscribers to the given component instance. This kind of subscribers come from WEB-Service subscriptions (/services/subscribe/{instanceId})
        Specified by:
        listAllSubscribers in interface ForumService
        Parameters:
        instanceId - the unique identifier of the component instance.
        Returns:
        a list of subscribers.
      • isSubscriber

        public boolean isSubscriber​(MessagePK messagePK,
                                    String userId)
        Indicates if the given user has subscribed to the given forum message.
        Specified by:
        isSubscriber in interface ForumService
        Parameters:
        messagePK - the unique identifier of a message.
        userId - the unique identifier of the user.
        Returns:
        true if the given user has subscribed to the specified message. False otherwise.
      • isSubscriberByInheritance

        public boolean isSubscriberByInheritance​(MessagePK messagePK,
                                                 String userId)
        Indicates if the given user is subscribed by inheritance to the given forum message.
        Specified by:
        isSubscriberByInheritance in interface ForumService
        Parameters:
        messagePK - the unique identifier of a message.
        userId - the unique identifier of the user.
        Returns:
        true if the given user has subscribed to the specified message. False otherwise.
      • isSubscriber

        public boolean isSubscriber​(ForumPK forumPK,
                                    String userId)
        Indicates if the given user has subscribed to the given forum.
        Specified by:
        isSubscriber in interface ForumService
        Parameters:
        forumPK - the unique identifier of the forum.
        userId - the unique identifier of the user.
        Returns:
        true if the given user has subscribed to the specified forum. False otherwise.
      • isSubscriberByInheritance

        public boolean isSubscriberByInheritance​(ForumPK forumPK,
                                                 String userId)
        Indicates if the given user is subscribed by inheritance to the given forum.
        Specified by:
        isSubscriberByInheritance in interface ForumService
        Parameters:
        forumPK - the unique identifier of the forum.
        userId - the unique identifier of the user.
        Returns:
        true if the given user has subscribed to the specified forum. False otherwise.
      • isSubscriber

        public boolean isSubscriber​(String instanceId,
                                    String userId)
        Indicates if the given user has subscribed to the given component instance.
        Specified by:
        isSubscriber in interface ForumService
        Parameters:
        instanceId - the unique identifier of the component instance.
        userId - the unique identifier of the user.
        Returns:
        true if the given user has subscribed to the specified component instance. False otherwise.
      • openConnection

        protected Connection openConnection()
        Open connection
        Returns:
        the connection
      • createCategory

        public void createCategory​(org.silverpeas.core.node.model.NodeDetail category)
        Specified by:
        createCategory in interface ForumService
      • updateCategory

        public void updateCategory​(org.silverpeas.core.node.model.NodeDetail category)
        Specified by:
        updateCategory in interface ForumService
      • getCategory

        public org.silverpeas.core.node.model.NodeDetail getCategory​(org.silverpeas.core.node.model.NodePK pk)
        Specified by:
        getCategory in interface ForumService
      • getWysiwygContent

        protected String getWysiwygContent​(String componentId,
                                           String messageId)
      • getSubscribeService

        protected org.silverpeas.core.subscription.SubscriptionService getSubscribeService()