use of com.thinkbiganalytics.repository.api.TemplateRepository.RepositoryType.FILESYSTEM in project kylo by Teradata.
the class FilesystemRepositoryService method listRepositories.
@Override
public List<TemplateRepository> listRepositories() {
TypeReference<List<TemplateRepository>> typeReference = new TypeReference<List<TemplateRepository>>() {
};
try {
InputStream is = resourceLoader.getResource("classpath:repositories.json").getInputStream();
List<TemplateRepository> repositories = new ArrayList<>();
repositories.add(new TemplateRepository("Kylo Repository", defaultKyloRepository, "", FILESYSTEM, true));
repositories.addAll(mapper.readValue(is, typeReference));
Set<String> set = new HashSet<>(repositories.size());
return repositories.stream().filter(r -> // location must be provided
StringUtils.isNotBlank(r.getLocation()) && // location must be valid
Files.exists(Paths.get(r.getLocation().trim())) && // unique name per repository type
set.add(r.getName().trim().toLowerCase() + "_" + r.getType().getKey().trim().toLowerCase())).collect(Collectors.toList());
} catch (Exception e) {
log.error("Error reading template repositories", e);
}
return new ArrayList<>();
}
Aggregations