Example usage for org.apache.hadoop.fs.permission AclStatus isStickyBit

List of usage examples for org.apache.hadoop.fs.permission AclStatus isStickyBit

Introduction

In this page you can find the example usage for org.apache.hadoop.fs.permission AclStatus isStickyBit.

Prototype

public boolean isStickyBit() 

Source Link

Document

Returns the sticky bit.

Usage

From source file:com.bigstep.datalake.JsonUtil.java

License:Apache License

/** Convert a AclStatus object to a Json string. */
public static String toJsonString(final AclStatus status) {
    if (status == null) {
        return null;
    }//  w w w.  j a  v  a2s.  c o m

    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);

    Gson gson = new Gson();
    return gson.toJson(finalMap);
}