Class AMAdminUtils
- java.lang.Object
-
- com.sun.identity.console.base.model.AMAdminUtils
-
public class AMAdminUtils extends Object
This provides a set helper methods to access Access and Service Management SDKs.
-
-
Constructor Summary
Constructors Constructor Description AMAdminUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static MapcloneStringToSetMap(Map orig)Returns a clone map of String to Set.static SetgetAttribute(ServiceSchemaManager svcSchemaMgr, SchemaType type, String attribute)Returns the default value of an attribute from the service schema.static AttributeSchemagetAttributeSchema(String serviceName, SchemaType schemaType, String subSchemaName, String attributeName)Returns attribute schema object.static SetgetDelimitedValues(String deString, String delimiter)Returns a set of string from a delimited string.static SetgetDisplayableAttributeNames(String serviceName, SchemaType schemaType)Returns a set of attribute schemas that can be displayed in console for a service of a given schema type.static StringgetFirstElement(Set set)Returns the firstStringelement from the given set.static InputStreamgetInputStreamFromString(String buff)static intgetInt(Set set, int defaultValue)Returns integer value of a item in a set.static intgetIntegerAttribute(ServiceSchemaManager svcSchemaMgr, SchemaType type, String attribute)Returns the integer value of an attribute.static intgetIntValue(Set set, int defaultValue)Returns the first value of a set.static StringgetParent(String dn)Returns the parent DN for the given DN.static ServiceSchemagetSchemaSchema(String serviceName, IdType idType)Returns service schema for an IdType.static StringgetSearchResultWarningMessage(SearchResults results, AMModel model)Gets search results warning message.static StringgetString(Collection collection, String delimiter, boolean reverse)Returns a concatenation string of all entries in a collection.static StringgetStringAttribute(ServiceSchemaManager svcSchemaMgr, SchemaType type, String attribute)Returns the string value of an attribute.static StringgetStringFromInputStream(InputStream is)static SSOTokengetSuperAdminSSOToken()Returns the Single-Sign-On Token of super administrator.static SetgetUserAttributeNames()static ObjectgetValue(Collection collection)Returns the first value of a collection.static MapgetValuesFromDelimitedString(String deString, String delimiter)Returns a map of String of String from a delimited string.static SetlowerCase(Set set)static voidmakeMapValuesEmpty(Map map)static ListorderByStringLength(Collection collection)Returns a list of strings in the order of string length.static voidremoveAllByDN(Set<String> originalSet, Collection<String> toDelete)Removes all matching entries from a set if entries exist in another set.static voidremoveAllCaseIgnore(Set master, Set deletingSet)Removes a set of string entries in a set with case insensitivity check.static voidremoveMapEntries(Map map, Set set)Removes the mapping of which keys matches with items in a given set.static StringreplaceString(String string, String orig, String substitution)Replaces character/s in a string with another.static ListreplaceString(List list, String orig, String substitution)Replaces character/s in a string with anotherstatic ListtoList(com.iplanet.jato.view.html.OptionList optList)static ListtoList(Object[] array)Returns a list that contains all items in array.static SettoOrderedSet(Object[] array)Returns a set that contains all items in array.static Set<String>toSet(Object... array)Returns a set that contains all items in array, converted to trimmed strings.static Set<String>toSetIgnoreEmpty(Object... items)Converts an array of objects into a set of strings by calling theObject.toString()method on each item and trimming the result.static MapupCaseKeys(Map map)Returns a map of upper cased keys.static SetwrapInSet(Object obj)Returns a hash set containing a given object.
-
-
-
Method Detail
-
getSuperAdminSSOToken
public static final SSOToken getSuperAdminSSOToken() throws SecurityException
Returns the Single-Sign-On Token of super administrator.- Returns:
- Single-Sign-On Token of super administrator.
- Throws:
SecurityException- if security check fails.
-
getValue
public static Object getValue(Collection collection)
Returns the first value of a collection. Returns empty string if set is collection or null.- Parameters:
collection- Collection to act on.
-
getIntValue
public static int getIntValue(Set set, int defaultValue) throws NumberFormatException
Returns the first value of a set. Returns -1 if set is empty or null. Returns int equals of the string.- Parameters:
set- Set to act on.defaultValue- Default Value of set is empty.- Throws:
NumberFormatException- if the item in the set is not an integer
-
wrapInSet
public static Set wrapInSet(Object obj)
Returns a hash set containing a given object.- Parameters:
obj- Object to be added in set.- Returns:
- a hash set containing a given object.
-
toSet
public static Set<String> toSet(Object... array)
Returns a set that contains all items in array, converted to trimmed strings.- Parameters:
array- Array which contains the items.- Returns:
- a set that contains all items in array.
- Throws:
NullPointerException- if any item in the array is null.
-
toSetIgnoreEmpty
public static Set<String> toSetIgnoreEmpty(Object... items)
Converts an array of objects into a set of strings by calling theObject.toString()method on each item and trimming the result. If the item's trimmed string is empty then it is excluded from the set.- Parameters:
items- array of items to add to the set.- Returns:
- a set of all items in the array, converted to trimmed strings. Excludes any empty string elements.
- Throws:
NullPointerException- if any item in the array is null.
-
toOrderedSet
public static Set toOrderedSet(Object[] array)
Returns a set that contains all items in array.- Parameters:
array- Array which contains the items.- Returns:
- a set that contains all items in array.
-
toList
public static List toList(Object[] array)
Returns a list that contains all items in array.- Parameters:
array- Array which contains the items.- Returns:
- a list that contains all items in array.
-
getInt
public static int getInt(Set set, int defaultValue) throws NumberFormatException
Returns integer value of a item in a set.- Parameters:
set- Set that contains the item.defaultValue- default value if set is null or empty.- Returns:
- integer value of a item in a set.
- Throws:
NumberFormatException- if the item in the set in non integer.
-
removeMapEntries
public static void removeMapEntries(Map map, Set set)
Removes the mapping of which keys matches with items in a given set.- Parameters:
map- Map object.set- Set of keys to be removed frommap.
-
upCaseKeys
public static Map upCaseKeys(Map map)
Returns a map of upper cased keys.- Parameters:
map- Map to operate on.- Returns:
- a map of upper cased keys.
-
getIntegerAttribute
public static int getIntegerAttribute(ServiceSchemaManager svcSchemaMgr, SchemaType type, String attribute) throws NumberFormatException, SMSException
Returns the integer value of an attribute.- Parameters:
svcSchemaMgr- service schema managertype- schema typeattribute- name- Returns:
- string value of an attribute
- Throws:
NumberFormatException- if value is not numericSMSException- if operation fails
-
getAttribute
public static Set getAttribute(ServiceSchemaManager svcSchemaMgr, SchemaType type, String attribute) throws SMSException
Returns the default value of an attribute from the service schema.- Parameters:
svcSchemaMgr- Service schema manager.type- Schema type.attribute- Attribute name.- Returns:
- values of service schema attribute.
- Throws:
SMSException- if operations fails.
-
getStringFromInputStream
public static String getStringFromInputStream(InputStream is)
-
getInputStreamFromString
public static InputStream getInputStreamFromString(String buff)
-
removeAllCaseIgnore
public static void removeAllCaseIgnore(Set master, Set deletingSet)
Removes a set of string entries in a set with case insensitivity check.- Parameters:
master- Master Set.deletingSet- Set that contains strings to be removed from master set.
-
getParent
public static String getParent(String dn)
Returns the parent DN for the given DN.- Parameters:
dn- name of the child object- Returns:
- parent of
dn
-
getFirstElement
public static String getFirstElement(Set set)
Returns the firstStringelement from the given set. If the set is empty, or null, an empty string will be returned.- Parameters:
set- where element resides- Returns:
- first String element from the set.
-
getSearchResultWarningMessage
public static String getSearchResultWarningMessage(SearchResults results, AMModel model)
Gets search results warning message.SearchResultreturns an error code whenever size or time limit is reached. This method interprets the error code and return the appropriate warning message. Empty string is returned if no limits are reached.- Parameters:
results- Access Management Search Result object.model- to retrieve localized string.- Returns:
- search results warning message.
-
getString
public static String getString(Collection collection, String delimiter, boolean reverse)
Returns a concatenation string of all entries in a collection.- Parameters:
collection- Collection.delimiter- Delimiterreverse- true to traversal the entries from bottom up.- Returns:
- a concatenation string of all entries in a collection.
-
getStringAttribute
public static String getStringAttribute(ServiceSchemaManager svcSchemaMgr, SchemaType type, String attribute) throws SMSException
Returns the string value of an attribute.- Parameters:
svcSchemaMgr- service schema managertype- schema typeattribute- name- Returns:
- string value of an attribute
- Throws:
SMSException- if operation fails
-
replaceString
public static String replaceString(String string, String orig, String substitution)
Replaces character/s in a string with another.- Parameters:
string- String to work on.orig- Original character/s.substitution- Substitution.- Returns:
- Manipulated string.
-
replaceString
public static List replaceString(List list, String orig, String substitution)
Replaces character/s in a string with another- Parameters:
list- List of string.orig- Original character/s.substitution- Substitution.- Returns:
- Manipulated list.
-
getValuesFromDelimitedString
public static Map getValuesFromDelimitedString(String deString, String delimiter)
Returns a map of String of String from a delimited string. Examplekey1=x|key2=y.- Parameters:
deString- Delimited Stringdelimiter- Delimiter.- Returns:
- a map of String of String from a delimited string.
-
getDelimitedValues
public static Set getDelimitedValues(String deString, String delimiter)
Returns a set of string from a delimited string. Exampleval1,val2,...,valN.- Parameters:
deString- Delimited Stringdelimiter- Delimiter.- Returns:
- Set of string from a delimited string.
-
getAttributeSchema
public static AttributeSchema getAttributeSchema(String serviceName, SchemaType schemaType, String subSchemaName, String attributeName)
Returns attribute schema object.- Parameters:
serviceName- Name of service.schemaType- Type of Schema.subSchemaName- Name of sub schema.attributeName- Name of attribute schema.- Returns:
- attribute schema object.
-
getDisplayableAttributeNames
public static Set getDisplayableAttributeNames(String serviceName, SchemaType schemaType)
Returns a set of attribute schemas that can be displayed in console for a service of a given schema type.- Parameters:
serviceName- Name of Service.schemaType- Schema Type.- Returns:
- set of attribute schemas that can be displayed in console.
-
getSchemaSchema
public static ServiceSchema getSchemaSchema(String serviceName, IdType idType)
Returns service schema for an IdType.- Parameters:
serviceName- Name of Service.idType- IdType.- Returns:
- service schema for an IdType.
-
makeMapValuesEmpty
public static void makeMapValuesEmpty(Map map)
-
toList
public static List toList(com.iplanet.jato.view.html.OptionList optList)
-
orderByStringLength
public static List orderByStringLength(Collection collection)
Returns a list of strings in the order of string length. Longest string is in front of the list.- Parameters:
collection- Collections of String.- Returns:
- a list of strings in the order of string length.
-
cloneStringToSetMap
public static Map cloneStringToSetMap(Map orig)
Returns a clone map of String to Set.- Parameters:
orig- Map to be cloned.- Returns:
- cloned map.
-
removeAllByDN
public static void removeAllByDN(Set<String> originalSet, Collection<String> toDelete)
Removes all matching entries from a set if entries exist in another set. entries in the sets are LDAP entries.- Parameters:
originalSet- Original Set.toDelete- Collection of entries to be deleted.
-
getUserAttributeNames
public static Set getUserAttributeNames()
-
-