Package org.dspace.app.requestitem
Class RequestItemServiceImpl
java.lang.Object
org.dspace.app.requestitem.RequestItemServiceImpl
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptionprotected AuthorizeServiceprotected ConfigurationServiceprotected RequestItemDAOprotected ResourcePolicyService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidauthorizeAccessByAccessToken(Context context, RequestItem requestItem, Bitstream bitstream, String accessToken) Taking into account 'accepted' flag, bitstream id or allfiles flag, decision date and access period, either return cleanly or throw an AuthorizeExceptionvoidauthorizeAccessByAccessToken(Context context, Bitstream bitstream, String accessToken) Taking into account 'accepted' flag, bitstream id or allfiles flag, decision date and access period, either return cleanly or throw an AuthorizeExceptioncreateRequest(Context context, Bitstream bitstream, Item item, boolean allFiles, String reqEmail, String reqName, String reqMessage) Create a new request-a-copy item request.voiddelete(Context context, RequestItem requestItem) Remove the record from the database.Fetch all item requests.findByAccessToken(Context context, String accessToken) Find a request item by its access token.findByItem(Context context, Item item) Retrieve a request based on the item.findByToken(Context context, String token) Retrieve a request by its approver token.getLinkTokenEmail(String token) Generate a link back to DSpace, to act on a request.booleanisRestricted(Context context, DSpaceObject o) Is there at least one valid READ resource policy for this object?static InstantparseDateOrDelta(String dateOrDelta, Instant decisionDate) Parse a date or delta string into an Instant.voidsanitizeRequestItem(Context context, RequestItem requestItem) Sanitize a RequestItem.voidsetAccessExpiry(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.voidsetAccessExpiry(RequestItem requestItem, Instant accessExpiry) Set the access expiry date for the request item.voidupdate(Context context, RequestItem requestItem) Save updates to the record.
-
Field Details
-
requestItemDAO
-
authorizeService
-
resourcePolicyService
-
configurationService
-
-
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:
createRequestin interfaceRequestItemService- Parameters:
context- The relevant DSpace Context.bitstream- The requested bitstreamitem- The requested itemallFiles- true indicates that all bitstreams of this item are requestedreqEmail- email Requester emailreqName- Requester namereqMessage- Request message text- Returns:
- token to be used to approver for grant/deny
- Throws:
SQLException
-
findAll
Description copied from interface:RequestItemServiceFetch all item requests.- Specified by:
findAllin interfaceRequestItemService- Parameters:
context- current DSpace session.- Returns:
- all item requests.
- Throws:
SQLException- passed through.
-
findByToken
Description copied from interface:RequestItemServiceRetrieve a request by its approver token.- Specified by:
findByTokenin interfaceRequestItemService- Parameters:
context- current DSpace session.token- the token identifying the request to be approved.- Returns:
- the matching request, or null if not found.
-
findByItem
Description copied from interface:RequestItemServiceRetrieve a request based on the item.- Specified by:
findByItemin interfaceRequestItemService- Parameters:
context- current DSpace session.item- the item to find requests for.- Returns:
- the matching requests, or null if not found.
- Throws:
SQLException
-
update
Description copied from interface:RequestItemServiceSave 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:
updatein interfaceRequestItemService- Parameters:
context- The relevant DSpace Context.requestItem- requested item
-
delete
Description copied from interface:RequestItemServiceRemove the record from the database.- Specified by:
deletein interfaceRequestItemService- Parameters:
context- current DSpace context.requestItem- record to be removed.
-
isRestricted
Description copied from interface:RequestItemServiceIs there at least one valid READ resource policy for this object?- Specified by:
isRestrictedin interfaceRequestItemService- Parameters:
context- current DSpace session.o- the object.- Returns:
- true if a READ policy applies.
- Throws:
SQLException- passed through.
-
findByAccessToken
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:
findByAccessTokenin interfaceRequestItemService- Parameters:
context- current DSpace session.accessToken- the token identifying the request to be temporarily accessed- Returns:
- request item data
-
setAccessExpiry
Set the access expiry date for the request item.- Specified by:
setAccessExpiryin interfaceRequestItemService- Parameters:
requestItem- the request item to updateaccessExpiry- the expiry date to set
-
setAccessExpiry
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:
setAccessExpiryin interfaceRequestItemService- Parameters:
requestItem- the request item to updatedateOrDelta- 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:
authorizeAccessByAccessTokenin interfaceRequestItemService- Parameters:
context- the DSpace contextrequestItem- the request item containing request and approval databitstream- the bitstream to which access is requestedaccessToken- 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:
authorizeAccessByAccessTokenin interfaceRequestItemService- Parameters:
context- the DSpace contextbitstream- the bitstream to which access is requestedaccessToken- the access token supplied by the user (e.g. to REST controller)- Throws:
AuthorizeException
-
getLinkTokenEmail
Generate a link back to DSpace, to act on a request.- Specified by:
getLinkTokenEmailin interfaceRequestItemService- 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
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:
sanitizeRequestItemin interfaceRequestItemService- 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:
ParseExceptionDateTimeException
-