Package com.microstrategy.web.app.utils
Class HTTPHelper
- java.lang.Object
-
- com.microstrategy.web.app.utils.HTTPHelper
-
public class HTTPHelper extends java.lang.ObjectThis class contains some public utility methods that can be used for handling parameters included on collections such as the HttpServletRequest object, and the RequestKeys object.- Since:
- MicroStrategy Web 7.3.1 or earlier
-
-
Constructor Summary
Constructors Constructor Description HTTPHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static intfixInt(RequestKeys rk, java.lang.String param, int defaultValue)static intfixInt(RequestKeys rk, java.lang.String param, int defaultValue, boolean isZeroLengthValid)Transforms the string sent as parameter into anintvalue.static intfixInt(java.lang.String fixedValue, int defaultValue)Transforms the string sent as parameter into anintvalue.static java.lang.StringfixString(RequestKeys rk, java.lang.String param, java.lang.String defaultValue)Searches for the asked parameter on the request object.static java.lang.StringfixString(RequestKeys rk, java.lang.String param, java.lang.String defaultValue, boolean isZeroLengthValid)Searches for the asked parameter on the request object.static intgetBrowserLocale(AppContext appContext)static java.lang.StringgetDescriptor(int key)Deprecated.static java.lang.StringgetDescriptor(int key, Messages messages)Obtains the descriptor string corresponding to the indicated keystatic java.lang.StringgetEnumerationValue(java.lang.String enumValue)Deprecated.This method is deprecated.static java.lang.StringgetLastRowPosition(ReportBean rb)Gets the position where the new attribute will be displayedstatic intgetLocale(java.lang.String localeStr, AppContext appContext)static intgetOutputFormatToUse(AppContext appContext)Determines the output mode the beans should use when getting displayed based on the preferences as defined by the instance of AppContext.static intgetOutputFormatToUse(Preferences preferences, BrowserSettings browserSettings)Deprecated.static WebProjectInstancegetProject(WebIServerSession session)static java.lang.StringgetProjectAlias(WebIServerSession session)Utility method for obtaining the project alias string based on the Server and original Project name.static java.lang.StringgetProjectAlias(java.lang.String serverName, int serverPort, java.lang.String projectName)Deprecated.static java.lang.StringgetProjectAlias(java.lang.String serverName, int serverPort, java.lang.String projectName, java.util.Locale locale)Utility method for obtaining the project alias string based on the Server and original Project name.static java.lang.StringgetProjectAlias(java.lang.String serverName, java.lang.String projectName)Deprecated.static booleanisDefaultLocale(java.lang.String localeStr)static booleanisIFrameRequest(PageComponent mstrPage)static booleanisKeyExisting(RequestKeys keys, WebEvent event, int argID)Checks if the argument sent as parameter exists on the RequestKeys instancestatic booleanisKeyExisting(RequestKeys keys, java.lang.String argName)Checks if the argument sent as parameter exists on the RequestKeys instancestatic java.lang.StringmimeEncode(java.lang.String input)Utility method to encode the HTTP header value with RFC 2047.static voidprocessApplyChanges(WebComponent wc)Handles the request for the instances of ReportBean and RWBeanstatic voidprocessResetChanges(ReportBean rb)Resets the changes om the ReportBean.static java.lang.StringremoveCrlf(java.lang.String input)Utility method to remove CRLF "\r", "\n" and encoded CRLF "%0a %0A %0d %0D" from the HTTP header to fix: "CWE-113 : Improper Neutralization of CRLF sequences in HTTP Headers (âHTTP Response splittingâ)" For only non-encoded CRLF removalstatic java.lang.StringtoSysBeanName(int sysBeanType)static inttoSysBeanType(java.lang.String sysBeanName)
-
-
-
Method Detail
-
fixString
public static java.lang.String fixString(RequestKeys rk, java.lang.String param, java.lang.String defaultValue, boolean isZeroLengthValid)
Searches for the asked parameter on the request object.- Parameters:
rk-RequestKeysobject initializedparam-Stringcontaining the name of the parameter to search fordefaultValue-Stringwith the default value of the parameterisZeroLengthValid-Booleanflag indicating if the value of the parameter can be zero-length- Returns:
- the value of the parameter. If not found, or the length of the value is zero and this is not allowed, the default value will be used. Otherwise, the value found for the parameter will be the output of the method.
-
fixString
public static java.lang.String fixString(RequestKeys rk, java.lang.String param, java.lang.String defaultValue)
Searches for the asked parameter on the request object.- Parameters:
rk-RequestKeysobject initializedparam-Stringcontaining the name of the parameter to search fordefaultValue-Stringwith the default value of the parameter- Returns:
- the value of the parameter. If not found, or the length of the value is zero and since this is not allowed, the default value will be used. Otherwise, the value found for the parameter will be the output of the method.
-
fixInt
public static int fixInt(java.lang.String fixedValue, int defaultValue)Transforms the string sent as parameter into anintvalue.- Parameters:
fixedValue-Stringcontaining the value to transform into an integerdefaultValue-intwith the default value of the parameter- Returns:
- the value of the parameter as an
int. If an error is generated while the conversion the default value will be used.
-
fixInt
public static int fixInt(RequestKeys rk, java.lang.String param, int defaultValue, boolean isZeroLengthValid)
Transforms the string sent as parameter into anintvalue.- Parameters:
rk-RequestKeysobject initializedparam-Stringcontaining the name of the parameter to search fordefaultValue-Stringwith the default value of the parameterisZeroLengthValid-booleanflag indicating if the value of the parameter can be zero-length- Returns:
- the value of the parameter. If not found, or the length of the value is zero and this is not allowed, the default value will be used. Otherwise, the value found for the parameter will be the output of the method.
-
fixInt
public static int fixInt(RequestKeys rk, java.lang.String param, int defaultValue)
-
getEnumerationValue
public static java.lang.String getEnumerationValue(java.lang.String enumValue)
Deprecated.This method is deprecated. Instead useReflectionHelper.getEnumerationValue(String enumName).Returns the value of the constant defined in the Java fully qualified class name and constant name received as a parameter. The value is always returned as a String regardless of the original data type. If the class cannot be resolved or the data member does not exist, null is returned.- Parameters:
enumValue- FCN of the data member to resolved. i.e. com.microstrategy.web.beans.EnumReportBeanEvents.REPORT_EVENT_EXECUTE- Returns:
- String object containing the value of the FCN memmber provided. For the previous example, the return value is "4001"
-
toSysBeanType
public static int toSysBeanType(java.lang.String sysBeanName)
-
toSysBeanName
public static java.lang.String toSysBeanName(int sysBeanType)
-
getDescriptor
public static java.lang.String getDescriptor(int key)
Deprecated.Obtains the descriptor string corresponding to the indicated key- Parameters:
key- identifier to look for on the string database- Returns:
- string corresponding to the indicated key
-
getDescriptor
public static java.lang.String getDescriptor(int key, Messages messages)Obtains the descriptor string corresponding to the indicated key- Parameters:
key- identifier to look for on the string databasemessages-Messagesinstance where the descriptor string will be looked for.- Returns:
- string corresponding to the indicated key
-
isKeyExisting
public static boolean isKeyExisting(RequestKeys keys, WebEvent event, int argID)
Checks if the argument sent as parameter exists on the RequestKeys instance- Parameters:
keys- aRequestKeysinitialized instanceevent- aWebEventinstance from where the argument name will be obtainedargID- the identifier of the argument to search for- Returns:
Trueif the argument was found as a parameter on the RequestKeys, either as the exact name or with the '.x' or '.y' extension (passed as an image input).
-
isKeyExisting
public static boolean isKeyExisting(RequestKeys keys, java.lang.String argName)
Checks if the argument sent as parameter exists on the RequestKeys instance- Parameters:
keys- aRequestKeysinitialized instanceargName- the name of the argument to search for- Returns:
Trueif the argument was found as a parameter on the RequestKeys, either as the exact name or with the '.x' or '.y' extension (passed as an image input).
-
getLastRowPosition
public static java.lang.String getLastRowPosition(ReportBean rb)
Gets the position where the new attribute will be displayed- Parameters:
rb- aReportBeaninstance initialized- Returns:
- the last index (plus one) of the row axis on the template. If an error happens, returns 1 by default.
-
processApplyChanges
public static void processApplyChanges(WebComponent wc) throws WebException
Handles the request for the instances of ReportBean and RWBean- Parameters:
wc- WebComponent- Throws:
WebException- Since:
- MicroStrategy Web 8.0.0
-
processResetChanges
public static void processResetChanges(ReportBean rb) throws WebException
Resets the changes om the ReportBean.- Parameters:
rb- ReportBean- Throws:
WebException
-
getOutputFormatToUse
public static int getOutputFormatToUse(AppContext appContext)
Determines the output mode the beans should use when getting displayed based on the preferences as defined by the instance of AppContext.- Parameters:
appContext- AppContext- Returns:
- int
-
getProjectAlias
public static java.lang.String getProjectAlias(java.lang.String serverName, java.lang.String projectName)Deprecated.Utility method for obtaining the project alias string based on the Server and original Project name- Parameters:
serverName- String with the name of the I-Server of the project to look forprojectName- String with the original project name to look for- Returns:
- a String with the original project name if no alias was found, or the value of the alias found on the System Preferences for the given project.
- Since:
- MicroStrategy Web 7.5.3
-
getProjectAlias
public static java.lang.String getProjectAlias(java.lang.String serverName, int serverPort, java.lang.String projectName)Deprecated.Utility method for obtaining the project alias string based on the Server and original Project name.- Parameters:
serverName- String with the name of the I-Server of the project to look forserverPort- Port of I-Server.projectName- String with the original project name to look for- Returns:
- a String with the original project name if no alias was found, or the value of the alias found on the System Preferences for the given project.
- Since:
- MicroStrategy Web 9.0.0
-
getProjectAlias
public static java.lang.String getProjectAlias(java.lang.String serverName, int serverPort, java.lang.String projectName, java.util.Locale locale)Utility method for obtaining the project alias string based on the Server and original Project name.- Parameters:
serverName- String with the name of the I-Server of the project to look forserverPort- Port of I-Server.projectName- String with the original project name to look forlocale- locale of the project alias to return- Returns:
- a String with the original project name if no alias was found, or the value of the alias found on the System Preferences for the given project.
-
getProjectAlias
public static java.lang.String getProjectAlias(WebIServerSession session)
Utility method for obtaining the project alias string based on the Server and original Project name.- Parameters:
session- session available for lookup.- Returns:
- a String with the original project name if no alias was found, or the value of the alias found on the System Preferences for the given project.
- Since:
- MicroStrategy Web 9.0.0
-
getProject
public static WebProjectInstance getProject(WebIServerSession session)
-
getOutputFormatToUse
public static int getOutputFormatToUse(Preferences preferences, BrowserSettings browserSettings)
Deprecated.Determines the output mode the beans should use when getting displayed based on preferences- Parameters:
preferences-Preferencesinitialized instancebrowserSettings-BrowserSettingsinitialized instance- Returns:
- an element of the
EnumBeanOutputFormatenumeration
-
isDefaultLocale
public static boolean isDefaultLocale(java.lang.String localeStr)
- Since:
- MicroStrategy Web 9.0.0
-
getLocale
public static int getLocale(java.lang.String localeStr, AppContext appContext)- Since:
- MicroStrategy Web 9.0.0
-
getBrowserLocale
public static int getBrowserLocale(AppContext appContext)
- Since:
- MicroStrategy Web 9.0.0
-
isIFrameRequest
public static boolean isIFrameRequest(PageComponent mstrPage)
- Since:
- MicroStrategy Web 9.0.1
-
mimeEncode
public static java.lang.String mimeEncode(java.lang.String input)
Utility method to encode the HTTP header value with RFC 2047.- Parameters:
input- HTTP header value which has non-ASCII characters.- Returns:
- an encoded String
- Since:
- MicroStrategy Web 9.0.2
-
removeCrlf
public static java.lang.String removeCrlf(java.lang.String input)
Utility method to remove CRLF "\r", "\n" and encoded CRLF "%0a %0A %0d %0D" from the HTTP header to fix: "CWE-113 : Improper Neutralization of CRLF sequences in HTTP Headers (âHTTP Response splittingâ)" For only non-encoded CRLF removal- Parameters:
input- HTTP header value which has CRLF characters.- Returns:
- an String without CRLF characters
- See Also:
StringUtils.removeCrlf(String value, boolean isRemoveEncodedCrlf)
-
-