use of org.opennms.web.alarm.filter.ExactUEIFilter in project opennms by OpenNMS.
the class AlarmUtil method getFilter.
/**
* <p>getFilter</p>
*
* @param filterString a {@link java.lang.String} object.
* @return a {@link org.opennms.web.filter.Filter} object.
*/
public static Filter getFilter(String filterString, ServletContext servletContext) {
if (filterString == null) {
throw new IllegalArgumentException("Cannot take null parameters.");
}
Filter filter = null;
String[] tempTokens = filterString.split("=");
String type;
String value;
try {
type = tempTokens[0];
String[] values = (String[]) ArrayUtils.remove(tempTokens, 0);
value = org.apache.commons.lang.StringUtils.join(values, "=");
} catch (NoSuchElementException e) {
throw new IllegalArgumentException("Could not tokenize filter string: " + filterString);
}
if (type.equals(SeverityFilter.TYPE)) {
filter = new SeverityFilter(OnmsSeverity.get(WebSecurityUtils.safeParseInt(value)));
} else if (type.equals(NodeFilter.TYPE)) {
filter = new NodeFilter(WebSecurityUtils.safeParseInt(value), servletContext);
} else if (type.equals(NodeNameLikeFilter.TYPE)) {
filter = new NodeNameLikeFilter(value);
} else if (type.equals(InterfaceFilter.TYPE)) {
filter = new InterfaceFilter(InetAddressUtils.addr(value));
} else if (type.equals(ServiceFilter.TYPE)) {
filter = new ServiceFilter(WebSecurityUtils.safeParseInt(value), servletContext);
} else if (type.equals(PartialUEIFilter.TYPE)) {
filter = new PartialUEIFilter(value);
} else if (type.equals(ExactUEIFilter.TYPE)) {
filter = new ExactUEIFilter(value);
} else if (type.equals(AcknowledgedByFilter.TYPE)) {
filter = new AcknowledgedByFilter(value);
} else if (type.equals(NegativeSeverityFilter.TYPE)) {
filter = new NegativeSeverityFilter(OnmsSeverity.get(WebSecurityUtils.safeParseInt(value)));
} else if (type.equals(NegativeNodeFilter.TYPE)) {
filter = new NegativeNodeFilter(WebSecurityUtils.safeParseInt(value), servletContext);
} else if (type.equals(NegativeInterfaceFilter.TYPE)) {
filter = new NegativeInterfaceFilter(InetAddressUtils.addr(value));
} else if (type.equals(NegativeServiceFilter.TYPE)) {
filter = new NegativeServiceFilter(WebSecurityUtils.safeParseInt(value), servletContext);
} else if (type.equals(NegativePartialUEIFilter.TYPE)) {
filter = new NegativePartialUEIFilter(value);
} else if (type.equals(NegativeExactUEIFilter.TYPE)) {
filter = new NegativeExactUEIFilter(value);
} else if (type.equals(NegativeAcknowledgedByFilter.TYPE)) {
filter = new NegativeAcknowledgedByFilter(value);
} else if (type.equals(IPAddrLikeFilter.TYPE)) {
filter = new IPAddrLikeFilter(value);
} else if (type.equals(LogMessageSubstringFilter.TYPE)) {
filter = new LogMessageSubstringFilter(value);
} else if (type.equals(LogMessageMatchesAnyFilter.TYPE)) {
filter = new LogMessageMatchesAnyFilter(value);
} else if (type.equals(BeforeLastEventTimeFilter.TYPE)) {
filter = new BeforeLastEventTimeFilter(WebSecurityUtils.safeParseLong(value));
} else if (type.equals(BeforeFirstEventTimeFilter.TYPE)) {
filter = new BeforeFirstEventTimeFilter(WebSecurityUtils.safeParseLong(value));
} else if (type.equals(AfterLastEventTimeFilter.TYPE)) {
filter = new AfterLastEventTimeFilter(WebSecurityUtils.safeParseLong(value));
} else if (type.equals(AfterFirstEventTimeFilter.TYPE)) {
filter = new AfterFirstEventTimeFilter(WebSecurityUtils.safeParseLong(value));
} else if (type.equals(EventParmLikeFilter.TYPE)) {
filter = new EventParmLikeFilter(value);
} else if (type.equals(NegativeEventParmLikeFilter.TYPE)) {
filter = new NegativeEventParmLikeFilter(value);
} else if (type.equals(LocationFilter.TYPE)) {
filter = new LocationFilter(value);
} else if (type.equals(NegativeLocationFilter.TYPE)) {
filter = new NegativeLocationFilter(value);
} else if (type.equals(NodeLocationFilter.TYPE)) {
filter = new NodeLocationFilter(value);
} else if (type.equals(NegativeNodeLocationFilter.TYPE)) {
filter = new NegativeNodeLocationFilter(value);
}
return filter;
}
Aggregations