Package org.dspace.app.rest.repository
Class CollectionRestRepository
java.lang.Object
org.dspace.app.rest.repository.AbstractDSpaceRestRepository
org.dspace.app.rest.repository.DSpaceRestRepository<R,UUID>
org.dspace.app.rest.repository.DSpaceObjectRestRepository<Collection,CollectionRest>
org.dspace.app.rest.repository.CollectionRestRepository
- All Implemented Interfaces:
ReloadableEntityObjectRepository<Collection,,UUID> Aware,BeanNameAware,org.springframework.data.repository.CrudRepository<CollectionRest,,UUID> org.springframework.data.repository.PagingAndSortingRepository<CollectionRest,,UUID> org.springframework.data.repository.Repository<CollectionRest,UUID>
@Component("core.collections")
public class CollectionRestRepository
extends DSpaceObjectRestRepository<Collection,CollectionRest>
This is the repository responsible to manage Item Rest object
- Author:
- Andrea Bollini (andrea.bollini at 4science.it)
-
Field Summary
FieldsFields inherited from class org.dspace.app.rest.repository.AbstractDSpaceRestRepository
converter, requestService, utils -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateAdminGroup(Context context, jakarta.servlet.http.HttpServletRequest request, Collection collection) This method will create an AdminGroup for the given Collection with the given Information through JSONprotected CollectionRestcreateAndReturn(Context context) Method to implement to support the creation of a new instance.protected CollectionRestcreateAndReturn(Context context, UUID id) Method to implement to support the creation of a new instance.createBitstreamReadGroup(Context context, jakarta.servlet.http.HttpServletRequest request, Collection collection) This method will create an BitstreamReadGroup for the given Collection with the given Information through JSONcreateItemReadGroup(Context context, jakarta.servlet.http.HttpServletRequest request, Collection collection) This method will create an ItemReadGroup for the given Collection with the given Information through JSONcreateSubmitterGroup(Context context, jakarta.servlet.http.HttpServletRequest request, Collection collection) This method will create a SubmitterGroup for the given Collection with the given Information through JSONcreateTemplateItem(Context context, Collection collection, TemplateItemRest inputItemRest) This method creates a new Item to be used as a template in a CollectioncreateWorkflowGroupForRole(Context context, jakarta.servlet.http.HttpServletRequest request, Collection collection, String workflowRole) This method will create the WorkflowGroup for the given Collection and workflowRoleprotected voidMethod to implement to support delete of a single object instancevoiddeleteAdminGroup(Context context, Collection collection) This method will delete the AdminGroup for the given CollectionvoiddeleteBitstreamReadGroup(Context context, Collection collection) This method will delete the BitstreamReadGroup for the given CollectionvoiddeleteItemReadGroup(Context context, Collection collection) This method will delete the ItemReadGroup for the given CollectionvoiddeleteSubmitterGroup(Context context, Collection collection) This method will delete the SubmitterGroup for the given CollectionvoiddeleteWorkflowGroupForRole(Context context, jakarta.servlet.http.HttpServletRequest request, Collection collection, String workflowRole) This method will delete the WorkflowGroup for a given Collection and workflowRoleorg.springframework.data.domain.Page<CollectionRest>findAdminAuthorized(org.springframework.data.domain.Pageable pageable, String query) org.springframework.data.domain.Page<CollectionRest>Method to implement to support scroll of entity instances from the collection resource endpointMethod to implement to support retrieval of a specific REST object instanceorg.springframework.data.domain.Page<CollectionRest>findSubmitAuthorized(String q, org.springframework.data.domain.Pageable pageable) org.springframework.data.domain.Page<CollectionRest>findSubmitAuthorizedByCommunity(UUID communityUuid, org.springframework.data.domain.Pageable pageable, String q) org.springframework.data.domain.Page<CollectionRest>findSubmitAuthorizedByCommunityAndEntityType(String query, UUID communityUuid, String entityTypeLabel, org.springframework.data.domain.Pageable pageable) Returns Collections for which the current user has 'submit' privileges limited by parent community.org.springframework.data.domain.Page<CollectionRest>findSubmitAuthorizedByEntityType(String query, String entityTypeLabel, org.springframework.data.domain.Pageable pageable) Returns Collections for which the current user has 'submit' privileges.The REST model supported by the repositorygetTemplateItem(Collection collection) This method looks up the template Item associated with a CollectiongetWorkflowGroupForRole(Context context, Collection collection, String workflowRole) This method will retrieve the GroupRest object for the workflowGroup for the given Collection and workflowRoleprotected voidpatch(Context context, jakarta.servlet.http.HttpServletRequest request, String apiCategory, String model, UUID id, Patch patch) Method to implement to allow partial update of the REST object via JSON Patchprotected CollectionRestput(Context context, jakarta.servlet.http.HttpServletRequest request, String apiCategory, String model, UUID id, com.fasterxml.jackson.databind.JsonNode jsonNode) Implement this method in the subclass to support updating a REST object.setLogo(Context context, Collection collection, MultipartFile uploadfile) Method to install a logo on a Collection which doesn't have a logo Called by request mappings in CollectionLogoControllerMethods inherited from class org.dspace.app.rest.repository.DSpaceObjectRestRepository
findDomainObjectByPk, getPKClass, patchDSpaceObjectMethods inherited from class org.dspace.app.rest.repository.DSpaceRestRepository
action, action, count, createAndReturn, createAndReturn, createAndReturn, createAndReturn, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findAll, findAll, findAll, findAllById, findById, patch, put, put, put, save, save, saveAll, setBeanName, upload, upload, uploadMethods inherited from class org.dspace.app.rest.repository.AbstractDSpaceRestRepository
getRequestService, obtainContext
-
Field Details
-
log
public static org.apache.logging.log4j.Logger log
-
-
Constructor Details
-
CollectionRestRepository
-
-
Method Details
-
findOne
@PreAuthorize("hasPermission(#id, \'COLLECTION\', \'READ\')") public CollectionRest findOne(Context context, UUID id) Description copied from class:DSpaceRestRepositoryMethod to implement to support retrieval of a specific REST object instance- Specified by:
findOnein classDSpaceRestRepository<CollectionRest,UUID> - Parameters:
context- the dspace contextid- the rest object id- Returns:
- the REST object identified by its ID
-
findAll
public org.springframework.data.domain.Page<CollectionRest> findAll(Context context, org.springframework.data.domain.Pageable pageable) Description copied from class:DSpaceRestRepositoryMethod to implement to support scroll of entity instances from the collection resource endpoint- Specified by:
findAllin classDSpaceRestRepository<CollectionRest,UUID> - Parameters:
context- the dspace contextpageable- object embedding the requested pagination info- Returns:
-
findSubmitAuthorizedByCommunity
public org.springframework.data.domain.Page<CollectionRest> findSubmitAuthorizedByCommunity(UUID communityUuid, org.springframework.data.domain.Pageable pageable, String q) -
findSubmitAuthorized
public org.springframework.data.domain.Page<CollectionRest> findSubmitAuthorized(String q, org.springframework.data.domain.Pageable pageable) throws SearchServiceException - Throws:
SearchServiceException
-
findAdminAuthorized
@PreAuthorize("hasAuthority(\'AUTHENTICATED\')") public org.springframework.data.domain.Page<CollectionRest> findAdminAuthorized(org.springframework.data.domain.Pageable pageable, String query) -
findSubmitAuthorizedByEntityType
public org.springframework.data.domain.Page<CollectionRest> findSubmitAuthorizedByEntityType(String query, String entityTypeLabel, org.springframework.data.domain.Pageable pageable) throws SearchServiceException Returns Collections for which the current user has 'submit' privileges.- Parameters:
query- The query used in the lookupentityTypeLabel- The EntityType label object that will be used to limit the returned collection to those related to given entity typepageable- The pagination information- Returns:
- Throws:
SearchServiceException- If search error
-
findSubmitAuthorizedByCommunityAndEntityType
public org.springframework.data.domain.Page<CollectionRest> findSubmitAuthorizedByCommunityAndEntityType(String query, UUID communityUuid, String entityTypeLabel, org.springframework.data.domain.Pageable pageable) Returns Collections for which the current user has 'submit' privileges limited by parent community.- Parameters:
query- The query used in the lookupcommunityUuid- UUID of the parent communityentityTypeLabel- The EntityType label object that will be used to limit the returned collection to those related to given entity typepageable- The pagination information- Returns:
-
patch
@PreAuthorize("hasPermission(#id, \'COLLECTION\', \'WRITE\')") protected void patch(Context context, jakarta.servlet.http.HttpServletRequest request, String apiCategory, String model, UUID id, Patch patch) throws AuthorizeException, SQLException Description copied from class:DSpaceRestRepositoryMethod to implement to allow partial update of the REST object via JSON Patch- Overrides:
patchin classDSpaceRestRepository<CollectionRest,UUID> request- the http requestid- the ID of the target REST objectpatch- the JSON Patch (https://tools.ietf.org/html/rfc6902) operation- Throws:
AuthorizeExceptionSQLException
-
getDomainClass
Description copied from class:DSpaceRestRepositoryThe REST model supported by the repository- Specified by:
getDomainClassin classDSpaceRestRepository<CollectionRest,UUID>
-
createAndReturn
Description copied from class:DSpaceRestRepositoryMethod to implement to support the creation of a new instance. Usually require to retrieve the http request from the thread bound attribute- Overrides:
createAndReturnin classDSpaceRestRepository<CollectionRest,UUID> - Parameters:
context- the dspace context- Returns:
- the created REST object
- Throws:
AuthorizeException
-
createAndReturn
@PreAuthorize("hasPermission(#id, \'COMMUNITY\', \'ADD\')") protected CollectionRest createAndReturn(Context context, UUID id) throws AuthorizeException Description copied from class:DSpaceRestRepositoryMethod to implement to support the creation of a new instance. Usually require to retrieve the http request from the thread bound attribute- Overrides:
createAndReturnin classDSpaceRestRepository<CollectionRest,UUID> - Parameters:
context- the dspace contextid- The uuid of the parent object retrieved from the query param.- Returns:
- the created REST object
- Throws:
AuthorizeException
-
put
@PreAuthorize("hasPermission(#id, \'COLLECTION\', \'WRITE\')") protected CollectionRest put(Context context, jakarta.servlet.http.HttpServletRequest request, String apiCategory, String model, UUID id, com.fasterxml.jackson.databind.JsonNode jsonNode) throws RepositoryMethodNotImplementedException, SQLException, AuthorizeException Description copied from class:DSpaceRestRepositoryImplement this method in the subclass to support updating a REST object.- Overrides:
putin classDSpaceRestRepository<CollectionRest,UUID> - Parameters:
context- the dspace contextapiCategory- the API category e.g. "api"model- the DSpace model e.g. "metadatafield"id- the ID of the target REST objectjsonNode- the part of the request body representing the updated rest object- Returns:
- the updated REST object
- Throws:
RepositoryMethodNotImplementedException- returned by the default implementation when the operation is not supported for the entitySQLException- when the database returns an errorAuthorizeException- if the context user is not authorized to perform this operation
-
delete
@PreAuthorize("hasPermission(#id, \'COLLECTION\', \'DELETE\')") protected void delete(Context context, UUID id) throws AuthorizeException Description copied from class:DSpaceRestRepositoryMethod to implement to support delete of a single object instance- Overrides:
deletein classDSpaceRestRepository<CollectionRest,UUID> - Parameters:
context- the dspace contextid- the id of the rest object to delete- Throws:
AuthorizeException
-
setLogo
public BitstreamRest setLogo(Context context, Collection collection, MultipartFile uploadfile) throws IOException, AuthorizeException, SQLException Method to install a logo on a Collection which doesn't have a logo Called by request mappings in CollectionLogoController- Parameters:
context-collection- The collection on which to install the logouploadfile- The new logo- Returns:
- The created bitstream containing the new logo
- Throws:
IOExceptionAuthorizeExceptionSQLException
-
createTemplateItem
public TemplateItemRest createTemplateItem(Context context, Collection collection, TemplateItemRest inputItemRest) throws SQLException, AuthorizeException This method creates a new Item to be used as a template in a Collection- Parameters:
context-collection- The collection for which to make the iteminputItemRest- The new item- Returns:
- The created TemplateItem
- Throws:
SQLExceptionAuthorizeException
-
getTemplateItem
This method looks up the template Item associated with a Collection- Parameters:
collection- The Collection for which to find the template- Returns:
- The template Item from the Collection
- Throws:
SQLException
-
createAdminGroup
public GroupRest createAdminGroup(Context context, jakarta.servlet.http.HttpServletRequest request, Collection collection) throws SQLException, AuthorizeException This method will create an AdminGroup for the given Collection with the given Information through JSON- Parameters:
context- The current contextrequest- The current requestcollection- The collection for which we'll create an admingroup- Returns:
- The created AdminGroup's REST object
- Throws:
SQLException- If something goes wrongAuthorizeException- If something goes wrong
-
deleteAdminGroup
public void deleteAdminGroup(Context context, Collection collection) throws SQLException, AuthorizeException, IOException This method will delete the AdminGroup for the given Collection- Parameters:
context- The current contextcollection- The community for which we'll delete the admingroup- Throws:
SQLException- If something goes wrongAuthorizeException- If something goes wrongIOException- If something goes wrong
-
createSubmitterGroup
public GroupRest createSubmitterGroup(Context context, jakarta.servlet.http.HttpServletRequest request, Collection collection) throws SQLException, AuthorizeException This method will create a SubmitterGroup for the given Collection with the given Information through JSON- Parameters:
context- The current contextrequest- The current requestcollection- The collection for which we'll create a submittergroup- Returns:
- The created SubmitterGroup's REST object
- Throws:
SQLException- If something goes wrongAuthorizeException- If something goes wrong
-
deleteSubmitterGroup
public void deleteSubmitterGroup(Context context, Collection collection) throws SQLException, AuthorizeException, IOException This method will delete the SubmitterGroup for the given Collection- Parameters:
context- The current contextcollection- The community for which we'll delete the submittergroup- Throws:
SQLException- If something goes wrongAuthorizeException- If something goes wrongIOException- If something goes wrong
-
createItemReadGroup
public GroupRest createItemReadGroup(Context context, jakarta.servlet.http.HttpServletRequest request, Collection collection) throws SQLException, AuthorizeException This method will create an ItemReadGroup for the given Collection with the given Information through JSON- Parameters:
context- The current contextrequest- The current requestcollection- The collection for which we'll create an ItemReadGroup- Returns:
- The created ItemReadGroup's REST object
- Throws:
SQLException- If something goes wrongAuthorizeException- If something goes wrong
-
deleteItemReadGroup
public void deleteItemReadGroup(Context context, Collection collection) throws SQLException, AuthorizeException, IOException This method will delete the ItemReadGroup for the given Collection- Parameters:
context- The current contextcollection- The community for which we'll delete the ItemReadGroup- Throws:
SQLException- If something goes wrongAuthorizeException- If something goes wrongIOException- If something goes wrong
-
createBitstreamReadGroup
public GroupRest createBitstreamReadGroup(Context context, jakarta.servlet.http.HttpServletRequest request, Collection collection) throws SQLException, AuthorizeException This method will create an BitstreamReadGroup for the given Collection with the given Information through JSON- Parameters:
context- The current contextrequest- The current requestcollection- The collection for which we'll create an BitstreamReadGroup- Returns:
- The created BitstreamReadGroup's REST object
- Throws:
SQLException- If something goes wrongAuthorizeException- If something goes wrong
-
deleteBitstreamReadGroup
public void deleteBitstreamReadGroup(Context context, Collection collection) throws SQLException, AuthorizeException, IOException This method will delete the BitstreamReadGroup for the given Collection- Parameters:
context- The current contextcollection- The community for which we'll delete the BitstreamReadGroup- Throws:
SQLException- If something goes wrongAuthorizeException- If something goes wrongIOException- If something goes wrong
-
getWorkflowGroupForRole
public GroupRest getWorkflowGroupForRole(Context context, Collection collection, String workflowRole) throws SQLException, IOException, WorkflowConfigurationException, AuthorizeException, WorkflowException This method will retrieve the GroupRest object for the workflowGroup for the given Collection and workflowRole- Parameters:
context- The relevant DSpace contextcollection- The given collectionworkflowRole- The given workflowRole- Returns:
- The GroupRest for the WorkflowGroup for the given Collection and workflowRole
- Throws:
SQLException- If something goes wrongIOException- If something goes wrongWorkflowConfigurationException- If something goes wrongAuthorizeException- If something goes wrongWorkflowException- If something goes wrong
-
createWorkflowGroupForRole
public GroupRest createWorkflowGroupForRole(Context context, jakarta.servlet.http.HttpServletRequest request, Collection collection, String workflowRole) throws SQLException, WorkflowConfigurationException, AuthorizeException, WorkflowException, IOException This method will create the WorkflowGroup for the given Collection and workflowRole- Parameters:
context- The relevant DSpace contextrequest- The current requestcollection- The given collectionworkflowRole- The given workflowRole- Returns:
- The created WorkflowGroup for the given Collection and workflowRole
- Throws:
SQLException- If something goes wrongWorkflowConfigurationException- If something goes wrongAuthorizeException- If something goes wrongWorkflowException- If something goes wrongIOException- If something goes wrong
-
deleteWorkflowGroupForRole
public void deleteWorkflowGroupForRole(Context context, jakarta.servlet.http.HttpServletRequest request, Collection collection, String workflowRole) throws SQLException, WorkflowConfigurationException, AuthorizeException, WorkflowException, IOException This method will delete the WorkflowGroup for a given Collection and workflowRole- Parameters:
context- The relevant DSpace contextrequest- The current DSpace requestcollection- The given CollectionworkflowRole- The given WorkflowRole- Throws:
SQLException- If something goes wrongWorkflowConfigurationException- If something goes wrongAuthorizeException- If something goes wrongWorkflowException- If something goes wrongIOException- If something goes wrong
-