Ejemplo n.º 1
0
        /// <summary>
        /// Initialize a new <see cref="S3ListItem" />
        /// </summary>
        /// <param name="provider">Associated <see cref="S3Provider"/></param>
        /// <param name="session">Current <see cref="T:Tridion.ExternalContentLibrary.V2.IEclSession"/></param>
        /// <param name="parentUri"><see cref="Tridion.ExternalContentLibrary.V2.IEclUri" /></param>
        /// <param name="eclObject"><see cref="Amazon.S3.Model.S3Object"/></param>
        /// <remarks>Creating a <see cref="S3ListItem" /> directly from an <see cref="T:S3ECLProvider.API.S3ItemData"/></remarks>
        public S3ListItem(S3Provider provider, IEclSession session, IEclUri parentUri, S3ItemData eclObject)
        {
            Provider = provider;
            Session  = session;
            ParentId = parentUri;

            _itemData = eclObject;
            Id        = provider.GetUri(_itemData, parentUri);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initialize a new <see cref="S3ListItem" />
        /// </summary>
        /// <param name="provider">Associated <see cref="S3Provider"/></param>
        /// <param name="session">Current <see cref="T:Tridion.ExternalContentLibrary.V2.IEclSession"/></param>
        /// <param name="uri"><see cref="Tridion.ExternalContentLibrary.V2.IEclUri" /></param>
        public S3ListItem(S3Provider provider, IEclSession session, IEclUri uri)
        {
            Provider = provider;
            Session  = session;
            ParentId = provider.GetParentUri(uri);

            if (uri.ItemType == EclItemTypes.Folder)
            {
                _itemData = provider.S3.GetFolder(uri.ItemId);
            }
            else
            {
                _itemData = provider.S3.GetObject(uri.ItemId);
            }

            Id = provider.GetUri(_itemData, uri);
        }
Ejemplo n.º 3
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();
        }