(no commit message)
[utils] / crawler / kiss / src / org / wamblee / crawler / kiss / Program.java
index 12f51db9e8b657689a2e08105cd3d5df62c0cfd6..f28246adf2f29528ad18bd9504a206b5a886930b 100644 (file)
@@ -17,6 +17,7 @@
 package org.wamblee.crawler.kiss;
 
 import org.wamblee.crawler.Action;
+import org.wamblee.crawler.Page;
 import org.wamblee.crawler.PageException;
 
 /**
@@ -28,6 +29,26 @@ public class Program {
      * Name of the record action on the program details page. 
      */
     private static final String RECORD_ACTION = "record";
+    
+    private static final String RESULT_ELEM = "result";
+    
+    public enum RecordingResult {
+            OK("Successfully recorded programs"), 
+            DUPLICATE("Already recorded programs"), 
+            CONFLICT("Programs in conflict with another recorded program"), 
+            OLDSHOW("Programs that occured in the past"), 
+            ERROR("Programs that could not be recorded for technical reasons");
+            
+            private String _description; 
+            
+            private RecordingResult(String aDescription) { 
+                _description = aDescription;     
+            }
+            
+            public String getDescription() { 
+                return _description; 
+            }
+    };
 
     /**
      * Indent string to use for pretty printing. 
@@ -129,13 +150,13 @@ public class Program {
      * @return True iff an attempt could be made to record the page. 
      * @throws PageException In case of problems recording the page.
      */
-    public boolean record() throws PageException {
+    public RecordingResult record() throws PageException {
         Action record = _programInfo.execute().getAction(RECORD_ACTION);
         if (record == null) {
-            return false;
+            return RecordingResult.OLDSHOW;
         }
-        record.execute();
-        return true;
+        Page result = record.execute();
+        return RecordingResult.valueOf(result.getContent().getText());    
     }
 
     /**