Class MetadataUtility
java.lang.Object
org.gcube.informationsystem.resourceregistry.persistence.orientdb.utils.MetadataUtility
- Author:
- Luca Frosini (ISTI - CNR)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.gcube.informationsystem.base.reference.properties.MetadataaddMetadata(com.orientechnologies.orient.core.record.OElement element) Creates new metadata and attaches it to the specified OrientDB element.static org.gcube.informationsystem.base.reference.properties.MetadataCreates and initializes a newMetadatainstance with the current creator, last updater, and creation/last-update timestamps.static org.gcube.informationsystem.base.reference.properties.MetadatagetMetadata(com.orientechnologies.orient.core.record.OElement element) Reads and returns theMetadataassociated with the specified OrientDB element.static org.gcube.informationsystem.base.reference.properties.MetadatagetMetadata(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode) Deserializes and returns theMetadatainstance from the specified JSON node.static MetadataOrientgetMetadataOrient(com.orientechnologies.orient.core.record.impl.ODocument oDocument) Extracts and converts an OrientDB ODocument into a strongly-typedMetadataOrientinstance.static StringgetUser()Retrieves and returns the current authenticated username from the SecretManager.static voidupdateModifiedByAndLastUpdate(com.orientechnologies.orient.core.record.OElement element) Updates the modification metadata (last update user and last update time) for the specified element.
-
Constructor Details
-
MetadataUtility
public MetadataUtility()
-
-
Method Details
-
getUser
Retrieves and returns the current authenticated username from the SecretManager.- Returns:
- the resolved username, or
Element.UNKNOWN_USERif not available
-
createMetadata
public static org.gcube.informationsystem.base.reference.properties.Metadata createMetadata()Creates and initializes a newMetadatainstance with the current creator, last updater, and creation/last-update timestamps.- Returns:
- the initialized metadata instance
-
getMetadata
public static org.gcube.informationsystem.base.reference.properties.Metadata getMetadata(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode) throws org.gcube.com.fasterxml.jackson.core.JsonParseException, org.gcube.com.fasterxml.jackson.databind.JsonMappingException, IOException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Deserializes and returns theMetadatainstance from the specified JSON node.- Parameters:
jsonNode- the JSON node containing metadata property- Returns:
- the deserialized metadata instance, or
nullif not found or null - Throws:
org.gcube.com.fasterxml.jackson.core.JsonParseException- on JSON syntax errororg.gcube.com.fasterxml.jackson.databind.JsonMappingException- on Jackson object mapping errorIOException- on input/output stream failureorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on internal registry serialization error
-
getMetadataOrient
public static MetadataOrient getMetadataOrient(com.orientechnologies.orient.core.record.impl.ODocument oDocument) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Extracts and converts an OrientDB ODocument into a strongly-typedMetadataOrientinstance.- Parameters:
oDocument- the OrientDB document to convert- Returns:
- the matching
MetadataOrientinstance - Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the metadata reconstruction fails
-
addMetadata
public static org.gcube.informationsystem.base.reference.properties.Metadata addMetadata(com.orientechnologies.orient.core.record.OElement element) Creates new metadata and attaches it to the specified OrientDB element.- Parameters:
element- the OrientDB element to enrich- Returns:
- the created metadata instance
-
getMetadata
public static org.gcube.informationsystem.base.reference.properties.Metadata getMetadata(com.orientechnologies.orient.core.record.OElement element) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Reads and returns theMetadataassociated with the specified OrientDB element.- Parameters:
element- the OrientDB element to inspect- Returns:
- the retrieved metadata instance
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the lookup fails
-
updateModifiedByAndLastUpdate
public static void updateModifiedByAndLastUpdate(com.orientechnologies.orient.core.record.OElement element) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Updates the modification metadata (last update user and last update time) for the specified element.- Parameters:
element- the OrientDB element to update- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the update fails
-