/** * Create from masked and unmasked modes. */ public static FsCreateModes create(FsPermission masked, FsPermission unmasked) { assert masked.getUnmasked() == null; assert unmasked.getUnmasked() == null; return new FsCreateModes(masked, unmasked); }
/** * Create from unmasked mode and umask. * * If the mode is already an FsCreateModes object, return it. */ public static FsPermission applyUMask(FsPermission mode, FsPermission umask) { if (mode.getUnmasked() != null) { return mode; } return create(mode.applyUMask(umask), mode); }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + getUnmasked().hashCode(); return result; } }
static FsPermission addExecutePermissionToOwner(FsPermission fsPermission) { FsAction newOwnerAction = fsPermission.getUserAction().or(FsAction.EXECUTE); return new FsPermission(newOwnerAction, fsPermission.getGroupAction(), fsPermission.getOtherAction()); }
/** * Get the default permission for file. */ public static FsPermission getFileDefault() { return new FsPermission((short)00666); }
/** * Get permission for file status. * * @param status Status. * @return Permission. */ private String permission(FileStatus status) { FsPermission perm = status.getPermission(); return "0" + perm.getUserAction().ordinal() + perm.getGroupAction().ordinal() + perm.getOtherAction().ordinal(); }
/** * Returns the FsPermission in an octal format. * * @return short Unlike {@link #toShort()} which provides a binary * representation, this method returns the standard octal style permission. */ public short toOctal() { int n = this.toShort(); int octal = (n>>>9&1)*1000 + (n>>>6&7)*100 + (n>>>3&7)*10 + (n&7); return (short)octal; }
/** * * @return the umask of this FileContext */ public FsPermission getUMask() { return (umask != null ? umask : FsPermission.getUMask(conf)); }
/** * Sets permission. * @param permission if permission is null, default value is set */ protected void setPermission(FsPermission permission) { this.permission = (permission == null) ? FsPermission.getFileDefault() : permission; }
@Override public boolean hasStickyBit(FsPermission permission) { return permission.getStickyBit(); }
@Override public boolean apply(AclEntry input) { if (input.getName() == null) { return true; } return false; } });
/** * Construct by the given mode. * @param mode * @see #toShort() */ public FsPermission(short mode) { fromShort(mode); }
/** * Builds a new AclStatus populated with the set properties. * * @return AclStatus new AclStatus */ public AclStatus build() { return new AclStatus(owner, group, stickyBit, entries, permission); } }
/** * Construct by given mode, either in octal or symbolic format. * @param mode mode as a string, either in octal or symbolic format * @throws IllegalArgumentException if <code>mode</code> is invalid */ public FsPermission(String mode) { this(new RawParser(mode).getPermission()); }
protected FsPermission getPermission() { if (permission == null) { permission = FsPermission.getFileDefault(); } return permission; }
@Override public boolean apply(AclEntry input) { if (input.getName() == null) { return true; } return false; } });