mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Request-a-copy: Use postgres max timestamp, not Instant.MAX
This commit is contained in:
@@ -211,7 +211,7 @@ public class RequestItemEmailNotifier {
|
||||
+ "/items/" + ri.getItem().getID()
|
||||
+ "?accessToken=" + ri.getAccess_token());
|
||||
// {7} access end date, but only add formatted date string if it is set and not "forever"
|
||||
if (ri.getAccess_expiry() != null && !ri.getAccess_expiry().equals(Instant.MAX)) {
|
||||
if (ri.getAccess_expiry() != null && !ri.getAccess_expiry().equals(RequestItemServiceImpl.getMaxTimestamp())) {
|
||||
email.addArgument(dateTimeFormatter.format(ri.getAccess_expiry()));
|
||||
} else {
|
||||
email.addArgument(null);
|
||||
|
@@ -17,7 +17,6 @@ import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
@@ -383,7 +382,7 @@ public class RequestItemServiceImpl implements RequestItemService {
|
||||
// First, if dateOrDelta is a null string or "FOREVER", we will set the expiry
|
||||
// date to a very distant date in the future.
|
||||
if (dateOrDelta == null || dateOrDelta.equals("FOREVER")) {
|
||||
return Instant.MAX;
|
||||
return getMaxTimestamp();
|
||||
}
|
||||
// Next, try parsing as a straight date using the multiple format parser
|
||||
ZonedDateTime parsedExpiryDate = MultiFormatDateParser.parse(dateOrDelta);
|
||||
@@ -400,4 +399,13 @@ public class RequestItemServiceImpl implements RequestItemService {
|
||||
return parsedExpiryDate.toInstant();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the maximum timestamp that can be stored in a PostgreSQL database, for our "distant future" access expiry date.
|
||||
* @return the maximum timestamp that can be stored in a PostgreSQL database
|
||||
*/
|
||||
public static Instant getMaxTimestamp() {
|
||||
return LocalDateTime.of(294276, 1, 1, 0, 0, 0)
|
||||
.toInstant(ZoneOffset.UTC);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user