private static string GetDocumentIdentification(TreeNode page)
 {
     return(HTMLHelper.HTMLEncode(AlternativeUrlHelper.GetDocumentIdentification(page.DocumentName, page.DocumentCulture)));
 }
 private static string GetDocumentIdentification(string pageName, string pageCulture)
 {
     return(HTMLHelper.HTMLEncode(AlternativeUrlHelper.GetDocumentIdentification(pageName, pageCulture)));
 }
    /// <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);
    }