private void processRecord(CSVPrinter csvPrinter, TreeNode<Resource> node, List<String> fieldNameOrder)
      throws IOException {

    if (node != null) {
      Resource recordResource = node.getObject();
      if (recordResource != null) {
        List<Object> values = new ArrayList<>();

        if (fieldNameOrder != null) {
          for (String fieldName : fieldNameOrder) {
            values.add(recordResource.getPropertyValue(fieldName));
          }
        } else {
          Map<String, Map<String, Object>> properties = recordResource.getPropertiesMap();
          if (properties != null) {

            for (Map.Entry<String, Map<String, Object>> outer : properties.entrySet()) {
              Map<String, Object> innerProperties = outer.getValue();

              if (innerProperties != null) {
                for (Map.Entry<String, Object> inner : innerProperties.entrySet()) {
                  values.add(inner.getValue());
                }
              }
            }
          }
        }

        if (!values.isEmpty()) {
          csvPrinter.printRecord(values);
        }
      }
    }
  }
Generate a CSV record by processing the resource embedded in the specified node.  The order of
the fields are to be set as specified.

@param csvPrinter     the CSVPrinter used to create the record
@param node           the relevant node in the collection
@param fieldNameOrder a list of field names indicating order
@throws IOException if an error occurs creating the CSV record
ambari-server/src/main/java/org/apache/ambari/server/api/services/serializers/CsvSerializer.java