public override void UpdateIndex(IndexRequestItem item, string namedIndexingService)
        {
            // never index data content. it's too slow
            item.DataUri = null;

            base.UpdateIndex(item, namedIndexingService);
        }
        public override void UpdateIndex(IndexRequestItem item)
        {
            // never index data content. it's too slow
            item.DataUri = null;

            base.UpdateIndex(item);
        }
        public override void UpdateIndex(IndexRequestItem item, string namedIndexingService)
        {
            // never index data content. it's too slow
            item.DataUri = null;

            base.UpdateIndex(item, namedIndexingService);
        }
        public override void UpdateIndex(IndexRequestItem item)
        {
            // never index data content. it's too slow
            item.DataUri = null;

            base.UpdateIndex(item);
        }
        private void ConvertContentToIndexItem(IContent content, IndexRequestItem item)
        {
            var contentSecurable = content as IContentSecurable;
            var categorizable    = content as ICategorizable;

            LuceneContentSearchHandler.AddUriToIndexItem(content, item);
            this.AddMetaDataToIndexItem(content, item);
            this.AddSearchablePropertiesToIndexItem(content, item);
            LuceneContentSearchHandler.AddBinaryStorableToIndexItem(content, item);
            if (contentSecurable != null)
            {
                IContentSecurityDescriptor contentSecurityDescriptor = contentSecurable.GetContentSecurityDescriptor();
                if (contentSecurityDescriptor != null && contentSecurityDescriptor.Entries != null)
                {
                    LuceneContentSearchHandler.AddReadAccessToIndexItem(contentSecurityDescriptor.Entries, item);
                }
            }
            else
            {
                item.AccessControlList.Add(string.Format(System.Globalization.CultureInfo.InvariantCulture, "G:{0}", new object[]
                {
                    EveryoneRole.RoleName
                }));
            }
            if (categorizable != null)
            {
                LuceneContentSearchHandler.AddCategoriesToIndexItem(categorizable.Category, item);
            }
            this.AddVirtualPathToIndexItem(content.ContentLink, item);
            LuceneContentSearchHandler.AddItemStatusToIndexItem(item);
            LuceneContentSearchHandler.AddExpirationToIndexItem(content, item);
            item.NamedIndex = this.NamedIndex;
        }
        private void UpdateDescendantItemsOf(IContent contentItem)
        {
            foreach (var childContent in this.contentRepository.GetChildren <IContent>(contentItem.ContentLink))
            {
                var searchableItem = childContent as ISearchable;
                if (searchableItem == null)
                {
                    this.UpdateDescendantItemsOf(childContent);
                }
                else
                {
                    string searchId = LuceneContentSearchHandler.GetSearchId(childContent);
                    var    item     = new IndexRequestItem(searchId, searchableItem.IsSearchable && this.IsInSearchableBranch(childContent) ? IndexAction.Update : IndexAction.Remove);
                    if (item.IndexAction != IndexAction.Remove)
                    {
                        item.AutoUpdateVirtualPath = true;
                        this.ConvertContentToIndexItem(childContent, item);
                    }
                    this.searchHandler.UpdateIndex(item, this.NamedIndexingService);

                    if (searchableItem.AllowIndexChildren)
                    {
                        this.UpdateDescendantItemsOf(childContent);
                    }
                    else
                    {
                        this.RemoveDescendantItemsOf(childContent);
                    }
                }
            }
        }
        // Hieu Le - 2013
        public virtual void UpdateItem(IContent contentItem)
        {
            if (contentItem == null)
            {
                return;
            }

            if (!this.ServiceActive)
            {
                return;
            }

            var searchableItem = contentItem as ISearchable;

            if (searchableItem == null)
            {
                return;
            }

            string searchId = LuceneContentSearchHandler.GetSearchId(contentItem);

            var item = new IndexRequestItem(searchId, searchableItem.IsSearchable && this.IsInSearchableBranch(contentItem) ? IndexAction.Update : IndexAction.Remove);

            if (item.IndexAction != IndexAction.Remove)
            {
                item.AutoUpdateVirtualPath = true;
                this.ConvertContentToIndexItem(contentItem, item);
            }

            this.searchHandler.UpdateIndex(item, this.NamedIndexingService);

            this.UpdateDescendantItemsOf(contentItem);
        }
