use of org.opennms.netmgt.config.ThresholdingConfigFactory in project opennms by OpenNMS.
the class ThresholdController method gotoEditThreshold.
private ModelAndView gotoEditThreshold(String thresholdIndexString, String groupName) throws ServletException {
ThresholdingConfigFactory configFactory = ThresholdingConfigFactory.getInstance();
ModelAndView modelAndView;
if (thresholdIndexString == null) {
throw new ServletException("thresholdIndex parameter required to edit a threshold");
}
int thresholdIndex = WebSecurityUtils.safeParseInt(thresholdIndexString);
Threshold threshold = configFactory.getGroup(groupName).getThresholds().get(thresholdIndex);
modelAndView = new ModelAndView("admin/thresholds/editThreshold");
modelAndView.addObject("threshold", threshold);
modelAndView.addObject("thresholdIndex", thresholdIndex);
modelAndView.addObject("groupName", groupName);
modelAndView.addObject("isNew", false);
addStandardEditingBits(modelAndView);
return modelAndView;
}
use of org.opennms.netmgt.config.ThresholdingConfigFactory in project opennms by OpenNMS.
the class ThresholdController method saveChanges.
private void saveChanges() throws ServletException {
ThresholdingConfigFactory configFactory = ThresholdingConfigFactory.getInstance();
try {
configFactory.saveCurrent();
EventBuilder ebldr = createEventBuilder(EventConstants.RELOAD_DAEMON_CONFIG_UEI);
ebldr.addParam(EventConstants.PARM_DAEMON_NAME, "Threshd");
ebldr.addParam(EventConstants.PARM_CONFIG_FILE_NAME, "thresholds.xml");
sendNotifEvent(ebldr.getEvent());
} catch (Throwable e) {
throw new ServletException("Could not save the changes to the threshold because " + e.getMessage(), e);
}
if (eventConfChanged) {
try {
m_eventConfDao.saveCurrent();
sendNotifEvent(createEventBuilder(EventConstants.EVENTSCONFIG_CHANGED_EVENT_UEI).getEvent());
} catch (Throwable e) {
throw new ServletException("Could not save the changes to the event configuration because " + e.getMessage(), e);
}
eventConfChanged = false;
}
}
use of org.opennms.netmgt.config.ThresholdingConfigFactory in project opennms by OpenNMS.
the class ThresholdController method gotoEditExpression.
private ModelAndView gotoEditExpression(String expressionIndexString, String groupName) throws ServletException {
ThresholdingConfigFactory configFactory = ThresholdingConfigFactory.getInstance();
ModelAndView modelAndView;
if (expressionIndexString == null) {
throw new ServletException("expressionIndex parameter required to edit a threshold");
}
int expressionIndex = WebSecurityUtils.safeParseInt(expressionIndexString);
Expression expression = configFactory.getGroup(groupName).getExpressions().get(expressionIndex);
modelAndView = new ModelAndView("admin/thresholds/editExpression");
modelAndView.addObject("expression", expression);
modelAndView.addObject("expressionIndex", expressionIndex);
modelAndView.addObject("groupName", groupName);
modelAndView.addObject("isNew", false);
addStandardEditingBits(modelAndView);
return modelAndView;
}
use of org.opennms.netmgt.config.ThresholdingConfigFactory in project opennms by OpenNMS.
the class LatencyThresholdingSetIT method initFactories.
private void initFactories(String threshd, String thresholds) throws Exception {
LOG.info("Initialize Threshold Factories");
ThresholdingConfigFactory.setInstance(new ThresholdingConfigFactory(getClass().getResourceAsStream(thresholds)));
ThreshdConfigFactory.setInstance(new ThreshdConfigFactory(getClass().getResourceAsStream(threshd), "127.0.0.1", false));
}
use of org.opennms.netmgt.config.ThresholdingConfigFactory in project opennms by OpenNMS.
the class ThresholdController method finishThresholdEdit.
private ModelAndView finishThresholdEdit(HttpServletRequest request) throws ServletException {
ThresholdingConfigFactory configFactory = ThresholdingConfigFactory.getInstance();
ModelAndView modelAndView;
String groupName = request.getParameter("groupName");
String submitAction = request.getParameter("submitAction");
Group group = configFactory.getGroup(groupName);
String thresholdIndexString = request.getParameter("thresholdIndex");
if (thresholdIndexString == null) {
throw new ServletException("thresholdIndex parameter required to modify or delete a threshold");
}
int thresholdIndex = WebSecurityUtils.safeParseInt(thresholdIndexString);
// TODO: NMS-4249, maybe a try/catch and add default on exception?
Threshold threshold = group.getThresholds().get(thresholdIndex);
if (SAVE_BUTTON_TITLE.equals(submitAction)) {
this.commonFinishEdit(request, threshold);
final String dsName = request.getParameter("dsName");
final String filterOperator = request.getParameter("filterOperator");
if (dsName == null || dsName.equals("")) {
throw new ServletException("ds-name cannot be null or empty string");
}
threshold.setDsName(dsName);
threshold.setFilterOperator(filterOperator == null ? null : FilterOperator.valueOf(filterOperator.toUpperCase()));
saveChanges();
} else if (CANCEL_BUTTON_TITLE.equals(submitAction)) {
String isNew = request.getParameter("isNew");
if ("true".equals(isNew)) {
// It was a new Threshold, but the user hit cancel. Remove the new threshold from the group
group.removeThreshold(threshold);
} else {
List<ResourceFilter> filters = getFilterList(request, false);
if (filters != null) {
threshold.setResourceFilters(filters);
}
}
} else {
return finishThresholdFilterEdit(request, threshold);
}
// Remove Filters from Session
setFilterList(request, null);
// and got back to the editGroup page
modelAndView = new ModelAndView("admin/thresholds/editGroup");
modelAndView.addObject("group", group);
return modelAndView;
}
Aggregations