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 Details

  • Method Details

    • 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 object
      community - DSpace Community (parent)
      Returns:
      the newly created collection
      Throws:
      SQLException - if database error
      AuthorizeException - 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 object
      community - DSpace Community (parent)
      handle - the pre-determined Handle to assign to the new community
      Returns:
      the newly created collection
      Throws:
      SQLException - if database error
      AuthorizeException - 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 object
      community - DSpace Community (parent)
      handle - the pre-determined Handle to assign to the new collection
      uuid - the pre-determined UUID to assign to the new collection
      Returns:
      the newly created collection
      Throws:
      SQLException - if database error
      AuthorizeException - 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 limit
      offset - 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 in null removes any existing logo. You will need to set the format of the new logo bitstream before it will work, for example to "JPEG". Note that update will need to be called for the change to take effect. Setting a logo and not calling update later may result in a previous logo lying around as an "orphaned" bitstream.
      Parameters:
      context - DSpace Context
      collection - Collection
      is - the stream to use as the new logo
      Returns:
      the new logo bitstream, or null if there is no logo (null was passed in)
      Throws:
      AuthorizeException - if authorization error
      IOException - if IO error
      SQLException - 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 until update is called.
      Parameters:
      context - DSpace Context
      collection - Collection
      step - 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 error
      AuthorizeException - 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. null can 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 - Collection
      step - the workflow step (1-3)
      group - the new workflow group, or null
      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 returns null if there is no group associated with this collection for the given step.
      Parameters:
      context - DSpace Context
      collection - Collection
      step - 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 Context
      collection - Collection
      Returns:
      the default group of submitters associated with this collection
      Throws:
      SQLException - if database error
      AuthorizeException - 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 Context
      collection - Collection
      Throws:
      SQLException - if database error
      AuthorizeException - 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 Context
      collection - Collection
      Returns:
      the default group of editors associated with this collection
      Throws:
      SQLException - if database error
      AuthorizeException - 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 Context
      collection - Collection
      Throws:
      SQLException - if database error
      AuthorizeException - 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:
      true if 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 call update on the collection after doing this, or the item will have been created but the collection record will not refer to it.
      Parameters:
      context - DSpace Context
      collection - Collection
      Throws:
      SQLException - if database error
      AuthorizeException - 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 an update.
      Parameters:
      context - DSpace Context
      collection - Collection
      Throws:
      SQLException - if database error
      AuthorizeException - if authorization error
      IOException - 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; update need not be called.
      Parameters:
      context - DSpace Context
      collection - Collection
      item - item to add
      Throws:
      SQLException - if database error
      AuthorizeException - 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 Context
      collection - Collection
      item - item to remove
      Throws:
      SQLException - if database error
      AuthorizeException - if authorization error
      IOException - 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:
      SQLException
      AuthorizeException
    • canEdit

      void canEdit(Context context, Collection collection, boolean useInheritance) throws SQLException, AuthorizeException
      Throws:
      SQLException
      AuthorizeException
    • 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 Context
      community - (optional) restrict search to a community, else null
      actionID - 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 Context
      group - 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 context
      collection - The collection for which it'll be created
      typeOfGroupString - The type of group to be made, item or bitstream
      defaultRead - The defaultRead int, item or bitstream
      Returns:
      The created Group
      Throws:
      SQLException - If something goes wrong
      AuthorizeException - If something goes wrong
    • getDefaultReadGroupName

      String getDefaultReadGroupName(Collection collection, String typeOfGroupString)
      This method will return the name to give to the group created by the createDefaultReadGroup(Context, Collection, String, int) method
      Parameters:
      collection - The DSpace collection to use in the name generation
      typeOfGroupString - 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 name
      context - DSpace Context
      community - parent community
      entityType - limit the returned collection to those related to given entity type
      offset - the position of the first result to return
      limit - paging limit
      Returns:
      discovery search result objects
      Throws:
      SQLException - if something goes wrong
      SearchServiceException - 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 name
      context - DSpace Context
      community - parent community
      offset - the position of the first result to return
      limit - paging limit
      Returns:
      discovery search result objects
      Throws:
      SQLException - if something goes wrong
      SearchServiceException - if search error
    • retrieveCollectionWithSubmitByCommunityAndEntityType

      Collection retrieveCollectionWithSubmitByCommunityAndEntityType(Context context, Community community, String entityType)
      Retrieve the first collection in the community or its descending that support the provided entityType
      Parameters:
      context - the DSpace context
      community - the root from where the search start
      entityType - the requested entity type
      Returns:
      the first collection in the community or its descending that support the provided entityType
    • retrieveCollectionWithSubmitByEntityType

      Collection retrieveCollectionWithSubmitByEntityType(Context context, Item item, String entityType) throws SQLException
      Retrieve the close collection to the item for which the current user has 'submit' privileges that support the provided entityType. Close mean the collection that can be reach with the minimum steps starting from the item (owningCollection, brothers collections, etc)
      Parameters:
      context - the DSpace context
      item - the item from where the search start
      entityType - the requested entity type
      Returns:
      the first collection in the community or its descending that support the provided entityType
      Throws:
      SQLException
    • 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 name
      context - DSpace Context
      community - parent community
      Returns:
      total collections found
      Throws:
      SQLException - if something goes wrong
      SearchServiceException - 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 name
      context - DSpace Context
      community - parent community
      entityType - limit the returned collection to those related to given entity type
      Returns:
      total collections found
      Throws:
      SQLException - if something goes wrong
      SearchServiceException - if search error
    • countArchivedItems

      int countArchivedItems(Context context, Collection collection)
      Returns total collection archived items
      Parameters:
      context - DSpace context
      collection - Collection
      Returns:
      total collection archived items