public IFolderContent GetFolderContent(IEclUri parentFolderUri, int pageIndex, EclItemTypes itemTypes)
        {
            List<IContentLibraryListItem> items = new List<IContentLibraryListItem>();

            if (parentFolderUri.ItemType == EclItemTypes.MountPoint && itemTypes.HasFlag(EclItemTypes.Folder))
            {
                // get photosets
                foreach (FlickrInfo info in Provider.Flickr.GetPhotoSets())
                {
                    items.Add(new ListItem(parentFolderUri.PublicationId, info));
                }

                // oops, no photosets
                if(items.Count == 0)
                {
                    items.Add(new ErrorListItem(parentFolderUri.PublicationId, "There are no public photo sets in this Flickr account."));
                }
            }
            // only return files if they are requested (itemTypes is EclItemTypes.File))
            else if (parentFolderUri.ItemType == EclItemTypes.Folder && parentFolderUri.SubType == "set" && itemTypes.HasFlag(EclItemTypes.File))
            {
                // get photos
                foreach (FlickrInfo info in Provider.Flickr.GetPhotosInSet(parentFolderUri.ItemId))
                {
                    //items.Add(new FlickrPhoto(parentFolderUri.PublicationId, info));
                    items.Add(new ListItem(parentFolderUri.PublicationId, info));
                }
            }

            return Provider.HostServices.CreateFolderContent(parentFolderUri, items, CanGetUploadMultimediaItemsUrl(parentFolderUri.PublicationId), CanSearch(parentFolderUri.PublicationId));
        }
        public IFolderContent GetFolderContent(IEclUri parentFolderUri, int pageIndex, EclItemTypes itemTypes)
        {
            List<IContentLibraryListItem> items = new List<IContentLibraryListItem>();

            // ToDo: consider using async calls for getting users and forms
            if (parentFolderUri.ItemType == EclItemTypes.MountPoint && itemTypes.HasFlag(EclItemTypes.Folder))
            {
                // get users
                foreach (WufooData data in Provider.Wufoo.GetUsers())
                {
                    items.Add(new ListItem(parentFolderUri.PublicationId, data));
                }
            }

            // only return files if they are requested (itemTypes is EclItemTypes.File))
            else if (parentFolderUri.ItemType == EclItemTypes.Folder && parentFolderUri.SubType == "user" && itemTypes.HasFlag(EclItemTypes.File))
            {
                // get forms
                foreach (WufooData data in Provider.Wufoo.GetForms(parentFolderUri.ItemId))
                {
                    items.Add(new ListItem(parentFolderUri.PublicationId, data));
                }
            }

            return Provider.HostServices.CreateFolderContent(parentFolderUri, items, CanGetUploadMultimediaItemsUrl(parentFolderUri.PublicationId), CanSearch(parentFolderUri.PublicationId));
        }
示例#3
0
 public IEclUri CreateEclUri(int publicationId, string mountPointId, string itemId, string subType, EclItemTypes itemType, int? version)
 {
     return new Mock.EclUriMockup()
     {
         PublicationId = publicationId,
         MountPointId = mountPointId,
         ItemId = itemId,
         SubType = subType,
         ItemType = itemType,
         Version = version
     };
 }
示例#4
0
        public IFolderContent GetFolderContent(IEclUri parentFolderUri, int pageIndex, EclItemTypes itemTypes)
        {
            FotoWareProvider.HostServices.LogMessage(LoggingSeverity.Debug,
                string.Format("Getting folder contents for {0}, page index {1} for item types {2}",
                    parentFolderUri.ToString(),
                    pageIndex,
                    itemTypes.ToString()
                )
            );

            List<IContentLibraryListItem> result = new List<IContentLibraryListItem>();

            if(parentFolderUri.ItemType == EclItemTypes.MountPoint && itemTypes.HasFlag(EclItemTypes.Folder))
            {
                result.AddRange(GetRootFolderContent(parentFolderUri));
            }

            bool canUpload = CanGetUploadMultimediaItemsUrl(parentFolderUri.PublicationId);
            bool canSearch = CanSearch(parentFolderUri.PublicationId);
            return FotoWareProvider.HostServices.CreateFolderContent(parentFolderUri, result, canUpload, canSearch);
        }
