Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DataAccessorBasedStore

ResourceStore which uses a DataAccessor for backend access.

The DataAccessor interface provides elementary store operations such as read and write. This DataAccessorBasedStore uses those elementary store operations to implement the more high-level ResourceStore contact, abstracting all common functionality such that new stores can be added by implementing the more simple DataAccessor contract. DataAccessorBasedStore thereby provides behaviours for reuse across different stores, such as:

  • Converting container metadata to data
  • Converting slug to URI
  • Checking if addResource target is a container
  • Checking if no containment triples are written to a container
  • etc.

Currently "metadata" is seen as something that is not directly accessible. That means that a consumer can't write directly to the metadata of a resource, only indirectly through headers. (Except for containers where data and metadata overlap).

The one thing this store does not take care of (yet?) are containment triples for containers

Work has been done to minimize the number of required calls to the DataAccessor, but the main disadvantage is that sometimes multiple calls are required where a specific store might only need one.

Hierarchy

  • DataAccessorBasedStore

Implements

Index

Constructors

constructor

Properties

Private Readonly accessor

accessor: DataAccessor

Private Readonly identifierStrategy

identifierStrategy: IdentifierStrategy

Methods

addResource

Protected createRecursiveContainers

  • Create containers starting from the root until the given identifier corresponds to an existing container. Will throw errors if the identifier of the last existing "container" corresponds to an existing document.

    Parameters

    Returns Promise<void>

Protected createSafeUri

Protected createURI

deleteResource

Protected getEmptyContainerRepresentation

Protected getNormalizedMetadata

  • Returns the metadata matching the identifier, ignoring the presence of a trailing slash or not. This is used to support the following part of the spec: "If two URIs differ only in the trailing slash, and the server has associated a resource with one of them, then the other URI MUST NOT correspond to another resource."

    First the identifier gets requested and if no result is found the identifier with differing trailing slash is requested.

    Parameters

    Returns Promise<RepresentationMetadata>

getRepresentation

Protected getSafeNormalizedMetadata

Protected handleContainerData

  • Verify if the incoming data for a container is valid (RDF and no containment triples). Adds the container data to its metadata afterwards.

    Parameters

    Returns Promise<void>

Protected hasContainerType

  • hasContainerType(types: Term[]): boolean

Protected isExistingContainer

  • Checks if the given metadata represents a container, purely based on metadata type triples. Since type metadata always gets generated when writing resources this should never fail on stored resources.

    Parameters

    Returns boolean

Protected isNewContainer

  • Checks if the given metadata represents a (potential) container, both based on the metadata and the URI.

    Parameters

    • metadata: RepresentationMetadata

      Metadata of the (new) resource.

    • Optional suffix: string

      Suffix of the URI. Can be the full URI, but only the last part is required.

    Returns boolean

Protected isRootStorage

modifyResource

  • modifyResource(): Promise<void>

setRepresentation

Protected validateIdentifier

Protected writeData

  • Write the given resource to the DataAccessor. Metadata will be updated with necessary triples. In case of containers handleContainerData will be used to verify the data.

    Parameters

    • identifier: ResourceIdentifier

      Identifier of the resource.

    • representation: Representation

      Corresponding Representation.

    • isContainer: boolean

      Is the incoming resource a container?

    • Optional createContainers: boolean

      Should parent containers (potentially) be created?

    Returns Promise<void>