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

The following examples show how to use org.apache.hadoop.fs.permission.AclStatus#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: JsonUtil.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/** Convert a AclStatus object to a Json string. */
public static String toJsonString(final AclStatus status) {
  if (status == null) {
    return null;
  }

  final Map<String, Object> m = new TreeMap<String, Object>();
  m.put("owner", status.getOwner());
  m.put("group", status.getGroup());
  m.put("stickyBit", status.isStickyBit());

  final List<String> stringEntries = new ArrayList<>();
  for (AclEntry entry : status.getEntries()) {
    stringEntries.add(entry.toString());
  }
  m.put("entries", stringEntries);

  FsPermission perm = status.getPermission();
  if (perm != null) {
    m.put("permission", toString(perm));
    if (perm.getAclBit()) {
      m.put("aclBit", true);
    }
    if (perm.getEncryptedBit()) {
      m.put("encBit", true);
    }
  }
  final Map<String, Map<String, Object>> finalMap =
      new TreeMap<String, Map<String, Object>>();
  finalMap.put(AclStatus.class.getSimpleName(), m);

  ObjectMapper mapper = new ObjectMapper();
  try {
    return mapper.writeValueAsString(finalMap);
  } catch (IOException ignored) {
  }
  return null;
}
 
Example 2
Source File: PBHelper.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public static GetAclStatusResponseProto convert(AclStatus e) {
  AclStatusProto.Builder builder = AclStatusProto.newBuilder();
  builder.setOwner(e.getOwner())
      .setGroup(e.getGroup()).setSticky(e.isStickyBit())
      .addAllEntries(convertAclEntryProto(e.getEntries()));
  if (e.getPermission() != null) {
    builder.setPermission(convert(e.getPermission()));
  }
  AclStatusProto r = builder.build();
  return GetAclStatusResponseProto.newBuilder().setResult(r).build();
}
 
Example 3
Source File: JsonUtil.java    From big-c with Apache License 2.0 5 votes vote down vote up
/** Convert a AclStatus object to a Json string. */
public static String toJsonString(final AclStatus status) {
  if (status == null) {
    return null;
  }

  final Map<String, Object> m = new TreeMap<String, Object>();
  m.put("owner", status.getOwner());
  m.put("group", status.getGroup());
  m.put("stickyBit", status.isStickyBit());

  final List<String> stringEntries = new ArrayList<>();
  for (AclEntry entry : status.getEntries()) {
    stringEntries.add(entry.toString());
  }
  m.put("entries", stringEntries);

  FsPermission perm = status.getPermission();
  if (perm != null) {
    m.put("permission", toString(perm));
    if (perm.getAclBit()) {
      m.put("aclBit", true);
    }
    if (perm.getEncryptedBit()) {
      m.put("encBit", true);
    }
  }
  final Map<String, Map<String, Object>> finalMap =
      new TreeMap<String, Map<String, Object>>();
  finalMap.put(AclStatus.class.getSimpleName(), m);

  ObjectMapper mapper = new ObjectMapper();
  try {
    return mapper.writeValueAsString(finalMap);
  } catch (IOException ignored) {
  }
  return null;
}
 
Example 4
Source File: PBHelper.java    From big-c with Apache License 2.0 5 votes vote down vote up
public static GetAclStatusResponseProto convert(AclStatus e) {
  AclStatusProto.Builder builder = AclStatusProto.newBuilder();
  builder.setOwner(e.getOwner())
      .setGroup(e.getGroup()).setSticky(e.isStickyBit())
      .addAllEntries(convertAclEntryProto(e.getEntries()));
  if (e.getPermission() != null) {
    builder.setPermission(convert(e.getPermission()));
  }
  AclStatusProto r = builder.build();
  return GetAclStatusResponseProto.newBuilder().setResult(r).build();
}