public void install(String coords, Path artifact) throws ProvisioningException { try { final Path path = getArtifactPath(coords); Files.createDirectories(path.getParent()); if(Files.isDirectory(artifact)) { ZipUtils.zip(artifact, path); }else { Files.copy(artifact, path, StandardCopyOption.REPLACE_EXISTING); } } catch (IOException ex) { throw new ProvisioningException("Failed to install artifact " + coords + " to " + artifact, ex); } }
public static void unzip(Path zipFile, Path targetDir) throws IOException { if(!Files.exists(targetDir)) { Files.createDirectories(targetDir); } try (FileSystem zipfs = newFileSystem(zipFile)) { for (Path zipRoot : zipfs.getRootDirectories()) { copyFromZip(zipRoot, targetDir); } } }
public static void zip(Path src, Path zipFile) throws IOException { try (FileSystem zipfs = newFileSystem(toZipUri(zipFile), Files.exists(zipFile) ? Collections.emptyMap() : CREATE_ENV)) { if(Files.isDirectory(src)) { try (DirectoryStream<Path> stream = Files.newDirectoryStream(src)) { for(Path srcPath : stream) { copyToZip(src, srcPath, zipfs); } } } else { Files.copy(src, zipfs.getPath(src.getFileName().toString()), StandardCopyOption.REPLACE_EXISTING); } } }
public static byte[] hashJar(Path jarFile, boolean ignoreManifest) throws IOException { synchronized (DIGEST) { DIGEST.reset(); try (FileSystem zipfs = ZipUtils.newFileSystem(jarFile)) { for (Path zipRoot : zipfs.getRootDirectories()) { final Map<String, Path> sortedChildren = new TreeMap<String, Path>(); try(DirectoryStream<Path> stream = Files.newDirectoryStream(zipRoot)) { for(Path p : stream) { final String fileName = p.getFileName().toString(); if(ignoreManifest && fileName.equals("META-INF/")) { continue; } sortedChildren.put(fileName, p); } } for (Path child : sortedChildren.values()) { updateDigest(DIGEST, child); } } } return DIGEST.digest(); } }
private void unpack(final Path fpDir, final Path artifactPath) throws ProvisioningException { try { Files.createDirectories(fpDir); } catch (IOException e) { throw new ProvisioningException(Errors.mkdirs(fpDir), e); } try { ZipUtils.unzip(artifactPath, fpDir); } catch (IOException e) { throw new ProvisioningException("Failed to unzip " + artifactPath + " to " + fpDir, e); } } }
public static FeaturePackDescription describeFeaturePackZip(Path artifactZip) throws IOException, ProvisioningDescriptionException { try (FileSystem zipfs = ZipUtils.newFileSystem(artifactZip)) { for(Path zipRoot : zipfs.getRootDirectories()) { return describeFeaturePack(zipRoot, "UTF-8"); } } return null; }
ZipUtils.zip(tmpDir, pluginsDir.resolve(pluginFileName)); if(!plugins.isEmpty()) { for(Path plugin : plugins) {
public static FeaturePackSpec readSpec(Path artifactZip) throws ProvisioningException { try (FileSystem zipfs = ZipUtils.newFileSystem(artifactZip)) { for(Path zipRoot : zipfs.getRootDirectories()) { final Path p = zipRoot.resolve(Constants.FEATURE_PACK_XML); if(!Files.exists(p)) { throw new ProvisioningException("Feature-pack archive does not contain " + Constants.FEATURE_PACK_XML); } try(BufferedReader reader = Files.newBufferedReader(p)) { return FeaturePackXmlParser.getInstance().parse(reader); } catch (XMLStreamException e) { throw new ProvisioningException(Errors.parseXml(p), e); } } } catch (IOException e) { throw new ProvisioningException(Errors.readFile(artifactZip), e); } return null; }
IoUtils.recursiveDelete(zippedFP); ZipUtils.zip(versionDir, zippedFP); final Artifact artifact = new DefaultArtifact( groupDir.getFileName().toString(),
IoUtils.recursiveDelete(zippedFP); ZipUtils.zip(versionDir, zippedFP); final Artifact artifact = new DefaultArtifact( groupDir.getFileName().toString(),
void install(FeaturePackLocation.FPID fpid, Path fpContentDir) throws ProvisioningException { Universe<?> universe = null; UniverseFeaturePackInstaller ufpInstaller = null; if (universeResolution) { universe = universeResolver.getUniverse(fpid.getLocation().getUniverse()); ufpInstaller = ufpInstallers.get(universe.getFactoryId()); if (ufpInstaller == null) { throw new ProvisioningException(Errors.featurePackInstallerNotFound(universe.getFactoryId(), ufpInstallers.keySet())); } } final Path fpZip = getBuildDir().resolve(LayoutUtils.ensureValidFileName(fpid.toString())); try { ZipUtils.zip(fpContentDir, fpZip); } catch (IOException e) { throw new ProvisioningException("Failed to create feature-pack archive", e); } if (ufpInstaller != null) { ufpInstaller.install(universe, fpid, fpZip); } }