(no commit message)
[utils] / crawler / kiss / src / org / wamblee / crawler / kiss / main / ProgramConfigurationParser.java
index 103ec0702c6caea299ca6583e265797c6e7cc8ee..2e22f351baca0ac126d5f5afbf288f54c956fa01 100644 (file)
@@ -33,16 +33,15 @@ import org.wamblee.crawler.kiss.guide.Program;
 import org.wamblee.crawler.kiss.notification.MailNotifier;
 import org.wamblee.crawler.kiss.notification.MailServer;
 import org.wamblee.crawler.kiss.notification.Notifier;
+import org.wamblee.xml.XslTransformer;
 
 /**
  * Parse the configuration of desired programs.
  */
 class ProgramConfigurationParser {
-
-    /**
-     * 
-     */
     private static final int DEFAULT_SMTP_PORT = 25;
+    
+    private static final int DEFAULT_PRIORITY = 1; 
 
     private static final String ELEM_PASSWORD = "password";
 
@@ -74,6 +73,8 @@ class ProgramConfigurationParser {
     // Configuration of interesting programs.
 
     private static final String ELEM_PROGRAM = "program";
+    
+    private static final String ELEM_PRIORITY = "priority";
 
     private static final String ELEM_PATTERN = "match";
 
@@ -84,12 +85,15 @@ class ProgramConfigurationParser {
     private static final String ACTION_NOTIFY = "notify";
 
     private List<ProgramFilter> _filters;
+    
+    private XslTransformer _transformer;
 
     private Notifier _notifier;
 
-    ProgramConfigurationParser() {
+    ProgramConfigurationParser(XslTransformer aTransformer) {
         _filters = null;
         _notifier = null;
+        _transformer = aTransformer;
     }
 
     /**
@@ -117,7 +121,12 @@ class ProgramConfigurationParser {
                 }
 
                 Element actionElem = program.element(ELEM_ACTION);
-                ProgramAction action = new RecordProgramAction(1);
+                int priority = DEFAULT_PRIORITY; 
+                String priorityString = program.elementTextTrim(ELEM_PRIORITY);
+                if ( priorityString != null ) { 
+                    priority = Integer.valueOf(priorityString);
+                }
+                ProgramAction action = new RecordProgramAction(priority);
                 if (actionElem != null) {
                     if (actionElem.getText().equals(ACTION_NOTIFY)) {
                         action = new InterestingProgramAction(category);
@@ -168,7 +177,7 @@ class ProgramConfigurationParser {
         String htmlXslt = format.elementTextTrim(ELEM_HTML);
         String textXslt = format.elementTextTrim(ELEM_TEXT);
 
-        return new MailNotifier(from, to, subject, htmlXslt, textXslt, server);
+        return new MailNotifier(from, to, subject, htmlXslt, textXslt, server, _transformer);
     }
 
     /**
@@ -188,8 +197,7 @@ class ProgramConfigurationParser {
         String username = aSmtp.elementTextTrim(ELEM_USERNAME);
         String password = aSmtp.elementTextTrim(ELEM_PASSWORD);
 
-        MailServer server = new MailServer(host, port, username, password);
-        return server;
+        return new MailServer(host, port, username, password);
     }
 
     /**