use of org.alien4cloud.tosca.model.CSARDependency in project alien4cloud by alien4cloud.
the class CsarDependencyLoader method buildDependencyBean.
@Override
@ToscaContextual
public CSARDependency buildDependencyBean(String name, String version) {
CSARDependency newDependency = new CSARDependency(name, version);
Csar csar = ToscaContext.get().getArchive(name, version);
if (csar != null) {
newDependency.setHash(csar.getHash());
}
return newDependency;
}
use of org.alien4cloud.tosca.model.CSARDependency in project alien4cloud by alien4cloud.
the class ArchiveIndexer method indexTopology.
private void indexTopology(final ArchiveRoot archiveRoot, List<ParsingError> parsingErrors, String archiveName, String archiveVersion) {
Topology topology = archiveRoot.getTopology();
if (topology == null || topology.isEmpty()) {
return;
}
topology.setTags(archiveRoot.getArchive().getTags());
if (archiveRoot.hasToscaTypes()) {
// The archive contains types, we assume those types are used in the embedded topology so we add the dependency to this CSAR
CSARDependency selfDependency = new CSARDependency(archiveRoot.getArchive().getName(), archiveRoot.getArchive().getVersion(), archiveRoot.getArchive().getHash());
topology.getDependencies().add(selfDependency);
}
// init the workflows
TopologyContext topologyContext = workflowBuilderService.buildCachedTopologyContext(new TopologyContext() {
@Override
public String getDSLVersion() {
return archiveRoot.getArchive().getToscaDefinitionsVersion();
}
@Override
public Topology getTopology() {
return topology;
}
@Override
public <T extends AbstractToscaType> T findElement(Class<T> clazz, String elementId) {
return ToscaContext.get(clazz, elementId);
}
});
workflowBuilderService.initWorkflows(topologyContext);
parsingErrors.add(new ParsingError(ParsingErrorLevel.INFO, ErrorCode.TOPOLOGY_DETECTED, "", null, "A topology template has been detected", null, archiveName));
topologyServiceCore.saveTopology(topology);
topologySubstitutionService.updateSubstitutionType(topology, archiveRoot.getArchive());
}
use of org.alien4cloud.tosca.model.CSARDependency in project alien4cloud by alien4cloud.
the class ChangeDependencyVersionProcessor method process.
@Override
public void process(Csar csar, Topology topology, ChangeDependencyVersionOperation operation) {
CSARDependency newDependency = new CSARDependency(operation.getDependencyName(), operation.getDependencyVersion());
// Check for missing type and update the topology's dependencies
topologyService.updateDependencies(EditionContextManager.get(), newDependency);
topologyService.recover(topology, newDependency);
}
use of org.alien4cloud.tosca.model.CSARDependency in project alien4cloud by alien4cloud.
the class EditorTopologyRecoveryHelperService method getUpdatedDependencyIfNeeded.
/**
* Update a dependency according to what is currently in the repository
*
* @param initialDependency
* @return
*/
private CSARDependency getUpdatedDependencyIfNeeded(CSARDependency initialDependency) {
CSARDependency updatedDependency = null;
Csar csar = csarService.getOrFail(initialDependency.getName(), initialDependency.getVersion());
if ((StringUtils.isNotBlank(initialDependency.getHash()) || StringUtils.isNotBlank(csar.getHash())) && !Objects.equals(initialDependency.getHash(), csar.getHash())) {
updatedDependency = new CSARDependency(csar.getName(), csar.getVersion(), csar.getHash());
}
return updatedDependency;
}
use of org.alien4cloud.tosca.model.CSARDependency in project alien4cloud by alien4cloud.
the class EditorTopologyRecoveryHelperService method getUpdatedDependencies.
/**
* Return a Set of updated {@link CSARDependency} that have changed since last added in a given topology
*
* @param topology
* @return
*/
public Set<CSARDependency> getUpdatedDependencies(Topology topology) {
Set<CSARDependency> dependencies = topology.getDependencies();
Set<CSARDependency> updatedDependencies = Sets.newHashSet();
for (CSARDependency csarDependency : dependencies) {
CSARDependency updatedDependency = getUpdatedDependencyIfNeeded(csarDependency);
if (updatedDependency != null) {
updatedDependencies.add(updatedDependency);
}
}
return updatedDependencies;
}
Aggregations