Quantcast
Channel: Developer to developer
Viewing all articles
Browse latest Browse all 9076

Restrictions are not indexed for the child pages when indexed them in the ContentSecuritySaved event

$
0
0

I need to index the child pages when an editor changes the restrictions in a page in CMS.

So, I have handled the ContentSecuritySaved event like below to index all the child pages.

 [InitializableModule]
    public class SecurityEventInitializationModule : IInitializableModule
    {
        public void Initialize(InitializationEngine context)                
        {            
            var secRepos = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<IContentSecurityRepository>();            
            secRepos.ContentSecuritySaved += secRepos_ContentSecuritySaved;
        }        
        public void Preload(string[] parameters) { }
        public void Uninitialize(InitializationEngine context)
        {
            var secRepos = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<IContentSecurityRepository>();
            secRepos.ContentSecuritySaved -= secRepos_ContentSecuritySaved;
        }
        void secRepos_ContentSecuritySaved(object sender, ContentSecurityEventArg e)
        {
           List<IContent> childPages = GetAllChildren(e.ContentLink);
           // Index all child pages
           IContentIndexer indexer = ContentIndexer.Instance;
           indexer.Index(childPages);
        }
    }

It indexes the child pages, but it does not correctly update the restrictions in the index (EPiServer.Find.Cms.ContentExtensions.RolesWithReadAccess property).
In the Find index, The child pages always have the previous restrictions we have defined.

How to have the current restrictions in the Find index ?

More Info on my setup:
All the child pages inherit the settings from parents.


Viewing all articles
Browse latest Browse all 9076

Trending Articles