public static ContentRepositoryElement createFolder(String path) { return new ContentRepositoryElement(path, true, -1); }
@Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { if (filter.acceptDirectory(rootPath, dir)) { String directoryPath = formatDirectoryPath(rootPath.relativize(dir)); if(! "/".equals(directoryPath)) { result.add(ContentRepositoryElement.createFolder(directoryPath)); } } return FileVisitResult.CONTINUE; }
for (ContentRepositoryElement content : contentRepository.listContent(deploymentHash, path, ContentFilter.Factory.createContentFilter(depth, explodable))) { ModelNode contentNode = new ModelNode(); contentNode.get(PATH).set(content.getPath()); contentNode.get(DIRECTORY).set(content.isFolder()); if(!content.isFolder()) { contentNode.get(FILE_SIZE).set(content.getSize());
private static List<ContentRepositoryElement> listZipContent(final Path zipFilePath, final ContentFilter filter) throws IOException { List<ContentRepositoryElement> result = new ArrayList<>(); try (final ZipFile zip = new ZipFile(zipFilePath.toFile())) { final Enumeration<? extends ZipEntry> entries = zip.entries(); while (entries.hasMoreElements()) { final ZipEntry entry = entries.nextElement(); final String name = entry.getName(); Path entryPath = zipFilePath.resolve(name); if (entry.isDirectory()) { if(filter.acceptDirectory(zipFilePath, entryPath)) { result.add(ContentRepositoryElement.createFolder(name)); } } else { try (InputStream in = zip.getInputStream(entry)) { if (filter.acceptFile(zipFilePath, entryPath, in)) { result.add(ContentRepositoryElement.createFile(name, entry.getSize())); } } } } } return result; }
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (filter.acceptFile(rootPath, file)) { result.add(ContentRepositoryElement.createFile(formatPath(rootPath.relativize(file)), Files.size(file))); } return FileVisitResult.CONTINUE; }
for (ContentRepositoryElement content : contentRepository.listContent(deploymentHash, path, ContentFilter.Factory.createContentFilter(depth, explodable))) { ModelNode contentNode = new ModelNode(); contentNode.get(PATH).set(content.getPath()); contentNode.get(DIRECTORY).set(content.isFolder()); if(!content.isFolder()) { contentNode.get(FILE_SIZE).set(content.getSize());
for (ContentRepositoryElement content : contentRepository.listContent(deploymentHash, path, ContentFilter.Factory.createContentFilter(depth, explodable))) { ModelNode contentNode = new ModelNode(); contentNode.get(PATH).set(content.getPath()); contentNode.get(DIRECTORY).set(content.isFolder()); if(!content.isFolder()) { contentNode.get(FILE_SIZE).set(content.getSize());
public static ContentRepositoryElement createFile(String path, long size) { return new ContentRepositoryElement(path, false, size); }
for (ContentRepositoryElement content : contentRepository.listContent(deploymentHash, path, ContentFilter.Factory.createContentFilter(depth, explodable))) { ModelNode contentNode = new ModelNode(); contentNode.get(PATH).set(content.getPath()); contentNode.get(DIRECTORY).set(content.isFolder()); if(!content.isFolder()) { contentNode.get(FILE_SIZE).set(content.getSize());