コード例 #1
0
        private string PublishModuleConfig(string moduleName, Component moduleConfigComponent)
        {
            Dictionary <string, string> data = new Dictionary <string, string>();
            ItemFields fields = new ItemFields(moduleConfigComponent.Content, moduleConfigComponent.Schema);

            foreach (Component configComp in fields.GetComponentValues("furtherConfiguration"))
            {
                data = MergeData(data, ReadComponentData(configComp));
                switch (configComp.Title)
                {
                case LocalizationConfigComponentTitle:
                    _localizationConfigurationComponent = configComp;
                    break;

                case EnvironmentConfigComponentTitle:
                    if (Session.ApiVersion.StartsWith("8."))
                    {
                        string cmWebsiteUrl = TopologyManager.GetCmWebsiteUrl();
                        string cmsUrl;
                        if (data.TryGetValue(CmsUrlKey, out cmsUrl) && !string.IsNullOrWhiteSpace(cmsUrl))
                        {
                            Logger.Warning(
                                string.Format("Overriding '{0}' specified in '{1}' Component ('{2}') with CM Website URL obtained from Topology Manager: '{3}'",
                                              CmsUrlKey, EnvironmentConfigComponentTitle, cmsUrl, cmWebsiteUrl)
                                );
                        }
                        else
                        {
                            Logger.Info(string.Format("Setting '{0}' to CM Website URL obtained from Topology Manager: '{1}'", CmsUrlKey, cmWebsiteUrl));
                        }
                        data[CmsUrlKey] = cmWebsiteUrl;
                    }
                    break;

                case SearchConfigComponentTitle:
                    string cdEnvironmentPurpose = Utility.GetCdEnvironmentPurpose(Engine.PublishingContext);
                    if (!string.IsNullOrEmpty(cdEnvironmentPurpose))
                    {
                        string searchQueryUrl = TopologyManager.GetSearchQueryUrl((Publication)configComp.ContextRepository, cdEnvironmentPurpose);
                        if (!string.IsNullOrEmpty(searchQueryUrl))
                        {
                            string legacyConfigKey = Utility.IsXpmEnabled(Engine.PublishingContext) ? StagingSearchIndexKey : LiveSearchIndexKey;
                            Logger.Info(string.Format("Setting '{0}' and '{1}' to Search Query URL obtained from Topology Manager: '{2}'",
                                                      SearchQueryUrlKey, legacyConfigKey, searchQueryUrl));
                            data[legacyConfigKey]   = searchQueryUrl;
                            data[SearchQueryUrlKey] = searchQueryUrl;
                        }
                        else
                        {
                            Logger.Warning(string.Format("No Search Query URL defined in Topology Manager for Publication '{0}' and CD Environment Purpose '{1}'.",
                                                         configComp.ContextRepository.Id, cdEnvironmentPurpose));
                        }
                    }
                    break;
                }
            }
            return(PublishJsonData(data, moduleConfigComponent, moduleName, "config", _configStructureGroup));
        }
コード例 #2
0
 protected virtual string ProcessModule(string moduleName, Component module, StructureGroup sg)
 {
     Dictionary<string, string> data = new Dictionary<string, string>();
     ItemFields fields = new ItemFields(module.Content, module.Schema);
     foreach (var configComp in fields.GetComponentValues("furtherConfiguration"))
     {
         data = MergeData(data, ReadComponentData(configComp));
     }
     return PublishJsonData(data, module, moduleName, "config", sg);
 }
コード例 #3
0
        protected string ProcessModule(string moduleName, Component module, StructureGroup sg)
        {
            Dictionary <string, string> data = new Dictionary <string, string>();
            ItemFields fields = new ItemFields(module.Content, module.Schema);

            foreach (Component configComp in fields.GetComponentValues("resource"))
            {
                data = MergeData(data, ReadComponentData(configComp));
            }
            return(PublishJsonData(data, module, moduleName, "resource", sg));
        }
