use of cz.metacentrum.perun.notif.exceptions.NotifRegexAlreadyExistsException 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;
}
Aggregations