示例#5
0
        //Search based on Directory
        public List <S3Info> SearchInS3Folders(IEclUri parentFolderUri, EclItemTypes itemTypes, string searchTerm = null)
        {
            List <S3Info>   s3SearchList = new List <S3Info>();
            S3DirectoryInfo s3Root       = null;

            if (parentFolderUri.ItemId == "root")
            {
                s3Root = new S3DirectoryInfo(s3Client, BucketName);
            }
            else
            {
                s3Root = new S3DirectoryInfo(s3Client, BucketName, parentFolderUri.ItemId.Replace('/', '\\').TrimEnd('/'));
            }

            //Search Folder
            foreach (var subdirectories in s3Root.GetDirectories())
            {
                if (subdirectories.Name.Contains(searchTerm))
                {
                    var item    = subdirectories.FullName.Split(':')[1].Replace('\\', '/').TrimStart('/');
                    var itemUrl = FullBucketUrl + item;
                    s3SearchList.Add(new S3Info(subdirectories, itemUrl, "Folder"));
                }
            }

            //Search Files
            foreach (var file in s3Root.GetFiles())
            {
                if (file.Name.Contains(searchTerm))
                {
                    var item    = file.FullName.Split(':')[1].Replace('\\', '/').TrimStart('/');
                    var itemUrl = FullBucketUrl + item;
                    s3SearchList.Add(new S3Info(file, itemUrl, "File"));
                }
            }
            return(s3SearchList);
        }
示例#6
0
        //Whole S3 Bucket Search
        public List <S3Info> SearchInS3(IEclUri parentFolderUri, EclItemTypes itemTypes, string searchTerm = null)
        {
            List <S3Info>      s3SearchList = new List <S3Info>();
            ListObjectsRequest objRequest   = new ListObjectsRequest();

            objRequest.BucketName = BucketName;
            var ItemTypes   = "";
            var returnedKey = "";
            //TODO: This pick all objects/items from s3 to search, where we should target to get object based on folder we are in
            ListObjectsResponse objResponse = s3Client.ListObjects(objRequest);

            foreach (S3Object obS3Object in objResponse.S3Objects)
            {
                if (obS3Object.Size == 0)
                {
                    ItemTypes = "Folder";
                    var nameArray = obS3Object.Key.Split('/');
                    int count     = nameArray.Length;
                    returnedKey = nameArray[count - 2].TrimEnd('/');
                }
                else
                {
                    ItemTypes = "File";
                    var nameArray = obS3Object.Key.Split('/');
                    int count     = nameArray.Length;
                    returnedKey = nameArray[count - 1];
                }
                if (returnedKey.Contains(searchTerm))
                {
                    var itemUrl = FullBucketUrl + obS3Object.Key;
                    s3SearchList.Add(new S3Info(obS3Object, itemUrl, ItemTypes));
                }
            }

            return(s3SearchList);
        }
        public IFolderContent GetFolderContent(IEclUri parentFolderUri, int pageIndex, EclItemTypes itemTypes)
        {
            int totalVideos = 0;
            var items       = new List <IContentLibraryListItem>();

            if (parentFolderUri.ItemType == EclItemTypes.MountPoint && itemTypes.HasFlag(EclItemTypes.Folder))
            {
                items.AddRange(YouTubeProvider.Client.Users.Select(user => new YouTubeListItem(parentFolderUri.PublicationId, user)));
            }

            if (parentFolderUri.ItemType == EclItemTypes.Folder && parentFolderUri.SubType == "usr" && itemTypes.HasFlag(EclItemTypes.File))
            {
                canPaginate = true;
                items.AddRange(YouTubeProvider.Client.GetUploadsForUser(parentFolderUri.ItemId, pageIndex, out totalVideos).Select(v => new YouTubeListItem(parentFolderUri.PublicationId, v)));
            }

            if (pageIndex == 0 && items.Count < 50)
            {
                canPaginate = false;
            }

            if (canPaginate)
            {
                bool isLast = items.Count < 50 || ((pageIndex + 1) * 50 >= totalVideos);
                return(YouTubeProvider.HostServices.CreateFolderContent(parentFolderUri, pageIndex, isLast, items, CanGetUploadMultimediaItemsUrl(parentFolderUri.PublicationId), CanSearch(parentFolderUri.PublicationId)));
            }
            else
            {
                return(YouTubeProvider.HostServices.CreateFolderContent(parentFolderUri, items, CanGetUploadMultimediaItemsUrl(parentFolderUri.PublicationId), CanSearch(parentFolderUri.PublicationId)));
            }
        }
