Class GrouperClientUtils
java.lang.Object
edu.internet2.middleware.grouperClient.util.GrouperClientCommonUtils
edu.internet2.middleware.grouperClient.util.GrouperClientUtils
utility methods specific to grouper client
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
dont print null fields in reflectionNested classes/interfaces inherited from class edu.internet2.middleware.grouperClient.util.GrouperClientCommonUtils
GrouperClientCommonUtils.CommandResult
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
use this for performance log label for sql queriesFields inherited from class edu.internet2.middleware.grouperClient.util.GrouperClientCommonUtils
DATE_FORMAT, DATE_MINUTES_SECONDS_FORMAT, DATE_MINUTES_SECONDS_NO_SLASH_FORMAT, DEFAULT_BUFFER_SIZE, EMPTY, EMPTY_OBJECT_ARRAY, EMPTY_STRING_ARRAY, INDEX_NOT_FOUND, LOG_ERROR, NOT_FOUND, ONE_GB, ONE_KB, ONE_MB, TIMESTAMP_DASHES_TENTHS_FORMAT, TIMESTAMP_FORMAT, TIMESTAMP_NO_SLASH_FORMAT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
appendQuestions
(int numberOfMarks) append a certain number of question marks to a querystatic void
appendQuestions
(StringBuilder query, int numberOfMarks) append a certain number of question marks to a querystatic String
name of the cache directory without trailing slashstatic String
decryptFromFileIfFileExists
(String pass, StringBuilder logInfo) decrypt a pass from a file if the file exists (i.e.static String
static String
encryptSha
(String plaintext) encrypt a message to SHA with base 64Deprecated.use GrouperClientConfig.retrieveConfig().propertiesOverrideMap() insteadstatic Properties
Deprecated.use GrouperClientConfig.retrieveConfig().properties() insteadstatic HttpCallResponse
httpCall
(String urlSuffix, String serviceAuthn, HttpCallMethod httpCallMethod, String body) call HTTP with a url, optional request body, get a response body.static void
wait for a thread to endstatic Object
jsonConvertFrom
(Map<String, Class<?>> conversionMap, String json) convert an object from json.static String
jsonConvertTo
(Object object, boolean includeObjectNameWrapper) convert object to json, optionally include object name wrapperstatic void
static void
performanceTimingAllDuration
(String key, long durationNanos) static String
popUrlString
(List<String> urlStrings) pop first url string, retrieve, and remove, or null if not therestatic String
propertiesValue
(String key, boolean required) Deprecated.use GrouperClientConfig.retrieveConfig().propertyValueString insteadstatic boolean
propertiesValueBoolean
(String key, boolean defaultValue, boolean required) Deprecated.use GrouperClientConfig.retrieveConfig().propertyValueBoolean insteadstatic int
propertiesValueInt
(String key, int defaultValue, boolean required) Deprecated.GrouperClientConfig.retrieveConfig().propertyValueIntstatic Log
retrieveLog
(Class<?> theClass) static String
subjectAttributeValue
(WsSubject wsSubject, String[] attributeNames, String attributeName) get the attribute value of an attribute name of a subjectstatic String
substituteExpressionLanguage
(String stringToParse, Map<String, Object> variableMap) substitute an EL for objects.static String
substituteExpressionLanguage
(String stringToParse, Map<String, Object> variableMap, boolean allowStaticClasses, boolean silent, boolean lenient, boolean logOnNull) substitute an EL for objectsstatic String
toStringReflection
(Object object) to string reflectionstatic String
toStringReflection
(Object object, Set<String> fieldsToIgnore) to string reflectionstatic String
toStringReflection
(Object object, Set<String> fieldsToIgnore, String extraInfo) to string reflectionMethods inherited from class edu.internet2.middleware.grouperClient.util.GrouperClientCommonUtils
abbreviate, abbreviate, absolutePath, addIfNotThere, append, argAfter, argKey, argMap, argMapBoolean, argMapBoolean, argMapFileList, argMapInteger, argMapList, argMapSet, argMapString, argMapTimestamp, argValue, assertion, assignField, assignField, assignField, assignField, assignField, assignSetter, batchList, batchNumberOfBatches, batchNumberOfBatches, batchNumberOfBatches, batchNumberOfBatches, bigDecimalObjectValue, booleanObjectValue, booleanValue, booleanValue, byteCountToDisplaySize, byteObjectValue, byteValue, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, capitalize, charObjectValue, charValue, classesString, classLoader, className, classNameCollection, clone, cloneFields, cloneValue, closeQuietly, closeQuietly, closeQuietly, closeQuietly, closeQuietly, closeQuietly, closeQuietly, compareObjectFields, computeUrl, construct, contains, contains, contains, convertLongToChar, convertLongToCharSmall, convertLongToString, convertLongToStringSmall, convertToRuntimeException, convertUrlToDriverClassIfNeeded, copy, copy, copy, copy, copy, copyLarge, createParentDirectories, dateToString, dateValue, debugMapIncrementLogEntry, defaultIfBlank, defaultIfEmpty, defaultIfNull, defaultString, defaultString, deleteCreateFile, deleteFile, deleteRecursiveDirectory, doubleObjectValue, doubleObjectValue, doubleValue, doubleValueNoError, endsWith, enumValueOfIgnoreCase, equals, equals, equalsIgnoreCase, escapeUrlDecode, escapeUrlEncode, execCommand, execCommand, execCommand, extensionFromName, field, fieldNames, fieldNames, fieldNames, fieldNames, fields, fields, fieldValue, fieldValue, fieldValue, fieldValue, fileCanonicalPath, fileFromResourceName, fileOrClasspathInputstream, floatObjectValue, floatValue, floatValueNoError, forName, get, getCause, getCause, getFullStackTrace, getter, getterHelper, getterNameFromPropertyName, getters, getThrowables, grouperClientVersion, grouperWsVersionConvert, hasOption, hostname, incrementChar, incrementStringInt, indent, indexOf, indexOf, injectInException, intObjectValue, intValue, intValue, intValueNoError, invokeMethod, invokeMethod, isAscii, isBlank, isBlank, isEmpty, iserNameFromPropertyName, isGetter, isMysql, isNestedThrowable, isNotBlank, isOracle, isPostgres, isScalar, isSetter, isSQLServer, isThrowableNested, isWindows, iterator, jarFile, jarFile, jarVersion, join, join, join, join, join, leftPad, leftPad, leftPad, length, lengthAscii, longObjectValue, longValue, longValue, longValueNoError, manifestProperty, mapDifferences, mapEquals, mapToString, MapToString, method, methodNames, methodsHelper, mkdirs, monthInt, newFileUniqueName, newInstance, newInstance, next, nonNull, nonNull, nonNull, nonNull, nonNull, nullOrBlank, oracleStandardNameFromJava, packInts, parentStemNameFromName, prefixOrSuffix, propertiesCacheClear, propertiesFromFile, propertiesFromResourceName, propertiesFromResourceName, propertiesThreadLocalOverrideMap, propertiesValue, propertiesValue, propertiesValue, propertiesValue, propertiesValueBoolean, propertiesValueBoolean, propertiesValueBoolean, propertiesValueBoolean, propertiesValueInt, propertiesValueInt, propertiesValueInt, propertyName, propertyType, propertyValidateValueBoolean, propertyValidateValueClass, propertyValidateValueInt, propertyValidateValueRequired, propertyValue, readFileIntoString, readFileIntoStringUtf8, readFileToString, readFromFileIfFile, readFromFileIfFileExists, readFromFileIfFileUtf8, readResourceIntoString, readResourceIntoString, remove, remove, removeEnd, removeEnd, renameTo, repeat, replace, replace, replace, replace, replace, replace, replace, replace, replace, replaceWhitespaceWithSpace, responseBodyAsString, retrieveExecutorService, retrievePasswordFromStdin, retrievePasswordFromStdin, rightPad, rightPad, rightPad, rollbackQuietly, saveStringIntoFile, saveStringIntoFile, serializeObjectToFile, setter, setterHelper, setterNameFromPropertyName, setters, setToString, shortObjectValue, shortValue, sleep, split, split, split, split, splitByWholeSeparator, splitByWholeSeparator, splitPreserveAllTokens, splitPreserveAllTokens, splitPreserveAllTokens, splitPreserveAllTokens, splitTrim, splitTrim, splitTrimToList, splitTrimToSet, stringToDate, stringToDate2, stringToTimestamp, stringValue, stringValue, stripEnd, stripLastSlashIfExists, stripPrefix, stripStart, substituteCommonVars, substringAfter, substringAfterLast, substringBefore, substringBeforeLast, suffixAfterChar, timestampToString, toArray, toArray, toList, toListClasses, toListFromCollection, toMap, toSet, toSqlDate, toString, toString, toStringForLog, toStringForLog, toStringForLog, toStringSafe, toTimestamp, trim, trimToEmpty, truncateAscii, typeCast, typeCast, uniqueId, unpackInt, unserializeObjectFromFile, uuid, writeStringToFile
-
Field Details
-
PERFORMANCE_LOG_LABEL_SQL
use this for performance log label for sql queries- See Also:
-
-
Constructor Details
-
GrouperClientUtils
public GrouperClientUtils()
-
-
Method Details
-
main
- Throws:
Exception
-
jsonConvertTo
convert object to json, optionally include object name wrapper- Parameters:
object
-includeObjectNameWrapper
-- Returns:
- the json
-
jsonConvertFrom
convert an object from json. note this works well if there are no collections, just real types, arrays, etc.- Parameters:
conversionMap
- is the class simple name to class of objects which are allowed to be brought back. Note: only the top level object needs to be registeredjson
-- Returns:
- the object
-
performanceTimingAllDuration
- Parameters:
key
-durationNanos
-
-
toStringReflection
to string reflection- Parameters:
object
-- Returns:
- the string representation
-
toStringReflection
public static String toStringReflection(Object object, Set<String> fieldsToIgnore, String extraInfo) to string reflection- Parameters:
object
-- Returns:
- the string representation
-
toStringReflection
to string reflection- Parameters:
object
-- Returns:
- the string representation
-
appendQuestions
append a certain number of question marks to a query- Parameters:
query
-numberOfMarks
-
-
appendQuestions
append a certain number of question marks to a query- Parameters:
query
-numberOfMarks
-
-
retrieveLog
- Parameters:
theClass
-- Returns:
- the log
-
grouperClientOverrideMap
Deprecated.use GrouperClientConfig.retrieveConfig().propertiesOverrideMap() insteadoverride map for properties for testing- Returns:
- the override map
-
grouperClientProperties
Deprecated.use GrouperClientConfig.retrieveConfig().properties() insteadgrouper client properties- Returns:
- the properties
-
propertiesValue
Deprecated.use GrouperClientConfig.retrieveConfig().propertyValueString insteadget a property and validate required from grouper.client.properties- Parameters:
key
-required
-- Returns:
- the value
-
propertiesValueBoolean
@Deprecated public static boolean propertiesValueBoolean(String key, boolean defaultValue, boolean required) Deprecated.use GrouperClientConfig.retrieveConfig().propertyValueBoolean insteadget a boolean and validate from grouper.client.properties- Parameters:
key
-defaultValue
-required
-- Returns:
- the string
-
propertiesValueInt
Deprecated.GrouperClientConfig.retrieveConfig().propertyValueIntget a boolean and validate from grouper.client.properties- Parameters:
key
-defaultValue
-required
-- Returns:
- the string
-
substituteExpressionLanguage
public static String substituteExpressionLanguage(String stringToParse, Map<String, Object> variableMap) substitute an EL for objects. Dont worry if something returns null- Parameters:
stringToParse
-variableMap
-- Returns:
- the string
-
join
wait for a thread to end- Parameters:
thread
-
-
substituteExpressionLanguage
public static String substituteExpressionLanguage(String stringToParse, Map<String, Object> variableMap, boolean allowStaticClasses, boolean silent, boolean lenient, boolean logOnNull) substitute an EL for objects- Parameters:
stringToParse
-variableMap
-allowStaticClasses
- if true allow static classes not registered with contextsilent
- if silent mode, swallow exceptions (warn), and dont warn when variable not foundlenient
- false if undefined variables should throw an exception. if lenient is true (default) then undefined variables are nulllogOnNull
- if null output of substitution should be logged- Returns:
- the string
-
subjectAttributeValue
public static String subjectAttributeValue(WsSubject wsSubject, String[] attributeNames, String attributeName) get the attribute value of an attribute name of a subject- Parameters:
wsSubject
- subjectattributeNames
- list of attribute names in the subjectattributeName
- to query- Returns:
- the value or null
-
encryptKey
- Returns:
- the encrypt key
-
decryptFromFileIfFileExists
decrypt a pass from a file if the file exists (i.e. passes might have slashes in them)- Parameters:
pass
-logInfo
- if not null, put log info in there- Returns:
- the pass
-
cacheDirectoryName
name of the cache directory without trailing slash- Returns:
- the name of the cache directory
-
encryptSha
encrypt a message to SHA with base 64- Parameters:
plaintext
-- Returns:
- the hash
-
httpCall
public static HttpCallResponse httpCall(String urlSuffix, String serviceAuthn, HttpCallMethod httpCallMethod, String body) call HTTP with a url, optional request body, get a response body. this assumes json by default- Parameters:
urlSuffix
- is after the configured URLserviceAuthn
- is the config string that identifies the user/pass/urlhttpCallMethod
- HTTPbody
- to send if applicable- Returns:
- the response
-
popUrlString
pop first url string, retrieve, and remove, or null if not there- Parameters:
urlStrings
-- Returns:
- the string or null if not there
-