Class ItemRestRepository

  • All Implemented Interfaces:
    ReloadableEntityObjectRepository<org.dspace.content.Item,​UUID>, org.springframework.data.repository.CrudRepository<ItemRest,​UUID>, org.springframework.data.repository.PagingAndSortingRepository<ItemRest,​UUID>, org.springframework.data.repository.Repository<ItemRest,​UUID>

    @Component("core.item")
    public class ItemRestRepository
    extends DSpaceObjectRestRepository<org.dspace.content.Item,​ItemRest>
    This is the repository responsible to manage Item Rest object
    Author:
    Andrea Bollini (andrea.bollini at 4science.it)
    • Field Detail

      • COPYVIRTUAL_ALL

        public static final String[] COPYVIRTUAL_ALL
      • COPYVIRTUAL_CONFIGURED

        public static final String[] COPYVIRTUAL_CONFIGURED
      • REQUESTPARAMETER_COPYVIRTUALMETADATA

        public static final String REQUESTPARAMETER_COPYVIRTUALMETADATA
        See Also:
        Constant Field Values
    • Constructor Detail

      • ItemRestRepository

        public ItemRestRepository​(org.dspace.content.service.ItemService dsoService)
    • Method Detail

      • findOne

        @PreAuthorize("hasPermission(#id, \'ITEM\', \'STATUS\') || hasPermission(#id, \'ITEM\', \'READ\')")
        public ItemRest findOne​(org.dspace.core.Context context,
                                UUID id)
        Description copied from class: DSpaceRestRepository
        Method to implement to support retrieval of a specific REST object instance
        Specified by:
        findOne in class DSpaceRestRepository<ItemRest,​UUID>
        Parameters:
        context - the dspace context
        id - the rest object id
        Returns:
        the REST object identified by its ID
      • findAll

        @PreAuthorize("hasAuthority(\'ADMIN\')")
        public org.springframework.data.domain.Page<ItemRest> findAll​(org.dspace.core.Context context,
                                                                      org.springframework.data.domain.Pageable pageable)
        Description copied from class: DSpaceRestRepository
        Method to implement to support scroll of entity instances from the collection resource endpoint
        Specified by:
        findAll in class DSpaceRestRepository<ItemRest,​UUID>
        Parameters:
        context - the dspace context
        pageable - object embedding the requested pagination info
        Returns:
      • patch

        @PreAuthorize("hasPermission(#id, \'ITEM\', #patch)")
        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,
                             SQLException
        Description copied from class: DSpaceRestRepository
        Method to implement to allow partial update of the REST object via JSON Patch
        Overrides:
        patch in class DSpaceRestRepository<ItemRest,​UUID>
        request - the http request
        id - the ID of the target REST object
        patch - the JSON Patch (https://tools.ietf.org/html/rfc6902) operation
        Throws:
        org.dspace.authorize.AuthorizeException
        SQLException
      • delete

        @PreAuthorize("hasPermission(#id, \'ITEM\', \'DELETE\')")
        protected void delete​(org.dspace.core.Context context,
                              UUID id)
                       throws org.dspace.authorize.AuthorizeException
        Description copied from class: DSpaceRestRepository
        Method to implement to support delete of a single object instance
        Overrides:
        delete in class DSpaceRestRepository<ItemRest,​UUID>
        Parameters:
        context - the dspace context
        id - the id of the rest object to delete
        Throws:
        org.dspace.authorize.AuthorizeException
      • createAndReturn

        @PreAuthorize("hasAuthority(\'ADMIN\')")
        protected ItemRest createAndReturn​(org.dspace.core.Context context)
                                    throws org.dspace.authorize.AuthorizeException,
                                           SQLException
        Description copied from class: DSpaceRestRepository
        Method to implement to support the creation of a new instance. Usually require to retrieve the http request from the thread bound attribute
        Overrides:
        createAndReturn in class DSpaceRestRepository<ItemRest,​UUID>
        Parameters:
        context - the dspace context
        Returns:
        the created REST object
        Throws:
        org.dspace.authorize.AuthorizeException
        SQLException
      • put

        @PreAuthorize("hasPermission(#uuid, \'ITEM\', \'WRITE\')")
        protected ItemRest put​(org.dspace.core.Context context,
                               javax.servlet.http.HttpServletRequest request,
                               String apiCategory,
                               String model,
                               UUID uuid,
                               com.fasterxml.jackson.databind.JsonNode jsonNode)
                        throws RepositoryMethodNotImplementedException,
                               SQLException,
                               org.dspace.authorize.AuthorizeException
        Description copied from class: DSpaceRestRepository
        Implement this method in the subclass to support updating a REST object.
        Overrides:
        put in class DSpaceRestRepository<ItemRest,​UUID>
        Parameters:
        context - the dspace context
        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
        Throws:
        RepositoryMethodNotImplementedException - returned by the default implementation when the operation is not supported for the entity
        SQLException - when the database returns an error
        org.dspace.authorize.AuthorizeException - if the context user is not authorized to perform this operation
      • addBundleToItem

        public org.dspace.content.Bundle addBundleToItem​(org.dspace.core.Context context,
                                                         org.dspace.content.Item item,
                                                         BundleRest bundleRest)
                                                  throws SQLException,
                                                         org.dspace.authorize.AuthorizeException
        Method to add a bundle to an item
        Parameters:
        context - The context
        item - The item to which the bundle has to be added
        bundleRest - The bundleRest that needs to be added to the item
        Returns:
        The added bundle
        Throws:
        SQLException
        org.dspace.authorize.AuthorizeException