private String getDefaultFS(ViewContext context) throws HdfsApiException {
    String defaultFS = getProperty(CORE_SITE, DEFAULT_FS_CLUSTER_PROPERTY, DEFAULT_FS_INSTANCE_PROPERTY);

    if (defaultFS == null || defaultFS.isEmpty())
      throw new HdfsApiException("HDFS070 fs.defaultFS is not configured");

    defaultFS = addProtocolIfMissing(defaultFS);

    if (context.getCluster() != null) {
      try {
        URI fsUri = new URI(defaultFS);
        String protocol = fsUri.getScheme();
        String hostWithPort = defaultFS.substring(protocol.length() + 3);

        Boolean webHdfsEnabled = Boolean.valueOf(getProperty(HDFS_SITE, DFS_WEBHDFS_ENABLED));
        Boolean isHttps = DFS_HTTP_POLICY_HTTPS_ONLY.equals(getProperty(HDFS_SITE, DFS_HTTP_POLICY));

        boolean isHA = isHAEnabled(defaultFS);

        if (webHdfsEnabled && isHttps && "hdfs".equals(protocol)) {
          protocol = "swebhdfs";
          String httpAddr = getProperty(HDFS_SITE, DFS_NAMENODE_HTTPS_ADDERSS);
          if (!isHA && httpAddr != null) hostWithPort = httpAddr;
        } else if (webHdfsEnabled && "hdfs".equals(protocol)) {
          protocol = "webhdfs";
          String httpsAddr = getProperty(HDFS_SITE, DFS_NAMENODE_HTTP_ADDERSS);
          if (!isHA) hostWithPort = httpsAddr;
        }

        return protocol + "://" + hostWithPort;
      } catch (URISyntaxException e) {
        throw new HdfsApiException("Invalid URI format." + e.getMessage(), e);
      }
    }
    return defaultFS;
  }
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