public Set<ConfigId> loadLayers() throws ProvisioningException, IOException { Path layersDir = getDir().resolve(Constants.LAYERS); if (!Files.exists(layersDir)) { return Collections.emptySet(); } Set<ConfigId> layers = new HashSet<>(); Files.walkFileTree(layersDir, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (file.getFileName().toString().equals(Constants.LAYER_SPEC_XML)) { ConfigId id; Path rootDir = file.getParent().getParent(); // No model if (rootDir.equals(layersDir)) { id = new ConfigId(null, file.getParent().getFileName().toString()); } else { id = new ConfigId(rootDir.getFileName().toString(), file.getParent().getFileName().toString()); } layers.add(id); } return FileVisitResult.CONTINUE; } }); return layers; }
public ConfigLayerSpec loadConfigLayerSpec(String model, String name) throws ProvisioningException { final Path specXml; if (model == null) { specXml = getDir().resolve(Constants.LAYERS).resolve(name).resolve(Constants.LAYER_SPEC_XML); } else { specXml = getDir().resolve(Constants.LAYERS).resolve(model).resolve(name).resolve(Constants.LAYER_SPEC_XML); } if (!Files.exists(specXml)) { return null; } try (BufferedReader reader = Files.newBufferedReader(specXml)) { return ConfigLayerSpecXmlParser.getInstance().parse(reader); } catch (Exception e) { throw new ProvisioningDescriptionException(Errors.parseXml(specXml), e); } }
@Override public F transform(O other) throws ProvisioningException { return fpFactory.newFeaturePack(other.getFPID().getLocation(), other.getSpec(), other.getDir(), other.getType()); } });
final List<F> patches = fpPatches.get(f.getFPID()); if(patches == null) { final Path fpResources = f.getDir().resolve(Constants.RESOURCES); if (Files.exists(fpResources)) { patchDir(getResources(), fpResources); final Path fpPlugins = f.getDir().resolve(Constants.PLUGINS); if (Files.exists(fpPlugins)) { patchDir(getPluginsDir(), fpPlugins); try { Files.createDirectories(fpDir); IoUtils.copy(f.getDir(), fpDir); } catch (IOException e) { throw new ProvisioningException("Failed to patch feature-pack dir for " + f.getFPID(), e); final Path patchDir = patch.getDir(); patchFpDir(fpDir, patchDir, Constants.PACKAGES); patchFpDir(fpDir, patchDir, Constants.FEATURES);
for(F p : queue) { layout(p.getSpec(), branch, FeaturePackLayout.TRANSITIVE_DEP); handle.copyResources(p.getDir()); ordered.add(p);