Package org.dspace.content
Class BitstreamServiceImpl
- java.lang.Object
-
- org.dspace.content.DSpaceObjectServiceImpl<Bitstream>
-
- org.dspace.content.BitstreamServiceImpl
-
- All Implemented Interfaces:
BitstreamService,DSpaceObjectLegacySupportService<Bitstream>,DSpaceObjectService<Bitstream>
public class BitstreamServiceImpl extends DSpaceObjectServiceImpl<Bitstream> implements BitstreamService
Service implementation for the Bitstream object. This class is responsible for all business logic calls for the Bitstream object and is autowired by spring. This class should never be accessed directly.- Author:
- kevinvandevelde at atmire.com
-
-
Field Summary
Fields Modifier and Type Field Description protected AuthorizeServiceauthorizeServiceprotected BitstreamDAObitstreamDAOprotected BitstreamFormatServicebitstreamFormatServiceprotected BitstreamStorageServicebitstreamStorageServiceprotected BundleServicebundleServiceprotected ItemServiceitemService-
Fields inherited from class org.dspace.content.DSpaceObjectServiceImpl
choiceAuthorityService, handleService, metadataAuthorityService, metadataFieldService, metadataValueService, relationshipService
-
Fields inherited from interface org.dspace.content.service.DSpaceObjectService
MD_COPYRIGHT_TEXT, MD_INTRODUCTORY_TEXT, MD_LICENSE, MD_NAME, MD_PROVENANCE_DESCRIPTION, MD_SHORT_DESCRIPTION, MD_SIDEBAR_TEXT, MD_SOURCE, MD_USER_FORMAT_DESCRIPTION
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedBitstreamServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Bitstreamclone(Context context, Bitstream bitstream)Clone the given bitstream by firstly creating a new bitstream, with a new ID.intcountBitstreamsWithoutPolicy(Context context)LongcountByStoreNumber(Context context, Integer storeNumber)intcountDeletedBitstreams(Context context)intcountTotal(Context context)Bitstreamcreate(Context context, InputStream is)Create a new bitstream, with a new ID.Bitstreamcreate(Context context, Bundle bundle, InputStream is)Create a new bitstream, with a new ID.voiddelete(Context context, Bitstream bitstream)voidexpunge(Context context, Bitstream bitstream)Remove a bitstream that has been set to "deleted" from the databaseBitstreamfind(Context context, UUID id)Generic find for when the precise type of an Entity is not knownList<Bitstream>findAll(Context context)Iterator<Bitstream>findAll(Context context, int limit, int offset)List<Bitstream>findBitstreamsWithNoRecentChecksum(Context context)BitstreamfindByIdOrLegacyId(Context context, String id)BitstreamfindByLegacyId(Context context, int id)Generic find for when the precise type of a DSO is not known, just the a pair of type number and database ID.Iterator<Bitstream>findByStoreNumber(Context context, Integer storeNumber)List<Bitstream>findDeletedBitstreams(Context context)Retrieve all bitstreams with the deleted flag set to trueList<Bitstream>findDuplicateInternalIdentifier(Context context, Bitstream bitstream)BitstreamgetBitstreamByName(Item item, String bundleName, String bitstreamName)Iterator<Bitstream>getCollectionBitstreams(Context context, Collection collection)Iterator<Bitstream>getCommunityBitstreams(Context context, Community community)BitstreamgetFirstBitstream(Item item, String bundleName)BitstreamFormatgetFormat(Context context, Bitstream bitstream)StringgetFormatDescription(Context context, Bitstream bitstream)Get the description of the format - either the user's or the description of the format defined by the system.Iterator<Bitstream>getItemBitstreams(Context context, Item item)LonggetLastModified(Bitstream bitstream)Gets the last modified timestamp of the the given bitstream's content, if known.List<Bitstream>getNotReferencedBitstreams(Context context)DSpaceObjectgetParentObject(Context context, Bitstream bitstream)Return the dspace object that "own" the current object in the hierarchy.intgetSupportsTypeConstant()Returns the Constants which this service supportsBitstreamgetThumbnail(Context context, Bitstream bitstream)booleanisRegisteredBitstream(Bitstream bitstream)Determine if this bitstream is registered (available elsewhere on filesystem than in assetstore).Bitstreamregister(Context context, int assetstore, String bitstreamPath)Register a new bitstream, with a new ID.Bitstreamregister(Context context, Bundle bundle, int assetstore, String bitstreamPath)Register a new bitstream, with a new ID.InputStreamretrieve(Context context, Bitstream bitstream)Retrieve the contents of the bitstreamvoidsetFormat(Context context, Bitstream bitstream, BitstreamFormat bitstreamFormat)Set the format of the bitstream.voidsetUserFormatDescription(Context context, Bitstream bitstream, String desc)Set the user's format description.voidupdate(Context context, Bitstream bitstream)voidupdateLastModified(Context context, Bitstream bitstream)-
Methods inherited from class org.dspace.content.DSpaceObjectServiceImpl
addAndShiftRightMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, clearMetadata, getAdminObject, getAuthoritiesAndConfidences, getElements, getElementsFilled, getIdentifiers, getMDValueByField, getMDValueByLegacyField, getMetadata, getMetadata, getMetadata, getMetadata, getMetadataByMetadataString, getMetadataFirstValue, getMetadataFirstValue, getMetadataValuePlace, getName, getTypeText, match, moveMetadata, moveSingleMetadataValue, removeMetadataValues, replaceMetadata, setMetadataModified, setMetadataSingleValue, setMetadataSingleValue
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.dspace.content.service.DSpaceObjectService
addAndShiftRightMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, clearMetadata, getAdminObject, getIdentifiers, getMetadata, getMetadata, getMetadata, getMetadata, getMetadataByMetadataString, getMetadataFirstValue, getMetadataFirstValue, getName, getTypeText, moveMetadata, removeMetadataValues, replaceMetadata, setMetadataModified, setMetadataSingleValue, setMetadataSingleValue
-
-
-
-
Field Detail
-
bitstreamDAO
@Autowired(required=true) protected BitstreamDAO bitstreamDAO
-
itemService
@Autowired(required=true) protected ItemService itemService
-
authorizeService
@Autowired(required=true) protected AuthorizeService authorizeService
-
bitstreamFormatService
@Autowired(required=true) protected BitstreamFormatService bitstreamFormatService
-
bundleService
@Autowired(required=true) protected BundleService bundleService
-
bitstreamStorageService
@Autowired(required=true) protected BitstreamStorageService bitstreamStorageService
-
-
Method Detail
-
find
public Bitstream find(Context context, UUID id) throws SQLException
Description copied from interface:DSpaceObjectServiceGeneric find for when the precise type of an Entity is not known- Specified by:
findin interfaceBitstreamService- Specified by:
findin interfaceDSpaceObjectService<Bitstream>- Parameters:
context- - the contextid- - uuid within table of typed dspace objects- Returns:
- the dspace object found, or null if it does not exist.
- Throws:
SQLException- only upon failure accessing the database.
-
findAll
public List<Bitstream> findAll(Context context) throws SQLException
- Specified by:
findAllin interfaceBitstreamService- Throws:
SQLException
-
clone
public Bitstream clone(Context context, Bitstream bitstream) throws SQLException, AuthorizeException
Description copied from interface:BitstreamServiceClone the given bitstream by firstly creating a new bitstream, with a new ID. Then set the internal identifier, file size, checksum, and checksum algorithm as same as the given bitstream. This allows multiple bitstreams to share the same internal identifier of assets . An example of such a use case scenario is versioning.- Specified by:
clonein interfaceBitstreamService- Parameters:
context- DSpace context objectbitstream- Bitstream to be cloned- Returns:
- the clone
- Throws:
SQLException- if database errorAuthorizeException
-
findAll
public Iterator<Bitstream> findAll(Context context, int limit, int offset) throws SQLException
- Specified by:
findAllin interfaceBitstreamService- Throws:
SQLException
-
create
public Bitstream create(Context context, InputStream is) throws IOException, SQLException
Description copied from interface:BitstreamServiceCreate a new bitstream, with a new ID. The checksum and file size are calculated. No authorization checks are made in this method. The newly created bitstream has the "unknown" format.- Specified by:
createin interfaceBitstreamService- Parameters:
context- DSpace context objectis- the bits to put in the bitstream- Returns:
- the newly created bitstream
- Throws:
IOException- if IO errorSQLException- if database error
-
create
public Bitstream create(Context context, Bundle bundle, InputStream is) throws IOException, SQLException, AuthorizeException
Description copied from interface:BitstreamServiceCreate a new bitstream, with a new ID. The checksum and file size are calculated. The newly created bitstream has the "unknown" format.- Specified by:
createin interfaceBitstreamService- Parameters:
context- DSpace context objectbundle- The bundle in which our bitstream should be added.is- the bits to put in the bitstream- Returns:
- the newly created bitstream
- Throws:
IOException- if IO errorSQLException- if database errorAuthorizeException- if authorization error
-
register
public Bitstream register(Context context, Bundle bundle, int assetstore, String bitstreamPath) throws IOException, SQLException, AuthorizeException
Description copied from interface:BitstreamServiceRegister a new bitstream, with a new ID. The checksum and file size are calculated. The newly created bitstream has the "unknown" format.- Specified by:
registerin interfaceBitstreamService- Parameters:
context- DSpace context objectbundle- The bundle in which our bitstream should be added.assetstore- corresponds to an assetstore in dspace.cfgbitstreamPath- the path and filename relative to the assetstore- Returns:
- the newly registered bitstream
- Throws:
IOException- if IO errorSQLException- if database errorAuthorizeException- if authorization error
-
register
public Bitstream register(Context context, int assetstore, String bitstreamPath) throws IOException, SQLException, AuthorizeException
Register a new bitstream, with a new ID. The checksum and file size are calculated. This method is not public, and does not check authorisation; other methods such as Bundle.createBitstream() will check authorisation. The newly created bitstream has the "unknown" format.- Specified by:
registerin interfaceBitstreamService- Parameters:
context- DSpace context objectassetstore- corresponds to an assetstore in dspace.cfgbitstreamPath- the path and filename relative to the assetstore- Returns:
- the newly registered bitstream
- Throws:
IOException- if IO errorSQLException- if database errorAuthorizeException- if authorization error
-
setUserFormatDescription
public void setUserFormatDescription(Context context, Bitstream bitstream, String desc) throws SQLException
Description copied from interface:BitstreamServiceSet the user's format description. This implies that the format of the bitstream is uncertain, and the format is set to "unknown."- Specified by:
setUserFormatDescriptionin interfaceBitstreamService- Parameters:
context- DSpace context objectbitstream- DSpace bitstreamdesc- the user's description of the format- Throws:
SQLException- if database error
-
getFormatDescription
public String getFormatDescription(Context context, Bitstream bitstream) throws SQLException
Description copied from interface:BitstreamServiceGet the description of the format - either the user's or the description of the format defined by the system.- Specified by:
getFormatDescriptionin interfaceBitstreamService- Parameters:
context- DSpace context objectbitstream- DSpace bitstream- Returns:
- a description of the format.
- Throws:
SQLException- if database error
-
setFormat
public void setFormat(Context context, Bitstream bitstream, BitstreamFormat bitstreamFormat) throws SQLException
Description copied from interface:BitstreamServiceSet 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".- Specified by:
setFormatin interfaceBitstreamService- Parameters:
context- DSpace context objectbitstream- DSpace bitstreambitstreamFormat- the format of this bitstream, ornullfor unknown- Throws:
SQLException- if database error
-
update
public void update(Context context, Bitstream bitstream) throws SQLException, AuthorizeException
- Specified by:
updatein interfaceDSpaceObjectService<Bitstream>- Overrides:
updatein classDSpaceObjectServiceImpl<Bitstream>- Throws:
SQLExceptionAuthorizeException
-
delete
public void delete(Context context, Bitstream bitstream) throws SQLException, AuthorizeException
- Specified by:
deletein interfaceDSpaceObjectService<Bitstream>- Throws:
SQLExceptionAuthorizeException
-
getSupportsTypeConstant
public int getSupportsTypeConstant()
Description copied from interface:DSpaceObjectServiceReturns the Constants which this service supports- Specified by:
getSupportsTypeConstantin interfaceDSpaceObjectLegacySupportService<Bitstream>- Specified by:
getSupportsTypeConstantin interfaceDSpaceObjectService<Bitstream>- Returns:
- a org.dspace.core.Constants that represents a IndexableObject type
-
retrieve
public InputStream retrieve(Context context, Bitstream bitstream) throws IOException, SQLException, AuthorizeException
Description copied from interface:BitstreamServiceRetrieve the contents of the bitstream- Specified by:
retrievein interfaceBitstreamService- Parameters:
context- DSpace context objectbitstream- DSpace bitstream- Returns:
- a stream from which the bitstream can be read.
- Throws:
IOException- if IO errorSQLException- if database errorAuthorizeException- if authorization error
-
isRegisteredBitstream
public boolean isRegisteredBitstream(Bitstream bitstream)
Description copied from interface:BitstreamServiceDetermine if this bitstream is registered (available elsewhere on filesystem than in assetstore). More about registered items: https://wiki.duraspace.org/display/DSDOC3x/Registering+(not+Importing)+Bitstreams+via+Simple+Archive+Format- Specified by:
isRegisteredBitstreamin interfaceBitstreamService- Parameters:
bitstream- DSpace bitstream- Returns:
- true if the bitstream is registered, false otherwise
-
getParentObject
public DSpaceObject getParentObject(Context context, Bitstream bitstream) throws SQLException
Description copied from interface:DSpaceObjectServiceReturn the dspace object that "own" the current object in the hierarchy. Note that this method has a meaning slightly different from the getAdminObject because it is independent of the action but it is in a way related to it. It defines the "first" dspace object OTHER then the current one, where allowed ADMIN actions imply allowed ADMIN actions on the object self.- Specified by:
getParentObjectin interfaceDSpaceObjectService<Bitstream>- Overrides:
getParentObjectin classDSpaceObjectServiceImpl<Bitstream>- Parameters:
context- DSpace contextbitstream- DSpaceObject- Returns:
- the dspace object that "own" the current object in the hierarchy
- Throws:
SQLException- if database error
-
updateLastModified
public void updateLastModified(Context context, Bitstream bitstream)
- Specified by:
updateLastModifiedin interfaceDSpaceObjectService<Bitstream>
-
findDeletedBitstreams
public List<Bitstream> findDeletedBitstreams(Context context) throws SQLException
Description copied from interface:BitstreamServiceRetrieve all bitstreams with the deleted flag set to true- Specified by:
findDeletedBitstreamsin interfaceBitstreamService- Parameters:
context- the dspace context- Returns:
- a list of all bitstreams that have been "deleted"
- Throws:
SQLException- if database error
-
expunge
public void expunge(Context context, Bitstream bitstream) throws SQLException, AuthorizeException
Description copied from interface:BitstreamServiceRemove a bitstream that has been set to "deleted" from the database- Specified by:
expungein interfaceBitstreamService- Parameters:
context- the dspace contextbitstream- the bitstream to deleted from the database- Throws:
SQLException- if database errorAuthorizeException- if authorization error
-
findDuplicateInternalIdentifier
public List<Bitstream> findDuplicateInternalIdentifier(Context context, Bitstream bitstream) throws SQLException
- Specified by:
findDuplicateInternalIdentifierin interfaceBitstreamService- Throws:
SQLException
-
getItemBitstreams
public Iterator<Bitstream> getItemBitstreams(Context context, Item item) throws SQLException
- Specified by:
getItemBitstreamsin interfaceBitstreamService- Throws:
SQLException
-
getCollectionBitstreams
public Iterator<Bitstream> getCollectionBitstreams(Context context, Collection collection) throws SQLException
- Specified by:
getCollectionBitstreamsin interfaceBitstreamService- Throws:
SQLException
-
getCommunityBitstreams
public Iterator<Bitstream> getCommunityBitstreams(Context context, Community community) throws SQLException
- Specified by:
getCommunityBitstreamsin interfaceBitstreamService- Throws:
SQLException
-
findBitstreamsWithNoRecentChecksum
public List<Bitstream> findBitstreamsWithNoRecentChecksum(Context context) throws SQLException
- Specified by:
findBitstreamsWithNoRecentChecksumin interfaceBitstreamService- Throws:
SQLException
-
getBitstreamByName
public Bitstream getBitstreamByName(Item item, String bundleName, String bitstreamName) throws SQLException
- Specified by:
getBitstreamByNamein interfaceBitstreamService- Throws:
SQLException
-
getFirstBitstream
public Bitstream getFirstBitstream(Item item, String bundleName) throws SQLException
- Specified by:
getFirstBitstreamin interfaceBitstreamService- Throws:
SQLException
-
getThumbnail
public Bitstream getThumbnail(Context context, Bitstream bitstream) throws SQLException
- Specified by:
getThumbnailin interfaceBitstreamService- Throws:
SQLException
-
getFormat
public BitstreamFormat getFormat(Context context, Bitstream bitstream) throws SQLException
- Specified by:
getFormatin interfaceBitstreamService- Throws:
SQLException
-
findByStoreNumber
public Iterator<Bitstream> findByStoreNumber(Context context, Integer storeNumber) throws SQLException
- Specified by:
findByStoreNumberin interfaceBitstreamService- Throws:
SQLException
-
countByStoreNumber
public Long countByStoreNumber(Context context, Integer storeNumber) throws SQLException
- Specified by:
countByStoreNumberin interfaceBitstreamService- Throws:
SQLException
-
countTotal
public int countTotal(Context context) throws SQLException
- Specified by:
countTotalin interfaceBitstreamService- Throws:
SQLException
-
findByIdOrLegacyId
public Bitstream findByIdOrLegacyId(Context context, String id) throws SQLException
- Specified by:
findByIdOrLegacyIdin interfaceDSpaceObjectLegacySupportService<Bitstream>- Throws:
SQLException
-
findByLegacyId
public Bitstream findByLegacyId(Context context, int id) throws SQLException
Description copied from interface:DSpaceObjectLegacySupportServiceGeneric find for when the precise type of a DSO is not known, just the a pair of type number and database ID.- Specified by:
findByLegacyIdin interfaceDSpaceObjectLegacySupportService<Bitstream>- Parameters:
context- - the contextid- - the legacy id within table of type'd objects- Returns:
- the object found, or null if it does not exist.
- Throws:
SQLException- only upon failure accessing the database.
-
countDeletedBitstreams
public int countDeletedBitstreams(Context context) throws SQLException
- Specified by:
countDeletedBitstreamsin interfaceBitstreamService- Throws:
SQLException
-
countBitstreamsWithoutPolicy
public int countBitstreamsWithoutPolicy(Context context) throws SQLException
- Specified by:
countBitstreamsWithoutPolicyin interfaceBitstreamService- Throws:
SQLException
-
getNotReferencedBitstreams
public List<Bitstream> getNotReferencedBitstreams(Context context) throws SQLException
- Specified by:
getNotReferencedBitstreamsin interfaceBitstreamService- Throws:
SQLException
-
getLastModified
@Nullable public Long getLastModified(Bitstream bitstream) throws IOException
Description copied from interface:BitstreamServiceGets the last modified timestamp of the the given bitstream's content, if known.- Specified by:
getLastModifiedin interfaceBitstreamService- Parameters:
bitstream- the bitstream.- Returns:
- the timestamp in milliseconds, or
nullif unknown. - Throws:
IOException- if an unexpected io error occurs.
-
-