示例#8
0
        /// <summary>
        /// Gets an <see cref="T:Tridion.ExternalContentLibrary.V2.IFolderContent" /> representing the content of an external content folder or mount point. This list is used to build a tree structure when the user browse the content of the external library.
        /// </summary>
        /// <param name="parentFolderUri">The <see cref="T:Tridion.ExternalContentLibrary.V2.IEclUri" /> of the parent item. If <see cref="P:Tridion.ExternalContentLibrary.V2.IEclUri.ItemType" /> is <see cref="F:Tridion.ExternalContentLibrary.V2.EclItemTypes.MountPoint" /> the top level items are requested.</param>
        /// <param name="pageIndex">The 0 based index of the page to retrieve if the folder supports pagination.</param>
        /// <param name="itemTypes">Filters the item types to return. This can be used to for example only retrieve Folders for building up the tree structure.</param>
        /// <returns>
        /// A list of child items that should be displayed under the specified Folder.
        /// </returns>
        /// <remarks>
        /// A provider can use <see cref="M:Tridion.ExternalContentLibrary.V2.IHostServices.CreateFolderContent(Tridion.ExternalContentLibrary.V2.IEclUri,System.Collections.Generic.IList{Tridion.ExternalContentLibrary.V2.IContentLibraryListItem},System.Boolean,System.Boolean)" />
        /// or one of the overloaded methods to initialize an instance of <see cref="T:Tridion.ExternalContentLibrary.V2.IFolderContent" />.
        /// </remarks>
        public IFolderContent GetFolderContent(IEclUri parentFolderUri, int pageIndex, EclItemTypes itemTypes)
        {
            String prefix = parentFolderUri.ItemId == "root" ? String.Empty : parentFolderUri.ItemId;

            IList <IContentLibraryListItem> items = new List <IContentLibraryListItem>();

            foreach (S3ItemData itemData in _provider.S3.GetListing(prefix))
            {
                S3ListItem item = null;

                if (itemData.ItemType == S3ItemType.Folder && itemTypes.HasFlag(EclItemTypes.Folder))
                {
                    item = new S3Folder(_provider, _session, parentFolderUri, itemData);
                }
                else if (itemTypes.HasFlag(EclItemTypes.File))
                {
                    item = new S3File(_provider, _session, parentFolderUri, itemData);
                }

                if (item != null)
                {
                    _provider.Cache(item);
                    items.Add(item);
                }
            }

            return(_session.HostServices.CreateFolderContent(
                       parentFolderUri,
                       items,
                       CanGetUploadMultimediaItemsUrl(parentFolderUri.PublicationId),
                       CanSearch(parentFolderUri.PublicationId)));
        }
示例#9
0
        public IFolderContent GetFolderContent(IEclUri parentFolderUri, int pageIndex, EclItemTypes itemTypes)
        {
            bool canSearch = false;

            if (parentFolderUri.ItemId == "root")
            {
                canSearch = true;
            }
            List <IContentLibraryListItem> items = new List <IContentLibraryListItem>();

            InfoList = S3Provider.S3.GetDirectories(parentFolderUri, itemTypes);
            foreach (S3Info info in InfoList)
            {
                Info = info;
                items.Add(new ListItem(parentFolderUri, info));
            }
            return(S3Provider.HostServices.CreateFolderContent(parentFolderUri, items, CanGetUploadMultimediaItemsUrl(parentFolderUri.PublicationId), canSearch));
        }
