From 77201f3805b8dca7618d3567abd01551614ee047 Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Mon, 11 Feb 2013 04:28:18 +0600 Subject: [PATCH] Fix merg issues. --- src/Umbraco.Web/Routing/LookupByLegacy404.cs | 52 ------- .../Routing/LookupByNotFoundHandlers.cs | 142 ------------------ src/Umbraco.Web/Umbraco.Web.csproj | 2 - src/umbraco.cms/businesslogic/media/Media.cs | 15 +- 4 files changed, 1 insertion(+), 210 deletions(-) delete mode 100644 src/Umbraco.Web/Routing/LookupByLegacy404.cs delete mode 100644 src/Umbraco.Web/Routing/LookupByNotFoundHandlers.cs diff --git a/src/Umbraco.Web/Routing/LookupByLegacy404.cs b/src/Umbraco.Web/Routing/LookupByLegacy404.cs deleted file mode 100644 index be73fa81c4..0000000000 --- a/src/Umbraco.Web/Routing/LookupByLegacy404.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Umbraco.Core; -using Umbraco.Core.Logging; -using Umbraco.Core.Models; - -namespace Umbraco.Web.Routing -{ - internal class LookupByLegacy404 : IPublishedContentLookup - { - /// - /// Tries to find and assign an Umbraco document to a PublishedContentRequest. - /// - /// The PublishedContentRequest. - /// A value indicating whether an Umbraco document was found and assigned. - public bool TrySetDocument(PublishedContentRequest pcr) - { - LogHelper.Debug("Looking for a page to handle 404."); - - // TODO - replace the whole logic and stop calling into library! - var error404 = global::umbraco.library.GetCurrentNotFoundPageId(); - var id = int.Parse(error404); - - IPublishedContent content = null; - - if (id > 0) - { - LogHelper.Debug("Got id={0}.", () => id); - - content = pcr.RoutingContext.PublishedContentStore.GetDocumentById( - pcr.RoutingContext.UmbracoContext, - id); - - if (content == null) - LogHelper.Debug("Could not find content with that id."); - else - LogHelper.Debug("Found corresponding content."); - } - else - { - LogHelper.Debug("Got nothing."); - } - - pcr.PublishedContent = content; - pcr.Is404 = true; - return content != null; - } - } -} diff --git a/src/Umbraco.Web/Routing/LookupByNotFoundHandlers.cs b/src/Umbraco.Web/Routing/LookupByNotFoundHandlers.cs deleted file mode 100644 index 311efcbcc3..0000000000 --- a/src/Umbraco.Web/Routing/LookupByNotFoundHandlers.cs +++ /dev/null @@ -1,142 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Reflection; -using System.Web; -using System.Xml; -using Umbraco.Core.Logging; -using Umbraco.Core.Models; -using umbraco.IO; -using umbraco.interfaces; - -namespace Umbraco.Web.Routing -{ - /// - /// Provides an implementation of that handles backward compatilibty with legacy INotFoundHandler. - /// - internal class LookupByNotFoundHandlers : IPublishedContentLookup - { - // notes - // - // at the moment we load the legacy INotFoundHandler - // excluding those that have been replaced by proper finders, - // and run them. - - /// - /// Tries to find and assign an Umbraco document to a PublishedContentRequest. - /// - /// The PublishedContentRequest. - /// A value indicating whether an Umbraco document was found and assigned. - public bool TrySetDocument(PublishedContentRequest docRequest) - { - HandlePageNotFound(docRequest); - return docRequest.HasNode; - } - - #region Copied over and adapted from presentation.requestHandler - - //FIXME: this is temporary and should be obsoleted - - void HandlePageNotFound(PublishedContentRequest docRequest) - { - var url = NotFoundHandlerHelper.GetLegacyUrlForNotFoundHandlers(); - LogHelper.Debug("Running for legacy url='{0}'.", () => url); - - foreach (var handler in GetNotFoundHandlers()) - { - IPublishedContentLookup lookup = null; - - LogHelper.Debug("Handler '{0}'.", () => handler.GetType().FullName); - - // replace with our own implementation - if (handler is global::umbraco.SearchForAlias) - lookup = new LookupByAlias(); - else if (handler is global::umbraco.SearchForProfile) - lookup = new LookupByProfile(); - else if (handler is global::umbraco.SearchForTemplate) - lookup = new LookupByNiceUrlAndTemplate(); - else if (handler is global::umbraco.handle404) - lookup = new LookupByLegacy404(); - - if (lookup != null) - { - LogHelper.Debug("Replace handler '{0}' by new lookup '{1}'.", () => handler.GetType().FullName, () => lookup.GetType().FullName); - if (lookup.TrySetDocument(docRequest)) - { - // do NOT set docRequest.PublishedContent again here as - // it would clear any template that the finder might have set - LogHelper.Debug("Lookup '{0}' found node with id={1}.", () => lookup.GetType().FullName, () => docRequest.PublishedContent.Id); - if (docRequest.Is404) - LogHelper.Debug("Lookup '{0}' set status to 404.", () => lookup.GetType().FullName); - return; - } - } - - // else it's a legacy handler, run - - if (handler.Execute(url) && handler.redirectID > 0) - { - docRequest.PublishedContent = docRequest.RoutingContext.PublishedContentStore.GetDocumentById( - docRequest.RoutingContext.UmbracoContext, - handler.redirectID); - - if (!docRequest.HasNode) - { - LogHelper.Debug("Handler '{0}' found node with id={1} which is not valid.", () => handler.GetType().FullName, () => handler.redirectID); - break; - } - - LogHelper.Debug("Handler '{0}' found valid node with id={1}.", () => handler.GetType().FullName, () => handler.redirectID); - - if (docRequest.RoutingContext.UmbracoContext.HttpContext.Response.StatusCode == 404) - { - LogHelper.Debug("Handler '{0}' set status code to 404.", () => handler.GetType().FullName); - docRequest.Is404 = true; - } - - //// check for caching - //if (handler.CacheUrl) - //{ - // if (url.StartsWith("/")) - // url = "/" + url; - - // var cacheKey = (currentDomain == null ? "" : currentDomain.Name) + url; - // var culture = currentDomain == null ? null : currentDomain.Language.CultureAlias; - // SetCache(cacheKey, new CacheEntry(handler.redirectID.ToString(), culture)); - - // HttpContext.Current.Trace.Write("NotFoundHandler", - // string.Format("Added to cache '{0}', {1}.", url, handler.redirectID)); - //} - - break; - } - } - } - - IEnumerable GetNotFoundHandlers() - { - // instanciate new handlers - // using definition cache - - var handlers = new List(); - - foreach (var type in NotFoundHandlerHelper.CustomHandlerTypes) - { - try - { - var handler = Activator.CreateInstance(type) as INotFoundHandler; - if (handler != null) - handlers.Add(handler); - } - catch (Exception e) - { - LogHelper.Error(string.Format("Error instanciating handler {0}, ignoring.", type.FullName), e); - } - } - - return handlers; - } - - #endregion - } -} \ No newline at end of file diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 209abee69a..2a468b0059 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -347,7 +347,6 @@ - @@ -514,7 +513,6 @@ - diff --git a/src/umbraco.cms/businesslogic/media/Media.cs b/src/umbraco.cms/businesslogic/media/Media.cs index 8d72694ab1..ec03a95f10 100644 --- a/src/umbraco.cms/businesslogic/media/Media.cs +++ b/src/umbraco.cms/businesslogic/media/Media.cs @@ -221,20 +221,7 @@ namespace umbraco.cms.businesslogic.media return children.Select(x => new Media(x)).ToArray(); } } - - public override string Text - { - get - { - return MediaItem.Name; - } - set - { - value = value.Trim(); - MediaItem.Name = value; - } - } - + #endregion #region Public methods