Class NewsServiceImpl

  • All Implemented Interfaces:
    NewsService

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

      • NewsServiceImpl

        public NewsServiceImpl​(org.exoplatform.services.jcr.RepositoryService repositoryService,
                               org.exoplatform.services.jcr.ext.app.SessionProviderService sessionProviderService,
                               org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreator nodeHierarchyCreator,
                               org.exoplatform.services.jcr.ext.distribution.DataDistributionManager dataDistributionManager,
                               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,
                               org.exoplatform.social.common.service.HTMLUploadImageProcessor imageProcessor,
                               org.exoplatform.services.cms.link.LinkManager linkManager,
                               org.exoplatform.services.ecm.publication.PublicationService publicationService,
                               org.exoplatform.services.wcm.extensions.publication.PublicationManager publicationManager,
                               org.exoplatform.services.wcm.publication.WCMPublicationService wCMPublicationService,
                               NewsSearchConnector newsSearchConnector,
                               NewsAttachmentsService newsAttachmentsService,
                               org.exoplatform.commons.search.index.IndexingService indexingService,
                               NewsESSearchConnector newsESSearchConnector,
                               org.exoplatform.portal.config.UserACL userACL)
    • Method Detail

      • createNews

        public News createNews​(News news)
                        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
      • getNewsById

        public News getNewsById​(String newsId,
                                boolean editMode)
        Description copied from interface: NewsService
        Retrives a news identified by its technical identifier
        Specified by:
        getNewsById in interface NewsService
        Parameters:
        newsId - News identifier
        Returns:
        News if found else null
      • updateNews

        public News updateNews​(News news)
                        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
        Parameters:
        news - The new news
        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:
        userId - The current user id
        news - The news to be updated
        Throws:
        Exception - when error
      • pinNews

        public void pinNews​(String newsId)
                     throws Exception
        Pin a news
        Specified by:
        pinNews in interface NewsService
        Parameters:
        newsId - The id of the news to be pinned
        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 IllegalAccessException,
                              org.exoplatform.commons.exception.ObjectNotFoundException
        Description copied from interface: NewsService
        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
      • deleteNews

        public void deleteNews​(String newsId,
                               boolean isDraft)
                        throws Exception
        Delete news
        Specified by:
        deleteNews in interface NewsService
        Parameters:
        newsId - the news id to delete
        isDraft -
        Throws:
        Exception - when error
      • search

        public List<NewsESSearchResult> search​(org.exoplatform.social.core.identity.model.Identity currentUser,
                                               String term,
                                               int offset,
                                               int limit)
        Search news by term
        Specified by:
        search in interface NewsService
        Parameters:
        term -
        offset -
        limit -
        Returns:
        News Search Result
      • canEditNews

        public boolean canEditNews​(String posterId,
                                   String spaceId)
        Return a boolean that indicates if the current user can edit the news or not
        Specified by:
        canEditNews in interface NewsService
        Parameters:
        posterId - the poster id of the news
        spaceId - the space id of the news
        Returns:
        if the news can be edited
      • getNewsById

        public News getNewsById​(String newsId,
                                String authenticatedUser,
                                boolean editMode)
                         throws IllegalAccessException
        Description copied from interface: NewsService
        Retrives a news identified by its technical identifier
        Specified by:
        getNewsById in interface NewsService
        Parameters:
        newsId - News identifier
        authenticatedUser - 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
      • getNewsByActivityId

        public News getNewsByActivityId​(String activityId,
                                        String authenticatedUser)
                                 throws IllegalAccessException,
                                        org.exoplatform.commons.exception.ObjectNotFoundException
        Description copied from interface: NewsService
        Retrives a news identified by originating Activity identifier or a shared activity identifier
        Specified by:
        getNewsByActivityId in interface NewsService
        Parameters:
        activityId - ExoSocialActivity identifier
        authenticatedUser - 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
      • 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
      • canEditNews

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

        public boolean canPinNews()
        Return a boolean that indicates if the current user can pin the news or not
        Specified by:
        canPinNews in interface NewsService
        Returns:
        if the news can be pinned
      • updateNewsActivities

        protected void updateNewsActivities​(org.exoplatform.social.core.activity.model.ExoSocialActivity activity,
                                            News news,
                                            javax.jcr.Session session)
                                     throws Exception
        Throws:
        Exception
      • substituteUsernames

        protected String substituteUsernames​(String portalOwner,
                                             String message)
      • getNewsNodeById

        public javax.jcr.Node getNewsNodeById​(String newsId,
                                              org.exoplatform.services.jcr.ext.common.SessionProvider sessionProvider)
                                       throws javax.jcr.RepositoryException,
                                              javax.jcr.ItemNotFoundException
        Throws:
        javax.jcr.RepositoryException
        javax.jcr.ItemNotFoundException
      • getSession

        public javax.jcr.Session getSession​(org.exoplatform.services.jcr.ext.common.SessionProvider sessionProvider)
                                     throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException