use of org.apache.syncope.core.persistence.api.entity.Entity in project syncope by apache.
the class MailTemplateLogic method delete.
@PreAuthorize("hasRole('" + StandardEntitlement.MAIL_TEMPLATE_DELETE + "')")
public MailTemplateTO delete(final String key) {
MailTemplate mailTemplate = mailTemplateDAO.find(key);
if (mailTemplate == null) {
LOG.error("Could not find mail template '" + key + "'");
throw new NotFoundException(key);
}
List<Notification> notifications = notificationDAO.findByTemplate(mailTemplate);
if (!notifications.isEmpty()) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InUse);
sce.getElements().addAll(notifications.stream().map(Entity::getKey).collect(Collectors.toList()));
throw sce;
}
MailTemplateTO deleted = getMailTemplateTO(key);
mailTemplateDAO.delete(key);
return deleted;
}
use of org.apache.syncope.core.persistence.api.entity.Entity in project syncope by apache.
the class JPAConnInstanceDAO method delete.
@Override
public void delete(final String key) {
ConnInstance connInstance = find(key);
if (connInstance == null) {
return;
}
connInstance.getResources().stream().map(Entity::getKey).collect(Collectors.toList()).forEach(resource -> resourceDAO.delete(resource));
connInstanceHistoryConfDAO.deleteByEntity(connInstance);
entityManager().remove(connInstance);
connRegistry.unregisterConnector(key);
}
Aggregations