コード例 #4
0
        private Binary PublishModuleResources(string moduleName, Component moduleConfigComponent, StructureGroup structureGroup)
        {
            ItemFields moduleConfigComponentFields = new ItemFields(moduleConfigComponent.Content, moduleConfigComponent.Schema);

            Dictionary<string, string> resources = new Dictionary<string, string>();
            foreach (Component resourcesComponent in moduleConfigComponentFields.GetComponentValues("resource"))
            {
                resources = MergeData(resources, ExtractKeyValuePairs(resourcesComponent));
            }

            return resources.Count == 0 ? null : AddJsonBinary(resources, moduleConfigComponent, structureGroup, moduleName, variantId: "resources");
        }
コード例 #5
0
        private Binary PublishModuleResources(string moduleName, Component moduleConfigComponent, StructureGroup structureGroup)
        {
            ItemFields moduleConfigComponentFields = new ItemFields(moduleConfigComponent.Content, moduleConfigComponent.Schema);

            Dictionary <string, string> resources = new Dictionary <string, string>();

            foreach (Component resourcesComponent in moduleConfigComponentFields.GetComponentValues("resource"))
            {
                resources = MergeData(resources, ExtractKeyValuePairs(resourcesComponent));
            }

            return(resources.Count == 0 ? null : AddJsonBinary(resources, moduleConfigComponent, structureGroup, moduleName, variantId: "resources"));
        }
 public static Component GetComponentValue(this ItemFields fields, string fieldName)
 {
     return(fields.GetComponentValues(fieldName).FirstOrDefault());
 }
コード例 #7
0
        private Binary PublishModuleConfig(string moduleName, Component moduleConfigComponent)
        {
            Dictionary<string, string> configSettings = new Dictionary<string, string>();
            ItemFields configComponentFields = new ItemFields(moduleConfigComponent.Content, moduleConfigComponent.Schema);
            foreach (Component configComp in configComponentFields.GetComponentValues("furtherConfiguration"))
            {
                configSettings = MergeData(configSettings, ExtractKeyValuePairs(configComp));
                switch (configComp.Title)
                {
                    case LocalizationConfigComponentTitle:
                        _localizationConfigurationComponent = configComp;
                        break;

                    case EnvironmentConfigComponentTitle:
                        string cmWebsiteUrl = TopologyManager.GetCmWebsiteUrl();
                        string cmsUrl;
                        if (configSettings.TryGetValue(CmsUrlKey, out cmsUrl) && !string.IsNullOrWhiteSpace(cmsUrl))
                        {
                            Logger.Warning(
                                string.Format("Overriding '{0}' specified in '{1}' Component ('{2}') with CM Website URL obtained from Topology Manager: '{3}'",
                                    CmsUrlKey, EnvironmentConfigComponentTitle, cmsUrl, cmWebsiteUrl)
                                );
                        }
                        else
                        {
                            Logger.Info(string.Format("Setting '{0}' to CM Website URL obtained from Topology Manager: '{1}'", CmsUrlKey, cmWebsiteUrl));
                        }
                        configSettings[CmsUrlKey] = cmWebsiteUrl;
                        break;

                    case SearchConfigComponentTitle:
                        string cdEnvironmentPurpose = Utility.GetCdEnvironmentPurpose(Engine.PublishingContext);
                        if (!string.IsNullOrEmpty(cdEnvironmentPurpose))
                        {
                            string searchQueryUrl = TopologyManager.GetSearchQueryUrl((Publication)configComp.ContextRepository, cdEnvironmentPurpose);
                            if (!string.IsNullOrEmpty(searchQueryUrl))
                            {
                                string legacyConfigKey = Utility.IsXpmEnabled(Engine.PublishingContext) ? StagingSearchIndexKey : LiveSearchIndexKey;
                                Logger.Info(string.Format("Setting '{0}' and '{1}' to Search Query URL obtained from Topology Manager: '{2}'",
                                    SearchQueryUrlKey, legacyConfigKey, searchQueryUrl));
                                configSettings[legacyConfigKey] = searchQueryUrl;
                                configSettings[SearchQueryUrlKey] = searchQueryUrl;
                            }
                            else
                            {
                                Logger.Warning(string.Format("No Search Query URL defined in Topology Manager for Publication '{0}' and CD Environment Purpose '{1}'.",
                                    configComp.ContextRepository.Id, cdEnvironmentPurpose));
                            }
                        }
                        break;

                }
            }

            return configSettings.Count == 0 ? null : AddJsonBinary(configSettings, moduleConfigComponent, _configStructureGroup, moduleName, "config");
        }