use of org.opennms.core.utils.MatchTable in project opennms by OpenNMS.
the class HttpNotificationStrategy method doSql.
private void doSql(String contents) {
if (getSql() == null) {
LOG.info("send: optional sql argument is null.");
return;
}
if (contents == null) {
LOG.info("doSql: HTTP reply is null");
return;
}
LOG.debug("send: compiling expression: {}", getSwitchValue("result-match"));
Pattern p = Pattern.compile(getSwitchValue("result-match"));
Matcher m = p.matcher(contents);
if (m.matches()) {
LOG.debug("send: compiled expression ready to run sql: {}", getSql());
MatchTable matches = new MatchTable(m);
String sqlString = PropertiesUtils.substitute(getSql(), matches);
LOG.debug("send: running sql: {}", sqlString);
JdbcTemplate template = new JdbcTemplate(DataSourceFactory.getInstance());
template.execute(sqlString);
} else {
LOG.info("send: result didn't match, not running sql");
}
}
Aggregations