Class DSpaceRestRepository<T extends RestAddressableModel,​ID extends Serializable>

    • Constructor Detail

      • DSpaceRestRepository

        public DSpaceRestRepository()
    • Method Detail

      • save

        public <S extends T> S save​(S entity)
        Specified by:
        save in interface org.springframework.data.repository.CrudRepository<T extends RestAddressableModel,​ID extends Serializable>
      • findOne

        @PreAuthorize("hasAuthority(\'ADMIN\')")
        public abstract T findOne​(Context context,
                                  ID id)
        Method to implement to support retrieval of a specific REST object instance
        Parameters:
        context - the dspace context
        id - the rest object id
        Returns:
        the REST object identified by its ID
      • existsById

        public boolean existsById​(ID id)
        Specified by:
        existsById in interface org.springframework.data.repository.CrudRepository<T extends RestAddressableModel,​ID extends Serializable>
      • deleteById

        public void deleteById​(ID id)
        Specified by:
        deleteById in interface org.springframework.data.repository.CrudRepository<T extends RestAddressableModel,​ID extends Serializable>
      • delete

        public void delete​(T entity)
        Specified by:
        delete in interface org.springframework.data.repository.CrudRepository<T extends RestAddressableModel,​ID extends Serializable>
      • deleteAll

        public void deleteAll​(Iterable<? extends T> entities)
        Specified by:
        deleteAll in interface org.springframework.data.repository.CrudRepository<T extends RestAddressableModel,​ID extends Serializable>
      • deleteAll

        public void deleteAll()
        Specified by:
        deleteAll in interface org.springframework.data.repository.CrudRepository<T extends RestAddressableModel,​ID extends Serializable>
      • findAll

        public final Iterable<T> findAll​(org.springframework.data.domain.Sort sort)
        Specified by:
        findAll in interface org.springframework.data.repository.PagingAndSortingRepository<T extends RestAddressableModel,​ID extends Serializable>
      • findAll

        public org.springframework.data.domain.Page<T> findAll​(org.springframework.data.domain.Pageable pageable)
        Specified by:
        findAll in interface org.springframework.data.repository.PagingAndSortingRepository<T extends RestAddressableModel,​ID extends Serializable>
      • findAll

        public 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 endpoint
        Parameters:
        context - the dspace context
        pageable - object embedding the requested pagination info
        Returns:
      • getDomainClass

        public abstract Class<T> getDomainClass()
        The REST model supported by the repository
      • createAndReturn

        public T createAndReturn()
        Create and return a new instance. Data are usually retrieved from the thread bound http request
        Returns:
        the created REST object
      • createAndReturn

        public T createAndReturn​(UUID uuid)
        Create and return a new instance after adding to the parent. Data are usually retrieved from the thread bound http request.
        Parameters:
        uuid - the id of the parent object
        Returns:
        the created REST object
      • createAndReturn

        public T createAndReturn​(List<String> list)
        Create and return a new instance. Data is recovered from the thread bound HTTP request and the list of DSpaceObjects provided in the uri-list body
        Parameters:
        list - The list of Strings to be used in the createAndReturn method
        Returns:
        The created REST object
      • put

        public 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
        Parameters:
        request - the http request
        apiCategory - the API category e.g. "api"
        model - the DSpace model e.g. "metadatafield"
        uuid - the ID of the target REST object
        jsonNode - the part of the request body representing the updated rest object
        Returns:
        the updated REST object
      • put

        public T put​(javax.servlet.http.HttpServletRequest request,
                     String apiCategory,
                     String model,
                     ID id,
                     List<String> stringList)
        Method to support updating a DSpace instance.
        Parameters:
        request - the http request
        apiCategory - the API category e.g. "api"
        model - the DSpace model e.g. "metadatafield"
        id - the ID of the target REST object
        stringList - The list of Strings that will be used as data for the put
        Returns:
        the updated REST object
      • put

        protected 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
        Implement this method in the subclass to support updating a REST object.
        Parameters:
        context - the dspace context
        apiCategory - the API category e.g. "api"
        model - the DSpace model e.g. "metadatafield"
        id - the ID of the target REST object
        jsonNode - the part of the request body representing the updated rest object
        Returns:
        the updated REST object
        Throws:
        AuthorizeException - if the context user is not authorized to perform this operation
        SQLException - when the database returns an error
        RepositoryMethodNotImplementedException - returned by the default implementation when the operation is not supported for the entity
      • put

        protected T put​(Context context,
                        javax.servlet.http.HttpServletRequest request,
                        String apiCategory,
                        String model,
                        ID id,
                        List<String> stringList)
                 throws RepositoryMethodNotImplementedException,
                        SQLException,
                        AuthorizeException
        Implement this method in the subclass to support updating a DSpace instance.
        Parameters:
        context - the dspace context
        apiCategory - the API category e.g. "api"
        model - the DSpace model e.g. "metadatafield"
        id - the ID of the target REST object
        stringList - The list of Strings that will be used as data for the put
        Returns:
        the updated REST object
        Throws:
        AuthorizeException - if the context user is not authorized to perform this operation
        SQLException - when the database returns an error
        RepositoryMethodNotImplementedException - returned by the default implementation when the operation is not supported for the entity