/** * Apply the filters to a replication event (at transaction). * * <p>The returned list of TransactionMatchResult objects should be walked and any messages from * each match result should be handled appropriately. * * @param event The Event to apply the filters to. * @return A list of TransactionMatchResult objects. */ public List<TransactionMatchResultAccumulator> apply(ReplDBMSEvent event) { List<TransactionMatchResultAccumulator> results = new ArrayList<TransactionMatchResultAccumulator>(); for (TransactionFilter tf : this.transaction_filters) { results.add(tf.match(event)); } return results; }
/** * Load the filter rules from a JSON-formatted string. * * @param rules_json JSON formatted string of the filter rules. * @throws PKPublishFilterException * @throws IOException * @throws JsonFilterException * @throws JsonProcessingException */ public void loadRules(String rules_json) throws IOException, JsonFilterException { try { JsonNode rules_jn = new ObjectMapper().readTree(rules_json); confirmNodeType(rules_jn, JsonNodeType.OBJECT, "TransactionRules", logger); JsonNode transaction_filters_jn = fetchChildByName(rules_jn, "transaction_filters", "array"); for (JsonNode tfilter_jn : transaction_filters_jn) { confirmNodeType(tfilter_jn, JsonNodeType.OBJECT, "TransactionFilter", logger); TransactionFilter tfilter = TransactionFilter.newFromJson(tfilter_jn); this.transaction_filters.add(tfilter); logger.debug("Added Transaction filter"); } } catch (JsonProcessingException e) { throw new JsonFilterException(e); } }