use of org.opennms.web.servlet.XssRequestWrapper in project opennms by OpenNMS.
the class AlarmDetailController method detail.
/**
* {@inheritDoc}
*
* Display alarm detail page
*/
public ModelAndView detail(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
OnmsAlarm m_alarm = null;
XssRequestWrapper safeRequest = new XssRequestWrapper(httpServletRequest);
String alarmIdString = "";
List<OnmsAcknowledgment> acknowledgments = Collections.emptyList();
// Try to parse alarm ID as string to integer
try {
alarmIdString = safeRequest.getParameter("id");
int alarmId = Integer.parseInt(alarmIdString);
acknowledgments = m_webAlarmRepository.getAcknowledgments(alarmId);
// Get alarm by ID
m_alarm = m_webAlarmRepository.getAlarm(alarmId);
logger.debug("Alarm retrieved: '{}'", m_alarm.toString());
} catch (NumberFormatException e) {
logger.error("Could not parse alarm ID '{}' to integer.", safeRequest.getParameter("id"));
} catch (Throwable e) {
logger.error("Could not retrieve alarm from webAlarmRepository for ID='{}'", alarmIdString);
}
if (m_alarm == null) {
throw new AlarmIdNotFoundException("Could not find alarm with ID: " + alarmIdString, alarmIdString);
}
// return to view WEB-INF/jsp/alarm/detail.jsp
ModelAndView mv = new ModelAndView("alarm/detail");
mv.addObject("alarm", m_alarm);
mv.addObject("alarmId", alarmIdString);
mv.addObject("acknowledgments", acknowledgments);
return mv;
}
Aggregations