Class NewsServiceImpl

  • All Implemented Interfaces:
    NewsService

    public class NewsServiceImpl
    extends Object
    implements NewsService
    Service managing News and storing them in ECMS
    • Field Detail

      • spaceService

        public org.exoplatform.social.core.space.spi.SpaceService spaceService
    • Constructor Detail

      • NewsServiceImpl

        public NewsServiceImpl​(org.exoplatform.social.core.space.spi.SpaceService spaceService,
                               org.exoplatform.social.core.manager.ActivityManager activityManager,
                               org.exoplatform.social.core.manager.IdentityManager identityManager,
                               org.exoplatform.upload.UploadService uploadService,
                               NewsESSearchConnector newsESSearchConnector,
                               org.exoplatform.commons.search.index.IndexingService indexingService,
                               NewsStorage newsStorage,
                               org.exoplatform.portal.config.UserACL userACL,
                               NewsTargetingService newsTargetingService)
    • Method Detail

      • createNews

        public News createNews​(News news,
                               org.exoplatform.services.security.Identity currentIdentity)
                        throws Exception
        Create and publish a News A news is composed of an activity and a CMS node containing the data. If the given News has an id and that a draft already exists with this id, the draft is updated and published.
        Specified by:
        createNews in interface NewsService
        Parameters:
        news - The news to create
        Throws:
        Exception - when error
      • canCreateNews

        public boolean canCreateNews​(org.exoplatform.social.core.space.model.Space space,
                                     org.exoplatform.services.security.Identity currentIdentity)
                              throws Exception
        Specified by:
        canCreateNews in interface NewsService
        Returns:
        Throws:
        Exception
      • updateNews

        public News updateNews​(News news,
                               String updater,
                               Boolean post,
                               boolean publish)
                        throws Exception
        Update a news If the uploadId of the news is null, the illustration is not updated. If the uploadId of the news is empty, the illustration is removed (if any).
        Specified by:
        updateNews in interface NewsService
        updater - user attempting to update news
        Returns:
        Throws:
        Exception
      • deleteNews

        public void deleteNews​(String newsId,
                               org.exoplatform.services.security.Identity currentIdentity,
                               boolean isDraft)
                        throws Exception
        Delete news
        Specified by:
        deleteNews in interface NewsService
        Parameters:
        newsId - the news id to delete
        currentIdentity - user attempting to delete news
        Throws:
        Exception - when error
      • getNewsById

        public News getNewsById​(String newsId,
                                org.exoplatform.services.security.Identity currentIdentity,
                                boolean editMode)
                         throws IllegalAccessException
        Retrives a news identified by its technical identifier
        Specified by:
        getNewsById in interface NewsService
        Parameters:
        newsId - News identifier
        currentIdentity - user attempting to access news
        editMode - access mode to news: whether to edit news to to view it.
        Returns:
        News if found else null
        Throws:
        IllegalAccessException - when user doesn't have access to News
      • getNewsById

        public News getNewsById​(String newsId,
                                boolean editMode)
                         throws Exception
        Retrives a news identified by its technical identifier
        Specified by:
        getNewsById in interface NewsService
        Parameters:
        newsId - News identifier
        editMode - access mode to news: whether to edit news to to view it.
        Returns:
        News if found else null
        Throws:
        Exception - when user doesn't have access to News
      • getNewsByTargetName

        public List<News> getNewsByTargetName​(NewsFilter newsFilter,
                                              String targetName,
                                              org.exoplatform.services.security.Identity currentIdentity)
                                       throws Exception
        Get list of news by a given target name
        Specified by:
        getNewsByTargetName in interface NewsService
        currentIdentity - user attempting to access news
        Returns:
        News list by target name. throws Exception when error
        Throws:
        Exception
      • getNewsByActivityId

        public News getNewsByActivityId​(String activityId,
                                        org.exoplatform.services.security.Identity currentIdentity)
                                 throws IllegalAccessException,
                                        org.exoplatform.commons.exception.ObjectNotFoundException
        Retrives a news identified by originating Activity identifier or a shared activity identifier
        Specified by:
        getNewsByActivityId in interface NewsService
        Parameters:
        activityId - ExoSocialActivity identifier
        currentIdentity - user attempting to access news
        Returns:
        News if found else null
        Throws:
        IllegalAccessException - when user doesn't have access to News or ExoSocialActivity
        org.exoplatform.commons.exception.ObjectNotFoundException - when a News wasn't found for this activity identifier
      • postNews

        public News postNews​(News news,
                             String poster)
                      throws Exception
        Create and publish a News A news is composed of an activity and a CMS node containing the data. If the given News has an id and that a draft already exists with this id, the draft is updated and published.
        Specified by:
        postNews in interface NewsService
        Parameters:
        news - The news to post
        Throws:
        Exception - when error
      • markAsRead

        public void markAsRead​(News news,
                               String userId)
                        throws Exception
        Increment the number of views for a news
        Specified by:
        markAsRead in interface NewsService
        Parameters:
        news - The news to be updated
        userId - The current user id
        Throws:
        Exception - when error
      • shareNews

        public void shareNews​(News news,
                              org.exoplatform.social.core.space.model.Space space,
                              org.exoplatform.social.core.identity.model.Identity userIdentity,
                              String sharedActivityId)
                       throws Exception
        Shares a news into a dedicated space
        Specified by:
        shareNews in interface NewsService
        Parameters:
        news - News to share
        space - Space to share with, the news
        userIdentity - Identity of user making the modification
        sharedActivityId - newly generated activity identifier
        Throws:
        IllegalAccessException - when user doesn't have access to News
        org.exoplatform.commons.exception.ObjectNotFoundException - when News is not found
        Exception
      • postNewsActivity

        public void postNewsActivity​(News news)
                              throws Exception
        Post the news activity in the given space
        Parameters:
        news - The news to post as an activity
        Throws:
        Exception - when error
      • archiveNews

        public void archiveNews​(String newsId,
                                String currentUserName)
                         throws Exception
        Archive a news
        Specified by:
        archiveNews in interface NewsService
        Parameters:
        newsId - The id of the news to be archived
        currentUserName - Identity of user archiving the news
        Throws:
        Exception - when error
      • canViewNews

        public boolean canViewNews​(News news,
                                   String username)
        Specified by:
        canViewNews in interface NewsService
        Parameters:
        news - News to check
        username - authenticated username
        Returns:
        true if user has access to news, else false
      • unarchiveNews

        public void unarchiveNews​(String newsId,
                                  String currentUserName)
                           throws Exception
        Unarchive a news
        Specified by:
        unarchiveNews in interface NewsService
        Parameters:
        newsId - The id of the news to be unarchived
        currentUserName - Identity of user unarchiving the news
        Throws:
        Exception - when error
      • canScheduleNews

        public boolean canScheduleNews​(org.exoplatform.social.core.space.model.Space space,
                                       org.exoplatform.services.security.Identity currentIdentity)
        Specified by:
        canScheduleNews in interface NewsService
        Returns:
      • canArchiveNews

        public boolean canArchiveNews​(org.exoplatform.services.security.Identity currentIdentity,
                                      String newsAuthor)
        Specified by:
        canArchiveNews in interface NewsService
        Returns: