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.SpaceServicespaceService
-
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)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidarchiveNews(String newsId, String currentUserName)Archive a newsbooleancanArchiveNews(org.exoplatform.services.security.Identity currentIdentity, String newsAuthor)booleancanCreateNews(org.exoplatform.social.core.space.model.Space space, org.exoplatform.services.security.Identity currentIdentity)booleancanScheduleNews(org.exoplatform.social.core.space.model.Space space, org.exoplatform.services.security.Identity currentIdentity)booleancanViewNews(News news, String username)NewscreateNews(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.voiddeleteNews(String newsId, org.exoplatform.services.security.Identity currentIdentity, boolean isDraft)Delete newsList<News>getNews(NewsFilter newsFilter, org.exoplatform.services.security.Identity currentIdentity)Get all newsNewsgetNewsByActivityId(String activityId, org.exoplatform.services.security.Identity currentIdentity)Retrives a news identified by originating Activity identifier or a shared activity identifierNewsgetNewsById(String newsId, boolean editMode)Retrives a news identified by its technical identifierNewsgetNewsById(String newsId, org.exoplatform.services.security.Identity currentIdentity, boolean editMode)Retrives a news identified by its technical identifierList<News>getNewsByTargetName(NewsFilter newsFilter, String targetName, org.exoplatform.services.security.Identity currentIdentity)Get list of news by a given target nameintgetNewsCount(NewsFilter newsFilter)voidmarkAsRead(News news, String userId)Increment the number of views for a newsNewspostNews(News news, String poster)Create and publish a News A news is composed of an activity and a CMS node containing the data.voidpostNewsActivity(News news)Post the news activity in the given spacevoidpublishNews(News publishedNews, String publisher)Publish a newsNewsscheduleNews(News news, org.exoplatform.services.security.Identity currentIdentity)List<NewsESSearchResult>search(org.exoplatform.social.core.identity.model.Identity currentIdentity, NewsFilter filter)Search news by termList<News>searchNews(NewsFilter filter, String lang)Search news with the given textvoidsendNotification(String currentUserId, News news, NotificationConstants.NOTIFICATION_CONTEXT context)voidshareNews(News news, org.exoplatform.social.core.space.model.Space space, org.exoplatform.social.core.identity.model.Identity userIdentity, String sharedActivityId)Shares a news into a dedicated spacevoidunarchiveNews(String newsId, String currentUserName)Unarchive a newsvoidunpublishNews(String newsId, String publisher)NewsunScheduleNews(News news, org.exoplatform.services.security.Identity currentIdentity)NewsupdateNews(News news, String updater, Boolean post, boolean publish)Update a news If the uploadId of the news is null, the illustration is not updated.
-
-
-
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:
createNewsin interfaceNewsService- 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:
canCreateNewsin interfaceNewsService- 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:
updateNewsin interfaceNewsServiceupdater- 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:
deleteNewsin interfaceNewsService- Parameters:
newsId- the news id to deletecurrentIdentity- 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:
getNewsByIdin interfaceNewsService- Parameters:
newsId-NewsidentifiercurrentIdentity- user attempting to access newseditMode- access mode to news: whether to edit news to to view it.- Returns:
Newsif found else null- Throws:
IllegalAccessException- when user doesn't have access toNews
-
getNewsById
public News getNewsById(String newsId, boolean editMode) throws Exception
Retrives a news identified by its technical identifier- Specified by:
getNewsByIdin interfaceNewsService- Parameters:
newsId-NewsidentifiereditMode- access mode to news: whether to edit news to to view it.- Returns:
Newsif found else null- Throws:
Exception- when user doesn't have access toNews
-
getNews
public List<News> getNews(NewsFilter newsFilter, org.exoplatform.services.security.Identity currentIdentity) throws Exception
Get all news- Specified by:
getNewsin interfaceNewsService- 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:
getNewsByTargetNamein interfaceNewsServicecurrentIdentity- user attempting to access news- Returns:
Newslist by target name. throws Exception when error- Throws:
Exception
-
getNewsCount
public int getNewsCount(NewsFilter newsFilter) throws Exception
- Specified by:
getNewsCountin interfaceNewsService- Returns:
- Throws:
Exception
-
searchNews
public List<News> searchNews(NewsFilter filter, String lang) throws Exception
Search news with the given text- Specified by:
searchNewsin interfaceNewsService- Parameters:
filter- news filterlang- language- Throws:
Exception- when error
-
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:
getNewsByActivityIdin interfaceNewsService- Parameters:
activityId-ExoSocialActivityidentifiercurrentIdentity- user attempting to access news- Returns:
Newsif found else null- Throws:
IllegalAccessException- when user doesn't have access toNewsorExoSocialActivityorg.exoplatform.commons.exception.ObjectNotFoundException- when aNewswasn't found for this activity identifier
-
scheduleNews
public News scheduleNews(News news, org.exoplatform.services.security.Identity currentIdentity) throws Exception
- Specified by:
scheduleNewsin interfaceNewsService- Returns:
- Throws:
Exception
-
unScheduleNews
public News unScheduleNews(News news, org.exoplatform.services.security.Identity currentIdentity) throws Exception
- Specified by:
unScheduleNewsin interfaceNewsService- Returns:
- Throws:
Exception
-
search
public List<NewsESSearchResult> search(org.exoplatform.social.core.identity.model.Identity currentIdentity, NewsFilter filter)
Search news by term- Specified by:
searchin interfaceNewsService- 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:
postNewsin interfaceNewsService- 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:
markAsReadin interfaceNewsService- Parameters:
news- The news to be updateduserId- The current user id- Throws:
Exception- when error
-
publishNews
public void publishNews(News publishedNews, String publisher) throws Exception
Publish a news- Specified by:
publishNewsin interfaceNewsService- Parameters:
publishedNews- to be published- Throws:
Exception- when error
-
unpublishNews
public void unpublishNews(String newsId, String publisher) throws Exception
- Specified by:
unpublishNewsin interfaceNewsService- Throws:
Exception
-
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:
shareNewsin interfaceNewsService- Parameters:
news-Newsto sharespace-Spaceto share with, the newsuserIdentity-Identityof user making the modificationsharedActivityId- newly generated activity identifier- Throws:
IllegalAccessException- when user doesn't have access toNewsorg.exoplatform.commons.exception.ObjectNotFoundException- whenNewsis not foundException
-
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:
archiveNewsin interfaceNewsService- Parameters:
newsId- The id of the news to be archivedcurrentUserName-Identityof user archiving the news- Throws:
Exception- when error
-
canViewNews
public boolean canViewNews(News news, String username)
- Specified by:
canViewNewsin interfaceNewsService- Parameters:
news-Newsto checkusername- 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:
unarchiveNewsin interfaceNewsService- Parameters:
newsId- The id of the news to be unarchivedcurrentUserName-Identityof 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:
canScheduleNewsin interfaceNewsService- Returns:
-
canArchiveNews
public boolean canArchiveNews(org.exoplatform.services.security.Identity currentIdentity, String newsAuthor)- Specified by:
canArchiveNewsin interfaceNewsService- Returns:
-
sendNotification
public void sendNotification(String currentUserId, News news, NotificationConstants.NOTIFICATION_CONTEXT context) throws Exception
- Throws:
Exception
-
-