This commit is contained in:
Massimiliano Assante 2022-09-16 12:33:04 +02:00
parent 944d14aaa0
commit 87c06555ca
2 changed files with 68 additions and 6 deletions

View File

@ -0,0 +1,64 @@
package org.gcube.portal.social.networking.ws.inputs;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
*
*
*/
public class UserSetNotificationBean {
@JsonProperty("username")
@NotNull(message="username cannot be null")
@Size(message="username cannot be empty", min=1)
private String username;
@JsonProperty("disableNotification")
@NotNull(message="disableNotification cannot be null")
@Size(message="disableNotification cannot be empty", min=1)
private boolean disableNotification;
public UserSetNotificationBean() {
super();
}
/**
* @param username
* @param disableNotification
*/
public UserSetNotificationBean(String username, boolean disableNotification) {
super();
this.username = username;
this.disableNotification = disableNotification;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public boolean isDisableNotification() {
return disableNotification;
}
public void setDisableNotification(boolean disableNotification) {
this.disableNotification = disableNotification;
}
@Override
public String toString() {
return "UserSetNotificationBean [username=" + username + ", disableNotification=" + disableNotification + "]";
}
}

View File

@ -47,6 +47,7 @@ import org.gcube.portal.social.networking.liferay.ws.GroupManagerWSBuilder;
import org.gcube.portal.social.networking.liferay.ws.LiferayJSONWsCredentials;
import org.gcube.portal.social.networking.liferay.ws.UserManagerWSBuilder;
import org.gcube.portal.social.networking.ws.ex.AuthException;
import org.gcube.portal.social.networking.ws.inputs.UserSetNotificationBean;
import org.gcube.portal.social.networking.ws.mappers.CatalogueEventTypeMapper;
import org.gcube.portal.social.networking.ws.mappers.JobMapper;
import org.gcube.portal.social.networking.ws.mappers.WorkspaceItemMapper;
@ -200,12 +201,9 @@ public class Notifications {
})
@AuthorizationControl(allowedRoles={INFRASTRUCTURE_MANAGER_ROLE}, exception=AuthException.class)
public Response setUserNotifications(
@NotNull(message="username cannot be null")
@JsonProperty("username")
String username,
@NotNull(message="must specify the disable parameter")
@JsonProperty("disable")
boolean disable) throws ValidationException{
@NotNull(message="input is missing")
@Valid
UserSetNotificationBean setting) throws ValidationException{
Caller caller = AuthorizationProvider.instance.get();
String context = ScopeProvider.instance.get();