Package org.trellisldp.api
Interface MementoService
-
- All Known Implementing Classes:
DBWrappedMementoService
,FileMementoService
,NoopMementoService
public interface MementoService
An interface for a Memento subsystem. Mementos ofResource
s may be made and retrieved using this service. Mementos may also be recorded by other means, including by the persistence layer independently of Trellis, but unless they are retrieved via this service, Trellis will not publish them as HTTP resources. Mementos of NonRDFSources (like any otherResource
) may also be made and retrieved here, but the associatedInputStream
s are made (like all binaryInputStream
s) via aBinaryService
implementation.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description CompletionStage<Resource>
get(IRI identifier, Instant time)
Fetch a Memento resource for the given time.CompletionStage<SortedSet<Instant>>
mementos(IRI identifier)
Get the times for all of the Mementos of the given resource.CompletionStage<Void>
put(Resource resource)
Create a new Memento for a resource.default CompletionStage<Void>
put(ResourceService resourceService, IRI identifier)
Create a new Memento for a resource, retrieved from aResourceService
.
-
-
-
Method Detail
-
put
default CompletionStage<Void> put(ResourceService resourceService, IRI identifier)
Create a new Memento for a resource, retrieved from aResourceService
.- Parameters:
resourceService
- the resource service.identifier
- the identifier.- Returns:
- a new completion stage that, when the stage completes normally, indicates that the Memento resource was successfully created in the corresponding persistence layer.
- Implementation Requirements:
- The default implementation of this method fetches a resource from a
ResourceService
that is external to the Memento service., An implementation may choose to store a new Memento only when this method is called, or at other times as well, e.g. whenResourceService.replace(org.trellisldp.api.Metadata, org.apache.commons.rdf.api.Dataset)
is called. - Implementation Note:
- In the case that the two services are managed by the same persistence layer, it may not be
necessary to fetch a
Resource
from the persistence layer, in which case this method can be overridden as a no-op method, e.g.return completedFuture(null);
.
-
put
CompletionStage<Void> put(Resource resource)
Create a new Memento for a resource.- Parameters:
resource
- the resource- Returns:
- a new completion stage that, when the stage completes normally, indicates that the Memento resource was
successfully created in the corresponding persistence layer. In the case of an unsuccessful write operation,
the
CompletionStage
will complete exceptionally and can be handled withCompletionStage.handle(java.util.function.BiFunction<? super T, java.lang.Throwable, ? extends U>)
,CompletionStage.exceptionally(java.util.function.Function<java.lang.Throwable, ? extends T>)
or similar methods.
-
get
CompletionStage<Resource> get(IRI identifier, Instant time)
Fetch a Memento resource for the given time.- Parameters:
identifier
- the resource identifiertime
- the requested time- Returns:
- the new completion stage, containing the fetched resource
-
mementos
CompletionStage<SortedSet<Instant>> mementos(IRI identifier)
Get the times for all of the Mementos of the given resource.- Parameters:
identifier
- the resource identifier- Returns:
- the new completion stage containing a collection of Memento dateTimes
-
-