added some debug logs

This commit is contained in:
Massimiliano Assante 2022-05-03 11:02:17 +02:00
parent b69fd1270e
commit bf44c985b7
1 changed files with 11 additions and 4 deletions

View File

@ -186,20 +186,25 @@ public class Notifications {
Caller caller = AuthorizationProvider.instance.get();
String context = ScopeProvider.instance.get();
String username = caller.getClient().getId();
logger.debug("workspace notifications from user = " + username);
if (!message.getType().getNotificationClass().isInstance(message)) {
//invalid call
return Response.status(Status.BAD_REQUEST).build();
}
logger.debug("workspace notifications request is correct, handling it");
ResponseBean responseBean = new ResponseBean();
Status status = Status.OK;
try{
try {
logger.debug("workspace notifications type is " + message.getType());
SocialNetworkingSite site = SocialNetworkingSiteFinder.getSocialNetworkingSiteFromScope(context);
GCubeUser senderUser = UserManagerWSBuilder.getInstance().getUserManager().getUserByUsername(username);
SocialNetworkingUser user = new SocialNetworkingUser(senderUser.getUsername(), senderUser.getEmail(), senderUser.getFullname(), senderUser.getUserAvatarURL());
NotificationsManager nm = new ApplicationNotificationsManager(UserManagerWSBuilder.getInstance().getUserManager(), site, context, user);
NotificationsManager nm = new ApplicationNotificationsManager(UserManagerWSBuilder.getInstance().getUserManager(), site, context, user);
switch (message.getType()) {
case ITEM_NEW: {
WorkspaceNotificationAddedItem itemBean = (WorkspaceNotificationAddedItem) message;
@ -230,7 +235,9 @@ public class Notifications {
responseBean.setMessage(e.getMessage());
status = Status.INTERNAL_SERVER_ERROR;
}
logger.debug("workspace notifications should have been sent");
responseBean.setSuccess(true);
responseBean.setMessage("Workspace notification delivered correctly");
return Response.status(status).entity(responseBean).build();
}