use of com.conveyal.gtfs.validator.json.serialization.JsonSerializer in project gtfs-realtime-validator by CUTR-at-USF.
the class GtfsFeed method runStaticGTFSValidation.
private Response runStaticGTFSValidation(String saveFileName, String gtfsFeedUrl, GtfsFeedModel gtfsFeed) {
FileSystemFeedBackend backend = new FileSystemFeedBackend();
FeedValidationResultSet results = new FeedValidationResultSet();
File input = backend.getFeed(saveFileName);
FeedProcessor processor = new FeedProcessor(input);
try {
_log.info("Running static GTFS validation on " + gtfsFeedUrl + "...");
processor.run();
} catch (IOException ex) {
Logger.getLogger(GtfsFeed.class.getName()).log(Level.SEVERE, null, ex);
return generateError("Unable to access input GTFS " + input.getPath() + ".", "Does the file " + saveFileName + "exist and do I have permission to read it?", Response.Status.NOT_FOUND);
}
results.add(processor.getOutput());
saveGtfsErrorCount(gtfsFeed, processor.getOutput());
JsonSerializer serializer = new JsonSerializer(results);
// get the location of the executed jar file
GetFile jarInfo = new GetFile();
String saveDir = jarInfo.getJarLocation().getParentFile().getAbsolutePath();
saveFileName = saveDir + File.separator + jsonFilePath + File.separator + saveFileName + "_out.json";
try {
serializer.serializeToFile(new File(saveFileName));
_log.info("Static GTFS validation data written to " + saveFileName);
} catch (Exception e) {
_log.error("Exception running static GTFS validation on " + gtfsFeedUrl + ": " + e.getMessage());
}
return Response.ok(gtfsFeed).build();
}
Aggregations