News Custom Provider

8 posts, 0 answers
  1. Felipe
    Felipe avatar
    1 posts
    Member since:
    Jul 2010

    Posted 14 Feb 2011 Link to this post

    Hi all.
    I am trying to create my own NewsDataProvider for read my news.
    Today I have two origins. I think I have to create two providers. But, how?
    Where I found some sample? Or detailed documentantion?

    Thanks a lot.

    -- EDITED

    This is my current code. It is in an separated assembly.

    using System;
    using System.Collections.Generic;
    using System.Collections.Specialized;
    using System.Configuration.Provider;
    using System.IO;
    using System.Xml;
    using Telerik.Web.UI;

    namespace XP.Portal.CMS.Providers
    {
       
        public class ReutersDataProvider : Telerik.Sitefinity.Modules.News.NewsDataProvider, Telerik.Sitefinity.Data.IOpenAccessDataProvider
        {
            private static System.Reflection.Assembly[] peristentAssemblies;
            private string[] supportedPermissionSets = new string[] { "Products", "Comments" };

            public ReutersDataProvider()
            {
            }

            protected override void Initialize(string providerName, NameValueCollection config, Type managerType)
            {
                if (config == null)
                    throw new ArgumentNullException("config");
                if (string.IsNullOrEmpty(providerName))
                    providerName = "ReutersDataProvider";

                base.Initialize(providerName, config, managerType);
            }

            protected override void Initialize(string providerName, NameValueCollection config, Type managerType, bool initializeDecorator)
            {
                if (config == null)
                    throw new ArgumentNullException("config");
                if (string.IsNullOrEmpty(providerName))
                    providerName = "ReutersDataProvider";
                
                initializeDecorator = false;
                base.Initialize(providerName, config, managerType, initializeDecorator);
            }

            /// <summary>
            /// Gets a unique key for each data provider base.
            /// </summary>
            /// <value></value>
            public override string RootKey
            {
                get { return "ReutersDataProvider"; }
            }

            /// <summary>
            /// Gets the permission sets relevant to this specific secured object.
            /// To be overridden by relevant providers (which involve security roots)
            /// </summary>
            /// <value>The supported permission sets.</value>
            public override string[] SupportedPermissionSets
            {
                get
                {
                    return this.supportedPermissionSets;
                }

                set
                {
                    this.supportedPermissionSets = value;
                }
            }


            public override Telerik.Sitefinity.News.Model.NewsItem CreateNewsItem(Guid id)
            {
                throw new NotImplementedException("Lucas 1");
            }

            public override Telerik.Sitefinity.News.Model.NewsItem CreateNewsItem()
            {
                throw new NotImplementedException("Lucas 2");
            }

            public override void Delete(Telerik.Sitefinity.News.Model.NewsItem newsItemToDelete)
            {
                throw new NotImplementedException("Lucas 3");
            }

            public override Telerik.Sitefinity.News.Model.NewsItem GetNewsItem(Guid id)
            {
                throw new NotImplementedException("Lucas 4");
            }

            public override System.Linq.IQueryable<Telerik.Sitefinity.News.Model.NewsItem> GetNewsItems()
            {
                throw new NotImplementedException("Lucas 5");
            }



            public override Telerik.Sitefinity.Security.Model.ISecuredObject GetSecurityRoot()
            {
                return base.GetSecurityRoot();
            }

            public override Telerik.Sitefinity.Security.Model.ISecuredObject GetSecurityRoot(bool create)
            {
                return base.GetSecurityRoot(create);
            }

            #region IOpenAccessDataProvider

            /// <summary>
            /// Gets or sets the database instance for this provider.
            /// </summary>
            /// <value>The database.</value>
            public Telerik.OpenAccess.Database Database
            {
                get;
                set;
            }

            /// <summary>
            /// Gets a value indicating whether to use implicit transactions.
            /// The recommended value for this property is true.
            /// </summary>
            /// <value>
            /// <c>true</c> if [use implicit transactions]; otherwise, <c>false</c>.
            /// </value>
            public bool UseImplicitTransactions
            {
                get { return true; }
            }

            /// <summary>
            /// The list of all assemblies with persistent classes inside.
            /// Only this list of assemblies will be used, it must be complete!
            /// </summary>
            /// <returns>The persistent assemblies.</returns>
            /// <value>The persistent assemblies.</value>
            public System.Reflection.Assembly[] GetPersistentAssemblies()
            {
                return peristentAssemblies;
            }

            #endregion
        }
    }


    The above code generate an error when the system try to execute the GetSecurityRoot method.
    What I need to do?

    Lucas Massena
    XP Investimentos CCTVM S/A
  2. Ivan Dimitrov
    Admin
    Ivan Dimitrov avatar
    78 posts

    Posted 15 Feb 2011 Link to this post

    Hi Felipe,

    Most probably you are getting an exception for Missing Decorator Exception, because the IDataProviderDecorator  is null. You can also see a base implementation for custom data provider in our sample products catalog module that comes with the SDK installation. Please check ProductsDataProvider class.

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. lcmassena
    lcmassena avatar
    4 posts
    Member since:
    Feb 2011

    Posted 18 Feb 2011 Link to this post

    Hi Kind!
    Thanks for the answer.
    So now I have another problem. I did the following code but I have received an error when returning data on GetNewsItems method. Take a look on first and second commented lines in the method.

    Where is my miskate? What I need to do? Can I use the NewsEntity class to return my own data?


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Collections.Specialized;
    using System.Configuration.Provider;
    using System.IO;
    using System.Xml;
    using Telerik.Web.UI;

    namespace XP.Portal.CMS.Providers
    {
        [Telerik.Sitefinity.Modules.GenericContent.Data.ContentProviderDecorator(typeof(Telerik.Sitefinity.Modules.GenericContent.Data.OpenAccessContentDecorator))]
        public class ReutersDataProvider : Telerik.Sitefinity.Modules.News.NewsDataProvider, Telerik.Sitefinity.Data.IOpenAccessDataProvider
        {
            private static System.Reflection.Assembly[] peristentAssemblies;
            private string[] supportedPermissionSets = new string[] { "Products", "Comments" };

            public ReutersDataProvider()
            {
                peristentAssemblies = new System.Reflection.Assembly[] { typeof(Telerik.Sitefinity.News.Model.NewsItem).Assembly };
            }

            protected override void Initialize(string providerName, NameValueCollection config, Type managerType)
            {
                if (config == null)
                    throw new ArgumentNullException("config");
                if (string.IsNullOrEmpty(providerName))
                    providerName = "ReutersDataProvider";

                base.Initialize(providerName, config, managerType);
            }

            protected override void Initialize(string providerName, NameValueCollection config, Type managerType, bool initializeDecorator)
            {
                if (config == null)
                    throw new ArgumentNullException("config");
                if (string.IsNullOrEmpty(providerName))
                    providerName = "ReutersDataProvider";
                
                //initializeDecorator = false;
                base.Initialize(providerName, config, managerType, initializeDecorator);
            }

            /// <summary>
            /// Gets a unique key for each data provider base.
            /// </summary>
            /// <value></value>
            public override string RootKey
            {
                get { return "ReutersDataProvider"; }
            }

            /// <summary>
            /// Gets the permission sets relevant to this specific secured object.
            /// To be overridden by relevant providers (which involve security roots)
            /// </summary>
            /// <value>The supported permission sets.</value>
            public override string[] SupportedPermissionSets
            {
                get
                {
                    return this.supportedPermissionSets;
                }

                set
                {
                    this.supportedPermissionSets = value;
                }
            }


            public override Telerik.Sitefinity.News.Model.NewsItem CreateNewsItem(Guid id)
            {
                throw new NotImplementedException("Lucas 1");
            }

            public override Telerik.Sitefinity.News.Model.NewsItem CreateNewsItem()
            {
                throw new NotImplementedException("Lucas 2");
            }

            public override void Delete(Telerik.Sitefinity.News.Model.NewsItem newsItemToDelete)
            {
                throw new NotImplementedException("Lucas 3");
            }

            public override Telerik.Sitefinity.News.Model.NewsItem GetNewsItem(Guid id)
            {
                return null;
                throw new NotImplementedException("Lucas 4");
            }

            public override System.Linq.IQueryable<Telerik.Sitefinity.News.Model.NewsItem> GetNewsItems()
            {
                //List<Telerik.Sitefinity.News.Model.NewsItem> vList = new List<Telerik.Sitefinity.News.Model.NewsItem>();
                //return vList.AsQueryable();

                var appName = this.ApplicationName;

                var query =
                    Telerik.Sitefinity.Data.Linq.SitefinityQuery
                    .Get<Telerik.Sitefinity.News.Model.NewsItem>(this, System.Reflection.MethodBase.GetCurrentMethod())
                    .Where(b => b.ApplicationName == appName);

                return query;
            }



            public override Telerik.Sitefinity.Security.Model.ISecuredObject GetSecurityRoot()
            {
                return base.GetSecurityRoot();
            }

            public override Telerik.Sitefinity.Security.Model.ISecuredObject GetSecurityRoot(bool create)
            {
                return base.GetSecurityRoot(create);
            }


            #region IOpenAccessDataProvider

            /// <summary>
            /// Gets or sets the database instance for this provider.
            /// </summary>
            /// <value>The database.</value>
            public Telerik.OpenAccess.Database Database
            {
                get;
                set;
            }

            /// <summary>
            /// Gets a value indicating whether to use implicit transactions.
            /// The recommended value for this property is true.
            /// </summary>
            /// <value>
            /// <c>true</c> if [use implicit transactions]; otherwise, <c>false</c>.
            /// </value>
            public bool UseImplicitTransactions
            {
                get { return true; }
            }

            /// <summary>
            /// The list of all assemblies with persistent classes inside.
            /// Only this list of assemblies will be used, it must be complete!
            /// </summary>
            /// <returns>The persistent assemblies.</returns>
            /// <value>The persistent assemblies.</value>
            public System.Reflection.Assembly[] GetPersistentAssemblies()
            {
                return peristentAssemblies;
            }

            #endregion
        }
    }



    Regards,
    Lucas C Massena
  4. Ivan Dimitrov
    Admin
    Ivan Dimitrov avatar
    78 posts

    Posted 23 Feb 2011 Link to this post

    Hi lcmassena,

    Could you let me know what is the error you are getting inside GetNewsItems ?

    Kind regards,
    Ivan Dimitrov
    the Telerik team
  5. lcmassena
    lcmassena avatar
    4 posts
    Member since:
    Feb 2011

    Posted 23 Feb 2011 Link to this post

    Hi Ivan.
    A curious thing is happening. My current code is the following.
    When I create a new NewsItem the propertiesTitle, Content and some others have disappeared causing an "Object reference not set" error.
    When I comment the lines "Item.Title = new Lstring("Titulo " + i.ToString());" "Item.Content = new Lstring("Content " + i.ToString());" and run the code, the "var securityRoot = this.GetSecurityRoot();" is allways null.
    If I comment the code "var securityRoot..." and run again, the following error is shown:

    Unable to cast object of type 'System.Linq.EnumerableQuery`1[Telerik.Sitefinity.News.Model.NewsItem]' to type 'Telerik.Sitefinity.Security.IPermissionApplier'.

    What I need to do?

    Thanks in advance!


    List<Telerik.Sitefinity.News.Model.NewsItem> vList = new List<Telerik.Sitefinity.News.Model.NewsItem>();

                for (int i = 0; i < 10; i++)
                {
                    Telerik.Sitefinity.News.Model.NewsItem Item = new Telerik.Sitefinity.News.Model.NewsItem("/Reuters", Guid.NewGuid());

                    Item.Owner = Telerik.Sitefinity.Security.SecurityManager.GetCurrentUserId();
                    var dateValue = DateTime.UtcNow;
                    Item.DateCreated = dateValue;
                    Item.PublicationDate = dateValue;
                    Item.DateCreated = dateValue.AddDays(-10).AddSeconds(120);
                    Item.ExpirationDate = dateValue.AddDays(10).AddSeconds(120);
                    Item.PublicationDate = dateValue.AddSeconds(120);

                    Item.Title = new Lstring("Titulo " + i.ToString());
                    Item.Content = new Lstring("Content " + i.ToString());

                    // news permissions inherit form the security root
                    var securityRoot = this.GetSecurityRoot();
                    if (securityRoot != null)
                    {
                        this.providerDecorator.CreatePermissionInheritanceAssociation(securityRoot, Item);
                    }
                    else
                    {
                        var msg = Res.Get<SecurityResources>().NoSecurityRoot;
                        msg = string.Format(msg, typeof(Telerik.Sitefinity.News.Model.NewsItem).AssemblyQualifiedName);
                        throw new InvalidOperationException(msg);
                    }

                    if (Item.Id != Guid.Empty)
                    {
                        this.GetScope().Add(Item);
                    }


                    //Item.Title = "Title " + i.ToString();
                    //Item.Content = "Content from item " + i.ToString();

                    vList.Add(Item);
                }

                return vList.AsQueryable();
  6. Alon Rotem
    Admin
    Alon Rotem avatar
    2 posts

    Posted 01 Mar 2011 Link to this post

    Hi lcmassena,

    I tried to run the code you have supplied below but did not get the errors you specified.
    Here's a detailed list of the steps I took in order to make this run and produce the dummy news items:

    I created a XP.Portal.CMS class library under the SitefinityWebApp solution, added the code you posted on 2/18/2011 as ReutersDataProvider class, and added the relevant references to make everything build successfully.

    I added the code you posted for creating news items as a method of the ReutersDataProvider with minor changes as follows:

    01.public IQueryable<Telerik.Sitefinity.News.Model.NewsItem> CreateDemoItems()
    02.{
    03.    List<Telerik.Sitefinity.News.Model.NewsItem> vList =
    04.        new List<Telerik.Sitefinity.News.Model.NewsItem>();
    05. 
    06.    for (int i = 0; i < 10; i++)
    07.    {
    08.        Telerik.Sitefinity.News.Model.NewsItem Item =
    09.           new Telerik.Sitefinity.News.Model.NewsItem(
    10.              "/Reuters",
    11.              Guid.NewGuid()
    12.           );
    13. 
    14.        if (Item.Id != Guid.Empty)
    15.        {
    16.            this.GetScope().Add(Item);
    17.        }
    18. 
    19.        Item.Owner =
    20.            Telerik
    21.                .Sitefinity
    22.                .Security
    23.                .SecurityManager
    24.                .GetCurrentUserId();
    25.                 
    26.        var dateValue = DateTime.UtcNow;
    27.        Item.DateCreated = dateValue;
    28.        Item.PublicationDate = dateValue;
    29.        Item.DateCreated = dateValue.AddDays(-10).AddSeconds(120);
    30.        Item.ExpirationDate = dateValue.AddDays(10).AddSeconds(120);
    31.        Item.PublicationDate = dateValue.AddSeconds(120);
    32. 
    33.        Item.Title = new Lstring("Titulo " + i.ToString());
    34.        Item.Content = new Lstring("Content from item " + i.ToString());
    35. 
    36.        // news permissions inherit form the security root
    37.        var securityRoot = this.GetSecurityRoot(true);
    38.        if (securityRoot != null)
    39.        {
    40.            this
    41.                .providerDecorator
    42.                .CreatePermissionInheritanceAssociation
    43.                (
    44.                    securityRoot,
    45.                    Item
    46.                );
    47.        }
    48.        else
    49.        {
    50.            var msg = Res.Get<SecurityResources>().NoSecurityRoot;
    51.            msg = string
    52.                .Format(
    53.                    msg,
    54.                    typeof(Telerik.Sitefinity.News.Model.NewsItem)
    55.                    .AssemblyQualifiedName);
    56.            throw new InvalidOperationException(msg);
    57.        }
    58. 
    59.        vList.Add(Item);
    60.    }
    61.    this.providerDecorator.CommitTransaction();
    62. 
    63.    return vList.AsQueryable();
    64.}
    1. In order to overcome the problem with setting the LString properties, you first need to add the item to the scope (see lines #14-#17).
    2. In order to make sure the SecurityRoot is created when I call to fetch it, I added the boolean argument set to true on line #37.
    3. In order to save the newly created items in the system, I added the CommitTransaction call on line #61.
    Also note that I had to add the following code snippet to the ReutersDataProvider class, which was missing in your implementation.
    01.public Telerik.OpenAccess.TransactionMode TransactionConcurrency
    02.{
    03.    get
    04.    {
    05.        return Telerik
    06.                   .OpenAccess
    07.                   .TransactionMode
    08.                   .OPTIMISTIC_NO_LOST_UPDATES;
    09.    }
    10.}

    On the Sitefinity UI under Administration -> Settings -> Advanced -> News -> Providers, I added a new provider, ReutersDataProvider, with the following fields set:


    And an added parameter under it with the following fields set:


    I added a new test aspx page, with a single button on it, which invokes the following code on click:
    1.void btnCreateNews_Click(object sender, EventArgs e)
    2.{
    3.    NewsManager nm = NewsManager.GetManager("ReutersDataProvider");
    4.    ((ReutersDataProvider)nm.Provider).CreateDemoItems();
    5.}

    Once all was saved, the application restarted, the demo page opened and the button clicked, all news items were created successfully, and I could see them on the UI under Content -> News.

    Please see if you can follow that sample, and if it works for you.
    If not, please provider additional information about your exact version and build of Sitefinity, the steps you took for trying to make this run, and the errors you got.

    Thank you.

    Greetings,
    Alon Rotem
    the Telerik team
  7. lcmassena
    lcmassena avatar
    4 posts
    Member since:
    Feb 2011

    Posted 02 Mar 2011 Link to this post

    Hi Alon!
    Thanks for your answer. But the problem persists. How can I send to you my complete ClassLibrary?
    My mission is implement a provider to save and load data from my database, using the CMS interface to manage the information.
    I have changed the inheritance to use Telerick.Sitefinity.Modules.News.NewsDataProvider. This is the only way to return some content to interface. But when the list is returned, the following error is show:

    Unable to cast object of type 'System.Linq.EnumerableQuery`1[Telerik.Sitefinity.News.Model.NewsItem]' to type 'Telerik.Sitefinity.Security.IPermissionApplier'.

    I do not have any idea to solve this.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Reflection;
    using Telerik.Sitefinity.Data;
    using Telerik.Sitefinity.Data.Linq;
    using Telerik.Sitefinity.Localization;
    using Telerik.Sitefinity.Model;
    using Telerik.Sitefinity.Modules.GenericContent.Data;
    using Telerik.Sitefinity.Security;
    using Telerik.Sitefinity.Security.Model;

    namespace XP.Portal.CMS.Providers.News.Data
    {
        /// <summary>
        /// Open access implementation of the products data provider
        /// </summary>
        [ContentProviderDecorator(typeof(OpenAccessContentDecorator))]
        public class OpenAccessProvider : Telerik.Sitefinity.Modules.News.NewsDataProvider, IOpenAccessDataProvider
        {
            #region Constructors

            /// <summary>
            /// Initializes static members of the <see cref="ReutersProvider"/> class.
            /// </summary>
            static OpenAccessProvider()
            {
                peristentAssemblies = new Assembly[] { typeof(Telerik.Sitefinity.News.Model.NewsItem).Assembly };
            }

            protected override void Initialize(string providerName, System.Collections.Specialized.NameValueCollection config, Type managerType)
            {
                base.Initialize(providerName, config, managerType);
            }

            #endregion

            #region IOpenAccessDataProvider

            /// <summary>
            /// Gets or sets the database instance for this provider.
            /// </summary>
            /// <value>The database.</value>
            public Telerik.OpenAccess.Database Database
            {
                get;
                set;
            }

            /// <summary>
            /// Gets a value indicating whether to use implicit transactions.
            /// The recommended value for this property is true.
            /// </summary>
            /// <value>
            /// <c>true</c> if [use implicit transactions]; otherwise, <c>false</c>.
            /// </value>
            public bool UseImplicitTransactions
            {
                get { return true; }
            }

            private static Assembly[] peristentAssemblies;

            /// <summary>
            /// The list of all assemblies with persistent classes inside.
            /// Only this list of assemblies will be used, it must be complete!
            /// </summary>
            /// <returns>The persistent assemblies.</returns>
            /// <value>The persistent assemblies.</value>
            public Assembly[] GetPersistentAssemblies()
            {
                return peristentAssemblies;
            }

            #endregion
            

            /// <summary>
            /// Create a product item with random id
            /// </summary>
            /// <returns>Newly created product item in transaction</returns>
            public override Telerik.Sitefinity.News.Model.NewsItem CreateNewsItem()
            {
                return this.CreateNewsItem(Guid.NewGuid());
            }

            /// <summary>
            /// Create a product item with specific primary key
            /// </summary>
            /// <param name="id">Primary key</param>
            /// <returns>Newly created product item in transaction</returns>
            public override Telerik.Sitefinity.News.Model.NewsItem CreateNewsItem(Guid id)
            {
                Telerik.Sitefinity.News.Model.NewsItem Item = new Telerik.Sitefinity.News.Model.NewsItem("/Reuters", Guid.NewGuid());

                if (Item.Id != Guid.Empty)
                {
                    this.GetScope().Add(Item);
                }

                Item.Owner = Telerik.Sitefinity.Security.SecurityManager.GetCurrentUserId();

                var dateValue = DateTime.UtcNow;
                Item.DateCreated = dateValue;
                Item.PublicationDate = dateValue;
                Item.DateCreated = dateValue.AddDays(-10).AddSeconds(120);
                Item.ExpirationDate = dateValue.AddDays(10).AddSeconds(120);
                Item.PublicationDate = dateValue.AddSeconds(120);

                Item.Title = new Lstring("Titulo ");
                Item.Content = new Lstring("Content from item ");

                // news permissions inherit form the security root
                var securityRoot = this.GetSecurityRoot(true);
                if (securityRoot != null)
                {
                    this.providerDecorator.CreatePermissionInheritanceAssociation(securityRoot, Item);
                }
                else
                {
                    var msg = Res.Get<SecurityResources>().NoSecurityRoot;
                    msg = string.Format(msg, typeof(Telerik.Sitefinity.News.Model.NewsItem).AssemblyQualifiedName);
                    throw new InvalidOperationException(msg);
                }
                return Item;
            }

            /// <summary>
            /// Get a prodct by primary key
            /// </summary>
            /// <param name="id">Primary key</param>
            /// <returns>Product item in transaction</returns>
            /// <exception cref="T:Telerik.Sitefinity.SitefinityExceptions.ItemNotFoundException">When there is no item with the given primary key</exception>
            public override Telerik.Sitefinity.News.Model.NewsItem GetNewsItem(Guid id)
            {
                if (id == Guid.Empty)
                {
                    throw new ArgumentException("Id cannot be Empty Guid");
                }

                // Always use this method. Do NOT change it to query. Catch the exception if the Id can be wrong.
                var newsItem = this.GetScope().GetItemById<Telerik.Sitefinity.News.Model.NewsItem>(id.ToString());
                ((IDataItem)newsItem).Provider = this;
                return newsItem;
            }

            /// <summary>
            /// Get a query of all products in this provider
            /// </summary>
            /// <returns>Query of all products</returns>
            public override IQueryable<Telerik.Sitefinity.News.Model.NewsItem> GetNewsItems()
            {
                List<Telerik.Sitefinity.News.Model.NewsItem> vList = new List<Telerik.Sitefinity.News.Model.NewsItem>();

                for (int i = 0; i < 10; i++)
                {
                    Telerik.Sitefinity.News.Model.NewsItem Item = new Telerik.Sitefinity.News.Model.NewsItem(
                        "/Reuters",
                        Guid.NewGuid()
                    );

                    if (Item.Id != Guid.Empty)
                    {
                        this.GetScope().Add(Item);
                    }

                    Item.Owner = Telerik.Sitefinity.Security.SecurityManager.GetCurrentUserId();

                    var dateValue = DateTime.UtcNow;
                    Item.DateCreated = dateValue;
                    Item.PublicationDate = dateValue;
                    Item.DateCreated = dateValue.AddDays(-10).AddSeconds(120);
                    Item.ExpirationDate = dateValue.AddDays(10).AddSeconds(120);
                    Item.PublicationDate = dateValue.AddSeconds(120);

                    Item.Title = new Lstring("Titulo " + i.ToString());
                    Item.Content = new Lstring("Content from item " + i.ToString());

                    // news permissions inherit form the security root
                    var securityRoot = this.GetSecurityRoot(true);
                    if (securityRoot != null)
                    {
                        this.providerDecorator.CreatePermissionInheritanceAssociation(securityRoot,Item);
                    }
                    else
                    {
                        var msg = Res.Get<SecurityResources>().NoSecurityRoot;
                        msg = string.Format(msg,typeof(Telerik.Sitefinity.News.Model.NewsItem).AssemblyQualifiedName);
                        throw new InvalidOperationException(msg);
                    }

                    vList.Add(Item);
                }
                this.providerDecorator.CommitTransaction();

                return vList.AsQueryable();

                //var query =
                //    SitefinityQuery
                //    .Get<Telerik.Sitefinity.News.Model.NewsItem>(this, MethodBase.GetCurrentMethod())
                //    .Where(b => b.ApplicationName == "/Reuters");

                //return query;
            }

            /// <summary>
            /// Delete a product
            /// </summary>
            /// <param name="product">Product to delete</param>
            public override void Delete(Telerik.Sitefinity.News.Model.NewsItem product)
            {
                var scope = this.GetScope();
                ////remove the item from the parent list of inheritors
                var securityRoot = this.GetSecurityRoot();
                if (securityRoot != null)
                {
                    List<PermissionsInheritanceMap> parentInheritors = securityRoot.PermissionChildren.Where(c => c.ChildObjectId == product.Id).ToList();
                    for (int inheritor = 0; inheritor < parentInheritors.Count(); inheritor++)
                    {
                        securityRoot.PermissionChildren.Remove(parentInheritors[inheritor]);
                    }
                }
                ////remove the relevant permissions
                this.providerDecorator.DeletePermissions(product);
                this.ClearLifecycle(product, this.GetNewsItems());
                if (scope != null)
                {
                    scope.Remove(product);
                }
            }

        }
    }



    Thanks,
        Lucas C Massena
  8. Ivan Dimitrov
    Admin
    Ivan Dimitrov avatar
    78 posts

    Posted 04 Mar 2011 Link to this post

    Hello lcmassena,

    Please open a support request from your account and attach a sample project there or give us a link from where we can download it. We will set the project locally and let you know what the problem is.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
Back to Top