Java Code Examples for org.apache.hadoop.fs.permission.PermissionStatus#getPermission()

The following examples show how to use org.apache.hadoop.fs.permission.PermissionStatus#getPermission() . 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: FSDirMkdirOp.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private static PermissionStatus addImplicitUwx(PermissionStatus parentPerm,
    PermissionStatus perm) {
  FsPermission p = parentPerm.getPermission();
  FsPermission ancestorPerm = new FsPermission(
      p.getUserAction().or(FsAction.WRITE_EXECUTE),
      p.getGroupAction(),
      p.getOtherAction());
  return new PermissionStatus(perm.getUserName(), perm.getGroupName(),
      ancestorPerm);
}
 
Example 2
Source File: FSImageLoader.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Return the JSON formatted ACL status of the specified file.
 * @param path a path specifies a file
 * @return JSON formatted AclStatus
 * @throws IOException if failed to serialize fileStatus to JSON.
 */
String getAclStatus(String path) throws IOException {
  PermissionStatus p = getPermissionStatus(path);
  List<AclEntry> aclEntryList = getAclEntryList(path);
  FsPermission permission = p.getPermission();
  AclStatus.Builder builder = new AclStatus.Builder();
  builder.owner(p.getUserName()).group(p.getGroupName())
      .addEntries(aclEntryList).setPermission(permission)
      .stickyBit(permission.getStickyBit());
  AclStatus aclStatus = builder.build();
  return JsonUtil.toJsonString(aclStatus);
}
 
Example 3
Source File: FSDirMkdirOp.java    From big-c with Apache License 2.0 5 votes vote down vote up
private static PermissionStatus addImplicitUwx(PermissionStatus parentPerm,
    PermissionStatus perm) {
  FsPermission p = parentPerm.getPermission();
  FsPermission ancestorPerm = new FsPermission(
      p.getUserAction().or(FsAction.WRITE_EXECUTE),
      p.getGroupAction(),
      p.getOtherAction());
  return new PermissionStatus(perm.getUserName(), perm.getGroupName(),
      ancestorPerm);
}
 
Example 4
Source File: FSImageLoader.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Return the JSON formatted ACL status of the specified file.
 * @param path a path specifies a file
 * @return JSON formatted AclStatus
 * @throws IOException if failed to serialize fileStatus to JSON.
 */
String getAclStatus(String path) throws IOException {
  PermissionStatus p = getPermissionStatus(path);
  List<AclEntry> aclEntryList = getAclEntryList(path);
  FsPermission permission = p.getPermission();
  AclStatus.Builder builder = new AclStatus.Builder();
  builder.owner(p.getUserName()).group(p.getGroupName())
      .addEntries(aclEntryList).setPermission(permission)
      .stickyBit(permission.getStickyBit());
  AclStatus aclStatus = builder.build();
  return JsonUtil.toJsonString(aclStatus);
}
 
Example 5
Source File: TestDistCh.java    From RDFS with Apache License 2.0 5 votes vote down vote up
static void checkFileStatus(PermissionStatus expected, FileStatus actual) {
  assertEquals(expected.getUserName(), actual.getOwner());
  assertEquals(expected.getGroupName(), actual.getGroup());
  FsPermission perm = expected.getPermission(); 
  if (!actual.isDir()) {
    perm = perm.applyUMask(UMASK);
  }
  assertEquals(perm, actual.getPermission());
}
 
Example 6
Source File: TestDistCh.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
static void checkFileStatus(PermissionStatus expected, FileStatus actual) {
  assertEquals(expected.getUserName(), actual.getOwner());
  assertEquals(expected.getGroupName(), actual.getGroup());
  FsPermission perm = expected.getPermission(); 
  if (!actual.isDir()) {
    perm = perm.applyUMask(UMASK);
  }
  assertEquals(perm, actual.getPermission());
}