public boolean sendNotifications(List<Invitation> invitations) {
boolean success = false;
if (!CollectionUtils.isEmpty(invitations)) {
User fromUser = userService.getUserFromSecurityContext();
Long fromUserId = fromUser != null ? fromUser.getId() : null;
Map<String, List<Invitation>> map = new HashMap<String, List<Invitation>>();
for (Invitation invitation : invitations) {
String key = StringUtils.trimAllWhitespace(invitation.getEmail()).toLowerCase();
if (map.get(key) == null) {
map.put(key, new ArrayList<Invitation>());
}
map.get(key).add(invitation);
}
for (String key : map.keySet()) {
User invitee = userService.getByEmail(key);
List<Invitation> invitationList = map.get(key);
Set<Long> invitationIds = new HashSet<Long>();
for (Invitation invitation : invitationList) {
if (invitee != null) {
userService.addUserToDomain(invitee, invitation.getDomain(), invitation.getRole().getUserRole());