public ContentMapFileSystem(IContentMapProvider contentMapProvider, IContentMapEntityUrlProvider contentMapUrlProvider, IDataAdapterDependencies dependencies) : base(dependencies) { if (contentMapProvider == null) { throw new ArgumentNullException("contentMapProvider"); } if (contentMapUrlProvider == null) { throw new ArgumentNullException("contentMapUrlProvider"); } ContentMapProvider = contentMapProvider; ContentMapUrlProvider = contentMapUrlProvider; }
protected CrmSiteMapNode GetNotFoundNode(ContentMap map, WebsiteNode site, IContentMapEntityUrlProvider urlProvider) { var notFoundPage = site.SiteMarkers.FirstOrDefault(sm => sm.Name == NotFoundPageSiteMarkerName); if (notFoundPage == null || notFoundPage.WebPage == null || notFoundPage.WebPage.IsReference) { return(null); } var languageInfo = HttpContext.Current.GetContextLanguageInfo(); var path = HttpContext.Current.Request.Path; var notFoundNode = languageInfo.FindLanguageSpecificWebPageNode(notFoundPage.WebPage, true); var isLanguageEnabled = languageInfo.IsCrmMultiLanguageEnabled; if (isLanguageEnabled) { var isPublished = languageInfo.ContextLanguage.IsPublished; var language = languageInfo.ContextLanguage.WebsiteLanguageNode.Name; if (isPublished && notFoundNode == null) { var root = this.RootNode as CrmSiteMapNode; if (null != root) { ADXTrace.Instance.TraceWarning(TraceCategory.Application, "Cannot find language specific web page for url"); var id = root.Entity.GetAttributeValue("adx_webpageid"); throw new HttpException((int)HttpStatusCode.NotFound, "Error ID - {0}. The Webpage you are looking for at {1} is not found in the {2} language. To display Page Not Found page localize it in {2} language.".FormatWith(id, path, language)); } } else if (!isPublished && notFoundNode != null) { ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Language not available for: {0}", language)); var id = notFoundNode.Id; throw new HttpException((int)HttpStatusCode.NotFound, "Error ID – {0} . {1} language is not available. Please ensure it is in published status.".FormatWith(id, language)); } else if (!isPublished) { throw new HttpException((int)HttpStatusCode.NotFound, "Not Found."); } } return(GetNode(map, notFoundNode, HttpStatusCode.NotFound, urlProvider)); }
private bool TryGetWebsite(ContentMap map, out WebsiteNode site, out IContentMapEntityUrlProvider urlProvider) { urlProvider = PortalCrmConfigurationManager.CreateDependencyProvider(PortalName).GetDependency <IContentMapEntityUrlProvider>(); if (urlProvider == null) { site = null; return(false); } var portal = PortalContext; var website = portal.Website; if (!map.TryGetValue(website, out site)) { return(false); } return(true); }
protected virtual CrmSiteMapNode GetNode(ContentMap map, ShortcutNode shortcut, HttpStatusCode statusCode, IContentMapEntityUrlProvider provider) { var entity = shortcut.ToEntity(GetEntityType("adx_shortcut")); var url = !string.IsNullOrWhiteSpace(shortcut.ExternalUrl) ? shortcut.ExternalUrl : provider.GetUrl(map, shortcut); if (url == null) { return(null); } var description = GetShortcutDescription(shortcut); return(new CrmSiteMapNode( this, url, url, !string.IsNullOrWhiteSpace(shortcut.Title) ? shortcut.Title : shortcut.Name, description, null, shortcut.ModifiedOn.GetValueOrDefault(DateTime.UtcNow), entity, statusCode)); }
protected virtual CrmSiteMapNode GetNode(ContentMap map, ShortcutNode shortcut, IContentMapEntityUrlProvider provider) { return(GetNode(map, shortcut, HttpStatusCode.OK, provider)); }
protected virtual CrmSiteMapNode GetNode(ContentMap map, WebFileNode file, HttpStatusCode statusCode, IContentMapEntityUrlProvider provider) { var entity = file.ToEntity(GetEntityType("adx_webfile")); var url = provider.GetUrl(map, file); return(new CrmSiteMapNode( this, url, url, file.Name, file.Summary, string.Empty, file.ModifiedOn.GetValueOrDefault(DateTime.UtcNow), entity, statusCode)); }
protected virtual CrmSiteMapNode GetNode(ContentMap map, WebFileNode file, IContentMapEntityUrlProvider provider) { return(GetNode(map, file, HttpStatusCode.OK, provider)); }
protected CrmSiteMapNode GetAccessibleNodeOrAccessDeniedNode(ContentMap map, WebFileNode file, IContentMapEntityUrlProvider provider, bool excludeFromSecurityValidation = false) { if (excludeFromSecurityValidation) { return(GetNode(map, file, provider) ?? GetAccessDeniedNodeInternal()); } return(ReturnNodeIfAccessible(GetNode(map, file, provider), GetAccessDeniedNodeInternal)); }
protected virtual CrmSiteMapNode GetNode(ContentMap map, WebPageNode page, HttpStatusCode statusCode, IContentMapEntityUrlProvider provider, bool includeReturnUrl = false) { if (HttpContext.Current.GetContextLanguageInfo().IsCrmMultiLanguageEnabled) { ADXTrace.Instance.TraceInfo(TraceCategory.Monitoring, string.Format("SiteMapProvider.GetNode Lang:{0} ", page.IsRoot != false ? "root" : page.WebPageLanguage.PortalLanguage.Code)); } var template = page.PageTemplate; if (template == null) { ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Web Page with id '{0}' does not have the required Page Template.", page.Id)); return(null); } var returnUrl = includeReturnUrl && HttpContext.Current != null ? "&ReturnUrl={0}".FormatWith(System.Web.Security.AntiXss.AntiXssEncoder.UrlEncode(HttpContext.Current.Request.Url.PathAndQuery)) : string.Empty; var rewriteUrl = template.Type == (int)PageTemplateNode.TemplateType.WebTemplate && template.WebTemplateId != null ? template.UseWebsiteHeaderAndFooter.GetValueOrDefault(true) ? "~/Pages/WebTemplate.aspx" : "~/Pages/WebTemplateNoMaster.aspx" : template.RewriteUrl; var entity = page.ToEntity(GetEntityType("adx_webpage")); var url = provider.GetUrl(map, page); var node = new CrmSiteMapNode( this, url, url, !string.IsNullOrWhiteSpace(page.Title) ? page.Title : page.Name, page.Summary, "{0}?pageid={1}{2}".FormatWith(rewriteUrl, page.Id, returnUrl), page.ModifiedOn.GetValueOrDefault(DateTime.UtcNow), entity, statusCode); if (template.WebTemplateId != null) { node["adx_webtemplateid"] = template.WebTemplateId.Id.ToString(); } return(node); }