public static AclEntry ParseAclEntryString()

in AdlsDotNetSDK/Acl/AclEntry.cs [46:90]


        public static AclEntry ParseAclEntryString(string aclEntry, bool removeAcl)
        {
            aclEntry = aclEntry.Trim();
            string[] parts = aclEntry.Split(':');
            if (parts.Length > 4)
            {
                throw new ArgumentException("Invalid AclEntry string: " + aclEntry);
            }
            if (parts.Length == 4 && !parts[0].Equals("default"))
            {
                throw new ArgumentException("Invalid AclEntry string: " + aclEntry);
            }
            int strtPartIndx = 0;
            AclScope scope;
            if (parts.Length == 4) //Because it is of AclScope default
            {
                strtPartIndx++;
                scope = AclScope.Default;
            }
            else
            {
                scope = AclScope.Access;
            }
            AclType aclType = (AclType)Enum.Parse(typeof(AclType), parts[strtPartIndx].Trim());//This will throw exception
            string aclNm = parts[strtPartIndx + 1].Trim();
            if (aclType == AclType.mask && !String.IsNullOrEmpty(aclNm))
            {
                throw new ArgumentException("AclType Mask should not contain userId or group Id");
            }
            if (aclType == AclType.other && !String.IsNullOrEmpty(aclNm))
            {
                throw new ArgumentException("AclType Other should not contain userId or group Id");
            }
            AclAction action = AclAction.None;
            if (!removeAcl)
            {
                AclAction? ac = AclActionExtension.GetAclAction(parts[strtPartIndx + 2].Trim());
                if (ac == null)
                {
                    throw new ArgumentException("Invalid permission in aclentry " + aclEntry);
                }
                action = ac.Value;
            }
            return new AclEntry(aclType, aclNm, scope, action);
        }