Package org.dspace.content.service
Interface CollectionService
-
- All Superinterfaces:
DSpaceObjectLegacySupportService<Collection>,DSpaceObjectService<Collection>
- All Known Implementing Classes:
CollectionServiceImpl
public interface CollectionService extends DSpaceObjectService<Collection>, DSpaceObjectLegacySupportService<Collection>
Service interface class for the Collection object. The implementation of this class is responsible for all business logic calls for the Collection object and is autowired by Spring.- Author:
- kevinvandevelde at atmire.com
-
-
Field Summary
-
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
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddItem(Context context, Collection collection, Item item)Add an item to the collection.voidcanEdit(Context context, Collection collection)voidcanEdit(Context context, Collection collection, boolean useInheritance)booleancanEditBoolean(Context context, Collection collection)booleancanEditBoolean(Context context, Collection collection, boolean useInheritance)intcountCollectionsWithSubmit(String q, Context context, Community community)Counts the number of Collection for which the current user has 'submit' privileges.intcountCollectionsWithSubmit(String q, Context context, Community community, String entityType)Counts the number of Collection for which the current user has 'submit' privileges.intcountTotal(Context context)Collectioncreate(Context context, Community community)Create a new collection with a new ID.Collectioncreate(Context context, Community community, String handle)Create a new collection with the supplied handle and with a new ID.Collectioncreate(Context context, Community community, String handle, UUID uuid)Create a new collection with the supplied handle and ID.GroupcreateAdministrators(Context context, Collection collection)Create a default administrators group if one does not already exist.GroupcreateDefaultReadGroup(Context context, Collection collection, String typeOfGroupString, int defaultRead)This method will create a default read group for the given Collection.GroupcreateSubmitters(Context context, Collection collection)Create a default submitters group if one does not already exist.voidcreateTemplateItem(Context context, Collection collection)Create an empty template item for this collection.GroupcreateWorkflowGroup(Context context, Collection collection, int step)Create a workflow group for the given step if one does not already exist.List<Collection>findAll(Context context)Get all collections in the system.List<Collection>findAll(Context context, Integer limit, Integer offset)Get all collections in the system.List<Collection>findAuthorized(Context context, Community community, int actionID)return an array of collections that user has a given permission on (useful for trimming 'select to collection' list) or figuring out which collections a person is an editor for.List<Collection>findAuthorizedOptimized(Context context, int actionID)CollectionfindByGroup(Context context, Group group)List<Collection>findCollectionsWithSubmit(String q, Context context, Community community, int offset, int limit)Returns Collections for which the current user has 'submit' privileges.List<Collection>findCollectionsWithSubmit(String q, Context context, Community community, String entityType, int offset, int limit)Returns Collections for which the current user has 'submit' privileges.List<Collection>findCollectionsWithSubscribers(Context context)List<Collection>findDirectMapped(Context context, int actionID)List<Collection>findGroup2CommunityMapped(Context context)List<Collection>findGroup2GroupMapped(Context context, int actionID)List<Collection>findGroupMapped(Context context, int actionID)List<Map.Entry<Collection,Long>>getCollectionsWithBitstreamSizesTotal(Context context)The map entry returned contains a collection as a key and sum of bitstream sizes in bytes as a valueStringgetDefaultReadGroupName(Collection collection, String typeOfGroupString)This method will return the name to give to the group created by thecreateDefaultReadGroup(Context, Collection, String, int)methodStringgetLicense(Collection collection)Get the license that users must grant before submitting to this collection.GroupgetWorkflowGroup(Context context, Collection collection, int step)Get the the workflow group corresponding to a particular workflow step.booleanhasCustomLicense(Collection collection)Find out if the collection has a custom licensevoidremoveAdministrators(Context context, Collection collection)Remove the administrators group, if no group has already been created then return without error.voidremoveItem(Context context, Collection collection, Item item)Remove an item.voidremoveSubmitters(Context context, Collection collection)Remove the submitters group, if no group has already been created then return without error.voidremoveTemplateItem(Context context, Collection collection)Remove the template item for this collection, if there is one.BitstreamsetLogo(Context context, Collection collection, InputStream is)Give the collection a logo.voidsetWorkflowGroup(Context context, Collection collection, int step, Group group)Set the workflow group corresponding to a particular workflow step.-
Methods inherited from interface org.dspace.content.service.DSpaceObjectLegacySupportService
findByIdOrLegacyId, findByLegacyId, getSupportsTypeConstant
-
Methods inherited from interface org.dspace.content.service.DSpaceObjectService
addAndShiftRightMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, clearMetadata, delete, find, getAdminObject, getIdentifiers, getMetadata, getMetadata, getMetadata, getMetadata, getMetadataByMetadataString, getMetadataFirstValue, getMetadataFirstValue, getName, getParentObject, getSupportsTypeConstant, getTypeText, moveMetadata, removeMetadataValues, replaceMetadata, setMetadataModified, setMetadataSingleValue, setMetadataSingleValue, update, updateLastModified
-
-
-
-
Method Detail
-
create
Collection create(Context context, Community community) throws SQLException, AuthorizeException
Create a new collection with a new ID. Once created the collection is added to the given community- Parameters:
context- DSpace context objectcommunity- DSpace Community (parent)- Returns:
- the newly created collection
- Throws:
SQLException- if database errorAuthorizeException- if authorization error
-
create
Collection create(Context context, Community community, String handle) throws SQLException, AuthorizeException
Create a new collection with the supplied handle and with a new ID. Once created the collection is added to the given community- Parameters:
context- DSpace context objectcommunity- DSpace Community (parent)handle- the pre-determined Handle to assign to the new community- Returns:
- the newly created collection
- Throws:
SQLException- if database errorAuthorizeException- if authorization error
-
create
Collection create(Context context, Community community, String handle, UUID uuid) throws SQLException, AuthorizeException
Create a new collection with the supplied handle and ID. Once created the collection is added to the given community- Parameters:
context- DSpace context objectcommunity- DSpace Community (parent)handle- the pre-determined Handle to assign to the new collectionuuid- the pre-determined UUID to assign to the new collection- Returns:
- the newly created collection
- Throws:
SQLException- if database errorAuthorizeException- if authorization error
-
findAll
List<Collection> findAll(Context context) throws SQLException
Get all collections in the system. These are alphabetically sorted by collection name.- Parameters:
context- DSpace context object- Returns:
- the collections in the system
- Throws:
SQLException- if database error
-
findAll
List<Collection> findAll(Context context, Integer limit, Integer offset) throws SQLException
Get all collections in the system. Adds support for limit and offset.- Parameters:
context- The relevant DSpace Context.limit- paging limitoffset- paging offset- Returns:
- List of Collections
- Throws:
SQLException- if database error
-
findAuthorizedOptimized
List<Collection> findAuthorizedOptimized(Context context, int actionID) throws SQLException
- Throws:
SQLException
-
findDirectMapped
List<Collection> findDirectMapped(Context context, int actionID) throws SQLException
- Throws:
SQLException
-
findGroup2CommunityMapped
List<Collection> findGroup2CommunityMapped(Context context) throws SQLException
- Throws:
SQLException
-
findGroup2GroupMapped
List<Collection> findGroup2GroupMapped(Context context, int actionID) throws SQLException
- Throws:
SQLException
-
findGroupMapped
List<Collection> findGroupMapped(Context context, int actionID) throws SQLException
- Throws:
SQLException
-
setLogo
Bitstream setLogo(Context context, Collection collection, InputStream is) throws AuthorizeException, IOException, SQLException
Give the collection a logo. Passing innullremoves any existing logo. You will need to set the format of the new logo bitstream before it will work, for example to "JPEG". Note thatupdatewill need to be called for the change to take effect. Setting a logo and not callingupdatelater may result in a previous logo lying around as an "orphaned" bitstream.- Parameters:
context- DSpace Contextcollection- Collectionis- the stream to use as the new logo- Returns:
- the new logo bitstream, or
nullif there is no logo (nullwas passed in) - Throws:
AuthorizeException- if authorization errorIOException- if IO errorSQLException- if database error
-
createWorkflowGroup
Group createWorkflowGroup(Context context, Collection collection, int step) throws SQLException, AuthorizeException
Create a workflow group for the given step if one does not already exist. Returns either the newly created group or the previously existing one. Note that while the new group is created in the database, the association between the group and the collection is not written untilupdateis called.- Parameters:
context- DSpace Contextcollection- Collectionstep- the step (1-3) of the workflow to create or get the group for- Returns:
- the workflow group associated with this collection
- Throws:
SQLException- if database errorAuthorizeException- if authorization error
-
setWorkflowGroup
void setWorkflowGroup(Context context, Collection collection, int step, Group group) throws SQLException, AuthorizeException
Set the workflow group corresponding to a particular workflow step.nullcan be passed in if there should be no associated group for that workflow step; any existing group is NOT deleted.- Parameters:
context- current DSpace session.collection- Collectionstep- the workflow step (1-3)group- the new workflow group, ornull- Throws:
SQLException- passed through.AuthorizeException- passed through.
-
getWorkflowGroup
Group getWorkflowGroup(Context context, Collection collection, int step)
Get the the workflow group corresponding to a particular workflow step. This returnsnullif there is no group associated with this collection for the given step.- Parameters:
context- DSpace Contextcollection- Collectionstep- the workflow step (1-3)- Returns:
- the group of reviewers or
null
-
createSubmitters
Group createSubmitters(Context context, Collection collection) throws SQLException, AuthorizeException
Create a default submitters group if one does not already exist. Returns either the newly created group or the previously existing one. Note that other groups may also be allowed to submit to this collection by the authorization system.- Parameters:
context- DSpace Contextcollection- Collection- Returns:
- the default group of submitters associated with this collection
- Throws:
SQLException- if database errorAuthorizeException- if authorization error
-
removeSubmitters
void removeSubmitters(Context context, Collection collection) throws SQLException, AuthorizeException
Remove the submitters group, if no group has already been created then return without error. This will merely dereference the current submitters group from the collection so that it may be deleted without violating database constraints.- Parameters:
context- DSpace Contextcollection- Collection- Throws:
SQLException- if database errorAuthorizeException- if authorization error
-
createAdministrators
Group createAdministrators(Context context, Collection collection) throws SQLException, AuthorizeException
Create a default administrators group if one does not already exist. Returns either the newly created group or the previously existing one. Note that other groups may also be administrators.- Parameters:
context- DSpace Contextcollection- Collection- Returns:
- the default group of editors associated with this collection
- Throws:
SQLException- if database errorAuthorizeException- if authorization error
-
removeAdministrators
void removeAdministrators(Context context, Collection collection) throws SQLException, AuthorizeException
Remove the administrators group, if no group has already been created then return without error. This will merely dereference the current administrators group from the collection so that it may be deleted without violating database constraints.- Parameters:
context- DSpace Contextcollection- Collection- Throws:
SQLException- if database errorAuthorizeException- if authorization error
-
getLicense
String getLicense(Collection collection)
Get the license that users must grant before submitting to this collection. If the collection does not have a specific license, the site-wide default is returned.- Parameters:
collection- Collection- Returns:
- the license for this collection
-
hasCustomLicense
boolean hasCustomLicense(Collection collection)
Find out if the collection has a custom license- Parameters:
collection- Collection- Returns:
trueif the collection has a custom license
-
createTemplateItem
void createTemplateItem(Context context, Collection collection) throws SQLException, AuthorizeException
Create an empty template item for this collection. If one already exists, no action is taken. Caution: Make sure you callupdateon the collection after doing this, or the item will have been created but the collection record will not refer to it.- Parameters:
context- DSpace Contextcollection- Collection- Throws:
SQLException- if database errorAuthorizeException- if authorization error
-
removeTemplateItem
void removeTemplateItem(Context context, Collection collection) throws SQLException, AuthorizeException, IOException
Remove the template item for this collection, if there is one. Note that since this has to remove the old template item ID from the collection record in the database, the collection record will be changed, including any other changes made; in other words, this method does anupdate.- Parameters:
context- DSpace Contextcollection- Collection- Throws:
SQLException- if database errorAuthorizeException- if authorization errorIOException- if IO error
-
addItem
void addItem(Context context, Collection collection, Item item) throws SQLException, AuthorizeException
Add an item to the collection. This simply adds a relationship between the item and the collection - it does nothing like set an issue date, remove a personal workspace item etc. This has instant effect;updateneed not be called.- Parameters:
context- DSpace Contextcollection- Collectionitem- item to add- Throws:
SQLException- if database errorAuthorizeException- if authorization error
-
removeItem
void removeItem(Context context, Collection collection, Item item) throws SQLException, AuthorizeException, IOException
Remove an item. If the item is then orphaned, it is deleted.- Parameters:
context- DSpace Contextcollection- Collectionitem- item to remove- Throws:
SQLException- if database errorAuthorizeException- if authorization errorIOException- if IO error
-
canEditBoolean
boolean canEditBoolean(Context context, Collection collection) throws SQLException
- Throws:
SQLException
-
canEditBoolean
boolean canEditBoolean(Context context, Collection collection, boolean useInheritance) throws SQLException
- Throws:
SQLException
-
canEdit
void canEdit(Context context, Collection collection) throws SQLException, AuthorizeException
- Throws:
SQLExceptionAuthorizeException
-
canEdit
void canEdit(Context context, Collection collection, boolean useInheritance) throws SQLException, AuthorizeException
- Throws:
SQLExceptionAuthorizeException
-
findAuthorized
List<Collection> findAuthorized(Context context, Community community, int actionID) throws SQLException
return an array of collections that user has a given permission on (useful for trimming 'select to collection' list) or figuring out which collections a person is an editor for.- Parameters:
context- DSpace Contextcommunity- (optional) restrict search to a community, else nullactionID- of the action- Returns:
- Collection [] of collections with matching permissions
- Throws:
SQLException- if database error
-
findByGroup
Collection findByGroup(Context context, Group group) throws SQLException
- Parameters:
context- DSpace Contextgroup- EPerson Group- Returns:
- the collection, if any, that has the specified group as administrators or submitters
- Throws:
SQLException
-
findCollectionsWithSubscribers
List<Collection> findCollectionsWithSubscribers(Context context) throws SQLException
- Throws:
SQLException
-
countTotal
int countTotal(Context context) throws SQLException
- Throws:
SQLException
-
getCollectionsWithBitstreamSizesTotal
List<Map.Entry<Collection,Long>> getCollectionsWithBitstreamSizesTotal(Context context) throws SQLException
The map entry returned contains a collection as a key and sum of bitstream sizes in bytes as a value- Parameters:
context- DSpace Context- Returns:
- List of Collections and bitstream sizes map
- Throws:
SQLException- if database error
-
createDefaultReadGroup
Group createDefaultReadGroup(Context context, Collection collection, String typeOfGroupString, int defaultRead) throws SQLException, AuthorizeException
This method will create a default read group for the given Collection. It'll create either a defaultItemRead or a defaultBitstreamRead group depending on the given parameters- Parameters:
context- The relevant DSpace contextcollection- The collection for which it'll be createdtypeOfGroupString- The type of group to be made, item or bitstreamdefaultRead- The defaultRead int, item or bitstream- Returns:
- The created Group
- Throws:
SQLException- If something goes wrongAuthorizeException- If something goes wrong
-
getDefaultReadGroupName
String getDefaultReadGroupName(Collection collection, String typeOfGroupString)
This method will return the name to give to the group created by thecreateDefaultReadGroup(Context, Collection, String, int)method- Parameters:
collection- The DSpace collection to use in the name generationtypeOfGroupString- The type of group to use in the name generation- Returns:
- the name to give to the group that hold default read for the collection
-
findCollectionsWithSubmit
List<Collection> findCollectionsWithSubmit(String q, Context context, Community community, String entityType, int offset, int limit) throws SQLException, SearchServiceException
Returns Collections for which the current user has 'submit' privileges. NOTE: for better performance, this method retrieves its results from an index (cache) and does not query the database directly. This means that results may be stale or outdated until https://github.com/DSpace/DSpace/issues/2853 is resolved"- Parameters:
q- limit the returned collection to those with metadata values matching the query terms. The terms are used to make also a prefix query on SOLR so it can be used to implement an autosuggest feature over the collection namecontext- DSpace Contextcommunity- parent communityentityType- limit the returned collection to those related to given entity typeoffset- the position of the first result to returnlimit- paging limit- Returns:
- discovery search result objects
- Throws:
SQLException- if something goes wrongSearchServiceException- if search error
-
findCollectionsWithSubmit
List<Collection> findCollectionsWithSubmit(String q, Context context, Community community, int offset, int limit) throws SQLException, SearchServiceException
Returns Collections for which the current user has 'submit' privileges. NOTE: for better performance, this method retrieves its results from an index (cache) and does not query the database directly. This means that results may be stale or outdated until https://github.com/DSpace/DSpace/issues/2853 is resolved"- Parameters:
q- limit the returned collection to those with metadata values matching the query terms. The terms are used to make also a prefix query on SOLR so it can be used to implement an autosuggest feature over the collection namecontext- DSpace Contextcommunity- parent communityoffset- the position of the first result to returnlimit- paging limit- Returns:
- discovery search result objects
- Throws:
SQLException- if something goes wrongSearchServiceException- if search error
-
countCollectionsWithSubmit
int countCollectionsWithSubmit(String q, Context context, Community community) throws SQLException, SearchServiceException
Counts the number of Collection for which the current user has 'submit' privileges. NOTE: for better performance, this method retrieves its results from an index (cache) and does not query the database directly. This means that results may be stale or outdated until https://github.com/DSpace/DSpace/issues/2853 is resolved."- Parameters:
q- limit the returned collection to those with metadata values matching the query terms. The terms are used to make also a prefix query on SOLR so it can be used to implement an autosuggest feature over the collection namecontext- DSpace Contextcommunity- parent community- Returns:
- total collections found
- Throws:
SQLException- if something goes wrongSearchServiceException- if search error
-
countCollectionsWithSubmit
int countCollectionsWithSubmit(String q, Context context, Community community, String entityType) throws SQLException, SearchServiceException
Counts the number of Collection for which the current user has 'submit' privileges. NOTE: for better performance, this method retrieves its results from an index (cache) and does not query the database directly. This means that results may be stale or outdated until https://github.com/DSpace/DSpace/issues/2853 is resolved."- Parameters:
q- limit the returned collection to those with metadata values matching the query terms. The terms are used to make also a prefix query on SOLR so it can be used to implement an autosuggest feature over the collection namecontext- DSpace Contextcommunity- parent communityentityType- limit the returned collection to those related to given entity type- Returns:
- total collections found
- Throws:
SQLException- if something goes wrongSearchServiceException- if search error
-
-