private void setMaxProvisioningFailures(Form form, String nodeindex, Node node)
      throws ValidationException {

    String value =
        form.getFirstValue("node--" + nodeindex + "--max--provisioning--failures--value", "0");
    node.setMaxProvisioningFailures(parseMaxProvisioningFailures(value));
  }
  private void parseNodeMapping() throws ValidationException {

    DeploymentModule module = castToModule();
    module.getNodes().clear();

    Set<String> formitems = getForm().getNames();

    // will contain the mapping between nodeindex and mappings
    // (parameter mapping)
    HashMap<String, List<String>> nodeMappingList = new HashMap<String, List<String>>();
    // will contain the mapping between nodeindex and node shortname
    HashMap<String, String> indexToNode = new HashMap<String, String>();

    // items should be encoded as:
    // node--[nodeindex]--mappingstable--[mappingindex]--[value]
    // Or node--[index]--shortname
    // We start by extracting the node indices and the mappings
    for (String item : formitems.toArray(new String[0])) {
      if (item.startsWith("node--")) {
        String nodeindex = item.split("--")[1]; // get the nodeindex
        // Extract the node indexes
        if (item.endsWith("--shortname")) {
          String shortName = getForm().getFirstValue(item);
          indexToNode.put(nodeindex, shortName);
          List<String> mapping = nodeMappingList.get(nodeindex);
          if (mapping == null) {
            mapping = new ArrayList<String>();
          }
          nodeMappingList.put(nodeindex, mapping);
          continue;
        }
        if (item.contains("--mappingtable--")) {
          List<String> mapping = nodeMappingList.get(nodeindex);
          if (mapping == null) {
            mapping = new ArrayList<String>();
          }
          String mappingIndex = item.split("--")[3];
          mapping.add(mappingIndex);
          nodeMappingList.put(nodeindex, mapping);
        }
      }
    }

    // Iterate over the local structure and extract the corresponding
    // data from the form
    for (Entry<String, List<String>> nodeentry : nodeMappingList.entrySet()) {
      String nodeindex = nodeentry.getKey();
      String shortname = getForm().getFirstValue("node--" + nodeindex + "--shortname");

      if (shortname == null) {
        throw (new ValidationException("Missing node shortname"));
      }

      Node node = createNode(nodeindex, shortname);

      if (module.parametersContainKey(shortname)) {
        throw (new ValidationException(
            "Node short names must be unique. '"
                + shortname.replace("<", "&lt;")
                + "' is already defined"));
      }

      for (String mappingindex : nodeentry.getValue()) {
        String input =
            getForm()
                .getFirstValue(
                    "node--" + nodeindex + "--mappingtable--" + mappingindex + "--input");
        if (input == null) {
          throw (new ValidationException(
              "Node " + node.getName() + " contains an empty input parameter"));
        }
        String output =
            getForm()
                .getFirstValue(
                    "node--" + nodeindex + "--mappingtable--" + mappingindex + "--output");
        if (output == null) {
          throw (new ValidationException(
              "Node " + node.getName() + " is missing a linked parameter for " + input));
        }
        if (output.startsWith(shortname + RuntimeParameter.NODE_PROPERTY_SEPARATOR)) {
          throw (new ValidationException("Output parameters cannot refer to their own node"));
        }
        node.setParameterMapping(new NodeParameter(input, output, ""));
      }

      setMultiplicity(getForm(), nodeindex, node);

      setCloudService(getForm(), nodeindex, node);

      setMaxProvisioningFailures(getForm(), nodeindex, node);

      module.setNode(node);
    }
  }
  private void setMultiplicity(Form form, String nodeindex, Node node) throws ValidationException {

    String multiplicityValue =
        form.getFirstValue("node--" + nodeindex + "--multiplicity--value", "1");
    node.setMultiplicity(parseMultiplicity(multiplicityValue));
  }
 private void setCloudService(Form form, String nodeindex, Node node) {
   String cloudServiceValue =
       form.getFirstValue("node--" + nodeindex + "--cloudservice--value", "default");
   node.setCloudService(cloudServiceValue);
 }