Class Quietly
- java.lang.Object
-
- com.identityworksllc.iiq.common.Quietly
-
public class Quietly extends Object
Utilities to quietly (i.e.without throwing an exception) invoke certain common operations. This prevents the need to write try/catch boilerplate. In most cases, the methods will return a sensible default (either null or an empty value) when the operation fails.
Exceptions will be logged at info level.
-
-
Constructor Summary
Constructors Constructor Description Quietly()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
close(Closeable thing)
Closes the thing quietlystatic void
close(AutoCloseable thing)
Closes the thing quietlystatic <SpoType extends sailpoint.object.SailPointObject>
SpoTypegetObject(sailpoint.api.SailPointContext context, Class<SpoType> objectType, String idOrName)
Quietly gets a Sailpoint objectIf the idOrName parameter is null, or if the retrieval throws an exception, this method returns null.
static <SpoType extends sailpoint.object.SailPointObject>
SpoTypegetObjectById(sailpoint.api.SailPointContext context, Class<SpoType> objectType, String id)
Quietly gets a Sailpoint objectIf the idOrName parameter is null, or if the retrieval throws an exception, this method returns null.
static <SpoType extends sailpoint.object.SailPointObject>
SpoTypegetObjectByName(sailpoint.api.SailPointContext context, Class<SpoType> objectType, String name)
Quietly gets a Sailpoint objectIf the idOrName parameter is null, or if the retrieval throws an exception, this method returns null.
static <T> void
invoke(T input, Functions.ConsumerWithError<? super T> action)
Performs the action, logging and swallowing any exceptionsstatic <In,Out>
OutinvokeWithOutput(In input, Functions.FunctionWithError<? super In,? extends Out> action)
Performs the action, logging and swallowing any exceptions.static <In,In2,Out>
OutinvokeWithOutput(In input, In2 input2, Functions.BiFunctionWithError<? super In,? super In2,Out> action)
Performs the action, logging and swallowing any exceptionsstatic void
rollback(Connection connection)
Rolls back the connection quietlystatic <SpoType extends sailpoint.object.SailPointObject>
Iterator<SpoType>search(sailpoint.api.SailPointContext context, Class<SpoType> objectType, sailpoint.object.QueryOptions qo)
Quietly searches for and returns an iterator of Sailpoint objects.static <SpoType extends sailpoint.object.SailPointObject>
Iterator<Object[]>search(sailpoint.api.SailPointContext context, Class<SpoType> objectType, sailpoint.object.QueryOptions qo, List<String> columns)
Quietly searches for and returns an iterator of Object[] projections.
-
-
-
Constructor Detail
-
Quietly
public Quietly()
-
-
Method Detail
-
close
public static void close(Closeable thing)
Closes the thing quietly- Parameters:
thing
- The thing to close
-
close
public static void close(AutoCloseable thing)
Closes the thing quietly- Parameters:
thing
- The thing to close
-
getObject
public static <SpoType extends sailpoint.object.SailPointObject> SpoType getObject(sailpoint.api.SailPointContext context, Class<SpoType> objectType, String idOrName)
Quietly gets a Sailpoint objectIf the idOrName parameter is null, or if the retrieval throws an exception, this method returns null.
This is in addition to the cases where getObject() already returns null, such as if the object doesn’t exist.
- Type Parameters:
SpoType
- On failures- Parameters:
context
- The IIQ context to use for retrievalobjectType
- The SailPointObject class to retrieveidOrName
- The ID or name of the object- Returns:
- The object, or null in the situations described above
- See Also:
Resolver.getObject(Class, String)
-
getObjectById
public static <SpoType extends sailpoint.object.SailPointObject> SpoType getObjectById(sailpoint.api.SailPointContext context, Class<SpoType> objectType, String id)
Quietly gets a Sailpoint objectIf the idOrName parameter is null, or if the retrieval throws an exception, this method returns null.
This is in addition to the cases where getObjectById() already returns null, such as if the object doesn’t exist.
- Type Parameters:
SpoType
- On failures- Parameters:
context
- The IIQ context to use for retrievalobjectType
- The SailPointObject class to retrieveid
- The ID of the object- Returns:
- The object, or null in the situations described above
- See Also:
PersistenceManager.getObjectById(Class, String)
-
getObjectByName
public static <SpoType extends sailpoint.object.SailPointObject> SpoType getObjectByName(sailpoint.api.SailPointContext context, Class<SpoType> objectType, String name)
Quietly gets a Sailpoint objectIf the idOrName parameter is null, or if the retrieval throws an exception, this method returns null.
This is in addition to the cases where getObjectByName() already returns null, such as if the object doesn’t exist.
- Type Parameters:
SpoType
- On failures- Parameters:
context
- The IIQ context to use for retrievalobjectType
- The SailPointObject class to retrievename
- The ID of the object- Returns:
- The object, or null in the situations described above
- See Also:
PersistenceManager.getObjectByName(Class, String)
-
invoke
public static <T> void invoke(T input, Functions.ConsumerWithError<? super T> action)
Performs the action, logging and swallowing any exceptions- Type Parameters:
T
- The type of the input object- Parameters:
input
- The input objectaction
- The action to perform on the input object
-
invokeWithOutput
public static <In,In2,Out> Out invokeWithOutput(In input, In2 input2, Functions.BiFunctionWithError<? super In,? super In2,Out> action)
Performs the action, logging and swallowing any exceptions- Type Parameters:
In
- The type of the input object- Parameters:
input
- The input objectinput2
- The second input objectaction
- The action to perform on the input object
-
invokeWithOutput
public static <In,Out> Out invokeWithOutput(In input, Functions.FunctionWithError<? super In,? extends Out> action)
Performs the action, logging and swallowing any exceptions.- Type Parameters:
In
- The type of the input objectOut
- The type of the output object- Parameters:
input
- The input objectaction
- The action to perform on the input object- Returns:
- Either the result of the computation, if it was error-free, or null
-
rollback
public static void rollback(Connection connection)
Rolls back the connection quietly- Parameters:
connection
- The conection to roll back
-
search
public static <SpoType extends sailpoint.object.SailPointObject> Iterator<SpoType> search(sailpoint.api.SailPointContext context, Class<SpoType> objectType, sailpoint.object.QueryOptions qo)
Quietly searches for and returns an iterator of Sailpoint objects.If this set is expected to be large, you should use IncrementalObjectIterator instead and just deal with the exceptions.
All exceptions on search will be swallowed.
This method never returns null, but may return an empty iterator.
- Type Parameters:
SpoType
- The SPO type- Parameters:
context
- The IIQ contextobjectType
- The IIQ object type to searchqo
- The QueryOptions containing the search criteria- Returns:
- An Iterator containing the search results
- See Also:
PersistenceManager.search(Class, QueryOptions)
,IncrementalObjectIterator
-
search
public static <SpoType extends sailpoint.object.SailPointObject> Iterator<Object[]> search(sailpoint.api.SailPointContext context, Class<SpoType> objectType, sailpoint.object.QueryOptions qo, List<String> columns)
Quietly searches for and returns an iterator of Object[] projections.If this set is expected to be large, you should use IncrementalProjectorIterator instead and just deal with the exceptions.
All exceptions on search will be swallowed.
This method never returns null, but may return an empty iterator.
- Type Parameters:
SpoType
- The SPO type- Parameters:
context
- The IIQ contextobjectType
- The IIQ object type to searchqo
- The QueryOptions containing the search criteriacolumns
- The columns to return in the projection- Returns:
- An Iterator containing the search results
- See Also:
PersistenceManager.search(Class, QueryOptions, List)
,IncrementalProjectionIterator
-
-