Java Code Examples for org.apache.hadoop.fs.permission.FsPermission#getEncryptedBit()

The following examples show how to use org.apache.hadoop.fs.permission.FsPermission#getEncryptedBit() . 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 HdfsFileStatus object to a Json string. */
public static String toJsonString(final HdfsFileStatus status,
    boolean includeType) {
  if (status == null) {
    return null;
  }
  final Map<String, Object> m = new TreeMap<String, Object>();
  m.put("pathSuffix", status.getLocalName());
  m.put("type", PathType.valueOf(status));
  if (status.isSymlink()) {
    m.put("symlink", status.getSymlink());
  }

  m.put("length", status.getLen());
  m.put("owner", status.getOwner());
  m.put("group", status.getGroup());
  FsPermission perm = status.getPermission();
  m.put("permission", toString(perm));
  if (perm.getAclBit()) {
    m.put("aclBit", true);
  }
  if (perm.getEncryptedBit()) {
    m.put("encBit", true);
  }
  m.put("accessTime", status.getAccessTime());
  m.put("modificationTime", status.getModificationTime());
  m.put("blockSize", status.getBlockSize());
  m.put("replication", status.getReplication());
  m.put("fileId", status.getFileId());
  m.put("childrenNum", status.getChildrenNum());
  m.put("storagePolicy", status.getStoragePolicy());
  ObjectMapper mapper = new ObjectMapper();
  try {
    return includeType ?
        toJsonString(FileStatus.class, m) : mapper.writeValueAsString(m);
  } catch (IOException ignored) {
  }
  return null;
}
 
Example 2
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 3
Source File: JsonUtil.java    From big-c with Apache License 2.0 5 votes vote down vote up
/** Convert a HdfsFileStatus object to a Json string. */
public static String toJsonString(final HdfsFileStatus status,
    boolean includeType) {
  if (status == null) {
    return null;
  }
  final Map<String, Object> m = new TreeMap<String, Object>();
  m.put("pathSuffix", status.getLocalName());
  m.put("type", PathType.valueOf(status));
  if (status.isSymlink()) {
    m.put("symlink", status.getSymlink());
  }

  m.put("length", status.getLen());
  m.put("owner", status.getOwner());
  m.put("group", status.getGroup());
  FsPermission perm = status.getPermission();
  m.put("permission", toString(perm));
  if (perm.getAclBit()) {
    m.put("aclBit", true);
  }
  if (perm.getEncryptedBit()) {
    m.put("encBit", true);
  }
  m.put("accessTime", status.getAccessTime());
  m.put("modificationTime", status.getModificationTime());
  m.put("blockSize", status.getBlockSize());
  m.put("replication", status.getReplication());
  m.put("fileId", status.getFileId());
  m.put("childrenNum", status.getChildrenNum());
  m.put("storagePolicy", status.getStoragePolicy());
  ObjectMapper mapper = new ObjectMapper();
  try {
    return includeType ?
        toJsonString(FileStatus.class, m) : mapper.writeValueAsString(m);
  } catch (IOException ignored) {
  }
  return null;
}
 
Example 4
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;
}