Class: SystemMetadata

SystemMetadata()

new SystemMetadata()

Class representing System Metadata for a DataONE object. This class currently only provides a basic implementation for fetching and parsing system metadata from a DataONE service. It excludes parsing complex elements like accessPolicy and replicationPolicy. In the future, all fields will be implemented, and the class will support serialization to XML and updating system metadata on the server.
Properties:
Name Type Description
metaServiceUrl string The URL of the metadata service.
data object The object that contains all the system metadata fields, like identifier, formatId, size, checksum, etc.
fetched boolean Indicates whether the system metadata has been fetched successfully.
fetchedWithError boolean Indicates whether there was an error during the fetch operation.
errors Array An array to hold any errors that occur during the fetch operation.
parsed boolean Indicates whether the system metadata has been parsed from XML.
url string The URL to fetch the system metadata.
Since:
  • 2.34.0
Source:

Members

url

Returns the URL for fetching the system metadata.
Source:

Methods

fetch(tokenopt) → {Promise.<(object|null)>}

Fetches the system metadata from the configured URL.
Parameters:
Name Type Attributes Description
token string <optional>
Optional authentication token for the request.
Source:
Returns:
A promise that resolves to the system metadata object or null if an error occurs.
Type
Promise.<(object|null)>

handleFetchError(e)

Handles errors that occur during the fetch operation.
Parameters:
Name Type Description
e Error The error object containing error details.
Source:

parse(xmlString) → {object}

Parses the XML string into a system metadata object.
Parameters:
Name Type Description
xmlString string The XML string to parse.
Source:
Returns:
The parsed system metadata object.
Type
object

parseError(text) → {Error|null}

Attempts to parse an xml error object returned from DataONE, e.g.: READ not allowed on urn:uuid:c6556d90-4f58-4439-a309-a517a4fe3dc3 for subject[s]: public;
Parameters:
Name Type Description
text string The XML string to parse.
Source:
Returns:
Returns a SysMetaError with the error message and status if the XML contains an error element, or null if no error is found.
Type
Error | null

SystemMetadata(options)

new SystemMetadata(options)

Creates an instance of SystemMetadata.
Parameters:
Name Type Description
options object Configuration options for the SystemMetadata instance.
Properties
Name Type Attributes Description
identifier string The identifier for the DataONE object.
metaServiceUrl string <optional>
The URL of the metadata service.
Source:

Members

url

Returns the URL for fetching the system metadata.
Source:

Methods

fetch(tokenopt) → {Promise.<(object|null)>}

Fetches the system metadata from the configured URL.
Parameters:
Name Type Attributes Description
token string <optional>
Optional authentication token for the request.
Source:
Returns:
A promise that resolves to the system metadata object or null if an error occurs.
Type
Promise.<(object|null)>

handleFetchError(e)

Handles errors that occur during the fetch operation.
Parameters:
Name Type Description
e Error The error object containing error details.
Source:

parse(xmlString) → {object}

Parses the XML string into a system metadata object.
Parameters:
Name Type Description
xmlString string The XML string to parse.
Source:
Returns:
The parsed system metadata object.
Type
object

parseError(text) → {Error|null}

Attempts to parse an xml error object returned from DataONE, e.g.: READ not allowed on urn:uuid:c6556d90-4f58-4439-a309-a517a4fe3dc3 for subject[s]: public;
Parameters:
Name Type Description
text string The XML string to parse.
Source:
Returns:
Returns a SysMetaError with the error message and status if the XML contains an error element, or null if no error is found.
Type
Error | null