public class H2BinaryDatabase extends Object implements BinaryDatabase
BinaryDatabase using H2 database| Constructor and Description |
|---|
H2BinaryDatabase(@NonNull UUID serverId)
Construct a
BinaryDatabase for a specific server. |
| Modifier and Type | Method and Description |
|---|---|
Duration |
addBinary(@NonNull UUID binaryTransferUuid,
byte[] bytes,
@NonNull String parameterIdentifier)
Save a binary stream to the database
|
Duration |
addBinary(@NonNull UUID binaryTransferUuid,
@NonNull InputStream stream,
@NonNull String parameterIdentifier)
Save a binary stream to the database
|
void |
close()
Cleanup method
Delete binaries, close the database and shutdown the
cleaner worker |
Duration |
extendBinaryExpiration(@NonNull UUID binaryTransferUuid)
Extend the binary expiration duration by
BINARY_EXTEND_DURATION |
Binary |
getBinary(@NonNull UUID binaryTransferUuid)
Retrieve a binary from the database
|
BinaryInfo |
getBinaryInfo(@NonNull UUID binaryTransferUuid)
Retrieve a binary
binary info |
boolean |
hasBinary(UUID binaryTransferUuid)
Check if the specified binary transfer UUID exists
|
void |
removeAllBinaries()
Remove the BINARIES table and hence all binaries from the database
|
void |
removeBinary(@NonNull UUID binaryTransferUuid)
Remove the specified binary from the database
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcurrentpublic H2BinaryDatabase(@NonNull
@NonNull UUID serverId)
throws SQLException
BinaryDatabase for a specific server.
The default credentials are database user database password
The default binary expiration is secondsserverId - The server UUIDSQLException - raised if the SQL_INIT query failspublic void close()
cleaner workerclose in interface AutoCloseablepublic Binary getBinary(@NonNull @NonNull UUID binaryTransferUuid) throws BinaryDatabaseException
getBinary in interface BinaryDatabasebinaryTransferUuid - the binary identifierBinaryDatabaseException - if the binary does not exist or the database connection failedpublic boolean hasBinary(UUID binaryTransferUuid) throws BinaryDatabaseException
hasBinary in interface BinaryDatabasebinaryTransferUuid - the binary identifierBinaryDatabaseException - if the binary does not exist or the database connection failedpublic BinaryInfo getBinaryInfo(@NonNull @NonNull UUID binaryTransferUuid) throws BinaryDatabaseException
binary infogetBinaryInfo in interface BinaryDatabasebinaryTransferUuid - the binary identifierBinaryDatabaseException - if the binary does not exist or the database connection failedpublic Duration addBinary(@NonNull @NonNull UUID binaryTransferUuid, byte[] bytes, @NonNull @NonNull String parameterIdentifier) throws BinaryDatabaseException
addBinary in interface BinaryDatabasebinaryTransferUuid - the binary identifierbytes - The data stream to save in the databaseparameterIdentifier - The fully qualified parameter identifierBinaryDatabaseException - if the binary could not be savedpublic Duration addBinary(@NonNull @NonNull UUID binaryTransferUuid, @NonNull @NonNull InputStream stream, @NonNull @NonNull String parameterIdentifier) throws BinaryDatabaseException
addBinary in interface BinaryDatabasebinaryTransferUuid - the binary identifierstream - The data stream to save in the databaseparameterIdentifier - The fully qualified parameter identifierBinaryDatabaseException - if the binary could not be savedpublic Duration extendBinaryExpiration(@NonNull @NonNull UUID binaryTransferUuid) throws BinaryDatabaseException
BINARY_EXTEND_DURATIONextendBinaryExpiration in interface BinaryDatabasebinaryTransferUuid - The binary identifierBinaryDatabaseException - if the binary could not be extendedpublic void removeAllBinaries()
throws BinaryDatabaseException
removeAllBinaries in interface BinaryDatabaseBinaryDatabaseException - If the removal of the binaries failedpublic void removeBinary(@NonNull
@NonNull UUID binaryTransferUuid)
throws BinaryDatabaseException
removeBinary in interface BinaryDatabasebinaryTransferUuid - The binary identifier to removeBinaryDatabaseException - If to binary removal failedCopyright © 2022 SiLA Java Developers. All rights reserved.