X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=crawler%2Fkiss%2Fsrc%2Forg%2Fwamblee%2Fcrawler%2Fkiss%2FProgram.java;h=f28246adf2f29528ad18bd9504a206b5a886930b;hb=a6b29131270e75d919043cb21b7df42f05653547;hp=12f51db9e8b657689a2e08105cd3d5df62c0cfd6;hpb=9d2a49c65872cd9330670a3cace19faf493df04d;p=utils diff --git a/crawler/kiss/src/org/wamblee/crawler/kiss/Program.java b/crawler/kiss/src/org/wamblee/crawler/kiss/Program.java index 12f51db9..f28246ad 100644 --- a/crawler/kiss/src/org/wamblee/crawler/kiss/Program.java +++ b/crawler/kiss/src/org/wamblee/crawler/kiss/Program.java @@ -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()); } /**