+ /**
+ * Records interesting shows.
+ *
+ * @param aProgramCondition
+ * Condition determining which shows are interesting.
+ * @param aGuide
+ * Television guide.
+ * @throws MessagingException
+ * In case of problems sending a summary mail.
+ */
+ private void processResults(List<ProgramFilter> aProgramCondition,
+ TVGuide aGuide) throws MessagingException {
+ ProgramActionExecutor executor = new ProgramActionExecutor();
+ for (ProgramFilter filter : aProgramCondition) {
+ List<Program> programs = filter.apply(aGuide);
+ ProgramAction action = filter.getAction();
+ for (Program program: programs) {
+ action.execute(program, executor);
+ }
+ }
+ executor.commit();
+ String msg = executor.getReport();
+ System.out.println(msg);
+ sendMail(msg);
+ }
+
+ /**
+ * Creates the crawler.
+ *
+ * @param aCrawlerConfig
+ * Crawler configuration file.
+ * @param aOs
+ * Logging output stream for the crawler.
+ * @param aClient
+ * HTTP Client to use.
+ * @return Crawler.
+ * @throws FileNotFoundException
+ * In case configuration files cannot be found.
+ */
+ private Crawler createCrawler(String aCrawlerConfig, PrintStream aOs,
+ HttpClient aClient) throws FileNotFoundException {
+ ConfigurationParser parser = new ConfigurationParser(aOs);
+ InputStream crawlerConfigFile = new FileInputStream(new File(
+ aCrawlerConfig));
+ Configuration config = parser.parse(crawlerConfigFile);
+ Crawler crawler = new CrawlerImpl(aClient, config);
+ return crawler;