Class TokenContextResolution
java.lang.Object
org.gcube.informationsystem.resourceregistry.contexts.TokenContextResolution
The single resolution of the caller's token path to a live Context, done once per request
(reference
08, Token path resolution): the token path is matched against current
paths first and then against previousPaths.
Every consumer that derives its Context from the token reads it from here, and
ResultScopeResponseFilter emits X-Result-Scope: previous-path and
X-Resolved-Context-Path on every response whose request resolved the token through a
previous path. The outcome is kept for the thread's current Secret, so a new request
(a new secret) always resolves again; the response filter also clears it.
- Author:
- Luca Frosini (ISTI - CNR)
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidclear()Forgets the outcome kept for this thread, at the end of a request.static org.gcube.informationsystem.contexts.reference.entities.Contextcurrent()Returns the live Context the caller's token path resolves to, resolving it on the first call of the request.static org.gcube.informationsystem.contexts.reference.entities.ContextReturns the live Context the caller's token path resolves to, ascurrent(), and tells a path that matches only a Context in the cemetery from one that matches no Context (reference08, Token path resolution): the cemetery is probed only when no live Context matches, and a deleted Context is never returned, whatever the caller's role.static StringReturns the current path of the live Context of the caller's token, which differs from the token path when the token carries a previous path.static UUIDReturns the UUID of the live Context of the caller's token.static StringReturns the current path the token resolved to during this request when the token carried a previous path,nullotherwise (no resolution, or a direct match).static voidrecord(org.gcube.informationsystem.contexts.reference.entities.Context context) Records a Context resolved from the caller's token path by a lookup other thancurrent()(e.g. the cemetery-inclusive lookup of Read Current), so that the response reports a previous-path match in the same way.
-
Method Details
-
current
public static org.gcube.informationsystem.contexts.reference.entities.Context current() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionReturns the live Context the caller's token path resolves to, resolving it on the first call of the request.- Returns:
- the live Context of the token
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException- if the thread carries no token Contextorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the path matches no live Context, or the lookup fails
-
currentOrForbiddenIfDeleted
public static org.gcube.informationsystem.contexts.reference.entities.Context currentOrForbiddenIfDeleted() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionReturns the live Context the caller's token path resolves to, ascurrent(), and tells a path that matches only a Context in the cemetery from one that matches no Context (reference08, Token path resolution): the cemetery is probed only when no live Context matches, and a deleted Context is never returned, whatever the caller's role.- Returns:
- the live Context of the token
- Throws:
jakarta.ws.rs.ForbiddenException- if the token path matches only a Context in the cemeteryorg.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException- if the token path matches no Contextorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the lookup fails
-
currentUUID
public static UUID currentUUID() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionReturns the UUID of the live Context of the caller's token.- Returns:
- the UUID of the token Context
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the token Context cannot be resolved- See Also:
-
currentPath
public static String currentPath() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionReturns the current path of the live Context of the caller's token, which differs from the token path when the token carries a previous path.- Returns:
- the current path of the token Context
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the token Context cannot be resolved- See Also:
-
record
public static void record(org.gcube.informationsystem.contexts.reference.entities.Context context) Records a Context resolved from the caller's token path by a lookup other thancurrent()(e.g. the cemetery-inclusive lookup of Read Current), so that the response reports a previous-path match in the same way.- Parameters:
context- the Context the token path resolved to
-
getPreviousPathResolution
Returns the current path the token resolved to during this request when the token carried a previous path,nullotherwise (no resolution, or a direct match).- Returns:
- the resolved current path after a previous-path match, or
null
-
clear
public static void clear()Forgets the outcome kept for this thread, at the end of a request.
-