public abstract class DSpaceRestRepository<T extends RestAddressableModel,ID extends Serializable> extends AbstractDSpaceRestRepository implements org.springframework.data.repository.PagingAndSortingRepository<T,ID>
requestService, utils| Constructor and Description |
|---|
DSpaceRestRepository() |
| Modifier and Type | Method and Description |
|---|---|
protected T |
action(Context context,
javax.servlet.http.HttpServletRequest request,
ID id) |
T |
action(javax.servlet.http.HttpServletRequest request,
ID id) |
long |
count() |
T |
createAndReturn()
Create and return a new instance.
|
protected T |
createAndReturn(Context context)
Method to implement to support the creation of a new instance.
|
protected T |
createAndReturn(Context context,
List<String> list)
Method to implement to support the creation of a new instance.
|
T |
createAndReturn(List<String> list)
Create and return a new instance.
|
protected void |
delete(Context context,
ID id)
Method to implement to support delete of a single object instance
|
void |
delete(ID id) |
void |
delete(Iterable<? extends T> entities) |
void |
delete(T entity) |
void |
deleteAll() |
boolean |
exists(ID id) |
Iterable<T> |
findAll() |
abstract org.springframework.data.domain.Page<T> |
findAll(Context context,
org.springframework.data.domain.Pageable pageable)
Method to implement to support scroll of entity instances from the collection resource endpoin
|
Iterable<T> |
findAll(Iterable<ID> ids) |
org.springframework.data.domain.Page<T> |
findAll(org.springframework.data.domain.Pageable pageable) |
Iterable<T> |
findAll(org.springframework.data.domain.Sort sort) |
abstract T |
findOne(Context context,
ID id)
Method to implement to support retrieval of a specific REST object instance
|
T |
findOne(ID id) |
abstract Class<T> |
getDomainClass()
The REST model supported by the repository
|
protected void |
patch(Context context,
javax.servlet.http.HttpServletRequest request,
String apiCategory,
String model,
ID id,
Patch patch)
Method to implement to allow partial update of the REST object via JSON Patch
|
T |
patch(javax.servlet.http.HttpServletRequest request,
String apiCategory,
String model,
ID id,
Patch patch)
Apply a partial update to the REST object via JSON Patch
|
protected T |
put(Context context,
javax.servlet.http.HttpServletRequest request,
String apiCategory,
String model,
ID id,
com.fasterxml.jackson.databind.JsonNode jsonNode)
Implement this method in the subclass to support updating a REST object.
|
protected T |
put(Context context,
javax.servlet.http.HttpServletRequest request,
String apiCategory,
String model,
ID id,
List<String> stringList)
Implement this method in the subclass to support updating a DSpace instance.
|
T |
put(javax.servlet.http.HttpServletRequest request,
String apiCategory,
String model,
ID uuid,
com.fasterxml.jackson.databind.JsonNode jsonNode)
This method will fully replace the REST object with the given UUID with the REST object that is described
in the JsonNode parameter
|
T |
put(javax.servlet.http.HttpServletRequest request,
String apiCategory,
String model,
ID id,
List<String> stringList)
Method to support updating a DSpace instance.
|
protected <S extends T> |
save(Context context,
S entity)
Method to implement to support full update of a REST object.
|
<S extends T> |
save(Iterable<S> entities) |
<S extends T> |
save(S entity) |
protected Iterable<T> |
upload(Context context,
javax.servlet.http.HttpServletRequest request,
org.springframework.web.multipart.MultipartFile uploadfile)
Method to implement to support bulk creation of objects from a file
|
Iterable<T> |
upload(javax.servlet.http.HttpServletRequest request,
org.springframework.web.multipart.MultipartFile uploadfile)
Bulk create object instances from an uploaded file
|
T |
upload(javax.servlet.http.HttpServletRequest request,
String apiCategory,
String model,
ID id,
org.springframework.web.multipart.MultipartFile file)
Method to implement to attach/upload a file to a specific REST object
|
abstract DSpaceResource<T> |
wrapResource(T model,
String... rels)
Wrap the REST model in a REST HAL Resource
|
getRequestService, obtainContextpublic <S extends T> S save(S entity)
save in interface org.springframework.data.repository.CrudRepository<T extends RestAddressableModel,ID extends Serializable>protected <S extends T> S save(Context context, S entity) throws AuthorizeException, RepositoryMethodNotImplementedException
context - the dspace contextentity - the REST object to updateAuthorizeExceptionRepositoryMethodNotImplementedException - returned by the default implementation when the operation is not supported for the entitypublic <S extends T> Iterable<S> save(Iterable<S> entities)
save in interface org.springframework.data.repository.CrudRepository<T extends RestAddressableModel,ID extends Serializable>public T findOne(ID id)
findOne in interface org.springframework.data.repository.CrudRepository<T extends RestAddressableModel,ID extends Serializable>public abstract T findOne(Context context, ID id)
context - the dspace contextid - the rest object idpublic boolean exists(ID id)
exists in interface org.springframework.data.repository.CrudRepository<T extends RestAddressableModel,ID extends Serializable>public final Iterable<T> findAll()
findAll in interface org.springframework.data.repository.CrudRepository<T extends RestAddressableModel,ID extends Serializable>public Iterable<T> findAll(Iterable<ID> ids)
findAll in interface org.springframework.data.repository.CrudRepository<T extends RestAddressableModel,ID extends Serializable>public long count()
count in interface org.springframework.data.repository.CrudRepository<T extends RestAddressableModel,ID extends Serializable>public void delete(ID id)
delete in interface org.springframework.data.repository.CrudRepository<T extends RestAddressableModel,ID extends Serializable>protected void delete(Context context, ID id) throws AuthorizeException, RepositoryMethodNotImplementedException
context - the dspace contextid - the id of the rest object to deleteAuthorizeExceptionRepositoryMethodNotImplementedException - returned by the default implementation when the operation is not supported for the entitypublic void delete(T entity)
delete in interface org.springframework.data.repository.CrudRepository<T extends RestAddressableModel,ID extends Serializable>public void delete(Iterable<? extends T> entities)
delete in interface org.springframework.data.repository.CrudRepository<T extends RestAddressableModel,ID extends Serializable>public void deleteAll()
deleteAll in interface org.springframework.data.repository.CrudRepository<T extends RestAddressableModel,ID extends Serializable>public final Iterable<T> findAll(org.springframework.data.domain.Sort sort)
findAll in interface org.springframework.data.repository.PagingAndSortingRepository<T extends RestAddressableModel,ID extends Serializable>public org.springframework.data.domain.Page<T> findAll(org.springframework.data.domain.Pageable pageable)
findAll in interface org.springframework.data.repository.PagingAndSortingRepository<T extends RestAddressableModel,ID extends Serializable>public abstract org.springframework.data.domain.Page<T> findAll(Context context, org.springframework.data.domain.Pageable pageable)
context - the dspace contextpageable - object embedding the requested pagination infopublic abstract DSpaceResource<T> wrapResource(T model, String... rels)
model - the rest model instancerels - the HAL linkspublic T createAndReturn(List<String> list)
list - The list of Strings to be used in the createAndReturn methodpublic T createAndReturn()
protected T createAndReturn(Context context, List<String> list) throws AuthorizeException, SQLException, RepositoryMethodNotImplementedException
context - the dspace contextlist - The list of Strings that will be used as data for the object that's to be created
This list is retrieved from the uri-list bodyAuthorizeExceptionSQLExceptionRepositoryMethodNotImplementedException - returned by the default implementation when the operation is not supported for the entityprotected T createAndReturn(Context context) throws AuthorizeException, SQLException, RepositoryMethodNotImplementedException
context - the dspace contextAuthorizeExceptionSQLExceptionRepositoryMethodNotImplementedException - returned by the default implementation when the operation is not supported for the entitypublic T upload(javax.servlet.http.HttpServletRequest request, String apiCategory, String model, ID id, org.springframework.web.multipart.MultipartFile file) throws Exception
request - the http requestapiCategory - model - id - the ID of the target REST objectfile - the uploaded fileExceptionpublic T patch(javax.servlet.http.HttpServletRequest request, String apiCategory, String model, ID id, Patch patch) throws org.springframework.web.HttpRequestMethodNotSupportedException, UnprocessableEntityException, PatchBadRequestException
request - the http requestapiCategory - model - id - the ID of the target REST objectpatch - the JSON Patch (https://tools.ietf.org/html/rfc6902) operationorg.springframework.web.HttpRequestMethodNotSupportedExceptionUnprocessableEntityExceptionPatchBadRequestExceptionprotected void patch(Context context, javax.servlet.http.HttpServletRequest request, String apiCategory, String model, ID id, Patch patch) throws RepositoryMethodNotImplementedException, SQLException, AuthorizeException, DCInputsReaderException
request - the http requestapiCategory - model - id - the ID of the target REST objectpatch - the JSON Patch (https://tools.ietf.org/html/rfc6902) operationorg.springframework.web.HttpRequestMethodNotSupportedExceptionUnprocessableEntityExceptionPatchBadRequestExceptionRepositoryMethodNotImplementedException - returned by the default implementation when the operation is not supported for the entitySQLExceptionAuthorizeExceptionDCInputsReaderExceptionpublic T action(javax.servlet.http.HttpServletRequest request, ID id) throws SQLException, IOException
SQLExceptionIOExceptionprotected T action(Context context, javax.servlet.http.HttpServletRequest request, ID id) throws SQLException, IOException
SQLExceptionIOExceptionpublic Iterable<T> upload(javax.servlet.http.HttpServletRequest request, org.springframework.web.multipart.MultipartFile uploadfile) throws SQLException, FileNotFoundException, IOException, AuthorizeException
request - the http requestuploadfile - the file to processSQLExceptionFileNotFoundExceptionIOExceptionAuthorizeExceptionprotected Iterable<T> upload(Context context, javax.servlet.http.HttpServletRequest request, org.springframework.web.multipart.MultipartFile uploadfile) throws SQLException, FileNotFoundException, IOException, AuthorizeException
request - the http requestuploadfile - the file to processSQLExceptionFileNotFoundExceptionIOExceptionAuthorizeExceptionRepositoryMethodNotImplementedExceptionpublic T put(javax.servlet.http.HttpServletRequest request, String apiCategory, String model, ID uuid, com.fasterxml.jackson.databind.JsonNode jsonNode)
request - the http requestapiCategory - the API category e.g. "api"model - the DSpace model e.g. "metadatafield"uuid - the ID of the target REST objectjsonNode - the part of the request body representing the updated rest objectpublic T put(javax.servlet.http.HttpServletRequest request, String apiCategory, String model, ID id, List<String> stringList)
request - the http requestapiCategory - the API category e.g. "api"model - the DSpace model e.g. "metadatafield"id - the ID of the target REST objectstringList - The list of Strings that will be used as data for the putprotected T put(Context context, javax.servlet.http.HttpServletRequest request, String apiCategory, String model, ID id, com.fasterxml.jackson.databind.JsonNode jsonNode) throws RepositoryMethodNotImplementedException, SQLException, AuthorizeException
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 objectAuthorizeException - if the context user is not authorized to perform this operationSQLException - when the database returns an errorRepositoryMethodNotImplementedException - returned by the default implementation when the operation is not supported for the entityprotected T put(Context context, javax.servlet.http.HttpServletRequest request, String apiCategory, String model, ID id, List<String> stringList) throws RepositoryMethodNotImplementedException, SQLException, AuthorizeException
context - the dspace contextapiCategory - the API category e.g. "api"model - the DSpace model e.g. "metadatafield"id - the ID of the target REST objectstringList - The list of Strings that will be used as data for the putAuthorizeException - if the context user is not authorized to perform this operationSQLException - when the database returns an errorRepositoryMethodNotImplementedException - returned by the default implementation when the operation is not supported for the entityCopyright © 2019 DuraSpace. All rights reserved.