use of org.onebusaway.admin.bundle.model.SourceFile in project onebusaway-application-modules by camsys.
the class BundleBuildingUtil method getSourceFilesWithSumsForDirectory.
public List<SourceFile> getSourceFilesWithSumsForDirectory(File baseDir, File dir, File rootDir) throws IllegalArgumentException {
List<SourceFile> files = new ArrayList<SourceFile>();
if (!dir.isDirectory()) {
throw new IllegalArgumentException(dir.getPath() + " is not a directory");
} else {
for (String filePath : dir.list()) {
File listEntry = new File(dir, filePath);
String listEntryFilename = null;
try {
listEntryFilename = listEntry.getCanonicalPath();
} catch (Exception e) {
// bury
}
// prevent lock files from insertion into json, they change
if (listEntry.isFile() && listEntryFilename != null && !listEntryFilename.endsWith(".lck")) {
SourceFile file = new SourceFile();
file.setCreatedDate(getCreatedDate(listEntry));
String relPathToBase = rootDir.toURI().relativize(listEntry.toURI()).getPath();
file.setUri(relPathToBase);
file.setFilename(relPathToBase);
String sum = getMd5ForFile(listEntry);
file.setMd5(sum);
files.add(file);
_log.debug("file:" + listEntry + " has Md5=" + sum + " and createdDate=" + file.getCreatedDate());
} else if (listEntry.isDirectory()) {
files.addAll(getSourceFilesWithSumsForDirectory(baseDir, listEntry, rootDir));
}
}
}
return files;
}
Aggregations