Package org.trellisldp.file
Class FileMementoService
- java.lang.Object
-
- org.trellisldp.file.FileMementoService
-
- All Implemented Interfaces:
MementoService
@Alternative public class FileMementoService extends Object implements MementoService
A file-based versioning system.
-
-
Field Summary
Fields Modifier and Type Field Description static String
CONFIG_FILE_MEMENTO
The configuration key controlling whether Memento versioning is enabled.static String
CONFIG_FILE_MEMENTO_PATH
The configuration key controlling the base filesystem path for memento storage.
-
Constructor Summary
Constructors Constructor Description FileMementoService()
Create a file-based memento service.FileMementoService(String path, boolean enabled)
Create a file-based memento service.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletionStage<Void>
delete(IRI identifier, Instant time)
Delete a memento at the given time.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.CompletionStage<Void>
put(Resource resource, Instant time)
Create a Memento from a resource at a particular time.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.trellisldp.api.MementoService
put
-
-
-
-
Field Detail
-
CONFIG_FILE_MEMENTO_PATH
public static final String CONFIG_FILE_MEMENTO_PATH
The configuration key controlling the base filesystem path for memento storage.- See Also:
- Constant Field Values
-
CONFIG_FILE_MEMENTO
public static final String CONFIG_FILE_MEMENTO
The configuration key controlling whether Memento versioning is enabled.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FileMementoService
public FileMementoService()
Create a file-based memento service.
-
FileMementoService
public FileMementoService(String path, boolean enabled)
Create a file-based memento service.- Parameters:
path
- the file pathenabled
- whether memento handling is enabled
-
-
Method Detail
-
put
public CompletionStage<Void> put(Resource resource)
Description copied from interface:MementoService
Create a new Memento for a resource.- Specified by:
put
in interfaceMementoService
- 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.
-
put
public CompletionStage<Void> put(Resource resource, Instant time)
Create a Memento from a resource at a particular time.- Parameters:
resource
- the resourcetime
- the time to which the Memento corresponds- Returns:
- the completion stage representing that the operation has completed
-
get
public CompletionStage<Resource> get(IRI identifier, Instant time)
Description copied from interface:MementoService
Fetch a Memento resource for the given time.- Specified by:
get
in interfaceMementoService
- Parameters:
identifier
- the resource identifiertime
- the requested time- Returns:
- the new completion stage, containing the fetched resource
-
mementos
public CompletionStage<SortedSet<Instant>> mementos(IRI identifier)
Description copied from interface:MementoService
Get the times for all of the Mementos of the given resource.- Specified by:
mementos
in interfaceMementoService
- Parameters:
identifier
- the resource identifier- Returns:
- the new completion stage containing a collection of Memento dateTimes
-
delete
public CompletionStage<Void> delete(IRI identifier, Instant time)
Delete a memento at the given time.- Parameters:
identifier
- the resource identifiertime
- the memento time- Returns:
- the next stage of completion
-
-