use of com.dexels.navajo.compiler.ScriptCompiler in project navajo by Dexels.
the class BundleCreatorComponent method getApplicableScriptFile.
private File getApplicableScriptFile(String rpcName, String tenant) {
for (ScriptCompiler compiler : compilers.values()) {
File scriptFolder = new File(navajoIOConfig.getRootPath(), compiler.getRelativeScriptPath());
if (tenant != null) {
String tenantFilename = rpcName + "_" + tenant + compiler.getScriptExtension();
File f = new File(scriptFolder, tenantFilename);
if (f.exists()) {
return f;
}
}
String filename = rpcName + compiler.getScriptExtension();
File f = new File(scriptFolder, filename);
if (f.exists()) {
return f;
}
}
return null;
}
use of com.dexels.navajo.compiler.ScriptCompiler in project navajo by Dexels.
the class BundleCreatorComponent method createBundleNoLocking.
private void createBundleNoLocking(String rpcName, List<String> failures, List<String> success, List<String> skipped, boolean force, boolean keepIntermediate) throws CompilationException {
boolean matchedScript = false;
removeOldCompiledScriptFiles(rpcName);
for (ScriptCompiler compiler : compilers.values()) {
System.err.println("Checking compiler " + compiler + " to compile service " + rpcName);
File scriptFolder = new File(navajoIOConfig.getRootPath(), compiler.getRelativeScriptPath());
File f = new File(scriptFolder, rpcName + compiler.getScriptExtension());
// Look for other tenant-specific files
AbstractFileFilter fileFilter = new WildcardFileFilter(FilenameUtils.getBaseName(rpcName) + "_*" + compiler.getScriptExtension());
File dir = new File(scriptFolder, FilenameUtils.getPath(rpcName));
Collection<File> files = Collections.<File>emptySet();
if (dir.exists()) {
files = FileUtils.listFiles(dir, fileFilter, null);
}
Map<String, File> tenantSpecificFiles = new HashMap<>();
Collection<String> tenantsToIgnore = new ArrayList<>();
for (File ascript : files) {
matchedScript = true;
String pathRelative = getRelative(scriptFolder, ascript);
String[] splitted = pathRelative.split("\\.");
String tenantScriptName = splitted[0].replace('\\', '/');
tenantSpecificFiles.put(tenantScriptName, ascript);
// Get the tenant out of the name and put it in the tenantsToIgnore collection
tenantsToIgnore.add(tenantScriptName.split("_")[1]);
}
if (f.exists()) {
matchedScript = true;
createBundleForScript(rpcName, rpcName, f, tenantsToIgnore, true, failures, success, skipped, keepIntermediate);
}
for (Map.Entry<String, File> entry : tenantSpecificFiles.entrySet()) {
createBundleForScript(entry.getKey(), rpcName, entry.getValue(), tenantsToIgnore, false, failures, success, skipped, keepIntermediate);
}
if (matchedScript) {
break;
}
}
if (!matchedScript) {
throw new CompilationException("Unable to find script for " + rpcName);
}
}
Aggregations