Beispiel #8
0
        public void ProcessRequest(IndexRequestItem request)
        {
            if (string.IsNullOrEmpty(request?.Action) || request?.Content == null)
            {
                return;
            }
            switch (request.Action)
            {
            case IndexRequestItem.REINDEX:
                _remoteContentIndexRepository.IndexContent(request.Content, request.IncludeChild);
                break;

            case IndexRequestItem.REMOVE:
                _remoteContentIndexRepository.RemoveContentIndex(request.Content, request.IncludeChild);
                break;

            case IndexRequestItem.REMOVE_LANGUAGE:
                _remoteContentIndexRepository.RemoveContentIndex(request.Content, false);
                break;

            case IndexRequestItem.REINDEXSITE:
                _remoteContentIndexRepository.ReindexSite(request.Content);
                break;

            default:
                break;
            }
        }
Beispiel #9
0
 private void IndexContent_Raised(object sender, EventNotificationEventArgs e)
 {
     if (e.RaiserId == LocalRaiserId)
     {
         return;
     }
     this.ProcessRequestInternal(IndexRequestItem.Parse((string)e.Param));
 }
        private static void AddBinaryStorableToIndexItem(IContent content, IndexRequestItem item)
        {
            var binaryStorable = content as IBinaryStorable;

            if (binaryStorable != null && binaryStorable.BinaryData is FileBlob)
            {
                item.DataUri = new Uri(((FileBlob)binaryStorable.BinaryData).FilePath);
            }
        }
        private static void AddExpirationToIndexItem(IContent content, IndexRequestItem item)
        {
            var versionable = content as IVersionable;

            if (versionable != null && versionable.StopPublish != System.DateTime.MaxValue)
            {
                item.PublicationEnd = versionable.StopPublish;
            }
        }
 private void RemoveDescendantItemsOf(IContent contentItem)
 {
     foreach (var childContent in this.contentRepository.GetChildren <IContent>(contentItem.ContentLink))
     {
         var item = new IndexRequestItem(LuceneContentSearchHandler.GetSearchId(childContent), IndexAction.Remove);
         this.searchHandler.UpdateIndex(item, this.NamedIndexingService);
         this.RemoveDescendantItemsOf(childContent);
     }
 }
Beispiel #13
0
 public void ProcessRequestInternal(IndexRequestItem request)
 {
     if (request == null || !IsAvailable())
     {
         return;
     }
     _requestQueue.Enqueue(request);
     _queueProcessTimer.Enabled = true;
 }
 private void AddVirtualPathToIndexItem(ContentReference contentLink, IndexRequestItem item)
 {
     if (!ContentReference.IsNullOrEmpty(contentLink))
     {
         foreach (string current in LuceneContentSearchHandler.GetVirtualPathNodes(contentLink, this.contentRepository))
         {
             item.VirtualPathNodes.Add(current);
         }
     }
 }
Beispiel #15
0
 public void RemoveContentIndex(IContent content, bool includeChild = false)
 {
     _contentIndexRepository.RemoveContentIndex(content, includeChild);
     if (ShouldRaiseEvent)
     {
         var indexRequest = new IndexRequestItem(content, IndexRequestItem.REMOVE, includeChild);
         var param        = indexRequest.RemoteRequest;
         this._eventService.Get(IndexContentEventId).RaiseAsync(LocalRaiserId, param, EventRaiseOption.RaiseBroadcast);
     }
 }
Beispiel #16
0
 public void ReindexSite(IContent content)
 {
     _contentIndexRepository.ReindexSite(content);
     if (ShouldRaiseEvent)
     {
         var indexRequest = new IndexRequestItem(content, IndexRequestItem.REINDEXSITE, true);
         var param        = indexRequest.RemoteRequest;
         this._eventService.Get(IndexContentEventId).RaiseAsync(LocalRaiserId, param, EventRaiseOption.RaiseBroadcast);
     }
 }
        private static void AddUriToIndexItem(IContent content, IndexRequestItem item)
        {
            string url    = PermanentLinkUtility.GetPermanentLinkVirtualPath(content.ContentGuid, ".aspx");
            var    locale = content as ILocale;

            if (locale != null && locale.Language != null)
            {
                url = UriSupport.AddLanguageSelection(url, locale.Language.Name);
            }
            item.Uri = new Url(url).Uri;
        }
 private static void AddCategoriesToIndexItem(CategoryList categories, IndexRequestItem item)
 {
     if (categories == null || categories.Count == 0)
     {
         return;
     }
     foreach (int current in categories)
     {
         item.Categories.Add(current.ToString(CultureInfo.InvariantCulture));
     }
 }
        private void AddMetaDataToIndexItem(IContent content, IndexRequestItem item)
        {
            var locale          = content as ILocale;
            var changeTrackable = content as IChangeTrackable;

            item.Title    = content.Name;
            item.Created  = ((changeTrackable != null) ? changeTrackable.Created : System.DateTime.MinValue);
            item.Modified = ((changeTrackable != null) ? changeTrackable.Changed : System.DateTime.MinValue);
            item.Culture  = ((locale != null) ? LuceneContentSearchHandler.GetCultureIdentifier(locale.Language) : string.Empty);
            item.ItemType = this.GetItemType(content.GetOriginalType());
            item.Authors.Add((changeTrackable != null) ? changeTrackable.CreatedBy : string.Empty);
        }
