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:
org.springframework.data.repository.CrudRepository<CollectionRest,UUID>,org.springframework.data.repository.PagingAndSortingRepository<CollectionRest,UUID>,org.springframework.data.repository.Repository<CollectionRest,UUID>
@Component("core.collection") 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
-
Fields inherited from class org.dspace.app.rest.repository.AbstractDSpaceRestRepository
converter, requestService, utils
-
-
Constructor Summary
Constructors Constructor Description CollectionRestRepository(CollectionService dsoService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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.TemplateItemRestcreateTemplateItem(Context context, Collection collection, TemplateItemRest inputItemRest)This method creates a new Item to be used as a template in a Collectionprotected voiddelete(Context context, UUID id)Method to implement to support delete of a single object instanceorg.springframework.data.domain.Page<CollectionRest>findAll(Context context, org.springframework.data.domain.Pageable pageable)Method to implement to support scroll of entity instances from the collection resource endpointorg.springframework.data.domain.Page<CollectionRest>findAuthorized(org.springframework.data.domain.Pageable pageable)org.springframework.data.domain.Page<CollectionRest>findAuthorizedByCommunity(UUID communityUuid, org.springframework.data.domain.Pageable pageable)CollectionRestfindOne(Context context, UUID id)Method to implement to support retrieval of a specific REST object instanceClass<CollectionRest>getDomainClass()The REST model supported by the repositoryTemplateItemRestgetTemplateItem(Collection collection)This method looks up the template Item associated with a Collectionprotected voidpatch(Context context, javax.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, javax.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.BitstreamRestsetLogo(Context context, Collection collection, org.springframework.web.multipart.MultipartFile uploadfile)Method to install a logo on a Collection which doesn't have a logo Called by request mappings in CollectionLogoController-
Methods inherited from class org.dspace.app.rest.repository.DSpaceObjectRestRepository
patchDSpaceObject
-
Methods inherited from class org.dspace.app.rest.repository.DSpaceRestRepository
action, action, count, createAndReturn, createAndReturn, createAndReturn, createAndReturn, delete, deleteAll, deleteAll, deleteById, existsById, findAll, findAll, findAll, findAllById, findById, patch, put, put, put, save, save, saveAll, upload, upload, upload
-
Methods inherited from class org.dspace.app.rest.repository.AbstractDSpaceRestRepository
getRequestService, obtainContext
-
-
-
-
Constructor Detail
-
CollectionRestRepository
public CollectionRestRepository(CollectionService dsoService)
-
-
Method Detail
-
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:
-
findAuthorizedByCommunity
public org.springframework.data.domain.Page<CollectionRest> findAuthorizedByCommunity(UUID communityUuid, org.springframework.data.domain.Pageable pageable)
-
findAuthorized
public org.springframework.data.domain.Page<CollectionRest> findAuthorized(org.springframework.data.domain.Pageable pageable)
-
patch
@PreAuthorize("hasPermission(#id, \'COLLECTION\', \'WRITE\')") protected void patch(Context context, javax.servlet.http.HttpServletRequest request, String apiCategory, String model, UUID id, Patch patch) throws AuthorizeException, SQLExceptionDescription 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
public Class<CollectionRest> getDomainClass()
Description copied from class:DSpaceRestRepositoryThe REST model supported by the repository- Specified by:
getDomainClassin classDSpaceRestRepository<CollectionRest,UUID>
-
createAndReturn
protected CollectionRest createAndReturn(Context context) 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 context- Returns:
- the created REST object
- Throws:
AuthorizeException
-
createAndReturn
@PreAuthorize("hasPermission(#id, \'COMMUNITY\', \'ADD\')") protected CollectionRest createAndReturn(Context context, UUID id) throws AuthorizeExceptionDescription 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, javax.servlet.http.HttpServletRequest request, String apiCategory, String model, UUID id, com.fasterxml.jackson.databind.JsonNode jsonNode) throws RepositoryMethodNotImplementedException, SQLException, AuthorizeExceptionDescription 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 AuthorizeExceptionDescription 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, org.springframework.web.multipart.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
public TemplateItemRest getTemplateItem(Collection collection) throws SQLException
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
-
-