private void checkInputArtifactExist(String inputArtifactId, Topology topology) { if (topology.getInputArtifacts() == null || !topology.getInputArtifacts().containsKey(inputArtifactId)) { throw new NotFoundException("Input Artifact with key [" + inputArtifactId + "] doesn't exist within the topology."); } }
/** * Validate that all input artifacts are filled * * @param topology The topology in process * @param deploymentInputs Input values as specified by a deployer user. Uploaded artifacts are stored in {@link DeploymentInputs#getInputArtifacts()}. * @return */ public List<InputArtifactTask> validate(Topology topology, DeploymentInputs deploymentInputs) { return safe(topology.getInputArtifacts()).entrySet().stream() .filter(inputArtifactEntry -> StringUtils.isBlank(inputArtifactEntry.getValue().getArtifactRef()) && !safe(deploymentInputs.getInputArtifacts()).containsKey(inputArtifactEntry.getKey())) .map(deploymentArtifactEntry -> new InputArtifactTask(deploymentArtifactEntry.getKey(), ArtifactTaskCode.MISSING)).collect(Collectors.toList()); } }
private void processInputArtifact(ArchivePathChecker archivePathResolver, ParsingResult<ArchiveRoot> parsedArchive) { if (hasInputArtifacts(parsedArchive)) { parsedArchive.getResult().getTopology().getInputArtifacts().values().stream() // If artifact reference is null it means it's to be uploaded with the GUI .filter(inputArtifact -> StringUtils.isNotBlank(inputArtifact.getArtifactRef())) .forEach(inputArtifact -> this.processArtifact(archivePathResolver, inputArtifact, parsedArchive)); } }
public static void doWithTopologyArtifacts(Topology topology, DoWithArtifact doWithArtifact) { safe(topology.getInputArtifacts()).values().forEach(doWithArtifact::doWithArtifact); safe(topology.getNodeTemplates()).values().forEach(nodeTemplate -> { safe(nodeTemplate.getArtifacts()).values().forEach(doWithArtifact::doWithArtifact); safe(nodeTemplate.getRelationships()).values() .forEach(relationshipTemplate -> safe(relationshipTemplate.getArtifacts()).values().forEach(doWithArtifact::doWithArtifact)); }); }
if (MapUtils.isNotEmpty(topology.getInputArtifacts())) { topology.getInputArtifacts().values().forEach(inputArtifact -> { if (StringUtils.isNotBlank(inputArtifact.getRepositoryURL()) && repositoriesName.add(inputArtifact.getRepositoryName())) { buffer.append(" ").append(inputArtifact.getRepositoryName()).append(":");
@Override public void process(Csar csar, Topology topology, DeleteInputArtifactOperation operation) { if (!safe(topology.getInputArtifacts()).containsKey(operation.getInputName())) { throw new NotFoundException("Input artifact <" + operation.getInputName() + "> can not be found in the topology."); } DeploymentArtifact inputArtifact = topology.getInputArtifacts().remove(operation.getInputName()); // change the value of concerned node template artifacts for (NodeTemplate nodeTemplate : safe(topology.getNodeTemplates()).values()) { for (DeploymentArtifact dArtifact : safe(nodeTemplate.getArtifacts()).values()) { if (operation.getInputName().equals(InputArtifactUtil.getInputArtifactId(dArtifact))) { InputArtifactUtil.unsetInputArtifact(dArtifact); } } } } }
@Override public void process(Topology topology, FlowExecutionContext context) { ApplicationEnvironment environment = context.getEnvironmentContext() .orElseThrow(() -> new IllegalArgumentException("Input modifier requires an environment context.")).getEnvironment(); DeploymentInputs deploymentInputs = context.getConfiguration(DeploymentInputs.class, InputsModifier.class.getSimpleName()) .orElse(new DeploymentInputs(environment.getTopologyVersion(), environment.getId())); if(deploymentInputs.getInputArtifacts() == null) { deploymentInputs.setInputArtifacts(Maps.newHashMap()); } boolean updated = false; // Cleanup inputs artifacts that does not exists anymore Iterator<Entry<String, DeploymentArtifact>> inputArtifactsIterator = safe(deploymentInputs.getInputArtifacts()).entrySet().iterator(); while (inputArtifactsIterator.hasNext()) { Entry<String, DeploymentArtifact> inputArtifactEntry = inputArtifactsIterator.next(); if (!topology.getInputArtifacts().containsKey(inputArtifactEntry.getKey())) { inputArtifactsIterator.remove(); updated = true; } } processInputArtifacts(topology, deploymentInputs.getInputArtifacts()); // should save if deploymentInput updated if (updated) { context.saveConfiguration(deploymentInputs); } }
public static boolean hasRepositories(String topologyArchiveName, String topologyArchiveVersion, Topology topology) { // we don't support node types in Editor context, just check the node templates for (NodeTemplate node : safe(topology.getNodeTemplates()).values()) { for (DeploymentArtifact artifact : safe(node.getArtifacts()).values()) { // Only consider artifact of the topology if (isInternalRepoArtifact(artifact, topologyArchiveName, topologyArchiveVersion)) { return true; } } for (Interface anInterface : safe(node.getInterfaces()).values()) { for (Operation operation : safe(anInterface.getOperations()).values()) { if (operation.getImplementationArtifact() != null && isInternalRepoArtifact(operation.getImplementationArtifact(), topologyArchiveName, topologyArchiveVersion)) { return true; } } } } return MapUtils.isNotEmpty(topology.getInputArtifacts()) && topology.getInputArtifacts().values().stream() .anyMatch(deploymentArtifact -> StringUtils.isNotBlank(deploymentArtifact.getRepositoryName())); }
private boolean hasInputArtifacts(ParsingResult<ArchiveRoot> parsedArchive) { return parsedArchive.getResult().getTopology() != null && parsedArchive.getResult().getTopology().getInputArtifacts() != null; }
@Override public void process(Csar csar, Topology topology, RenameInputArtifactOperation operation) { if (operation.getNewInputName() == null || operation.getNewInputName().isEmpty() || !operation.getNewInputName().matches("\\w+")) { throw new InvalidNameException("newInputName", operation.getNewInputName(), "\\w+"); } if (safe(topology.getInputArtifacts()).containsKey(operation.getNewInputName())) { throw new AlreadyExistException("Input artifact with name <" + operation.getNewInputName() + "> already exists."); } if (!safe(topology.getInputArtifacts()).containsKey(operation.getInputName())) { throw new NotFoundException("Input artifact with name <" + operation.getInputName() + "> does not exists."); } DeploymentArtifact inputArtifact = topology.getInputArtifacts().remove(operation.getInputName()); topology.getInputArtifacts().put(operation.getNewInputName(), inputArtifact); // change the value of concerned node template artifacts for (NodeTemplate nodeTemplate : safe(topology.getNodeTemplates()).values()) { for (DeploymentArtifact dArtifact : safe(nodeTemplate.getArtifacts()).values()) { InputArtifactUtil.updateInputArtifactIdIfNeeded(dArtifact, operation.getInputName(), operation.getNewInputName()); } } } }
if (topology.getInputArtifacts() != null && !topology.getInputArtifacts().isEmpty()) { allInputArtifact.putAll(topology.getInputArtifacts()); if (MapUtils.isNotEmpty(inputArtifacts)) { allInputArtifact.putAll(inputArtifacts);
if (MapUtils.isNotEmpty(topology.getInputArtifacts())) { Map<String, DeploymentArtifact> inputsArtifactsDefinitions = topology.getInputArtifacts();
@Override protected void processNodeOperation(Csar csar, Topology topology, SetNodeArtifactAsInputOperation operation, NodeTemplate nodeTemplate) { if (safe(nodeTemplate.getArtifacts()).get(operation.getArtifactName()) == null) { throw new NotFoundException("The artifact <" + operation.getArtifactName() + "> cannot be found on node <" + operation.getNodeName() + ">"); } DeploymentArtifact artifact = nodeTemplate.getArtifacts().get(operation.getArtifactName()); if (!safe(topology.getInputArtifacts()).containsKey(operation.getInputName())) { // we have to create the artifact operation.setNewArtifact(true); DeploymentArtifact inputArtifact = new DeploymentArtifact(); inputArtifact.setArchiveName(artifact.getArchiveName()); inputArtifact.setArchiveVersion(artifact.getArchiveVersion()); inputArtifact.setArtifactType(artifact.getArtifactType()); Map<String, DeploymentArtifact> inputArtifacts = topology.getInputArtifacts(); if (inputArtifacts == null) { inputArtifacts = Maps.newHashMap(); topology.setInputArtifacts(inputArtifacts); } inputArtifacts.put(operation.getInputName(), inputArtifact); } InputArtifactUtil.setInputArtifact(artifact, operation.getInputName()); } }
safe(instance.getInputArtifacts()).values().forEach(typeDeploymentArtifactPostProcessor);
if (!parsedArchive.getResult().getTopology().getInputArtifacts().containsKey(inputArtifactId)) {
validateMavenDeploymentArtifact(mavenExtendedComponent); DeploymentArtifact artifact = archiveRoot.getTopology().getInputArtifacts().get("simple_war"); validateSimpleWar(artifact); DeploymentArtifact repositoryArtifact = archiveRoot.getTopology().getInputArtifacts().get("remote_war"); validateRemoteWar(repositoryArtifact);