Package org.dspace.content
Class Bitstream
- java.lang.Object
-
- org.dspace.content.DSpaceObject
-
- org.dspace.content.Bitstream
-
- All Implemented Interfaces:
Serializable,DSpaceObjectLegacySupport,ReloadableEntity<UUID>
@Entity public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport
Class representing bitstreams stored in the DSpace system.When modifying the bitstream metadata, changes are not reflected in the database until
updateis called. Note that you cannot alter the contents of a bitstream; you need to create a new bitstream.- Author:
- Robert Tansley
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.dspace.content.DSpaceObject
id, predefinedUUID
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedBitstream()Protected constructor, create object using:BitstreamService.create(Context, Bundle, InputStream)orBitstreamService.create(Context, InputStream)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object other)Returntrueifotheris the same Bitstream as this object,falseotherwiseprotected BitstreamFormatgetBitstreamFormat()List<Bundle>getBundles()Get the bundles this bitstream appears inStringgetChecksum()Get the checksum of the content of the bitstream, for integrity checkingStringgetChecksumAlgorithm()Get the algorithm used to calculate the checksumCollectiongetCollection()CommunitygetCommunity()StringgetDescription()Get the description of this bitstream - optional free text, typically provided by a user at submission timeBitstreamFormatgetFormat(Context context)Get the format of the bitstreamStringgetFormatDescription(Context context)Get the description of the format - either the user's or the description of the format defined by the system.StringgetInternalId()IntegergetLegacyId()StringgetName()Get the name of this bitstream - typically the filename, without any path informationintgetSequenceID()Get the sequence ID of this bitstream.longgetSizeBytes()Get the size of the bitstreamStringgetSource()Get the source of this bitstream - typically the filename with path information (if originally provided) or the name of the tool that generated this bitstreamintgetStoreNumber()Get the asset store number where this bitstream is storedintgetType()return type found in ConstantsStringgetUserFormatDescription()Get the user's format description.inthashCode()booleanisDeleted()Bitstreams are only logically deleted (via a flag in the database).voidsetAcceptanceDate(Context context, DCDate acceptanceDate)Add date for bitstream granted (used into the use case for license grant theLicenseUtils.grantLicense(Context, Item, String, String)voidsetChecksum(String checksum)voidsetChecksumAlgorithm(String checksumAlgorithm)voidsetDeleted(boolean deleted)voidsetDescription(Context context, String n)Set the description of the bitstreamvoidsetFormat(Context context, BitstreamFormat f)Set the format of the bitstream.voidsetInternalId(String internalId)voidsetName(Context context, String n)Set the name of the bitstreamvoidsetSequenceID(int sid)Set the sequence ID of this bitstream.voidsetSizeBytes(long sizeBytes)voidsetSource(Context context, String n)Set the source of the bitstreamvoidsetStoreNumber(int storeNumber)Set the asset store number where this bitstream is storedvoidsetUserFormatDescription(Context context, String desc)Set the user's format description.-
Methods inherited from class org.dspace.content.DSpaceObject
addDetails, addHandle, addMetadata, clearDetails, clearModified, getDetails, getHandle, getHandles, getID, getMetadata, getPredefinedUUID, getResourcePolicies, isMetadataModified, isModified, removeMetadata, removeMetadata, setMetadata, setMetadataModified, setModified
-
-
-
-
Constructor Detail
-
Bitstream
protected Bitstream()
Protected constructor, create object using:BitstreamService.create(Context, Bundle, InputStream)orBitstreamService.create(Context, InputStream)
-
-
Method Detail
-
getSequenceID
public int getSequenceID()
Get the sequence ID of this bitstream. The sequence ID is a unique (within an Item) integer that references this bitstream. It acts as a "persistent" identifier within the Item for this Bitstream (as Bitstream names are not persistent). Because it is unique within an Item, sequence IDs are assigned by the ItemService.update() method.- Returns:
- the sequence ID
- See Also:
ItemServiceImpl.update(Context, Item)
-
setSequenceID
public void setSequenceID(int sid)
Set the sequence ID of this bitstream. The sequence ID is a unique (within an Item) integer that references this bitstream. While this method is public, it should only be used by ItemService.update() or other methods which validate the uniqueness of the ID within the associated Item. This method itself does not validate uniqueness of the ID, nor does the underlying database table.- Parameters:
sid- the ID- See Also:
ItemServiceImpl.update(Context, Item)
-
getName
public String getName()
Get the name of this bitstream - typically the filename, without any path information- Specified by:
getNamein classDSpaceObject- Returns:
- the name of the bitstream
-
setName
public void setName(Context context, String n) throws SQLException
Set the name of the bitstream- Parameters:
context- contextn- the new name of the bitstream- Throws:
SQLException- if database error
-
getSource
public String getSource()
Get the source of this bitstream - typically the filename with path information (if originally provided) or the name of the tool that generated this bitstream- Returns:
- the source of the bitstream
-
setSource
public void setSource(Context context, String n) throws SQLException
Set the source of the bitstream- Parameters:
context- contextn- the new source of the bitstream- Throws:
SQLException- if database error
-
getDescription
public String getDescription()
Get the description of this bitstream - optional free text, typically provided by a user at submission time- Returns:
- the description of the bitstream
-
setDescription
public void setDescription(Context context, String n) throws SQLException
Set the description of the bitstream- Parameters:
context- contextn- the new description of the bitstream- Throws:
SQLException- if database error
-
getChecksum
public String getChecksum()
Get the checksum of the content of the bitstream, for integrity checking- Returns:
- the checksum
-
setChecksum
public void setChecksum(String checksum)
-
getChecksumAlgorithm
public String getChecksumAlgorithm()
Get the algorithm used to calculate the checksum- Returns:
- the algorithm, e.g. "MD5"
-
setChecksumAlgorithm
public void setChecksumAlgorithm(String checksumAlgorithm)
-
getSizeBytes
public long getSizeBytes()
Get the size of the bitstream- Returns:
- the size in bytes
-
setSizeBytes
public void setSizeBytes(long sizeBytes)
-
getUserFormatDescription
public String getUserFormatDescription()
Get the user's format description. Returns null if the format is known by the system.- Returns:
- the user's format description.
-
getBitstreamFormat
protected BitstreamFormat getBitstreamFormat()
-
getFormat
public BitstreamFormat getFormat(Context context) throws SQLException
Get the format of the bitstream- Parameters:
context- context- Returns:
- the format of this bitstream
- Throws:
SQLException- if database error
-
isDeleted
public boolean isDeleted() throws SQLExceptionBitstreams are only logically deleted (via a flag in the database). This method allows us to verify is the bitstream is still valid- Returns:
- true if the bitstream has been deleted
- Throws:
SQLException- if database error
-
setDeleted
public void setDeleted(boolean deleted)
-
getBundles
public List<Bundle> getBundles() throws SQLException
Get the bundles this bitstream appears in- Returns:
- array of
Bundles this bitstream appears in - Throws:
SQLException- if database error
-
getType
public int getType()
return type found in Constants- Specified by:
getTypein classDSpaceObject- Returns:
- int Constants.BITSTREAM
-
getCollection
public Collection getCollection()
-
getCommunity
public Community getCommunity()
-
getStoreNumber
public int getStoreNumber()
Get the asset store number where this bitstream is stored- Returns:
- the asset store number of the bitstream
-
setStoreNumber
public void setStoreNumber(int storeNumber)
Set the asset store number where this bitstream is stored- Parameters:
storeNumber- asset store number of the bitstream
-
getInternalId
public String getInternalId()
-
setInternalId
public void setInternalId(String internalId)
-
setUserFormatDescription
public void setUserFormatDescription(Context context, String desc) throws SQLException
Set the user's format description. This implies that the format of the bitstream is uncertain, and the format is set to "unknown."- Parameters:
context- The relevant DSpace Context.desc- the user's description of the format- Throws:
SQLException- if database error
-
getFormatDescription
public String getFormatDescription(Context context) throws SQLException
Get the description of the format - either the user's or the description of the format defined by the system.- Parameters:
context- context- Returns:
- a description of the format.
- Throws:
SQLException- if database error
-
setFormat
public void setFormat(Context context, BitstreamFormat f) throws SQLException
Set the format of the bitstream. If the user has supplied a type description, it is cleared. Passing innullsets the type of this bitstream to "unknown".- Parameters:
context- contextf- the format of this bitstream, ornullfor unknown- Throws:
SQLException- if database error
-
getLegacyId
public Integer getLegacyId()
- Specified by:
getLegacyIdin interfaceDSpaceObjectLegacySupport- Returns:
- the old integer based legacy identifier
-
equals
public boolean equals(Object other)
Returntrueifotheris the same Bitstream as this object,falseotherwise
-
setAcceptanceDate
public void setAcceptanceDate(Context context, DCDate acceptanceDate) throws SQLException
Add date for bitstream granted (used into the use case for license grant theLicenseUtils.grantLicense(Context, Item, String, String)- Parameters:
context- the dspace contextacceptanceDate- the granted date- Throws:
SQLException
-
-