Package i5.las2peer.persistency
Interface L2pStorageInterface
- All Known Subinterfaces:
NodeStorageInterface
- All Known Implementing Classes:
EthereumNode
,LocalNode
,LocalStorage
,Node
,PastryNodeImpl
,SharedStorage
public interface L2pStorageInterface
-
Method Summary
Modifier and TypeMethodDescriptioncreateEnvelope
(EnvelopeVersion previousVersion, Serializable content) Creates an continuous version instance for the given Envelope.createEnvelope
(EnvelopeVersion previousVersion, Serializable content, AgentImpl... readers) Creates an continuous version instance for the given Envelope.createEnvelope
(EnvelopeVersion previousVersion, Serializable content, Collection<?> readers) Creates an continous version instance for the given Envelope.createEnvelope
(String identifier, PublicKey authorPubKey, Serializable content, AgentImpl... readers) Creates a new version of an Envelope.createEnvelope
(String identifier, PublicKey authorPubKey, Serializable content, Collection<?> readers) Creates a new version of an Envelope.createUnencryptedEnvelope
(EnvelopeVersion previousVersion, Serializable content) Creates an continous unencrypted version instance for the given Envelope.createUnencryptedEnvelope
(String identifier, PublicKey authorPubKey, Serializable content) Creates a new version of an unencrypted Envelope.fetchEnvelope
(String identifier, long timeoutMs) Fetches the latest version for the given identifier from the network.void
fetchEnvelopeAsync
(String identifier, StorageEnvelopeHandler envelopeHandler, StorageExceptionHandler exceptionHandler) Fetches the latest version for the given identifier from the network.void
removeEnvelope
(String identifier) Removes the envelope with the given identifier from the network.void
storeEnvelope
(EnvelopeVersion Envelope, AgentImpl author, long timeoutMs) Stores the given Envelope in the network.void
storeEnvelopeAsync
(EnvelopeVersion Envelope, AgentImpl author, StorageStoreResultHandler resultHandler, StorageCollisionHandler collisionHandler, StorageExceptionHandler exceptionHandler) Stores the given Envelope in the network.
-
Method Details
-
createEnvelope
EnvelopeVersion createEnvelope(String identifier, PublicKey authorPubKey, Serializable content, AgentImpl... readers) throws IllegalArgumentException, SerializationException, CryptoException Creates a new version of an Envelope. The Envelope uses by default the start version number.- Parameters:
identifier
- An unique identifier for the Envelope.authorPubKey
- The authors public key. Validated on store operation.content
- The actual content that should be stored.readers
- An arbitrary number of Agents, who are allowed to read the content.- Returns:
- Returns the Envelope instance.
- Throws:
IllegalArgumentException
- If the given identifier isnull
, the version number is below the start version number or too high.SerializationException
- If a problem occurs with object serialization.CryptoException
- If an cryptographic issue occurs.
-
createEnvelope
EnvelopeVersion createEnvelope(String identifier, PublicKey authorPubKey, Serializable content, Collection<?> readers) throws IllegalArgumentException, SerializationException, CryptoException Creates a new version of an Envelope. The Envelope uses by default the start version number.- Parameters:
identifier
- An unique identifier for the Envelope.authorPubKey
- The authors public key. Validated on store operation.content
- The actual content that should be stored.readers
- An arbitrary number of Agents, who are allowed to read the content.- Returns:
- Returns the Envelope instance.
- Throws:
IllegalArgumentException
- If the given identifier isnull
, the version number is below the start version number or too high.SerializationException
- If a problem occurs with object serialization.CryptoException
- If an cryptographic issue occurs.
-
createEnvelope
EnvelopeVersion createEnvelope(EnvelopeVersion previousVersion, Serializable content) throws IllegalArgumentException, SerializationException, CryptoException Creates an continuous version instance for the given Envelope. This method copies the reader list from the previous Envelope instance.- Parameters:
previousVersion
- The previous version of the Envelope that should be updated.content
- The updated content that should be stored.- Returns:
- Returns the Envelope instance.
- Throws:
IllegalArgumentException
- If the given identifier isnull
, the version number is below the start version number or too high.SerializationException
- If a problem occurs with object serialization.CryptoException
- If an cryptographic issue occurs.
-
createEnvelope
EnvelopeVersion createEnvelope(EnvelopeVersion previousVersion, Serializable content, AgentImpl... readers) throws IllegalArgumentException, SerializationException, CryptoException Creates an continuous version instance for the given Envelope.- Parameters:
previousVersion
- The previous version of the Envelope that should be updated.content
- The updated content that should be stored.readers
- An arbitrary number of Agents, who are allowed to read the content.- Returns:
- Returns the Envelope instance.
- Throws:
IllegalArgumentException
- If the given identifier isnull
, the version number is below the start version number or too high.SerializationException
- If a problem occurs with object serialization.CryptoException
- If an cryptographic issue occurs.
-
createEnvelope
EnvelopeVersion createEnvelope(EnvelopeVersion previousVersion, Serializable content, Collection<?> readers) throws IllegalArgumentException, SerializationException, CryptoException Creates an continous version instance for the given Envelope.- Parameters:
previousVersion
- The previous version of the Envelope that should be updated.content
- The updated content that should be stored.readers
- An arbitrary number of Agents, who are allowed to read the content.- Returns:
- Returns the Envelope instance.
- Throws:
IllegalArgumentException
- If the given identifier isnull
, the version number is below the start version number or too high.SerializationException
- If a problem occurs with object serialization.CryptoException
- If an cryptographic issue occurs.
-
createUnencryptedEnvelope
EnvelopeVersion createUnencryptedEnvelope(String identifier, PublicKey authorPubKey, Serializable content) throws IllegalArgumentException, SerializationException, CryptoException Creates a new version of an unencrypted Envelope. The Envelope uses by default the start version number.- Parameters:
identifier
- An unique identifier for the Envelope.authorPubKey
- The authors public key. Validated on store operation.content
- The updated content that should be stored.- Returns:
- Returns the Envelope instance.
- Throws:
IllegalArgumentException
- If the given identifier isnull
, the version number is below the start version number or too high.SerializationException
- If a problem occurs with object serialization.CryptoException
- If an cryptographic issue occurs.
-
createUnencryptedEnvelope
EnvelopeVersion createUnencryptedEnvelope(EnvelopeVersion previousVersion, Serializable content) throws IllegalArgumentException, SerializationException, CryptoException Creates an continous unencrypted version instance for the given Envelope.- Parameters:
previousVersion
- The previous version of the Envelope that should be updated.content
- The updated content that should be stored.- Returns:
- Returns the Envelope instance.
- Throws:
IllegalArgumentException
- If the given identifier isnull
, the version number is below the start version number or too high.SerializationException
- If a problem occurs with object serialization.CryptoException
- If an cryptographic issue occurs.
-
storeEnvelope
void storeEnvelope(EnvelopeVersion Envelope, AgentImpl author, long timeoutMs) throws EnvelopeAlreadyExistsException, EnvelopeException Stores the given Envelope in the network. The content is signed with the key from the given author. If an exception occurs it's wrapped as StorageException. With this method collisions are handled by throwing anEnvelopeAlreadyExistsException
.- Parameters:
Envelope
- The Envelope to store in the network.author
- The author that is used to sign the content.timeoutMs
- A timeout after that anEnvelopeException
is thrown.- Throws:
EnvelopeAlreadyExistsException
- If an Envelope with the given identifier and version is already known in the network.EnvelopeException
- If an issue with the storage occurs.
-
storeEnvelopeAsync
void storeEnvelopeAsync(EnvelopeVersion Envelope, AgentImpl author, StorageStoreResultHandler resultHandler, StorageCollisionHandler collisionHandler, StorageExceptionHandler exceptionHandler) Stores the given Envelope in the network. The content is signed with the key from the given author. If an exception occurs the operation is canceled and the exception handler is called. Same for collisions. If the operations is completed the result handler is called.- Parameters:
Envelope
- The Envelope to store in the network.author
- The author that is used to sign the content.resultHandler
- A result handler that is called, if the operation terminates.collisionHandler
- A collision handler that is called, if an Envelope with the given identifier and version already exists.exceptionHandler
- An exception handler that is called, if an exception occurs.
-
fetchEnvelope
EnvelopeVersion fetchEnvelope(String identifier, long timeoutMs) throws EnvelopeNotFoundException, EnvelopeException Fetches the latest version for the given identifier from the network.- Parameters:
identifier
- An unique identifier for the Envelope.timeoutMs
- A timeout after that anEnvelopeException
is thrown.- Returns:
- Returns the fetched Envelope from the network.
- Throws:
EnvelopeNotFoundException
- If no envelope or any part of it was not found in the network.EnvelopeException
- If an issue with the storage occurs.
-
fetchEnvelopeAsync
void fetchEnvelopeAsync(String identifier, StorageEnvelopeHandler envelopeHandler, StorageExceptionHandler exceptionHandler) Fetches the latest version for the given identifier from the network.- Parameters:
identifier
- An unique identifier for the Envelope.envelopeHandler
- A result handler that is called, if the operation terminates.exceptionHandler
- An exception handler that is called, if an exception occurs.
-
removeEnvelope
Removes the envelope with the given identifier from the network.- Parameters:
identifier
- An unique identifier for the Envelope.- Throws:
EnvelopeNotFoundException
- If no envelope or any part of it was not found in the network.EnvelopeException
- If an issue with the storage occurs.
-