X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=crawler%2Fkiss%2Fsrc%2Forg%2Fwamblee%2Fcrawler%2Fkiss%2FProgramConfigurationParser.java;h=e9ba272e3ec33fe25497c6637d87974af91075f8;hb=8baad2389febcbcd9132fbb62e6329247275a000;hp=b8d5c67863adcd9406c3bae2fc76d6f11f86b829;hpb=c78140d07025961d92a4635b6e30f4bf66725746;p=utils diff --git a/crawler/kiss/src/org/wamblee/crawler/kiss/ProgramConfigurationParser.java b/crawler/kiss/src/org/wamblee/crawler/kiss/ProgramConfigurationParser.java index b8d5c678..e9ba272e 100644 --- a/crawler/kiss/src/org/wamblee/crawler/kiss/ProgramConfigurationParser.java +++ b/crawler/kiss/src/org/wamblee/crawler/kiss/ProgramConfigurationParser.java @@ -29,7 +29,6 @@ import org.dom4j.io.SAXReader; import org.wamblee.conditions.AndCondition; import org.wamblee.conditions.Condition; import org.wamblee.conditions.PropertyRegexCondition; -import org.wamblee.crawler.kiss.ProgramFilter.ProgramAction; /** * Parse the configuration of desired programs. @@ -41,6 +40,8 @@ class ProgramConfigurationParser { private static final String ELEM_PATTERN = "match"; private static final String ELEM_ACTION = "action"; + + private static final String ELEM_CATEGORY = "category"; private static final String ACTION_NOTIFY = "notify"; @@ -62,13 +63,20 @@ class ProgramConfigurationParser { for (Iterator i = root.elementIterator(ELEM_PROGRAM); i.hasNext();) { Element program = (Element) i.next(); + Element categoryElem = program.element(ELEM_CATEGORY); + String category = ""; + if ( categoryElem != null ) { + category = categoryElem.getText().trim(); + } + Element actionElem = program.element(ELEM_ACTION); - ProgramAction action = ProgramAction.RECORD; + ProgramAction action = new RecordProgramAction(); if (actionElem != null) { if (actionElem.getText().equals(ACTION_NOTIFY)) { - action = ProgramAction.NOTIFY; + action = new InterestingProgramAction(category); } } + List> regexConditions = new ArrayList>(); for (Iterator j = program.elementIterator(ELEM_PATTERN); j.hasNext(); ) { @@ -78,8 +86,8 @@ class ProgramConfigurationParser { if ( fieldAttribute != null ) { fieldName = fieldAttribute.getText(); } - String pattern = ".*" + patternElem.getText() - + ".*"; + String pattern = ".*(" + patternElem.getText() + + ").*"; regexConditions.add(new PropertyRegexCondition(fieldName, pattern, true)); } Condition condition = new AndCondition(regexConditions);