org.tranche.meta
Class MetaData

java.lang.Object
  extended by org.tranche.meta.MetaData

public class MetaData
extends java.lang.Object

Object that represents a meta data chunk on the Tranche network.

Author:
Jayson Falkner - jfalkner@umich.edu, James "Augie" Hill - augman85@gmail.com, Bryan Smith - bryanesmith@gmail.com

Field Summary
static int GZIP_COMPRESSED_BIT
          Flag meaning this meta data is GZIP compressed.
static int LIMITED_LIFE_BIT
          Deprecated. Use the property for expiration timestamp to denote when a file should expire.
static int MIME_TYPE_BIT
          Deprecated. Of no purpose since the mime type was moved into the properties structure and now depends on the uploader.
static int PROJECT_FILE_BIT
          Flag meaning this meta data represents a directory/project.
static java.lang.String PROP_DATA_SET_DESCRIPTION
          
static java.lang.String PROP_DATA_SET_FILES
          
static java.lang.String PROP_DATA_SET_NAME
          
static java.lang.String PROP_DATA_SET_SIZE
          
static java.lang.String PROP_HIDDEN
           
static java.lang.String PROP_MIME_TYPE
          
static java.lang.String PROP_NAME
          The name of the file.
static java.lang.String PROP_PATH_IN_DATA_SET
          The relative name of the file in the data set (includes the file name.)
static java.lang.String PROP_SHARE_INFO_IF_ENCRYPTED
           
static java.lang.String PROP_TIMESTAMP_FILE
          The last modified timestamp of the file as it existed on the uploader's system.
static java.lang.String PROP_TIMESTAMP_UPLOADED
          
static java.lang.String PROP_VERSION_NEXT
          The hash of the newer version of this file or data set.
static java.lang.String PROP_VERSION_PREVIOUS
          The hash of the older version of this file or data set.
static long SIZE_MAX
          Maximum size.
static int STICKY_DATA_BIT
          Deprecated. Making a file sticky is now done by adding a Meta Data Annotation of a server to which it should be stuck.
static int STICKY_META_DATA_BIT
          Deprecated. making a file sticky is now done by adding a Meta Data Annotation of a server to which it should be stuck.
static java.lang.String VERSION_FOUR
          Identifies the fourth meta data version -- allows for multiple uploaders and distinguishes the overlap.
static java.lang.String VERSION_LATEST
          Identifies the latest meta data version.
static java.lang.String VERSION_ONE
          Identifies the first meta data version.
static int VERSION_ONE_BIT
          Flag meaning this meta data is version 1.0
static java.lang.String VERSION_THREE
          Identifies the third meta data version -- added properties (project files, project size, project name, and project description.)
static java.lang.String VERSION_TWO
          Identifies the second meta data version -- added last modified timestamp and version.
 
Constructor Summary
MetaData()
           
 
Method Summary
 void addAnnotation(java.lang.String annotationName, java.lang.String annotationValue)
           
 void addPart(BigHash partHash)
          Adds the given hash to the list of part hashes for the final encoding of the currently selected uploader.
 void addStickyServer(java.lang.String host)
           
 void addUploader(Signature signature, java.util.ArrayList<FileEncoding> encodings, java.util.Map<java.lang.String,java.lang.String> properties, java.util.ArrayList<MetaDataAnnotation> annotations)
          In the given properties, the PROP_TIMESTAMP_UPLOADED value is overwritten by the given uploadTimestamp, and the PROP_PATH_IN_DATA_SET value is overwritten by the given fullPathInDataSet.
 void clearAnnotations()
           
 void clearPublicPassphrase()
          Clears the published passphrase.
 MetaData clone()
           
 boolean containsUploader(java.lang.String targetUploaderName, java.lang.Long targetUploadTimestamp, java.lang.String fullPathInDataSet)
           
