public class FileBinaryService extends Object implements BinaryService
BinaryService implementation that stores LDP-NR resources as files on a local filesystem.
This service supports the following digest algorithms:
When running under JDK 9+, the following additional digest algorithms are supported:
| Modifier and Type | Field and Description |
|---|---|
static String |
CONFIG_FILE_BINARY_BASE_PATH
The configuration key controlling the base filesystem path for the binary service.
|
static String |
CONFIG_FILE_BINARY_HIERARCHY
The configuration key controlling the levels of hierarchy in a binary storage layout.
|
static String |
CONFIG_FILE_BINARY_LENGTH
The configuration key controlling the length of each level of hierarchy in a filesystem layout.
|
| Constructor and Description |
|---|
FileBinaryService()
Create a File-based Binary service.
|
FileBinaryService(IdentifierService idService)
Create a File-based Binary service.
|
FileBinaryService(IdentifierService idService,
String basePath,
int hierarchy,
int length)
Create a File-based Binary service.
|
| Modifier and Type | Method and Description |
|---|---|
CompletionStage<MessageDigest> |
calculateDigest(IRI identifier,
MessageDigest algorithm)
Calculate the digest for a binary object.
|
String |
generateIdentifier()
Get a new identifier.
|
CompletionStage<Binary> |
get(IRI identifier)
Get a resource by the given identifier.
|
CompletionStage<Void> |
purgeContent(IRI identifier)
Purge the content from its corresponding datastore.
|
CompletionStage<Void> |
setContent(BinaryMetadata metadata,
InputStream stream)
Set the content for a binary object.
|
Set<String> |
supportedAlgorithms()
Get a list of supported algorithms.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitsetContentpublic static final String CONFIG_FILE_BINARY_BASE_PATH
public static final String CONFIG_FILE_BINARY_HIERARCHY
public static final String CONFIG_FILE_BINARY_LENGTH
@Inject public FileBinaryService()
public FileBinaryService(IdentifierService idService)
idService - an identifier servicepublic FileBinaryService(IdentifierService idService, String basePath, int hierarchy, int length)
idService - an identifier servicebasePath - the base file pathhierarchy - the levels of hierarchylength - the length of each level of hierarchypublic CompletionStage<Binary> get(IRI identifier)
RetrievalServiceget in interface RetrievalService<Binary>identifier - the resource identifierpublic CompletionStage<Void> purgeContent(IRI identifier)
BinaryServicepurgeContent in interface BinaryServiceidentifier - the binary object identifierCompletionStage will complete exceptionally and can be handled with
CompletionStage.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.public CompletionStage<Void> setContent(BinaryMetadata metadata, InputStream stream)
BinaryServicesetContent in interface BinaryServicemetadata - the binary metadatastream - the contentpublic CompletionStage<MessageDigest> calculateDigest(IRI identifier, MessageDigest algorithm)
BinaryServicecalculateDigest in interface BinaryServiceidentifier - the identifieralgorithm - the algorithmpublic Set<String> supportedAlgorithms()
BinaryServicesupportedAlgorithms in interface BinaryServicepublic String generateIdentifier()
BinaryServicegenerateIdentifier in interface BinaryService