/// <summary> /// Returns <see cref="String.Empty"/> when <paramref name="alternativeUrl"/> was saved. /// If error occurs during saving the <paramref name="alternativeUrl"/>, corresponding error message is returned. /// </summary> private string SaveData(AlternativeUrlInfo alternativeUrl) { if (String.IsNullOrWhiteSpace(alternativeUrl.AlternativeUrlUrl.NormalizedUrl)) { return(GetString("general.requiresvalue")); } try { AlternativeUrlInfoProvider.SetInfoCheckForConflictingPage(alternativeUrl); } catch (InvalidAlternativeUrlException ex) when(ex.ConflictingPage != null) { return(String.Format(GetString("alternativeurl.isinconflictwithpage"), alternativeUrl.AlternativeUrlUrl, AlternativeUrlHelper.GetDocumentIdentification(ex.ConflictingPage.DocumentNamePath, ex.ConflictingPage.DocumentCulture))); } catch (InvalidAlternativeUrlException ex) when(ex.ConflictingAlternativeUrl != null) { var page = DocumentHelper.GetDocument(ex.ConflictingAlternativeUrl.AlternativeUrlDocumentID, new TreeProvider()); return(String.Format(GetString("alternativeurl.isinconflictwithalternativeurl"), alternativeUrl.AlternativeUrlUrl, AlternativeUrlHelper.GetDocumentIdentification(page.DocumentNamePath, page.DocumentCulture))); } catch (InvalidAlternativeUrlException ex) when(!String.IsNullOrEmpty(ex.ExcludedUrl) || ex.AlternativeUrl != null) { var errorMessage = SettingsKeyInfoProvider.GetValue("CMSAlternativeURLsErrorMessage", SiteContext.CurrentSiteID); return(String.IsNullOrEmpty(errorMessage) ? GetString("settingskey.cmsalternativeurlsfallbackerrormessage") : ResHelper.LocalizeString(errorMessage)); } catch (InvalidAlternativeUrlException) { return(String.Format(GetString("general.mustbeunique"), TypeHelper.GetNiceObjectTypeName(AlternativeUrlInfo.OBJECT_TYPE))); } catch (RegexMatchTimeoutException) { return(String.Format(GetString("settingskey.cmsalternativeurlstimeouterrormessage"), alternativeUrl.AlternativeUrlUrl)); } DocumentManager.SaveDocument(); return(String.Empty); }
/// <summary> /// Returns <see cref="String.Empty"/> when <paramref name="alternativeUrl"/> was saved. /// If error occurs during saving the <paramref name="alternativeUrl"/>, corresponding error message is returned. /// </summary> private string SaveData(AlternativeUrlInfo alternativeUrl) { alternativeUrl.AlternativeUrlUrl = AlternativeUrlHelper.NormalizeAlternativeUrl(txtAltUrl.Text); if (String.IsNullOrWhiteSpace(alternativeUrl.AlternativeUrlUrl.NormalizedUrl)) { return(GetString("general.requiresvalue")); } try { AlternativeUrlInfoProvider.SetInfoCheckForConflictingPage(alternativeUrl); } catch (InvalidAlternativeUrlException ex) when(ex.CollisionData != null) { var collisionData = ex.CollisionData; if (collisionData.CultureVersionExists) { var editDocumentLink = $"<a onclick=\"window.CMSContentManager.changed(false); EditDocument({collisionData.NodeID}, 'Properties.URLs', {ScriptHelper.GetString(collisionData.CultureCode)})\">{GetDocumentIdentification(collisionData.PageName, collisionData.CultureCode)}</a>"; return(String.Format(GetString("alternativeurl.isinconflictwithpage"), alternativeUrl.AlternativeUrlUrl, editDocumentLink)); } else { var editDocumentLink = $"<a onclick=\"window.CMSContentManager.changed(false); EditDocument({collisionData.NodeID}, 'Properties.URLs|{PageRoutingUIHelper.SLUGS_LIST_SUBTAB_NAME}', {ScriptHelper.GetString(collisionData.ExistingCultureCode)})\">{collisionData.PageName}</a>"; return(String.Format(GetString("alternativeurl.isinconflictwithnottranslatedpage"), alternativeUrl.AlternativeUrlUrl, GetCultureShortName(collisionData.CultureCode), editDocumentLink)); } } catch (InvalidAlternativeUrlException ex) when(ex.ConflictingAlternativeUrl != null) { var page = DocumentHelper.GetDocument(ex.ConflictingAlternativeUrl.AlternativeUrlDocumentID, new TreeProvider()); var editDocumentLink = $"<a onclick=\"window.CMSContentManager.changed(false); EditDocument({page.NodeID}, 'Properties.URLs', {ScriptHelper.GetString(page.DocumentCulture)})\">{GetDocumentIdentification(page)}</a>"; return(String.Format(GetString("alternativeurl.isinconflictwithalternativeurl"), alternativeUrl.AlternativeUrlUrl, editDocumentLink)); } catch (InvalidAlternativeUrlException ex) when(!String.IsNullOrEmpty(ex.ExcludedUrl) || ex.AlternativeUrl != null) { var errorMessage = SettingsKeyInfoProvider.GetValue("CMSAlternativeURLsErrorMessage", Node.NodeSiteID); return(String.IsNullOrEmpty(errorMessage) ? GetString("settingskey.cmsalternativeurlsfallbackerrormessage") : ResHelper.LocalizeString(errorMessage)); } catch (InvalidAlternativeUrlException) { return(String.Format(GetString("general.mustbeunique"), TypeHelper.GetNiceObjectTypeName(AlternativeUrlInfo.OBJECT_TYPE))); } catch (RegexMatchTimeoutException) { return(String.Format(GetString("settingskey.cmsalternativeurlstimeouterrormessage"), alternativeUrl.AlternativeUrlUrl)); } catch (Exception ex) { Service.Resolve <IEventLogService>().LogException("Alternative URLs", "EDIT", ex); return(GetString("alternativeurl.generalerror")); } DocumentManager.SaveDocument(); txtAltUrl.Text = alternativeUrl.AlternativeUrlUrl.NormalizedUrl; return(String.Empty); }