Search in sources :

Example 1 with GenericId

use of org.eclipse.winery.common.ids.GenericId in project winery by eclipse.

the class FilebasedRepository method getContainedFiles.

@Override
public SortedSet<RepositoryFileReference> getContainedFiles(GenericId id) {
    Path dir = this.id2AbsolutePath(id);
    SortedSet<RepositoryFileReference> res = new TreeSet<>();
    if (!Files.exists(dir)) {
        return res;
    }
    assert (Files.isDirectory(dir));
    final OnlyNonHiddenFiles onlyNonHiddenFiles = new OnlyNonHiddenFiles();
    try {
        Files.walk(dir).filter(f -> {
            try {
                return onlyNonHiddenFiles.accept(f);
            } catch (IOException e) {
                LOGGER.debug("Error during crawling", e);
                return false;
            }
        }).map(f -> {
            final Path relativePath = dir.relativize(f.getParent());
            if (relativePath.toString().isEmpty()) {
                return new RepositoryFileReference(id, f.getFileName().toString());
            } else {
                return new RepositoryFileReference(id, relativePath, f.getFileName().toString());
            }
        }).forEach(ref -> res.add(ref));
    } catch (IOException e1) {
        LOGGER.debug("Error during crawling", e1);
    }
    return res;
}
Also used : Configuration(org.apache.commons.configuration.Configuration) ZipOutputStream(java.util.zip.ZipOutputStream) HasIdInIdOrNameField(org.eclipse.winery.model.tosca.HasIdInIdOrNameField) ZipArchiveEntry(org.apache.commons.compress.archivers.zip.ZipArchiveEntry) Definitions(org.eclipse.winery.model.tosca.Definitions) java.util(java.util) ZipInputStream(java.util.zip.ZipInputStream) ToscaElementId(org.eclipse.winery.common.ids.elements.ToscaElementId) LoggerFactory(org.slf4j.LoggerFactory) InvalidPathException(org.eclipse.jgit.dircache.InvalidPathException) FileTime(java.nio.file.attribute.FileTime) MediaType(org.apache.tika.mime.MediaType) FileSystemProvider(java.nio.file.spi.FileSystemProvider) Constructor(java.lang.reflect.Constructor) XmlId(org.eclipse.winery.common.ids.XmlId) WineryRepositoryException(org.eclipse.winery.repository.exceptions.WineryRepositoryException) java.nio.file(java.nio.file) Constants(org.eclipse.winery.repository.Constants) Charset(java.nio.charset.Charset) XsdImportManager(org.eclipse.winery.repository.backend.xsd.XsdImportManager) NamespacesId(org.eclipse.winery.common.ids.admin.NamespacesId) ArchiveStreamFactory(org.apache.commons.compress.archivers.ArchiveStreamFactory) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) ZipEntry(java.util.zip.ZipEntry) RepositoryFileReference(org.eclipse.winery.common.RepositoryFileReference) FileBasedRepositoryConfiguration(org.eclipse.winery.repository.configuration.FileBasedRepositoryConfiguration) ArchiveException(org.apache.commons.compress.archivers.ArchiveException) Logger(org.slf4j.Logger) RepositoryBasedXsdImportManager(org.eclipse.winery.repository.backend.xsd.RepositoryBasedXsdImportManager) SystemUtils(org.apache.commons.lang3.SystemUtils) GenericId(org.eclipse.winery.common.ids.GenericId) DefinitionsChildId(org.eclipse.winery.common.ids.definitions.DefinitionsChildId) FileSystem(java.nio.file.FileSystem) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes) Util(org.eclipse.winery.common.Util) org.eclipse.winery.repository.backend(org.eclipse.winery.repository.backend) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOUtils(org.apache.commons.io.IOUtils) java.io(java.io) ArchiveOutputStream(org.apache.commons.compress.archivers.ArchiveOutputStream) MediaTypes(org.eclipse.winery.repository.backend.constants.MediaTypes) Namespace(org.eclipse.winery.common.ids.Namespace) ConfigurationException(org.apache.commons.configuration.ConfigurationException) RepositoryFileReference(org.eclipse.winery.common.RepositoryFileReference)

Aggregations

java.io (java.io)1 Constructor (java.lang.reflect.Constructor)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Charset (java.nio.charset.Charset)1 java.nio.file (java.nio.file)1 FileSystem (java.nio.file.FileSystem)1 BasicFileAttributes (java.nio.file.attribute.BasicFileAttributes)1 FileTime (java.nio.file.attribute.FileTime)1 FileSystemProvider (java.nio.file.spi.FileSystemProvider)1 java.util (java.util)1 ZipEntry (java.util.zip.ZipEntry)1 ZipInputStream (java.util.zip.ZipInputStream)1 ZipOutputStream (java.util.zip.ZipOutputStream)1 ArchiveException (org.apache.commons.compress.archivers.ArchiveException)1 ArchiveOutputStream (org.apache.commons.compress.archivers.ArchiveOutputStream)1 ArchiveStreamFactory (org.apache.commons.compress.archivers.ArchiveStreamFactory)1 ZipArchiveEntry (org.apache.commons.compress.archivers.zip.ZipArchiveEntry)1 Configuration (org.apache.commons.configuration.Configuration)1 ConfigurationException (org.apache.commons.configuration.ConfigurationException)1 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)1