Package org.dspace.content
Class BundleServiceImpl
- All Implemented Interfaces:
BundleService,DSpaceObjectLegacySupportService<Bundle>,DSpaceObjectService<Bundle>
Service implementation for the Bundle object.
This class is responsible for all business logic calls for the Bundle object and is autowired by spring.
This class should never be accessed directly.
- Author:
- kevinvandevelde at atmire.com
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AuthorizeServiceprotected BitstreamServiceprotected BundleDAOprotected ItemServiceprotected ResourcePolicyServiceFields inherited from class org.dspace.content.DSpaceObjectServiceImpl
choiceAuthorityService, handleService, metadataAuthorityService, metadataFieldService, metadataValueService, relationshipServiceFields 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 -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBitstream(Context context, Bundle bundle, Bitstream bitstream) Add an existing bitstream to this bundleintcountTotal(Context context) Create a new bundle, with a new ID and link it to the provided itemvoidGeneric find for when the precise type of an Entity is not knownfindByIdOrLegacyId(Context context, String id) findByLegacyId(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.getAdminObject(Context context, Bundle bundle, int action) Return the dspace object where an ADMIN action right is sufficient to grant the initial authorize check.getBitstreamByName(Bundle bundle, String name) getBitstreamPolicies(Context context, Bundle bundle) getBundlePolicies(Context context, Bundle bundle) getParentObject(Context context, Bundle bundle) Return the dspace object that "own" the current object in the hierarchy.intReturns the Constants which this service supportsvoidinheritCollectionDefaultPolicies(Context context, Bundle bundle, Collection collection) remove all policies on the bundle and its contents, and replace them with the DEFAULT_BITSTREAM_READ policies belonging to the collection.voidmoveBitstreamToBundle(Context context, Bundle targetBundle, Bitstream bitstream) Moves a bitstream from its current bundle to a new target bundlevoidremoveBitstream(Context context, Bundle bundle, Bitstream bitstream) Remove a bitstream from this bundle - the bitstream is only deleted if this was the last reference to itvoidreplaceAllBitstreamPolicies(Context context, Bundle bundle, List<ResourcePolicy> newpolicies) remove all of the policies for the bundle and bitstream contents and replace them with a new list of policiesvoidChanges bitstream order according to the arrayvoidvoidupdateBitstreamOrder(Context context, Bundle bundle, int from, int to) Moves a bitstream within a bundle from one place to another, shifting all other bitstreams in the processvoidupdateLastModified(Context context, Bundle dso) Methods inherited from class org.dspace.content.DSpaceObjectServiceImpl
addAndShiftRightMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, clearMetadata, getAuthoritiesAndConfidences, getElements, getElementsFilled, getIdentifiers, getMDValueByField, getMDValueByLegacyField, getMetadata, getMetadata, getMetadata, getMetadata, getMetadataByMetadataString, getMetadataFirstValue, getMetadataFirstValue, getMetadataValuePlace, getName, getTypeText, match, moveMetadata, moveSingleMetadataValue, removeMetadataValues, replaceMetadata, setMetadataModified, setMetadataSingleValue, setMetadataSingleValueMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.dspace.content.service.DSpaceObjectService
addAndShiftRightMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, clearMetadata, getIdentifiers, getMetadata, getMetadata, getMetadata, getMetadata, getMetadataByMetadataString, getMetadataFirstValue, getMetadataFirstValue, getName, getTypeText, moveMetadata, removeMetadataValues, replaceMetadata, setMetadataModified, setMetadataSingleValue, setMetadataSingleValue
-
Field Details
-
bundleDAO
-
bitstreamService
-
itemService
-
authorizeService
-
resourcePolicyService
-
-
Constructor Details
-
BundleServiceImpl
protected BundleServiceImpl()
-
-
Method Details
-
find
Description copied from interface:DSpaceObjectServiceGeneric find for when the precise type of an Entity is not known- Specified by:
findin interfaceDSpaceObjectService<Bundle>- 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.
-
create
public Bundle create(Context context, Item item, String name) throws SQLException, AuthorizeException Description copied from interface:BundleServiceCreate a new bundle, with a new ID and link it to the provided item- Specified by:
createin interfaceBundleService- Parameters:
context- DSpace context objectitem- DSpace itemname- bundle name- Returns:
- the newly created bundle
- Throws:
SQLException- if database errorAuthorizeException- if authorization error
-
getBitstreamByName
- Specified by:
getBitstreamByNamein interfaceBundleService
-
addBitstream
public void addBitstream(Context context, Bundle bundle, Bitstream bitstream) throws SQLException, AuthorizeException Description copied from interface:BundleServiceAdd an existing bitstream to this bundle- Specified by:
addBitstreamin interfaceBundleService- Parameters:
context- DSpace Contextbundle- the bitstream bundlebitstream- the bitstream to add- Throws:
SQLException- if database errorAuthorizeException- if authorization error
-
removeBitstream
public void removeBitstream(Context context, Bundle bundle, Bitstream bitstream) throws AuthorizeException, SQLException, IOException Description copied from interface:BundleServiceRemove a bitstream from this bundle - the bitstream is only deleted if this was the last reference to itIf the bitstream in question is the primary bitstream recorded for the bundle the primary bitstream field is unset in order to free the bitstream from the foreign key constraint so that the
cleanupprocess can run normally.- Specified by:
removeBitstreamin interfaceBundleService- Parameters:
context- DSpace Contextbundle- the bitstream bundlebitstream- the bitstream to remove- Throws:
AuthorizeException- if authorization errorSQLException- if database errorIOException- if IO error
-
inheritCollectionDefaultPolicies
public void inheritCollectionDefaultPolicies(Context context, Bundle bundle, Collection collection) throws SQLException, AuthorizeException Description copied from interface:BundleServiceremove all policies on the bundle and its contents, and replace them with the DEFAULT_BITSTREAM_READ policies belonging to the collection.- Specified by:
inheritCollectionDefaultPoliciesin interfaceBundleService- Parameters:
context- DSpace Contextbundle- the bitstream bundlecollection- Collection- Throws:
SQLException- if an SQL error or if no default policies found. It's a bit draconian, but default policies must be enforced.AuthorizeException- if authorization error
-
replaceAllBitstreamPolicies
public void replaceAllBitstreamPolicies(Context context, Bundle bundle, List<ResourcePolicy> newpolicies) throws SQLException, AuthorizeException Description copied from interface:BundleServiceremove all of the policies for the bundle and bitstream contents and replace them with a new list of policies- Specified by:
replaceAllBitstreamPoliciesin interfaceBundleService- Parameters:
context- DSpace Contextbundle- the bitstream bundlenewpolicies- - this will be all of the new policies for the bundle and bitstream contents- Throws:
SQLException- if database errorAuthorizeException- if authorization error
-
getBitstreamPolicies
public List<ResourcePolicy> getBitstreamPolicies(Context context, Bundle bundle) throws SQLException - Specified by:
getBitstreamPoliciesin interfaceBundleService- Throws:
SQLException
-
getBundlePolicies
- Specified by:
getBundlePoliciesin interfaceBundleService- Throws:
SQLException
-
updateBitstreamOrder
public void updateBitstreamOrder(Context context, Bundle bundle, int from, int to) throws AuthorizeException, SQLException Description copied from interface:BundleServiceMoves a bitstream within a bundle from one place to another, shifting all other bitstreams in the process- Specified by:
updateBitstreamOrderin interfaceBundleService- Parameters:
context- DSpace Contextbundle- The bitstream bundlefrom- The index of the bitstream to moveto- The index to move the bitstream to- Throws:
AuthorizeException- when an SQL error has occurred (querying DSpace)SQLException- If the user can't make the changes
-
moveBitstreamToBundle
public void moveBitstreamToBundle(Context context, Bundle targetBundle, Bitstream bitstream) throws SQLException, AuthorizeException, IOException Description copied from interface:BundleServiceMoves a bitstream from its current bundle to a new target bundle- Specified by:
moveBitstreamToBundlein interfaceBundleService- Parameters:
context- DSpace ContexttargetBundle- The target bundle where bitstream will be moved tobitstream- The bitstream being moved- Throws:
SQLException- if database errorAuthorizeException- if authorization errorIOException- if IO error
-
setOrder
public void setOrder(Context context, Bundle bundle, UUID[] bitstreamIds) throws AuthorizeException, SQLException Description copied from interface:BundleServiceChanges bitstream order according to the array- Specified by:
setOrderin interfaceBundleService- Parameters:
context- DSpace Contextbundle- the bitstream bundlebitstreamIds- the identifiers in the order they are to be set- Throws:
AuthorizeException- If the user can't make the changesSQLException- when an SQL error has occurred (querying DSpace)
-
getAdminObject
Description copied from interface:DSpaceObjectServiceReturn the dspace object where an ADMIN action right is sufficient to grant the initial authorize check.Default behaviour is ADMIN right on the object grant right on all other action on the object itself. Subclass should override this method as needed.
- Specified by:
getAdminObjectin interfaceDSpaceObjectService<Bundle>- Overrides:
getAdminObjectin classDSpaceObjectServiceImpl<Bundle>- Parameters:
context- DSpace contextbundle- DSpaceObjectaction- ID of action being attempted, fromorg.dspace.core.Constants. The ADMIN action is not a valid parameter for this method, an IllegalArgumentException should be thrown- Returns:
- the dspace object, if any, where an ADMIN action is sufficient to grant the original action
- Throws:
SQLException- if database error
-
getParentObject
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<Bundle>- Overrides:
getParentObjectin classDSpaceObjectServiceImpl<Bundle>- Parameters:
context- DSpace contextbundle- DSpaceObject- Returns:
- the dspace object that "own" the current object in the hierarchy
- Throws:
SQLException- if database error
-
updateLastModified
- Specified by:
updateLastModifiedin interfaceDSpaceObjectService<Bundle>
-
update
- Specified by:
updatein interfaceDSpaceObjectService<Bundle>- Overrides:
updatein classDSpaceObjectServiceImpl<Bundle>- Throws:
SQLExceptionAuthorizeException
-
delete
public void delete(Context context, Bundle bundle) throws SQLException, AuthorizeException, IOException - Specified by:
deletein interfaceDSpaceObjectService<Bundle>- Throws:
SQLExceptionAuthorizeExceptionIOException
-
getSupportsTypeConstant
public int getSupportsTypeConstant()Description copied from interface:DSpaceObjectServiceReturns the Constants which this service supports- Specified by:
getSupportsTypeConstantin interfaceDSpaceObjectLegacySupportService<Bundle>- Specified by:
getSupportsTypeConstantin interfaceDSpaceObjectService<Bundle>- Returns:
- a org.dspace.core.Constants that represents a IndexableObject type
-
findByIdOrLegacyId
- Specified by:
findByIdOrLegacyIdin interfaceDSpaceObjectLegacySupportService<Bundle>- Throws:
SQLException
-
findByLegacyId
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<Bundle>- 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.
-
countTotal
- Specified by:
countTotalin interfaceBundleService- Throws:
SQLException
-