public static Path getFeaturePackDir(Path fpLayoutDir, FPID fpid) throws ProvisioningDescriptionException { return getFeaturePackDir(fpLayoutDir, fpid, true); }
public static Path getFeaturePackDir(Path fpLayoutDir, FPID fpid, boolean existing) throws ProvisioningDescriptionException { final FeaturePackLocation fps = fpid.getLocation(); final UniverseSpec universe = fps.getUniverse(); Path fpPath = fpLayoutDir.resolve(universe.getFactory()); if (universe.getLocation() != null) { fpPath = fpPath.resolve(ensureValidFileName(universe.getLocation())); } fpPath = fpPath.resolve(ensureValidFileName(fps.getProducerName())).resolve(fps.getChannelName()).resolve(ensureValidFileName(fpid.getBuild())); if (existing && !Files.exists(fpPath)) { throw new ProvisioningDescriptionException(Errors.pathDoesNotExist(fpPath)); } return fpPath; }
public static Path getPackageDir(Path fpDir, String packageName) throws ProvisioningDescriptionException { return getPackageDir(fpDir, packageName, true); }
throw new ProvisioningDescriptionException("Feature-pack build number has not been set"); final Path fpWorkDir = LayoutUtils.getFeaturePackDir(creator.getWorkDir(), fps.getFPID(), false); final FeaturePackSpec fpSpec; try { for(Map.Entry<ConfigId, ConfigLayerSpec> entry : layers.entrySet()) { final ConfigId id = entry.getKey(); final Path xml = LayoutUtils.getLayerSpecXml(fpWorkDir, id.getModel(), id.getName(), false); if (Files.exists(xml)) { throw new ProvisioningException("Failed to create feature-pack: " + xml + " already exists"); final Path modelXml = LayoutUtils.getConfigXml(fpWorkDir, config.getId(), false); if (Files.exists(modelXml)) { throw new ProvisioningException("Failed to create feature-pack: " + modelXml + " already exists");
private void persistHashes(ProvisioningRuntime runtime) throws ProvisioningException { final long startTime = System.nanoTime(); final FsEntry root = getDefaultFsEntryFactory().forPath(runtime.getStagedDir()); if (root.hasChildren()) { final Path hashes = LayoutUtils.getHashesDir(runtime.getStagedDir()); try { Files.createDirectories(hashes); } catch (IOException e) { throw new ProvisioningException("Failed to persist hashes", e); } final List<FsEntry> dirs = new ArrayList<>(); persistChildHashes(hashes, root, dirs, hashes); if(!dirs.isEmpty()) { for(int i = dirs.size() - 1; i >= 0; --i) { persistDirHashes(hashes, dirs.get(i), dirs); } } } if(log.isVerboseEnabled()) { final long timeMs = (System.nanoTime() - startTime) / 1000000; final long timeSec = timeMs / 1000; log.print("Hashing took %d.%d seconds", timeSec, (timeMs - timeSec * 1000)); } }
ConfigLayerSpec getConfigLayer(ConfigId configId) throws ProvisioningException { if(layers != null) { final ConfigLayerSpec layer = layers.get(configId); if(layer != null) { return layer; } } final Path p = LayoutUtils.getLayerSpecXml(dir, configId.getModel(), configId.getName(), false); if (!Files.exists(p)) { return null; } final ConfigLayerSpec layer = XmlParsers.parseConfigLayerSpec(p, configId.getModel()); if (layers == null) { layers = new HashMap<>(); } layers.put(configId, layer); return layer; }
ConfigModel getConfig(ConfigId configId) throws ProvisioningException { if(configs != null) { final ConfigModel config = configs.get(configId); if(config != null) { return config; } } final Path p = LayoutUtils.getConfigXml(dir, configId, false); if (!Files.exists(p)) { return null; } try (BufferedReader reader = Files.newBufferedReader(p)) { final ConfigModel config = ConfigXmlParser.getInstance().parse(reader); if (configs == null) { configs = new HashMap<>(); } configs.put(config.getId(), config); return config; } catch (Exception e) { throw new ProvisioningException(Errors.parseXml(p), e); } }
final Path hashesDir = LayoutUtils.getHashesDir(getInstallationHome()); if(Files.exists(hashesDir)) { final FsEntry originalState = new FsEntry(null, hashesDir);
public void remove(FeaturePackLocation.FPID fpid) throws ProvisioningException { IoUtils.recursiveDelete(LayoutUtils.getFeaturePackDir(home, fpid, false)); }
public PackageSpec build(Path fpDir) { final PackageSpec pkgSpec = pkg.build(); final Path pkgDir; try { pkgDir = LayoutUtils.getPackageDir(fpDir, pkgSpec.getName(), false); } catch (ProvisioningDescriptionException e) { throw new IllegalStateException(e); } try { Files.createDirectories(pkgDir); if(tasks != null && !tasks.isEmpty()) { tasks.execute(FsTaskContext.builder().setTargetRoot(pkgDir).build()); } PackageXmlWriter.getInstance().write(pkgSpec, pkgDir.resolve(Constants.PACKAGE_XML)); } catch (XMLStreamException | IOException e) { throw new IllegalStateException(e); } return pkgSpec; } }
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); } }
public Path put(Path featurePack, FeaturePackLocation.FPID fpid) throws ProvisioningException { final Path fpDir = LayoutUtils.getFeaturePackDir(home, fpid, false); if (Files.exists(fpDir)) { IoUtils.recursiveDelete(fpDir); } unpack(fpDir, featurePack); overwritePolicy.cached(fpid); return fpDir; }
boolean resolvePackage(String pkgName, ProvisioningRuntimeBuilder rt, PackageRuntime.Builder parent, int type) throws ProvisioningException { PackageRuntime.Builder pkgBuilder = pkgBuilders.get(pkgName); if(pkgBuilder == null) { final Path pkgDir = LayoutUtils.getPackageDir(dir, pkgName, false); if (!Files.exists(pkgDir)) { return false;
String time = props.getProperty(k); long lastUsage = Long.decode(time); Path p = LayoutUtils.getFeaturePackDir(config.getLayoutCache(), FeaturePackLocation.fromString(k).getFPID()); if (!Files.exists(p)) {
public Path put(UniverseResolver universeResolver, FeaturePackLocation fpl) throws ProvisioningException { Path fpDir = LayoutUtils.getFeaturePackDir(home, fpl.getFPID(), false); if (Files.exists(fpDir)) { if (!overwritePolicy.hasExpired(fpDir, fpl.getFPID())) { return fpDir; } IoUtils.recursiveDelete(fpDir); } unpack(fpDir, universeResolver.resolve(fpl)); overwritePolicy.cached(fpl.getFPID()); return fpDir; }
final Path fpDir = LayoutUtils.getFeaturePackDir(handle.getPatchedDir(), f.getFPID(), false); try { Files.createDirectories(fpDir);