Class RequestItemServiceImpl

java.lang.Object
org.dspace.app.requestitem.RequestItemServiceImpl
All Implemented Interfaces:
RequestItemService

public class RequestItemServiceImpl extends Object implements RequestItemService
Service implementation for the RequestItem object. This class is responsible for all business logic calls for the RequestItem object and is autowired by Spring. This class should never be accessed directly.
Author:
kevinvandevelde at atmire.com, Kim Shepherd
  • Field Details

  • Constructor Details

    • RequestItemServiceImpl

      protected RequestItemServiceImpl()
  • Method Details

    • createRequest

      public String createRequest(Context context, Bitstream bitstream, Item item, boolean allFiles, String reqEmail, String reqName, String reqMessage) throws SQLException
      Create a new request-a-copy item request.
      Specified by:
      createRequest in interface RequestItemService
      Parameters:
      context - The relevant DSpace Context.
      bitstream - The requested bitstream
      item - The requested item
      allFiles - true indicates that all bitstreams of this item are requested
      reqEmail - email Requester email
      reqName - Requester name
      reqMessage - Request message text
      Returns:
      token to be used to approver for grant/deny
      Throws:
      SQLException
    • findAll

      public List<RequestItem> findAll(Context context) throws SQLException
      Description copied from interface: RequestItemService
      Fetch all item requests.
      Specified by:
      findAll in interface RequestItemService
      Parameters:
      context - current DSpace session.
      Returns:
      all item requests.
      Throws:
      SQLException - passed through.
    • findByToken

      public RequestItem findByToken(Context context, String token)
      Description copied from interface: RequestItemService
      Retrieve a request by its approver token.
      Specified by:
      findByToken in interface RequestItemService
      Parameters:
      context - current DSpace session.
      token - the token identifying the request to be approved.
      Returns:
      the matching request, or null if not found.
    • findByItem

      public Iterator<RequestItem> findByItem(Context context, Item item) throws SQLException
      Description copied from interface: RequestItemService
      Retrieve a request based on the item.
      Specified by:
      findByItem in interface RequestItemService
      Parameters:
      context - current DSpace session.
      item - the item to find requests for.
      Returns:
      the matching requests, or null if not found.
      Throws:
      SQLException
    • update

      public void update(Context context, RequestItem requestItem)
      Description copied from interface: RequestItemService
      Save updates to the record. Only accept_request, decision_date, access_period are settable. Note: the "is settable" rules mentioned here are enforced in RequestItemRest with annotations meaning that these JSON properties are considered READ-ONLY by the core DSpaceRestRepository methods
      Specified by:
      update in interface RequestItemService
      Parameters:
      context - The relevant DSpace Context.
      requestItem - requested item
    • delete

      public void delete(Context context, RequestItem requestItem)
      Description copied from interface: RequestItemService
      Remove the record from the database.
      Specified by:
      delete in interface RequestItemService
      Parameters:
      context - current DSpace context.
      requestItem - record to be removed.
    • isRestricted

      public boolean isRestricted(Context context, DSpaceObject o) throws SQLException
      Description copied from interface: RequestItemService
      Is there at least one valid READ resource policy for this object?
      Specified by:
      isRestricted in interface RequestItemService
      Parameters:
      context - current DSpace session.
      o - the object.
      Returns:
      true if a READ policy applies.
      Throws:
      SQLException - passed through.
    • findByAccessToken

      public RequestItem findByAccessToken(Context context, String accessToken)
      Find a request item by its access token. This is the token that a requester would use to authenticate themselves as a granted requester. It is up to the RequestItemRepository to check validity of the item, access granted, data sanitization, etc.
      Specified by:
      findByAccessToken in interface RequestItemService
      Parameters:
      context - current DSpace session.
      accessToken - the token identifying the request to be temporarily accessed
      Returns:
      request item data
    • setAccessExpiry

      public void setAccessExpiry(RequestItem requestItem, Instant accessExpiry)
      Set the access expiry date for the request item.
      Specified by:
      setAccessExpiry in interface RequestItemService
      Parameters:
      requestItem - the request item to update
      accessExpiry - the expiry date to set
    • setAccessExpiry

      public void setAccessExpiry(RequestItem requestItem, String dateOrDelta)
      Take a string either as a formatted date, or in the "math" format expected by the DateMathParser, e.g. +7DAYS or +10MONTHS, and set the access expiry date accordingly. There are no special checks here to check that the date is in the future, or after the 'decision date', as there may be legitimate reasons to set past dates. If past dates are not allowed by some interface, then the caller should check this.
      Specified by:
      setAccessExpiry in interface RequestItemService
      Parameters:
      requestItem - the request item to update
      dateOrDelta - the delta as a string in format expected by the DateMathParser
    • authorizeAccessByAccessToken

      public void authorizeAccessByAccessToken(Context context, RequestItem requestItem, Bitstream bitstream, String accessToken) throws AuthorizeException
      Taking into account 'accepted' flag, bitstream id or allfiles flag, decision date and access period, either return cleanly or throw an AuthorizeException
      Specified by:
      authorizeAccessByAccessToken in interface RequestItemService
      Parameters:
      context - the DSpace context
      requestItem - the request item containing request and approval data
      bitstream - the bitstream to which access is requested
      accessToken - the access token supplied by the user (e.g. to REST controller)
      Throws:
      AuthorizeException
    • authorizeAccessByAccessToken

      public void authorizeAccessByAccessToken(Context context, Bitstream bitstream, String accessToken) throws AuthorizeException
      Taking into account 'accepted' flag, bitstream id or allfiles flag, decision date and access period, either return cleanly or throw an AuthorizeException
      Specified by:
      authorizeAccessByAccessToken in interface RequestItemService
      Parameters:
      context - the DSpace context
      bitstream - the bitstream to which access is requested
      accessToken - the access token supplied by the user (e.g. to REST controller)
      Throws:
      AuthorizeException
    • getLinkTokenEmail

      public String getLinkTokenEmail(String token) throws URISyntaxException, MalformedURLException
      Generate a link back to DSpace, to act on a request.
      Specified by:
      getLinkTokenEmail in interface RequestItemService
      Parameters:
      token - identifies the request.
      Returns:
      URL to the item request API, with the token as request parameter "token".
      Throws:
      URISyntaxException - passed through.
      MalformedURLException - passed through.
    • sanitizeRequestItem

      public void sanitizeRequestItem(Context context, RequestItem requestItem)
      Sanitize a RequestItem. The following values in the referenced RequestItem are nullified: - approver token (aka token) - requester name - requester email - requester message These properties contain personal information, or can be used to access personal information and are not needed except for sending the original request and grant/deny emails
      Specified by:
      sanitizeRequestItem in interface RequestItemService
      Parameters:
      requestItem -
    • parseDateOrDelta

      public static Instant parseDateOrDelta(String dateOrDelta, Instant decisionDate) throws ParseException, DateTimeException
      Parse a date or delta string into an Instant. Kept here as a static method for use in unit tests and other areas that might not have access to the full spring service
      Parameters:
      dateOrDelta -
      decisionDate -
      Returns:
      parsed date as instant
      Throws:
      ParseException
      DateTimeException