public void rebuildDependencies(Topology topology) { ToscaTypeLoader typeLoader = initializeTypeLoader(topology, true); topology.setDependencies(typeLoader.getLoadedDependencies()); }
private void setDependencies(Topology instance, ArchiveRoot archiveRoot) { if (archiveRoot.getArchive().getDependencies() == null) { return; } instance.setDependencies(Sets.newHashSet(archiveRoot.getArchive().getDependencies())); }
public void unloadType(Topology topology, String... types) { // make sure to set the failOnTypeNotFound to false, to deal with topology recovering when a type is deleted from a dependency ToscaTypeLoader typeLoader = initializeTypeLoader(topology, false); for (String type : types) { typeLoader.unloadType(type); } ToscaContext.get().resetDependencies(typeLoader.getLoadedDependencies()); // TODO update csar dependencies also ? topology.setDependencies(typeLoader.getLoadedDependencies()); }
public void updateDependencies(EditionContext context, CSARDependency newDependency) { final Set<CSARDependency> oldDependencies = new HashSet<>(context.getTopology().getDependencies()); final Set<CSARDependency> newDependencies = csarDependencyLoader.getDependencies(newDependency.getName(), newDependency.getVersion()); newDependencies.add(newDependency); // Update context with the new dependencies. newDependencies.forEach(csarDependency -> context.getToscaContext().updateDependency(csarDependency)); // Validate that the dependency change does not induce missing types. try { this.checkForMissingTypes(context.getTopology()); } catch (NotFoundException e) { // Revert changes made to the Context then throw. context.getToscaContext().resetDependencies(oldDependencies); context.getTopology().setDependencies(oldDependencies); throw new VersionConflictException("Changing the dependency [" + newDependency.getName() + "] to version [" + newDependency.getVersion() + "] induces missing types in the topology. Not found : [" + e.getMessage() + "].", e); } // Perform the dependency update on the topology. context.getTopology().setDependencies(new HashSet<>(context.getToscaContext().getDependencies())); }
topology.setDependencies(typeLoader.getLoadedDependencies());