Package org.exoplatform.news
Class NewsServiceImpl
- java.lang.Object
-
- org.exoplatform.news.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 static StringAPPLICATION_DATA_PATHstatic StringMIX_NEWS_MODIFIERSstatic StringMIX_NEWS_MODIFIERS_PROPstatic StringNEWS_NODES_FOLDERstatic StringPINNED_NEWS_NODES_FOLDERstatic String[]SHARE_NEWS_PERMISSIONS
-
Constructor Summary
Constructors Constructor Description 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 Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidarchiveNews(String newsId)Archive a newsbooleancanArchiveNews(String newsAuthor)NewscancelScheduleNews(News news)booleancanDeleteNews(String posterId, String spaceId)booleancanEditNews(String posterId, String spaceId)Return a boolean that indicates if the current user can edit the news or notbooleancanEditNews(News news, String authenticatedUser)booleancanPublishNews()Return a boolean that indicates if the current user can publish the news or notbooleancanViewNews(News news, String username)NewsconvertNodeToNews(javax.jcr.Node node, boolean editMode)NewscreateNews(News news)Create and publish a News A news is composed of an activity and a CMS node containing the data.NewscreateNews(News news, javax.jcr.Session session)NewscreateNewsDraft(News news)Create the exo:news draft node in CMSvoiddeleteNews(String newsId, boolean isDraft)Delete newsList<News>getNews(NewsFilter filter)Get all newsNewsgetNewsByActivityId(String activityId, String authenticatedUser)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, String authenticatedUser, boolean editMode)Retrives a news identified by its technical identifierintgetNewsCount(NewsFilter filter)javax.jcr.NodegetNewsNodeById(String newsId, org.exoplatform.services.jcr.ext.common.SessionProvider sessionProvider)javax.jcr.SessiongetSession(org.exoplatform.services.jcr.ext.common.SessionProvider sessionProvider)voidmarkAsRead(News news, String userId)Increment the number of views for a newsvoidpinNews(String newsId)Pin a newsNewsscheduleNews(News news)List<NewsESSearchResult>search(org.exoplatform.social.core.identity.model.Identity currentUser, String term, int offset, int limit)Search news by termList<News>searchNews(NewsFilter filter, String lang)Search news with the given textprotected voidsendNotification(News news, NotificationConstants.NOTIFICATION_CONTEXT context, javax.jcr.Session session)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 spaceprotected StringsubstituteUsernames(String portalOwner, String message)voidunarchiveNews(String newsId)Unarchive a newsvoidunpinNews(String newsId)NewsupdateNews(News news)Update a news If the uploadId of the news is null, the illustration is not updated.protected voidupdateNewsActivities(org.exoplatform.social.core.activity.model.ExoSocialActivity activity, News news, javax.jcr.Session session)
-
-
-
Field Detail
-
SHARE_NEWS_PERMISSIONS
public static final String[] SHARE_NEWS_PERMISSIONS
-
NEWS_NODES_FOLDER
public static final String NEWS_NODES_FOLDER
- See Also:
- Constant Field Values
-
PINNED_NEWS_NODES_FOLDER
public static final String PINNED_NEWS_NODES_FOLDER
- See Also:
- Constant Field Values
-
APPLICATION_DATA_PATH
public static final String APPLICATION_DATA_PATH
- See Also:
- Constant Field Values
-
MIX_NEWS_MODIFIERS
public static final String MIX_NEWS_MODIFIERS
- See Also:
- Constant Field Values
-
MIX_NEWS_MODIFIERS_PROP
public static final String MIX_NEWS_MODIFIERS_PROP
- See Also:
- Constant Field Values
-
-
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:
createNewsin interfaceNewsService- Parameters:
news- The news to create- Throws:
Exception- when error
-
createNews
public News createNews(News news, javax.jcr.Session session) throws Exception
- Specified by:
createNewsin interfaceNewsService- Throws:
Exception
-
getNewsById
public News getNewsById(String newsId, boolean editMode)
Description copied from interface:NewsServiceRetrives a news identified by its technical identifier- Specified by:
getNewsByIdin interfaceNewsService- Parameters:
newsId-Newsidentifier- Returns:
Newsif found else null
-
getNews
public List<News> getNews(NewsFilter filter) throws Exception
Get all news- Specified by:
getNewsin interfaceNewsService- Returns:
- all news
- Throws:
Exception- when error
-
canArchiveNews
public boolean canArchiveNews(String newsAuthor)
- Specified by:
canArchiveNewsin interfaceNewsService
-
getNewsCount
public int getNewsCount(NewsFilter filter) throws Exception
- Specified by:
getNewsCountin interfaceNewsService- Throws:
Exception
-
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:
updateNewsin interfaceNewsService- 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:
markAsReadin interfaceNewsService- Parameters:
userId- The current user idnews- The news to be updated- Throws:
Exception- when error
-
pinNews
public void pinNews(String newsId) throws Exception
Pin a news- Specified by:
pinNewsin interfaceNewsService- Parameters:
newsId- The id of the news to be pinned- Throws:
Exception- when error
-
unpinNews
public void unpinNews(String newsId) throws Exception
- Specified by:
unpinNewsin 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 IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException
Description copied from interface:NewsServiceShares 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 found
-
deleteNews
public void deleteNews(String newsId, boolean isDraft) throws Exception
Delete news- Specified by:
deleteNewsin interfaceNewsService- Parameters:
newsId- the news id to deleteisDraft-- Throws:
Exception- when error
-
convertNodeToNews
public News convertNodeToNews(javax.jcr.Node node, boolean editMode) throws Exception
- Specified by:
convertNodeToNewsin interfaceNewsService- Throws:
Exception
-
createNewsDraft
public News createNewsDraft(News news) throws Exception
Create the exo:news draft node in CMS- Specified by:
createNewsDraftin interfaceNewsService- Parameters:
news- the news- Returns:
- News draft id
- 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:
searchin interfaceNewsService- 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:
canEditNewsin interfaceNewsService- Parameters:
posterId- the poster id of the newsspaceId- 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:NewsServiceRetrives a news identified by its technical identifier- Specified by:
getNewsByIdin interfaceNewsService- Parameters:
newsId-NewsidentifierauthenticatedUser- 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
-
getNewsByActivityId
public News getNewsByActivityId(String activityId, String authenticatedUser) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException
Description copied from interface:NewsServiceRetrives a news identified by originating Activity identifier or a shared activity identifier- Specified by:
getNewsByActivityIdin interfaceNewsService- Parameters:
activityId-ExoSocialActivityidentifierauthenticatedUser- 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
-
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
-
canEditNews
public boolean canEditNews(News news, String authenticatedUser)
- Specified by:
canEditNewsin interfaceNewsService- Parameters:
news-Newsto checkauthenticatedUser- authenticated username- Returns:
- true if user has access to news, else false
-
canPublishNews
public boolean canPublishNews()
Return a boolean that indicates if the current user can publish the news or not- Specified by:
canPublishNewsin interfaceNewsService- Returns:
- if the news can be published
-
scheduleNews
public News scheduleNews(News news) throws Exception
- Specified by:
scheduleNewsin interfaceNewsService- Throws:
Exception
-
cancelScheduleNews
public News cancelScheduleNews(News news) throws Exception
- Specified by:
cancelScheduleNewsin interfaceNewsService- Throws:
Exception
-
updateNewsActivities
protected void updateNewsActivities(org.exoplatform.social.core.activity.model.ExoSocialActivity activity, News news, javax.jcr.Session session) throws Exception- Throws:
Exception
-
sendNotification
protected void sendNotification(News news, NotificationConstants.NOTIFICATION_CONTEXT context, javax.jcr.Session session) throws Exception
- 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
-
archiveNews
public void archiveNews(String newsId) throws Exception
Archive a news- Specified by:
archiveNewsin interfaceNewsService- Parameters:
newsId- The id of the news to be archived- Throws:
Exception- when error
-
unarchiveNews
public void unarchiveNews(String newsId) throws Exception
Unarchive a news- Specified by:
unarchiveNewsin interfaceNewsService- Parameters:
newsId- The id of the news to be unarchived- Throws:
Exception- when error
-
canDeleteNews
public boolean canDeleteNews(String posterId, String spaceId)
- Specified by:
canDeleteNewsin interfaceNewsService
-
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.RepositoryExceptionjavax.jcr.ItemNotFoundException
-
getSession
public javax.jcr.Session getSession(org.exoplatform.services.jcr.ext.common.SessionProvider sessionProvider) throws javax.jcr.RepositoryException- Throws:
javax.jcr.RepositoryException
-
-