bugfix 25760

This commit is contained in:
Massimiliano Assante 2023-09-29 11:32:16 +02:00
parent 2e6d0c7521
commit b86d5501fe
1 changed files with 10 additions and 3 deletions

View File

@ -1,5 +1,6 @@
package org.gcube.portal.social.networking.ws.methods.v2;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
@ -240,13 +241,15 @@ public class Notifications {
*
* @param usernameToCheck
* @return true if notification are enabled for this user
* @throws IOException
*/
private boolean isNotificationEnabled(String usernameToCheck) {
private boolean isNotificationEnabled(String usernameToCheck) throws IOException {
MemcachedClient entries = new DistributedCacheClient().getMemcachedClient();
String key = SocialUtils.DISABLED_USERS_NOTIFICATIONS_NAMESPACE+usernameToCheck;
Boolean userEnabled = false;
if(entries.get(key) == null)
userEnabled = true;
entries.getConnection().shutdown();
return userEnabled;
}
/**
@ -255,8 +258,9 @@ public class Notifications {
* @param callerId the username or clientid of the operation executor
* @param disable true if you want to disable the notifications for this user
* @return true if the operation was performed
* @throws IOException
*/
private Boolean setUserNotificationsOnOff(String username, boolean disable, String callerId) {
private Boolean setUserNotificationsOnOff(String username, boolean disable, String callerId) throws IOException {
MemcachedClient entries = new DistributedCacheClient().getMemcachedClient();
String key = SocialUtils.DISABLED_USERS_NOTIFICATIONS_NAMESPACE+username;
OperationFuture<Boolean> result = null;
@ -266,8 +270,11 @@ public class Notifications {
result = entries.delete(key);
}
try {
return result.getStatus().isSuccess();
boolean res = result.getStatus().isSuccess();
entries.getConnection().shutdown();
return res;
} catch (Exception e) {
entries.getConnection().shutdown();
e.printStackTrace();
}
return null;