/** Inject input artifacts in the corresponding nodes. */
  public void processInputArtifacts(DeploymentTopology topology) {
    if (topology.getInputArtifacts() != null && !topology.getInputArtifacts().isEmpty()) {
      // we'll build a map inputArtifactId -> List<DeploymentArtifact>
      Map<String, List<DeploymentArtifact>> artifactMap = Maps.newHashMap();
      // iterate over nodes in order to remember all nodes referencing an input artifact
      for (NodeTemplate nodeTemplate : topology.getNodeTemplates().values()) {
        if (nodeTemplate.getArtifacts() != null && !nodeTemplate.getArtifacts().isEmpty()) {
          for (DeploymentArtifact da : nodeTemplate.getArtifacts().values()) {
            String inputArtifactId = InputArtifactUtil.getInputArtifactId(da);
            if (inputArtifactId != null) {
              List<DeploymentArtifact> das = artifactMap.get(inputArtifactId);
              if (das == null) {
                das = Lists.newArrayList();
                artifactMap.put(inputArtifactId, das);
              }
              das.add(da);
            }
          }
        }
      }

      for (Map.Entry<String, DeploymentArtifact> e : topology.getInputArtifacts().entrySet()) {
        List<DeploymentArtifact> nodeArtifacts = artifactMap.get(e.getKey());
        if (nodeArtifacts != null) {
          for (DeploymentArtifact nodeArtifact : nodeArtifacts) {
            nodeArtifact.setArtifactRef(e.getValue().getArtifactRef());
            nodeArtifact.setArtifactName(e.getValue().getArtifactName());
          }
        }
      }
    }
  }