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

Constructors

Properties

accessor: DataAccessor
auxiliaryStrategy: AuxiliaryStrategy
identifierStrategy: IdentifierStrategy
logger: Logger = ...
metadataStrategy: AuxiliaryStrategy

Methods

  • Generates activity metadata specifically for Add/Remove events on a container.

    Parameters

    • map: ChangeMap

      ChangeMap to update.

    • id: ResourceIdentifier

      Identifier of the container.

    • add: boolean

      If there is a resource being added (true) or removed (false).

    • object: ResourceIdentifier

      The object that is being added/removed.

    Returns void

  • Clean http Slug to be compatible with the server. Makes sure there are no unwanted characters e.g.: cleanslug('&%26') returns '%26%26'

    Parameters

    • slug: string

      the slug to clean

    Returns string

  • 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<ChangeMap>

  • Generates a new URI for a resource in the given container, potentially using the given slug.

    Solid, §5.3: "Servers MUST allow creating new resources with a POST request to URI path ending /. Servers MUST create a resource with URI path ending /{id} in container /. Servers MUST create a container with URI path ending /{id}/ in container / for requests including the HTTP Link header with rel="type" targeting a valid LDP container type." https://solid.github.io/specification/protocol#writing-resources

    Parameters

    • container: ResourceIdentifier

      Parent container of the new URI.

    • isContainer: boolean

      Does the new URI represent a container?

    • Optional slug: string

      Slug to use for the new URI.

    Returns ResourceIdentifier

  • Warns when the representation has data and removes the content-type from the metadata.

    Parameters

    Returns Promise<void>

  • Validates if the slug and headers are valid. Errors if slug exists, ends on slash, but ContainerType Link header is NOT present

    Parameters

    • isContainer: boolean

      Is the slug supposed to represent a container?

    • Optional slug: string

      Is the requested slug (if any).

    Returns void

  • 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?

    • createContainers: boolean

      Should parent containers (potentially) be created?

    • exists: boolean

      If the resource already exists.

    Returns Promise<ChangeMap>

    Identifiers of resources that were possibly modified.