public static void checkResourceParameters(Resource resource,
      FileSystem dfs) throws IllegalArgumentException, IOException {

    ArrayList<String> actionsAvailable = new ArrayList<String>();
    actionsAvailable.add("create");
    actionsAvailable.add("delete");
    actionsAvailable.add("download");
    ArrayList<String> typesAvailable = new ArrayList<String>();
    typesAvailable.add("file");
    typesAvailable.add("directory");

    if (resource.getAction() == null || !actionsAvailable.contains(resource.getAction())) {
      throw new IllegalArgumentException("Action is not supported.");
    }

    String dfsPath = resource.getTarget();
    String localPath = resource.getSource();
    if (resource.getAction().equals("download")) {
      dfsPath = resource.getSource();
      localPath = resource.getTarget();
    }

    if (dfsPath == null) {
      throw new IllegalArgumentException("Path to resource in HadoopFs must be filled.");
    }

    if (resource.getType() == null || !typesAvailable.contains(resource.getType())) {
      throw new IllegalArgumentException("Type is not supported.");
    }

    // Check consistency for ("type":"file" == file in hadoop)
    if (dfs.isFile(new Path(dfsPath)) && !"file".equals(resource.getType())) {
      throw new IllegalArgumentException(
          "Cannot create a directory " + dfsPath +
              " because file is present on the given path.");
    }
    // Check consistency for ("type":"directory" == directory in hadoop)
    else if (dfs.isDirectory(new Path(dfsPath)) && !"directory".equals(resource.getType())) {
      throw new IllegalArgumentException(
          "Cannot create a file " + dfsPath +
              " because directory is present on the given path.");
    }

    if(localPath != null) {
      File local = new File(localPath);
      if(local.isFile() && !"file".equals(resource.getType())) {
        throw new IllegalArgumentException(
            "Cannot create a directory " + dfsPath +
                " because source " + localPath + "is a file");
      }
      else if(local.isDirectory() && !"directory".equals(resource.getType())) {
        throw new IllegalArgumentException(
            "Cannot create a file " + dfsPath +
                " because source " + localPath + "is a directory");
      }
    }
  }
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