diff --git a/src/main/java/org/gcube/portal/social/networking/ws/methods/v2/Notifications.java b/src/main/java/org/gcube/portal/social/networking/ws/methods/v2/Notifications.java index d8ea78a..33c4682 100644 --- a/src/main/java/org/gcube/portal/social/networking/ws/methods/v2/Notifications.java +++ b/src/main/java/org/gcube/portal/social/networking/ws/methods/v2/Notifications.java @@ -149,10 +149,8 @@ public class Notifications { @Produces(MediaType.APPLICATION_JSON) /** * Return whether the notifications for this user are enabled or not - * @param from must be greater or equal to 1, range[0, infinity] - * @param quantity quantity must be greater or equal to 0 - * @return notifications up to quantity - * @throws ValidationException + * @param username the username you want to check + * @return true if the notification for the user are disabled (Catalogue and Workspace ones) */ @StatusCodes ({ @ResponseCode ( code = 200, condition = "Users with silenced notifications are reported in the 'result' field of the returned object"), @@ -160,15 +158,15 @@ public class Notifications { }) @AuthorizationControl(allowedRoles={INFRASTRUCTURE_MANAGER_ROLE}, exception=AuthException.class) public Response isUserDisabled( - @QueryParam("usernameToCheck") @NotNull(message="username cannot be null") @Size(min=2, message="username cannot be empty") - String usernameToCheck) throws ValidationException{ + @QueryParam("username") @NotNull(message="username cannot be null") @Size(min=2, message="username cannot be empty") + String username) throws ValidationException{ ResponseBean responseBean = new ResponseBean(); Status status = Status.OK; try{ - Boolean userDisabled= !isNotificationEnabled(usernameToCheck); + Boolean userDisabled= !isNotificationEnabled(username); responseBean.setResult(userDisabled); responseBean.setSuccess(true); - logger.debug("are User " + usernameToCheck + " Notifications Disabled?"+userDisabled); + logger.debug("are User " + username + " Notifications Disabled?"+userDisabled); }catch(Exception e){ logger.error("Unable to read whether the notifications for this user are enabled or not.", e); responseBean.setMessage(e.getMessage()); @@ -209,10 +207,10 @@ public class Notifications { try{ String opExecutor = caller.getClient().getId(); Boolean result = setUserNotificationsOnOff(username, disable, opExecutor); - String toReturn = "Notifications have been set "; + String toReturn = "Notifications have been set"; if (result) { - toReturn += disable ? " Off ": " On "; - toReturn += "for " + username; + toReturn += disable ? " OFF ": " ON "; + toReturn += "for username=" + username; } responseBean.setSuccess(true); responseBean.setResult(toReturn); @@ -258,8 +256,8 @@ public class Notifications { result = entries.delete(username); } try { - return result.get(); - } catch (InterruptedException | ExecutionException e) { + return result.getStatus().isSuccess(); + } catch (Exception e) { e.printStackTrace(); } return null;