Class WebsiteUtil


  • public class WebsiteUtil
    extends java.lang.Object
    Website utility class.
    Since:
    6.2.0
    Version:
    $Revision$ $Date$
    • Field Detail

      • IGNORE_FILE_ADJUST_ON_WEBSITE_CHANGE_TRANSACTION_ATTRIBUTE

        public static final java.lang.String IGNORE_FILE_ADJUST_ON_WEBSITE_CHANGE_TRANSACTION_ATTRIBUTE
        Name of a transaction attribute that turn off the files adjustment when changing websites. This is for testing purposes only!
        Since:
        12.4.0
    • Constructor Detail

      • WebsiteUtil

        public WebsiteUtil()
    • Method Detail

      • resolveWebsiteByString

        public static IWebsite resolveWebsiteByString​(java.lang.String websiteStr)
                                               throws PortalException
        Resolves the given website string in a website.
        The given string will be parsed as new URI(String), so that it must adhere with URI syntax.
        Parameters:
        websiteStr - the website string to be parsed.
        Returns:
        the resolved website.
        Throws:
        java.lang.IllegalArgumentException - if the given string is a malformed URL.
        java.lang.IllegalArgumentException - if the protocol isn't neither HTTP nor HTTPS.
        PortalException
        Since:
        6.2.0
        See Also:
        resolveWebsiteBaseURLByString(String)
      • resolveWebsiteBaseURLByString

        @Deprecated
        public static IWebsiteBaseURL resolveWebsiteBaseURLByString​(java.lang.String websiteStr)
                                                             throws PortalException
        Deprecated.
        since 10.4.0, use IWebsiteManager.getWebsiteBaseURL(URI) instead.
        Resolves the given website string in a website base URL.
        The given string will be parsed as new URI(String), so that it must adhere with URI syntax.
        Parameters:
        websiteStr - the website string to be parsed.
        Returns:
        the resolved website base URL.
        Throws:
        java.lang.IllegalArgumentException - if the given string is a malformed URL.
        java.lang.IllegalArgumentException - if the protocol isn't neither HTTP nor HTTPS.
        PortalException
        Since:
        6.2.0
      • match

        public static boolean match​(IWebsiteBaseURL baseUrl,
                                    java.net.URI uri)
        Checks whether the given base URL matches the given URI.
        Parameters:
        baseUrl - the base URL.
        uriStr - the URI.
        Returns:
        whether the given base URL matches the given URI.
        Since:
        10.2.0
      • match

        public static boolean match​(IWebsiteBaseURL baseUrl,
                                    java.lang.String uriStr)
        Checks whether the given base URL matches the given URI.
        Parameters:
        baseUrl - the base URL.
        uriStr - the URI.
        Returns:
        whether the given base URL matches the given URI.
        Since:
        10.2.0
      • getId

        public static java.lang.String getId​(IWebsiteBaseURL url)
        Returns the identifier of the given website base URL.
        Parameters:
        url - the website base URL.
        Returns:
        the identifier of the given website base URL.
        Throws:
        java.lang.IllegalArgumentException - if the given object is null.
        java.lang.IllegalArgumentException - if the given object's class is unknown.
        Since:
        6.2.0
      • getWebsiteURL

        public static java.lang.String getWebsiteURL​(javax.servlet.http.HttpServletRequest request)
        Returns the current WebsiteURL.
        Parameters:
        request - request in which the website is situated.
        Returns:
        string containing protocol://hostname : port / context. Port may be omitted if it's 80.
        Since:
        7.0.0
      • getDefaultPageWebSiteURL

        public static java.lang.String getDefaultPageWebSiteURL​(javax.servlet.http.HttpServletRequest request,
                                                                IPortalMode portalMode)
                                                         throws PortalException
        Returns the URL to the current website with page id to the defined portal mode.
        Parameters:
        request - from where to find website.
        portalMode - value of the portal mode for the url to be generated to.
        Returns:
        string containing website url.
        Throws:
        PortalException
        Since:
        7.0.0
      • getBestBaseURLForChannel

        public static java.util.Optional<IWebsiteBaseURL> getBestBaseURLForChannel​(java.lang.String channelId)
                                                                            throws PortalException
        Returns the best URL for the given channel.
        Parameters:
        channelId - the channel identifier
        Returns:
        the best URL for the given channel.
        Throws:
        PortalException
        Since:
        12.5.0