Class 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 quietly
      static void close​(AutoCloseable thing)
      Closes the thing quietly
      static <SpoType extends sailpoint.object.SailPointObject>
      SpoType
      getObject​(sailpoint.api.SailPointContext context, Class<SpoType> objectType, String idOrName)
      Quietly gets a Sailpoint object

      If the idOrName parameter is null, or if the retrieval throws an exception, this method returns null.

      static <SpoType extends sailpoint.object.SailPointObject>
      SpoType
      getObjectById​(sailpoint.api.SailPointContext context, Class<SpoType> objectType, String id)
      Quietly gets a Sailpoint object

      If the idOrName parameter is null, or if the retrieval throws an exception, this method returns null.

      static <SpoType extends sailpoint.object.SailPointObject>
      SpoType
      getObjectByName​(sailpoint.api.SailPointContext context, Class<SpoType> objectType, String name)
      Quietly gets a Sailpoint object

      If 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 exceptions
      static <In,​Out>
      Out
      invokeWithOutput​(In input, Functions.FunctionWithError<? super In,​? extends Out> action)
      Performs the action, logging and swallowing any exceptions.
      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
      static void rollback​(Connection connection)
      Rolls back the connection quietly
      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.
      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

    • 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 object

        If 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 retrieval
        objectType - The SailPointObject class to retrieve
        idOrName - 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 object

        If 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 retrieval
        objectType - The SailPointObject class to retrieve
        id - 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 object

        If 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 retrieval
        objectType - The SailPointObject class to retrieve
        name - 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 object
        action - 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 object
        input2 - The second input object
        action - 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 object
        Out - The type of the output object
        Parameters:
        input - The input object
        action - 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 context
        objectType - The IIQ object type to search
        qo - 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 context
        objectType - The IIQ object type to search
        qo - The QueryOptions containing the search criteria
        columns - The columns to return in the projection
        Returns:
        An Iterator containing the search results
        See Also:
        PersistenceManager.search(Class, QueryOptions, List), IncrementalProjectionIterator