示例#10
0
        public IFolderContent GetFolderContent(IEclUri parentFolderUri, int pageIndex, EclItemTypes itemTypes)
        {
            List <IContentLibraryListItem> items = new List <IContentLibraryListItem>();

            // ToDo: consider using async calls for getting users and forms
            if (parentFolderUri.ItemType == EclItemTypes.MountPoint && itemTypes.HasFlag(EclItemTypes.Folder))
            {
                // get users
                foreach (WufooData data in Provider.Wufoo.GetUsers())
                {
                    items.Add(new ListItem(parentFolderUri.PublicationId, data));
                }
            }

            // only return files if they are requested (itemTypes is EclItemTypes.File))
            else if (parentFolderUri.ItemType == EclItemTypes.Folder && parentFolderUri.SubType == "user" && itemTypes.HasFlag(EclItemTypes.File))
            {
                // get forms
                foreach (WufooData data in Provider.Wufoo.GetForms(parentFolderUri.ItemId))
                {
                    items.Add(new ListItem(parentFolderUri.PublicationId, data));
                }
            }

            return(Provider.HostServices.CreateFolderContent(parentFolderUri, items, CanGetUploadMultimediaItemsUrl(parentFolderUri.PublicationId), CanSearch(parentFolderUri.PublicationId)));
        }
示例#11
0
 public IEclUri CreateEclUri(int publicationId, string mountPointId, string itemId, string subType, EclItemTypes itemType)
 {
     return CreateEclUri(publicationId, mountPointId, itemId, subType, itemType, null);
 }
示例#12
0
 public IDisplayType CreateDisplayType(string id, string displayText, EclItemTypes itemType)
 {
     return new Mock.DisplayTypeMockup(id, displayText, itemType);
 }
示例#13
0
        public IFolderContent GetFolderContent(IEclUri parentFolderUri, int pageIndex, EclItemTypes itemTypes)
        {
            List <IContentLibraryListItem> items = new List <IContentLibraryListItem>();

            if (parentFolderUri.ItemType == EclItemTypes.MountPoint && itemTypes.HasFlag(EclItemTypes.Folder))
            {
                // get photosets
                foreach (FlickrInfo info in Provider.Flickr.GetPhotoSets())
                {
                    items.Add(new ListItem(parentFolderUri.PublicationId, info));
                }

                // oops, no photosets
                if (items.Count == 0)
                {
                    items.Add(new ErrorListItem(parentFolderUri.PublicationId, "There are no public photo sets in this Flickr account."));
                }
            }
            // only return files if they are requested (itemTypes is EclItemTypes.File))
            else if (parentFolderUri.ItemType == EclItemTypes.Folder && parentFolderUri.SubType == "set" && itemTypes.HasFlag(EclItemTypes.File))
            {
                // get photos
                foreach (FlickrInfo info in Provider.Flickr.GetPhotosInSet(parentFolderUri.ItemId))
                {
                    //items.Add(new FlickrPhoto(parentFolderUri.PublicationId, info));
                    items.Add(new ListItem(parentFolderUri.PublicationId, info));
                }
            }

            return(Provider.HostServices.CreateFolderContent(parentFolderUri, items, CanGetUploadMultimediaItemsUrl(parentFolderUri.PublicationId), CanSearch(parentFolderUri.PublicationId)));
        }
