@Override public void deleteContact(MailingList mailingList, String contactUuid) throws BusinessException { MailingListContact contactToDelete = findContact(contactUuid); mailingList.deleteMailingListContact(contactToDelete); listRepository.update(mailingList); contactRepository.delete(contactToDelete); }
@Override public void addContact(MailingList mailingList, MailingListContact contact) throws BusinessException { if (!mailingList.getMailingListContact().contains(contact)) { mailingList.addMailingListContact(contact); contactRepository.create(contact); listRepository.update(mailingList); } else { logger.debug("Concact already present : " + contact.getMail()); } }
@Override public void updateList(MailingList updatedMailingList) throws BusinessException { MailingList entity = findByUuid(updatedMailingList.getUuid()); String newIdentifier = updatedMailingList.getIdentifier(); if (!entity.getIdentifier().equals(newIdentifier)) { // The identifier was changed. // check if new list identifier is unique (do not already exist) if (listRepository.findByIdentifier(entity.getOwner(), newIdentifier) != null) { String msg = "Update failed : current list identifier already exists : " + newIdentifier; logger.error(msg); throw new BusinessException(BusinessErrorCode.LIST_ALDREADY_EXISTS, msg); } } entity.setIdentifier(newIdentifier); entity.setDescription(updatedMailingList.getDescription()); entity.setPublic(updatedMailingList.isPublic()); if (updatedMailingList.getDomain() != null) entity.setDomain(updatedMailingList.getDomain()); if (updatedMailingList.getOwner() != null) entity.setOwner(updatedMailingList.getOwner()); listRepository.update(entity); }