本文整理汇总了Java中org.apache.hadoop.fs.permission.AclStatus.getPermission方法的典型用法代码示例。如果您正苦于以下问题:Java AclStatus.getPermission方法的具体用法?Java AclStatus.getPermission怎么用?Java AclStatus.getPermission使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.fs.permission.AclStatus
的用法示例。
在下文中一共展示了AclStatus.getPermission方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toJsonString
import org.apache.hadoop.fs.permission.AclStatus; //导入方法依赖的package包/类
/** 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;
}
示例2: convert
import org.apache.hadoop.fs.permission.AclStatus; //导入方法依赖的package包/类
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();
}