示例#14
0
        public List <S3Info> GetDirectories(IEclUri parentFolderUri, EclItemTypes itemTypes)
        {
            List <S3Info>    s3List = new List <S3Info>();
            List <S3Info>    myList = new List <S3Info>();
            S3DirectoryInfo  s3Root = null;
            GetObjectRequest getDirObjectRequest = null;

            if (parentFolderUri.ItemId == "root")
            {
                s3Root = new S3DirectoryInfo(s3Client, BucketName);
            }
            else
            {
                s3Root = new S3DirectoryInfo(s3Client, BucketName, parentFolderUri.ItemId.Replace('/', '\\').TrimEnd('/'));
            }



            if (parentFolderUri.ItemType == EclItemTypes.MountPoint && itemTypes.HasFlag(EclItemTypes.Folder) && !itemTypes.HasFlag(EclItemTypes.File))
            {
                foreach (var subdirectories in s3Root.GetDirectories())
                {
                    var item    = subdirectories.FullName.Split(':')[1].Replace('\\', '/').TrimStart('/');
                    var itemUrl = FullBucketUrl + item;
                    myList.Add(new S3Info(subdirectories, itemUrl, "Folder"));
                }
            }


            else if (itemTypes.HasFlag(EclItemTypes.File) && itemTypes.HasFlag(EclItemTypes.Folder))
            {
                foreach (var subdirectories in s3Root.GetDirectories())
                {
                    var item    = subdirectories.FullName.Split(':')[1].Replace('\\', '/').TrimStart('/');
                    var itemUrl = FullBucketUrl + item;
                    myList.Add(new S3Info(subdirectories, itemUrl, "Folder"));
                }
                foreach (var file in s3Root.GetFiles())
                {
                    var item    = file.FullName.Split(':')[1].Replace('\\', '/').TrimStart('/');
                    var itemUrl = FullBucketUrl + item;
                    myList.Add(new S3Info(file, itemUrl, "File"));
                }
            }



            else if (itemTypes.HasFlag(EclItemTypes.Folder))
            {
                foreach (var subdirectories in s3Root.GetDirectories())
                {
                    var item    = subdirectories.FullName.Split(':')[1].Replace('\\', '/').TrimStart('/');
                    var itemUrl = FullBucketUrl + item;
                    myList.Add(new S3Info(subdirectories, itemUrl, "Folder"));
                }
            }


            else if (itemTypes.HasFlag(EclItemTypes.File))
            {
                foreach (var file in s3Root.GetFiles())
                {
                    var item    = file.FullName.Split(':')[1].Replace('\\', '/').TrimStart('/');
                    var itemUrl = FullBucketUrl + item;
                    myList.Add(new S3Info(file, itemUrl, "File"));
                }
            }
            else
            {
                throw new NotSupportedException();
            }
            return(myList);
        }
示例#15
0
        public IFolderContent GetFolderContent(IEclUri parentFolderUri, int pageIndex, EclItemTypes itemTypes)
        {
            List <IContentLibraryListItem> items = new List <IContentLibraryListItem>();

            // If root -> list all root categories
            //
            if (parentFolderUri.ItemType == EclItemTypes.MountPoint && itemTypes.HasFlag(EclItemTypes.Folder))
            {
                items.Add(new TypeItem(parentFolderUri.PublicationId, "Categories"));
                items.Add(new TypeItem(parentFolderUri.PublicationId, "Products"));
            }
            else if (parentFolderUri.ItemType == EclItemTypes.Folder && itemTypes.HasFlag(EclItemTypes.Folder))
            {
                if (parentFolderUri.ItemId.StartsWith("Type_"))
                {
                    if (parentFolderUri.ItemId.Equals("Type_Products"))
                    {
                        foreach (var category in EclProvider.RootCategory.Categories)
                        {
                            if (!String.IsNullOrEmpty(category.CategoryId))
                            {
                                items.Add(new CategoryItem(parentFolderUri.PublicationId, category));
                            }
                        }
                    }
                    else // Type_Categories
                    {
                        /*
                         * List<string> allCategories = EclProvider.GetAllCategoryIds();
                         * foreach ( var categoryId in allCategories )
                         * {
                         *  items.Add(new SelectableCategoryItem(parentFolderUri.PublicationId, categoryId));
                         * }
                         * */
                        var allCategories = EclProvider.GetAllCategories();
                        foreach (var category in allCategories)
                        {
                            items.Add(new SelectableCategoryItem(parentFolderUri.PublicationId, category));
                        }
                    }
                }
                else
                {
                    // TODO: Always use the product catalog for retrieving the category???

                    var parentCategory = EclProvider.GetCategory(parentFolderUri.ItemId);
                    if (parentCategory != null)
                    {
                        foreach (var category in parentCategory.Categories)
                        {
                            if (!String.IsNullOrEmpty(category.CategoryId))
                            {
                                // TODO: Have possibility to have concrete category items for each provider
                                items.Add(new CategoryItem(parentFolderUri.PublicationId, category));
                            }
                        }

                        var products = EclProvider.ProductCatalog.GetProducts(parentFolderUri.ItemId, parentFolderUri.PublicationId);
                        if (products != null)
                        {
                            // TODO: Have some kind of pagination here???

                            // At a leaf category -> list all products in that category
                            //
                            foreach (var product in products)
                            {
                                items.Add(this.CreateProductItem(parentFolderUri.PublicationId, parentCategory, product));
                            }
                        }
                    }
                }
            }

            return(EclProvider.HostServices.CreateFolderContent(parentFolderUri, items, CanGetUploadMultimediaItemsUrl(parentFolderUri.PublicationId), CanSearch(parentFolderUri.PublicationId)));
        }
