Package org.dspace.app.rest.repository
Class CommunityRestRepository
java.lang.Object
org.dspace.app.rest.repository.AbstractDSpaceRestRepository
org.dspace.app.rest.repository.DSpaceRestRepository<R,UUID>
org.dspace.app.rest.repository.DSpaceObjectRestRepository<Community,CommunityRest>
org.dspace.app.rest.repository.CommunityRestRepository
- All Implemented Interfaces:
ReloadableEntityObjectRepository<Community,,UUID> Aware,BeanNameAware,org.springframework.data.repository.CrudRepository<CommunityRest,,UUID> org.springframework.data.repository.PagingAndSortingRepository<CommunityRest,,UUID> org.springframework.data.repository.Repository<CommunityRest,UUID>
@Component("core.communities")
public class CommunityRestRepository
extends DSpaceObjectRestRepository<Community,CommunityRest>
This is the repository responsible to manage Community 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 -
Method Summary
Modifier and TypeMethodDescriptioncreateAdminGroup(Context context, jakarta.servlet.http.HttpServletRequest request, Community community) This method will create an AdminGroup for the given Community with the given Information through JSONprotected CommunityRestcreateAndReturn(Context context) Method to implement to support the creation of a new instance.protected CommunityRestcreateAndReturn(Context context, UUID id) Method to implement to support the creation of a new instance.protected voidMethod to implement to support delete of a single object instancevoiddeleteAdminGroup(Context context, Community community) This method will delete the AdminGroup for the given Communityorg.springframework.data.domain.Page<CommunityRest>findAdminAuthorized(org.springframework.data.domain.Pageable pageable, String query) org.springframework.data.domain.Page<CommunityRest>Method to implement to support scroll of entity instances from the collection resource endpointorg.springframework.data.domain.Page<CommunityRest>findAllTop(org.springframework.data.domain.Pageable pageable) Method to implement to support retrieval of a specific REST object instanceThe REST model supported by the repositoryprotected 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 CommunityRestput(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, Community community, MultipartFile uploadfile) Method to install a logo on a Community which doesn't have a logo Called by request mappings in CommunityLogoControllerMethods 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
-
Constructor Details
-
CommunityRestRepository
-
-
Method Details
-
createAndReturn
@PreAuthorize("hasAuthority(\'ADMIN\')") protected CommunityRest 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<CommunityRest,UUID> - Parameters:
context- the dspace context- Returns:
- the created REST object
- Throws:
AuthorizeException
-
createAndReturn
@PreAuthorize("hasPermission(#id, \'COMMUNITY\', \'ADD\')") protected CommunityRest 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<CommunityRest,UUID> - Parameters:
context- the dspace contextid- The uuid of the parent object retrieved from the query param.- Returns:
- the created REST object
- Throws:
AuthorizeException
-
findOne
@PreAuthorize("hasPermission(#id, \'COMMUNITY\', \'READ\')") public CommunityRest 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<CommunityRest,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<CommunityRest> 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<CommunityRest,UUID> - Parameters:
context- the dspace contextpageable- object embedding the requested pagination info- Returns:
-
findAllTop
public org.springframework.data.domain.Page<CommunityRest> findAllTop(org.springframework.data.domain.Pageable pageable) -
findAdminAuthorized
@PreAuthorize("hasAuthority(\'AUTHENTICATED\')") public org.springframework.data.domain.Page<CommunityRest> findAdminAuthorized(org.springframework.data.domain.Pageable pageable, String query) -
patch
@PreAuthorize("hasPermission(#id, \'COMMUNITY\', \'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<CommunityRest,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<CommunityRest,UUID>
-
put
@PreAuthorize("hasPermission(#id, \'COMMUNITY\', \'WRITE\')") protected CommunityRest 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<CommunityRest,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, \'COMMUNITY\', \'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<CommunityRest,UUID> - Parameters:
context- the dspace contextid- the id of the rest object to delete- Throws:
AuthorizeException
-
setLogo
public BitstreamRest setLogo(Context context, Community community, MultipartFile uploadfile) throws IOException, AuthorizeException, SQLException Method to install a logo on a Community which doesn't have a logo Called by request mappings in CommunityLogoController- Parameters:
context-community- The community on which to install the logouploadfile- The new logo- Returns:
- The created bitstream containing the new logo
- Throws:
IOExceptionAuthorizeExceptionSQLException
-
createAdminGroup
public GroupRest createAdminGroup(Context context, jakarta.servlet.http.HttpServletRequest request, Community community) throws SQLException, AuthorizeException This method will create an AdminGroup for the given Community with the given Information through JSON- Parameters:
context- The current contextrequest- The current requestcommunity- The community 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, Community community) throws SQLException, AuthorizeException, IOException This method will delete the AdminGroup for the given Community- Parameters:
context- The current contextcommunity- The community for which we'll delete the admingroup- Throws:
SQLException- If something goes wrongAuthorizeException- If something goes wrongIOException- If something goes wrong
-