java.lang.Object
org.gcube.informationsystem.resourceregistry.persistence.MembershipView

public class MembershipView extends Object
The view of Context memberships a request is entitled to: it builds every contexts map of the response from the memberships of an instance.

Two independent rules select the memberships. The boundary is the MembershipScope: the token Context and its descendants, or every Context. The state rule omits the Contexts whose effectiveState is not ACTIVE for a caller without the administrative state override. Neither rule depends on how the instance was selected (hierarchical).

One view is shared by every element serialized for a request, so the Context lookups are done once and a membership omitted by the state rule on any element is reported once.

Author:
Luca Frosini (ISTI - CNR)
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates the unrestricted view: every membership, whatever the state of its Context.
    MembershipView(org.gcube.informationsystem.resourceregistry.api.rest.MembershipScope membershipScope, UUID tokenContextUUID, boolean omitNonActive, Runnable stateFilteredListener)
    Creates the view of a request.
  • Method Summary

    Modifier and Type
    Method
    Description
    filter(Set<String> memberships)
    Selects, among the memberships of an instance, the ones this view lists.
    protected String
    readCachedPath(String contextUUID)
    Reads the path of a Context from the cache.
    protected Map<String,org.gcube.informationsystem.contexts.reference.ContextState>
    Reads the effectiveState of every descendant of a Context.
    protected org.gcube.informationsystem.contexts.reference.ContextState
    Reads the effectiveState of a Context.
    protected String
    readStoredPath(String contextUUID)
    Reads the path of a Context from the database.
    org.gcube.com.fasterxml.jackson.databind.node.ObjectNode
    toContextsMap(Set<String> memberships)
    Builds the contexts map of an instance: the listed memberships, each with the current path of its Context.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MembershipView

      public MembershipView()
      Creates the unrestricted view: every membership, whatever the state of its Context.
    • MembershipView

      public MembershipView(org.gcube.informationsystem.resourceregistry.api.rest.MembershipScope membershipScope, UUID tokenContextUUID, boolean omitNonActive, Runnable stateFilteredListener)
      Creates the view of a request.
      Parameters:
      membershipScope - the boundary of the memberships to list
      tokenContextUUID - the token Context, root of the MembershipScope.SUBTREE boundary
      omitNonActive - whether memberships in Contexts that are not effectively ACTIVE are omitted
      stateFilteredListener - notified every time the state rule omits a membership
  • Method Details

    • filter

      public Set<String> filter(Set<String> memberships) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Selects, among the memberships of an instance, the ones this view lists.
      Parameters:
      memberships - the UUIDs of every Context the instance belongs to
      Returns:
      the UUIDs of the listed Contexts
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if a Context lookup fails
    • toContextsMap

      public org.gcube.com.fasterxml.jackson.databind.node.ObjectNode toContextsMap(Set<String> memberships) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Builds the contexts map of an instance: the listed memberships, each with the current path of its Context. A path is never null: when the cache does not answer it is read from the database.
      Parameters:
      memberships - the UUIDs of every Context the instance belongs to
      Returns:
      the map from Context UUID to Context path
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if a Context lookup fails or a path cannot be resolved
    • readDescendantEffectiveStates

      protected Map<String,org.gcube.informationsystem.contexts.reference.ContextState> readDescendantEffectiveStates(UUID contextUUID) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Reads the effectiveState of every descendant of a Context.
      Parameters:
      contextUUID - the UUID of the Context
      Returns:
      the effectiveState of each descendant, by UUID
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the lookup fails
    • readEffectiveState

      protected org.gcube.informationsystem.contexts.reference.ContextState readEffectiveState(String contextUUID) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Reads the effectiveState of a Context.
      Parameters:
      contextUUID - the UUID of the Context
      Returns:
      its effectiveState
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the lookup fails
    • readCachedPath

      protected String readCachedPath(String contextUUID)
      Reads the path of a Context from the cache.
      Parameters:
      contextUUID - the UUID of the Context
      Returns:
      its path, or null when the cache does not answer
    • readStoredPath

      protected String readStoredPath(String contextUUID) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Reads the path of a Context from the database.
      Parameters:
      contextUUID - the UUID of the Context
      Returns:
      its path
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the lookup fails