From c999c5df06709c001c29da9421e677d6e087b906 Mon Sep 17 00:00:00 2001 From: milanmajchrak <90026355+milanmajchrak@users.noreply.github.com> Date: Mon, 16 Sep 2024 16:08:38 +0200 Subject: [PATCH] Internal/Copy fixes from ZCU (#749) * Use $JAVA_OPTS_HANDLE to define handle server memory. * Do not add another slash in the handle URL (#737) * The scheduled tasks are available in the `/scheduledtasks` endpoint. (#741) * TUL/ The context user is set to current subscriber (#747) * The context user is set to current subscriber * Updated comment * Fixed checktyle issue * Cherry picked fix about integration tests (#751) Co-authored-by: Tim Donohue --------- Co-authored-by: Tim Donohue --- .../java/org/dspace/handle/HandleClarinServiceImpl.java | 5 +++-- .../SubscriptionEmailNotificationServiceImpl.java | 8 +++++++- dspace/bin/start-handle-server | 6 +++--- dspace/config/modules/actuator.cfg | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/dspace-api/src/main/java/org/dspace/handle/HandleClarinServiceImpl.java b/dspace-api/src/main/java/org/dspace/handle/HandleClarinServiceImpl.java index ebec91f7fd2..d4e33939928 100644 --- a/dspace-api/src/main/java/org/dspace/handle/HandleClarinServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/handle/HandleClarinServiceImpl.java @@ -268,8 +268,9 @@ public String resolveToURL(Context context, String handleStr) throws SQLExceptio if (isInternalResource(handle)) { // Internal handle // Create url for internal handle - url = configurationService.getProperty("dspace.ui.url") - + "/handle/" + handleStr; + String currentUiUrl = configurationService.getProperty("dspace.ui.url"); + url = currentUiUrl.endsWith("/") ? currentUiUrl : currentUiUrl + "/"; + url += "handle/" + handleStr; } else { // External handle url = handle.getUrl(); diff --git a/dspace-api/src/main/java/org/dspace/subscriptions/SubscriptionEmailNotificationServiceImpl.java b/dspace-api/src/main/java/org/dspace/subscriptions/SubscriptionEmailNotificationServiceImpl.java index 8fb01cd36e9..c803f1407e0 100644 --- a/dspace-api/src/main/java/org/dspace/subscriptions/SubscriptionEmailNotificationServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/subscriptions/SubscriptionEmailNotificationServiceImpl.java @@ -67,6 +67,7 @@ public SubscriptionEmailNotificationServiceImpl(Map public void perform(Context context, DSpaceRunnableHandler handler, String subscriptionType, String frequency) { List communityItems = new ArrayList<>(); List collectionsItems = new ArrayList<>(); + EPerson currentEperson = context.getCurrentUser(); try { List subscriptions = findAllSubscriptionsBySubscriptionTypeAndFrequency(context, subscriptionType, frequency); @@ -77,7 +78,10 @@ public void perform(Context context, DSpaceRunnableHandler handler, String subsc for (Subscription subscription : subscriptions) { DSpaceObject dSpaceObject = subscription.getDSpaceObject(); EPerson ePerson = subscription.getEPerson(); - + // Set the current user to the subscribed eperson because the Solr query checks + // the permissions of the current user in the ANONYMOUS group. + // If there is no user (i.e., `current user = null`), it will send an email with no new items. + context.setCurrentUser(ePerson); if (!authorizeService.authorizeActionBoolean(context, ePerson, dSpaceObject, READ, true)) { iterator++; continue; @@ -126,6 +130,8 @@ public void perform(Context context, DSpaceRunnableHandler handler, String subsc handler.handleException(e); context.abort(); } + // Reset the current user because it was changed to subscriber eperson + context.setCurrentUser(currentEperson); } @SuppressWarnings("rawtypes") diff --git a/dspace/bin/start-handle-server b/dspace/bin/start-handle-server index 6d5c9a4b440..06c4fb5d90c 100755 --- a/dspace/bin/start-handle-server +++ b/dspace/bin/start-handle-server @@ -23,9 +23,9 @@ HANDLEDIR=`$BINDIR/dspace dsprop --property handle.dir` LOGDIR=$DSPACEDIR/log #Allow user to specify java options through JAVA_OPTS variable -if [ "$JAVA_OPTS" = "" ]; then +if [ "$JAVA_OPTS_HANDLE" = "" ]; then #Default Java to use 256MB of memory - JAVA_OPTS=-Xmx256m + $JAVA_OPTS_HANDLE=-Xmx256m fi # Remove lock file, in case the old Handle server did not shut down properly @@ -34,7 +34,7 @@ rm -f $HANDLEDIR/txns/lock # Start the Handle server, with a special log4j properties file. # We cannot simply write to the same logs, since log4j # does not support more than one JVM writing to the same rolling log. -nohup java $JAVA_OPTS -classpath `$BINDIR/dspace classpath` \ +nohup java $JAVA_OPTS_HANDLE -classpath `$BINDIR/dspace classpath` \ -Ddspace.log.init.disable=true \ -Dlog4j.configuration=log4j-handle-plugin.properties \ net.handle.server.Main $HANDLEDIR \ diff --git a/dspace/config/modules/actuator.cfg b/dspace/config/modules/actuator.cfg index a14a3f1cac1..b23ccc3424b 100644 --- a/dspace/config/modules/actuator.cfg +++ b/dspace/config/modules/actuator.cfg @@ -12,7 +12,7 @@ management.endpoint.health.roles = ADMIN ## Configuration to establis management.endpoint.health.status.order= down, out-of-service, up-with-issues, up, unknown ## Configuration that enables only health and info endpoints -management.endpoints.web.exposure.include=health,info +management.endpoints.web.exposure.include=health,info,scheduledtasks ## Configuration to set 200 as status of health http response when it is DOWN or OUT_OF_SERVICE ## The DSpace UI requires these be set to 200 in order to support health status reports when services are down.