Class URLStreamHandlerWithContextUtil

java.lang.Object
ro.sync.ecss.extensions.api.webapp.plugin.URLStreamHandlerWithContextUtil

@API(src=PUBLIC, type=EXTENDABLE) public class URLStreamHandlerWithContextUtil extends 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 Details

    • URLStreamHandlerWithContextUtil

      public URLStreamHandlerWithContextUtil()
      Constructor.
  • Method Details

    • getInstance

      public static URLStreamHandlerWithContextUtil getInstance()
      Returns:
      Returns the singleton instance.
    • setUserContext

      public void setUserContext(UserContext context, URL url) throws 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:
      MalformedURLException
    • copyContextId

      public void copyContextId(URL source, 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 String toStrippedExternalForm(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.