示例#1
0
文件: HostNode.cs 项目: lulzzz/simias
        /// <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);
            }
        }
示例#2
0
 /// <summary>
 /// Constructor that creates a LinkNode object from a ShallowNode object.
 /// </summary>
 /// <param name="collection">Collection that the specified Node object belongs to.</param>
 /// <param name="shallowNode">ShallowNode object to create the LinkNode object from.</param>
 public LinkNode(Collection collection, ShallowNode shallowNode) :
     base(collection, shallowNode)
 {
     if (type != NodeTypes.LinkNodeType)
     {
         throw new CollectionStoreException(String.Format("Cannot construct an object type of {0} from an object of type {1}.", NodeTypes.LinkNodeType, type));
     }
 }
示例#3
0
 /// <summary>
 /// Constructor for creating an existing LocalDatabase object from a ShallowNode.
 /// </summary>
 /// <param name="storeObject">Store object that this collection belongs to.</param>
 /// <param name="shallowNode">A ShallowNode object.</param>
 internal LocalDatabase(Store storeObject, ShallowNode shallowNode) :
     base(storeObject, shallowNode)
 {
     if (type != NodeTypes.LocalDatabaseType)
     {
         throw new CollectionStoreException(String.Format("Cannot construct an object type of {0} from an object of type {1}.", NodeTypes.LocalDatabaseType, type));
     }
 }
示例#4
0
文件: HostNode.cs 项目: lulzzz/simias
 /// <summary>
 /// Construct a host node from a shallow node.
 /// </summary>
 /// <param name="collection">The collection the node belongs to.</param>
 /// <param name="shallowNode">The shallow node that represents the HostNode.</param>
 public HostNode(Collection collection, ShallowNode shallowNode)
     :
     base(collection, shallowNode)
 {
     if (!IsType(HostNodeType))
     {
         throw new CollectionStoreException(String.Format("Cannot construct an object type of {0}.", HostNodeType));
     }
 }
示例#5
0
文件: Node.cs 项目: lulzzz/simias
        /// <summary>
        /// Constructor for create an existing Node object from a ShallowNode object.
        /// </summary>
        /// <param name="collection">Collection that the ShallowNode belongs to.</param>
        /// <param name="shallowNode">ShallowNode object to create new Node object from.</param>
        public Node(Collection collection, ShallowNode shallowNode)
        {
            Node node = collection.GetNodeByID(shallowNode.ID);

            if (node == null)
            {
                throw new DoesNotExistException("The specified Node object does not exist.");
            }

            name       = node.name;
            id         = node.id;
            type       = node.type;
            properties = new PropertyList(node.properties);
        }
示例#6
0
文件: HostNode.cs 项目: lulzzz/simias
        /// <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);
        }
示例#7
0
文件: Node.cs 项目: lulzzz/simias
        /// <summary>
        /// Node factory method that constructs a derived Node object type from the specified ShallowNode object.
        /// </summary>
        /// <param name="collection">Collection object associated with the specified Node object.</param>
        /// <param name="shallowNode">ShallowNode object to construct new Node from.</param>
        /// <returns>Downcasts the derived Node object back to a Node that can then be explicitly casted back up.</returns>
        static public Node NodeFactory(Collection collection, ShallowNode shallowNode)
        {
            Node rNode = null;

            switch (shallowNode.Type)
            {
            case "Node":
                rNode = new Node(collection, shallowNode);
                break;

            case "DirNode":
                rNode = new DirNode(collection, shallowNode);
                break;

            case "FileNode":
                rNode = new FileNode(collection, shallowNode);
                break;

            case "LinkNode":
                rNode = new LinkNode(collection, shallowNode);
                break;

            case "StoreFileNode":
                rNode = new StoreFileNode(collection, shallowNode);
                break;

            case "Collection":
                rNode = new Collection(collection.StoreReference, shallowNode);
                break;

            case "Tombstone":
                rNode = new Node(collection, shallowNode);
                break;

            case "LocalDatabase":
                rNode = new LocalDatabase(collection.StoreReference, shallowNode);
                break;

            case "Identity":
                rNode = new Identity(collection, shallowNode);
                break;

            case "Member":
                rNode = new Member(collection, shallowNode);
                break;

            case "Domain":
                rNode = new Domain(collection.StoreReference, shallowNode);
                break;

            case "Policy":
                rNode = new Policy.Policy(collection, shallowNode);
                break;

            case "POBox":
                rNode = new POBox.POBox(collection.StoreReference, shallowNode);
                break;

            case "Subscription":
                rNode = new Subscription(collection, shallowNode);
                break;

            case "NotificationLog":
                rNode = new NotificationLog(collection.StoreReference, shallowNode);
                break;

            default:
                rNode = new Node(collection, shallowNode);
                break;
            }

            return(rNode);
        }
示例#8
0
文件: Domain.cs 项目: lulzzz/simias
 /// <summary>
 /// Constructor for creating an existing Domain object from a ShallowNode.
 /// </summary>
 /// <param name="storeObject">Store object that this collection belongs to.</param>
 /// <param name="shallowNode">A ShallowNode object.</param>
 public Domain(Store storeObject, ShallowNode shallowNode) :
     base(storeObject, shallowNode)
 {
 }
示例#9
0
 /// <summary>
 /// Constructor for create an existing BaseFileNode object from a ShallowNode object.
 /// </summary>
 /// <param name="collection">Collection that the ShallowNode belongs to.</param>
 /// <param name="shallowNode">ShallowNode object to create new BaseFileNode object from.</param>
 internal protected BaseFileNode(Collection collection, ShallowNode shallowNode) :
     base(collection, shallowNode)
 {
 }