Exemplo n.º 1
0
        /// <summary>
        /// Gets the document.
        /// </summary>
        /// <param name="fetchXmlResult">The fetch XML result.</param>
        /// <returns></returns>
        /// <exception cref="System.InvalidOperationException">
        /// </exception>
        public CrmEntityIndexDocument GetDocument(FetchXmlResult fetchXmlResult)
        {
            var entityMetadata = _dataContext.GetEntityMetadata(_fetchXml.LogicalName, _metadataCache);

            var attributes = entityMetadata.Attributes.ToDictionary(a => a.LogicalName, a => a);

            var document = new Document();

            var primaryKey = Guid.Empty;

            var languageValueAdded = false;

            var lcid = 0;

            // Store the entity logical name and the logical name of the primary key attribute in the index document, for
            // easier later retrieval of the entity corresponding to this document.
            document.Add(
                new Field(_index.LogicalNameFieldName, entityMetadata.LogicalName, Field.Store.YES, Field.Index.NOT_ANALYZED));
            document.Add(
                new Field(
                    _index.PrimaryKeyLogicalNameFieldName,
                    entityMetadata.PrimaryIdAttribute,
                    Field.Store.YES,
                    Field.Index.NOT_ANALYZED));
            try
            {
                var content = new ContentFieldBuilder();

                foreach (var fetchXmlField in fetchXmlResult)
                {
                    // Treat the primary key field in a special way.
                    if (fetchXmlField.Name == entityMetadata.PrimaryIdAttribute)
                    {
                        primaryKey = new Guid(fetchXmlField.Value);

                        document.Add(new Field(_index.PrimaryKeyFieldName, primaryKey.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));
                        document.Add(new Field(fetchXmlField.Name, primaryKey.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));

                        // Adding webroles for the webpage to the index.
                        if (FeatureCheckHelper.IsFeatureEnabled(FeatureNames.CmsEnabledSearching))
                        {
                            if (entityMetadata.LogicalName == "adx_webpage")
                            {
                                ADXTrace.Instance.TraceInfo(TraceCategory.Monitoring, "CMS is enabled. Adding roles for adx_webpage index");

                                var ruleNames = CmsIndexHelper.GetWebPageWebRoles(this._contentMapProvider, primaryKey);
                                this.AddWebRolesToDocument(document, ruleNames);
                            }

                            if (entityMetadata.LogicalName == "adx_ideaforum")
                            {
                                ADXTrace.Instance.TraceInfo(TraceCategory.Monitoring, "CMS is enabled. Adding roles for adx_ideaforum index");

                                var ruleNames = CmsIndexHelper.GetIdeaForumWebRoles(this._contentMapProvider, primaryKey);
                                this.AddWebRolesToDocument(document, ruleNames);
                            }

                            if (entityMetadata.LogicalName == "adx_communityforum")
                            {
                                ADXTrace.Instance.TraceInfo(TraceCategory.Monitoring, "CMS is enabled. Adding roles for adx_communityforum index");

                                var ruleNames = CmsIndexHelper.GetForumsWebRoles(this._contentMapProvider, primaryKey);
                                this.AddWebRolesToDocument(document, ruleNames);
                            }
                        }
                        continue;
                    }

                    if (FeatureCheckHelper.IsFeatureEnabled(FeatureNames.CmsEnabledSearching))
                    {
                        if (fetchXmlField.Name == "adx_ideaforumid" && entityMetadata.LogicalName == "adx_idea")
                        {
                            ADXTrace.Instance.TraceInfo(TraceCategory.Monitoring, "CMS is enabled. Adding roles for adx_idea index");

                            var ruleNames = CmsIndexHelper.GetIdeaForumWebRoles(
                                this._contentMapProvider,
                                new Guid(fetchXmlField.Value));
                            this.AddWebRolesToDocument(document, ruleNames);
                        }

                        // Based off the Parent Web Page get the webroles for each given entity
                        if ((fetchXmlField.Name == "adx_parentpageid" && entityMetadata.LogicalName == "adx_blog") ||
                            (fetchXmlField.Name == "adx_blog_blogpost.adx_parentpageid" && entityMetadata.LogicalName == "adx_blogpost") ||
                            (fetchXmlField.Name == "adx_parentpageid" && entityMetadata.LogicalName == "adx_webfile"))
                        {
                            ADXTrace.Instance.TraceInfo(TraceCategory.Monitoring, string.Format("CMS is enabled. Adding roles for {0} index", fetchXmlField.Name));

                            var ruleNames = CmsIndexHelper.GetWebPageWebRoles(this._contentMapProvider, new Guid(fetchXmlField.Value));
                            this.AddWebRolesToDocument(document, ruleNames);
                        }

                        if ((fetchXmlField.Name == "adx_forumid" && entityMetadata.LogicalName == "adx_communityforumthread") ||
                            (fetchXmlField.Name == "adx_communityforumpost_communityforumthread.adx_forumid" && entityMetadata.LogicalName == "adx_communityforumpost"))
                        {
                            ADXTrace.Instance.TraceInfo(TraceCategory.Monitoring, string.Format("CMS is enabled. Adding roles for {0} index", fetchXmlField.Name));

                            var ruleNames = CmsIndexHelper.GetForumsWebRoles(
                                this._contentMapProvider,
                                new Guid(fetchXmlField.Value));
                            this.AddWebRolesToDocument(document, ruleNames);
                        }
                        if (entityMetadata.LogicalName == "annotation" && fetchXmlField.Name == "knowledgearticle.knowledgearticleid")
                        {
                            var id = new Guid(fetchXmlField.Value);
                            document.Add(new Field("annotation_knowledgearticleid", id.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));
                        }
                    }


                    // Store the title of the result in a special field.
                    if (fetchXmlField.Name == _titleAttributeLogicalName && entityMetadata.LogicalName != "annotation")
                    {
                        document.Add(new Field(_index.TitleFieldName, fetchXmlField.Value, Field.Store.YES, Field.Index.ANALYZED));
                    }

                    // Store the language locale code in a separate field.
                    if (_localeConfig.IsLanguageCodeLogicalName(fetchXmlField.Name))
                    {
                        document.Add(
                            new Field(
                                _index.LanguageLocaleCodeFieldName,
                                fetchXmlField.Value.ToLowerInvariant(),
                                Field.Store.YES,
                                Field.Index.NOT_ANALYZED));
                        languageValueAdded = true;
                    }

                    // Store the language locale LCID in a separate field.
                    if (_localeConfig.IsLCIDLogicalName(fetchXmlField.Name) && int.TryParse(fetchXmlField.Value, out lcid))
                    {
                        document.Add(
                            new Field(_index.LanguageLocaleLCIDFieldName, fetchXmlField.Value, Field.Store.YES, Field.Index.NOT_ANALYZED));
                    }

                    // Skip metadata parsing for language fields
                    if (_localeConfig.CanSkipMetadata(fetchXmlField.Name))
                    {
                        continue;
                    }

                    FetchXmlLinkAttribute link;

                    if (_fetchXml.TryGetLinkAttribute(fetchXmlField, out link))
                    {
                        var linkEntityMetadata = _dataContext.GetEntityMetadata(link.EntityLogicalName, _metadataCache);

                        var linkAttributeMetadata = linkEntityMetadata.Attributes.FirstOrDefault(a => a.LogicalName == link.LogicalName);

                        if (linkAttributeMetadata == null)
                        {
                            throw new InvalidOperationException("Unable to retrieve attribute metadata for FetchXML result field {0} for entity {1}.".FormatWith(link.LogicalName, linkEntityMetadata.LogicalName));
                        }

                        var fieldName = fetchXmlResult.Any(f => f.Name == link.LogicalName)
                                                                                        ? "{0}.{1}".FormatWith(linkEntityMetadata.LogicalName, linkAttributeMetadata.LogicalName)
                                                                                        : link.LogicalName;

                        //Renaming product identifier field to  "associated.product"
                        if (FeatureCheckHelper.IsFeatureEnabled(FeatureNames.CmsEnabledSearching) &&
                            (this._fetchXml.LogicalName == "knowledgearticle" && fieldName == "record2id" ||
                             this._fetchXml.LogicalName == "annotation" && fieldName == "productid"))
                        {
                            fieldName = FixedFacetsConfiguration.ProductFieldFacetName;
                        }
                        if (FeatureCheckHelper.IsFeatureEnabled(FeatureNames.CmsEnabledSearching) &&
                            (this._fetchXml.LogicalName == "knowledgearticle" && (fieldName == "notetext" || fieldName == "filename")))
                        {
                            fieldName = "related_" + fieldName;
                        }

                        if (fieldName == "related_filename")
                        {
                            fetchXmlField.Value = Regex.Replace(fetchXmlField.Value, "[._,-]", " ");
                        }
                        if (fieldName == "related_notetext")
                        {
                            fetchXmlField.Value = fetchXmlField.Value.Substring(GetNotesFilterPrefix().Length);
                        }

                        AddDocumentFields(document, fieldName, fetchXmlField, linkAttributeMetadata, content);
                    }
                    else
                    {
                        AttributeMetadata attributeMetadata;

                        if (!attributes.TryGetValue(fetchXmlField.Name, out attributeMetadata))
                        {
                            throw new InvalidOperationException(
                                      ResourceManager.GetString("Attribute_Metadata_Fetchxml_Retrieve_Exception")
                                      .FormatWith(fetchXmlField.Name, entityMetadata.LogicalName));
                        }

                        if (fetchXmlField.Name == "filename")
                        {
                            fetchXmlField.Value = Regex.Replace(fetchXmlField.Value, "[._,-]", " ");
                        }
                        if (fetchXmlField.Name == "notetext")
                        {
                            fetchXmlField.Value = fetchXmlField.Value.Substring(GetNotesFilterPrefix().Length);
                        }

                        AddDocumentFields(document, fetchXmlField.Name, fetchXmlField, attributeMetadata, content);
                    }
                }

                if (FeatureCheckHelper.IsFeatureEnabled(FeatureNames.CmsEnabledSearching))
                {
                    // Add the default value for entities that are not Knowledge articles for the Product filtering field.
                    if (entityMetadata.LogicalName != "knowledgearticle")
                    {
                        document.Add(
                            new Field(
                                FixedFacetsConfiguration.ProductFieldFacetName,
                                this._index.ProductAccessNonKnowledgeArticleDefaultValue,
                                Field.Store.NO,
                                Field.Index.NOT_ANALYZED));
                        document.Add(
                            new Field(FixedFacetsConfiguration.ContentAccessLevel,
                                      "public",
                                      Field.Store.NO,
                                      Field.Index.NOT_ANALYZED));
                    }
                    else
                    {
                        // If there aren't any products associated to the article add the default value so then at query time
                        //    based on the site setting it will add these to the result or not.
                        var productsDocument = document.GetField(FixedFacetsConfiguration.ProductFieldFacetName);
                        if (productsDocument == null)
                        {
                            document.Add(
                                new Field(
                                    FixedFacetsConfiguration.ProductFieldFacetName,
                                    this._index.ProductAccessDefaultValue,
                                    Field.Store.NO,
                                    Field.Index.NOT_ANALYZED));
                        }
                    }
                }

                if (!languageValueAdded)
                {
                    document.Add(new Field(_index.LanguageLocaleCodeFieldName, _index.LanguageLocaleCodeDefaultValue, Field.Store.YES, Field.Index.NOT_ANALYZED));
                }

                // Add the field for the main, analyzed, search content.
                document.Add(new Field(_index.ContentFieldName, content.ToString(), _index.StoreContentField ? Field.Store.YES : Field.Store.NO, Field.Index.ANALYZED));

                if (_index.AddScopeField)
                {
                    var scopeField = document.GetField(_index.ScopeValueSourceFieldName);

                    var scopeValue = scopeField == null ? _index.ScopeDefaultValue : scopeField.StringValue;

                    document.Add(new Field(_index.ScopeFieldName, scopeValue, Field.Store.NO, Field.Index.NOT_ANALYZED));
                }

                if (FeatureCheckHelper.IsFeatureEnabled(FeatureNames.CmsEnabledSearching))
                {
                    this.AddDefaultWebRoleToAllDocumentsNotUnderCMS(document, entityMetadata.LogicalName);
                    this.AddUrlDefinedToDocument(document, entityMetadata.LogicalName, fetchXmlResult);
                }

                var documentAnalyzer = lcid > 0
                                                                                   ? _index.GetLanguageSpecificAnalyzer(lcid)
                                                                                   : _index.Analyzer;
                return(new CrmEntityIndexDocument(document, documentAnalyzer, primaryKey));
            }
            catch (Exception e)
            {
                ADXTrace.Instance.TraceError(TraceCategory.Application, string.Format("Error: Exception when trying to create the index document. {0}", e));
            }
            return(new CrmEntityIndexDocument(document, _index.Analyzer, primaryKey));
        }