static MetaData createFromBytes(byte[] bytes)
           
 java.util.Map<BigHash,java.util.List<BigHash>> getAllParts()
           
 java.util.Collection<java.lang.String> getAllStickyServers()
          Returns the host names for all the servers to which uploaders have designated that the file be stuck.
 java.util.List<MetaDataAnnotation> getAnnotations()
           
 java.util.Collection<MetaDataAnnotation> getAnnotationsWithName(java.lang.String name)
           
 java.util.Collection<java.lang.String> getAnnotationValuesWithName(java.lang.String name)
           
 java.lang.String getDataSetDescription()
           
 long getDataSetFiles()
           
 java.lang.String getDataSetName()
           
 long getDataSetSize()
           
 java.util.List<FileEncoding> getEncodings()
           
 int getFlags()
          Gets the flags.
 BigHash getHash()
           
 long getLastModifiedTimestamp()
          Returns the UNIX timestamp of when the meta data was last modified.
 java.lang.String getMimeType()
           
 java.lang.String getName()
           
 BigHash getNextVersion()
           
 java.util.List<BigHash> getParts()
          Returns the parts associated with the final encoding for the selected uploader.
 BigHash getPreviousVersion()
           
 java.util.Map<java.lang.String,java.lang.String> getProperties()
           
 java.lang.String getPublicPassphrase()
          Gets the published passphrase.
 java.lang.String getRelativePathInDataSet()
           
 int getSelectedUploader()
           
 Signature getSignature()
           
 java.util.Collection<java.lang.String> getStickyServers()
          Returns the host names for servers to which this uploader has designated that the file be stuck.
 long getTimestampFileModified()
           
 long getTimestampUploaded()
           
 int getUploaderCount()
           
 java.lang.String getVersion()
          Returns the version of this meta data.
 boolean isEncrypted()
          Helper method that will inspect the encodings and check that all encryptions have a passphrase.
 boolean isGZIPCompressed()
          Returns the flag for whether this meta data is GZIP compressed.
 boolean isHidden()
          Whether the file this meta data represents should be visible in searches.
 boolean isLimitedLife()
          Deprecated. No longer support expiration timestamps.
protected  boolean isMimeType()
           
 boolean isProjectFile()
          Returns the flag for whether this meta data is for a project file.
 boolean isPublicPassphraseSet()
          Returns whether the public passphrase is set.
 boolean isVersionOne()
          Returns the flag for whether this meta data is version 1.0.
 void removeAnnotation(MetaDataAnnotation annotation)
           
 void removeAnnotation(java.lang.String name, java.lang.String value)
           
 void removeStickyServer(java.lang.String host)
           
 void removeUploader(java.lang.String uploaderName, long uploadTimestamp, java.lang.String fullPathInDataSet)
           
 void selectUploader(int selectedUploader)
           
 void selectUploader(java.lang.String targetUploaderName, java.lang.Long targetUploadTimestamp, java.lang.String fullPathInDataSet)
           
 void setDataSetDescription(java.lang.String description)
           
 void setDataSetFiles(long files)
           
 void setDataSetName(java.lang.String name)
           
 void setDataSetSize(long size)
           
protected  void setFlags(int flags)
          Sets the flags.
 void setGZIPCompress(boolean GZIPcompress)
          Sets whether to GZIP compress the meta data file upon writing.
 void setHidden(boolean isHidden)
          Sets the data this meta data represents as hidden.
protected  void setIsLimitedLife(boolean isLimitedLife)
          Deprecated. No longer support expiration timestamps.
protected  void setIsMimeType(boolean isMimeType)
           
 void setIsProjectFile(boolean isProjectFile)
           
protected  void setLastModifiedTimestamp(long timestamp)
          DO NOT USE THIS METHOD.
 void setMimeType(java.lang.String mimeType)
           
 void setNextVersion(BigHash hash)
           
 void setParts(java.util.ArrayList<BigHash> parts)
           
protected  void setParts(BigHash finalEncodingHash, java.util.ArrayList<BigHash> parts)
           
 void setPreviousVersion(BigHash hash)
           
protected  void setProperty(java.lang.String name, java.lang.String value)
           
 void setPublicPassphrase(java.lang.String passphrase)
          Publish a passphrase to this meta data.
 void setShareMetaDataIfEncrypted(boolean shareMetaDataIfEncrypted)
           
 void setTimestampFileModified(long timestamp)
           
 void setVersion(java.lang.String version)
          Sets the version of this meta data.
 boolean shareMetaData()
          Whether the meta information should be shared with persons that do not have the passphrase.
 boolean shareMetaDataIfEncrypted()
           
 byte[] toByteArray()
           
 byte[] toByteArray(java.lang.String version)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION_ONE

public static final java.lang.String VERSION_ONE

Identifies the first meta data version.

See Also:
Constant Field Values

VERSION_TWO

public static final java.lang.String VERSION_TWO

Identifies the second meta data version -- added last modified timestamp and version.

See Also:
Constant Field Values

VERSION_THREE

public static final java.lang.String VERSION_THREE

Identifies the third meta data version -- added properties (project files, project size, project name, and project description.)

See Also:
Constant Field Values

VERSION_FOUR

public static final java.lang.String VERSION_FOUR

