Java Code Examples for org.apache.hadoop.util.Shell#getSetOwnerCommand()

The following examples show how to use org.apache.hadoop.util.Shell#getSetOwnerCommand() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileUtil.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Set the ownership on a file / directory. User name and group name
 * cannot both be null.
 * @param file the file to change
 * @param username the new user owner name
 * @param groupname the new group owner name
 * @throws IOException
 */
public static void setOwner(File file, String username,
    String groupname) throws IOException {
  if (username == null && groupname == null) {
    throw new IOException("username == null && groupname == null");
  }
  String arg = (username == null ? "" : username)
      + (groupname == null ? "" : ":" + groupname);
  String [] cmd = Shell.getSetOwnerCommand(arg);
  execCommand(file, cmd);
}
 
Example 2
Source File: FileUtil.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Set the ownership on a file / directory. User name and group name
 * cannot both be null.
 * @param file the file to change
 * @param username the new user owner name
 * @param groupname the new group owner name
 * @throws IOException
 */
public static void setOwner(File file, String username,
    String groupname) throws IOException {
  if (username == null && groupname == null) {
    throw new IOException("username == null && groupname == null");
  }
  String arg = (username == null ? "" : username)
      + (groupname == null ? "" : ":" + groupname);
  String [] cmd = Shell.getSetOwnerCommand(arg);
  execCommand(file, cmd);
}
 
Example 3
Source File: FileUtil.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/**
 * Set the ownership on a file / directory. User name and group name
 * cannot both be null.
 * @param file the file to change
 * @param username the new user owner name
 * @param groupname the new group owner name
 * @throws IOException exception on setOwner
 */
public static void setOwner(File file, String username,
                            String groupname) throws IOException {
  if (username == null && groupname == null) {
    throw new IOException("username == null && groupname == null");
  }
  String arg = (username == null ? "" : username)
      + (groupname == null ? "" : ":" + groupname);
  String [] cmd = Shell.getSetOwnerCommand(arg);
  execCommand(file, cmd);
}