dk.netarkivet.harvester.harvesting.distribute
Class MetadataEntry

java.lang.Object
  extended by dk.netarkivet.harvester.harvesting.distribute.MetadataEntry
All Implemented Interfaces:
java.io.Serializable

public class MetadataEntry
extends java.lang.Object
implements java.io.Serializable

Class used to carry metadata in DoOneCrawl messages, including the URL and mimetype necessary to write the metadata to metadata ARC files.

See Also:
Serialized Form

Constructor Summary
MetadataEntry(java.lang.String url, java.lang.String mimeType, java.lang.String data)
          Constructor for this class.
 
Method Summary
 byte[] getData()
           
 java.lang.String getMimeType()
           
 java.lang.String getURL()
           
 boolean isDuplicateReductionMetadataEntry()
          Checks, if this is a duplicate reduction MetadataEntry.
static MetadataEntry makeAliasMetadataEntry(java.util.List<AliasInfo> aliases, java.lang.Long origHarvestDefinitionID, int harvestNum, java.lang.Long jobId)
          Generate a MetadataEntry from a list of AliasInfo objects (VERSION 2) Expired aliases is skipped by this method.
static MetadataEntry makeDuplicateReductionMetadataEntry(java.util.List<java.lang.Long> jobIDsForDuplicateReduction, java.lang.Long origHarvestDefinitionID, int harvestNum, java.lang.Long jobId)
          Generate a MetadataEntry from a list of job ids for duplicate reduction.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MetadataEntry

public MetadataEntry(java.lang.String url,
                     java.lang.String mimeType,
                     java.lang.String data)
Constructor for this class.

Parameters:
url - the URL assigned to this metadata (needed for it to be searchable)
mimeType - the mimeType for this metadata (normally text/plain or text/xml)
data - the metadata itself
Throws:
ArgumentNotValid - if arguments are null or empty strings, or if argument url is not valid URL or if argument mimeType is not valid MimeType
Method Detail

makeAliasMetadataEntry

public static MetadataEntry makeAliasMetadataEntry(java.util.List<AliasInfo> aliases,
                                                   java.lang.Long origHarvestDefinitionID,
                                                   int harvestNum,
                                                   java.lang.Long jobId)
Generate a MetadataEntry from a list of AliasInfo objects (VERSION 2) Expired aliases is skipped by this method.

Parameters:
aliases - the list of aliases (possibly empty)
origHarvestDefinitionID - The harvestdefinition that is behind the job with the given jobId
harvestNum - The number of the harvest that the job with the given jobid belongs to
jobId - The id of the Job, which this metadata belongs to
Returns:
null, if the list if empty (or only consists of expired aliases), otherwise returns a MetadataEntry from a list of AliasInfo objects containing unexpired aliases.

makeDuplicateReductionMetadataEntry

public static MetadataEntry makeDuplicateReductionMetadataEntry(java.util.List<java.lang.Long> jobIDsForDuplicateReduction,
                                                                java.lang.Long origHarvestDefinitionID,
                                                                int harvestNum,
                                                                java.lang.Long jobId)
Generate a MetadataEntry from a list of job ids for duplicate reduction.

Parameters:
jobIDsForDuplicateReduction - the list of jobids (possibly empty)
origHarvestDefinitionID - The harvestdefinition that is behind the job with the given jobId
harvestNum - The number of the harvest that the job with the given jobid belongs to
jobId - The id of the Job, which this metadata belongs to
Returns:
null, if the list is empty, otherwise returns a MetadataEntry from the list of jobids.

getData

public byte[] getData()
Returns:
Returns the data.

getMimeType

public java.lang.String getMimeType()
Returns:
Returns the mimeType.

getURL

public java.lang.String getURL()
Returns:
Returns the URL

isDuplicateReductionMetadataEntry

public boolean isDuplicateReductionMetadataEntry()
Checks, if this is a duplicate reduction MetadataEntry.

Returns:
true, if this is a duplicate reduction MetadataEntry, otherwise false.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
a string representation of this object