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);
        }
Exemplo n.º 5
0
        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;
        }
Exemplo n.º 6
0
        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);
                    }
                }
            }
        }
Exemplo n.º 7
0
        // 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);
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 9
0
 private void IndexContent_Raised(object sender, EventNotificationEventArgs e)
 {
     if (e.RaiserId == LocalRaiserId)
     {
         return;
     }
     this.ProcessRequestInternal(IndexRequestItem.Parse((string)e.Param));
 }
Exemplo n.º 10
0
        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);
            }
        }
Exemplo n.º 11
0
        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;
            }
        }
Exemplo n.º 12
0
 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);
     }
 }
Exemplo n.º 13
0
 public void ProcessRequestInternal(IndexRequestItem request)
 {
     if (request == null || !IsAvailable())
     {
         return;
     }
     _requestQueue.Enqueue(request);
     _queueProcessTimer.Enabled = true;
 }
Exemplo n.º 14
0
 private void AddVirtualPathToIndexItem(ContentReference contentLink, IndexRequestItem item)
 {
     if (!ContentReference.IsNullOrEmpty(contentLink))
     {
         foreach (string current in LuceneContentSearchHandler.GetVirtualPathNodes(contentLink, this.contentRepository))
         {
             item.VirtualPathNodes.Add(current);
         }
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 17
0
        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;
        }
Exemplo n.º 18
0
 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));
     }
 }
Exemplo n.º 19
0
        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);
        }
Exemplo n.º 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;
 }
Exemplo n.º 21
0
        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);
        }
Exemplo n.º 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
            });
        }
Exemplo n.º 23
0
        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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 25
0
        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);
        }
Exemplo n.º 27
0
 private void AddSearchablePropertiesToIndexItem(IContent content, IndexRequestItem item)
 {
     item.DisplayText = string.Join(System.Environment.NewLine, this.GetSearchablePropertyValues(content, content.ContentTypeID).ToArray());
 }
Exemplo n.º 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;
            }
        }
Exemplo n.º 29
0
 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));
         }
     }
 }
Exemplo n.º 30
0
 private static void AddItemStatusToIndexItem(IndexRequestItem item)
 {
     item.ItemStatus = ItemStatus.Approved;
 }