Class NewsServiceImpl

java.lang.Object
org.exoplatform.news.service.impl.NewsServiceImpl
All Implemented Interfaces:
NewsService

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

    Fields
    Modifier and Type
    Field
    Description
    org.exoplatform.social.core.space.spi.SpaceService
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    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, org.exoplatform.social.metadata.MetadataService metadataService)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    archiveNews(String newsId, String currentUserName)
    Archive a news
    boolean
    canArchiveNews(org.exoplatform.services.security.Identity currentIdentity, String newsAuthor)
    checks if the user can archive the news
    boolean
    canCreateNews(org.exoplatform.social.core.space.model.Space space, org.exoplatform.services.security.Identity currentIdentity)
    Checks if the user can create a News
    boolean
    canScheduleNews(org.exoplatform.social.core.space.model.Space space, org.exoplatform.services.security.Identity currentIdentity)
    Checks if the user can schedule publishinga News
    boolean
    canViewNews(News news, String username)
    Checks if the user can view the News
    createNews(News news, org.exoplatform.services.security.Identity currentIdentity)
    Create and publish a News A news is composed of an activity and a CMS node containing the data.
    void
    deleteNews(String newsId, org.exoplatform.services.security.Identity currentIdentity, boolean isDraft)
    Delete news
    getNews(NewsFilter newsFilter, org.exoplatform.services.security.Identity currentIdentity)
    Get all news
    getNewsByActivityId(String activityId, org.exoplatform.services.security.Identity currentIdentity)
    Retrieves a news item identified by originating Activity identifier or a shared activity identifier
    getNewsById(String newsId, boolean editMode)
    Retrives a news identified by its technical identifier
    getNewsById(String newsId, org.exoplatform.services.security.Identity currentIdentity, boolean editMode)
    Retrives a news identified by its technical identifier
    getNewsByTargetName(NewsFilter newsFilter, String targetName, org.exoplatform.services.security.Identity currentIdentity)
    Get list of news by a given target name
    int
    get the count of News after applying a filter
    void
    markAsRead(News news, String userId)
    Increment the number of views for a news
    postNews(News news, String poster)
    Create and publish a News A news is composed of an activity and a CMS node containing the data.
    void
    publishNews(News publishedNews, String publisher)
    Publish a news
    scheduleNews(News news, org.exoplatform.services.security.Identity currentIdentity)
    Schedule publishing a News
    search(org.exoplatform.social.core.identity.model.Identity currentIdentity, NewsFilter filter)
    Search news by term
    searchNews(NewsFilter filter, String lang)
    Search news with the given text
    void
    shareNews(News news, org.exoplatform.social.core.space.model.Space space, org.exoplatform.social.core.identity.model.Identity userIdentity, String sharedActivityId)
    Shares a news item into a dedicated space
    void
    unarchiveNews(String newsId, String currentUserName)
    Unarchive a news
    void
    unpublishNews(String newsId, String publisher)
    Unpublish a News
    unScheduleNews(News news, org.exoplatform.services.security.Identity currentIdentity)
    Un-schedule publishing a News
    updateNews(News news, String updater, Boolean post, boolean publish)
    Update a news If the uploadId of the news is null, the illustration is not updated.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • spaceService

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

    • 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, org.exoplatform.social.metadata.MetadataService metadataService)
  • Method Details

    • 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
      Returns:
      created News object
      Throws:
      Exception - when error
    • canCreateNews

      public boolean canCreateNews(org.exoplatform.social.core.space.model.Space space, org.exoplatform.services.security.Identity currentIdentity) throws Exception
      Checks if the user can create a News
      Specified by:
      canCreateNews in interface NewsService
      Returns:
      boolean true if the user can create the news
      Throws:
      Exception - if an error occurred
    • 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:
      updated News
      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
      isDraft - if the News is still draft
      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
    • getNews

      public List<News> getNews(NewsFilter newsFilter, org.exoplatform.services.security.Identity currentIdentity) throws Exception
      Get all news
      Specified by:
      getNews in interface NewsService
      Returns:
      all news
      Throws:
      Exception - when error
    • 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
    • getNewsCount

      public int getNewsCount(NewsFilter newsFilter) throws Exception
      get the count of News after applying a filter
      Specified by:
      getNewsCount in interface NewsService
      Returns:
      int the number of News
      Throws:
      Exception
    • searchNews

      public List<News> searchNews(NewsFilter filter, String lang) throws Exception
      Search news with the given text
      Specified by:
      searchNews in interface NewsService
      Parameters:
      filter - news filter
      lang - language
      Returns:
      List of News returned by the search
      Throws:
      Exception - when error
    • getNewsByActivityId

      public News getNewsByActivityId(String activityId, org.exoplatform.services.security.Identity currentIdentity) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException
      Retrieves a news item 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
    • scheduleNews

      public News scheduleNews(News news, org.exoplatform.services.security.Identity currentIdentity) throws Exception
      Schedule publishing a News
      Specified by:
      scheduleNews in interface NewsService
      Returns:
      the published news
      Throws:
      Exception - when error occurs
    • unScheduleNews

      public News unScheduleNews(News news, org.exoplatform.services.security.Identity currentIdentity) throws Exception
      Un-schedule publishing a News
      Specified by:
      unScheduleNews in interface NewsService
      Returns:
      unscheduled News
      Throws:
      Exception - when error occurs
    • search

      public List<NewsESSearchResult> search(org.exoplatform.social.core.identity.model.Identity currentIdentity, NewsFilter filter)
      Search news by term
      Specified by:
      search in interface NewsService
      Returns:
      News Search Result
    • 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
      poster - the Poster of the News
      Returns:
      The posted 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:
      news - The news to be updated
      userId - The current user id
      Throws:
      Exception - when error
    • publishNews

      public void publishNews(News publishedNews, String publisher) throws Exception
      Publish a news
      Specified by:
      publishNews in interface NewsService
      Parameters:
      publishedNews - to be published
      publisher - of the News
      Throws:
      Exception - when error
    • unpublishNews

      public void unpublishNews(String newsId, String publisher) throws Exception
      Unpublish a News
      Specified by:
      unpublishNews in interface NewsService
      Parameters:
      newsId - the ID of the News
      publisher - the publisher of the News
      Throws:
      Exception - when an error occurs
    • 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 item 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:
      Exception - when user doesn't have access to News
    • 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)
      Checks if the user can view the News
      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)
      Checks if the user can schedule publishinga News
      Specified by:
      canScheduleNews in interface NewsService
      Returns:
      boolean : true if the user can schedule publishing a News
    • canArchiveNews

      public boolean canArchiveNews(org.exoplatform.services.security.Identity currentIdentity, String newsAuthor)
      checks if the user can archive the news
      Specified by:
      canArchiveNews in interface NewsService
      Returns:
      boolean : true if user can archive the news