/**
   * Erase url of removing node from the list of additional nodes of type = removingNode.getType()
   * of the configuration of puppet master, and return this list as row with comma-separated values.
   * For example: given: $additional_builders =
   * "http://builder2.example.com:8080/builder/internal/builder,http://builder3.example.com:8080/builder/internal/builder"
   * removingNode = new NodeConfig(BUILDER, "builder3.example.com") Result =
   * "http://builder2.example.com:8080/builder/internal/builder"
   *
   * @throws IllegalArgumentException if there is no removing node in the list of additional nodes
   * @throws IllegalStateException if additional nodes property isn't found in Codenvy config
   */
  public String getValueWithoutNode(NodeConfig removingNode) throws IllegalArgumentException {
    String additionalNodesProperty = getPropertyNameBy(removingNode.getType());
    List<String> nodesUrls = config.getAllValues(additionalNodesProperty);
    if (nodesUrls == null) {
      throw new IllegalStateException(
          format(
              "Additional nodes property '%s' isn't found in Codenvy config",
              additionalNodesProperty));
    }

    String nodeUrl = getAdditionalNodeUrl(removingNode);
    if (!nodesUrls.contains(nodeUrl)) {
      throw new IllegalArgumentException(
          format("There is no node '%s' in the list of additional nodes", removingNode.getHost()));
    }

    nodesUrls.remove(nodeUrl);

    return on(',').skipNulls().join(nodesUrls);
  }
  /**
   * Construct url of adding node, add it to the list of additional nodes of type =
   * addingNode.getType() of the configuration of puppet master, and return this list as row with
   * comma-separated values. For example: given: $additional_builders =
   * "http://builder2.example.com:8080/builder/internal/builder" addingNode = new
   * NodeConfig(BUILDER, "builder3.example.com") Result =
   * "http://builder2.example.com:8080/builder/internal/builder,http://builder3.example.com:8080/builder/internal/builder"
   *
   * @throws IllegalArgumentException if there is adding node in the list of additional nodes
   * @throws IllegalStateException if additional nodes property isn't found in Codenvy config
   */
  public String getValueWithNode(NodeConfig addingNode)
      throws IllegalArgumentException, IllegalStateException {
    String additionalNodesProperty = getPropertyNameBy(addingNode.getType());
    List<String> nodesUrls = config.getAllValues(additionalNodesProperty);
    if (nodesUrls == null) {
      throw new IllegalStateException(
          format(
              "Additional nodes property '%s' isn't found in Codenvy config",
              additionalNodesProperty));
    }

    String nodeUrl = getAdditionalNodeUrl(addingNode);
    if (nodesUrls.contains(nodeUrl)) {
      throw new IllegalArgumentException(
          format("Node '%s' has been already used", addingNode.getHost()));
    }

    nodesUrls.add(nodeUrl);

    return on(',').skipNulls().join(nodesUrls);
  }
 /**
  * @return link like "http://builder3.example.com:8080/builder/internal/builder", or
  *     "http://runner3.example.com:8080/runner/internal/runner" For example: given: node = new
  *     NodeConfig(BUILDER, "builder2.example.com") Result =
  *     "http://builder2.example.com:8080/builder/internal/builder"
  */
 protected String getAdditionalNodeUrl(NodeConfig node) {
   return format(
       ADDITIONAL_NODE_URL_TEMPLATE, node.getHost(), node.getType().toString().toLowerCase());
 }