Class MembershipView
java.lang.Object
org.gcube.informationsystem.resourceregistry.persistence.MembershipView
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
ConstructorsConstructorDescriptionCreates 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 TypeMethodDescriptionSelects, among the memberships of an instance, the ones this view lists.protected StringreadCachedPath(String contextUUID) Reads the path of a Context from the cache.readDescendantEffectiveStates(UUID contextUUID) Reads theeffectiveStateof every descendant of a Context.protected org.gcube.informationsystem.contexts.reference.ContextStatereadEffectiveState(String contextUUID) Reads theeffectiveStateof a Context.protected StringreadStoredPath(String contextUUID) Reads the path of a Context from the database.org.gcube.com.fasterxml.jackson.databind.node.ObjectNodetoContextsMap(Set<String> memberships) Builds thecontextsmap of an instance: the listed memberships, each with the current path of its Context.
-
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 listtokenContextUUID- the token Context, root of theMembershipScope.SUBTREEboundaryomitNonActive- whether memberships in Contexts that are not effectivelyACTIVEare omittedstateFilteredListener- 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 thecontextsmap of an instance: the listed memberships, each with the current path of its Context. A path is nevernull: 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 theeffectiveStateof every descendant of a Context.- Parameters:
contextUUID- the UUID of the Context- Returns:
- the
effectiveStateof 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 theeffectiveStateof 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
Reads the path of a Context from the cache.- Parameters:
contextUUID- the UUID of the Context- Returns:
- its path, or
nullwhen 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
-