Search in sources :

Example 1 with PerunNotifRegexUsedException

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

Aggregations

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