From 0e3a2ec80a5bb09c3373afe97f7640159f2eb8dc Mon Sep 17 00:00:00 2001 From: Adam Miller Date: Mon, 4 Mar 2013 16:34:18 -0800 Subject: [PATCH] CrawlJobModel.java Adding check for application context --- .../crawler/restlet/models/CrawlJobModel.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/engine/src/main/java/org/archive/crawler/restlet/models/CrawlJobModel.java b/engine/src/main/java/org/archive/crawler/restlet/models/CrawlJobModel.java index 851b1f36..a91cb786 100644 --- a/engine/src/main/java/org/archive/crawler/restlet/models/CrawlJobModel.java +++ b/engine/src/main/java/org/archive/crawler/restlet/models/CrawlJobModel.java @@ -126,8 +126,10 @@ public class CrawlJobModel extends HashMap implements Serializab } } this.put("checkpointFiles",checkpointFiles); - this.put("alertLogFilePath",crawlJob.getCrawlController().getLoggerModule().getAlertsLogPath().getFile().getAbsolutePath()); - this.put("crawlLogFilePath",crawlJob.getCrawlController().getLoggerModule().getCrawlLogPath().getFile().getAbsolutePath()); + if (crawlJob.hasApplicationContext()) + this.put("alertLogFilePath",crawlJob.getCrawlController().getLoggerModule().getAlertsLogPath().getFile().getAbsolutePath()); + if(crawlJob.isRunning() || (crawlJob.hasApplicationContext() && !crawlJob.isLaunchable())) + this.put("crawlLogFilePath",crawlJob.getCrawlController().getLoggerModule().getCrawlLogPath().getFile().getAbsolutePath()); this.put("reports", generateReports()); } public String formatBytes(Long bytes){ @@ -178,13 +180,15 @@ public class CrawlJobModel extends HashMap implements Serializab } public List> generateReports(){ List> reports = new ArrayList>(); - for (Report report : crawlJob.getCrawlController().getStatisticsTracker().getReports()) { - if (report.getShouldReportDuringCrawl()) { - Map reportMap = new HashMap(); - String className = report.getClass().getSimpleName(); - reportMap.put("className", className); - reportMap.put("shortName",className.substring(0,className.length() - "Report".length())); - reports.add(reportMap); + if(crawlJob.hasApplicationContext()){ + for (Report report : crawlJob.getCrawlController().getStatisticsTracker().getReports()) { + if (report.getShouldReportDuringCrawl()) { + Map reportMap = new HashMap(); + String className = report.getClass().getSimpleName(); + reportMap.put("className", className); + reportMap.put("shortName",className.substring(0,className.length() - "Report".length())); + reports.add(reportMap); + } } } return reports;