Class URLStreamHandlerWithContextUtil


  • @API(src=PUBLIC,
         type=EXTENDABLE)
    public class URLStreamHandlerWithContextUtil
    extends java.lang.Object
    Utility class for adding/removing the user context id from the URLs. The context ID is typically added when the user asks the webapp to open an URL and is stripped before displaying a URL to the user.
    Since:
    17
    • Constructor Detail

      • URLStreamHandlerWithContextUtil

        public URLStreamHandlerWithContextUtil()
        Constructor.
    • Method Detail

      • setUserContext

        public void setUserContext​(UserContext context,
                                   java.net.URL url)
                            throws java.net.MalformedURLException
        Method called to set the context of an URL. If the URL handler for this URL is an URLStreamHandlerWithContext, it is used to set the context for the URL, otherwise the URL is left unmodified. Note: If the URL already has a context, the newly set context must have the same id.
        Parameters:
        context - The context.
        url - The URL.
        Throws:
        java.net.MalformedURLException
      • copyContextId

        public void copyContextId​(java.net.URL source,
                                  java.net.URL target)
        Method called to copy the context ID of a source URL to a target one. If the two URLs have different protocols, this method does nothing.
        Parameters:
        source - The URL from which to copy the user context id.
        target - The URL where to copy the user context id.
      • toStrippedExternalForm

        public java.lang.String toStrippedExternalForm​(java.net.URL url)
        If the URL contains a context id (set by a URLStreamHandlerWithContext), this method strips it, otherwise it simply returns the URL.
        Parameters:
        url - The URL with the context id.
        Returns:
        The stripped URL.
      • clearCacheForTC

        public void clearCacheForTC()
        Clears the handlers cache. Note: To be used only from TC.