use of org.opennms.web.notification.filter.NotificationIdListFilter in project opennms by OpenNMS.
the class WebNotificationRepositoryFilterIT method testNotificationIdListFilter.
@Test
// Relies on specific IDs so we need a fresh database
@JUnitTemporaryDatabase
public void testNotificationIdListFilter() {
int[] ids = { 1 };
NotificationIdListFilter filter = new NotificationIdListFilter(ids);
assert1Result(filter);
}
use of org.opennms.web.notification.filter.NotificationIdListFilter in project opennms by OpenNMS.
the class AcknowledgeNotificationController method handleRequestInternal.
/**
* {@inheritDoc}
*
* Acknowledge the notifications specified in the POST and then redirect the client
* to an appropriate URL for display.
*/
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
String[] required = { "notices" };
String[] noticeIdStrings = request.getParameterValues("notices");
if (noticeIdStrings == null) {
throw new MissingParameterException("notices", required);
}
String currentUser = request.getParameter("curUser");
if (currentUser == null) {
currentUser = request.getRemoteUser();
}
List<Integer> noticeIds = new ArrayList<>();
for (String noticeIdString : noticeIdStrings) {
noticeIds.add(WebSecurityUtils.safeParseInt(noticeIdString));
}
List<Filter> filters = new ArrayList<>();
filters.add(new NotificationIdListFilter(noticeIds.toArray(new Integer[0])));
NotificationCriteria criteria = new NotificationCriteria(filters.toArray(new Filter[0]));
m_webNotificationRepository.acknowledgeMatchingNotification(currentUser, new Date(), criteria);
Notification[] notices = m_webNotificationRepository.getMatchingNotifications(criteria);
request.setAttribute("notices", notices);
String redirectParms = request.getParameter("redirectParms");
String redirect = request.getParameter("redirect");
String viewName;
if (redirect != null) {
viewName = redirect;
} else {
viewName = (redirectParms == null || redirectParms == "" || redirectParms == "null" ? m_redirectView : m_redirectView + "?" + redirectParms);
}
RedirectView view = new RedirectView(viewName, true);
return new ModelAndView(view);
}
Aggregations