Beispiel #20
0
 public void ProcessRequest(IndexRequestItem request)
 {
     if (request == null || !IsAvailable())
     {
         return;
     }
     _requestQueue.Enqueue(request);
     if (ShouldRaiseEvent)
     {
         this._eventService.Get(IndexContentEventId).RaiseAsync(LocalRaiserId, request.RemoteRequest, EventRaiseOption.RaiseBroadcast);
     }
     _queueProcessTimer.Enabled = true;
 }
        public virtual void RemoveLanguageBranch(IContent contentItem)
        {
            Validator.ThrowIfNull("contentItem", contentItem);
            if (!this.ServiceActive)
            {
                return;
            }
            string searchId         = LuceneContentSearchHandler.GetSearchId(contentItem);
            var    indexRequestItem = new IndexRequestItem(searchId, IndexAction.Remove);

            indexRequestItem.NamedIndex = this.NamedIndex;
            this.searchHandler.UpdateIndex(indexRequestItem, this.NamedIndexingService);
        }
Beispiel #22
0
        internal static void AddToQueue(IndexRequestItem item, string namedIndexingService)
        {
            if (string.IsNullOrEmpty(namedIndexingService))
            {
                namedIndexingService = SearchSettings.Config.NamedIndexingServices.DefaultService;
            }

            SearchSettings.GetDynamicDataStore().Save(new IndexRequestQueueItem
            {
                IndexItemId          = item.Id,
                NamedIndex           = item.NamedIndex,
                NamedIndexingService = namedIndexingService,
                SyndicationItemXml   = item.ToSyndicationItemXml(),
                Timestamp            = System.DateTime.Now
            });
        }
        public virtual void RemoveItemsByVirtualPath(System.Collections.Generic.ICollection <string> virtualPathNodes)
        {
            Validator.ThrowIfNull("virtualPathNodes", virtualPathNodes);
            if (!ServiceActive || virtualPathNodes.Count == 0)
            {
                return;
            }
            var indexRequestItem = new IndexRequestItem(IgnoreItemSearchId, IndexAction.Remove);

            foreach (string current in virtualPathNodes)
            {
                indexRequestItem.VirtualPathNodes.Add(current);
            }
            indexRequestItem.AutoUpdateVirtualPath = true;
            indexRequestItem.NamedIndex            = this.NamedIndex;
            this.searchHandler.UpdateIndex(indexRequestItem, this.NamedIndexingService);
        }