示例#16
0
 public DisplayTypeMockup(string id, string displayText, EclItemTypes itemType)
 {
     Id = id;
     DisplayText = displayText;
     ItemType = itemType;
 }
        public IFolderContent GetFolderContent(IEclUri parentFolderUri, int pageIndex, EclItemTypes itemTypes)
        {
            List <IContentLibraryListItem> items = new List <IContentLibraryListItem>();
            int numberOfPages = 1;

            // If root -> list all root categories
            //
            if (parentFolderUri.ItemType == EclItemTypes.MountPoint && itemTypes.HasFlag(EclItemTypes.Folder))
            {
                items.Add(new TypeItem(parentFolderUri.PublicationId, "Categories"));
                items.Add(new TypeItem(parentFolderUri.PublicationId, "Products"));
            }
            else if (parentFolderUri.ItemType == EclItemTypes.Folder && itemTypes.HasFlag(EclItemTypes.Folder))
            {
                if (parentFolderUri.ItemId.StartsWith("Type_"))
                {
                    if (parentFolderUri.ItemId.Equals("Type_Products"))
                    {
                        foreach (var category in EclProvider.GetRootCategory(parentFolderUri.PublicationId).Categories)
                        {
                            if (!String.IsNullOrEmpty(category.CategoryId))
                            {
                                items.Add(new CategoryItem(parentFolderUri.PublicationId, category));
                            }
                        }
                    }
                    else // Type_Categories
                    {
                        /*
                         * List<string> allCategories = EclProvider.GetAllCategoryIds();
                         * foreach ( var categoryId in allCategories )
                         * {
                         *  items.Add(new SelectableCategoryItem(parentFolderUri.PublicationId, categoryId));
                         * }
                         */

                        // TODO: Can we somehow build up a structure here instead???
                        // TODO: Have a hook for providers to hook in their variant on the listing here???

                        var allCategories = EclProvider.GetAllCategories(parentFolderUri.PublicationId);
                        foreach (var category in allCategories)
                        {
                            items.Add(new SelectableCategoryItem(parentFolderUri.PublicationId, category));
                        }
                    }
                }
                else
                {
                    // TODO: Always use the product catalog for retrieving the category???

                    var parentCategory = EclProvider.GetCategory(parentFolderUri.ItemId, parentFolderUri.PublicationId);
                    if (parentCategory != null)
                    {
                        foreach (var category in parentCategory.Categories)
                        {
                            if (!String.IsNullOrEmpty(category.CategoryId))
                            {
                                // TODO: Have possibility to have concrete category items for each provider
                                items.Add(new CategoryItem(parentFolderUri.PublicationId, category));
                            }
                        }

                        var result = EclProvider.ProductCatalog.GetProducts(parentFolderUri.ItemId, parentFolderUri.PublicationId, pageIndex);
                        if (result != null)
                        {
                            numberOfPages = result.NumberOfPages;
                            foreach (var product in result.Products)
                            {
                                items.Add(this.CreateProductItem(parentFolderUri.PublicationId, parentCategory, product));
                            }
                        }
                    }
                }
            }

            return(EclProvider.HostServices.CreateFolderContent(parentFolderUri, pageIndex, numberOfPages, items, CanGetUploadMultimediaItemsUrl(parentFolderUri.PublicationId), CanSearch(parentFolderUri.PublicationId)));
        }