private void UpdateRegexSettingsInternal(UpdateRegexSettingsRequest request) { var settings = new Dictionary <string, string>() { { FriendlyUrlSettings.IgnoreRegexSetting, request.IgnoreRegex }, { FriendlyUrlSettings.DoNotRewriteRegExSetting, request.DoNotRewriteRegex }, { FriendlyUrlSettings.SiteUrlsOnlyRegexSetting, request.UseSiteUrlsRegex }, { FriendlyUrlSettings.DoNotRedirectUrlRegexSetting, request.DoNotRedirectRegex }, { FriendlyUrlSettings.DoNotRedirectHttpsUrlRegexSetting, request.DoNotRedirectSecureRegex }, { FriendlyUrlSettings.PreventLowerCaseUrlRegexSetting, request.ForceLowerCaseRegex }, { FriendlyUrlSettings.DoNotUseFriendlyUrlRegexSetting, request.NoFriendlyUrlRegex }, { FriendlyUrlSettings.KeepInQueryStringRegexSetting, request.DoNotIncludeInPathRegex }, { FriendlyUrlSettings.UrlsWithNoExtensionRegexSetting, request.ValidExtensionlessUrlsRegex }, { FriendlyUrlSettings.ValidFriendlyUrlRegexSetting, request.RegexMatch } }; settings.ToList().ForEach((value) => { if (this.PortalId == Null.NullInteger) { HostController.Instance.Update(value.Key, value.Value, false); } else { PortalController.Instance.UpdatePortalSetting(this.PortalId, value.Key, value.Value, false, Null.NullString, false); } }); }
public ActionResult UpdateSettings(dynamic requestSettings) { ActionResult actionResult = new ActionResult(); try { PortalInfo portalInfo = PortalController.Instance.GetPortal(PortalSettings.PortalId); portalInfo.PortalName = requestSettings.SiteTitle.Value; PortalController.UpdatePortalSetting(PortalSettings.PortalId, "PageHeadText", string.IsNullOrEmpty(requestSettings.HTMLPageHeader.Value) ? "false" : requestSettings.HTMLPageHeader.Value); PortalController.Instance.UpdatePortalInfo(portalInfo); UpdateGeneralSettingsRequest updateGeneralSettingsRequest = JsonConvert.DeserializeObject <UpdateGeneralSettingsRequest>(requestSettings.UpdateGeneralSettingsRequest.ToString()); UpdateRegexSettingsRequest updateRegexSettingsRequest = JsonConvert.DeserializeObject <UpdateRegexSettingsRequest>(requestSettings.UpdateRegexSettingsRequest.ToString()); SitemapSettingsRequest sitemapSettingsRequest = JsonConvert.DeserializeObject <SitemapSettingsRequest>(requestSettings.SitemapSettingsRequest.ToString()); actionResult = Managers.SEOManager.UpdateGeneralSettings(updateGeneralSettingsRequest); if (actionResult.HasErrors) { return(actionResult); } actionResult = Managers.SEOManager.UpdateRegexSettings(updateRegexSettingsRequest); if (actionResult.HasErrors) { return(actionResult); } actionResult = Managers.SEOManager.UpdateSitemapSettings(sitemapSettingsRequest); if (actionResult.HasErrors) { return(actionResult); } actionResult = UpdateSearch(requestSettings.UpdateSearchData); } catch (Exception exc) { actionResult.AddError(HttpStatusCode.InternalServerError.ToString(), exc.Message); } return(actionResult); }
public HttpResponseMessage UpdateRegexSettings(UpdateRegexSettingsRequest request) { try { List <KeyValuePair <string, string> > validationErrors = new List <KeyValuePair <string, string> >(); if (!ValidateRegex(request.IgnoreRegex)) { validationErrors.Add(new KeyValuePair <string, string>("IgnoreRegex", Localization.GetString("ignoreRegExInvalidPattern", LocalResourcesFile))); } if (!ValidateRegex(request.DoNotRewriteRegex)) { validationErrors.Add(new KeyValuePair <string, string>("DoNotRewriteRegex", Localization.GetString("doNotRewriteRegExInvalidPattern", LocalResourcesFile))); } if (!ValidateRegex(request.UseSiteUrlsRegex)) { validationErrors.Add(new KeyValuePair <string, string>("UseSiteUrlsRegex", Localization.GetString("siteUrlsOnlyRegExInvalidPattern", LocalResourcesFile))); } if (!ValidateRegex(request.DoNotRedirectRegex)) { validationErrors.Add(new KeyValuePair <string, string>("DoNotRedirectRegex", Localization.GetString("doNotRedirectUrlRegExInvalidPattern", LocalResourcesFile))); } if (!ValidateRegex(request.DoNotRedirectSecureRegex)) { validationErrors.Add(new KeyValuePair <string, string>("DoNotRedirectSecureRegex", Localization.GetString("doNotRedirectHttpsUrlRegExInvalidPattern", LocalResourcesFile))); } if (!ValidateRegex(request.ForceLowerCaseRegex)) { validationErrors.Add(new KeyValuePair <string, string>("ForceLowerCaseRegex", Localization.GetString("preventLowerCaseUrlRegExInvalidPattern", LocalResourcesFile))); } if (!ValidateRegex(request.NoFriendlyUrlRegex)) { validationErrors.Add(new KeyValuePair <string, string>("NoFriendlyUrlRegex", Localization.GetString("doNotUseFriendlyUrlsRegExInvalidPattern", LocalResourcesFile))); } if (!ValidateRegex(request.DoNotIncludeInPathRegex)) { validationErrors.Add(new KeyValuePair <string, string>("DoNotIncludeInPathRegex", Localization.GetString("keepInQueryStringRegExInvalidPattern", LocalResourcesFile))); } if (!ValidateRegex(request.ValidExtensionlessUrlsRegex)) { validationErrors.Add(new KeyValuePair <string, string>("ValidExtensionlessUrlsRegex", Localization.GetString("urlsWithNoExtensionRegExInvalidPattern", LocalResourcesFile))); } if (!ValidateRegex(request.RegexMatch)) { validationErrors.Add(new KeyValuePair <string, string>("RegexMatch", Localization.GetString("validFriendlyUrlRegExInvalidPattern", LocalResourcesFile))); } if (validationErrors.Count > 0) { return(this.Request.CreateResponse(HttpStatusCode.BadRequest, new { Success = false, Errors = validationErrors })); } else { // if no errors, update settings in db this.UpdateRegexSettingsInternal(request); // clear cache this.ClearCache(); return(this.Request.CreateResponse(HttpStatusCode.OK, new { Success = true })); } } catch (Exception exc) { Logger.Error(exc); return(this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc)); } }
public HttpResponseMessage UpdateRegexSettings(UpdateRegexSettingsRequest request) { try { List <KeyValuePair <string, string> > validationErrors = new List <KeyValuePair <string, string> >(); if (!ValidateRegex(request.IgnoreRegex)) { validationErrors.Add(new KeyValuePair <string, string>("IgnoreRegex", Localization.GetString("ignoreRegExInvalidPattern", LocalResourcesFile))); } if (!ValidateRegex(request.DoNotRewriteRegex)) { validationErrors.Add(new KeyValuePair <string, string>("DoNotRewriteRegex", Localization.GetString("doNotRewriteRegExInvalidPattern", LocalResourcesFile))); } if (!ValidateRegex(request.UseSiteUrlsRegex)) { validationErrors.Add(new KeyValuePair <string, string>("UseSiteUrlsRegex", Localization.GetString("siteUrlsOnlyRegExInvalidPattern", LocalResourcesFile))); } if (!ValidateRegex(request.DoNotRedirectRegex)) { validationErrors.Add(new KeyValuePair <string, string>("DoNotRedirectRegex", Localization.GetString("doNotRedirectUrlRegExInvalidPattern", LocalResourcesFile))); } if (!ValidateRegex(request.DoNotRedirectSecureRegex)) { validationErrors.Add(new KeyValuePair <string, string>("DoNotRedirectSecureRegex", Localization.GetString("doNotRedirectHttpsUrlRegExInvalidPattern", LocalResourcesFile))); } if (!ValidateRegex(request.ForceLowerCaseRegex)) { validationErrors.Add(new KeyValuePair <string, string>("ForceLowerCaseRegex", Localization.GetString("preventLowerCaseUrlRegExInvalidPattern", LocalResourcesFile))); } if (!ValidateRegex(request.NoFriendlyUrlRegex)) { validationErrors.Add(new KeyValuePair <string, string>("NoFriendlyUrlRegex", Localization.GetString("doNotUseFriendlyUrlsRegExInvalidPattern", LocalResourcesFile))); } if (!ValidateRegex(request.DoNotIncludeInPathRegex)) { validationErrors.Add(new KeyValuePair <string, string>("DoNotIncludeInPathRegex", Localization.GetString("keepInQueryStringRegExInvalidPattern", LocalResourcesFile))); } if (!ValidateRegex(request.ValidExtensionlessUrlsRegex)) { validationErrors.Add(new KeyValuePair <string, string>("ValidExtensionlessUrlsRegex", Localization.GetString("urlsWithNoExtensionRegExInvalidPattern", LocalResourcesFile))); } if (!ValidateRegex(request.RegexMatch)) { validationErrors.Add(new KeyValuePair <string, string>("RegexMatch", Localization.GetString("validFriendlyUrlRegExInvalidPattern", LocalResourcesFile))); } if (validationErrors.Count > 0) { return(Request.CreateResponse(HttpStatusCode.BadRequest, new { Success = false, Errors = validationErrors })); } else { HostController.Instance.Update(FriendlyUrlSettings.IgnoreRegexSetting, request.IgnoreRegex, false); HostController.Instance.Update(FriendlyUrlSettings.DoNotRewriteRegExSetting, request.DoNotRewriteRegex, false); HostController.Instance.Update(FriendlyUrlSettings.SiteUrlsOnlyRegexSetting, request.UseSiteUrlsRegex, false); HostController.Instance.Update(FriendlyUrlSettings.DoNotRedirectUrlRegexSetting, request.DoNotRedirectRegex, false); HostController.Instance.Update(FriendlyUrlSettings.DoNotRedirectHttpsUrlRegexSetting, request.DoNotRedirectSecureRegex, false); HostController.Instance.Update(FriendlyUrlSettings.PreventLowerCaseUrlRegexSetting, request.ForceLowerCaseRegex, false); HostController.Instance.Update(FriendlyUrlSettings.DoNotUseFriendlyUrlRegexSetting, request.NoFriendlyUrlRegex, false); HostController.Instance.Update(FriendlyUrlSettings.KeepInQueryStringRegexSetting, request.DoNotIncludeInPathRegex, false); HostController.Instance.Update(FriendlyUrlSettings.UrlsWithNoExtensionRegexSetting, request.ValidExtensionlessUrlsRegex, false); HostController.Instance.Update(FriendlyUrlSettings.ValidFriendlyUrlRegexSetting, request.RegexMatch, false); DataCache.ClearHostCache(false); CacheController.FlushPageIndexFromCache(); CacheController.FlushFriendlyUrlSettingsFromCache(); return(Request.CreateResponse(HttpStatusCode.OK, new { Success = true })); } } catch (Exception exc) { Logger.Error(exc); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc)); } }
internal static ActionResult UpdateRegexSettings(UpdateRegexSettingsRequest request) { ActionResult actionResult = new ActionResult(); try { List <KeyValuePair <string, string> > validationErrors = new List <KeyValuePair <string, string> >(); if (!ValidateRegex(request.IgnoreRegex)) { validationErrors.Add(new KeyValuePair <string, string>("IgnoreRegex", Localization.GetString("ignoreRegExInvalidPattern", Constants.DNNLocalResourcesFile))); } if (!ValidateRegex(request.DoNotRewriteRegex)) { validationErrors.Add(new KeyValuePair <string, string>("DoNotRewriteRegex", Localization.GetString("doNotRewriteRegExInvalidPattern", Constants.DNNLocalResourcesFile))); } if (!ValidateRegex(request.UseSiteUrlsRegex)) { validationErrors.Add(new KeyValuePair <string, string>("UseSiteUrlsRegex", Localization.GetString("siteUrlsOnlyRegExInvalidPattern", Constants.DNNLocalResourcesFile))); } if (!ValidateRegex(request.DoNotRedirectRegex)) { validationErrors.Add(new KeyValuePair <string, string>("DoNotRedirectRegex", Localization.GetString("doNotRedirectUrlRegExInvalidPattern", Constants.DNNLocalResourcesFile))); } if (!ValidateRegex(request.DoNotRedirectSecureRegex)) { validationErrors.Add(new KeyValuePair <string, string>("DoNotRedirectSecureRegex", Localization.GetString("doNotRedirectHttpsUrlRegExInvalidPattern", Constants.DNNLocalResourcesFile))); } if (!ValidateRegex(request.ForceLowerCaseRegex)) { validationErrors.Add(new KeyValuePair <string, string>("ForceLowerCaseRegex", Localization.GetString("preventLowerCaseUrlRegExInvalidPattern", Constants.DNNLocalResourcesFile))); } if (!ValidateRegex(request.NoFriendlyUrlRegex)) { validationErrors.Add(new KeyValuePair <string, string>("NoFriendlyUrlRegex", Localization.GetString("doNotUseFriendlyUrlsRegExInvalidPattern", Constants.DNNLocalResourcesFile))); } if (!ValidateRegex(request.DoNotIncludeInPathRegex)) { validationErrors.Add(new KeyValuePair <string, string>("DoNotIncludeInPathRegex", Localization.GetString("keepInQueryStringRegExInvalidPattern", Constants.DNNLocalResourcesFile))); } if (!ValidateRegex(request.ValidExtensionlessUrlsRegex)) { validationErrors.Add(new KeyValuePair <string, string>("ValidExtensionlessUrlsRegex", Localization.GetString("urlsWithNoExtensionRegExInvalidPattern", Constants.DNNLocalResourcesFile))); } if (!ValidateRegex(request.RegexMatch)) { validationErrors.Add(new KeyValuePair <string, string>("RegexMatch", Localization.GetString("validFriendlyUrlRegExInvalidPattern", Constants.DNNLocalResourcesFile))); } if (validationErrors.Count > 0) { foreach (KeyValuePair <string, string> error in validationErrors) { actionResult.AddError(error.Key, error.Value); } } else { if (actionResult.IsSuccess) { // if no errors, update settings in db UpdateRegexSettingsInternal(request); // clear cache ClearCache(); } } } catch (Exception exc) { actionResult.AddError(HttpStatusCode.InternalServerError.ToString(), exc.Message); } return(actionResult); }