@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Objects.requireNonNull(file); Objects.requireNonNull(attrs); businessArchive.addResource(barRootFolder.relativize(file).toString().replace(File.separator, "/"), IOUtil.getAllContentFrom(file.toFile())); resourcesCount++; return FileVisitResult.CONTINUE; }
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Objects.requireNonNull(file); Objects.requireNonNull(attrs); businessArchive.addResource(barRootFolder.relativize(file).toString().replace(File.separator, "/"), IOUtil.getAllContentFrom(file.toFile())); resourcesCount++; return FileVisitResult.CONTINUE; }
@Override public boolean readFromBarFolder(final BusinessArchive businessArchive, final File barFolder) throws IOException { final File folder = new File(barFolder, getFolderName()); if (folder.exists() && !folder.isFile()) { final File[] listFiles = folder.listFiles(); for (final File file : listFiles) { final byte[] content = IOUtil.getContent(file); businessArchive.addResource(getFolderName() + '/' + file.getName(), content); } return listFiles.length > 0; } return false; }
protected void addBarResourceInPath(final BarResource resource, final String path) { final String resourcePath = path + resource.getName(); final byte[] resourceContent = resource.getContent(); if (resourceContent == null || resourceContent.length == 0) { throw new IllegalArgumentException("You are trying to add file " + resourcePath + " with empty content into the BusinessArchive (bar file)." + " Either add content to this file, or remove it from the resources."); } entity.addResource(resourcePath, resourceContent); }
protected void addBarResourceInPath(final BarResource resource, final String path) { final String resourcePath = path + resource.getName(); final byte[] resourceContent = resource.getContent(); if (resourceContent == null || resourceContent.length == 0) { throw new IllegalArgumentException("You are trying to add file " + resourcePath + " with empty content into the BusinessArchive (bar file)." + " Either add content to this file, or remove it from the resources."); } entity.addResource(resourcePath, resourceContent); }
@Override public boolean readFromBarFolder(final BusinessArchive businessArchive, final File barFolder) throws IOException { final File folder = new File(barFolder, getFolderName()); if (folder.exists() && !folder.isFile()) { final File[] listFiles = folder.listFiles(); for (final File file : listFiles) { final byte[] content = IOUtil.getContent(file); businessArchive.addResource(getFolderName() + '/' + file.getName(), content); } return listFiles.length > 0; } return false; }
@Override public boolean readFromBarFolder(final BusinessArchive businessArchive, final File barFolder) throws IOException { final File file = new File(barFolder, getFileName()); if (!file.exists()) { return false; } final byte[] content = IOUtil.getContent(file); businessArchive.addResource(getFileName(), content); return true; }
@Override public boolean readFromBarFolder(final BusinessArchive businessArchive, final File barFolder) throws IOException { final File file = new File(barFolder, getFileName()); if (!file.exists()) { return false; } final byte[] content = IOUtil.getContent(file); businessArchive.addResource(getFileName(), content); return true; }