Identifies the fourth meta data version -- allows for multiple uploaders and distinguishes the overlap.

See Also:
Constant Field Values

VERSION_LATEST

public static final java.lang.String VERSION_LATEST

Identifies the latest meta data version.

See Also:
Constant Field Values

VERSION_ONE_BIT

public static final int VERSION_ONE_BIT

Flag meaning this meta data is version 1.0

Not useful past the first version.


PROJECT_FILE_BIT

public static final int PROJECT_FILE_BIT

Flag meaning this meta data represents a directory/project.


STICKY_DATA_BIT

public static final int STICKY_DATA_BIT
Deprecated. Making a file sticky is now done by adding a Meta Data Annotation of a server to which it should be stuck.

Flag meaning this meta data represents sticky data.


STICKY_META_DATA_BIT

public static final int STICKY_META_DATA_BIT
Deprecated. making a file sticky is now done by adding a Meta Data Annotation of a server to which it should be stuck.

Flag meaning this meta data represents stick meta data.


GZIP_COMPRESSED_BIT

public static final int GZIP_COMPRESSED_BIT

Flag meaning this meta data is GZIP compressed.


LIMITED_LIFE_BIT

public static final int LIMITED_LIFE_BIT
Deprecated. Use the property for expiration timestamp to denote when a file should expire.

Flag meaning this meta data is limited life.


MIME_TYPE_BIT

public static final int MIME_TYPE_BIT
Deprecated. Of no purpose since the mime type was moved into the properties structure and now depends on the uploader.

Flag meaning this meta data has a mime type.


PROP_DATA_SET_SIZE

public static final java.lang.String PROP_DATA_SET_SIZE

See Also:
Constant Field Values

PROP_DATA_SET_FILES

public static final java.lang.String PROP_DATA_SET_FILES

See Also:
Constant Field Values

PROP_DATA_SET_NAME

public static final java.lang.String PROP_DATA_SET_NAME

See Also:
Constant Field Values

PROP_DATA_SET_DESCRIPTION

public static final java.lang.String PROP_DATA_SET_DESCRIPTION

See Also:
Constant Field Values

PROP_TIMESTAMP_UPLOADED

public static final java.lang.String PROP_TIMESTAMP_UPLOADED

See Also:
Constant Field Values

PROP_TIMESTAMP_FILE

public static final java.lang.String PROP_TIMESTAMP_FILE

The last modified timestamp of the file as it existed on the uploader's system.

See Also:
Constant Field Values

PROP_NAME

public static final java.lang.String PROP_NAME

The name of the file.

See Also:
Constant Field Values

PROP_PATH_IN_DATA_SET

public static final java.lang.String PROP_PATH_IN_DATA_SET

The relative name of the file in the data set (includes the file name.)

See Also:
Constant Field Values

PROP_MIME_TYPE

public static final java.lang.String PROP_MIME_TYPE

See Also:
Constant Field Values

PROP_VERSION_NEXT

public static final java.lang.String PROP_VERSION_NEXT

The hash of the newer version of this file or data set.

See Also:
Constant Field Values

PROP_VERSION_PREVIOUS

public static final java.lang.String PROP_VERSION_PREVIOUS

The hash of the older version of this file or data set.

See Also:
Constant Field Values

PROP_HIDDEN

public static final java.lang.String PROP_HIDDEN
See Also:
Constant Field Values

PROP_SHARE_INFO_IF_ENCRYPTED

public static final java.lang.String PROP_SHARE_INFO_IF_ENCRYPTED
See Also:
Constant Field Values

SIZE_MAX

public static final long SIZE_MAX

Maximum size.

See Also:
Constant Field Values
Constructor Detail

MetaData

public MetaData()
Method Detail

getVersion

public final java.lang.String getVersion()

Returns the version of this meta data.

Returns:

setVersion

public final void setVersion(java.lang.String version)

Sets the version of this meta data.

Parameters:
version -

getFlags

public final int getFlags()

Gets the flags.

Returns:

setFlags

protected final void setFlags(int flags)

Sets the flags.

Parameters:
flags -

isVersionOne

public final boolean isVersionOne()

Returns the flag for whether this meta data is version 1.0.

Returns:

isGZIPCompressed

public final boolean isGZIPCompressed()

Returns the flag for whether this meta data is GZIP compressed.

Returns:

setGZIPCompress

public final void setGZIPCompress(boolean GZIPcompress)

Sets whether to GZIP compress the meta data file upon writing.

Parameters:
GZIPcompress -

isProjectFile

public final boolean isProjectFile()

Returns the flag for whether this meta data is for a project file.

