/** * 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; }
/** * Add a dependency to the current context. * * @param dependency The dependency to add. */ public void addDependency(CSARDependency dependency) { log.debug("Add dependency to context", dependency); if (dependency.getHash() == null) { // we should try to get the hash from the repository Csar csar = getArchive(dependency.getName(), dependency.getVersion()); dependency.setHash(csar.getHash()); } dependencies.add(dependency); }
@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; } }
dependency.setHash(csar.getHash()); ToscaContext.get().addDependency(dependency);
allDependencies.add(new CSARDependency(csar.getName(), csar.getVersion(), csar.getHash())); CapabilityType capabilityType = toscaTypeSearchService.getElementInDependencies(CapabilityType.class, capabilityDefinition.getType(), allDependencies);
if (dependencies.contains(new CSARDependency(archive.getName(), archive.getVersion(), archive.getHash()))) { ParsingContextExecution.getParsingErrors().add(new ParsingError(ParsingErrorLevel.ERROR, ErrorCode.CSAR_IMPORT_ITSELF, AlienUtils.prefixWith(":", archive.getVersion(), archive.getName()), null, "Import itself", null, null));
/** * From all exposed plugin archives of the location, get the one that are not yet indexed * * @param orchestrator * @param location * @return an object of type {@link ArchiveToIndex} with the indexable archives and the full list of dependencies */ private ArchiveToIndex getArchivesToIndex(Orchestrator orchestrator, Location location) { Set<CSARDependency> dependencies = Sets.newHashSet(); IOrchestratorPlugin orchestratorInstance = (IOrchestratorPlugin) orchestratorPluginService.getOrFail(orchestrator.getId()); ILocationConfiguratorPlugin configuratorPlugin = orchestratorInstance.getConfigurator(location.getInfrastructureType()); List<PluginArchive> allPluginArchives = configuratorPlugin.pluginArchives(); Set<PluginArchive> archivesToIndex = Sets.newHashSet(); for (PluginArchive pluginArchive : safe(allPluginArchives)) { ArchiveRoot archive = pluginArchive.getArchive(); Csar csar = csarService.get(archive.getArchive().getName(), archive.getArchive().getVersion()); String lastParsedHash = null; if (csar == null) { // the archive does not exist into the repository: should be indexed lastParsedHash = archive.getArchive().getHash(); archivesToIndex.add(pluginArchive); } else { // Else, just take the hash lastParsedHash = csar.getHash(); } if (archive.getArchive().getDependencies() != null) { dependencies.addAll(archive.getArchive().getDependencies()); } dependencies.add(new CSARDependency(archive.getArchive().getName(), archive.getArchive().getVersion(), lastParsedHash)); } return new ArchiveToIndex(dependencies, archivesToIndex); }
.getArchive().getHash()); topology.getDependencies().add(selfDependency);
@Override public CSARDependency parse(Node node, ParsingContextExecution context) { CSARDependency dependency = laxImportParser.parse(node, context); if (dependency == null) { return null; } String valueAsString = dependency.getName() + ":" + dependency.getVersion(); String currentArchiveVersion = context.<ArchiveRoot> getRootObj().getArchive().getVersion(); Csar csar = ToscaContext.get().getArchive(dependency.getName(), dependency.getVersion()); log.debug("Import {} {} {}", dependency.getName(), dependency.getVersion(), csar); if (csar == null) { // error is not a blocker, as long as no type is missing we just mark it as a warning. context.getParsingErrors().add(new ParsingError(ParsingErrorLevel.WARNING, ErrorCode.MISSING_DEPENDENCY, "Import definition is not valid", node.getStartMark(), "Specified dependency is not found in Alien 4 Cloud repository.", node.getEndMark(), valueAsString)); return null; } else { if (!VersionUtil.isSnapshot(currentArchiveVersion) && VersionUtil.isSnapshot(dependency.getVersion())) { // the current archive is a released version but depends on a snapshot version context.getParsingErrors().add(new ParsingError(ParsingErrorLevel.ERROR, ErrorCode.SNAPSHOT_DEPENDENCY, "Import definition is not valid", node.getStartMark(), "A released archive cannot depends on snapshots archives.", node.getEndMark(), valueAsString)); } dependency.setHash(csar.getHash()); ToscaContext.get().addDependency(dependency); return dependency; } }
if (!hash.equals(csar.getHash())) { csar.setHash(hash); updateCsar = true;