/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.importer.ZipImporter#importZip(java.util.zip.ZipInputStream) */ @Override @Deprecated public ZipImporter importZip(final ZipInputStream stream) { // Delegate return this.importFrom(stream); }
protected boolean setupUsingAppArtifact(DependenciesContainer<?> archive) throws IOException { String appArtifact = System.getProperty("wildfly.swarm.app.artifact"); if (appArtifact != null) { try (InputStream in = ClassLoader.getSystemClassLoader().getResourceAsStream("_bootstrap/" + appArtifact)) { ZipImporterImpl importer = new ZipImporterImpl(archive); importer.importFrom(in); } return true; } return false; }
private ZipImporter importFrom(final ZipFile file, Filter<ArchivePath> filter) throws ArchiveImportException { Validate.notNull(file, "File must be specified"); try { Enumeration<? extends ZipEntry> entries = file.entries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); // Get the entry (path) name final String entryName = entry.getName(); if(!filter.include(ArchivePaths.create(entryName))) { continue; } // Get the archive final Archive<?> archive = this.getArchive(); // Handle directories separately if (entry.isDirectory()) { archive.addAsDirectory(entryName); continue; } archive.add(new ZipFileEntryAsset(file, entry), new BasicPath(entryName)); } } catch (Exception e) { throw new ArchiveImportException("Could not import file", e); } return this; } }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.importer.ZipImporter#importZip(java.util.zip.ZipFile) */ @Deprecated @Override public ZipImporter importZip(ZipFile file) { // Delegate return this.importFrom(file); }
public static JavaArchive artifact(String gav, String asName) throws IOException, ModuleLoadException { File file = findFile(gav); JavaArchive archive = ShrinkWrap.create(JavaArchive.class, asName); new ZipImporterImpl(archive).importFrom(file); return archive; }
final Archive<?> archive = this.getArchive();
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.importer.ZipImporter#importZip(java.util.zip.ZipFile) */ @Deprecated @Override public ZipImporter importZip(ZipFile file) { // Delegate return this.importFrom(file); }
public static JavaArchive artifact(String gav) throws IOException, ModuleLoadException { File file = findFile(gav); JavaArchive archive = ShrinkWrap.create(JavaArchive.class, file.getName()); new ZipImporterImpl(archive).importFrom(file); return archive; }
final Archive<?> archive = this.getArchive();
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.importer.ZipImporter#importZip(java.util.zip.ZipInputStream) */ @Override @Deprecated public ZipImporter importZip(final ZipInputStream stream) { // Delegate return this.importFrom(stream); }
protected boolean setupUsingAppPath(DependenciesContainer<?> archive) throws IOException { String appPath = System.getProperty("wildfly.swarm.app.path"); if (appPath != null) { final Path path = Paths.get(System.getProperty("wildfly.swarm.app.path")); if (Files.isDirectory(path)) { Files.walkFileTree(path, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Path simple = path.relativize(file); archive.add(new FileAsset(file.toFile()), convertSeparators(simple)); return super.visitFile(file, attrs); } }); } else { ZipImporterImpl importer = new ZipImporterImpl(archive); importer.importFrom(new File(System.getProperty("wildfly.swarm.app.path"))); } return true; } return false; }
final Archive<?> archive = this.getArchive();
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.importer.StreamImporter#importFrom(java.io.File) */ @Override public ZipImporter importFrom(final ZipFile file) throws ArchiveImportException { return importFrom(file, Filters.includeAll()); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.importer.StreamImporter#importFrom(java.io.File) */ @Override public ZipImporter importFrom(final ZipFile file) throws ArchiveImportException { return importFrom(file, Filters.includeAll()); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.importer.StreamImporter#importFrom(java.io.InputStream) */ @Override public ZipImporter importFrom(final InputStream stream) throws ArchiveImportException { return importFrom(stream, Filters.includeAll()); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.importer.StreamImporter#importFrom(java.io.File) */ @Override public ZipImporter importFrom(final File file) throws ArchiveImportException { return importFrom(file, Filters.includeAll()); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.importer.StreamImporter#importFrom(java.io.InputStream) */ @Override public ZipImporter importFrom(final InputStream stream) throws ArchiveImportException { return importFrom(stream, Filters.includeAll()); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.importer.StreamImporter#importFrom(java.io.File) */ @Override public ZipImporter importFrom(final File file) throws ArchiveImportException { return importFrom(file, Filters.includeAll()); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.importer.StreamImporter#importFrom(java.io.File, Filter) */ @Override public ZipImporter importFrom(File file, Filter<ArchivePath> filter) throws ArchiveImportException { Validate.notNull(file, "File must be specified"); if (file.isDirectory()) { throw new IllegalArgumentException("File to import as ZIP must not be a directory: " + file.getAbsolutePath()); } Validate.notNull(filter, "Filter must be specified"); final ZipFile zipFile; try { zipFile = new ZipFile(file); } catch (final IOException ioe) { throw new ArchiveImportException("Could not obtain ZIP File from File", ioe); } // Delegate return this.importFrom(zipFile, filter); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.importer.StreamImporter#importFrom(java.io.File, Filter) */ @Override public ZipImporter importFrom(File file, Filter<ArchivePath> filter) throws ArchiveImportException { Validate.notNull(file, "File must be specified"); if (file.isDirectory()) { throw new IllegalArgumentException("File to import as ZIP must not be a directory: " + file.getAbsolutePath()); } Validate.notNull(filter, "Filter must be specified"); final ZipFile zipFile; try { zipFile = new ZipFile(file); } catch (final IOException ioe) { throw new ArchiveImportException("Could not obtain ZIP File from File", ioe); } // Delegate return this.importFrom(zipFile, filter); }