コード例 #1
0
 @Override
 public void downloadAndValidate(BundleRequest request, BundleResponse response) {
   String gtfsDirectory =
       request.getBundleDirectory() + File.separator + _fileService.getGtfsPath();
   _log.info("gtfsDir=" + gtfsDirectory);
   List<String> files = _fileService.list(gtfsDirectory, -1);
   if (files == null || files.size() == 0) {
     response.addStatusMessage("no files found in " + gtfsDirectory);
     response.setComplete(true);
     return;
   }
   String tmpDir = request.getTmpDirectory();
   if (tmpDir == null) {
     tmpDir = new FileUtils().createTmpDirectory();
     request.setTmpDirectory(tmpDir);
   }
   response.setTmpDirectory(request.getTmpDirectory());
   for (String s3Key : files) {
     response.addStatusMessage("downloading " + s3Key);
     _log.info("downloading " + s3Key);
     String gtfsZipFileName = _fileService.get(s3Key, tmpDir);
     String outputFile = gtfsZipFileName + _gtfsValidationService.getOutputExtension();
     response.addStatusMessage("validating " + s3Key);
     _log.info("validating " + s3Key);
     if (installAndValidateGtfs(gtfsZipFileName, outputFile) != 0) {
       _log.error("Failed to successfully validate: " + gtfsZipFileName);
       response.addStatusMessage("validation failed for " + s3Key);
       continue;
     }
     _log.info("results of " + gtfsZipFileName + " at " + outputFile);
     response.addValidationFile(new FileUtils().parseFileName(outputFile));
     upload(request, response);
     response.addStatusMessage("complete");
   }
 }
コード例 #2
0
  public void upload(BundleRequest request, BundleResponse response) {
    String destDirectory =
        request.getBundleDirectory()
            + File.separator
            + BUILD_DIR
            + File.separator
            + request.getBundleBuildName()
            + File.separator
            + OUTPUT_DIR;
    String outputsPath = request.getTmpDirectory();
    response.setRemoteOutputDirectory(destDirectory);

    for (String htmlFile : response.getValidationFiles()) {
      String msg = "uploading " + htmlFile + " to " + destDirectory;
      response.addStatusMessage(msg);
      _log.info(msg);
      _fileService.put(
          destDirectory + File.separator + htmlFile, outputsPath + File.separator + htmlFile);
    }

    response.addStatusMessage("upload complete");
  }