public static FsPermission parseFsPermission ( String permissions ) throws IllegalArgumentException { try { // Octal or symbolic representation return new FsPermission ( permissions ) ; } catch ( IllegalArgumentException e ) { // FsPermission.valueOf will work with unix style permissions which is 10 characters // where the first character says the type of file if ( permissions . length ( ) == 9 ) { // This means it is a posix standard without the first character for file type // We will simply set it to '-' suggesting regular file permissions = "-" + permissions ; } // Try to parse unix style format. return FsPermission . valueOf ( permissions ) ; } }
Parse String representation of permissions into HDFS FsPermission class .