/// <summary> /// Gets the local host /// </summary> /// <returns>Hostnode with local host details</returns> public static HostNode GetLocalHost() { Store store = Store.GetStore(); Domain domain = null; // this might given an exception if the Default Domain is not set up. // this is true when the entire iFolder store is restored - so the try/catch // Need to find a better way to fix this without try/catch - FIXME try { domain = store.GetDomain(store.DefaultDomain); ICSList searchList = domain.Search(LocalHostTag, Syntax.Boolean, SearchOp.Exists); if (searchList.Count == 1) { IEnumerator list = searchList.GetEnumerator(); list.MoveNext(); ShallowNode sn = (ShallowNode)list.Current; return(new HostNode(domain.GetNodeByID(sn.ID))); } else if (!Store.IsEnterpriseServer) { return(domain.Host); } return(null); } catch { return(null); } }
/// <summary> /// Returns whether this DirNode object contains children. /// </summary> /// <param name="collection">Collection object that this object belongs to.</param> /// <returns>True if DirNode object contains children, otherwise false is returned.</returns> public bool HasChildren(Collection collection) { ICSList results = collection.Search(PropertyTags.Parent, new Relationship(collection.ID, id)); ICSEnumerator e = results.GetEnumerator() as ICSEnumerator; bool hasChildren = e.MoveNext(); e.Dispose(); return(hasChildren); }
/// <summary> /// Gets the specified Member object. /// </summary> /// <param name="userID">User ID of the member to find.</param> /// <returns>The Member object represented by the specified user guid.</returns> public Member GetMember(string userID) { ICSList list = collection.Search(PropertyTags.Ace, userID, SearchOp.Begins); ICSEnumerator e = list.GetEnumerator() as ICSEnumerator; Member member = e.MoveNext() ? new Member(collection, e.Current as ShallowNode) : null; e.Dispose(); return(member); }
/// <summary> /// Gets the hosts available in a domain /// </summary> /// <param name="domainId">Domain ID</param> /// <returns>Array of HostNode</returns> public static HostNode[] GetHosts(string domainId) { Domain domain = Store.GetStore().GetDomain(domainId); ICSList snHosts = domain.GetNodesByType(HostNodeType); ArrayList hosts = new ArrayList(); foreach (ShallowNode sn in snHosts) { HostNode hn = new HostNode(domain.GetNodeByID(sn.ID)); hosts.Add(hn); } return((HostNode[])hosts.ToArray(typeof(HostNode))); }
/// <summary> /// Gets the master in a domain /// </summary> /// <param name="domainId">Domain ID for which master details needed</param> /// <returns>Returns the HostNode of master</returns> public static HostNode GetMaster(string domainId) { Domain domain = Store.GetStore().GetDomain(domainId); ICSList searchList = domain.Search(PropertyTags.MasterHost, Syntax.Boolean, SearchOp.Exists); if (searchList.Count == 1) { IEnumerator list = searchList.GetEnumerator(); list.MoveNext(); ShallowNode sn = (ShallowNode)list.Current; return(new HostNode(domain.GetNodeByID(sn.ID))); } return(null); }