/// <summary> /// Returns a list of tab and redirects from the database, for the specified portal /// Assumes that the dictionary should have any existing items replaced if the portalid is specified /// and the portal tabs already exist in the dictionary. /// </summary> /// <param name="existingTabs"></param> /// <param name="portalId"></param> /// <param name="settings"></param> /// <param name="customAliasTabs"></param> /// <remarks> /// Each dictionary entry in the return value is a complex data type of another dictionary that is indexed by the url culture. If there is /// only one culture for the Url, it will be that culture. /// </remarks> /// <returns></returns> private static SharedDictionary <int, SharedDictionary <string, string> > BuildUrlDictionary(SharedDictionary <int, SharedDictionary <string, string> > existingTabs, int portalId, FriendlyUrlSettings settings, ref SharedDictionary <string, string> customAliasTabs) { //fetch tabs with redirects var tabs = FriendlyUrlController.GetTabs(portalId, false, null, settings); if (existingTabs == null) { existingTabs = new SharedDictionary <int, SharedDictionary <string, string> >(); } if (customAliasTabs == null) { customAliasTabs = new SharedDictionary <string, string>(); } //go through each tab in the found list foreach (TabInfo tab in tabs.Values) { //check the custom alias tabs collection and add to the dictionary where necessary foreach (var customAlias in tab.CustomAliases) { string key = tab.TabID.ToString() + ":" + customAlias.Key; using (customAliasTabs.GetWriteLock()) //obtain write lock on custom alias Tabs { if (customAliasTabs.ContainsKey(key) == false) { customAliasTabs.Add(key, customAlias.Value); } } } foreach (TabUrlInfo redirect in tab.TabUrls) { if (redirect.HttpStatus == "200") { string url = redirect.Url; //770 : add in custom alias into the tab path for the custom Urls if (redirect.PortalAliasUsage != PortalAliasUsageType.Default && redirect.PortalAliasId > 0) { //there is a custom http alias specified for this portal alias PortalAliasInfo alias = PortalAliasController.Instance.GetPortalAliasByPortalAliasID(redirect.PortalAliasId); if (alias != null) { string customHttpAlias = alias.HTTPAlias; url = customHttpAlias + "::" + url; } } string cultureKey = redirect.CultureCode.ToLowerInvariant(); var locales = LocaleController.Instance.GetLocales(portalId).Values; if (String.IsNullOrEmpty(cultureKey)) { //Add entry for each culture foreach (Locale locale in locales) { AddEntryToDictionary(existingTabs, portalId, tab, locale.Code.ToLowerInvariant(), url); } } else { AddEntryToDictionary(existingTabs, portalId, tab, cultureKey, url); } } } } return(existingTabs); }
/// <summary> /// Returns a list of tab and redirects from the database, for the specified portal /// Assumes that the dictionary should have any existing items replaced if the portalid is specified /// and the portal tabs already exist in the dictionary. /// </summary> /// <param name="existingTabs"></param> /// <param name="portalId"></param> /// <param name="settings"></param> /// <param name="customAliasTabs"></param> /// <remarks> /// Each dictionary entry in the return value is a complex data type of another dictionary that is indexed by the url culture. If there is /// only one culture for the Url, it will be that culture. /// </remarks> /// <returns></returns> private static SharedDictionary <int, SharedDictionary <string, string> > BuildUrlDictionary(SharedDictionary <int, SharedDictionary <string, string> > existingTabs, int portalId, FriendlyUrlSettings settings, ref SharedDictionary <string, string> customAliasTabs) { //fetch tabs with redirects var tabs = FriendlyUrlController.GetTabs(portalId, false, null, settings); if (existingTabs == null) { existingTabs = new SharedDictionary <int, SharedDictionary <string, string> >(); } if (customAliasTabs == null) { customAliasTabs = new SharedDictionary <string, string>(); } //go through each tab in the found list foreach (TabInfo tab in tabs.Values) { //check the custom alias tabs collection and add to the dictionary where necessary foreach (var customAlias in tab.CustomAliases) { string key = tab.TabID.ToString() + ":" + customAlias.Key; using (customAliasTabs.GetWriteLock()) //obtain write lock on custom alias Tabs { if (customAliasTabs.ContainsKey(key) == false) { customAliasTabs.Add(key, customAlias.Value); } } } foreach (TabUrlInfo redirect in tab.TabUrls) { if (redirect.HttpStatus == "200") { string url = redirect.Url; //770 : add in custom alias into the tab path for the custom Urls if (redirect.PortalAliasUsage != PortalAliasUsageType.Default && redirect.PortalAliasId > 0) { //there is a custom http alias specified for this portal alias var pac = new PortalAliasController(); PortalAliasInfo alias = pac.GetPortalAliasByPortalAliasID(redirect.PortalAliasId); if (alias != null) { string customHttpAlias = alias.HTTPAlias; url = customHttpAlias + "::" + url; } } string cultureKey = redirect.CultureCode.ToLower(); int tabid = tab.TabID; using (existingTabs.GetWriteLock()) { if (existingTabs.ContainsKey(tabid) == false) { var entry = new SharedDictionary <string, string>(); using (entry.GetWriteLock()) { entry.Add(cultureKey, url); } //871 : use lower case culture code as key existingTabs.Add(tab.TabID, entry); } else { SharedDictionary <string, string> entry = existingTabs[tabid]; //replace tab if existing but was retreieved from tabs call if (tab.PortalID == portalId || portalId == -1) { using (entry.GetWriteLock()) { if (entry.ContainsKey(cultureKey) == false) { //add the culture and set in parent dictionary //871 : use lower case culture code as key entry.Add(cultureKey, url); existingTabs[tabid] = entry; } } } } } } } } return(existingTabs); }