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); }
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); } }
private void AddVirtualPathToIndexItem(ContentReference contentLink, IndexRequestItem item) { if (!ContentReference.IsNullOrEmpty(contentLink)) { foreach (string current in LuceneContentSearchHandler.GetVirtualPathNodes(contentLink, this.contentRepository)) { item.VirtualPathNodes.Add(current); } } }
private static string GetSearchId(IContent content) { System.Globalization.CultureInfo language = null; var locale = content as ILocale; if (locale != null) { language = locale.Language; } return(LuceneContentSearchHandler.CreateSearchId(content.ContentGuid, language)); }
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); }
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); }
public virtual string GetItemType(Type contentType) { Validator.ThrowIfNull("contentType", contentType); var stringBuilder = new System.Text.StringBuilder(LuceneContentSearchHandler.GetItemTypeSection(contentType)); if (contentType.IsClass) { while (contentType.BaseType != typeof(object)) { contentType = contentType.BaseType; stringBuilder.Append(" "); stringBuilder.Append(LuceneContentSearchHandler.GetItemTypeSection(contentType)); } } stringBuilder.Append(" "); stringBuilder.Append(LuceneContentSearchHandler.BaseItemType); return(stringBuilder.ToString()); }
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); }
private static string CreateSearchId(System.Guid contentGuid, System.Globalization.CultureInfo language) { return(string.Format("{0}|{1}", contentGuid, LuceneContentSearchHandler.GetCultureIdentifier(language))); }
public static string GetItemTypeSection <T>() { return(LuceneContentSearchHandler.GetItemTypeSection(typeof(T))); }