Modifier and Type | Method and Description |
---|---|
static void |
addAttachmentToResponse(javax.servlet.http.HttpServletResponse response,
InputStream inputStream,
String contentType,
String fileName,
long fileSize)
Adds the header and content of an attachment to the response.
|
static boolean |
areDifferentDomains(String firstDomain,
String secondDomain)
Determines whether two URLs point at the same domain.
|
static String |
buildAttributeTitleString(String prependText,
Class<?> element,
Map<String,String> keyValueMap)
Helper method for building title text for an element and a map of key/value pairs,
|
static String |
buildMapParameterString(Map<String,String> map)
Builds a string from the given map by joining each entry with a comma and
each key/value pair with a colon
|
static String |
buildViewUrl(String baseUrl,
String controllerMapping,
String viewId)
Helper method for building a URL that will invoke the given controller and render the given
KRAD view
|
static String |
clean(String string)
Removes all query characters from a string.
|
static void |
cleanRequestParameters(Properties requestParameters)
Removes parameters from the given properties object that are request specific (useful when manupulating the
current URL to invoke something else)
|
static Map<String,Object> |
coerceRequestParameterTypes(Class<?> dataObjectClass,
Map<String,String> parameters)
This method converts request parameters coming in as String to native types in case of Boolean, Number or
java.sql.Date.
|
static boolean |
containsSensitiveDataPatternMatch(String fieldValue)
Check if data might be sensitive
|
static String |
convertDecimalIntoInteger(KualiDecimal decimalNumber)
Convert the given money amount into an integer string.
|
static Properties |
convertMapToProperties(Map<String,String> parameters)
Utility method to convert a Map to a Properties object
|
static Properties |
convertRequestMapToProperties(Map<String,String[]> requestParameters)
Utility method to convert a Request Parameters Map to a Properties object
|
static List<String> |
convertStringParameterToList(String parameter)
Parses a string that is in list format (commas separating list entries) to a new List instance
|
static Map<String,String> |
convertStringParameterToMap(String parameter)
Parses a string that is in map format (commas separating map entries, colon separates
map key/value) to a new map instance
|
static String |
convertToHTMLAttributeSafeString(String message)
Helper method to change common characters into HTML attribute safe characters
|
static <T> T |
createNewObjectFromClass(Class<T> clazz)
This method safely creates a object from a class
Convenience method to create new object and throw a runtime exception if it cannot
If the class is an
ExternalizableBusinessObject , this method will determine the
interface for the EBO and
query the
appropriate module service to create a new instance. |
static Object |
createObject(Class<?> clazz,
Class<?>[] argumentClasses,
Object[] argumentValues) |
static Class |
easyGetPropertyType(Object object,
String propertyName)
LegacyCase - This method simply uses PojoPropertyUtilsBean logic to get the Class of a Class property.
|
static String |
generateRowCssClassString(Map<String,String> conditionalRowCssClasses,
int lineIndex,
boolean isOdd,
Map<String,Object> lineContext,
ExpressionEvaluator expressionEvaluator)
Get the rowCss for the line specified, by evaluating the conditionalRowCssClasses map for that row
|
static String |
generateUniqueViewTitle(UifFormBase form,
View view)
Attempts to generate a unique view title by combining the View's headerText with the title attribute for the
dataObjectClass found through the DataObjectMetaDataService.
|
static String |
getBusinessTitleForClass(Class<? extends Object> clazz)
Retrieve the title for a business object class
|
static List<String> |
getFileNameFromPath(List<String> fullFileNames)
Picks off the filename from the full path
|
static String |
getFullURL(javax.servlet.http.HttpServletRequest request)
Get the full url for a request (requestURL + queryString)
|
static Integer |
getIntegerValue(String numberStr)
Return the integer value of a string
|
static Map<String,String> |
getMapFromParameterString(String parameterString)
Parses the given string into a Map by splitting on the comma to get the
map entries and within each entry splitting by colon to get the key/value
pairs
|
static String |
getMessageText(ErrorMessage errorMessage,
boolean processPrefixSuffix)
Gets the message associated with ErrorMessage object passed in, using message service.
|
static Map<String,String> |
getNamespaceAndActionClass(Class<? extends Object> clazz) |
static Map<String,String> |
getNamespaceAndComponentFullName(Class<? extends Object> clazz) |
static Map<String,String> |
getNamespaceAndComponentSimpleName(Class<? extends Object> clazz) |
static String |
getNamespaceCode(Class<? extends Object> clazz)
TODO this method will probably need to be exposed in a public KRADUtils class as it is used
by several different modules.
|
static String |
getNestedAttributePrefix(String attributeName)
Returns the prefix of a nested attribute name, or the empty string if the attribute name is not nested.
|
static String |
getNestedAttributePrimitive(String attributeName)
Returns the primitive part of an attribute name string.
|
static Object |
getNestedValue(Object bo,
String fieldName)
This method safely extracts either simple values OR nested values.
|
static Map<String,String> |
getParametersFromRequest(List<String> parameterNames,
Class<?> parentObjectClass,
Map<String,String> requestParameters)
Retrieves parameter values from the request that match the requested
names.
|
static Map<String,String> |
getPropertyKeyValuesFromDataObject(List<String> propertyNames,
List<String> securePropertyNames,
Object dataObject)
Returns a map containing a key/value pair for each property given in the property names list, ignoring any values
considered to be secure, including those in
securePropertyNames . |
static Map<String,String> |
getPropertyKeyValuesFromDataObject(List<String> propertyNames,
Object dataObject)
Returns a map containing a key/value pair for each property given in the property names list, ignoring any values
considered to be secure.
|
static Boolean |
getRequestParameterAsBoolean(javax.servlet.ServletRequest request,
String parameterName)
Retrieves value for the given parameter name in the request and attempts to convert to a Boolean using
the
BooleanFormatter |
static String |
getRequestStringFromMap(Map<String,String> requestParameters)
Generate the request parameter portion of the url based on the map of key value pairs passed in
|
static String |
getSimpleFieldValue(Object model,
Field field)
Attempts to extract a string value out of the field passed in, varies depending on field type
|
static UserSession |
getUserSessionFromRequest(javax.servlet.http.HttpServletRequest request)
Gets the UserSession object from the HttpServletRequest object's
associated session.
|
static Object |
hydrateAttributeValue(Class<?> propertyType,
String attributeValue)
Attempt to coerce a String attribute value to the given propertyType.
|
static boolean |
isNotNull(Object object)
This method is a confirms if object is not null, and unproxies if necessary to determine this
|
static boolean |
isNull(Object object)
This method is a confirms if object is null, and unproxies if necessary to determine this
|
static boolean |
isProductionEnvironment()
Check if current deployment is the production environment
|
static boolean |
isSecure(String propertyName,
Class<?> dataObjectClass)
Determines whether a property name should be secured, either based on installed sensitive data patterns, a list
of secure property name patterns, or attributes in the Data Dictionary.
|
static boolean |
isSecure(String propertyName,
List<String> securePropertyNames,
Class<?> dataObjectClass)
Determines whether a property name should be secured, either based on installed sensitive data patterns, a list
of secure property name patterns, or attributes in the Data Dictionary.
|
static String |
joinWithQuotes(List<String> list)
Creates a comma separated String representation of the given list.
|
static void |
logErrors()
Logs the error messages if any in the message map
|
static Class |
materializeClassForProxiedObject(Object object)
Attempts to find the Class for the given potentially proxied object
|
static void |
materializeObjects(Collection possiblyProxiedObjects)
This method runs the KRADUtils.isNotNull() method for each item in a list of BOs.
|
static void |
setObjectProperty(Object bo,
String propertyName,
Class propertyType,
Object propertyValue)
Sets the property of an object with the given value.
|
static void |
setObjectProperty(Object bo,
String propertyName,
Object propertyValue)
Sets the property of an object with the given value.
|
static String |
stripXSSPatterns(String value)
Strips out common patterns used in cross side scripting.
|
static String[] |
stripXSSPatterns(String[] values)
Strips out common patterns used in cross side scripting.
|
static void |
syncClientSideStateForComponent(Component component,
Map<String,Object> clientSideState)
Updates the properties of the given component instance with the value found from the
corresponding map of client state (if found)
|
static Map<String,String> |
translateRequestParameterMap(Map<String,String[]> requestParameters)
Translates the given Map of String keys and String array values to a Map
of String key and values.
|
static String |
translateToMapSafeKey(String key)
Translates characters in the given string like brackets that will cause
problems with binding to characters that do not affect the binding
|
public static final String getBusinessTitleForClass(Class<? extends Object> clazz)
The title is a nicely formatted version of the simple class name.
clazz
- business object classpublic static final List<String> getFileNameFromPath(List<String> fullFileNames)
The different OS path separators are being taken into consideration.
fullFileNames
- file name with pathpublic static final String convertDecimalIntoInteger(KualiDecimal decimalNumber)
Since the return string cannot have decimal point, multiplies the amount by 100 so the decimal places are not lost, for example, 320.15 is converted into 32015.
decimalNumber
- decimal number to be convertedpublic static Integer getIntegerValue(String numberStr)
If the string contains a decimal value everything after the decimal point is dropped.
numberStr
- stringpublic static Object hydrateAttributeValue(Class<?> propertyType, String attributeValue)
propertyType
- the Class to coerce the attributeValue toattributeValue
- the String value to coercepublic static Object createObject(Class<?> clazz, Class<?>[] argumentClasses, Object[] argumentValues)
public static String joinWithQuotes(List<String> list)
For example 'a','b',c'.
list
- public static String getNamespaceCode(Class<? extends Object> clazz)
clazz
- class to get a namespace code forpublic static Map<String,String> getNamespaceAndComponentSimpleName(Class<? extends Object> clazz)
public static Map<String,String> getNamespaceAndComponentFullName(Class<? extends Object> clazz)
public static Map<String,String> getNamespaceAndActionClass(Class<? extends Object> clazz)
public static Map<String,String> convertStringParameterToMap(String parameter)
parameter
- - string parameter to parsepublic static List<String> convertStringParameterToList(String parameter)
parameter
- - string parameter to parsepublic static String translateToMapSafeKey(String key)
key
- - string to translatepublic static String buildMapParameterString(Map<String,String> map)
map
- - map instance to build string forpublic static Map<String,String> getMapFromParameterString(String parameterString)
parameterString
- - string to parse into mappublic static Boolean getRequestParameterAsBoolean(javax.servlet.ServletRequest request, String parameterName)
BooleanFormatter
request
- - servlet request containing parametersparameterName
- - name of parameter to retrieve value forpublic static Map<String,String> translateRequestParameterMap(Map<String,String[]> requestParameters)
requestParameters
- - Map of request parameters to translatepublic static Map<String,String> getParametersFromRequest(List<String> parameterNames, Class<?> parentObjectClass, Map<String,String> requestParameters)
parameterNames
- - names of the parameters whose values should be retrieved
from the requestparentObjectClass
- - object class that contains the parameter names as properties
and should be consulted for security checksrequestParameters
- - all request parameters to pull frompublic static Map<String,String> getPropertyKeyValuesFromDataObject(List<String> propertyNames, Object dataObject)
propertyNames
- the list of property names for which to get key/value pairsdataObject
- the object instance containing the properties for which the values will be pulledpublic static Map<String,String> getPropertyKeyValuesFromDataObject(List<String> propertyNames, List<String> securePropertyNames, Object dataObject)
securePropertyNames
.propertyNames
- the list of property names for which to get key/value pairssecurePropertyNames
- list of additional secure property names to match for encryptiondataObject
- the object instance containing the properties for which the values will be pulledpublic static boolean isSecure(String propertyName, Class<?> dataObjectClass)
propertyName
- the property name to check for securitydataObjectClass
- the class of the object containing this propertypublic static boolean isSecure(String propertyName, List<String> securePropertyNames, Class<?> dataObjectClass)
propertyName
- the property name to check for securitysecurePropertyNames
- the secure property name patterns to checkdataObjectClass
- the class of the object containing this propertypublic static Properties convertMapToProperties(Map<String,String> parameters)
parameters
- - map to convertpublic static Properties convertRequestMapToProperties(Map<String,String[]> requestParameters)
Multiple values for a parameter are joined together with comma delimiter
requestParameters
- - map to convertpublic static Map<String,Object> coerceRequestParameterTypes(Class<?> dataObjectClass, Map<String,String> parameters)
dataObjectClass
- - business object classparameters
- - map of request parameters with field values as String for the fields in the dataObjectClasspublic static boolean containsSensitiveDataPatternMatch(String fieldValue)
The sensitivity of the data is checked by matching it against the sensitive data patterns that are specified in the system parameter table.
fieldValue
- data to be checked for sensitivitypublic static String[] stripXSSPatterns(String[] values)
values
- string array to strip patterns frompublic static String stripXSSPatterns(String value)
value
- string to strip patterns frompublic static final UserSession getUserSessionFromRequest(javax.servlet.http.HttpServletRequest request)
In some cases (different threads) the UserSession cannot be retrieved from GlobalVariables but can still be accessed via the session object
request
- servlet requestpublic static boolean isProductionEnvironment()
public static String getMessageText(ErrorMessage errorMessage, boolean processPrefixSuffix)
errorMessage
- the ErrorMessage object containing the message key(s)processPrefixSuffix
- if true appends the prefix and suffix to the message if they exist on ErrorMessagepublic static void logErrors()
public static String getRequestStringFromMap(Map<String,String> requestParameters)
requestParameters
- the request parameters to use in the stringpublic static void addAttachmentToResponse(javax.servlet.http.HttpServletResponse response, InputStream inputStream, String contentType, String fileName, long fileSize) throws IOException
response
- HttpServletResponse instancecontentType
- the content type of the attachmentinputStream
- the content of the attachmentfileName
- the file name of the attachmentfileSize
- the size of the attachmentIOException
- if attachment to the results fails due to an IO errorpublic static String buildViewUrl(String baseUrl, String controllerMapping, String viewId)
baseUrl
- base url (domain, port)controllerMapping
- mapping for the controller that should be invokedviewId
- id for the view that should be renderedpublic static void cleanRequestParameters(Properties requestParameters)
requestParameters
- properties instance containing the parameters to cleanpublic static String getFullURL(javax.servlet.http.HttpServletRequest request)
request
- the requestpublic static boolean areDifferentDomains(String firstDomain, String secondDomain)
firstDomain
- first URL string to comparesecondDomain
- second URL string to comparepublic static String generateUniqueViewTitle(UifFormBase form, View view)
form
- the formview
- the viewpublic static String buildAttributeTitleString(String prependText, Class<?> element, Map<String,String> keyValueMap)
Each key of the key value map is assumed to be an attribute for the given element class. The label is then retrieved for the attribute from the data dictionary and used in the title (instead of the key)
prependText
- text to prepend to the titleelement
- element class the title is being generated for, used as the parent for getting the key labelskeyValueMap
- map of key value pairs to add to the title textpublic static String getSimpleFieldValue(Object model, Field field)
If the field is a dataField, it will use its propertyName to retrieve a value, otherwise it will try to retrieve textual content out of various component types. If the field is a FieldGroup, only the first component's determined value will be used. This function is used for sorting.
model
- the current modelfield
- the field to get a value frompublic static String convertToHTMLAttributeSafeString(String message)
message
- the string to convertpublic static String generateRowCssClassString(Map<String,String> conditionalRowCssClasses, int lineIndex, boolean isOdd, Map<String,Object> lineContext, ExpressionEvaluator expressionEvaluator)
conditionalRowCssClasses
- the conditionalRowCssClass map, where key is the condition and value is
the class(es)lineIndex
- the line/row indexisOdd
- true if the row is considered oddlineContext
- the lineContext for expressions, pass null if not applicableexpressionEvaluator
- the expressionEvaluator, pass null if not applicablepublic static Class easyGetPropertyType(Object object, String propertyName) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException
object
- An instance of the Class of which we're trying to get the property Class.propertyName
- The name of the property.IllegalAccessException
NoSuchMethodException
InvocationTargetException
public static void setObjectProperty(Object bo, String propertyName, Object propertyValue) throws FormatException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
bo
- business objectpropertyName
- property namepropertyValue
- propery valueIllegalAccessException
InvocationTargetException
NoSuchMethodException
FormatException
public static void setObjectProperty(Object bo, String propertyName, Class propertyType, Object propertyValue) throws FormatException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
bo
- propertyName
- propertyType
- propertyValue
- NoSuchMethodException
InvocationTargetException
IllegalAccessException
FormatException
public static String clean(String string)
string
- public static boolean isNull(Object object)
object
- - any object, proxied or not, materialized or notpublic static boolean isNotNull(Object object)
object
- - any object, proxied or not, materialized or notpublic static Class materializeClassForProxiedObject(Object object)
object
- the potentially proxied object to find the Class ofpublic static void materializeObjects(Collection possiblyProxiedObjects)
possiblyProxiedObjects
- - a Collection of objects that may be proxiespublic static String getNestedAttributePrefix(String attributeName)
attributeName
- public static String getNestedAttributePrimitive(String attributeName)
attributeName
- public static Object getNestedValue(Object bo, String fieldName)
bo
- fieldName
- public static <T> T createNewObjectFromClass(Class<T> clazz)
ExternalizableBusinessObject
, this method will determine the
interface for the EBO and
query the
appropriate module service to create a new instance.clazz
- public static void syncClientSideStateForComponent(Component component, Map<String,Object> clientSideState)
component
- component instance to updateclientSideState
- map of state to sync withCopyright © 2005–2016 The Kuali Foundation. All rights reserved.