Returns:

setIsProjectFile

public final void setIsProjectFile(boolean isProjectFile)
Parameters:
isProjectFile -

isLimitedLife

public final boolean isLimitedLife()
Deprecated. No longer support expiration timestamps.

Returns:

setIsLimitedLife

protected final void setIsLimitedLife(boolean isLimitedLife)
Deprecated. No longer support expiration timestamps.

Parameters:
isLimitedLife -

isMimeType

protected final boolean isMimeType()
Returns:

setIsMimeType

protected final void setIsMimeType(boolean isMimeType)
Parameters:
isMimeType -

getLastModifiedTimestamp

public final long getLastModifiedTimestamp()

Returns the UNIX timestamp of when the meta data was last modified.

Returns:

setLastModifiedTimestamp

protected final void setLastModifiedTimestamp(long timestamp)

DO NOT USE THIS METHOD. It is only meant to be used by MetaDataUtil.

Sets the UNIX timestamp of when the meta data was last modified.

Parameters:
timestamp -

containsUploader

public final boolean containsUploader(java.lang.String targetUploaderName,
                                      java.lang.Long targetUploadTimestamp,
                                      java.lang.String fullPathInDataSet)
                               throws AmbiguousFileSelectionException
Parameters:
targetUploaderName -
targetUploadTimestamp -
fullPathInDataSet -
Returns:
Throws:
AmbiguousFileSelectionException

selectUploader

public final void selectUploader(java.lang.String targetUploaderName,
                                 java.lang.Long targetUploadTimestamp,
                                 java.lang.String fullPathInDataSet)
                          throws java.lang.Exception
Parameters:
targetUploaderName -
targetUploadTimestamp -
fullPathInDataSet -
Throws:
java.lang.Exception

selectUploader

public final void selectUploader(int selectedUploader)
Parameters:
selectedUploader -

getSelectedUploader

public final int getSelectedUploader()
Returns:

getUploaderCount

public final int getUploaderCount()
Returns:

addUploader

public final void addUploader(Signature signature,
                              java.util.ArrayList<FileEncoding> encodings,
                              java.util.Map<java.lang.String,java.lang.String> properties,
                              java.util.ArrayList<MetaDataAnnotation> annotations)
                       throws java.lang.Exception

In the given properties, the PROP_TIMESTAMP_UPLOADED value is overwritten by the given uploadTimestamp, and the PROP_PATH_IN_DATA_SET value is overwritten by the given fullPathInDataSet.

Selects the added uploader.

Parameters:
signature -
encodings -
properties -
annotations -
Throws:
java.lang.Exception

removeUploader

public final void removeUploader(java.lang.String uploaderName,
                                 long uploadTimestamp,
                                 java.lang.String fullPathInDataSet)
                          throws java.lang.Exception
Parameters:
uploaderName -
uploadTimestamp -
fullPathInDataSet -
Throws:
java.lang.Exception

getSignature

public final Signature getSignature()
Returns:

getEncodings

public final java.util.List<FileEncoding> getEncodings()
Returns:

getHash

public final BigHash getHash()
Returns:

getParts

public final java.util.List<BigHash> getParts()

Returns the parts associated with the final encoding for the selected uploader.

Returns:

setParts

protected final void setParts(BigHash finalEncodingHash,
                              java.util.ArrayList<BigHash> parts)
Parameters:
finalEncodingHash -
parts -

addPart

public final void addPart(BigHash partHash)

Adds the given hash to the list of part hashes for the final encoding of the currently selected uploader.

Parameters:
partHash -

setParts

public final void setParts(java.util.ArrayList<BigHash> parts)
Parameters:
parts -

getAllParts

public final java.util.Map<BigHash,java.util.List<BigHash>> getAllParts()
Returns:

getProperties

public final java.util.Map<java.lang.String,java.lang.String> getProperties()
Returns:

setProperty

protected final void setProperty(java.lang.String name,
                                 java.lang.String value)
Parameters:
name -
value -

getAnnotations

public final java.util.List<MetaDataAnnotation> getAnnotations()
Returns:

getAnnotationsWithName

public final java.util.Collection<MetaDataAnnotation> getAnnotationsWithName(java.lang.String name)
Parameters:
name -
Returns:

getAnnotationValuesWithName

public final java.util.Collection<java.lang.String> getAnnotationValuesWithName(java.lang.String name)
Parameters:
name -
Returns:

addAnnotation

public final void addAnnotation(java.lang.String annotationName,
                                java.lang.String annotationValue)
