Class LocalStorage

java.lang.Object
i5.las2peer.persistency.LocalStorage
All Implemented Interfaces:
L2pStorageInterface

public class LocalStorage
extends java.lang.Object
implements L2pStorageInterface
  • Constructor Details

  • Method Details

    • createEnvelope

      public EnvelopeVersion createEnvelope​(java.lang.String identifier, java.security.PublicKey authorPubKey, java.io.Serializable content, AgentImpl... readers) throws java.lang.IllegalArgumentException, SerializationException, CryptoException
      Description copied from interface: L2pStorageInterface
      Creates a new version of an Envelope. The Envelope uses by default the start version number.
      Specified by:
      createEnvelope in interface L2pStorageInterface
      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:
      java.lang.IllegalArgumentException - If the given identifier is null, 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

      public EnvelopeVersion createEnvelope​(java.lang.String identifier, java.security.PublicKey authorPubKey, java.io.Serializable content, java.util.Collection<?> readers) throws java.lang.IllegalArgumentException, SerializationException, CryptoException
      Description copied from interface: L2pStorageInterface
      Creates a new version of an Envelope. The Envelope uses by default the start version number.
      Specified by:
      createEnvelope in interface L2pStorageInterface
      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:
      java.lang.IllegalArgumentException - If the given identifier is null, 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

      public EnvelopeVersion createEnvelope​(EnvelopeVersion previousVersion, java.io.Serializable content) throws java.lang.IllegalArgumentException, SerializationException, CryptoException
      Description copied from interface: L2pStorageInterface
      Creates an continuous version instance for the given Envelope. This method copies the reader list from the previous Envelope instance.
      Specified by:
      createEnvelope in interface L2pStorageInterface
      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:
      java.lang.IllegalArgumentException - If the given identifier is null, 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

      public EnvelopeVersion createEnvelope​(EnvelopeVersion previousVersion, java.io.Serializable content, AgentImpl... readers) throws java.lang.IllegalArgumentException, SerializationException, CryptoException
      Description copied from interface: L2pStorageInterface
      Creates an continuous version instance for the given Envelope.
      Specified by:
      createEnvelope in interface L2pStorageInterface
      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:
      java.lang.IllegalArgumentException - If the given identifier is null, 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

      public EnvelopeVersion createEnvelope​(EnvelopeVersion previousVersion, java.io.Serializable content, java.util.Collection<?> readers) throws java.lang.IllegalArgumentException, SerializationException, CryptoException
      Description copied from interface: L2pStorageInterface
      Creates an continous version instance for the given Envelope.
      Specified by:
      createEnvelope in interface L2pStorageInterface
      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:
      java.lang.IllegalArgumentException - If the given identifier is null, 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

      public EnvelopeVersion createUnencryptedEnvelope​(java.lang.String identifier, java.security.PublicKey authorPubKey, java.io.Serializable content) throws java.lang.IllegalArgumentException, SerializationException, CryptoException
      Description copied from interface: L2pStorageInterface
      Creates a new version of an unencrypted Envelope. The Envelope uses by default the start version number.
      Specified by:
      createUnencryptedEnvelope in interface L2pStorageInterface
      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:
      java.lang.IllegalArgumentException - If the given identifier is null, 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

      public EnvelopeVersion createUnencryptedEnvelope​(EnvelopeVersion previousVersion, java.io.Serializable content) throws java.lang.IllegalArgumentException, SerializationException, CryptoException
      Description copied from interface: L2pStorageInterface
      Creates an continous unencrypted version instance for the given Envelope.
      Specified by:
      createUnencryptedEnvelope in interface L2pStorageInterface
      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:
      java.lang.IllegalArgumentException - If the given identifier is null, 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

      public void storeEnvelope​(EnvelopeVersion envelope, AgentImpl author, long timeoutMs) throws EnvelopeException
      Description copied from interface: L2pStorageInterface
      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 an EnvelopeAlreadyExistsException.
      Specified by:
      storeEnvelope in interface L2pStorageInterface
      Parameters:
      envelope - The Envelope to store in the network.
      author - The author that is used to sign the content.
      timeoutMs - A timeout after that an EnvelopeException 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

      public void storeEnvelopeAsync​(EnvelopeVersion envelope, AgentImpl author, StorageStoreResultHandler resultHandler, StorageCollisionHandler collisionHandler, StorageExceptionHandler exceptionHandler)
      Description copied from interface: L2pStorageInterface
      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.
      Specified by:
      storeEnvelopeAsync in interface L2pStorageInterface
      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

      public EnvelopeVersion fetchEnvelope​(java.lang.String identifier, long timeoutMs) throws EnvelopeException
      Description copied from interface: L2pStorageInterface
      Fetches the latest version for the given identifier from the network.
      Specified by:
      fetchEnvelope in interface L2pStorageInterface
      Parameters:
      identifier - An unique identifier for the Envelope.
      timeoutMs - A timeout after that an EnvelopeException 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

      public void fetchEnvelopeAsync​(java.lang.String identifier, StorageEnvelopeHandler envelopeHandler, StorageExceptionHandler exceptionHandler)
      Description copied from interface: L2pStorageInterface
      Fetches the latest version for the given identifier from the network.
      Specified by:
      fetchEnvelopeAsync in interface L2pStorageInterface
      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

      public void removeEnvelope​(java.lang.String identifier) throws EnvelopeException
      Description copied from interface: L2pStorageInterface
      Removes the envelope with the given identifier from the network.
      Specified by:
      removeEnvelope in interface L2pStorageInterface
      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.