Interface ResourceStore


public interface ResourceStore
A ResourceStore is responsible to manage the persistence of Resource instances.
Author:
Pedro Igor
  • Method Details

    • create

      default Resource create(ResourceServer resourceServer, String name, String owner)

      Creates a Resource instance backed by this persistent storage implementation.

      Parameters:
      resourceServer - the resource server to where the given resource belongs to. Cannot be null.
      name - the name of this resource. It must be unique.
      owner - the owner of this resource or null if the resource server is the owner
      Returns:
      an instance backed by the underlying storage implementation
    • create

      Resource create(ResourceServer resourceServer, String id, String name, String owner)

      Creates a Resource instance backed by this persistent storage implementation.

      Parameters:
      resourceServer - the resource server to where the given resource belongs to. Cannot be null.
      id - the id of this resource. It must be unique. Will be randomly generated if null.
      name - the name of this resource. It must be unique.
      owner - the owner of this resource or null if the resource server is the owner
      Returns:
      an instance backed by the underlying storage implementation
    • delete

      void delete(RealmModel realm, String id)
      Removes a Resource instance, with the given id from the persistent storage.
      Parameters:
      realm - the realm. Cannot be null.
      id - the identifier of an existing resource instance
    • findById

      Resource findById(RealmModel realm, ResourceServer resourceServer, String id)
      Returns a Resource instance based on its identifier.
      Parameters:
      realm - the realm. Cannot be null.
      resourceServer - the resource server. Ignored if null
      id - the identifier of an existing resource instance
      Returns:
      the resource instance with the given identifier or null if no instance was found
    • findByOwner

      default List<Resource> findByOwner(RealmModel realm, ResourceServer resourceServer, String ownerId)
      Finds all Resource instances with the given ownerId.
      Parameters:
      realm - the realm. Cannot be null.
      resourceServer - resource server. Ignored if null
      ownerId - the identifier of the owner
      Returns:
      a list with all resource instances owned by the given owner
    • findByOwner

      void findByOwner(RealmModel realm, ResourceServer resourceServer, String ownerId, Consumer<Resource> consumer)
    • findByResourceServer

      List<Resource> findByResourceServer(ResourceServer resourceServer)
      Finds all Resource instances associated with a given resource server.
      Parameters:
      resourceServer - the identifier of the resource server. Cannot be null.
      Returns:
      a list with all resources associated with the given resource server
    • find

      List<Resource> find(RealmModel realm, ResourceServer resourceServer, Map<Resource.FilterOption,String[]> attributes, Integer firstResult, Integer maxResults)
      Finds all Resource instances associated with a given resource server.
      Parameters:
      realm - the realm. Cannot be null.
      resourceServer - the identifier of the resource server. Ignored if null.
      attributes - a map holding the attributes that will be used as a filter; possible filter options are given by Resource.FilterOption
      firstResult - first result to return. Ignored if negative or null.
      maxResults - maximum number of results to return. Ignored if negative or null.
      Returns:
      a list with all resources associated with the given resource server
      Throws:
      IllegalArgumentException - when there is an unknown attribute in the attributes map
    • findByScopes

      default List<Resource> findByScopes(ResourceServer resourceServer, Set<Scope> scopes)
      Finds all Resource associated with a given scope.
      Parameters:
      resourceServer - the resource server. Cannot be null.
      scopes - one or more scope identifiers
      Returns:
      a list of resources associated with the given scope(s)
    • findByScopes

      void findByScopes(ResourceServer resourceServer, Set<Scope> scopes, Consumer<Resource> consumer)
    • findByName

      default Resource findByName(ResourceServer resourceServer, String name)
      Find a Resource by its name where the owner is the resource server itself.
      Parameters:
      resourceServer - the resource server. Cannot be null.
      name - the name of the resource
      Returns:
      a resource with the given name
    • findByName

      Resource findByName(ResourceServer resourceServer, String name, String ownerId)
      Find a Resource by its name where the owner is the given ownerId.
      Parameters:
      resourceServer - the identifier of the resource server. Cannot be null.
      name - the name of the resource
      ownerId - the owner id
      Returns:
      a resource with the given name
    • findByType

      default List<Resource> findByType(ResourceServer resourceServer, String type)
      Finds all Resource from ResourceServer with the given type.
      Parameters:
      resourceServer - the resource server. Cannot be null.
      type - the type of the resource
      Returns:
      a list of resources with the given type
    • findByType

      void findByType(ResourceServer resourceServer, String type, Consumer<Resource> consumer)
      Finds all Resource from ResourceServer with the given type.
      Parameters:
      resourceServer - the resource server id. Cannot be null.
      type - the type of the resource
      consumer - the result consumer
    • findByType

      void findByType(ResourceServer resourceServer, String type, String owner, Consumer<Resource> consumer)
      Finds all Resource with the given type.
      Parameters:
      resourceServer - the resource server id. Cannot be null
      type - the type of the resource
      owner - the resource owner or null for any resource with a given type
      consumer - the result consumer
    • findByTypeInstance

      void findByTypeInstance(ResourceServer resourceServer, String type, Consumer<Resource> consumer)
      Finds all Resource by type where client represented by the resourceServer is not the owner
      Parameters:
      resourceServer - the resourceServer. Cannot be null.
      type - searched type
      consumer - a consumer that will be fed with the resulting resources