Class Utils
- java.lang.Object
-
- org.exoplatform.social.notification.Utils
-
public class Utils extends Object
-
-
Constructor Summary
Constructors Constructor Description Utils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringaddExternalFlag(org.exoplatform.social.core.identity.model.Identity userIdentity)Add the external flag if the user is an externalstatic StringformatContent(String content)Get 150 first characters of a stringstatic org.exoplatform.social.core.manager.ActivityManagergetActivityManager()static List<String>getDestinataires(org.exoplatform.social.core.activity.model.ExoSocialActivity activity, org.exoplatform.social.core.space.model.Space space)Gets remote Ids of all users who receive a notification message when an activity is posted in a space.static org.exoplatform.social.core.manager.IdentityManagergetIdentityManager()static Set<String>getMentioners(String title, String posterId, String spaceId)Gets the list of mentioners in a message that is not the posterstatic org.exoplatform.social.core.manager.RelationshipManagergetRelationshipManager()static <T> TgetService(Class<T> clazz)static org.exoplatform.commons.api.notification.service.storage.MailNotificationStoragegetSocialEmailStorage()static org.exoplatform.social.core.space.spi.SpaceServicegetSpaceService()static StringgetUserId(String identityId)Gets a remote Id from a user's identity Id.static booleanisActivityNotificationsEnabled(String activityType)Checks if the notification is enabled for activities of type activityTypestatic booleanisSpaceActivity(org.exoplatform.social.core.activity.model.ExoSocialActivity activity)Checks if an activity is created in a space or not.static booleanisValidUrl(String url)Validates URL.static StringprocessLinkTitle(String title)static StringprocessMentions(String title)Finds all mention prefixes from an activity title, then adds a domain name to ensure the link to a user profile is correct.static voidsendToActivityPoster(Set<String> receivers, String activityPosterId, String posterId, String spaceId)Checks if a notification message is sent to an activity poster when a new comment is created.static voidsendToCommeters(Set<String> receivers, String[] commenters, String poster, String spaceId)static voidsendToLikers(Set<String> receivers, String[] likers, String poster, String spaceId)static voidsendToMentioners(Set<String> receivers, String[] mentioners, String poster, String spaceId)static voidsendToStreamOwner(Set<String> receivers, String streamOwner, String posteId)Checks if a notification message is sent to a stream owner or not.static List<String>toListUserIds(String... userIds)Converts an array of remote user Ids into a list.
-
-
-
Method Detail
-
getService
public static <T> T getService(Class<T> clazz)
-
getSocialEmailStorage
public static org.exoplatform.commons.api.notification.service.storage.MailNotificationStorage getSocialEmailStorage()
-
getUserId
public static String getUserId(String identityId)
Gets a remote Id from a user's identity Id.- Parameters:
identityId- The user's identity Id.- Returns:
- The remote Id.
-
toListUserIds
public static List<String> toListUserIds(String... userIds)
Converts an array of remote user Ids into a list.- Parameters:
userIds- The remote user Ids.- Returns:
- The list of remote Ids.
-
isSpaceActivity
public static boolean isSpaceActivity(org.exoplatform.social.core.activity.model.ExoSocialActivity activity)
Checks if an activity is created in a space or not.- Parameters:
activity- The activity to be checked.- Returns:
- The returned value is "true" if the activity is created, or "false" if the activity is not created.
-
sendToCommeters
public static void sendToCommeters(Set<String> receivers, String[] commenters, String poster, String spaceId)
-
sendToLikers
public static void sendToLikers(Set<String> receivers, String[] likers, String poster, String spaceId)
-
sendToStreamOwner
public static void sendToStreamOwner(Set<String> receivers, String streamOwner, String posteId)
Checks if a notification message is sent to a stream owner or not.- Parameters:
receivers- The list of users receiving the notification message.streamOwner- The owner of activity stream.posteId- Id of the user who has posted the activity.
-
sendToActivityPoster
public static void sendToActivityPoster(Set<String> receivers, String activityPosterId, String posterId, String spaceId)
Checks if a notification message is sent to an activity poster when a new comment is created.- Parameters:
receivers- The list of users receiving the notification message.activityPosterId- Id of the activity poster.posterId- Id of the user who has commented.
-
sendToMentioners
public static void sendToMentioners(Set<String> receivers, String[] mentioners, String poster, String spaceId)
-
processMentions
public static String processMentions(String title)
Finds all mention prefixes from an activity title, then adds a domain name to ensure the link to a user profile is correct.- Parameters:
title- The activity title.- Returns:
- The new title which contains the correct link to the user profile.
-
getMentioners
public static Set<String> getMentioners(String title, String posterId, String spaceId)
Gets the list of mentioners in a message that is not the poster- Parameters:
title- the activity titleposterId- id of the poster- Returns:
- list of mentioners
-
isValidUrl
public static boolean isValidUrl(String url)
Validates URL.- Parameters:
url- string to validate- Returns:
- true if url is valid (url started with http/https/www/ftp ...)
-
getDestinataires
public static List<String> getDestinataires(org.exoplatform.social.core.activity.model.ExoSocialActivity activity, org.exoplatform.social.core.space.model.Space space)
Gets remote Ids of all users who receive a notification message when an activity is posted in a space.- Parameters:
activity- The created activity.space- The space which contains the activity.- Returns:
- The remote Ids.
-
formatContent
public static String formatContent(String content)
Get 150 first characters of a string- Parameters:
content-- Returns:
-
getIdentityManager
public static org.exoplatform.social.core.manager.IdentityManager getIdentityManager()
-
getSpaceService
public static org.exoplatform.social.core.space.spi.SpaceService getSpaceService()
-
getActivityManager
public static org.exoplatform.social.core.manager.ActivityManager getActivityManager()
-
getRelationshipManager
public static org.exoplatform.social.core.manager.RelationshipManager getRelationshipManager()
-
isActivityNotificationsEnabled
public static boolean isActivityNotificationsEnabled(String activityType)
Checks if the notification is enabled for activities of type activityType- Parameters:
activityType- type of activity to check if their notification is enabled- Returns:
- true if the notification is enabled for this Activity Type
-
addExternalFlag
public static String addExternalFlag(org.exoplatform.social.core.identity.model.Identity userIdentity)
Add the external flag if the user is an external- Parameters:
userIdentity-- Returns:
- full username
-
-