示例#1
0
        /// <summary>
        /// Creates <see cref="IHierarchyItemAsync"/> instance by path.
        /// </summary>
        /// <param name="path">Item relative path including query string.</param>
        /// <returns>Instance of corresponding <see cref="IHierarchyItemAsync"/> or null if item is not found.</returns>
        public override async Task <IHierarchyItemAsync> GetHierarchyItemAsync(string path)
        {
            path = path.Trim(new[] { ' ', '/' });

            //remove query string.
            int ind = path.IndexOf('?');

            if (ind > -1)
            {
                path = path.Remove(ind);
            }

            IHierarchyItemAsync item = null;

            // Return items from [DAVLocation]/acl/ folder and subfolders.
            item = await AclFactory.GetAclItemAsync(this, path);

            if (item != null)
            {
                return(item);
            }

            // Return items from [DAVLocation]/addressbooks/ folder and subfolders.
            item = CardDavFactory.GetCardDavItem(this, path);
            if (item != null)
            {
                return(item);
            }

            // Return folder that corresponds to [DAVLocation] path. If no DavLocation is defined in config file this is a website root.
            item = DavLocationFolder.GetDavLocationFolder(this, path);
            if (item != null)
            {
                return(item);
            }

            item = await DavFolder.GetFolderAsync(this, path);

            if (item != null)
            {
                return(item);
            }

            item = await DavFile.GetFileAsync(this, path);

            if (item != null)
            {
                return(item);
            }

            Logger.LogDebug("Could not find item that corresponds to path: " + path);

            return(null); // no hierarchy item that corresponds to path parameter was found in the repository
        }
示例#2
0
        /// <summary>
        /// Returns list of folders that contain address books owned by this principal.
        /// </summary>
        /// <remarks>This enables address books discovery owned by current loged-in principal.</remarks>
        public async Task <IEnumerable <IItemCollectionAsync> > GetAddressbookHomeSetAsync()
        {
            string addressbooksUserFolder = string.Format("{0}{1}/", AddressbooksRootFolder.AddressbooksRootFolderPath, context.UserName);

            return(new[] { await DavFolder.GetFolderAsync(context, addressbooksUserFolder) });
        }