Class URLStreamHandlerWithContextUtil
- java.lang.Object
-
- ro.sync.ecss.extensions.api.webapp.plugin.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 Summary
Constructors Constructor Description URLStreamHandlerWithContextUtil()
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearCacheForTC()
Clears the handlers cache.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.static URLStreamHandlerWithContextUtil
getInstance()
void
setUserContext(UserContext context, java.net.URL url)
Method called to set the context of an URL.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.
-
-
-
Method Detail
-
getInstance
public static URLStreamHandlerWithContextUtil getInstance()
- Returns:
- Returns the singleton instance.
-
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.
-
-