if (isGet(e) && isAdmin(loggedInUser)) { // Get account for current user
List<AlertRecipient> alertRecipientList = getAdministrationService().getAlertRecipients(loggedInUser.getAccountName());
JsonArray alertArray = new JsonArray();
for (AlertRecipient ar : alertRecipientList) {
BasicAlertRecipient basicAr = new BasicAlertRecipient(ar);
alertArray.add(new Gson().toJsonTree(basicAr, BasicAlertRecipient.class));
}
JsonObject alertPlugins = new JsonObject();
alertPlugins.add("alertRecipients", alertArray);
jsonResponse = alertPlugins.toString();
} else if ((isPost(e) || isPut(e)) && isAdmin(loggedInUser)) {
AlertRecipientModel alertRecipientModel = new Gson().fromJson(messageContent, AlertRecipientModel.class);
BasicAlertRecipient alertRecipient = alertRecipientModel.getAlertRecipient();
if (id != null) {
alertRecipient.setId(id);
}
alertRecipient.setAccountName(loggedInUser.getAccountName());
logger.info("Persisting Alert Recipient: " + new Gson().toJson(alertRecipient));
getAdministrationService().persistAlertRecipient(alertRecipient);