Beispiel #24
0
        private void ClearSearchItem(object sender, ContentEventArgs e)
        {
            ISearchable seachable = e.Content as ISearchable;

            if (seachable?.IsSearchable == true)
            {
                return;
            }

            CultureInfo  language    = null;
            ILocalizable localizable = e.Content as ILocalizable;

            if (localizable != null)
            {
                language = localizable.Language;
            }

            string           searchId  = string.Concat(e.Content.ContentGuid, "|", language);
            IndexRequestItem indexItem = new IndexRequestItem(searchId, IndexAction.Remove);

            SearchHandler.Instance.UpdateIndex(indexItem);
        }
        public virtual void MoveItem(ContentReference contentLink)
        {
            if (!this.ServiceActive)
            {
                return;
            }
            if (ContentReference.IsNullOrEmpty(contentLink))
            {
                return;
            }
            IContent content;

            if (!this.contentRepository.TryGet(contentLink, this.languageSelectorFactory.MasterLanguage(), out content))
            {
                return;
            }
            string searchId         = LuceneContentSearchHandler.GetSearchId(content);
            var    indexRequestItem = new IndexRequestItem(searchId, IndexAction.Update);

            indexRequestItem.AutoUpdateVirtualPath = true;
            this.ConvertContentToIndexItem(content, indexRequestItem);
            this.searchHandler.UpdateIndex(indexRequestItem, this.NamedIndexingService);
        }
        public IndexShard LocateShard(IndexRequestItem indexRequest)
        {
            BuildServices();
            IContent content = null;

            if (indexRequest.Content != null)
            {
                content = indexRequest.Content;
            }
            else if (indexRequest.ContentId != 0)
            {
                _contentRepository.TryGet(new ContentReference(indexRequest.ContentId), out content);
            }
            if (content != null)
            {
                var site = _siteDefinitionResolver.GetByContent(content.ContentLink, true, true);
                if (site != null)
                {
                    return(GetOrCreateShard(site.StartPage.ToReferenceWithoutVersion().ToString()));
                }
            }
            return(null);
        }
 private void AddSearchablePropertiesToIndexItem(IContent content, IndexRequestItem item)
 {
     item.DisplayText = string.Join(System.Environment.NewLine, this.GetSearchablePropertyValues(content, content.ContentTypeID).ToArray());
 }
Beispiel #28
0
        public virtual void ProcessRequest(string indexRequest)
        {
            if (string.IsNullOrEmpty(indexRequest))
            {
                return;
            }
            var request = IndexRequestItem.Parse(indexRequest);

            if (request == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(request.Action))
            {
                return;
            }
            switch (request.Action)
            {
            case IndexRequestItem.REINDEX:
                if (request.Content != null)
                {
                    _contentIndexRepository.IndexContent(request.Content, request.IncludeChild);
                }
                break;

            case IndexRequestItem.REMOVE:
                if (request.Content != null)
                {
                    _contentIndexRepository.RemoveContentIndex(request.Content, request.IncludeChild);
                }
                break;

            case IndexRequestItem.REMOVE_LANGUAGE:
                if (request.Content != null)
                {
                    _contentIndexRepository.RemoveContentLanguageBranch(request.Content);
                }
                break;

            case IndexRequestItem.REINDEXSITE:
                if (request.Content != null)
                {
                    _contentIndexRepository.ReindexSite(request.Content);
                }
                break;

            case IndexRequestItem.CALCULATESIZE:
                var folderSize = _contentIndexRepository.GetIndexFolderSize();
                var store      = typeof(ServerInfomation).GetOrCreateStore();
                store.Save(new ServerInfomation()
                {
                    IndexSize        = folderSize,
                    LocalRaiserId    = LocalRaiserId,
                    Name             = Environment.MachineName,
                    InRecovering     = IndexRecoveryService.IN_RECOVERING,
                    InHealthChecking = IndexHealthCheckService.IS_HEALTH_CHECK
                });
                break;

            case IndexRequestItem.RESETINDEX:
                var resetRequest = (ResetIndexRequestItem)request;
                if (resetRequest.TargetMachine != null && resetRequest.TargetMachine != Guid.Empty)
                {
                    if (LocalRaiserId == resetRequest.TargetMachine.Value)
                    {
                        _contentIndexRepository.ResetIndexDirectory();
                    }
                }
                else
                {
                    _contentIndexRepository.ResetIndexDirectory();
                }
                break;

            case IndexRequestItem.RECOVERINDEX:
                var recoverRequest = (RecoverIndexRequestItem)request;
                if (recoverRequest.TargetMachine != null && recoverRequest.TargetMachine != Guid.Empty)
                {
                    if (LocalRaiserId == recoverRequest.TargetMachine.Value)
                    {
                        _indexRecoveryService.RecoverIndex(true);
                    }
                }
                else
                {
                    _indexRecoveryService.RecoverIndex(true);
                }
                break;

            default:
                break;
            }
        }
 internal static void AddReadAccessToIndexItem(System.Collections.Generic.IEnumerable <AccessControlEntry> acl, IndexRequestItem item)
 {
     foreach (AccessControlEntry current in acl)
     {
         if ((current.Access & AccessLevel.Read) == AccessLevel.Read)
         {
             item.AccessControlList.Add(string.Format("{0}:{1}", (current.EntityType == SecurityEntityType.User) ? "U" : "G", current.Name));
         }
     }
 }
 private static void AddItemStatusToIndexItem(IndexRequestItem item)
 {
     item.ItemStatus = ItemStatus.Approved;
 }