Class Utils


  • public class Utils
    extends Object
    Created by The eXo Platform SAS.
    Version:
    $Id: Utils.java 00000 Mar 30, 2017 pnedonosko $
    Author:
    Peter Nedonosko
    • Constructor Detail

      • Utils

        public Utils()
    • Method Detail

      • spaceRoomName

        public static String spaceRoomName​(String spacePrettyName)
        Generate a space room name.
        Parameters:
        spacePrettyName - the space pretty name
        Returns:
        the string
      • getSpaceByContext

        public static org.exoplatform.social.core.space.model.Space getSpaceByContext()
        Gets the space by context.
        Returns:
        the space by context
      • getSpaceNameByContext

        public static String getSpaceNameByContext()
        Gets the space name by context.
        Returns:
        the space name in portal context
      • getCurrentContext

        public static ContextInfo getCurrentContext​(String userId,
                                                    Locale locale)
        Gets the current context.
        Parameters:
        userId - the user id
        locale - the locale
        Returns:
        the current context
      • getResourceMessages

        public static Map<String,​String> getResourceMessages​(String bundleName,
                                                                   Locale locale)
        Gets the resource messages.
        Parameters:
        bundleName - the bundle name
        locale - the locale
        Returns:
        the resource messages
      • getResourceMessage

        public static String getResourceMessage​(String bundleName,
                                                Locale locale,
                                                String messageKey)
        Gets the resource message.
        Parameters:
        bundleName - the bundle name
        locale - the locale
        messageKey - the message key
        Returns:
        the resource message
      • asJSON

        public static String asJSON​(Object obj)
                             throws org.exoplatform.ws.frameworks.json.impl.JsonException
        Format specified object to JSON string.
        Parameters:
        obj - the obj
        Returns:
        the string
        Throws:
        org.exoplatform.ws.frameworks.json.impl.JsonException - the json exception
      • parseISODate

        public static Date parseISODate​(String date)
                                 throws ParseException
        Parses the date from a ISO-8601 formatted string.
        Parameters:
        date - the date
        Returns:
        the date
        Throws:
        ParseException - the parse exception
      • formatISODate

        public static String formatISODate​(Date date)
        Format date as ISO-8601 string with UTC time zone.
        Parameters:
        date - the date
        Returns:
        the string
      • buildUrl

        public static String buildUrl​(String protocol,
                                      String hostname,
                                      int port,
                                      String path)
                               throws MalformedURLException
        Build client URL using given parameters.
        Parameters:
        protocol - the scheme
        hostname - the host name
        port - the port
        path - the path
        Returns:
        the string
        Throws:
        MalformedURLException - if the protocol hasn't a handled