private void copyPropertyIfExists(String type, String key) {
    String value;

    if (context.getCluster() != null) {
      value = context.getCluster().getConfigurationValue(type, key);
      if (value != null) {
        conf.set(key, value);
        LOG.debug("set " + key + " = " + value);
      } else {
        LOG.debug("No such property " + type + "/" + key);
      }
    } else {
      LOG.debug("No such property " + type + "/" + key);
    }
  }
takes context and any extra custom properties that needs to be included into config
@param context
@param customProperties
contrib/views/utils/src/main/java/org/apache/ambari/view/utils/hdfs/ConfigurationBuilder.java