Class URLStreamHandlerWithContextUtil
java.lang.Object
ro.sync.ecss.extensions.api.webapp.plugin.URLStreamHandlerWithContextUtil
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clears the handlers cache.void
copyContextId
(URL source, URL target) Method called to copy the context ID of a source URL to a target one.void
setUserContext
(UserContext context, URL url) Method called to set the context of an URL.If the URL contains a context id (set by a URLStreamHandlerWithContext), this method strips it, otherwise it simply returns the URL.
-
Constructor Details
-
URLStreamHandlerWithContextUtil
public URLStreamHandlerWithContextUtil()Constructor.
-
-
Method Details
-
getInstance
- Returns:
- Returns the singleton instance.
-
setUserContext
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
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
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.
-