Interface IPersistenceService

All Superinterfaces:
LocalDirectoryInfo, LocalDirectoryInfo2

public interface IPersistenceService extends LocalDirectoryInfo2
Provides CRUD access to the underlying persistence engine of your Jans Server installation.

To obtain an instance object that implements this interface, use method Utils.managedBean(Class).

Author:
jgomer
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> boolean
    add(T object)
    Adds an entry in the underlying persistence engine.
    <T> int
    count(T object)
    Similar to find(Object) search except it only returns the amount of matching objects.
    <T> boolean
    delete(T object)
    Deletes the entry represented by parameter object from the persistence engine.
    <T> List<T>
    find(Class<T> clazz, String baseDn, io.jans.orm.search.filter.Filter filter)
    Builds a List of objects of type T from a search (with scope of SUB) using baseDn as search base; this type of search accounts for the entry referenced at baseDn and any subordinate entries to any depth.
    <T> List<T>
    find(Class<T> clazz, String baseDn, io.jans.orm.search.filter.Filter filter, int start, int count)
    Performs a search as method find(Class, String, Filter) does except the first start elements are skipped and at most count results are included in the returned list
    <T> List<T>
    find(Class<T> clazz, String baseDn, io.jans.orm.search.filter.Filter filter, int start, int count, io.jans.orm.model.SearchScope searchScope)
    Performs a search as method find(Class, String, Filter) does except the first start elements are skipped and at most count results are included in the returned list
    <T> List<T>
    find(T object)
    Builds a List of objects of type T from a search (with scope of SUB) using as search base the field annotated with io.jans.orm.annotation.DN in the object passed as parameter; this type of search accounts for the entry referenced at the search base and any subordinate entries to any depth.
    <T> T
    get(Class<T> clazz, String dn)
    Retrieves the object representing the entry at the provided DN location.
    <T> boolean
    modify(T object)
    Stores a previously obtained object (via get or find) - and potentially modified - into the persistence engine.
  • Method Details

    • find

      <T> List<T> find(Class<T> clazz, String baseDn, io.jans.orm.search.filter.Filter filter)
      Builds a List of objects of type T from a search (with scope of SUB) using baseDn as search base; this type of search accounts for the entry referenced at baseDn and any subordinate entries to any depth. The search can use an instance of io.jans.search.filter.Filter to include an LDAP-like filter expression.

      Note this search is performed in the context of oxcore-persist. In this sense, the Class referenced as parameter has to be annotated with io.jans.persist.model.base.Entry and potentially other annotations of the same package to be functional.

      Type Parameters:
      T - Type parameter of clazz
      Parameters:
      clazz - A class to which the search objects must belong to
      baseDn - Search base DN
      filter - Filter to constrain the search (supply null to returned ALL entries under the base DN that can be associated to Class clazz)
      Returns:
      A List of matching objects. Empty if no matches
    • find

      <T> List<T> find(Class<T> clazz, String baseDn, io.jans.orm.search.filter.Filter filter, int start, int count)
      Performs a search as method find(Class, String, Filter) does except the first start elements are skipped and at most count results are included in the returned list
      Type Parameters:
      T - Type parameter of clazz
      Parameters:
      clazz - A class to which the search objects must belong to
      baseDn - Search base DN
      filter - Filter to constrain the search (supply null to returned ALL entries under the base DN that can be associated to Class clazz)
      start - Zero-based index at which the search starts
      count - Maximum number of results to return
      Returns:
      A List of matching objects according to the rules specified above. Empty if no matches
    • find

      <T> List<T> find(T object)
      Builds a List of objects of type T from a search (with scope of SUB) using as search base the field annotated with io.jans.orm.annotation.DN in the object passed as parameter; this type of search accounts for the entry referenced at the search base and any subordinate entries to any depth. The object passed as parameter is used to internally build a filter to perform the search.

      Note this search is performed in the context of jans-orm. In this sense, the class to which the object passed belongs to has to be annotated with io.jans.orm.model.base.Entry and potentially other annotations of the same package to be functional.

      Type Parameters:
      T - Type parameter of clazz
      Parameters:
      object - An object employed to build a filter
      Returns:
      A List of matching objects. Empty if no matches
    • find

      <T> List<T> find(Class<T> clazz, String baseDn, io.jans.orm.search.filter.Filter filter, int start, int count, io.jans.orm.model.SearchScope searchScope)
      Performs a search as method find(Class, String, Filter) does except the first start elements are skipped and at most count results are included in the returned list
      Type Parameters:
      T - Type parameter of clazz
      Parameters:
      clazz - A class to which the search objects must belong to
      baseDn - Search base DN
      filter - Filter to constrain the search (supply null to returned ALL entries under the base DN that can be associated to Class clazz)
      start - Zero-based index at which the search starts
      count - Maximum number of results to return
      searchScope - LDAP search scope (if LDAP DB is used)
      Returns:
      A List of matching objects according to the rules specified above. Empty if no matches
    • count

      <T> int count(T object)
      Similar to find(Object) search except it only returns the amount of matching objects.
      Type Parameters:
      T - Type parameter of the class to which the object belongs to
      Parameters:
      object - Object describing the search
      Returns:
      An int with the number of matching objects, -1 if there was an error performing the operation
    • add

      <T> boolean add(T object)
      Adds an entry in the underlying persistence engine.
      Type Parameters:
      T - Type parameter of clazz
      Parameters:
      object - Represents the entry to be added. Its class should be annotated with io.jans.orm.model.base.Entry
      Returns:
      A boolean value indicating the success (true) or failure (false) of the operation
    • get

      <T> T get(Class<T> clazz, String dn)
      Retrieves the object representing the entry at the provided DN location.
      Type Parameters:
      T - Type parameter of clazz
      Parameters:
      clazz - The class the object to return is an instance of
      dn - Path (DN) of the entry
      Returns:
      An object of type T (null if an error was found performing the operation or if the entry does not exist)
    • modify

      <T> boolean modify(T object)
      Stores a previously obtained object (via get or find) - and potentially modified - into the persistence engine.
      Type Parameters:
      T - Type parameter of the class to which the object belongs to
      Parameters:
      object - An object whose attributes are potentially altered (eg. via setters) with respect to the original retrieved via get or find methods
      Returns:
      A boolean value indicating the success (true) or failure (false) of the operation.
    • delete

      <T> boolean delete(T object)
      Deletes the entry represented by parameter object from the persistence engine.
      Type Parameters:
      T - Type parameter of the class to which the object belongs to
      Parameters:
      object - A representation of the object to delete. It must have been previously retrieved via get or find methods
      Returns:
      A boolean value indicating the success (true) or failure (false) of the operation