Class WebConsoleUtil
- java.lang.Object
-
- org.apache.felix.webconsole.WebConsoleUtil
-
@Deprecated(since="2021-04-30") public final class WebConsoleUtil extends java.lang.Object
Deprecated.The Apache Felix Webconsole is not supported in Cloud environments.TheWebConsoleUtil
provides various utility methods for use by Web Console plugins.
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static java.lang.String
escapeHtml(java.lang.String text)
Deprecated.Escapes HTML special chars like: <>&\r\n and spacestatic java.lang.String
getParameter(HttpServletRequest request, java.lang.String name)
Deprecated.An utility method, that is used to filter out simple parameter from file parameter when multipart transfer encoding is used.static int
getParameterInt(HttpServletRequest request, java.lang.String name, int _default)
Deprecated.Retrieves a request parameter and converts it to int.static VariableResolver
getVariableResolver(ServletRequest request)
Deprecated.Returns theVariableResolver
for the given request.static void
sendRedirect(HttpServletRequest request, HttpServletResponse response, java.lang.String redirectUrl)
Deprecated.Utility method to handle relative redirects.static void
setNoCache(HttpServletResponse response)
Deprecated.Sets response headers to force the client to not cache the response sent back.static void
setVariableResolver(ServletRequest request, VariableResolver resolver)
Deprecated.Sets theVariableResolver
as theWebConsoleConstants.ATTR_CONSOLE_VARIABLE_RESOLVER
attribute in the given request.static java.lang.String
toString(java.lang.Object value)
Deprecated.This method will stringify a Java object.static java.lang.String
urlDecode(java.lang.String value)
Deprecated.Decode the given value expected to be URL encoded.
-
-
-
Method Detail
-
getVariableResolver
public static VariableResolver getVariableResolver(ServletRequest request)
Deprecated.Returns theVariableResolver
for the given request.If no resolver has yet be created for the requests, an instance of the
DefaultVariableResolver
is created with preset properties, placed into the request and returned. The preset properties areappRoot
set to the value of theWebConsoleConstants.ATTR_APP_ROOT
request attribute andpluginRoot
set to the value of theWebConsoleConstants.ATTR_PLUGIN_ROOT
request attribute.Note: An object not implementing the
VariableResolver
interface already stored as theWebConsoleConstants.ATTR_CONSOLE_VARIABLE_RESOLVER
attribute will silently be replaced by theDefaultVariableResolver
instance.- Parameters:
request
- The request whose attribute is returned (or set)- Returns:
- The
VariableResolver
for the given request.
-
setVariableResolver
public static void setVariableResolver(ServletRequest request, VariableResolver resolver)
Deprecated.Sets theVariableResolver
as theWebConsoleConstants.ATTR_CONSOLE_VARIABLE_RESOLVER
attribute in the given request. An attribute of that name already existing is silently replaced.- Parameters:
request
- The request whose attribute is setresolver
- TheVariableResolver
to place into the request
-
getParameter
public static final java.lang.String getParameter(HttpServletRequest request, java.lang.String name)
Deprecated.An utility method, that is used to filter out simple parameter from file parameter when multipart transfer encoding is used. This method processes the request and sets a request attributeAbstractWebConsolePlugin.ATTR_FILEUPLOAD
. The attribute value is aMap
where the key is a String specifying the field name and the value is aFileItem
.- Parameters:
request
- the HTTP request coming from the username
- the name of the parameter- Returns:
- if not multipart transfer encoding is used - the value is the
parameter value or
null
if not set. If multipart is used, and the specified parameter is field - then the value of the parameter is returned.
-
sendRedirect
public static final void sendRedirect(HttpServletRequest request, HttpServletResponse response, java.lang.String redirectUrl) throws java.io.IOException
Deprecated.Utility method to handle relative redirects. Some application servers like Web Sphere handle relative redirects differently therefore we should make an absolute URL before invoking send redirect.- Parameters:
request
- the HTTP request coming from the userresponse
- the HTTP response, where data is renderedredirectUrl
- the redirect URI.- Throws:
java.io.IOException
- If an input or output exception occursjava.lang.IllegalStateException
- If the response was committed or if a partial URL is given and cannot be converted into a valid URL
-
setNoCache
public static final void setNoCache(HttpServletResponse response)
Deprecated.Sets response headers to force the client to not cache the response sent back. This method must be called before the response is committed otherwise it will have no effect.This method sets the
Cache-Control
,Expires
, andPragma
headers.- Parameters:
response
- The response for which to set the cache prevention
-
escapeHtml
public static final java.lang.String escapeHtml(java.lang.String text)
Deprecated.Escapes HTML special chars like: <>&\r\n and space- Parameters:
text
- the text to escape- Returns:
- the escaped text
-
getParameterInt
public static final int getParameterInt(HttpServletRequest request, java.lang.String name, int _default)
Deprecated.Retrieves a request parameter and converts it to int.- Parameters:
request
- the HTTP requestname
- the name of the request parameter_default
- the default value returned if the parameter is not set or is not a valid integer.- Returns:
- the request parameter if set and is valid integer, or the default value
-
urlDecode
public static java.lang.String urlDecode(java.lang.String value)
Deprecated.Decode the given value expected to be URL encoded.This method first tries to use the Java 1.4 method
URLDecoder.decode(String, String)
method and falls back to the now deprecatedURLDecoder.decode(String, String)
which uses the platform character set to decode the string. This is because the platforms before 1.4 and most notably some OSGi Execution Environments (such as Minimum EE) do not provide the newer method.- Parameters:
value
- the value to decode- Returns:
- the decoded string
-
toString
public static final java.lang.String toString(java.lang.Object value)
Deprecated.This method will stringify a Java object. It is mostly used to print the values of unknown properties. This method will correctly handle if the passed object is array and will property display it. If the value is byte[] the elements are shown as Hex- Parameters:
value
- the value to convert- Returns:
- the string representation of the value
-
-