Exemplo n.º 2
0
        public void UpdateCmsEntityTree(string entityLogicalName, Guid rootEntityId, int?lcid = null)
        {
            ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Begin updating Cms Entity Tree for logical name: {0}, rootEntityId: {1}", entityLogicalName, rootEntityId));
            var timer = Stopwatch.StartNew();

            if (entityLogicalName == "adx_webpage")
            {
                IContentMapProvider contentMapProvider  = AdxstudioCrmConfigurationManager.CreateContentMapProvider();
                Guid[] descendantLocalizedWebPagesGuids = CmsIndexHelper.GetDescendantLocalizedWebpagesForWebpage(contentMapProvider, rootEntityId, lcid).ToArray();
                Guid[] descendantRootWebPagesGuids      = CmsIndexHelper.GetDescendantRootWebpagesForWebpage(contentMapProvider, rootEntityId).ToArray();

                // -------------------- WEB PAGES ------------------------------
                if (descendantLocalizedWebPagesGuids.Any())
                {
                    var localizedWebPagesUnderTargetWebPageFilter = new Fetch.Filter
                    {
                        Type       = Microsoft.Xrm.Sdk.Query.LogicalOperator.Or,
                        Conditions = new List <Fetch.Condition>()
                        {
                            new Fetch.Condition
                            {
                                Attribute = "adx_webpageid",
                                Operator  = Microsoft.Xrm.Sdk.Query.ConditionOperator.In,
                                Values    = descendantLocalizedWebPagesGuids.Cast <object>().ToList()
                            },
                        }
                    };

                    var webPageIndexers = _index.GetIndexers("adx_webpage", filters: new List <Fetch.Filter> {
                        localizedWebPagesUnderTargetWebPageFilter
                    });

                    UpdateWithIndexers("adx_webpage", webPageIndexers);
                }

                // -------------------- FORUMS ------------------------------
                if (descendantRootWebPagesGuids.Any())
                {
                    var rootWebPagesUnderTargetWebPageFilter = new Fetch.Filter
                    {
                        Type       = Microsoft.Xrm.Sdk.Query.LogicalOperator.Or,
                        Conditions = new List <Fetch.Condition>()
                        {
                            new Fetch.Condition
                            {
                                Attribute = "adx_webpageid",
                                Operator  = Microsoft.Xrm.Sdk.Query.ConditionOperator.In,
                                Values    = descendantRootWebPagesGuids.Cast <object>().ToList()
                            },
                        }
                    };

                    var forumBlogToParentPageLink = new Fetch.Link
                    {
                        Name          = "adx_webpage",
                        FromAttribute = "adx_webpageid",
                        ToAttribute   = "adx_parentpageid",
                        Filters       = new List <Fetch.Filter>()
                        {
                            rootWebPagesUnderTargetWebPageFilter
                        }
                    };

                    Fetch.Link languageFilter = null;

                    if (lcid.HasValue)
                    {
                        languageFilter = new Fetch.Link
                        {
                            Name          = "adx_websitelanguage",
                            FromAttribute = "adx_websitelanguageid",
                            ToAttribute   = "adx_websitelanguageid",
                            Type          = Microsoft.Xrm.Sdk.Query.JoinOperator.Inner,
                            Alias         = "websitelangforupdatefilter",
                            Links         = new List <Fetch.Link>()
                            {
                                new Fetch.Link
                                {
                                    Name          = "adx_portallanguage",
                                    FromAttribute = "adx_portallanguageid",
                                    ToAttribute   = "adx_portallanguageid",
                                    Type          = Microsoft.Xrm.Sdk.Query.JoinOperator.Inner,
                                    Alias         = "portallangforupdatefilter",
                                    Filters       = new List <Fetch.Filter>()
                                    {
                                        new Fetch.Filter
                                        {
                                            Type       = Microsoft.Xrm.Sdk.Query.LogicalOperator.And,
                                            Conditions = new List <Fetch.Condition>()
                                            {
                                                new Fetch.Condition
                                                {
                                                    Attribute = "adx_lcid",
                                                    Operator  = Microsoft.Xrm.Sdk.Query.ConditionOperator.Equal,
                                                    Value     = lcid.Value
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        };
                    }

                    var forumBlogLinks = new List <Fetch.Link>()
                    {
                        forumBlogToParentPageLink
                    };
                    if (languageFilter != null)
                    {
                        forumBlogLinks.Add(languageFilter);
                    }

                    var forumIndexers = _index.GetIndexers("adx_communityforum", links: forumBlogLinks);
                    UpdateWithIndexers("adx_communityforum", forumIndexers);

                    var forumThreadForumLinks = new List <Fetch.Link>()
                    {
                        forumBlogToParentPageLink
                    };
                    if (languageFilter != null)
                    {
                        forumThreadForumLinks.Add(languageFilter);
                    }

                    var forumThreadToParentPageLink = new Fetch.Link
                    {
                        Name          = "adx_communityforum",
                        FromAttribute = "adx_communityforumid",
                        ToAttribute   = "adx_forumid",
                        Links         = forumThreadForumLinks
                    };

                    var forumThreadIndexers = _index.GetIndexers("adx_communityforumthread",
                                                                 links: new List <Fetch.Link>()
                    {
                        forumThreadToParentPageLink
                    });
                    UpdateWithIndexers("adx_communityforumthread", forumThreadIndexers);

                    var forumPostToParentPageLink = new Fetch.Link
                    {
                        Name          = "adx_communityforumthread",
                        FromAttribute = "adx_communityforumthreadid",
                        ToAttribute   = "adx_forumthreadid",
                        Alias         = "adx_communityforumpost_communityforumthread",
                        Links         = new List <Fetch.Link>()
                        {
                            forumThreadToParentPageLink
                        }
                    };

                    var forumPostIndexers = _index.GetIndexers("adx_communityforumpost",
                                                               links: new List <Fetch.Link>()
                    {
                        forumPostToParentPageLink
                    });
                    UpdateWithIndexers("adx_communityforumpost", forumPostIndexers);

                    // -------------------- BLOGS ------------------------------
                    var blogIndexers = _index.GetIndexers("adx_blog", links: forumBlogLinks);
                    UpdateWithIndexers("adx_blog", blogIndexers);

                    var blogPostBlogLinks = new List <Fetch.Link>()
                    {
                        forumBlogToParentPageLink
                    };
                    if (languageFilter != null)
                    {
                        blogPostBlogLinks.Add(languageFilter);
                    }

                    var blogPostParentPageLink = new Fetch.Link
                    {
                        Name          = "adx_blog",
                        FromAttribute = "adx_blogid",
                        ToAttribute   = "adx_blogid",
                        Alias         = "adx_blog_blogpost",
                        Links         = blogPostBlogLinks
                    };

                    var blogPostIndexers = _index.GetIndexers("adx_blogpost", links: new List <Fetch.Link> {
                        blogPostParentPageLink
                    });
                    UpdateWithIndexers("adx_blogpost", blogPostIndexers);
                }
            }
            else if (entityLogicalName == "adx_communityforum")
            {
                UpdateEntity("adx_communityforum", rootEntityId);

                var inForumFilterForThread = new Fetch.Filter
                {
                    Type       = Microsoft.Xrm.Sdk.Query.LogicalOperator.And,
                    Conditions = new List <Fetch.Condition>()
                    {
                        new Fetch.Condition
                        {
                            Attribute = "adx_forumid",
                            Operator  = Microsoft.Xrm.Sdk.Query.ConditionOperator.Equal,
                            Value     = rootEntityId
                        }
                    }
                };

                var forumThreadIndexers = _index.GetIndexers("adx_communityforumthread", filters: new List <Fetch.Filter> {
                    inForumFilterForThread
                });
                UpdateWithIndexers("adx_communityforumthread", forumThreadIndexers);

                var inForumFilterForPost = new Fetch.Link
                {
                    Name          = "adx_communityforumthread",
                    FromAttribute = "adx_communityforumthreadid",
                    ToAttribute   = "adx_forumthreadid",
                    Alias         = "adx_communityforumpost_communityforumthread",
                    Filters       = new List <Fetch.Filter>()
                    {
                        inForumFilterForThread
                    }
                };

                var forumPostIndexers = _index.GetIndexers("adx_communityforumpost", links: new List <Fetch.Link> {
                    inForumFilterForPost
                });
                UpdateWithIndexers("adx_communityforumpost", forumPostIndexers);
            }
            else if (entityLogicalName == "adx_ideaforum")
            {
                UpdateEntity("adx_ideaforum", rootEntityId);

                var inIdeaForumFilter = new Fetch.Filter
                {
                    Type       = Microsoft.Xrm.Sdk.Query.LogicalOperator.And,
                    Conditions = new List <Fetch.Condition>()
                    {
                        new Fetch.Condition
                        {
                            Attribute = "adx_ideaforumid",
                            Operator  = Microsoft.Xrm.Sdk.Query.ConditionOperator.Equal,
                            Value     = rootEntityId
                        }
                    }
                };

                var ideaIndexers = _index.GetIndexers("adx_idea", filters: new List <Fetch.Filter> {
                    inIdeaForumFilter
                });
                UpdateWithIndexers("adx_idea", ideaIndexers);
            }

            timer.Stop();
            ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Cms Entity Tree updated for logical name: {0}, rootEntityId: {1}, timespan: {2}", entityLogicalName, rootEntityId, timer.ElapsedMilliseconds));
        }
Exemplo n.º 3
0
        private void AddUrlDefinedToDocument(Document document, string entityLogicalName, FetchXmlResult fetchXmlResult)
        {
            var isUrlDefined = false;

            if (entityLogicalName == "adx_blog")
            {
                var blogPartialUrlFetch = fetchXmlResult.FirstOrDefault(x => x.Name == "adx_partialurl");
                var parentPageIdFetch   = fetchXmlResult.FirstOrDefault(x => x.Name == "adx_parentpageid");
                if (blogPartialUrlFetch == null || parentPageIdFetch == null)
                {
                    return;
                }

                var blogPartialUrl = blogPartialUrlFetch.Value;
                isUrlDefined = CmsIndexHelper.IsWebPageUrlDefined(
                    this._contentMapProvider,
                    new Guid(parentPageIdFetch.Value),
                    blogPartialUrl);
            }
            if (entityLogicalName == "adx_blogpost")
            {
                var blogPostPartialUrlFetch = fetchXmlResult.FirstOrDefault(x => x.Name == "adx_partialurl");
                var blogPartialUrlFetch     = fetchXmlResult.FirstOrDefault(x => x.Name == "adx_blog_blogpost.adx_partialurl");
                var parentWebPageIdFetch    = fetchXmlResult.FirstOrDefault(x => x.Name == "adx_blog_blogpost.adx_parentpageid");
                if (blogPartialUrlFetch == null || parentWebPageIdFetch == null)
                {
                    return;
                }
                var blogPostId = fetchXmlResult.FirstOrDefault(x => x.Name == "adx_blogpostid");
                if (blogPostPartialUrlFetch == null && blogPostId == null)
                {
                    return;
                }
                var blogPostPartialUrl = blogPostPartialUrlFetch == null ? blogPostId.Value : blogPostPartialUrlFetch.Value;
                var blogPartialUrl     = blogPartialUrlFetch.Value;

                var blogPostsCombineUrl = string.Format("{0}/{1}", blogPartialUrl, blogPostPartialUrl);

                isUrlDefined = CmsIndexHelper.IsWebPageUrlDefined(
                    this._contentMapProvider,
                    new Guid(parentWebPageIdFetch.Value),
                    blogPostsCombineUrl);
            }

            if (entityLogicalName == "adx_communityforum")
            {
                var forumIdFetch =
                    fetchXmlResult.FirstOrDefault(x => x.Name == "adx_communityforumid");
                if (forumIdFetch == null)
                {
                    return;
                }
                isUrlDefined = CmsIndexHelper.IsForumUrlDefined(
                    this._contentMapProvider,
                    new Guid(forumIdFetch.Value));
            }
            if (entityLogicalName == "adx_communityforumthread")
            {
                var forumIdFetch =
                    fetchXmlResult.FirstOrDefault(x => x.Name == "adx_forumid");
                if (forumIdFetch == null)
                {
                    return;
                }
                isUrlDefined = CmsIndexHelper.IsForumUrlDefined(
                    this._contentMapProvider,
                    new Guid(forumIdFetch.Value));
            }
            if (entityLogicalName == "adx_communityforumpost")
            {
                var forumIdFetch =
                    fetchXmlResult.FirstOrDefault(x => x.Name == "adx_communityforumpost_communityforumthread.adx_forumid");
                if (forumIdFetch == null)
                {
                    return;
                }
                isUrlDefined = CmsIndexHelper.IsForumUrlDefined(
                    this._contentMapProvider,
                    new Guid(forumIdFetch.Value));
            }

            if (entityLogicalName == "adx_idea")
            {
                var ideaPartialUrlFetch      = fetchXmlResult.FirstOrDefault(x => x.Name == "adx_partialurl");
                var ideaForumPartialUrlFetch = fetchXmlResult.FirstOrDefault(x => x.Name == "adx_idea_ideaforum.adx_partialurl");
                if (ideaPartialUrlFetch == null || ideaForumPartialUrlFetch == null)
                {
                    return;
                }
                var ideaPartialUrl      = ideaPartialUrlFetch.Value;
                var ideaForumPartialUrl = ideaForumPartialUrlFetch.Value;

                isUrlDefined = !string.IsNullOrEmpty(ideaPartialUrl) && !string.IsNullOrEmpty(ideaForumPartialUrl);
            }
            if (entityLogicalName == "adx_ideaforum")
            {
                var ideaForumPartialUrlFetch = fetchXmlResult.FirstOrDefault(x => x.Name == "adx_partialurl");
                if (ideaForumPartialUrlFetch == null)
                {
                    return;
                }
                isUrlDefined = !string.IsNullOrEmpty(ideaForumPartialUrlFetch.Value);
            }

            if (entityLogicalName == "incident")
            {
                isUrlDefined = CmsIndexHelper.IsSiteMakerUrlDefined(this._contentMapProvider, "Case");
            }

            if (entityLogicalName == "adx_webfile")
            {
                var webfilePartialUrlFetch = fetchXmlResult.FirstOrDefault(x => x.Name == "adx_partialurl");
                var webPageIdFetch         = fetchXmlResult.FirstOrDefault(x => x.Name == "adx_parentpageid");
                if (webfilePartialUrlFetch == null || webPageIdFetch == null)
                {
                    return;
                }
                isUrlDefined = CmsIndexHelper.IsWebPageUrlDefined(
                    this._contentMapProvider,
                    new Guid(webPageIdFetch.Value),
                    webfilePartialUrlFetch.Value);
            }

            if (entityLogicalName == "adx_webpage")
            {
                var webpageId = fetchXmlResult.FirstOrDefault(x => x.Name == "adx_webpageid");
                if (webpageId == null)
                {
                    return;
                }
                var primaryId = new Guid(webpageId.Value);
                isUrlDefined = CmsIndexHelper.IsWebPageUrlDefined(this._contentMapProvider, primaryId);
            }

            if (!this.oOBUrlDefinedEntities.Contains(entityLogicalName))
            {
                isUrlDefined = true;
            }

            document.Add(
                new Field(this._index.IsUrlDefinedFieldName, isUrlDefined.ToString(), Field.Store.NO, Field.Index.NOT_ANALYZED));
        }