Search in sources :

Example 1 with NotifRegexAlreadyExistsException

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;
}
Also used : NotExistsException(cz.metacentrum.perun.notif.exceptions.NotExistsException) PerunNotifRegex(cz.metacentrum.perun.notif.entities.PerunNotifRegex) NotifRegexAlreadyExistsException(cz.metacentrum.perun.notif.exceptions.NotifRegexAlreadyExistsException) PerunNotifObject(cz.metacentrum.perun.notif.entities.PerunNotifObject)

Aggregations

PerunNotifObject (cz.metacentrum.perun.notif.entities.PerunNotifObject)1 PerunNotifRegex (cz.metacentrum.perun.notif.entities.PerunNotifRegex)1 NotExistsException (cz.metacentrum.perun.notif.exceptions.NotExistsException)1 NotifRegexAlreadyExistsException (cz.metacentrum.perun.notif.exceptions.NotifRegexAlreadyExistsException)1