use of org.onebusaway.admin.util.NYCFileUtils in project onebusaway-application-modules by camsys.
the class BundleValidationServiceImpl method downloadFeedValidator.
public synchronized void downloadFeedValidator() {
String tmpDir = System.getProperty("java.io.tmpdir");
String localFile = tmpDir + File.separatorChar + TRANSIT_FEED + ".tar.gz";
if (new File(localFile).exists()) {
_log.error("feed Validator found at " + localFile + ", exiting");
_log.error("remove the file at " + localFile + " if it is corrupt");
return;
}
NYCFileUtils fs = new NYCFileUtils(tmpDir);
String url = "http://developer.onebusaway.org/tmp/" + TRANSIT_FEED + ".tar.gz";
fs.wget(url);
fs.tarzxf(localFile);
}
use of org.onebusaway.admin.util.NYCFileUtils in project onebusaway-application-modules by camsys.
the class DirectoryBundleDeployerImpl method setup.
@PostConstruct
public void setup() {
_fileUtil = new FileUtility();
_nycFileUtils = new NYCFileUtils();
}
use of org.onebusaway.admin.util.NYCFileUtils in project onebusaway-application-modules by camsys.
the class BaseModTask method cleanup.
private String cleanup(GtfsBundle gtfsBundle) throws Exception {
File gtfsFile = gtfsBundle.getPath();
FileUtility fu = new FileUtility();
NYCFileUtils fs = new NYCFileUtils();
_log.info("gtfsBundle.getPath=" + gtfsFile.getPath());
String oldGtfsName = gtfsFile.getPath().toString();
// delete the old zip file
_log.info("deleting " + gtfsFile.getPath());
gtfsFile.delete();
// create a new zip file
String newGtfsName = fs.parseDirectory(oldGtfsName) + File.separator + fs.parseFileNameMinusExtension(oldGtfsName) + "_mod.zip";
String basePath = fs.parseDirectory(oldGtfsName);
String includeExpression = ".*\\.txt";
fu.zip(newGtfsName, basePath, includeExpression);
int deletedFiles = fu.deleteFilesInFolder(basePath, includeExpression);
if (deletedFiles < 1) {
throw new IllegalStateException("Missing expected modded gtfs files in directory " + basePath);
}
gtfsBundle.setPath(new File(newGtfsName));
_log.info("gtfsBundle.getPath(mod)=" + gtfsBundle.getPath() + " with mappings= " + gtfsBundle.getAgencyIdMappings());
if (getOutputDirectory() != null) {
File outputDir = new File(getOutputDirectory() + File.separator + getDirectoryHint());
if (!outputDir.exists() || !outputDir.isDirectory()) {
outputDir.mkdirs();
}
String outputLocation = getOutputDirectory() + File.separator + getDirectoryHint() + File.separator + fs.parseFileName(newGtfsName).replaceAll("_mod", "");
// copy to outputs for downstream systems
NYCFileUtils.copyFile(new File(newGtfsName), new File(outputLocation));
}
return newGtfsName;
}
use of org.onebusaway.admin.util.NYCFileUtils in project onebusaway-application-modules by camsys.
the class DiskFileServiceImpl method put.
@Override
public // copy file to dir
String put(String key, String directory) {
_log.debug("put(" + key + ", " + directory + ")");
NYCFileUtils fs = new NYCFileUtils();
String baseDirectoryName = _basePath + File.separator + fs.parseDirectory(key);
File baseDirectory = new File(baseDirectoryName);
if (!baseDirectory.exists()) {
baseDirectory.mkdirs();
}
String destFileName = _basePath + File.separator + key;
File destLocation = new File(destFileName);
File srcLocation = new File(directory);
try {
_log.debug("cp " + srcLocation + " " + destLocation);
fs.copyFiles(srcLocation, destLocation);
} catch (Exception e) {
_log.error("put failed(" + key + ", " + directory + "):", e);
}
return null;
}
use of org.onebusaway.admin.util.NYCFileUtils in project onebusaway-application-modules by camsys.
the class HastusTranslateTask method buildAgencyMap.
private void buildAgencyMap(String zipFile) {
File auxFilePath = new File(zipFile);
if (auxFilePath.exists() && auxFilePath.getName().contains("_")) {
NYCFileUtils fu = new NYCFileUtils();
String agencyId = fu.parseAgency(auxFilePath.toString());
HastusData hd = null;
if (agencyId != null) {
hd = _agencyMap.get(agencyId);
}
if (hd == null) {
hd = new HastusData();
hd.setAgencyId(agencyId);
_agencyMap.put(agencyId, hd);
}
if (zipFile.toUpperCase().contains("HASTUS")) {
hd.setScheduleDataDirectory(createScheduleDataDir(zipFile));
} else if (zipFile.toUpperCase().contains("GIS")) {
hd.setGisDataDirectory(createGisDataDir(zipFile));
}
}
}
Aggregations