Package com.exedio.cope.vault
Interface VaultService
-
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
VaultFileService
,VaultReferenceService
public interface VaultService extends AutoCloseable
Implementations of VaultService must conform to the requirements set byProperties.valueService
.It is highly recommended to override
toString
with a informative message containing essential configuration of the service. For instance, this message is included into the result ofConnectProperties.probe()
.All methods are guaranteed not to be called for the empty byte sequence - this special case must be handled by the caller.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
close()
Overrides method fromAutoCloseable
to add empty default implementation.byte[]
get(String hash)
void
get(String hash, OutputStream sink)
long
getLength(String hash)
default void
purgeSchema(JobContext ctx)
Gives this service the chance to purge / cleanup whatever it needs to.boolean
put(String hash, byte[] value, VaultPutInfo info)
Is not called, if service instance was created withVaultServiceParameters.isWritable()
==false.boolean
put(String hash, InputStream value, VaultPutInfo info)
Is not called, if service instance was created withVaultServiceParameters.isWritable()
==false.boolean
put(String hash, Path value, VaultPutInfo info)
The caller must make sure, thatvalue
is not modified during the call.
-
-
-
Method Detail
-
purgeSchema
default void purgeSchema(@Nonnull JobContext ctx)
Gives this service the chance to purge / cleanup whatever it needs to. Is called byModel.purgeSchema(JobContext)
. The default implementation does nothing.
-
close
default void close()
Overrides method fromAutoCloseable
to add empty default implementation. Also requires implementations not to declare any checked exception to be thrown.- Specified by:
close
in interfaceAutoCloseable
-
getLength
long getLength(@Nonnull String hash) throws VaultNotFoundException
- Throws:
VaultNotFoundException
-
get
byte[] get(@Nonnull String hash) throws VaultNotFoundException
- Throws:
VaultNotFoundException
-
get
void get(@Nonnull String hash, @Nonnull OutputStream sink) throws VaultNotFoundException, IOException
Must notclose
orflush
sink
.If this method throws a
VaultNotFoundException
, it MUST not have modifiedsink
in any way. In particular it must not have written any byte tosink
.- Throws:
VaultNotFoundException
IOException
-
put
boolean put(@Nonnull String hash, @Nonnull byte[] value, @Nonnull VaultPutInfo info)
Is not called, if service instance was created withVaultServiceParameters.isWritable()
==false.- Returns:
true
ifhash
has been initially stored in the vault by this call. The result is used for statistics only. If the implementation does not have this information available, simply returntrue
.
-
put
boolean put(@Nonnull String hash, @Nonnull InputStream value, @Nonnull VaultPutInfo info) throws IOException
Is not called, if service instance was created withVaultServiceParameters.isWritable()
==false.- Returns:
true
ifhash
has been initially stored in the vault by this call. The result is used for statistics only. If the implementation does not have this information available, simply returntrue
.- Throws:
IOException
-
put
boolean put(@Nonnull String hash, @Nonnull Path value, @Nonnull VaultPutInfo info) throws IOException
The caller must make sure, thatvalue
is not modified during the call. Is not called, if service instance was created withVaultServiceParameters.isWritable()
==false.- Returns:
true
ifhash
has been initially stored in the vault by this call. The result is used for statistics only. If the implementation does not have this information available, simply returntrue
.- Throws:
IOException
-
-