use of cz.metacentrum.perun.notif.exceptions.NotExistsException in project perun by CESNET.
the class PerunNotifTemplateManagerImpl method removePerunNotifTemplateMessage.
@Override
public void removePerunNotifTemplateMessage(int id) throws InternalErrorException {
PerunNotifTemplateMessage templateMessage = getPerunNotifTemplateMessageById(id);
if (templateMessage == null) {
throw new NotExistsException("Template message with id: " + id + " not exists.");
}
perunNotifTemplateDao.removePerunNotifTemplateMessage(id);
PerunNotifTemplate template = allTemplatesById.get(templateMessage.getTemplateId());
template.getPerunNotifTemplateMessages().remove(templateMessage);
StringTemplateLoader stringTemplateLoader = (StringTemplateLoader) configuration.getTemplateLoader();
String templateName = createTemplateName(templateMessage);
stringTemplateLoader.removeTemplate(templateName);
configuration.clearTemplateCache();
}
use of cz.metacentrum.perun.notif.exceptions.NotExistsException in project perun by CESNET.
the class PerunNotifRegexManagerImpl method createPerunNotifRegex.
@Override
public PerunNotifRegex createPerunNotifRegex(PerunNotifRegex regex) throws InternalErrorException, NotifRegexAlreadyExistsException {
// check if there is no other Notif regex with the same regular expression
for (PerunNotifRegex item : getAllPerunNotifRegexes()) {
if (item.getRegex().equals(regex.getRegex())) {
throw new NotifRegexAlreadyExistsException(regex);
}
}
PerunNotifRegex perunNotifRegex = perunNotifRegexDao.saveInternals(regex);
for (PerunNotifObject object : regex.getObjects()) {
if (object.getId() == null) {
throw new NotExistsException("Object does not exists.");
}
perunNotifObjectDao.saveObjectRelation(regex.getId(), object.getId());
}
allRegex.add(regex);
return perunNotifRegex;
}
use of cz.metacentrum.perun.notif.exceptions.NotExistsException in project perun by CESNET.
the class PerunNotifRegexManagerImpl method removePerunNotifRegexById.
@Override
public void removePerunNotifRegexById(int id) throws InternalErrorException, PerunNotifRegexUsedException {
PerunNotifRegex regex = getPerunNotifRegexById(id);
if (regex == null) {
throw new NotExistsException("Regex does not exists in db");
}
List<Integer> referencedTemplates = perunNotifRegexDao.getTemplateIdsForRegexId(id);
if (referencedTemplates != null && !referencedTemplates.isEmpty()) {
throw new PerunNotifRegexUsedException("Regex is still used.", referencedTemplates);
}
perunNotifRegexDao.removePerunNotifRegexById(id);
allRegex.remove(regex);
}
use of cz.metacentrum.perun.notif.exceptions.NotExistsException in project perun by CESNET.
the class PerunNotifObjectManagerImpl method removePerunNotifObjectById.
@Override
public void removePerunNotifObjectById(int id) throws InternalErrorException {
PerunNotifObject objectToRemove = getPerunNotifObjectById(id);
if (objectToRemove == null) {
throw new NotExistsException("Object does not exists in db.");
}
perunNotifObjectDao.removePerunNotifObjectById(id);
perunNotifRegexManager.removePerunNotifObjectFromCache(objectToRemove);
}
Aggregations