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<org.dspace.content.Community,CommunityRest>
-
- org.dspace.app.rest.repository.CommunityRestRepository
-
- All Implemented Interfaces:
ReloadableEntityObjectRepository<org.dspace.content.Community,UUID>,org.springframework.data.repository.CrudRepository<CommunityRest,UUID>,org.springframework.data.repository.PagingAndSortingRepository<CommunityRest,UUID>,org.springframework.data.repository.Repository<CommunityRest,UUID>
@Component("core.community") public class CommunityRestRepository extends DSpaceObjectRestRepository<org.dspace.content.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 Constructor Description CommunityRestRepository(org.dspace.content.service.CommunityService dsoService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GroupRestcreateAdminGroup(org.dspace.core.Context context, javax.servlet.http.HttpServletRequest request, org.dspace.content.Community community)This method will create an AdminGroup for the given Community with the given Information through JSONprotected CommunityRestcreateAndReturn(org.dspace.core.Context context)Method to implement to support the creation of a new instance.protected CommunityRestcreateAndReturn(org.dspace.core.Context context, UUID id)Method to implement to support the creation of a new instance.protected voiddelete(org.dspace.core.Context context, UUID id)Method to implement to support delete of a single object instancevoiddeleteAdminGroup(org.dspace.core.Context context, org.dspace.content.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>findAll(org.dspace.core.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<CommunityRest>findAllTop(org.springframework.data.domain.Pageable pageable)CommunityRestfindOne(org.dspace.core.Context context, UUID id)Method to implement to support retrieval of a specific REST object instanceClass<CommunityRest>getDomainClass()The REST model supported by the repositoryprotected voidpatch(org.dspace.core.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 CommunityRestput(org.dspace.core.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(org.dspace.core.Context context, org.dspace.content.Community community, org.springframework.web.multipart.MultipartFile uploadfile)Method to install a logo on a Community which doesn't have a logo Called by request mappings in CommunityLogoController-
Methods inherited from class org.dspace.app.rest.repository.DSpaceObjectRestRepository
findDomainObjectByPk, getPKClass, 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
-
-
-
-
Method Detail
-
createAndReturn
@PreAuthorize("hasAuthority(\'ADMIN\')") protected CommunityRest createAndReturn(org.dspace.core.Context context) throws org.dspace.authorize.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<CommunityRest,UUID>- Parameters:
context- the dspace context- Returns:
- the created REST object
- Throws:
org.dspace.authorize.AuthorizeException
-
createAndReturn
@PreAuthorize("hasPermission(#id, \'COMMUNITY\', \'ADD\')") protected CommunityRest createAndReturn(org.dspace.core.Context context, UUID id) throws org.dspace.authorize.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<CommunityRest,UUID>- Parameters:
context- the dspace contextid- The uuid of the parent object retrieved from the query param.- Returns:
- the created REST object
- Throws:
org.dspace.authorize.AuthorizeException
-
findOne
@PreAuthorize("hasPermission(#id, \'COMMUNITY\', \'READ\')") public CommunityRest findOne(org.dspace.core.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(org.dspace.core.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(org.dspace.core.Context context, javax.servlet.http.HttpServletRequest request, String apiCategory, String model, UUID id, Patch patch) throws org.dspace.authorize.AuthorizeException, SQLExceptionDescription 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:
org.dspace.authorize.AuthorizeExceptionSQLException
-
getDomainClass
public Class<CommunityRest> 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(org.dspace.core.Context context, javax.servlet.http.HttpServletRequest request, String apiCategory, String model, UUID id, com.fasterxml.jackson.databind.JsonNode jsonNode) throws RepositoryMethodNotImplementedException, SQLException, org.dspace.authorize.AuthorizeExceptionDescription 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 errororg.dspace.authorize.AuthorizeException- if the context user is not authorized to perform this operation
-
delete
@PreAuthorize("hasPermission(#id, \'COMMUNITY\', \'DELETE\')") protected void delete(org.dspace.core.Context context, UUID id) throws org.dspace.authorize.AuthorizeExceptionDescription 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:
org.dspace.authorize.AuthorizeException
-
setLogo
public BitstreamRest setLogo(org.dspace.core.Context context, org.dspace.content.Community community, org.springframework.web.multipart.MultipartFile uploadfile) throws IOException, org.dspace.authorize.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:
IOExceptionorg.dspace.authorize.AuthorizeExceptionSQLException
-
createAdminGroup
public GroupRest createAdminGroup(org.dspace.core.Context context, javax.servlet.http.HttpServletRequest request, org.dspace.content.Community community) throws SQLException, org.dspace.authorize.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 wrongorg.dspace.authorize.AuthorizeException- If something goes wrong
-
deleteAdminGroup
public void deleteAdminGroup(org.dspace.core.Context context, org.dspace.content.Community community) throws SQLException, org.dspace.authorize.AuthorizeException, IOExceptionThis 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 wrongorg.dspace.authorize.AuthorizeException- If something goes wrongIOException- If something goes wrong
-
-