This commit is contained in:
Massimiliano Assante 2022-05-09 12:19:42 +02:00
parent c07d618220
commit 5fd457f230
1 changed files with 20 additions and 11 deletions

View File

@ -185,7 +185,7 @@ public class Notifications {
return Response.status(status).entity(responseBean).build(); return Response.status(status).entity(responseBean).build();
} }
/** /**
* Send a Catalogue notification to a given user * Send a Catalogue notification to a given user
* @param event * @param event
@ -225,8 +225,9 @@ public class Notifications {
if (! event.idsAsGroup()) { if (! event.idsAsGroup()) {
for (int i = 0; i < idsToNotify.length; i++) { for (int i = 0; i < idsToNotify.length; i++) {
String userIdToNotify = idsToNotify[i]; String userIdToNotify = idsToNotify[i];
String username2Notify = null;
try { try {
um.getUserByUsername(userIdToNotify); username2Notify = um.getUserByUsername(userIdToNotify).getUsername();
} }
catch (Exception e) { catch (Exception e) {
status = Status.NOT_ACCEPTABLE; status = Status.NOT_ACCEPTABLE;
@ -235,13 +236,20 @@ public class Notifications {
responseBean.setMessage("Username not found " + userIdToNotify); responseBean.setMessage("Username not found " + userIdToNotify);
return Response.status(status).entity(responseBean).build(); return Response.status(status).entity(responseBean).build();
} }
deliveryResult = if (username2Notify != null) {
nm.notifyCatalogueEvent( deliveryResult =
CatalogueEventTypeMapper.getType(event.getType()), nm.notifyCatalogueEvent(
userIdToNotify, CatalogueEventTypeMapper.getType(event.getType()),
event.getItemId(), username,
event.getNotifyText(), event.getItemId(),
event.getItemURL()); event.getNotifyText(),
event.getItemURL());
} else {
status = Status.NOT_ACCEPTABLE;
responseBean.setSuccess(false);
responseBean.setMessage("Username not found " + userIdToNotify);
return Response.status(status).entity(responseBean).build();
}
} }
} else { //the ids are contexts } else { //the ids are contexts
for (int i = 0; i < idsToNotify.length; i++) { for (int i = 0; i < idsToNotify.length; i++) {
@ -335,8 +343,9 @@ public class Notifications {
if (! event.idsAsGroup()) { if (! event.idsAsGroup()) {
for (int i = 0; i < idsToNotify.length; i++) { for (int i = 0; i < idsToNotify.length; i++) {
String userIdToNotify = idsToNotify[i]; String userIdToNotify = idsToNotify[i];
String username2Notify = "";
try { try {
um.getUserByUsername(userIdToNotify); username2Notify = um.getUserByUsername(userIdToNotify).getUsername();
} }
catch (Exception e) { catch (Exception e) {
status = Status.NOT_ACCEPTABLE; status = Status.NOT_ACCEPTABLE;
@ -345,7 +354,7 @@ public class Notifications {
responseBean.setMessage("Username not found " + userIdToNotify); responseBean.setMessage("Username not found " + userIdToNotify);
return Response.status(status).entity(responseBean).build(); return Response.status(status).entity(responseBean).build();
} }
deliveryResult = notifyWorkspaceEvent(event, nm, userIdToNotify); deliveryResult = notifyWorkspaceEvent(event, nm, username2Notify);
} }
} else { //the ids are contexts } else { //the ids are contexts
for (int i = 0; i < idsToNotify.length; i++) { for (int i = 0; i < idsToNotify.length; i++) {