Package i5.las2peer.persistency
Class EnvelopeVersion
java.lang.Object
i5.las2peer.persistency.EnvelopeVersion
- All Implemented Interfaces:
XmlAble
,Serializable
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
freshly created local instance, can be considered asnull
static final long
The following constant is used for practical purposes to prohibit some otherwise almost infinite loops.static final long
freshly created local instance, can be considered asnull
static final long
first version, that reaches the network -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
EnvelopeVersion
(EnvelopeVersion previousVersion, Serializable content) Creates an continuous version instance for the given Envelope.protected
EnvelopeVersion
(EnvelopeVersion previousVersion, Serializable content, Collection<?> readers) Creates an continuous version instance for the given Envelope.protected
EnvelopeVersion
(String identifier, long version, PublicKey authorPubKey, Serializable content, Collection<?> readers, Set<String> readerGroups) Creates an envelope with the given identifier, version, content and readable by the given reader list.protected
EnvelopeVersion
(String identifier, PublicKey authorPubKey, Serializable content, Collection<?> readers) Creates a new version of an Envelope. -
Method Summary
Modifier and TypeMethodDescriptionstatic EnvelopeVersion
createFromXml
(String xml) factory for generating an envelope from the given XML String representationstatic EnvelopeVersion
createFromXml
(Element rootElement) factory for generating an envelope from the given XML String representationstatic String
getAgentIdentifier
(String agentId) Gets the authors public key of this envelope.getContent
(AgentContext context) Gets the identifier for this envelope.long
Gets the version of this envelope.boolean
toString()
Returns a XML representation of this object.
-
Field Details
-
LATEST_VERSION
public static final long LATEST_VERSIONfreshly created local instance, can be considered asnull
- See Also:
-
NULL_VERSION
public static final long NULL_VERSIONfreshly created local instance, can be considered asnull
- See Also:
-
START_VERSION
public static final long START_VERSIONfirst version, that reaches the network- See Also:
-
MAX_UPDATE_CYCLES
public static final long MAX_UPDATE_CYCLESThe following constant is used for practical purposes to prohibit some otherwise almost infinite loops. It describes the maximum number of write cycles to an envelope (identifier). Its value may be set to any value from 1 (not useful at all!) up to Long.MAX_VALUE (some parts will take almost forever).- See Also:
-
-
Constructor Details
-
EnvelopeVersion
protected EnvelopeVersion(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 updated content that should be stored.readers
- An arbitrary number of Agents, who are allowed to read the content.- Throws:
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.
-
EnvelopeVersion
protected EnvelopeVersion(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.- Throws:
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.
-
EnvelopeVersion
protected EnvelopeVersion(EnvelopeVersion previousVersion, Serializable content, Collection<?> 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.- Throws:
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.
-
EnvelopeVersion
protected EnvelopeVersion(String identifier, long version, PublicKey authorPubKey, Serializable content, Collection<?> readers, Set<String> readerGroups) throws IllegalArgumentException, SerializationException, CryptoException Creates an envelope with the given identifier, version, content and readable by the given reader list.- Parameters:
identifier
- An unique identifier for the envelope.version
- The version number for this envelope.authorPubKey
- The authors public key for this envelope.content
- The actual content that should be stored.readers
- An arbitrary number of Agents, who are allowed to read the content.readerGroups
- A set of group agent id's with read access.- Throws:
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.
-
-
Method Details
-
getAgentIdentifier
-
getIdentifier
Gets the identifier for this envelope.- Returns:
- Returns the identifier.
-
getVersion
public long getVersion()Gets the version of this envelope.- Returns:
- Returns the version number.
-
getAuthorPublicKey
Gets the authors public key of this envelope.- Returns:
- Returns the authors public key.
-
toString
-
isEncrypted
public boolean isEncrypted() -
getReaderKeys
-
getReaderGroupIds
-
getContent
public Serializable getContent() throws CryptoException, EnvelopeAccessDeniedException, SerializationException -
getContent
public Serializable getContent(AgentContext context) throws CryptoException, EnvelopeAccessDeniedException, SerializationException -
toXmlString
Description copied from interface:XmlAble
Returns a XML representation of this object.- Specified by:
toXmlString
in interfaceXmlAble
- Returns:
- a XML (string) representation of this envelope
- Throws:
SerializationException
- If serialization fails
-
createFromXml
factory for generating an envelope from the given XML String representation- Parameters:
rootElement
- A root element to use- Returns:
- envelope created from the given XML String serialization
- Throws:
MalformedXMLException
- If the XML data is malformed
-
createFromXml
factory for generating an envelope from the given XML String representation- Parameters:
xml
- An XML data string- Returns:
- envelope created from the given XML String serialization
- Throws:
MalformedXMLException
- If the XML data string is malformed
-