public static void setOwner(Resource resource, FileSystem dfs,
      Path pathHadoop) throws IOException {

    if (!(resource.getOwner() == null && resource.getGroup() == null)) {
      dfs.setOwner(pathHadoop, resource.getOwner(), resource.getGroup());

      // Get the list of sub-directories and files
      HashSet<String> resultSet = new HashSet<String>();
      if (resource.isRecursiveChown())
        resource.fillDirectoryList(dfs, resource.getTarget(), resultSet);
      if(resource.isChangePermissionOnParents())
        resource.fillInParentDirectories(dfs, resource.getTarget(), resultSet);

      for (String path : resultSet) {
        dfs.setOwner(new Path(path), resource.getOwner(), resource.getGroup());
      }
    }
  }
Used to:
  1) copy files/directories from localFS to hadoopFs
  2) create empty
  3) download files/directories from hadoopFs to localFS
files/directories in hadoopFs
contrib/fast-hdfs-resource/src/main/java/org/apache/ambari/fast_hdfs_resource/Resource.java