|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.internet2.middleware.grouper.ws.util.GrouperServiceUtils
public final class GrouperServiceUtils
Field Summary | |
---|---|
static GrouperSession |
testSession
test session so we can run tests not in a container |
static String |
WS_LITE_OBJECT_TYPE
url param for the classname of a bean |
Method Summary | ||
---|---|---|
static void |
addResponseHeaders(HttpServletResponse response,
String success,
String resultCode,
String resultCode2)
add response headers for a success and response code |
|
static void |
addResponseHeaders(WsResultMeta wsResultMeta,
boolean isSoap)
add response headers for a success and response code will retrieve the response object from threadlocal |
|
static int |
arrayLengthAtLeastOne(Object[] objects,
String configNameOfMax,
int defaultMax,
String label)
get array length, make sure at least 1 |
|
static Boolean |
booleanObjectValue(String input,
String paramName)
parse a boolean as "T" or "F" or "TRUE" or "FALSE" case insensitive. |
|
static String |
booleanToStringOneChar(Boolean theBoolean)
convert a boolean to a T or F |
|
static boolean |
booleanValue(String input,
boolean defaultValue,
String paramName)
parse a boolean as "T" or "F" or "TRUE" or "FALSE" case insensitive. |
|
static String[] |
calculateSubjectAttributes(String[] requestedAttributes,
boolean includeSubjectDetailBoolean)
|
|
static ClassLoader |
classLoader()
fast class loader |
|
static URL |
computeUrl(String resourceName,
boolean canBeNull)
compute a url of a resource |
|
static Set<Privilege> |
convertAccessPrivilegesToPrivileges(Set<AccessPrivilege> accessPrivileges)
convert a set of access privileges to privileges |
|
static AttributeAssignDelegatable |
convertAttributeAssignDelegatable(String attributeAssignDelegatable)
convert the AttributeAssignDelegatable, default to null |
|
static AttributeAssignOperation |
convertAttributeAssignOperation(String attributeAssignOperation)
convert the attributeAssignOperation, default to null |
|
static AttributeAssignType |
convertAttributeAssignType(String attributeAssignType)
convert the attributeAssignType, default to null |
|
static AttributeAssignValueOperation |
convertAttributeAssignValueOperation(String attributeAssignValueOperation)
convert the attributeAssignValueOperation, default to null |
|
static GrouperVersion |
convertGrouperWsVersion(String theVersion)
convert the version safely with a descriptive message. |
|
static Map<String,Object> |
convertLimitsToMap(WsPermissionEnvVar[] limitEnvParams)
if wrong size or a name is blank, then throw descriptive exception. |
|
static WsMemberFilter |
convertMemberFilter(String memberFilter)
convert the member filter, default to all |
|
static Map<String,String> |
convertParamsToMap(WsParam[] params)
if wrong size or a name is blank, then throw descriptive exception. |
|
static PermissionAssignOperation |
convertPermissionAssignOperation(String permissionAssignOperation)
convert the permissionAssignOperation, default to null |
|
static PermissionType |
convertPermissionType(String permissionType)
convert the permissionType, default to null |
|
static Map<String,String> |
convertQueryStringToMap(String queryString)
convert a query string to a map (for testing purposes only, in a real system the HttpServletRequest would be used. |
|
static SaveMode |
convertSaveMode(String theSaveMode)
convert the save mode safely with a descriptive message |
|
static Member |
convertSubjectToMember(GrouperSession session,
Subject subject)
convert a subject to a member, throw an invalid query exception if there is a problem, with a descriptive cause |
|
static GrouperTransactionType |
convertTransactionType(String txTypeString)
convert the tx type safely with a descriptive message |
|
static Class<?> |
currentServiceClass()
|
|
static String |
dateToString(Date date)
convert a date to a string using the standard web service pattern yyyy/MM/dd HH:mm:ss.SSS Note that HH is 0-23 |
|
static
|
enumValueOfIgnoreCase(Class<E> theEnumClass,
String string,
boolean exceptionOnNotFound)
do a case-insensitive matching |
|
static String |
extractSubjectInfoFromUrlStrings(List<String> urlStrings,
int startIndex,
boolean sourceIdOrSubjectId,
boolean removeSubjectUrlStrings)
from url strings, get the subjectId e.g. |
|
static String |
fieldName(Field field)
get null safe field name from field |
|
static File |
fileFromResourceName(String resourceName)
get a file name from a resource name |
|
static
|
firstInArrayOfOne(T[] array)
take an array. |
|
static String |
formatHttp(String http)
take an http request and format it (assume xml or json) |
|
static WsPermissionEnvVar[] |
limitEnvVars(String limitEnvVarName0,
String limitEnvVarValue0,
String limitEnvVarType0,
String limitEnvVarName1,
String limitEnvVarValue1,
String limitEnvVarType1)
organize limit env vars |
|
static Object |
marshalHttpParamsToObject(Map<String,String> paramMap,
HttpServletRequest httpServletRequest,
StringBuilder warnings)
take http params and put into an object (type is specified in the http params object if there is an object specified) |
|
static String |
marshalLiteBeanToQueryString(Object object,
boolean convertNullToEmpty,
boolean includeClassName)
convert a bean to a query string (including bean type) |
|
static
|
nullArray(T[] array)
see if array is empty or size 0 or size 1 with null inside |
|
static WsParam[] |
params(String paramName0,
String paramValue0,
String paramName1,
String paramValue1)
organize params |
|
static String |
pickOne(String first,
String second,
boolean allowBlank,
String reasonFieldName)
pick one of the values which is not null or empty. |
|
static String |
popUrlString(List<String> urlStrings)
pop first url string, retrieve, and remove, or null if not there |
|
static Field |
retrieveField(String fieldName)
convert a fieldName into a Field |
|
static GrouperSession |
retrieveGrouperSession(WsSubjectLookup actAsSubjectLookup)
convert the actAsSubjectLookup (and the currently logged in user) to a grouper session |
|
static GroupType |
retrieveGroupType(String groupTypeName)
retrieve group type based on name |
|
static Date |
stringToDate(String dateString)
convert a string to a date using the standard web service pattern Note that HH is 0-23 |
|
static Timestamp |
stringToTimestamp(String timestampString)
convert a string to a date using the standard web service pattern Note that HH is 0-23 |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String WS_LITE_OBJECT_TYPE
public static GrouperSession testSession
Method Detail |
---|
public static Class<?> currentServiceClass()
public static URL computeUrl(String resourceName, boolean canBeNull)
resourceName
- canBeNull
- if cant be null, throw runtime
public static ClassLoader classLoader()
public static File fileFromResourceName(String resourceName)
resourceName
- is the classpath location
public static GroupType retrieveGroupType(String groupTypeName)
groupTypeName
-
public static <E extends Enum<?>> E enumValueOfIgnoreCase(Class<E> theEnumClass, String string, boolean exceptionOnNotFound) throws GrouperRestInvalidRequest
E
- generic typetheEnumClass
- class of the enumstring
- exceptionOnNotFound
- true if exception should be thrown on not found
GrouperRestInvalidRequest
- if there is a problempublic static String popUrlString(List<String> urlStrings)
urlStrings
-
public static String extractSubjectInfoFromUrlStrings(List<String> urlStrings, int startIndex, boolean sourceIdOrSubjectId, boolean removeSubjectUrlStrings)
from url strings, get the subjectId e.g. if the url is: /groups/aStem:aGroup/members/123412345 then the index should be 3 (0 for group, 1 for group name, etc) if url is: /groups/aStem:aGroup/members/sourceId/someSource/subjectId/123412345 then index is still 3
urlStrings
- startIndex
- removeSubjectUrlStrings
- true to remove these url strings after getting datasourceIdOrSubjectId
- true to get sourceId, false to get subjectId
public static String pickOne(String first, String second, boolean allowBlank, String reasonFieldName)
first
- second
- allowBlank
- if ok if blank (return null)reasonFieldName
- if not ok to be blank and both blank, then put this in error.
or if both set to different things, then put this in error
WsInvalidQueryException
- if there is a problem with the reason text in therepublic static Object marshalHttpParamsToObject(Map<String,String> paramMap, HttpServletRequest httpServletRequest, StringBuilder warnings)
paramMap
- httpServletRequest
- if not null, make sure no dupes. if null, forget itwarnings
- is the warnings, if null, just throw exception
public static Map<String,String> convertQueryStringToMap(String queryString)
queryString
-
public static String marshalLiteBeanToQueryString(Object object, boolean convertNullToEmpty, boolean includeClassName)
object
- convertNullToEmpty
- is true to convert null to empty, false to exclude nullsincludeClassName
- true to include the classname in the params
public static String formatHttp(String http)
http
-
public static String fieldName(Field field)
field
-
public static <T> T firstInArrayOfOne(T[] array)
T
- array
- is the array to interrogate
public static Member convertSubjectToMember(GrouperSession session, Subject subject)
session
- subject
-
public static WsMemberFilter convertMemberFilter(String memberFilter) throws WsInvalidQueryException
memberFilter
-
WsInvalidQueryException
- if there is a problempublic static AttributeAssignType convertAttributeAssignType(String attributeAssignType) throws WsInvalidQueryException
attributeAssignType
-
WsInvalidQueryException
- if there is a problempublic static PermissionType convertPermissionType(String permissionType) throws WsInvalidQueryException
permissionType
-
WsInvalidQueryException
- if there is a problempublic static AttributeAssignOperation convertAttributeAssignOperation(String attributeAssignOperation) throws WsInvalidQueryException
attributeAssignOperation
-
WsInvalidQueryException
- if there is a problempublic static PermissionAssignOperation convertPermissionAssignOperation(String permissionAssignOperation) throws WsInvalidQueryException
permissionAssignOperation
-
WsInvalidQueryException
- if there is a problempublic static AttributeAssignDelegatable convertAttributeAssignDelegatable(String attributeAssignDelegatable) throws WsInvalidQueryException
attributeAssignDelegatable
-
WsInvalidQueryException
- if there is a problempublic static AttributeAssignValueOperation convertAttributeAssignValueOperation(String attributeAssignValueOperation) throws WsInvalidQueryException
attributeAssignValueOperation
-
WsInvalidQueryException
- if there is a problempublic static GrouperTransactionType convertTransactionType(String txTypeString) throws WsInvalidQueryException
txTypeString
-
WsInvalidQueryException
public static SaveMode convertSaveMode(String theSaveMode) throws WsInvalidQueryException
theSaveMode
-
WsInvalidQueryException
public static GrouperVersion convertGrouperWsVersion(String theVersion) throws WsInvalidQueryException
theVersion
-
WsInvalidQueryException
public static GrouperSession retrieveGrouperSession(WsSubjectLookup actAsSubjectLookup)
actAsSubjectLookup
-
public static int arrayLengthAtLeastOne(Object[] objects, String configNameOfMax, int defaultMax, String label) throws WsInvalidQueryException
objects
- to countconfigNameOfMax
- is the config name of grouper-ws.properties where the max number of subjects isdefaultMax
- is the default if not in the config filelabel
- for error
WsInvalidQueryException
- if array is null or size 0 or more than maxpublic static Map<String,String> convertParamsToMap(WsParam[] params) throws WsInvalidQueryException
params
-
WsInvalidQueryException
- if problem with inputspublic static Map<String,Object> convertLimitsToMap(WsPermissionEnvVar[] limitEnvParams) throws WsInvalidQueryException
limitEnvParams
-
WsInvalidQueryException
- if problem with inputspublic static String[] calculateSubjectAttributes(String[] requestedAttributes, boolean includeSubjectDetailBoolean)
requestedAttributes
- requestedAttributesLength
- includeSubjectDetailBoolean
-
public static String booleanToStringOneChar(Boolean theBoolean)
theBoolean
-
public static boolean booleanValue(String input, boolean defaultValue, String paramName) throws WsInvalidQueryException
input
- defaultValue
- paramName
- to put in the invalid query exception
WsInvalidQueryException
- if there is a problempublic static Boolean booleanObjectValue(String input, String paramName) throws WsInvalidQueryException
input
- paramName
- to put in the invalid query exception
WsInvalidQueryException
- if there is a problempublic static Field retrieveField(String fieldName)
fieldName
- name of field
public static String dateToString(Date date)
date
-
public static Date stringToDate(String dateString)
dateString
-
public static Timestamp stringToTimestamp(String timestampString)
timestampString
-
public static WsParam[] params(String paramName0, String paramValue0, String paramName1, String paramValue1)
paramName0
- paramValue0
- paramName1
- paramValue1
-
public static WsPermissionEnvVar[] limitEnvVars(String limitEnvVarName0, String limitEnvVarValue0, String limitEnvVarType0, String limitEnvVarName1, String limitEnvVarValue1, String limitEnvVarType1)
limitEnvVarName0
- limitEnvVars if processing limits, pass in a set of limits. The name is the
name of the variable, and the value is the value. Note, you can typecast the
values by putting a valid type in parens in front of the param name. e.g.
name: (int)amount, value: 50limitEnvVarValue0
- first limit env var valuelimitEnvVarType0
- first limit env var typelimitEnvVarName1
- second limit env var namelimitEnvVarValue1
- second limit env var valuelimitEnvVarType1
- second limit env var type
public static Set<Privilege> convertAccessPrivilegesToPrivileges(Set<AccessPrivilege> accessPrivileges)
accessPrivileges
-
public static void addResponseHeaders(HttpServletResponse response, String success, String resultCode, String resultCode2)
response
- success
- T or FresultCode
- resultCode2
- public static void addResponseHeaders(WsResultMeta wsResultMeta, boolean isSoap)
wsResultMeta
- result metadataisSoap
- if soappublic static <T> boolean nullArray(T[] array)
T
- array
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |