Package org.trellisldp.file
Class FileBinaryService
- java.lang.Object
-
- org.trellisldp.file.FileBinaryService
-
- All Implemented Interfaces:
BinaryService
,RetrievalService<Binary>
@ApplicationScoped public class FileBinaryService extends Object implements BinaryService
ABinaryService
implementation that stores LDP-NR resources as files on a local filesystem.
-
-
Field Summary
Fields Modifier and Type Field Description 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.static String
CONFIG_FILE_BINARY_PATH
The configuration key controlling the base filesystem path for the binary service.
-
Constructor Summary
Constructors Constructor 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
generateIdentifier(IRI identifier)
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.
-
-
-
Field Detail
-
CONFIG_FILE_BINARY_PATH
public static final String CONFIG_FILE_BINARY_PATH
The configuration key controlling the base filesystem path for the binary service.- See Also:
- Constant Field Values
-
CONFIG_FILE_BINARY_HIERARCHY
public static final String CONFIG_FILE_BINARY_HIERARCHY
The configuration key controlling the levels of hierarchy in a binary storage layout.- See Also:
- Constant Field Values
-
CONFIG_FILE_BINARY_LENGTH
public static final String CONFIG_FILE_BINARY_LENGTH
The configuration key controlling the length of each level of hierarchy in a filesystem layout.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FileBinaryService
public FileBinaryService()
Create a File-based Binary service.
-
FileBinaryService
@Inject public FileBinaryService(IdentifierService idService)
Create a File-based Binary service.- Parameters:
idService
- an identifier service
-
FileBinaryService
public FileBinaryService(IdentifierService idService, String basePath, int hierarchy, int length)
Create a File-based Binary service.- Parameters:
idService
- an identifier servicebasePath
- the base file pathhierarchy
- the levels of hierarchylength
- the length of each level of hierarchy
-
-
Method Detail
-
get
public CompletionStage<Binary> get(IRI identifier)
Description copied from interface:RetrievalService
Get a resource by the given identifier.- Specified by:
get
in interfaceRetrievalService<Binary>
- Parameters:
identifier
- the resource identifier- Returns:
- the resource
-
purgeContent
public CompletionStage<Void> purgeContent(IRI identifier)
Description copied from interface:BinaryService
Purge the content from its corresponding datastore.- Specified by:
purgeContent
in interfaceBinaryService
- Parameters:
identifier
- the binary object identifier- Returns:
- a new completion stage that, when the stage completes normally, indicates that the binary data
were successfully deleted from the corresponding persistence layer. In the case of an unsuccessful
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.
-
setContent
public CompletionStage<Void> setContent(BinaryMetadata metadata, InputStream stream)
Description copied from interface:BinaryService
Set the content for a binary object.- Specified by:
setContent
in interfaceBinaryService
- Parameters:
metadata
- the binary metadatastream
- the content- Returns:
- the new completion stage
-
generateIdentifier
public String generateIdentifier(IRI identifier)
Description copied from interface:BinaryService
Get a new identifier.- Specified by:
generateIdentifier
in interfaceBinaryService
- Parameters:
identifier
- the associated resource identifier- Returns:
- a new identifier
-
-