Exemple #1
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)));
        }
Exemple #2
0
        /// <summary>
        /// Performs a search for external Items.
        /// </summary>
        /// <param name="contextUri">The <see cref="T:Tridion.ExternalContentLibrary.V2.IEclUri" /> of the Folder or Mount Point the search should be performed from.</param>
        /// <param name="searchTerm">The term to search for.</param>
        /// <param name="pageIndex">The 0 based index of the page to retrieve if the search result supports pagination.</param>
        /// <param name="numberOfItems">The number of items the user requested as the search result. If the provider supports pagination</param>
        /// <returns>
        /// A list of <see cref="T:Tridion.ExternalContentLibrary.V2.IContentLibraryListItem" /> matching the search term.
        /// </returns>
        /// <remarks>
        /// <para>
        /// This method should only be called when <see cref="M:Tridion.ExternalContentLibrary.V2.IContentLibraryContext.CanSearch(System.Int32)" />, <see cref="P:Tridion.ExternalContentLibrary.V2.IFolderContent.CanSearch" />, or <see cref="M:Tridion.ExternalContentLibrary.V2.IContentLibraryContext.CanSearch(System.Int32)" />
        /// is <c>true</c> for the item identified by the <paramref name="contextUri" />.
        /// </para>
        /// <para>
        /// Ideally the provider should perform the search recursively across all subfolders of the Folder or Mount Point identified by the <paramref name="contextUri" />. The search
        /// should include the title and metadata on the external item.
        /// </para></remarks>
        public IFolderContent Search(IEclUri contextUri, string searchTerm, int pageIndex, int numberOfItems)
        {
            if (searchTerm != null)
            {
                String prefix = contextUri.ItemId == "root" ? String.Empty : contextUri.ItemId;

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

                String term = searchTerm.ToLowerInvariant();

                foreach (S3ItemData itemData in _provider.S3.GetListing(prefix, true))
                {
                    if (itemData.Key.ToLowerInvariant().Contains(term))
                    {
                        S3ListItem item = null;

                        IEclUri parentUri = _provider.GetParentUri(_provider.GetUri(itemData, contextUri));

                        if (itemData.ItemType == S3ItemType.Folder)
                        {
                            item = new S3Folder(_provider, _session, parentUri, itemData);
                        }
                        else
                        {
                            item = new S3File(_provider, _session, parentUri, itemData);
                        }

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

                return(_session.HostServices.CreateFolderContent(contextUri,
                                                                 items,
                                                                 CanGetUploadMultimediaItemsUrl(contextUri.PublicationId),
                                                                 CanSearch(contextUri.PublicationId)));
            }

            throw new NotSupportedException();
        }
Exemple #3
0
        /// <summary>
        /// Gets the item with the specified <see cref="T:Tridion.ExternalContentLibrary.V2.IEclUri" />.
        /// </summary>
        /// <param name="eclUri">The URI specifying the item to get.</param>
        /// <returns>
        /// The <see cref="T:Tridion.ExternalContentLibrary.V2.IContentLibraryItem" /> for the specified URI. If the item is not available or not accessible for the <see cref="T:Tridion.ExternalContentLibrary.V2.ITridionUser" />
        /// of the current <see cref="T:Tridion.ExternalContentLibrary.V2.IEclSession" /> the provider must throw an exception.
        /// </returns>
        /// <remarks>
        /// To check if the user can read an item without having an exception thrown call <see cref="M:Tridion.ExternalContentLibrary.V2.IContentLibraryContext.GetItems(System.Collections.Generic.IList{Tridion.ExternalContentLibrary.V2.IEclUri})" /> with a single item and check if
        /// it is returned.
        /// </remarks>
        public IContentLibraryItem GetItem(IEclUri eclUri)
        {
            S3ListItem item = _provider.Cached(eclUri.ItemId, eclUri);

            if (item == null)
            {
                if (eclUri.ItemType == EclItemTypes.Folder)
                {
                    item = new S3Folder(_provider, _session, eclUri);
                }

                if (eclUri.ItemType == EclItemTypes.File)
                {
                    item = new S3File(_provider, _session, eclUri);
                }

                _provider.Cache(item);
            }

            return(item as IContentLibraryItem);
        }