use of cz.metacentrum.perun.notif.entities.PerunNotifObject in project perun by CESNET.
the class PerunNotifRegexManagerImpl method getIdsOfRegexesMatchingMessage.
@Override
public Set<Integer> getIdsOfRegexesMatchingMessage(PerunNotifAuditMessage auditMessage) throws InternalErrorException {
Set<PerunNotifObject> setOfObjects = new HashSet<PerunNotifObject>();
for (PerunBean bean : auditMessage.getPerunBeanList()) {
for (PerunNotifObject object : allObjects) {
if (object.getObjectClass() != null) {
if (bean.getClass().isAssignableFrom(object.getObjectClass())) {
setOfObjects.add(object);
}
}
}
}
Set<Integer> result = new HashSet<Integer>();
for (PerunNotifRegex regex : allRegex) {
if (auditMessage.getMessage().matches(regex.getRegex())) {
//We test whether message has all objects
boolean matches = true;
for (PerunNotifObject object : regex.getObjects()) {
if (!setOfObjects.contains(object)) {
matches = false;
}
}
if (matches) {
result.add(regex.getId());
}
}
}
return result;
}
use of cz.metacentrum.perun.notif.entities.PerunNotifObject in project perun by CESNET.
the class PerunNotifRegexManagerImpl method removePerunNotifObjectFromCache.
@Override
public void removePerunNotifObjectFromCache(PerunNotifObject objectToRemove) {
boolean removed = false;
for (Iterator<PerunNotifObject> iter = allObjects.iterator(); iter.hasNext(); ) {
PerunNotifObject objectFromCache = iter.next();
if (objectFromCache.getId().equals(objectToRemove.getId())) {
iter.remove();
removed = true;
}
}
if (!removed) {
logger.warn("Remove of object from cache failed. Object is not in cache. ID: {}", objectToRemove.getId());
}
for (PerunNotifRegex regex : allRegex) {
Set<PerunNotifObject> regexObjects = regex.getObjects();
if (regexObjects.contains(objectToRemove)) {
regexObjects.remove(objectToRemove);
}
}
}
Aggregations