/** * <p>toString</p> * * @param value a {@link org.opennms.netmgt.xml.event.Value} object. * @return a {@link java.lang.String} object. */ public static String toString(Value value) { return value.getType() + "(" + value.getEncoding() + "): " + value.getContent(); }
@Override public String toString() { final StringBuilder sb = new StringBuilder("SnmpTrapConfig[") .append("enterpriseId=").append(enterpriseId) .append(", generic=").append(generic) .append(", specific=").append(specific) .append(", version=").append(version) .append(", community=").append(community) .append(", hostAddress=").append(hostAddress.getHostAddress()) .append(", destinationAddress=").append(destinationAddress.getHostAddress()) .append(", destinationPort=").append(destinationPort) .append(", parameters={"); for (int i=0; i<getParameters().size(); i++) { Parm p = getParameters().get(i); sb.append(p.getParmName()).append("(").append(p.getValue().getType()).append(")='").append(p.getValue().getContent()).append("'"); if (i < getParameters().size() -1) { sb.append(", "); } } sb.append("}]"); return sb.toString(); }
/** * Checks if is valid. * * @return true, if is valid */ public boolean isValid() { if (version.isV1()) { for (Parm p : parameters) { if (p.getValue().getType().equals(VarbindType.TYPE_SNMP_COUNTER64.toString())) { return false; } } } return true; }
Value pValue = parm.getValue(); String type = pValue.getType(); String encoding = pValue.getEncoding();
insertStatement.setString(2, entry.getValue().getParmName()); insertStatement.setString(3, entry.getValue().getValue().getContent()); insertStatement.setString(4, entry.getValue().getValue().getType()); insertStatement.execute(); parameterCount++;
Value pValue = parm.getValue(); String type = pValue.getType(); String encoding = pValue.getEncoding();
private void handleParameters(Event event, List<Parm> parameters, JSONObject body) { final JSONParser jsonParser = new JSONParser(); for(Parm parm : parameters) { final String parmName = "p_" + parm.getParmName().replaceAll("\\.", "_"); // Some parameter values are of type json and should be decoded properly. // See HZN-1272 if ("json".equalsIgnoreCase(parm.getValue().getType())) { try { JSONObject tmpJson = (JSONObject) jsonParser.parse(parm.getValue().getContent()); body.put(parmName, tmpJson); } catch (ParseException ex) { LOG.error("Cannot parse parameter content '{}' of parameter '{}' from eventid {} to json: {}", parm.getValue().getContent(), parm.getParmName(), event.getDbid(), ex.getMessage(), ex); // To not lose the data, just use as is body.put(parmName, parm.getValue().getContent()); } } else { body.put(parmName, parm.getValue().getContent()); } } }
private void handleParameters(Event event, List<Parm> parameters, JSONObject body) { final JSONParser jsonParser = new JSONParser(); for(Parm parm : parameters) { final String parmName = "p_" + parm.getParmName().replaceAll("\\.", "_"); // Some parameter values are of type json and should be decoded properly. // See HZN-1272 if ("json".equalsIgnoreCase(parm.getValue().getType())) { try { JSONObject tmpJson = (JSONObject) jsonParser.parse(parm.getValue().getContent()); body.put(parmName, tmpJson); } catch (ParseException ex) { LOG.error("Cannot parse parameter content '{}' of parameter '{}' from eventid {} to json: {}", parm.getValue().getContent(), parm.getParmName(), event.getDbid(), ex.getMessage(), ex); // To not lose the data, just use as is body.put(parmName, parm.getValue().getContent()); } } else { body.put(parmName, parm.getValue().getContent()); } } }
private void handleParameters(Event event, List<Parm> parameters, JSONObject body) { final JSONParser jsonParser = new JSONParser(); for(Parm parm : parameters) { final String parmName = "p_" + parm.getParmName().replaceAll("\\.", "_"); // Some parameter values are of type json and should be decoded properly. // See HZN-1272 if ("json".equalsIgnoreCase(parm.getValue().getType())) { try { JSONObject tmpJson = (JSONObject) jsonParser.parse(parm.getValue().getContent()); body.put(parmName, tmpJson); } catch (ParseException ex) { LOG.error("Cannot parse parameter content '{}' of parameter '{}' from eventid {} to json: {}", parm.getValue().getContent(), parm.getParmName(), event.getDbid(), ex.getMessage(), ex); // To not lose the data, just use as is body.put(parmName, parm.getValue().getContent()); } } else { body.put(parmName, parm.getValue().getContent()); } } }
/** * Instantiates a new OpenNMS event parameter. * * @param parm the Event parameter object */ public OnmsEventParameter(OnmsEvent event, Parm parm) { this.event = event; name = parm.getParmName(); value = EventDatabaseConstants.escape(parm.getValue().getContent() == null ? "" : parm.getValue().getContent(), EventDatabaseConstants.NAME_VAL_DELIM); type = parm.getValue().getType(); }
/** * Adds the parameters. * * @param builder the trap builder object * @param trapConfig the trap configuration object * @throws SnmpTrapException the SNMP trap exception */ private void addParameters(SnmpTrapBuilder builder, SnmpTrapConfig trapConfig) throws SnmpTrapException { int i = 0; for (Parm parm : trapConfig.getParameters()) { try { Value value = parm.getValue(); addVarBinding(builder, parm.getParmName(), value.getType(), value.getEncoding(), value.getContent()); } catch (SnmpTrapException e) { throw new SnmpTrapException(e.getMessage() + " in event parm[" + i + "]"); } finally { i++; } } }
parm.getParmName(), parm.getValue().getContent(), parm.getValue().getType() }; update("insert into event_parameters (eventid, name, value, type) values (?, ?, ?, ?)", parmValues);
parm.getParmName(), parm.getValue().getContent(), parm.getValue().getType() }; update("insert into event_parameters (eventid, name, value, type) values (?, ?, ?, ?)", parmValues);
try { Value value = parm.getValue(); addVarBinding(trap, parm.getParmName(), value.getType(), value.getEncoding(), value.getContent()); } catch (SnmpTrapHelperException e) { throw new SnmpTrapHelperException(e.getMessage() + " in event parm[" + i + "]"); if (!(EventConstants.TYPE_SNMP_COUNTER64.equals(value.getType()))) { addVarBinding(trap, parm.getParmName(), value.getType(), value.getEncoding(), value.getContent());