diff --git a/src/main/java/com/databasepreservation/common/api/v1/DatabaseResource.java b/src/main/java/com/databasepreservation/common/api/v1/DatabaseResource.java index 51c2adc4..e933b01c 100644 --- a/src/main/java/com/databasepreservation/common/api/v1/DatabaseResource.java +++ b/src/main/java/com/databasepreservation/common/api/v1/DatabaseResource.java @@ -8,9 +8,10 @@ package com.databasepreservation.common.api.v1; import java.io.IOException; +import java.time.DateTimeException; import java.time.LocalDateTime; -import java.time.LocalTime; import java.time.ZoneId; +import java.time.ZoneOffset; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; @@ -321,13 +322,21 @@ public static List getDatabaseFindContentTypeFilterQueries() { public static List getDatabaseFindUserPermissionsFilterQueries(User user) { Filter filter = new Filter(); - // Convert today's date to midnight, start of the day - LocalDateTime now = LocalDateTime.ofInstant(new Date().toInstant(), ZoneId.systemDefault()); - LocalDateTime today = now.with(LocalTime.MIN); - Date todayDate = Date.from(today.atZone(ZoneId.systemDefault()).toInstant()); + String zoneIdString = ViewerConfiguration.getInstance().getViewerConfigurationAsString("UTC", + ViewerConstants.PROPERTY_EXPIRY_ZONE_ID_OVERRIDE); + ZoneId zoneId; + try { + zoneId = ZoneId.of(zoneIdString); + } catch (DateTimeException e) { + zoneId = ZoneOffset.UTC; + } + // LocalDateTime gets the current time in the configured timezone... + LocalDateTime nowDateTime = LocalDateTime.ofInstant(new Date().toInstant(), zoneId); + // ... and then we convert to Date using UTC so that it is sent to the query with the timezone's offset + Date now = Date.from(nowDateTime.atZone(ZoneOffset.UTC).toInstant()); - BlockJoinAnyParentExpiryFilterParameter param = new BlockJoinAnyParentExpiryFilterParameter(user.getAllRoles(), - todayDate, null); + BlockJoinAnyParentExpiryFilterParameter param = new BlockJoinAnyParentExpiryFilterParameter(user.getAllRoles(), now, + null); filter.add(param); return new ArrayList<>(List.of(filter)); } diff --git a/src/main/java/com/databasepreservation/common/client/ViewerConstants.java b/src/main/java/com/databasepreservation/common/client/ViewerConstants.java index e97d1614..2d6117bc 100644 --- a/src/main/java/com/databasepreservation/common/client/ViewerConstants.java +++ b/src/main/java/com/databasepreservation/common/client/ViewerConstants.java @@ -590,6 +590,11 @@ public class ViewerConstants { public static final String SEARCH_ALL_SELECTED_NONE = "none"; public static final String PROPERTY_SEARCH_ALL_DEFAULT_SELECTION = "ui.searchAll.defaultSelection"; + /** + * Permissions + */ + public static final String PROPERTY_EXPIRY_ZONE_ID_OVERRIDE = "permissions.expiry.zoneId.override"; + /** * Header */ diff --git a/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/navigation/PermissionsNavigationPanel.java b/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/navigation/PermissionsNavigationPanel.java index b3f3a415..c3c94830 100644 --- a/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/navigation/PermissionsNavigationPanel.java +++ b/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/navigation/PermissionsNavigationPanel.java @@ -76,7 +76,8 @@ public class PermissionsNavigationPanel { private AuthorizationGroup currentGroup; private DateTimeFormat htmlInputPresentedDateFormat = DateTimeFormat.getFormat("MM/dd/yyyy"); - private DateTimeFormat htmlInputDateFormat = DateTimeFormat.getFormat("yyyy-MM-dd"); + private DateTimeFormat htmlMinDateFormat = DateTimeFormat.getFormat("yyyy-MM-dd"); + private DateTimeFormat htmlInputDateFormat = DateTimeFormat.getFormat("yyyy-MM-ddTHH:mm:ssZ"); private Date lastDate; private boolean overrideMissingGroups = false; @@ -316,7 +317,7 @@ public void render(Cell.Context context, AuthorizationGroup object, SafeHtmlBuil } private void showDatePicker() { - String today = htmlInputDateFormat.format(new Date()); + String today = htmlMinDateFormat.format(new Date()); String currentDateValueAttribute = ""; if (groupDetails.getOrDefault(currentGroup.getAttributeValue(), new AuthorizationDetails()).hasExpiryDate()) { currentDateValueAttribute = "value=\"" @@ -329,7 +330,7 @@ protected void onDetach() { super.onDetach(); String datePickerValue = JavascriptUtils.getInputValue("expiryDatePicker"); if (datePickerValue != null && !datePickerValue.isEmpty()) { - lastDate = htmlInputDateFormat.parse(datePickerValue); + lastDate = htmlInputDateFormat.parse(datePickerValue + "T23:59:59-0000"); } else { lastDate = null; } diff --git a/src/main/java/com/databasepreservation/common/utils/UserUtility.java b/src/main/java/com/databasepreservation/common/utils/UserUtility.java index 1487ed28..758ebd0c 100644 --- a/src/main/java/com/databasepreservation/common/utils/UserUtility.java +++ b/src/main/java/com/databasepreservation/common/utils/UserUtility.java @@ -11,8 +11,10 @@ import java.lang.reflect.Method; import java.net.InetAddress; import java.net.UnknownHostException; -import java.time.Instant; -import java.time.temporal.ChronoUnit; +import java.time.DateTimeException; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.ZoneOffset; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -164,14 +166,24 @@ private static void checkAuthorizationGroups(final User user, Map