Parameters:
annotationName -
annotationValue -

removeAnnotation

public final void removeAnnotation(MetaDataAnnotation annotation)
Parameters:
annotation -

removeAnnotation

public final void removeAnnotation(java.lang.String name,
                                   java.lang.String value)
Parameters:
name -
value -

clearAnnotations

public final void clearAnnotations()

isEncrypted

public final boolean isEncrypted()

Helper method that will inspect the encodings and check that all encryptions have a passphrase.

Returns:

setPublicPassphrase

public final void setPublicPassphrase(java.lang.String passphrase)
                               throws java.lang.Exception

Publish a passphrase to this meta data.

Parameters:
passphrase -
Throws:
java.lang.Exception

clearPublicPassphrase

public final void clearPublicPassphrase()
                                 throws java.lang.Exception

Clears the published passphrase.

Throws:
java.lang.Exception

getPublicPassphrase

public final java.lang.String getPublicPassphrase()
                                           throws java.lang.Exception

Gets the published passphrase.

Returns:
Throws:
java.lang.Exception

isPublicPassphraseSet

public final boolean isPublicPassphraseSet()

Returns whether the public passphrase is set.

Returns:

getName

public final java.lang.String getName()
Returns:

getTimestampUploaded

public final long getTimestampUploaded()
Returns:

getRelativePathInDataSet

public final java.lang.String getRelativePathInDataSet()
Returns:

getMimeType

public final java.lang.String getMimeType()
Returns:

setMimeType

public final void setMimeType(java.lang.String mimeType)
Parameters:
mimeType -

getTimestampFileModified

public final long getTimestampFileModified()
Returns:

setTimestampFileModified

public final void setTimestampFileModified(long timestamp)
Parameters:
timestamp -

getNextVersion

public final BigHash getNextVersion()
Returns:

setNextVersion

public final void setNextVersion(BigHash hash)
Parameters:
hash -

getPreviousVersion

public final BigHash getPreviousVersion()
Returns:

setPreviousVersion

public final void setPreviousVersion(BigHash hash)
Parameters:
hash -

getDataSetFiles

public final long getDataSetFiles()
Returns:

setDataSetFiles

public final void setDataSetFiles(long files)
Parameters:
files -

getDataSetSize

public final long getDataSetSize()
Returns:

setDataSetSize

public final void setDataSetSize(long size)
Parameters:
size -

getDataSetName

public final java.lang.String getDataSetName()
Returns:

setDataSetName

public final void setDataSetName(java.lang.String name)
Parameters:
name -

getDataSetDescription

public final java.lang.String getDataSetDescription()
Returns:

setDataSetDescription

public final void setDataSetDescription(java.lang.String description)
Parameters:
description -

shareMetaDataIfEncrypted

public final boolean shareMetaDataIfEncrypted()
Returns:

setShareMetaDataIfEncrypted

public final void setShareMetaDataIfEncrypted(boolean shareMetaDataIfEncrypted)
Parameters:
shareMetaDataIfEncrypted -

shareMetaData

public final boolean shareMetaData()

Whether the meta information should be shared with persons that do not have the passphrase.

Returns:

isHidden

public final boolean isHidden()

Whether the file this meta data represents should be visible in searches.

Returns:

setHidden

public void setHidden(boolean isHidden)

Sets the data this meta data represents as hidden.

Parameters:
isHidden -

getAllStickyServers

public final java.util.Collection<java.lang.String> getAllStickyServers()

Returns the host names for all the servers to which uploaders have designated that the file be stuck.

Returns:
A collection of Tranche server host names

getStickyServers

public final java.util.Collection<java.lang.String> getStickyServers()

Returns the host names for servers to which this uploader has designated that the file be stuck.

Returns:
A collection of Tranche server host names

addStickyServer

public final void addStickyServer(java.lang.String host)
Parameters:
host -

removeStickyServer

public final void removeStickyServer(java.lang.String host)
Parameters:
host -

clone

public final MetaData clone()
Overrides:
clone in class java.lang.Object
Returns:

toByteArray

public final byte[] toByteArray()
                         throws java.lang.Exception
Returns:
Throws:
java.lang.Exception

toByteArray

public final byte[] toByteArray(java.lang.String version)
                         throws java.lang.Exception
Parameters:
version -
Returns:
Throws:
java.lang.Exception

createFromBytes

public static final MetaData createFromBytes(byte[] bytes)
                                      throws java.lang.Exception
Parameters:
bytes -
Returns:
Throws:
java.lang.Exception


This code is free for use both commercially and non-commercially as stated in the project's license