/// <exception cref="System.Exception"/> private void VerifyACL(CuratorFramework curatorFramework, string path, ACL expectedACL ) { IList <ACL> acls = curatorFramework.GetACL().ForPath(path); Assert.Equal(1, acls.Count); Assert.Equal(expectedACL, acls[0]); }
/// <summary> /// Recursively expand the path into the supplied string builder, increasing /// the indentation by /// <see cref="Indent"/> /// as it proceeds (depth first) down /// the tree /// </summary> /// <param name="builder">string build to append to</param> /// <param name="path">path to examine</param> /// <param name="indent">current indentation</param> private void Expand(StringBuilder builder, string path, int indent) { try { GetChildrenBuilder childrenBuilder = curator.GetChildren(); IList <string> children = childrenBuilder.ForPath(path); foreach (string child in children) { string childPath = path + "/" + child; string body; Stat stat = curator.CheckExists().ForPath(childPath); StringBuilder bodyBuilder = new StringBuilder(256); bodyBuilder.Append(" [").Append(stat.GetDataLength()).Append("]"); if (stat.GetEphemeralOwner() > 0) { bodyBuilder.Append("*"); } if (verbose) { // verbose: extract ACLs builder.Append(" -- "); IList <ACL> acls = curator.GetACL().ForPath(childPath); foreach (ACL acl in acls) { builder.Append(RegistrySecurity.AclToString(acl)); builder.Append(" "); } } body = bodyBuilder.ToString(); // print each child Append(builder, indent, ' '); builder.Append('/').Append(child); builder.Append(body); builder.Append('\n'); // recurse Expand(builder, childPath, indent + Indent); } } catch (Exception e) { builder.Append(e.ToString()).Append("\n"); } }
/// <summary>Get the ACLs of a path</summary> /// <param name="path">path of operation</param> /// <returns>a possibly empty list of ACLs</returns> /// <exception cref="System.IO.IOException"/> public virtual IList <ACL> ZkGetACLS(string path) { CheckServiceLive(); string fullpath = CreateFullPath(path); IList <ACL> acls; try { if (Log.IsDebugEnabled()) { Log.Debug("GetACLS {}", fullpath); } acls = curator.GetACL().ForPath(fullpath); } catch (Exception e) { throw OperationFailure(fullpath, "read()", e); } if (acls == null) { throw new PathNotFoundException(path); } return(acls); }