fixing what i missed last time; returning proper pretty answers
@@ -483,33 +483,27 @@ public class WorkMgr {
}
Path answerFile = answerDir.resolve(answerFilename);
if (!Files.exists(answerFile)) {
- if (pretty) {
- answer = "Not answered";
- }
- else {
Answer ans = Answer.failureAnswer("Not answered", null);
ans.setStatus(AnswerStatus.NOTFOUND);
-
+ if (pretty) {
+ ans = ans.prettyPrintAnswer();
+ }
BatfishObjectMapper mapper = new BatfishObjectMapper();
answer = mapper.writeValueAsString(ans);
}
- }
else {
boolean answerIsStale;
answerIsStale = CommonUtil.getLastModifiedTime(questionFile)
.compareTo(CommonUtil.getLastModifiedTime(answerFile)) > 0;
if (answerIsStale) {
+ Answer ans = Answer.failureAnswer("Not fresh", null);
+ ans.setStatus(AnswerStatus.STALE);
if (pretty) {
- answer = "Not fresh";
+ ans = ans.prettyPrintAnswer();
}
- else {
- Answer ans = Answer.failureAnswer("Not answered", null);
- ans.setStatus(AnswerStatus.STALE);
-
BatfishObjectMapper mapper = new BatfishObjectMapper();
answer = mapper.writeValueAsString(ans);
}
- }
else {
answer = CommonUtil.readFile(answerFile);
}
