Class ContextUtility
java.lang.Object
org.gcube.informationsystem.resourceregistry.api.contexts.ContextUtility
Client-side helper methods for converting between the wire representations of
Context identity (JSON UUID-to-path maps, UUID strings) and their in-memory
counterparts, resolving paths via a
ContextCache.- Author:
- Luca Frosini (ISTI - CNR)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.gcube.informationsystem.contexts.reference.entities.ContextgetContextFromReadResponse(String contextsJson) Reads the response of a Context read (GET /contexts/{uuid}andGET /contexts/@current): a flat JSON array with the requested Context first, followed by its descendants level by level.getContextMap(String objectnode) Gets the context map.getContextPathSet(ContextCache contextCache, Collection<UUID> uuids) Gets the context path set.getContextUUIDSet(Collection<String> uuidStrings) Gets the context UUID set.
-
Constructor Details
-
ContextUtility
public ContextUtility()
-
-
Method Details
-
getContextMap
public static Map<UUID,String> getContextMap(String objectnode) throws org.gcube.com.fasterxml.jackson.core.JsonParseException, org.gcube.com.fasterxml.jackson.databind.JsonMappingException, IOException Gets the context map.- Parameters:
objectnode- the objectnode- Returns:
- the context map
- Throws:
org.gcube.com.fasterxml.jackson.core.JsonParseException- the json parse exceptionorg.gcube.com.fasterxml.jackson.databind.JsonMappingException- the json mapping exceptionIOException- Signals that an I/O exception has occurred.
-
getContextUUIDSet
Gets the context UUID set.- Parameters:
uuidStrings- the uuid strings- Returns:
- the context UUID set
- Throws:
Exception- the exception
-
getContextPathSet
public static Set<String> getContextPathSet(ContextCache contextCache, Collection<UUID> uuids) throws Exception Gets the context path set. An unknown UUID renews the cache at most once a minute (seeContextCache.getContextPathByUUID(UUID)), never at every call.- Parameters:
contextCache- the context cacheuuids- the uuids- Returns:
- the context path set
- Throws:
Exception- the exception
-
getContextFromReadResponse
public static org.gcube.informationsystem.contexts.reference.entities.Context getContextFromReadResponse(String contextsJson) throws ContextNotFoundException, ResourceRegistryException Reads the response of a Context read (GET /contexts/{uuid}andGET /contexts/@current): a flat JSON array with the requested Context first, followed by its descendants level by level. The descendants returned are linked to their parents, so that the Context returned carries its subtree as far as the response goes.- Parameters:
contextsJson- the body of the response- Returns:
- the requested Context, the first of the array
- Throws:
ContextNotFoundException- if the array is emptyResourceRegistryException- if the body is not an array of Contexts
-