+1-888-365-2779
Try Now
More in this section

Forums / Sitefinity SDK / Custom Amazon Libraries-Provider

Custom Amazon Libraries-Provider

6 posts, 0 answered
  1. Dave
    Dave avatar
    37 posts
    Registered:
    26 Dec 2008
    25 Feb 2011
    Link to this post
    Hi!

    I'm trying to write a Custom Libraries-Provider. The Libraries and Albums should be stored in the databases as they are now, also the Information about the Images, Videos, Documents (Title, Description, etc). But the files should be uploaded to Amazon-Cloudfront/S3.

    Since I want to use the existing Save-Functions to database, I've created a Custom-Provider that inherits from OpenAccessLibrariesProvider and a Custom-Manager that inherits from ContentManagerBase<MyAmazonprovider>.

    In the Administration-Section I've registered the new Provider, which works fine. Also I used the "ItemToManagerMapping" to map "Telerik.Sitefinity.Libraries.Model.Image, Document, Library, and so on" to the Manager.

    It seems that the Manager dosn't work. I've tried to change some functions and also tried to throw an exception f.e. from GetImage, but without luck. Am I missing something? Do I have to register the Manger somewhere else?

    Any help would be greatly appreciated.

    Thanks in adcance.

    Dieter
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    19 Sep 2016
    08 Mar 2011
    Link to this post
    Hi Dieter,

    1. Please make sure that the provider is properly registered inside Sitefinity/Administration/Settings/Advanced/ Libraries/Providers. After you register the provider, please restart the application.

    2. Please send sample implementation of the data provider, manager and the way that you call the manger.


    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. Dave
    Dave avatar
    37 posts
    Registered:
    26 Dec 2008
    10 Mar 2011
    Link to this post
    Hello Ivan!

    Thank you, for you answer.

    Here's my code for the provider. I commented out the "child.Provider = this", because I'm getting an error, that this class has no access to the private property "Provider" of the child. I did not find a method to define the Provider.
    025.namespace ProChrist.Provider.Libraries.Amazon
    026.{
    027.    [ContentProviderDecorator(typeof(OpenAccessContentDecorator))]
    028.    public class AmazonLibrariesProvider : LibrariesDataProvider, IOpenAccessDataProvider, IDataProviderBase, IDisposable, ICloneable, IChunkProvider
    029.    {
    030.        public virtual Assembly[] GetPersistentAssemblies()
    031.        {
    032.            return new[] { typeof(Telerik.Sitefinity.Libraries.Model.Library).Assembly };
    033.        }
    034. 
    035.        // Methods
    036.        public void ClearChunks(IChunkContent content)
    037.        {
    038.            ClearChunks((MediaContent)content);
    039.        }
    040. 
    041.        private void ClearChunks(MediaContent content)
    042.        {
    043.            var scope = this.GetScope();
    044.            var list = new List<Chunk>(content.Chunks);
    045.            foreach (var chunk in list)
    046.            {
    047.                scope.Remove(chunk);
    048.            }
    049.            content.Uploaded = false;
    050.            content.TotalSize = 0L;
    051.            content.NumberOfChunks = 0;
    052.            scope.Transaction.Commit();
    053.        }
    054. 
    055.        /// <summary>
    056.        /// Mark a library for removal
    057.        /// </summary>
    058.        /// <param name="libraryToDelete">The Library to delete.</param>
    059.        public override void Delete(Telerik.Sitefinity.Libraries.Model.Library libraryToDelete)
    060.        {
    061.            var scope = this.GetScope();
    062.            var securityRoot = GetSecurityRoot();
    063.            if (securityRoot != null)
    064.            {
    065.                Func<PermissionsInheritanceMap, bool> predicate = c => c.ChildObjectId == libraryToDelete.Id;
    066.                var source = securityRoot.PermissionChildren.Where(predicate).ToList();
    067.                for (var i = 0; i < source.Count(); i++)
    068.                {
    069.                    securityRoot.PermissionChildren.Remove(source[i]);
    070.                }
    071.            }
    072.            providerDecorator.DeletePermissions(libraryToDelete);
    073.            if (libraryToDelete is Album)
    074.            {
    075.                ClearLifecycle((Album)libraryToDelete, GetAlbums());
    076.            }
    077.            else if (libraryToDelete is VideoLibrary)
    078.            {
    079.                ClearLifecycle((VideoLibrary)libraryToDelete, GetVideoLibraries());
    080.            }
    081.            else if (libraryToDelete is DocumentLibrary)
    082.            {
    083.                ClearLifecycle((DocumentLibrary)libraryToDelete, GetDocumentLibraries());
    084.            }
    085.            if (scope != null)
    086.            {
    087.                scope.Remove(libraryToDelete);
    088.            }
    089.        }
    090. 
    091.        public override Album CreateAlbum()
    092.        {
    093.            return CreateAlbum(Guid.NewGuid());
    094.        }
    095. 
    096.        public override Album CreateAlbum(Guid id)
    097.        {
    098.            var child = new Album(ApplicationName, id)
    099.                            {
    100.                                DateCreated = DateTime.UtcNow,
    101.                                LastModified = DateTime.UtcNow,
    102.                                PublicationDate = DateTime.UtcNow,
    103.                                Owner = SecurityManager.GetCurrentUserId()
    104.                            };
    105.            //child.Provider = this;
    106.            providerDecorator.CreatePermissionInheritanceAssociation(GetSecurityRoot(), child);
    107.            if (id != Guid.Empty)
    108.            {
    109.                this.GetScope().Add(child);
    110.            }
    111.            return child;
    112.        }
    113. 
    114.        public IChunk CreateChunk(IChunkContent content)
    115.        {
    116.            return new Chunk((MediaContent)content);
    117.        }
    118. 
    119.        public override Document CreateDocument()
    120.        {
    121.            return CreateDocument(Guid.NewGuid());
    122.        }
    123. 
    124.        public override Document CreateDocument(Guid id)
    125.        {
    126.            var persistenceCapableObject = new Document(ApplicationName, id)
    127.                                               {
    128.                                                   Owner = SecurityManager.GetCurrentUserId(),
    129.                                                   PublicationDate = DateTime.UtcNow,
    130.                                                   DateCreated = DateTime.UtcNow,
    131.                                                   LastModified = DateTime.UtcNow
    132.                                               };
    133.            //persistenceCapableObject.Provider = this;
    134.            persistenceCapableObject.ParentChanged += DocumentParentChanged;
    135.            if (id != Guid.Empty)
    136.            {
    137.                this.GetScope().Add(persistenceCapableObject);
    138.            }
    139.            return persistenceCapableObject;
    140.        }
    141. 
    142.        public override DocumentLibrary CreateDocumentLibrary()
    143.        {
    144.            return CreateDocumentLibrary(Guid.NewGuid());
    145.        }
    146. 
    147.        public override DocumentLibrary CreateDocumentLibrary(Guid id)
    148.        {
    149.            var child = new DocumentLibrary(ApplicationName, id)
    150.                            {
    151.                                DateCreated = DateTime.UtcNow,
    152.                                LastModified = DateTime.UtcNow,
    153.                                PublicationDate = DateTime.UtcNow,
    154.                                Owner = SecurityManager.GetCurrentUserId()
    155.                            };
    156.            //child.Provider = this;
    157.            providerDecorator.CreatePermissionInheritanceAssociation(GetSecurityRoot(), child);
    158.            if (id != Guid.Empty)
    159.            {
    160.                this.GetScope().Add(child);
    161.            }
    162.            return child;
    163.        }
    164. 
    165.        public override Image CreateImage()
    166.        {
    167.            return CreateImage(Guid.NewGuid());
    168.        }
    169. 
    170.        public override Image CreateImage(Guid id)
    171.        {
    172.            var persistenceCapableObject = new Image(ApplicationName, id)
    173.                                               {
    174.                                                   Owner = SecurityManager.GetCurrentUserId(),
    175.                                                   PublicationDate = DateTime.UtcNow,
    176.                                                   DateCreated = DateTime.UtcNow,
    177.                                                   LastModified = DateTime.UtcNow
    178.                                               };
    179.            //persistenceCapableObject.Provider = this;
    180.            persistenceCapableObject.ParentChanged += ImageParentChanged;
    181.            if (id != Guid.Empty)
    182.            {
    183.                this.GetScope().Add(persistenceCapableObject);
    184.            }
    185.            return persistenceCapableObject;
    186.        }
    187. 
    188.        public override Thumbnail CreateThumbnail(Guid contentId, int size)
    189.        {
    190.            var persistenceCapableObject = new Thumbnail(contentId, size);
    191.            this.GetScope().Add(persistenceCapableObject);
    192.            return persistenceCapableObject;
    193.        }
    194. 
    195.        public override Video CreateVideo()
    196.        {
    197.            return CreateVideo(Guid.NewGuid());
    198.        }
    199. 
    200.        public override Video CreateVideo(Guid id)
    201.        {
    202.            var persistenceCapableObject = new Video(ApplicationName, id)
    203.                                               {
    204.                                                   Owner = SecurityManager.GetCurrentUserId(),
    205.                                                   PublicationDate = DateTime.UtcNow,
    206.                                                   DateCreated = DateTime.UtcNow,
    207.                                                   LastModified = DateTime.UtcNow
    208.                                               };
    209.            //persistenceCapableObject.Provider = this;
    210.            persistenceCapableObject.ParentChanged += VideoParentChanged;
    211.            if (id != Guid.Empty)
    212.            {
    213.                this.GetScope().Add(persistenceCapableObject);
    214.            }
    215.            return persistenceCapableObject;
    216.        }
    217. 
    218.        public override VideoLibrary CreateVideoLibrary()
    219.        {
    220.            return CreateVideoLibrary(Guid.NewGuid());
    221.        }
    222. 
    223.        public override VideoLibrary CreateVideoLibrary(Guid id)
    224.        {
    225.            var child = new VideoLibrary(ApplicationName, id)
    226.                            {
    227.                                DateCreated = DateTime.UtcNow,
    228.                                LastModified = DateTime.UtcNow,
    229.                                PublicationDate = DateTime.UtcNow,
    230.                                Owner = SecurityManager.GetCurrentUserId()
    231.                            };
    232.            //child.Provider = this;
    233.            providerDecorator.CreatePermissionInheritanceAssociation(GetSecurityRoot(), child);
    234.            if (id != Guid.Empty)
    235.            {
    236.                this.GetScope().Add(child);
    237.            }
    238.            return child;
    239.        }
    240. 
    241.        protected override void Delete(Chunk chunk)
    242.        {
    243.            this.GetScope().Remove(chunk);
    244.        }
    245. 
    246.        public override void Delete(Document documentToDelete)
    247.        {
    248.            var scope = this.GetScope();
    249.            var source = documentToDelete.Parent.PermissionChildren.Where(c => (c.ChildObjectId == documentToDelete.Id)).ToList();
    250.            for (var i = 0; i < source.Count(); i++)
    251.            {
    252.                documentToDelete.Parent.PermissionChildren.Remove(source[i]);
    253.            }
    254.            providerDecorator.DeletePermissions(documentToDelete);
    255.            ClearLifecycle(documentToDelete, GetDocuments());
    256.            if (scope != null)
    257.            {
    258.                scope.Remove(documentToDelete);
    259.            }
    260.        }
    261. 
    262.        public override void Delete(Image imageToDelete)
    263.        {
    264.            var scope = this.GetScope();
    265.            var source = imageToDelete.Parent.PermissionChildren.Where(c => (c.ChildObjectId == imageToDelete.Id)).ToList();
    266.            for (var i = 0; i < source.Count(); i++)
    267.            {
    268.                imageToDelete.Parent.PermissionChildren.Remove(source[i]);
    269.            }
    270.            providerDecorator.DeletePermissions(imageToDelete);
    271.            ClearLifecycle(imageToDelete, GetImages());
    272.            if (scope != null)
    273.            {
    274.                scope.Remove(imageToDelete);
    275.            }
    276.        }
    277. 
    278.        protected override void Delete(Thumbnail thumbnail)
    279.        {
    280.            this.GetScope().Remove(thumbnail);
    281.        }
    282. 
    283.        public override void Delete(Video videoToDelete)
    284.        {
    285.            var scope = this.GetScope();
    286.            var source = videoToDelete.Parent.PermissionChildren.Where(c => (c.ChildObjectId == videoToDelete.Id)).ToList();
    287.            for (var i = 0; i < source.Count(); i++)
    288.            {
    289.                videoToDelete.Parent.PermissionChildren.Remove(source[i]);
    290.            }
    291.            providerDecorator.DeletePermissions(videoToDelete);
    292.            ClearLifecycle(videoToDelete, GetVideos());
    293.            if (scope != null)
    294.            {
    295.                scope.Remove(videoToDelete);
    296.            }
    297.        }
    298. 
    299.        public override void DeleteMediaThumbnails(MediaContent content)
    300.        {
    301.            if (content.Thumbnails.Count <= 0) return;
    302.            var scope = this.GetScope();
    303.            if (scope == null) return;
    304.            var list = new List<Thumbnail>(content.Thumbnails);
    305.            foreach (var thumbnail in list)
    306.            {
    307.                scope.Remove(thumbnail);
    308.            }
    309.            scope.Transaction.Flush();
    310.        }
    311. 
    312.        private void DocumentParentChanged(MediaContent sender, Content parent)
    313.        {
    314.            providerDecorator.CreatePermissionInheritanceAssociation((DocumentLibrary)parent, sender);
    315.        }
    316. 
    317.        public override Stream Download(MediaContent content)
    318.        {
    319.            return new MediaStream(this, content);
    320.        }
    321. 
    322.        public override Album GetAlbum(Guid id)
    323.        {
    324.            if (id == Guid.Empty)
    325.            {
    326.                throw new ArgumentException("Id cannot be Empty Guid");
    327.            }
    328.            var itemById = this.GetScope().GetItemById<Album>(id.ToString());
    329.            //itemById.Provider = this;
    330.            return itemById;
    331.        }
    332. 
    333.        public override IQueryable<Album> GetAlbums()
    334.        {
    335.            string appName = ApplicationName;
    336.            var query = (from b in SitefinityQuery.Get<Album>(this, MethodBase.GetCurrentMethod())
    337.                    where b.ApplicationName == appName
    338.                    select b);
    339.            return query;
    340.        }
    341. 
    342.        public IChunk GetChunk(IChunkContent content, int ordinal)
    343.        {
    344.            return content.Chunks.Where(ch => (ch.Ordinal == ordinal)).FirstOrDefault();
    345.        }
    346. 
    347.        public override Stream GetContentStream(MediaContent content)
    348.        {
    349.            return new MediaStream(this, content);
    350.        }
    351. 
    352.        public override Document GetDocument(Guid id)
    353.        {
    354.            if (id == Guid.Empty)
    355.            {
    356.                throw new ArgumentException("Id cannot be Empty Guid");
    357.            }
    358.            var itemById = this.GetScope().GetItemById<Document>(id.ToString());
    359.            //itemById.Provider = this;
    360.            return itemById;
    361.        }
    362. 
    363.        public override IQueryable<DocumentLibrary> GetDocumentLibraries()
    364.        {
    365.            string appName = this.ApplicationName;
    366.            var query = (from b in SitefinityQuery.Get<DocumentLibrary>(this, MethodBase.GetCurrentMethod())
    367.                         where b.ApplicationName == appName
    368.                         select b);
    369.            return query;
    370.        }
    371. 
    372.        public override DocumentLibrary GetDocumentLibrary(Guid id)
    373.        {
    374.            if (id == Guid.Empty)
    375.            {
    376.                throw new ArgumentException("Id cannot be Empty Guid");
    377.            }
    378.            var itemById = this.GetScope().GetItemById<DocumentLibrary>(id.ToString());
    379.            //itemById.Provider = this;
    380.            return itemById;
    381.        }
    382. 
    383.        public override IQueryable<Document> GetDocuments()
    384.        {
    385.            var appName = this.ApplicationName;
    386.            var query = (from b in SitefinityQuery.Get<Document>(this, MethodBase.GetCurrentMethod())
    387.                         where b.ApplicationName == appName
    388.                         select b);
    389.            return query;
    390.         
    391.        }
    392. 
    393.        public override Image GetImage(Guid id)
    394.        {
    395.            if (id == Guid.Empty)
    396.            {
    397.                throw new ArgumentException("Id cannot be Empty Guid");
    398.            }
    399.            var itemById = this.GetScope().GetItemById<Image>(id.ToString());
    400.            //itemById.Provider = this;
    401.            return itemById;
    402.        }
    403. 
    404.        public override IQueryable<Image> GetImages()
    405.        {
    406.            var appName = this.ApplicationName;
    407.            var query = (from b in SitefinityQuery.Get<Image>(this, MethodBase.GetCurrentMethod())
    408.                         where b.ApplicationName == appName
    409.                         select b);
    410.            return query;
    411.        }
    412. 
    413.        public override IQueryable<Thumbnail> GetThumbnails()
    414.        {
    415.            ParameterExpression expression;
    416.            return SitefinityQuery.Get<Thumbnail>(this, MethodBase.GetCurrentMethod()).Select(Expression.Lambda<Func<Thumbnail, Thumbnail>>(expression = Expression.Parameter(typeof(Thumbnail), "thumb"), new[] { expression }));
    417.        }
    418. 
    419.        public override Video GetVideo(Guid id)
    420.        {
    421.            if (id == Guid.Empty)
    422.            {
    423.                throw new ArgumentException("Id cannot be Empty Guid");
    424.            }
    425.            var itemById = this.GetScope().GetItemById<Video>(id.ToString());
    426.            //itemById.Provider = this;
    427.            return itemById;
    428.        }
    429. 
    430.        public override IQueryable<VideoLibrary> GetVideoLibraries()
    431.        {
    432.            ParameterExpression expression;
    433.            string appName = this.ApplicationName;
    434.            //return SitefinityQuery.Get<VideoLibrary>(this).Where<VideoLibrary>(Expression.Lambda<Func<VideoLibrary, bool>>(Expression.Equal(Expression.Property(expression = Expression.Parameter(typeof(VideoLibrary), "b"), (MethodInfo)methodof(Content.get_ApplicationName)), Expression.Constant(appName), false, (MethodInfo)methodof(string.op_Equality)), new ParameterExpression[] { expression }));
    435. 
    436.            return SitefinityQuery.Get<VideoLibrary>(this);
    437.         
    438.        }
    439. 
    440.        public override VideoLibrary GetVideoLibrary(Guid id)
    441.        {
    442.            if (id == Guid.Empty)
    443.            {
    444.                throw new ArgumentException("Id cannot be Empty Guid");
    445.            }
    446.            var itemById = this.GetScope().GetItemById<VideoLibrary>(id.ToString());
    447.            //itemById.Provider = this;
    448.            return itemById;
    449.        }
    450. 
    451.        public override IQueryable<Video> GetVideos()
    452.        {
    453.            ParameterExpression expression;
    454.            var appName = this.ApplicationName;
    455.            //return SitefinityQuery.Get<Video>(this, MethodBase.GetCurrentMethod()).Where<Video>(Expression.Lambda<Func<Video, bool>>(Expression.Equal(Expression.Property(expression = Expression.Parameter(typeof(Video), "b"), (MethodInfo)methodof(Content.get_ApplicationName)), Expression.Constant(appName), false, (MethodInfo)methodof(string.op_Equality)), new ParameterExpression[] { expression }));
    456. 
    457.            return SitefinityQuery.Get<Video>(this);
    458.        
    459.        }
    460. 
    461.        private void ImageParentChanged(MediaContent sender, Content parent)
    462.        {
    463.            providerDecorator.CreatePermissionInheritanceAssociation((Album)parent, sender);
    464.        }
    465. 
    466.        public virtual void SaveChunk(IChunk chunk, bool isFinalChunk)
    467.        {
    468.            var scope = this.GetScope();
    469.            var persistenceCapableObject = (Chunk)chunk;
    470.            scope.Add(persistenceCapableObject);
    471.            var content = persistenceCapableObject.Content;
    472.            scope.Add(content);
    473.            content.TotalSize += chunk.Size;
    474.            content.NumberOfChunks++;
    475.            if (isFinalChunk)
    476.            {
    477.                content.Uploaded = true;
    478.            }
    479.            scope.Transaction.Commit();
    480.        }
    481. 
    482.        private void VideoParentChanged(MediaContent sender, Content parent)
    483.        {
    484.            providerDecorator.CreatePermissionInheritanceAssociation((VideoLibrary)parent, sender);
    485.        }
    486. 
    487.        // Properties
    488.        public Database Database { get; set; }
    489. 
    490.        public virtual bool UseImplicitTransactions
    491.        {
    492.            get
    493.            {
    494.                return true;
    495.            }
    496.        }
    497. 
    498.        /// <summary>
    499.        /// Controls the concurrency of the transaction.
    500.        /// </summary>
    501.        /// <value>
    502.        /// The transaction concurrency.
    503.        /// </value>
    504.        public TransactionMode TransactionConcurrency
    505.        {
    506.            get { return TransactionMode.OPTIMISTIC_NO_LOST_UPDATES; }
    507.        }
    508.    }
    509.}

    and the manager
    0019.namespace ProChrist.Provider.Libraries.Amazon
    0020.{
    0021.    public class AmazonLibrariesManager : ContentManagerBase<AmazonLibrariesProvider>, IContentLifecycleManager<Image>, IContentLifecycleManager<Document>, IContentLifecycleManager<Video>, IContentLifecycleManager<Album>, IContentLifecycleManager<DocumentLibrary>, IContentLifecycleManager<VideoLibrary>
    0022.    {
    0023.        // Fields
    0024.        private static readonly string librariesTempFolder = Path.Combine(HostingEnvironment.ApplicationPhysicalPath, @"App_Data\Sitefinity\Temp\Libraries");
    0025. 
    0026.        // Methods
    0027.        static AmazonLibrariesManager()
    0028.        {
    0029.            if (!Directory.Exists(librariesTempFolder))
    0030.            {
    0031.                Directory.CreateDirectory(librariesTempFolder);
    0032.            }
    0033.        }
    0034. 
    0035.        public AmazonLibrariesManager()
    0036.            : this(null)
    0037.        {
    0038.        }
    0039. 
    0040.        public AmazonLibrariesManager(string providerName)
    0041.            : base(providerName)
    0042.        {
    0043.        }
    0044. 
    0045.        public AmazonLibrariesManager(string providerName, string transactionName)
    0046.            : base(providerName, transactionName)
    0047.        {
    0048.        }
    0049. 
    0050.        public Content CheckIn(Content item)
    0051.        {
    0052.            if (item is Image)
    0053.            {
    0054.                return CheckIn((Image)item);
    0055.            }
    0056.            if (item is Document)
    0057.            {
    0058.                return CheckIn((Document)item);
    0059.            }
    0060.            if (item is Video)
    0061.            {
    0062.                return CheckIn((Video)item);
    0063.            }
    0064.            if (item is Album)
    0065.            {
    0066.                return CheckIn((Album)item);
    0067.            }
    0068.            if (item is Telerik.Sitefinity.Libraries.Model.Library)
    0069.            {
    0070.                return CheckIn((Telerik.Sitefinity.Libraries.Model.Library)item);
    0071.            }
    0072.            if (item is DocumentLibrary)
    0073.            {
    0074.                return CheckIn((DocumentLibrary)item);
    0075.            }
    0076.            if (!(item is VideoLibrary))
    0077.            {
    0078.                throw new NotSupportedException("Type {0} is not supported by this manager".Arrange(new object[] { item.GetType() }));
    0079.            }
    0080.            return CheckIn((VideoLibrary)item);
    0081.        }
    0082. 
    0083.        public Album CheckIn(Album item)
    0084.        {
    0085.            throw new NotSupportedException();
    0086.        }
    0087. 
    0088.        public virtual Document CheckIn(Document document)
    0089.        {
    0090.            return Provider.CheckIn(document, CopyDocument);
    0091.        }
    0092. 
    0093.        public DocumentLibrary CheckIn(DocumentLibrary item)
    0094.        {
    0095.            throw new NotSupportedException();
    0096.        }
    0097. 
    0098.        public virtual Image CheckIn(Image image)
    0099.        {
    0100.            return Provider.CheckIn(image, CopyImage);
    0101.        }
    0102. 
    0103.        public Telerik.Sitefinity.Libraries.Model.Library CheckIn(Telerik.Sitefinity.Libraries.Model.Library item)
    0104.        {
    0105.            throw new NotSupportedException();
    0106.        }
    0107. 
    0108.        public virtual Video CheckIn(Video video)
    0109.        {
    0110.            return Provider.CheckIn(video, CopyVideo);
    0111.        }
    0112. 
    0113.        public VideoLibrary CheckIn(VideoLibrary item)
    0114.        {
    0115.            throw new NotSupportedException();
    0116.        }
    0117. 
    0118.        public Content CheckOut(Content item)
    0119.        {
    0120.            if (item is Image)
    0121.            {
    0122.                return CheckOut((Image)item);
    0123.            }
    0124.            if (item is Document)
    0125.            {
    0126.                return CheckOut((Document)item);
    0127.            }
    0128.            if (item is Video)
    0129.            {
    0130.                return CheckOut((Video)item);
    0131.            }
    0132.            if (item is Album)
    0133.            {
    0134.                return CheckOut((Album)item);
    0135.            }
    0136.            if (item is Telerik.Sitefinity.Libraries.Model.Library)
    0137.            {
    0138.                return CheckOut((Telerik.Sitefinity.Libraries.Model.Library)item);
    0139.            }
    0140.            if (item is DocumentLibrary)
    0141.            {
    0142.                return CheckOut((DocumentLibrary)item);
    0143.            }
    0144.            if (!(item is VideoLibrary))
    0145.            {
    0146.                throw new NotSupportedException("Type {0} is not supported by this manager".Arrange(new object[] { item.GetType() }));
    0147.            }
    0148.            return CheckOut((VideoLibrary)item);
    0149.        }
    0150. 
    0151.        public Album CheckOut(Album item)
    0152.        {
    0153.            throw new NotSupportedException();
    0154.        }
    0155. 
    0156.        public virtual Document CheckOut(Document document)
    0157.        {
    0158.            return Provider.CheckOut(document, CopyDocument, GetDocuments());
    0159.        }
    0160. 
    0161.        public DocumentLibrary CheckOut(DocumentLibrary item)
    0162.        {
    0163.            throw new NotSupportedException();
    0164.        }
    0165. 
    0166.        public virtual Image CheckOut(Image image)
    0167.        {
    0168.            return Provider.CheckOut<Image>(image, CopyImage, GetImages());
    0169.        }
    0170. 
    0171.        public Telerik.Sitefinity.Libraries.Model.Library CheckOut(Telerik.Sitefinity.Libraries.Model.Library item)
    0172.        {
    0173.            throw new NotSupportedException();
    0174.        }
    0175. 
    0176.        public virtual Video CheckOut(Video video)
    0177.        {
    0178.            return Provider.CheckOut(video, CopyVideo, GetVideos());
    0179.        }
    0180. 
    0181.        public VideoLibrary CheckOut(VideoLibrary item)
    0182.        {
    0183.            throw new NotSupportedException();
    0184.        }
    0185. 
    0186.        public virtual void Copy(Content source, Content destination)
    0187.        {
    0188.            Type type;
    0189.            if (source == null)
    0190.            {
    0191.                throw new ArgumentNullException("source");
    0192.            }
    0193.            if (destination == null)
    0194.            {
    0195.                throw new ArgumentNullException("destination");
    0196.            }
    0197.            if ((type = source.GetType()) != destination.GetType())
    0198.            {
    0199.                throw new ArgumentException("source and destination must be of the same type");
    0200.            }
    0201.            if (type == typeof(Image))
    0202.            {
    0203.                Copy((Image)source, (Image)destination);
    0204.            }
    0205.            else if (type == typeof(Document))
    0206.            {
    0207.                Copy((Document)source, (Document)destination);
    0208.            }
    0209.            else if (type == typeof(Video))
    0210.            {
    0211.                Copy((Video)source, (Video)destination);
    0212.            }
    0213.            else if (type == typeof(Album))
    0214.            {
    0215.                Copy((Album)source, (Album)destination);
    0216.            }
    0217.            else if (type == typeof(DocumentLibrary))
    0218.            {
    0219.                Copy((DocumentLibrary)source, (DocumentLibrary)destination);
    0220.            }
    0221.            else
    0222.            {
    0223.                if (type != typeof(VideoLibrary))
    0224.                {
    0225.                    throw new NotSupportedException("Type {0} is not supported".Arrange(new object[] { type }));
    0226.                }
    0227.                Copy((VideoLibrary)source, (VideoLibrary)destination);
    0228.            }
    0229.        }
    0230. 
    0231.        public void Copy(Album source, Album destination)
    0232.        {
    0233.            Provider.CopyContent(source, destination);
    0234.        }
    0235. 
    0236.        public void Copy(Document source, Document destination)
    0237.        {
    0238.            CopyDocument(source, destination);
    0239.        }
    0240. 
    0241.        public void Copy(DocumentLibrary source, DocumentLibrary destination)
    0242.        {
    0243.            Provider.CopyContent(source, destination);
    0244.        }
    0245. 
    0246.        public void Copy(Image source, Image destination)
    0247.        {
    0248.            CopyImage(source, destination);
    0249.        }
    0250. 
    0251.        public void Copy(Video source, Video destination)
    0252.        {
    0253.            CopyVideo(source, destination);
    0254.        }
    0255. 
    0256.        public void Copy(VideoLibrary source, VideoLibrary destination)
    0257.        {
    0258.            Provider.CopyContent(source, destination);
    0259.        }
    0260. 
    0261.        private void CopyDocument(Document source, Document destination)
    0262.        {
    0263.            Provider.CopyMediaContent(source, destination);
    0264.            destination.Parent = source.Library;
    0265.        }
    0266. 
    0267.        private void CopyImage(Image source, Image destination)
    0268.        {
    0269.            Provider.CopyMediaContent(source, destination);
    0270.            destination.Parent = source.Album;
    0271.            destination.AlternativeText.CopyFrom(source.AlternativeText);
    0272.            destination.Height = source.Height;
    0273.            destination.Width = source.Width;
    0274.        }
    0275. 
    0276.        private void CopyVideo(Video source, Video destination)
    0277.        {
    0278.            Provider.CopyMediaContent(source, destination);
    0279.            destination.Height = source.Height;
    0280.            destination.Width = source.Width;
    0281.            destination.Parent = source.Library;
    0282.        }
    0283. 
    0284.        public virtual Album CreateAlbum()
    0285.        {
    0286.            return Provider.CreateAlbum();
    0287.        }
    0288. 
    0289.        public virtual Album CreateAlbum(Guid id)
    0290.        {
    0291.            return Provider.CreateAlbum(id);
    0292.        }
    0293. 
    0294.        public virtual Document CreateDocument()
    0295.        {
    0296.            return Provider.CreateDocument();
    0297.        }
    0298. 
    0299.        public virtual Document CreateDocument(Guid id)
    0300.        {
    0301.            return Provider.CreateDocument(id);
    0302.        }
    0303. 
    0304.        public virtual DocumentLibrary CreateDocumentLibrary()
    0305.        {
    0306.            return Provider.CreateDocumentLibrary();
    0307.        }
    0308. 
    0309.        public virtual DocumentLibrary CreateDocumentLibrary(Guid id)
    0310.        {
    0311.            return Provider.CreateDocumentLibrary(id);
    0312.        }
    0313. 
    0314.        public virtual Image CreateImage()
    0315.        {
    0316.            return Provider.CreateImage();
    0317.        }
    0318. 
    0319.        public virtual Image CreateImage(Guid id)
    0320.        {
    0321.            return Provider.CreateImage(id);
    0322.        }
    0323. 
    0324.        public virtual Video CreateVideo()
    0325.        {
    0326.            return Provider.CreateVideo();
    0327.        }
    0328. 
    0329.        public virtual Video CreateVideo(Guid id)
    0330.        {
    0331.            return Provider.CreateVideo(id);
    0332.        }
    0333. 
    0334.        public virtual VideoLibrary CreateVideoLibrary()
    0335.        {
    0336.            return Provider.CreateVideoLibrary();
    0337.        }
    0338. 
    0339.        public virtual VideoLibrary CreateVideoLibrary(Guid id)
    0340.        {
    0341.            return Provider.CreateVideoLibrary(id);
    0342.        }
    0343. 
    0344.        public virtual void DeleteAlbum(Album albumToDelete)
    0345.        {
    0346.            Provider.Delete(albumToDelete);
    0347.        }
    0348. 
    0349.        public virtual void DeleteDocument(Document documentToDelete)
    0350.        {
    0351.            Provider.Delete(documentToDelete);
    0352.        }
    0353. 
    0354.        public virtual void DeleteDocumentLibrary(DocumentLibrary libraryToDelete)
    0355.        {
    0356.            Provider.Delete(libraryToDelete);
    0357.        }
    0358. 
    0359.        public virtual void DeleteImage(Image imageToDelete)
    0360.        {
    0361.            Provider.Delete(imageToDelete);
    0362.        }
    0363. 
    0364.        public virtual void DeleteLibrary(Telerik.Sitefinity.Libraries.Model.Library libraryToDelete)
    0365.        {
    0366.            Provider.Delete(libraryToDelete);
    0367.        }
    0368. 
    0369.        public virtual void DeleteVideo(Video videoToDelete)
    0370.        {
    0371.            Provider.Delete(videoToDelete);
    0372.        }
    0373. 
    0374.        public virtual void DeleteVideoLibrary(VideoLibrary libraryToDelete)
    0375.        {
    0376.            Provider.Delete(libraryToDelete);
    0377.        }
    0378. 
    0379.        public virtual Stream Download(MediaContent content)
    0380.        {
    0381.            return Provider.Download(content);
    0382.        }
    0383. 
    0384.        public Content Edit(Content item)
    0385.        {
    0386.            if (item is Image)
    0387.            {
    0388.                return Edit((Image)item);
    0389.            }
    0390.            if (item is Document)
    0391.            {
    0392.                return Edit((Document)item);
    0393.            }
    0394.            if (item is Video)
    0395.            {
    0396.                return Edit((Video)item);
    0397.            }
    0398.            if (item is Album)
    0399.            {
    0400.                return Edit((Album)item);
    0401.            }
    0402.            if (item is Telerik.Sitefinity.Libraries.Model.Library)
    0403.            {
    0404.                return Edit((Telerik.Sitefinity.Libraries.Model.Library)item);
    0405.            }
    0406.            if (item is DocumentLibrary)
    0407.            {
    0408.                return Edit((DocumentLibrary)item);
    0409.            }
    0410.            if (!(item is VideoLibrary))
    0411.            {
    0412.                throw new NotSupportedException("Type {0} is not supported by this manager".Arrange(new object[] { item.GetType() }));
    0413.            }
    0414.            return Edit((VideoLibrary)item);
    0415.        }
    0416. 
    0417.        public Album Edit(Album item)
    0418.        {
    0419.            throw new NotSupportedException();
    0420.        }
    0421. 
    0422.        public virtual Document Edit(Document document)
    0423.        {
    0424.            return Provider.Edit<Document>(document, new Action<Document, Document>(CopyDocument), GetDocuments());
    0425.        }
    0426. 
    0427.        public DocumentLibrary Edit(DocumentLibrary item)
    0428.        {
    0429.            throw new NotSupportedException();
    0430.        }
    0431. 
    0432.        public virtual Image Edit(Image image)
    0433.        {
    0434.            return Provider.Edit(image, CopyImage, GetImages());
    0435.        }
    0436. 
    0437.        public Telerik.Sitefinity.Libraries.Model.Library Edit(Telerik.Sitefinity.Libraries.Model.Library item)
    0438.        {
    0439.            throw new NotSupportedException();
    0440.        }
    0441. 
    0442.        public virtual Video Edit(Video video)
    0443.        {
    0444.            return Provider.Edit(video, CopyVideo, GetVideos());
    0445.        }
    0446. 
    0447.        public VideoLibrary Edit(VideoLibrary item)
    0448.        {
    0449.            throw new NotSupportedException();
    0450.        }
    0451. 
    0452.        public void GenerateVideoThumbnails(Video video)
    0453.        {
    0454.            GenerateVideoThumbnails(video, new FileInfo(GetItemTemporaryFilePath(video, video.UrlName + video.Extension)));
    0455.        }
    0456. 
    0457.        public virtual void GenerateVideoThumbnails(Video video, FileInfo videofile)
    0458.        {
    0459.            try
    0460.            {
    0461.                Provider.GenerateVideoThumbnails(video, videofile);
    0462.            }
    0463.            catch (Exception exception)
    0464.            {
    0465.                Log.Write(exception, "Video");
    0466.            }
    0467.        }
    0468. 
    0469.        public virtual Album GetAlbum(Guid id)
    0470.        {
    0471.            return Provider.GetAlbum(id);
    0472.        }
    0473. 
    0474.        public virtual IQueryable<Album> GetAlbums()
    0475.        {
    0476.            return Provider.GetAlbums();
    0477.        }
    0478. 
    0479.        public Guid GetCheckedOutBy(Content item)
    0480.        {
    0481.            if (item is Image)
    0482.            {
    0483.                return GetCheckedOutBy((Image)item);
    0484.            }
    0485.            if (item is Document)
    0486.            {
    0487.                return GetCheckedOutBy((Document)item);
    0488.            }
    0489.            if (item is Video)
    0490.            {
    0491.                return GetCheckedOutBy((Video)item);
    0492.            }
    0493.            if (item is Album)
    0494.            {
    0495.                return GetCheckedOutBy((Album)item);
    0496.            }
    0497.            if (item is Telerik.Sitefinity.Libraries.Model.Library)
    0498.            {
    0499.                return GetCheckedOutBy((Telerik.Sitefinity.Libraries.Model.Library)item);
    0500.            }
    0501.            if (item is DocumentLibrary)
    0502.            {
    0503.                return GetCheckedOutBy((DocumentLibrary)item);
    0504.            }
    0505.            if (!(item is VideoLibrary))
    0506.            {
    0507.                throw new NotSupportedException("Type {0}is not supported by this manager".Arrange(new object[] { item.GetType() }));
    0508.            }
    0509.            return GetCheckedOutBy((VideoLibrary)item);
    0510.        }
    0511. 
    0512.        public Guid GetCheckedOutBy(Album item)
    0513.        {
    0514.            throw new NotSupportedException();
    0515.        }
    0516. 
    0517.        public virtual Guid GetCheckedOutBy(Document item)
    0518.        {
    0519.            return Provider.GetCheckedOutBy<Document>(item, GetDocuments());
    0520.        }
    0521. 
    0522.        public Guid GetCheckedOutBy(DocumentLibrary item)
    0523.        {
    0524.            throw new NotSupportedException();
    0525.        }
    0526. 
    0527.        public virtual Guid GetCheckedOutBy(Image item)
    0528.        {
    0529.            return Provider.GetCheckedOutBy<Image>(item, GetImages());
    0530.        }
    0531. 
    0532.        public Guid GetCheckedOutBy(Telerik.Sitefinity.Libraries.Model.Library item)
    0533.        {
    0534.            throw new NotSupportedException();
    0535.        }
    0536. 
    0537.        public virtual Guid GetCheckedOutBy(Video item)
    0538.        {
    0539.            return Provider.GetCheckedOutBy<Video>(item, GetVideos());
    0540.        }
    0541. 
    0542.        public Guid GetCheckedOutBy(VideoLibrary item)
    0543.        {
    0544.            throw new NotSupportedException();
    0545.        }
    0546. 
    0547.        public virtual Document GetDocument(Guid id)
    0548.        {
    0549.            return Provider.GetDocument(id);
    0550.        }
    0551. 
    0552.        public virtual IQueryable<DocumentLibrary> GetDocumentLibraries()
    0553.        {
    0554.            return Provider.GetDocumentLibraries();
    0555.        }
    0556. 
    0557.        public virtual DocumentLibrary GetDocumentLibrary(Guid id)
    0558.        {
    0559.            return Provider.GetDocumentLibrary(id);
    0560.        }
    0561. 
    0562.        public virtual IQueryable<Document> GetDocuments()
    0563.        {
    0564.            return Provider.GetDocuments();
    0565.        }
    0566. 
    0567.        public virtual Image GetImage(Guid id)
    0568.        {
    0569.            var i = Provider.GetImage(id);
    0570.            return i;
    0571.        }
    0572. 
    0573.        public virtual IQueryable<Image> GetImages()
    0574.        {
    0575.            return Provider.GetImages();
    0576.        }
    0577. 
    0578.        public override IQueryable<TItem> GetItems<TItem>()
    0579.        {
    0580.            if (typeof(Image).IsAssignableFrom(typeof(TItem)))
    0581.            {
    0582.                return (GetImages() as IQueryable<TItem>);
    0583.            }
    0584.            if (typeof(Video).IsAssignableFrom(typeof(TItem)))
    0585.            {
    0586.                return (GetVideos() as IQueryable<TItem>);
    0587.            }
    0588.            if (typeof(Document).IsAssignableFrom(typeof(TItem)))
    0589.            {
    0590.                return (GetDocuments() as IQueryable<TItem>);
    0591.            }
    0592.            if (typeof(Album).IsAssignableFrom(typeof(TItem)))
    0593.            {
    0594.                return (GetAlbums() as IQueryable<TItem>);
    0595.            }
    0596.            if (typeof(DocumentLibrary).IsAssignableFrom(typeof(TItem)))
    0597.            {
    0598.                return (GetDocumentLibraries() as IQueryable<TItem>);
    0599.            }
    0600.            if (!typeof(VideoLibrary).IsAssignableFrom(typeof(TItem)))
    0601.            {
    0602.                throw new ArgumentException("Unable to cast TItem to Image or Video or Document or Album or DocumentLibrary or VideoLibrary");
    0603.            }
    0604.            return (GetVideoLibraries() as IQueryable<TItem>);
    0605.        }
    0606. 
    0607.        public string GetItemTemporaryFilePath(MediaContent content, string fileName)
    0608.        {
    0609.            return Path.Combine(LibrariesTempFolder, string.Format("{0}_{1}_{2}", Provider.Name, content.Parent.UrlName, fileName));
    0610.        }
    0611. 
    0612.        public Content GetLive(Content cnt)
    0613.        {
    0614.            if (cnt is Image)
    0615.            {
    0616.                return GetLive((Image)cnt);
    0617.            }
    0618.            if (cnt is Document)
    0619.            {
    0620.                return GetLive((Document)cnt);
    0621.            }
    0622.            if (cnt is Video)
    0623.            {
    0624.                return GetLive((Video)cnt);
    0625.            }
    0626.            if (cnt is Album)
    0627.            {
    0628.                return GetLive((Album)cnt);
    0629.            }
    0630.            if (cnt is Telerik.Sitefinity.Libraries.Model.Library)
    0631.            {
    0632.                return GetLive((Telerik.Sitefinity.Libraries.Model.Library)cnt);
    0633.            }
    0634.            if (cnt is DocumentLibrary)
    0635.            {
    0636.                return GetLive((DocumentLibrary)cnt);
    0637.            }
    0638.            if (!(cnt is VideoLibrary))
    0639.            {
    0640.                throw new NotSupportedException("Type {0}is not supported by this manager".Arrange(new object[] { cnt.GetType() }));
    0641.            }
    0642.            return GetLive((VideoLibrary)cnt);
    0643.        }
    0644. 
    0645.        public Album GetLive(Album cnt)
    0646.        {
    0647.            throw new NotImplementedException();
    0648.        }
    0649. 
    0650.        public virtual Document GetLive(Document cnt)
    0651.        {
    0652.            return Provider.GetLiveBase<Document>(cnt);
    0653.        }
    0654. 
    0655.        public DocumentLibrary GetLive(DocumentLibrary cnt)
    0656.        {
    0657.            throw new NotSupportedException();
    0658.        }
    0659. 
    0660.        public virtual Image GetLive(Image cnt)
    0661.        {
    0662.            var i = Provider.GetLiveBase<Image>(cnt);
    0663.            return i;
    0664.        }
    0665. 
    0666.        public Telerik.Sitefinity.Libraries.Model.Library GetLive(Telerik.Sitefinity.Libraries.Model.Library cnt)
    0667.        {
    0668.            throw new NotSupportedException();
    0669.        }
    0670. 
    0671.        public virtual Video GetLive(Video cnt)
    0672.        {
    0673.            return Provider.GetLiveBase<Video>(cnt);
    0674.        }
    0675. 
    0676.        public VideoLibrary GetLive(VideoLibrary cnt)
    0677.        {
    0678.            throw new NotSupportedException();
    0679.        }
    0680. 
    0681.        public static AmazonLibrariesManager GetManager()
    0682.        {
    0683.            return GetManager<AmazonLibrariesManager>();
    0684.        }
    0685. 
    0686.        public static AmazonLibrariesManager GetManager(string providerName)
    0687.        {
    0688.            return GetManager<AmazonLibrariesManager>(providerName);
    0689.        }
    0690. 
    0691.        public static AmazonLibrariesManager GetManager(string providerName, string transactionName)
    0692.        {
    0693.            return GetManager<AmazonLibrariesManager>(providerName, transactionName);
    0694.        }
    0695. 
    0696.        public Content GetMaster(Content cnt)
    0697.        {
    0698.            if (cnt is Image)
    0699.            {
    0700.                return GetMaster((Image)cnt);
    0701.            }
    0702.            if (cnt is Document)
    0703.            {
    0704.                return GetMaster((Document)cnt);
    0705.            }
    0706.            if (cnt is Video)
    0707.            {
    0708.                return GetMaster((Video)cnt);
    0709.            }
    0710.            if (cnt is Album)
    0711.            {
    0712.                return GetMaster((Album)cnt);
    0713.            }
    0714.            if (cnt is Telerik.Sitefinity.Libraries.Model.Library)
    0715.            {
    0716.                return GetMaster((Telerik.Sitefinity.Libraries.Model.Library)cnt);
    0717.            }
    0718.            if (cnt is DocumentLibrary)
    0719.            {
    0720.                return GetMaster((DocumentLibrary)cnt);
    0721.            }
    0722.            if (!(cnt is VideoLibrary))
    0723.            {
    0724.                throw new NotSupportedException("Type {0}is not supported by this manager".Arrange(new object[] { cnt.GetType() }));
    0725.            }
    0726.            return GetMaster((VideoLibrary)cnt);
    0727.        }
    0728. 
    0729.        public Album GetMaster(Album cnt)
    0730.        {
    0731.            throw new NotImplementedException();
    0732.        }
    0733. 
    0734.        public virtual Document GetMaster(Document cnt)
    0735.        {
    0736.            return Provider.GetMasterBase<Document>(cnt);
    0737.        }
    0738. 
    0739.        public DocumentLibrary GetMaster(DocumentLibrary cnt)
    0740.        {
    0741.            throw new NotSupportedException();
    0742.        }
    0743. 
    0744.        public virtual Image GetMaster(Image cnt)
    0745.        {
    0746.            return Provider.GetMasterBase(cnt);
    0747.        }
    0748. 
    0749.        public Telerik.Sitefinity.Libraries.Model.Library GetMaster(Telerik.Sitefinity.Libraries.Model.Library cnt)
    0750.        {
    0751.            throw new NotImplementedException();
    0752.        }
    0753. 
    0754.        public virtual Video GetMaster(Video cnt)
    0755.        {
    0756.            return Provider.GetMasterBase(cnt);
    0757.        }
    0758. 
    0759.        public VideoLibrary GetMaster(VideoLibrary cnt)
    0760.        {
    0761.            throw new NotSupportedException();
    0762.        }
    0763. 
    0764.        public Content GetTemp(Content cnt)
    0765.        {
    0766.            if (cnt is Image)
    0767.            {
    0768.                return GetTemp((Image)cnt);
    0769.            }
    0770.            if (cnt is Document)
    0771.            {
    0772.                return GetTemp((Document)cnt);
    0773.            }
    0774.            if (cnt is Video)
    0775.            {
    0776.                return GetTemp((Video)cnt);
    0777.            }
    0778.            if (cnt is Album)
    0779.            {
    0780.                return GetTemp((Album)cnt);
    0781.            }
    0782.            if (cnt is Telerik.Sitefinity.Libraries.Model.Library)
    0783.            {
    0784.                return GetTemp((Telerik.Sitefinity.Libraries.Model.Library)cnt);
    0785.            }
    0786.            if (cnt is DocumentLibrary)
    0787.            {
    0788.                return GetTemp((DocumentLibrary)cnt);
    0789.            }
    0790.            if (!(cnt is VideoLibrary))
    0791.            {
    0792.                throw new NotSupportedException("Type {0}is not supported by this manager".Arrange(new object[] { cnt.GetType() }));
    0793.            }
    0794.            return GetTemp((VideoLibrary)cnt);
    0795.        }
    0796. 
    0797.        public Album GetTemp(Album cnt)
    0798.        {
    0799.            throw new NotImplementedException();
    0800.        }
    0801. 
    0802.        public virtual Document GetTemp(Document cnt)
    0803.        {
    0804.            return Provider.GetTempBase<Document>(cnt);
    0805.        }
    0806. 
    0807.        public DocumentLibrary GetTemp(DocumentLibrary cnt)
    0808.        {
    0809.            throw new NotSupportedException();
    0810.        }
    0811. 
    0812.        public virtual Image GetTemp(Image cnt)
    0813.        {
    0814.            return Provider.GetTempBase<Image>(cnt);
    0815.        }
    0816. 
    0817.        public Telerik.Sitefinity.Libraries.Model.Library GetTemp(Telerik.Sitefinity.Libraries.Model.Library cnt)
    0818.        {
    0819.            throw new NotImplementedException();
    0820.        }
    0821. 
    0822.        public virtual Video GetTemp(Video cnt)
    0823.        {
    0824.            return Provider.GetTempBase(cnt);
    0825.        }
    0826. 
    0827.        public VideoLibrary GetTemp(VideoLibrary cnt)
    0828.        {
    0829.            throw new NotSupportedException();
    0830.        }
    0831. 
    0832.        public virtual Video GetVideo(Guid id)
    0833.        {
    0834.            return Provider.GetVideo(id);
    0835.        }
    0836. 
    0837.        public virtual IQueryable<VideoLibrary> GetVideoLibraries()
    0838.        {
    0839.            return Provider.GetVideoLibraries();
    0840.        }
    0841. 
    0842.        public virtual VideoLibrary GetVideoLibrary(Guid id)
    0843.        {
    0844.            return Provider.GetVideoLibrary(id);
    0845.        }
    0846. 
    0847.        public virtual IQueryable<Video> GetVideos()
    0848.        {
    0849.            return Provider.GetVideos();
    0850.        }
    0851. 
    0852.        public bool IsCheckedOut(Content item)
    0853.        {
    0854.            if (item is Image)
    0855.            {
    0856.                return IsCheckedOut((Image)item);
    0857.            }
    0858.            if (item is Document)
    0859.            {
    0860.                return IsCheckedOut((Document)item);
    0861.            }
    0862.            if (item is Video)
    0863.            {
    0864.                return IsCheckedOut((Video)item);
    0865.            }
    0866.            if (item is Album)
    0867.            {
    0868.                return IsCheckedOut((Album)item);
    0869.            }
    0870.            if (item is Telerik.Sitefinity.Libraries.Model.Library)
    0871.            {
    0872.                return IsCheckedOut((Telerik.Sitefinity.Libraries.Model.Library)item);
    0873.            }
    0874.            if (item is DocumentLibrary)
    0875.            {
    0876.                return IsCheckedOut((DocumentLibrary)item);
    0877.            }
    0878.            if (!(item is VideoLibrary))
    0879.            {
    0880.                throw new NotSupportedException("Type {0}is not supported by this manager".Arrange(new object[] { item.GetType() }));
    0881.            }
    0882.            return IsCheckedOut((VideoLibrary)item);
    0883.        }
    0884. 
    0885.        public bool IsCheckedOut(Album item)
    0886.        {
    0887.            throw new NotSupportedException();
    0888.        }
    0889. 
    0890.        public bool IsCheckedOut(Document item)
    0891.        {
    0892.            return Provider.IsCheckedOut<Document>(item, GetDocuments());
    0893.        }
    0894. 
    0895.        public bool IsCheckedOut(DocumentLibrary item)
    0896.        {
    0897.            throw new NotSupportedException();
    0898.        }
    0899. 
    0900.        public bool IsCheckedOut(Image item)
    0901.        {
    0902.            return Provider.IsCheckedOut<Image>(item, GetImages());
    0903.        }
    0904. 
    0905.        public bool IsCheckedOut(Telerik.Sitefinity.Libraries.Model.Library item)
    0906.        {
    0907.            throw new NotSupportedException();
    0908.        }
    0909. 
    0910.        public bool IsCheckedOut(Video item)
    0911.        {
    0912.            return Provider.IsCheckedOut<Video>(item, GetVideos());
    0913.        }
    0914. 
    0915.        public bool IsCheckedOut(VideoLibrary item)
    0916.        {
    0917.            throw new NotSupportedException();
    0918.        }
    0919. 
    0920.        public bool IsCheckedOutBy(Content item, Guid userId)
    0921.        {
    0922.            if (item is Image)
    0923.            {
    0924.                return IsCheckedOutBy((Image)item, userId);
    0925.            }
    0926.            if (item is Document)
    0927.            {
    0928.                return IsCheckedOutBy((Document)item, userId);
    0929.            }
    0930.            if (item is Video)
    0931.            {
    0932.                return IsCheckedOutBy((Video)item, userId);
    0933.            }
    0934.            if (item is Album)
    0935.            {
    0936.                return IsCheckedOutBy((Album)item, userId);
    0937.            }
    0938.            if (item is Telerik.Sitefinity.Libraries.Model.Library)
    0939.            {
    0940.                return IsCheckedOutBy((Telerik.Sitefinity.Libraries.Model.Library)item, userId);
    0941.            }
    0942.            if (item is DocumentLibrary)
    0943.            {
    0944.                return IsCheckedOutBy((DocumentLibrary)item, userId);
    0945.            }
    0946.            if (!(item is VideoLibrary))
    0947.            {
    0948.                throw new NotSupportedException("Type {0}is not supported by this manager".Arrange(new object[] { item.GetType() }));
    0949.            }
    0950.            return IsCheckedOutBy((VideoLibrary)item, userId);
    0951.        }
    0952. 
    0953.        public bool IsCheckedOutBy(Album item, Guid userId)
    0954.        {
    0955.            throw new NotSupportedException();
    0956.        }
    0957. 
    0958.        public bool IsCheckedOutBy(Document item, Guid userId)
    0959.        {
    0960.            return Provider.IsCheckedOutBy<Document>(item, userId, GetDocuments());
    0961.        }
    0962. 
    0963.        public bool IsCheckedOutBy(DocumentLibrary item, Guid userId)
    0964.        {
    0965.            throw new NotSupportedException();
    0966.        }
    0967. 
    0968.        public bool IsCheckedOutBy(Image item, Guid userId)
    0969.        {
    0970.            return Provider.IsCheckedOutBy<Image>(item, userId, GetImages());
    0971.        }
    0972. 
    0973.        public bool IsCheckedOutBy(Telerik.Sitefinity.Libraries.Model.Library item, Guid userId)
    0974.        {
    0975.            throw new NotSupportedException();
    0976.        }
    0977. 
    0978.        public bool IsCheckedOutBy(Video item, Guid userId)
    0979.        {
    0980.            return Provider.IsCheckedOutBy<Video>(item, userId, GetVideos());
    0981.        }
    0982. 
    0983.        public bool IsCheckedOutBy(VideoLibrary item, Guid userId)
    0984.        {
    0985.            throw new NotSupportedException();
    0986.        }
    0987. 
    0988.        public Content Publish(Content item)
    0989.        {
    0990.            if (item is Image)
    0991.            {
    0992.                return Publish((Image)item);
    0993.            }
    0994.            if (item is Document)
    0995.            {
    0996.                return Publish((Document)item);
    0997.            }
    0998.            if (item is Video)
    0999.            {
    1000.                return Publish((Video)item);
    1001.            }
    1002.            if (item is Album)
    1003.            {
    1004.                return Publish((Album)item);
    1005.            }
    1006.            if (item is Telerik.Sitefinity.Libraries.Model.Library)
    1007.            {
    1008.                return Publish((Telerik.Sitefinity.Libraries.Model.Library)item);
    1009.            }
    1010.            if (item is DocumentLibrary)
    1011.            {
    1012.                return Publish((DocumentLibrary)item);
    1013.            }
    1014.            if (!(item is VideoLibrary))
    1015.            {
    1016.                throw new NotSupportedException("Type {0}is not supported by this manager".Arrange(new object[] { item.GetType() }));
    1017.            }
    1018.            return Publish((VideoLibrary)item);
    1019.        }
    1020. 
    1021.        public Album Publish(Album item)
    1022.        {
    1023.            throw new NotSupportedException();
    1024.        }
    1025. 
    1026.        public virtual Document Publish(Document document)
    1027.        {
    1028.            return Provider.Publish(document, CopyDocument, GetDocuments());
    1029.        }
    1030. 
    1031.        public DocumentLibrary Publish(DocumentLibrary item)
    1032.        {
    1033.            throw new NotSupportedException();
    1034.        }
    1035. 
    1036.        public virtual Image Publish(Image image)
    1037.        {
    1038.            throw new Exception("Publish(Image image)");
    1039.            return Provider.Publish(image, CopyImage, GetImages());
    1040.        }
    1041. 
    1042.        public Telerik.Sitefinity.Libraries.Model.Library Publish(Telerik.Sitefinity.Libraries.Model.Library item)
    1043.        {
    1044.            throw new NotSupportedException();
    1045.        }
    1046. 
    1047.        public virtual Video Publish(Video video)
    1048.        {
    1049.            return Provider.Publish(video, CopyVideo, GetVideos());
    1050.        }
    1051. 
    1052.        public VideoLibrary Publish(VideoLibrary item)
    1053.        {
    1054.            throw new NotSupportedException();
    1055.        }
    1056. 
    1057.        public Content Schedule(Content item, DateTime publicationDate, DateTime? expirationDate)
    1058.        {
    1059.            if (item is Image)
    1060.            {
    1061.                return Schedule((Image)item, publicationDate, expirationDate);
    1062.            }
    1063.            if (item is Document)
    1064.            {
    1065.                return Schedule((Document)item, publicationDate, expirationDate);
    1066.            }
    1067.            if (item is Video)
    1068.            {
    1069.                return Schedule((Video)item, publicationDate, expirationDate);
    1070.            }
    1071.            if (item is Album)
    1072.            {
    1073.                return Schedule((Album)item, publicationDate, expirationDate);
    1074.            }
    1075.            if (item is Telerik.Sitefinity.Libraries.Model.Library)
    1076.            {
    1077.                return Schedule((Telerik.Sitefinity.Libraries.Model.Library)item, publicationDate, expirationDate);
    1078.            }
    1079.            if (item is DocumentLibrary)
    1080.            {
    1081.                return Schedule((DocumentLibrary)item, publicationDate, expirationDate);
    1082.            }
    1083.            if (!(item is VideoLibrary))
    1084.            {
    1085.                throw new NotSupportedException("Type {0}is not supported by this manager".Arrange(new object[] { item.GetType() }));
    1086.            }
    1087.            return Schedule((VideoLibrary)item, publicationDate, expirationDate);
    1088.        }
    1089. 
    1090.        public Album Schedule(Album item, DateTime publicationDate, DateTime? expirationDate)
    1091.        {
    1092.            throw new NotSupportedException();
    1093.        }
    1094. 
    1095.        public Document Schedule(Document item, DateTime publicationDate, DateTime? expirationDate)
    1096.        {
    1097.            return Provider.Schedule(item, publicationDate, expirationDate, CopyDocument, GetDocuments());
    1098.        }
    1099. 
    1100.        public DocumentLibrary Schedule(DocumentLibrary item, DateTime publicationDate, DateTime? expirationDate)
    1101.        {
    1102.            throw new NotSupportedException();
    1103.        }
    1104. 
    1105.        public Image Schedule(Image item, DateTime publicationDate, DateTime? expirationDate)
    1106.        {
    1107.            return Provider.Schedule(item, publicationDate, expirationDate, CopyImage, GetImages());
    1108.        }
    1109. 
    1110.        public Telerik.Sitefinity.Libraries.Model.Library Schedule(Telerik.Sitefinity.Libraries.Model.Library item, DateTime publicationDate, DateTime? expirationDate)
    1111.        {
    1112.            throw new NotSupportedException();
    1113.        }
    1114. 
    1115.        public Video Schedule(Video item, DateTime publicationDate, DateTime? expirationDate)
    1116.        {
    1117.            return Provider.Schedule(item, publicationDate, expirationDate, CopyVideo, GetVideos());
    1118.        }
    1119. 
    1120.        public VideoLibrary Schedule(VideoLibrary item, DateTime publicationDate, DateTime? expirationDate)
    1121.        {
    1122.            throw new NotSupportedException();
    1123.        }
    1124. 
    1125.        public Content Unpublish(Content item)
    1126.        {
    1127.            if (item is Image)
    1128.            {
    1129.                return Unpublish((Image)item);
    1130.            }
    1131.            if (item is Document)
    1132.            {
    1133.                return Unpublish((Document)item);
    1134.            }
    1135.            if (item is Video)
    1136.            {
    1137.                return Unpublish((Video)item);
    1138.            }
    1139.            if (item is Album)
    1140.            {
    1141.                return Unpublish((Album)item);
    1142.            }
    1143.            if (item is Telerik.Sitefinity.Libraries.Model.Library)
    1144.            {
    1145.                return Unpublish((Telerik.Sitefinity.Libraries.Model.Library)item);
    1146.            }
    1147.            if (item is DocumentLibrary)
    1148.            {
    1149.                return Unpublish((DocumentLibrary)item);
    1150.            }
    1151.            if (!(item is VideoLibrary))
    1152.            {
    1153.                throw new NotSupportedException("Type {0}is not supported by this manager".Arrange(new object[] { item.GetType() }));
    1154.            }
    1155.            return Unpublish((VideoLibrary)item);
    1156.        }
    1157. 
    1158.        public virtual Album Unpublish(Album cnt)
    1159.        {
    1160.            throw new NotSupportedException();
    1161.        }
    1162. 
    1163.        public virtual Document Unpublish(Document cnt)
    1164.        {
    1165.            return Provider.Unpublish(cnt, GetDocuments());
    1166.        }
    1167. 
    1168.        public virtual DocumentLibrary Unpublish(DocumentLibrary cnt)
    1169.        {
    1170.            throw new NotSupportedException();
    1171.        }
    1172. 
    1173.        public virtual Image Unpublish(Image cnt)
    1174.        {
    1175.            return Provider.Unpublish(cnt, GetImages());
    1176.        }
    1177. 
    1178.        public virtual Video Unpublish(Video cnt)
    1179.        {
    1180.            return Provider.Unpublish(cnt, GetVideos());
    1181.        }
    1182. 
    1183.        public virtual VideoLibrary Unpublish(VideoLibrary cnt)
    1184.        {
    1185.            throw new NotSupportedException();
    1186.        }
    1187. 
    1188.        public virtual void UpdateThumbnail(Guid id, byte[] data)
    1189.        {
    1190.            var video = GetVideo(id);
    1191.            var image = ImagesHelper.ByteArrayToImage(data);
    1192.            //Provider.UpdateThumbnail(video, image, MimeMapping.GetMimeMapping(".jpg"));
    1193.        }
    1194. 
    1195.        public virtual void Upload(MediaContent content, Stream source, string extension)
    1196.        {
    1197.            throw new Exception("Upload");
    1198.            Provider.Upload(content, source, extension);
    1199.        }
    1200. 
    1201.        public static string LibrariesTempFolder
    1202.        {
    1203.            get
    1204.            {
    1205.                return librariesTempFolder;
    1206.            }
    1207.        }
    1208. 
    1209.        protected override GetDefaultProvider DefaultProviderDelegate
    1210.        {
    1211.            get
    1212.            {
    1213.                return () => Config.Get<LibrariesConfig>().DefaultProvider;
    1214.            }
    1215.        }
    1216. 
    1217.        public override string ModuleName
    1218.        {
    1219.            get
    1220.            {
    1221.                return "Libraries";
    1222.            }
    1223.        }
    1224. 
    1225.        protected override ConfigElementDictionary<string, DataProviderSettings> ProvidersSettings
    1226.        {
    1227.            get
    1228.            {
    1229.                return Config.Get<LibrariesConfig>().Providers;
    1230.            }
    1231.        }
    1232.    }
    1233.}

    I've registered the provider as you mentioned above. If I write a "throw exception" in the constructor of the Provider, is it thrown when I try to open Libraries. So I think, that it might be implementd right. I tried also to define the manager in Sitefinity/Administration/Settings/Advanced/Libraries/Controls/ImagesBackend (and others).

    Frankly said, I dont know if this is the right way/approach for what I'm trying to do. Will I have the posibility to override the methods that do the upload, or would it be better to write a custom module? On the other hand in the second case I had to implement my module in the editor and some other modules, to use the images/files.

    Thank you, for any help and pushing me in the right direction.

    Dieter
      
  4. Ivan Pelovski
    Ivan Pelovski avatar
    43 posts
    Registered:
    24 Sep 2012
    15 Mar 2011
    Link to this post
    Hello Dieter,

    There is a new functionality in Sitefinity SP1 that gives you the ability to extend the way in which the images, videos and documents are stored. This is accomplished by adding the IStorageProviderDecorator interface to be used by the LibrariesDataProvider class. So all you need is to implement the IStorageProviderDecorator interface and to register it in the Sitefinity configuration.
    In your implementation you should write the data access operations for storing files in Amazon-Cloudfront/S3. To register your implementation go to Libraries -> Providers -> OpenAccessDataProvider and replace the existing text in ProviderDecoratorType field with the full type name of your class implementing IStorageProviderDecorator.
    With this new functionality you need to extend/rewrite neither providers nor managers.

    Best wishes,
    Ivan Pelovski
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  5. Dave
    Dave avatar
    37 posts
    Registered:
    26 Dec 2008
    17 Mar 2011
    Link to this post
    Hello Ivan!

    Thank You. That sounds nice :-) I'll try to implement this.

    Unfortunatelly I don't have a field named ProviderDecoratorType in my Configuration-Section. Am I missing something? Do I have to to configuration somewhere else to have these fields?

    My version: Sitefinity 4.0.1210.0 SE

    Greetings, Dieter
  6. Ivan Pelovski
    Ivan Pelovski avatar
    43 posts
    Registered:
    24 Sep 2012
    18 Mar 2011
    Link to this post
    Hello Dieter,

    I am sorry I was mistaken in my last post. This functionality is not included in the SP1 but in the last internal build of Sitefinity. Small changes to the IStorageProviderDecorator interface are exptected for the Q1 release of Sitefinity because of upgrading to a newer version of OpenAccess. We apologize for the inconvenience.

    Regards,
    Ivan Pelovski
    the Telerik team
6 posts, 0 answered