use of org.xwiki.notifications.filters.NotificationFilter in project xwiki-platform by xwiki.
the class DefaultNotificationFilterManager method getFilters.
@Override
public Set<NotificationFilter> getFilters(DocumentReference user, NotificationPreference preference) throws NotificationException {
Set<NotificationFilter> filters = getAllFilters(user);
Iterator<NotificationFilter> it = filters.iterator();
while (it.hasNext()) {
NotificationFilter filter = it.next();
if (!filter.matchesPreference(preference)) {
it.remove();
}
}
return filters;
}
use of org.xwiki.notifications.filters.NotificationFilter in project xwiki-platform by xwiki.
the class DefaultNotificationFilterManager method getToggleableFilters.
@Override
public Set<NotificationFilter> getToggleableFilters(DocumentReference user) throws NotificationException {
Set<NotificationFilter> userFilters = fetchAllFilters(user);
Iterator<NotificationFilter> it = userFilters.iterator();
while (it.hasNext()) {
NotificationFilter filter = it.next();
if (!(filter instanceof ToggleableNotificationFilter)) {
it.remove();
}
}
return userFilters;
}
use of org.xwiki.notifications.filters.NotificationFilter in project xwiki-platform by xwiki.
the class DefaultNotificationFilterManager method removeDisabledFilters.
/**
* Goes through every given {@link NotificationFilter}. One of the filters implements
* {@link ToggleableNotificationFilter}, checks if the given user has disabled this filter. If so, remove the
* filter from the set.
*
* @param user the user to use
* @param filters the filters that should be examined
* @return a set of filters that are not marked as disabled by the user
* @throws NotificationException if an error occurs
*
* @since 9.7RC1
*/
private Set<NotificationFilter> removeDisabledFilters(DocumentReference user, Set<NotificationFilter> filters) throws NotificationException {
Iterator<NotificationFilter> it = filters.iterator();
Map<String, Boolean> filterActivations = modelBridge.getToggeableFilterActivations(user);
while (it.hasNext()) {
NotificationFilter filter = it.next();
if (filter instanceof ToggleableNotificationFilter && filterActivations.containsKey(filter.getName()) && !filterActivations.get(filter.getName())) {
it.remove();
}
}
return filters;
}
Aggregations