Search in sources :

Example 1 with FileSystemFeedBackend

use of com.conveyal.gtfs.validator.json.backends.FileSystemFeedBackend 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();
}
Also used : FileSystemFeedBackend(com.conveyal.gtfs.validator.json.backends.FileSystemFeedBackend) FeedProcessor(com.conveyal.gtfs.validator.json.FeedProcessor) GetFile(edu.usf.cutr.gtfsrtvalidator.helper.GetFile) FeedValidationResultSet(com.conveyal.gtfs.validator.json.FeedValidationResultSet) JsonSerializer(com.conveyal.gtfs.validator.json.serialization.JsonSerializer) GetFile(edu.usf.cutr.gtfsrtvalidator.helper.GetFile) MalformedURLException(java.net.MalformedURLException) SSLHandshakeException(javax.net.ssl.SSLHandshakeException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Aggregations

FeedProcessor (com.conveyal.gtfs.validator.json.FeedProcessor)1 FeedValidationResultSet (com.conveyal.gtfs.validator.json.FeedValidationResultSet)1 FileSystemFeedBackend (com.conveyal.gtfs.validator.json.backends.FileSystemFeedBackend)1 JsonSerializer (com.conveyal.gtfs.validator.json.serialization.JsonSerializer)1 GetFile (edu.usf.cutr.gtfsrtvalidator.helper.GetFile)1 MalformedURLException (java.net.MalformedURLException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 SSLHandshakeException (javax.net.ssl.SSLHandshakeException)1