protected ZipFile zipFileFor(final File file) throws IOException { return loadZipFileWithMaxRetries(file, 3); }
public static ResourceList forResources(final Pattern pattern) { return new ResourceList(pattern); }
public static FileResources from(final String resourceDirectoryRoot) { return new FileResources(resourceDirectoryRoot); }
private Collection<String> getResources(final String element, final Pattern pattern) { final ArrayList<String> resources = new ArrayList<>(); final File file = new File(element); if (isAJarFile(file)) { resources.addAll(getResourcesFromJarFile(file, pattern)); } else { resources.addAll(getResourcesFromDirectory(file, pattern)); } return removeUnnecessaryFilesFrom(resources); }
/** * Resources (stylesheets, images) etc are all stored in the * src/main/resources/reports directory. When the jar is deployed, they will * end up on the classpath. */ public void copyHTMLResourcesTo(final File targetDirectory) throws IOException { Pattern resourcePattern = allFilesInDirectory(resourceDirectory); FileResources fileResource = FileResources.from(resourceDirectory); Collection<String> reportResources = ResourceList.forResources(resourcePattern).list(); for (String resourcePath : reportResources) { if (fileResourceFromAJar(resourcePath)) { fileResource.copyResourceTo(resourcePath, targetDirectory); } else if (fileResourceFromPath(resourcePath)) { fileResource.copyResourceTo(resourcePath, targetDirectory); } } }
public final String findTargetSubdirectoryFrom(final String sourceResource) { int directoryRootStartsAt = StringUtils.lastIndexOf(sourceResource, resourceDirectoryRoot); int relativePathStartsAt = directoryRootStartsAt + resourceDirectoryRoot.length() + 1; String relativePath = sourceResource.substring(relativePathStartsAt); relativePath = stripLeadingSeparatorFrom(relativePath); return directoryIn(relativePath); }
private void copyFileFromClasspathToTargetDirectory( final String resourcePath, final File targetDirectory) throws IOException { File destinationFile = new File(targetDirectory, new File(resourcePath).getName()); if (destinationFile.exists()) { return; } if (destinationFile.getParent() != null) { new File(destinationFile.getParent()).mkdirs(); } try(InputStream in = fileSource(resourcePath); FileOutputStream out = getOutputStreamForDestination(destinationFile);) { copyData(in, out); } }
public final String findTargetFileFrom(final String sourceResource) { int directoryRootStartsAt = StringUtils.lastIndexOf(sourceResource, resourceDirectoryRoot); int relativePathStartsAt = directoryRootStartsAt + resourceDirectoryRoot.length() + 1; String relativePath = sourceResource.substring(relativePathStartsAt); return filenameIn(relativePath); }
private Collection<String> systemPropertiesClasspathElements() { final ArrayList<String> resources = new ArrayList<>(); final String classPath = System.getProperty("java.class.path", "."); final String[] classPathElements = classPath.split(PATH_SEPARATOR); for (final String element : classPathElements) { resources.addAll(getResources(element, pattern)); } return resources; }
private Collection<String> getResources(final String element, final Pattern pattern) { final ArrayList<String> resources = new ArrayList<String>(); final File file = new File(element); if (isAJarFile(file)) { resources.addAll(getResourcesFromJarFile(file, pattern)); } else { resources.addAll(getResourcesFromDirectory(file, pattern)); } return removeUnnecessaryFilesFrom(resources); }
/** * Resources (stylesheets, images) etc are all stored in the * src/main/resources/reports directory. When the jar is deployed, they will * end up on the classpath. */ public void copyHTMLResourcesTo(final File targetDirectory) throws IOException { Pattern resourcePattern = allFilesInDirectory(resourceDirectory); FileResources fileResource = FileResources.from(resourceDirectory); Collection<String> reportResources = ResourceList.forResources(resourcePattern).list(); for (String resourcePath : reportResources) { if (fileResourceFromAJar(resourcePath)) { fileResource.copyResourceTo(resourcePath, targetDirectory); } else if (fileResourceFromPath(resourcePath)) { fileResource.copyResourceTo(resourcePath, targetDirectory); } } }
public final String findTargetSubdirectoryFrom(final String sourceResource) { int directoryRootStartsAt = StringUtils.lastIndexOf(sourceResource, resourceDirectoryRoot); int relativePathStartsAt = directoryRootStartsAt + resourceDirectoryRoot.length() + 1; String relativePath = sourceResource.substring(relativePathStartsAt); relativePath = stripLeadingSeparatorFrom(relativePath); return directoryIn(relativePath); }
public static ResourceList forResources(final String resourceDirectory, final Pattern pattern) { return new ResourceList(resourceDirectory, pattern); }
public static FileResources from(final String resourceDirectoryRoot) { return new FileResources(resourceDirectoryRoot); }
public final String findTargetFileFrom(final String sourceResource) { int directoryRootStartsAt = StringUtils.lastIndexOf(sourceResource, resourceDirectoryRoot); int relativePathStartsAt = directoryRootStartsAt + resourceDirectoryRoot.length() + 1; String relativePath = sourceResource.substring(relativePathStartsAt); return filenameIn(relativePath); }
private Collection<String> getResources(final String element, final Pattern pattern) { final ArrayList<String> resources = new ArrayList<String>(); final File file = new File(element); if (isAJarFile(file)) { resources.addAll(getResourcesFromJarFile(file, pattern)); } else { resources.addAll(getResourcesFromDirectory(file, pattern)); } return removeUnnecessaryFilesFrom(resources); }
public final String findTargetSubdirectoryFrom(final String sourceResource) { int directoryRootStartsAt = StringUtils.lastIndexOf(sourceResource, resourceDirectoryRoot); int relativePathStartsAt = directoryRootStartsAt + resourceDirectoryRoot.length() + 1; String relativePath = sourceResource.substring(relativePathStartsAt); relativePath = stripLeadingSeparatorFrom(relativePath); return directoryIn(relativePath); }
public static ResourceList forResources(final Pattern pattern) { return new ResourceList(pattern); }
public static FileResources from(final String resourceDirectoryRoot) { return new FileResources(resourceDirectoryRoot); }
public final String findTargetFileFrom(final String sourceResource) { int directoryRootStartsAt = StringUtils.lastIndexOf(sourceResource, resourceDirectoryRoot); int relativePathStartsAt = directoryRootStartsAt + resourceDirectoryRoot.length() + 1; String relativePath = sourceResource.substring(relativePathStartsAt); return filenameIn(relativePath); }