Class Utils


  • public class Utils
    extends Object
    • Constructor Detail

      • Utils

        public Utils()
    • 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)
      • sendToLikers

        public static void sendToLikers​(Set<String> receivers,
                                        String[] likers,
                                        String poster)
      • 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 posteId)
        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.
        posteId - Id of the user who has commented.
      • sendToMentioners

        public static void sendToMentioners​(Set<String> receivers,
                                            String[] mentioners,
                                            String poster)
      • 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)
        Gets the list of mentioners in a message that is not the poster
        Parameters:
        title - the activity title
        posterId - id of the poster
        Returns:
        list of mentioners
      • processLinkTitle

        public static String processLinkTitle​(String title)
      • 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