use of org.phoenicis.repository.dto.ScriptDTO in project POL-POM-5 by PlayOnLinux.
the class LocalRepository method fetchScripts.
private List<ScriptDTO> fetchScripts(File applicationDirectory) {
final File[] scriptDirectories = applicationDirectory.listFiles();
if (scriptDirectories == null) {
return Collections.emptyList();
}
final List<ScriptDTO> results = new ArrayList<>();
for (File scriptDirectory : scriptDirectories) {
if (scriptDirectory.isDirectory() && !"miniatures".equals(scriptDirectory.getName()) && !"resources".equals(scriptDirectory.getName())) {
final ScriptDTO.Builder scriptDTOBuilder = new ScriptDTO.Builder(unSerializeScript(new File(scriptDirectory, "script.json")));
scriptDTOBuilder.withScriptSource(repositorySource);
if (StringUtils.isBlank(scriptDTOBuilder.getScriptName())) {
scriptDTOBuilder.withScriptName(scriptDirectory.getName());
}
final File scriptFile = new File(scriptDirectory, "script.js");
if (scriptFile.exists()) {
try {
scriptDTOBuilder.withScript(new String(IOUtils.toByteArray(new FileInputStream(scriptFile))));
} catch (IOException e) {
LOGGER.warn("Script not found", e);
}
}
results.add(scriptDTOBuilder.build());
}
}
return results;
}
Aggregations