Search in sources :

Example 1 with FILESYSTEM

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<>();
}
Also used : UploadProgressService(com.thinkbiganalytics.feedmgr.service.UploadProgressService) RegisteredTemplateService(com.thinkbiganalytics.feedmgr.service.template.RegisteredTemplateService) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) TemplateImporter(com.thinkbiganalytics.feedmgr.service.template.importing.TemplateImporter) StringUtils(org.apache.commons.lang3.StringUtils) TemplateChangeEvent(com.thinkbiganalytics.metadata.api.event.template.TemplateChangeEvent) ObjectMapperSerializer(com.thinkbiganalytics.json.ObjectMapperSerializer) ByteArrayInputStream(java.io.ByteArrayInputStream) ImportUtil(com.thinkbiganalytics.feedmgr.util.ImportUtil) TemplateSearchFilter(com.thinkbiganalytics.repository.api.TemplateSearchFilter) TypeReference(com.fasterxml.jackson.core.type.TypeReference) MetadataAccess(com.thinkbiganalytics.metadata.api.MetadataAccess) Path(java.nio.file.Path) RepositoryService(com.thinkbiganalytics.repository.api.RepositoryService) ResourceLoader(org.springframework.core.io.ResourceLoader) ImportTemplate(com.thinkbiganalytics.feedmgr.service.template.importing.model.ImportTemplate) MetadataEventListener(com.thinkbiganalytics.metadata.api.event.MetadataEventListener) FILESYSTEM(com.thinkbiganalytics.repository.api.TemplateRepository.RepositoryType.FILESYSTEM) Set(java.util.Set) MetadataEventService(com.thinkbiganalytics.metadata.api.event.MetadataEventService) Collectors(java.util.stream.Collectors) ExportTemplate(com.thinkbiganalytics.metadata.api.template.export.ExportTemplate) List(java.util.List) Principal(java.security.Principal) Stream(java.util.stream.Stream) PostConstruct(javax.annotation.PostConstruct) ImportTemplateOptions(com.thinkbiganalytics.feedmgr.rest.model.ImportTemplateOptions) Optional(java.util.Optional) TemplateChange(com.thinkbiganalytics.metadata.api.event.template.TemplateChange) FilenameUtils(org.apache.commons.io.FilenameUtils) SearchResultImpl(com.thinkbiganalytics.rest.model.search.SearchResultImpl) TemplateComparator.valueOf(com.thinkbiganalytics.repository.api.TemplateSearchFilter.TemplateComparator.valueOf) DigestUtils(org.springframework.util.DigestUtils) PropertySource(org.springframework.context.annotation.PropertySource) Scheduled(org.springframework.scheduling.annotation.Scheduled) TemplateMetadataWrapper(com.thinkbiganalytics.repository.api.TemplateMetadataWrapper) ArrayList(java.util.ArrayList) Value(org.springframework.beans.factory.annotation.Value) HashSet(java.util.HashSet) Inject(javax.inject.Inject) TemplateRepository(com.thinkbiganalytics.repository.api.TemplateRepository) TemplateModelTransform(com.thinkbiganalytics.feedmgr.service.template.TemplateModelTransform) Service(org.springframework.stereotype.Service) DefaultPrettyPrinter(com.fasterxml.jackson.core.util.DefaultPrettyPrinter) MetadataChange(com.thinkbiganalytics.metadata.api.event.MetadataChange) RegisteredTemplate(com.thinkbiganalytics.feedmgr.rest.model.RegisteredTemplate) TemplateImporterFactory(com.thinkbiganalytics.feedmgr.service.template.importing.TemplateImporterFactory) NAME(com.thinkbiganalytics.repository.api.TemplateSearchFilter.TemplateComparator.NAME) Logger(org.slf4j.Logger) Files(java.nio.file.Files) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) TemplateExporter(com.thinkbiganalytics.metadata.api.template.export.TemplateExporter) FileInputStream(java.io.FileInputStream) SearchResult(com.thinkbiganalytics.rest.model.search.SearchResult) TemplateMetadata(com.thinkbiganalytics.repository.api.TemplateMetadata) Paths(java.nio.file.Paths) Cache(com.google.common.cache.Cache) Comparator(java.util.Comparator) Collections(java.util.Collections) ImportComponentOption(com.thinkbiganalytics.feedmgr.rest.model.ImportComponentOption) InputStream(java.io.InputStream) TemplateRepository(com.thinkbiganalytics.repository.api.TemplateRepository) ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) TypeReference(com.fasterxml.jackson.core.type.TypeReference) HashSet(java.util.HashSet)

Aggregations

TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 DefaultPrettyPrinter (com.fasterxml.jackson.core.util.DefaultPrettyPrinter)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Cache (com.google.common.cache.Cache)1 ImportComponentOption (com.thinkbiganalytics.feedmgr.rest.model.ImportComponentOption)1 ImportTemplateOptions (com.thinkbiganalytics.feedmgr.rest.model.ImportTemplateOptions)1 RegisteredTemplate (com.thinkbiganalytics.feedmgr.rest.model.RegisteredTemplate)1 UploadProgressService (com.thinkbiganalytics.feedmgr.service.UploadProgressService)1 RegisteredTemplateService (com.thinkbiganalytics.feedmgr.service.template.RegisteredTemplateService)1 TemplateModelTransform (com.thinkbiganalytics.feedmgr.service.template.TemplateModelTransform)1 TemplateImporter (com.thinkbiganalytics.feedmgr.service.template.importing.TemplateImporter)1 TemplateImporterFactory (com.thinkbiganalytics.feedmgr.service.template.importing.TemplateImporterFactory)1 ImportTemplate (com.thinkbiganalytics.feedmgr.service.template.importing.model.ImportTemplate)1 ImportUtil (com.thinkbiganalytics.feedmgr.util.ImportUtil)1 ObjectMapperSerializer (com.thinkbiganalytics.json.ObjectMapperSerializer)1 MetadataAccess (com.thinkbiganalytics.metadata.api.MetadataAccess)1 MetadataChange (com.thinkbiganalytics.metadata.api.event.MetadataChange)1 MetadataEventListener (com.thinkbiganalytics.metadata.api.event.MetadataEventListener)1 MetadataEventService (com.thinkbiganalytics.metadata.api.event.MetadataEventService)1 TemplateChange (com.thinkbiganalytics.metadata.api.event.template.TemplateChange)1