diff --git a/src/Umbraco.Tests/Services/ContentServiceTests.cs b/src/Umbraco.Tests/Services/ContentServiceTests.cs
index d5ee00e663..ece4e568c6 100644
--- a/src/Umbraco.Tests/Services/ContentServiceTests.cs
+++ b/src/Umbraco.Tests/Services/ContentServiceTests.cs
@@ -40,7 +40,21 @@ namespace Umbraco.Tests.Services
//TODO Add test to verify there is only ONE newest document/content in cmsDocument table after updating.
//TODO Add test to delete specific version (with and without deleting prior versions) and versions by date.
- [Test]
+ [Test]
+ public void Can_Remove_Property_Type()
+ {
+ // Arrange
+ var contentService = ServiceContext.ContentService;
+
+ // Act
+ var content = contentService.CreateContent("Test", -1, "umbTextpage", 0);
+
+ // Assert
+ Assert.That(content, Is.Not.Null);
+ Assert.That(content.HasIdentity, Is.False);
+ }
+
+ [Test]
public void Can_Create_Content()
{
// Arrange
diff --git a/src/Umbraco.Web/Cache/MacroCacheRefresher.cs b/src/Umbraco.Web/Cache/MacroCacheRefresher.cs
index 763e94fe8d..e884ab4a7f 100644
--- a/src/Umbraco.Web/Cache/MacroCacheRefresher.cs
+++ b/src/Umbraco.Web/Cache/MacroCacheRefresher.cs
@@ -9,9 +9,12 @@ using System.Linq;
namespace Umbraco.Web.Cache
{
///
- /// Used to invalidate/refresh the cache for macros
+ /// A cache refresher to ensure macro cache is updated when members change
///
- public sealed class MacroCacheRefresher : ICacheRefresher, ICacheRefresher
+ ///
+ /// This is not intended to be used directly in your code and it should be sealed but due to legacy code we cannot seal it.
+ ///
+ public class MacroCacheRefresher : ICacheRefresher, ICacheRefresher
{
internal static string[] GetAllMacroCacheKeys()
{
diff --git a/src/Umbraco.Web/Cache/MediaCacheRefresher.cs b/src/Umbraco.Web/Cache/MediaCacheRefresher.cs
index 20a47d3111..7382a39427 100644
--- a/src/Umbraco.Web/Cache/MediaCacheRefresher.cs
+++ b/src/Umbraco.Web/Cache/MediaCacheRefresher.cs
@@ -6,7 +6,14 @@ using umbraco.interfaces;
namespace Umbraco.Web.Cache
{
- public sealed class MediaCacheRefresher : ICacheRefresher
+
+ ///
+ /// A cache refresher to ensure media cache is updated when members change
+ ///
+ ///
+ /// This is not intended to be used directly in your code and it should be sealed but due to legacy code we cannot seal it.
+ ///
+ public class MediaCacheRefresher : ICacheRefresher
{
public Guid UniqueIdentifier
{
diff --git a/src/Umbraco.Web/Cache/MemberCacheRefresher.cs b/src/Umbraco.Web/Cache/MemberCacheRefresher.cs
index bfb93ae434..ccdb9e1ae9 100644
--- a/src/Umbraco.Web/Cache/MemberCacheRefresher.cs
+++ b/src/Umbraco.Web/Cache/MemberCacheRefresher.cs
@@ -6,7 +6,13 @@ using umbraco.interfaces;
namespace Umbraco.Web.Cache
{
- public sealed class MemberCacheRefresher : ICacheRefresher
+ ///
+ /// A cache refresher to ensure member cache is updated when members change
+ ///
+ ///
+ /// This is not intended to be used directly in your code and it should be sealed but due to legacy code we cannot seal it.
+ ///
+ public class MemberCacheRefresher : ICacheRefresher
{
public Guid UniqueIdentifier
diff --git a/src/Umbraco.Web/Cache/TemplateCacheRefresher.cs b/src/Umbraco.Web/Cache/TemplateCacheRefresher.cs
index b5f806b7d6..8b2507ddbf 100644
--- a/src/Umbraco.Web/Cache/TemplateCacheRefresher.cs
+++ b/src/Umbraco.Web/Cache/TemplateCacheRefresher.cs
@@ -6,7 +6,14 @@ using umbraco.interfaces;
namespace Umbraco.Web.Cache
{
- public sealed class TemplateCacheRefresher : ICacheRefresher
+
+ ///
+ /// A cache refresher to ensure template cache is updated when members change
+ ///
+ ///
+ /// This is not intended to be used directly in your code and it should be sealed but due to legacy code we cannot seal it.
+ ///
+ public class TemplateCacheRefresher : ICacheRefresher
{
public string Name
diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj
index d0069ddd70..c18bce6862 100644
--- a/src/Umbraco.Web/Umbraco.Web.csproj
+++ b/src/Umbraco.Web/Umbraco.Web.csproj
@@ -327,6 +327,7 @@
+
AssignDomain2.aspx
ASPXCodeBehind
@@ -437,7 +438,6 @@
ASPXCodeBehind
-
ASPXCodeBehind
@@ -447,9 +447,7 @@
ASPXCodeBehind
-
-
ASPXCodeBehind
@@ -635,7 +633,7 @@
-
+
Code
diff --git a/src/Umbraco.Web/umbraco.presentation/DLRMacroResult.cs b/src/Umbraco.Web/umbraco.presentation/DLRMacroResult.cs
deleted file mode 100644
index ca56ceebc4..0000000000
--- a/src/Umbraco.Web/umbraco.presentation/DLRMacroResult.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-using System.Web.UI;
-
-namespace umbraco
-{
- [Obsolete("This has been replaced with ScriptingMacroResult instead")]
- public class DLRMacroResult
- {
- public DLRMacroResult()
- {
- }
-
- public DLRMacroResult(Control control, Exception resultException)
- {
- Control = control;
- ResultException = resultException;
- }
-
- public Control Control { get; set; }
- public Exception ResultException { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/Umbraco.Web/umbraco.presentation/EnsureSystemPathsApplicationStartupHandler.cs b/src/Umbraco.Web/umbraco.presentation/EnsureSystemPathsApplicationStartupHandler.cs
index 553abb1589..f5949ff1c3 100644
--- a/src/Umbraco.Web/umbraco.presentation/EnsureSystemPathsApplicationStartupHandler.cs
+++ b/src/Umbraco.Web/umbraco.presentation/EnsureSystemPathsApplicationStartupHandler.cs
@@ -3,16 +3,19 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
+using Umbraco.Core;
using Umbraco.Core.IO;
using umbraco.businesslogic;
using umbraco.interfaces;
namespace umbraco.presentation
{
- public class EnsureSystemPathsApplicationStartupHandler : IApplicationStartupHandler
+ public class EnsureSystemPathsApplicationStartupHandler : ApplicationEventHandler
{
- public EnsureSystemPathsApplicationStartupHandler()
+ protected override void ApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
+ base.ApplicationInitialized(umbracoApplication, applicationContext);
+
EnsurePathExists("~/App_Code");
EnsurePathExists("~/App_Data");
EnsurePathExists(SystemDirectories.AppPlugins);
@@ -23,11 +26,11 @@ namespace umbraco.presentation
EnsurePathExists(SystemDirectories.Scripts);
EnsurePathExists(SystemDirectories.UserControls);
EnsurePathExists(SystemDirectories.Xslt);
- EnsurePathExists(SystemDirectories.MvcViews);
- EnsurePathExists(SystemDirectories.MvcViews + "/Partials");
- EnsurePathExists(SystemDirectories.MvcViews + "/MacroPartials");
+ EnsurePathExists(SystemDirectories.MvcViews);
+ EnsurePathExists(SystemDirectories.MvcViews + "/Partials");
+ EnsurePathExists(SystemDirectories.MvcViews + "/MacroPartials");
}
-
+
public void EnsurePathExists(string path)
{
var absolutePath = IOHelper.MapPath(path);
diff --git a/src/Umbraco.Web/umbraco.presentation/requestHandler.cs b/src/Umbraco.Web/umbraco.presentation/LegacyClasses.cs
similarity index 61%
rename from src/Umbraco.Web/umbraco.presentation/requestHandler.cs
rename to src/Umbraco.Web/umbraco.presentation/LegacyClasses.cs
index 8b5bb2e980..ced878e389 100644
--- a/src/Umbraco.Web/umbraco.presentation/requestHandler.cs
+++ b/src/Umbraco.Web/umbraco.presentation/LegacyClasses.cs
@@ -1,29 +1,32 @@
-using System;
+using System;
using System.Collections;
+using System.Collections.Generic;
using System.Diagnostics;
+using System.Linq;
using System.Reflection;
+using System.Text;
using System.Web;
+using System.Web.UI;
using System.Xml;
-using Umbraco.Core.Logging;
-using umbraco.BusinessLogic;
-using umbraco.cms.businesslogic.member;
-using umbraco.cms.businesslogic.template;
-using umbraco.cms.businesslogic.web;
-using umbraco.interfaces;
using umbraco.IO;
using umbraco.NodeFactory;
+using umbraco.cms.businesslogic.web;
+using umbraco.interfaces;
-namespace umbraco {
+namespace umbraco
+{
///
/// Summary description for requestHandler.
///
[Obsolete("This class is no longer used and will be removed in future versions")]
- public class requestHandler {
+ public class requestHandler
+ {
#region public properties
public XmlNode currentPage;
- public String PageXPathQuery {
+ public String PageXPathQuery
+ {
get { return _pageXPathQuery; }
}
@@ -34,21 +37,23 @@ namespace umbraco {
private static string pageXPathQueryStart = "/root";
- private static string _urlName = "@urlName";
- private static bool _urlNameInitialized = true;
+ private static string _urlName = "@urlName";
+ private static bool _urlNameInitialized = true;
private static XmlDocument _customHandlers;
private string _pageXPathQuery = string.Empty;
private bool _doNotCache = false;
- public static void ClearProcessedRequests() {
+ public static void ClearProcessedRequests()
+ {
lock (locker)
{
_processedRequests.Clear();
}
}
- public static string cleanUrl() {
+ public static string cleanUrl()
+ {
if (HttpContext.Current.Items["UmbPage"] == null)
return string.Empty;
@@ -66,8 +71,8 @@ namespace umbraco {
if (tmp == "/default.aspx")
tmp = string.Empty;
-// else if (tmp == "/")
-// tmp = string.Empty;
+ // else if (tmp == "/")
+ // tmp = string.Empty;
else if (tmp == root)
tmp = string.Empty;
@@ -77,10 +82,11 @@ namespace umbraco {
// Init urlName to correspond to web.config entries (umbracoUrlForbittenCharacters and umbracoUrlSpaceCharacter).
// Needed to compensate for known asp.net framework error KB826437:
// http://support.microsoft.com/default.aspx?scid=kb;EN-US;826437
- // note: obsoleted, everything was commented out anyway since long, so it just
- // initializes _urlName, which we can do in the variable definition.
- [Obsolete("This method did nothing anyway...")]
- private static void InitializeUrlName() {
+ // note: obsoleted, everything was commented out anyway since long, so it just
+ // initializes _urlName, which we can do in the variable definition.
+ [Obsolete("This method did nothing anyway...")]
+ private static void InitializeUrlName()
+ {
/* string toReplace = string.Empty;
string replaceWith = string.Empty;
XmlNode replaceChars = UmbracoSettings.UrlReplaceCharacters;
@@ -99,7 +105,8 @@ namespace umbraco {
_urlNameInitialized = true;
}
- public static string CreateXPathQuery(string url, bool checkDomain) {
+ public static string CreateXPathQuery(string url, bool checkDomain)
+ {
string _tempQuery = "";
if (GlobalSettings.HideTopLevelNodeFromPath && checkDomain)
@@ -129,8 +136,9 @@ namespace umbraco {
}
domainUrl = "/" + domainUrl;
- // If at domain root
- if (url == "") {
+ // If at domain root
+ if (url == "")
+ {
_tempQuery = "";
requestRawUrl = domainUrl.Split("/".ToCharArray());
HttpContext.Current.Trace.Write("requestHandler",
@@ -140,7 +148,9 @@ namespace umbraco {
Domain.GetRootFromDomain(
HttpContext.Current.Request.ServerVariables["SERVER_NAME"]).
ToString());
- } else {
+ }
+ else
+ {
// if it matches a domain url, skip all other xpaths and use this!
string langXpath = CreateXPathQuery(domainUrl + "/" + url, false);
if (content.Instance.XmlContent.DocumentElement.SelectSingleNode(langXpath) != null)
@@ -148,7 +158,8 @@ namespace umbraco {
else if (UmbracoSettings.UseDomainPrefixes)
return "/domainprefixes-are-used-so-i-do-not-work";
}
- } else if (url == "" && !GlobalSettings.HideTopLevelNodeFromPath)
+ }
+ else if (url == "" && !GlobalSettings.HideTopLevelNodeFromPath)
_tempQuery += "/*";
bool rootAdded = false;
@@ -196,12 +207,13 @@ namespace umbraco {
return "";
}
- public requestHandler(XmlDocument umbracoContent, String url) {
+ public requestHandler(XmlDocument umbracoContent, String url)
+ {
HttpContext.Current.Trace.Write("request handler", "current url '" + url + "'");
bool getByID = false;
string currentDomain = HttpContext.Current.Request.ServerVariables["SERVER_NAME"];
- // obsoleted
+ // obsoleted
//if (!_urlNameInitialized)
// InitializeUrlName();
@@ -220,26 +232,36 @@ namespace umbraco {
getByID = true;
_pageXPathQuery = _processedRequests[currentDomain + url].ToString();
}
- // The url isn't cached
- else {
- if (url == "") {
+ // The url isn't cached
+ else
+ {
+ if (url == "")
+ {
url = "";
_pageXPathQuery = CreateXPathQuery(url, true);
// Never cache roots
_doNotCache = true;
- } else {
+ }
+ else
+ {
// If url is an integer, then asume it's the ID of the page
if (url[0] == '/')
url = url.Substring(1, url.Length - 1);
int result;
- if (int.TryParse(url, out result)) {
+ if (int.TryParse(url, out result))
+ {
_pageXPathQuery = url;
getByID = true;
- } else {
- if (!string.IsNullOrEmpty(url)) {
+ }
+ else
+ {
+ if (!string.IsNullOrEmpty(url))
+ {
_pageXPathQuery = CreateXPathQuery(url, true);
- } else {
+ }
+ else
+ {
_pageXPathQuery = Document.GetRootDocuments()[0].Id.ToString();
getByID = true;
}
@@ -253,17 +275,20 @@ namespace umbraco {
if (getByID)
currentPage = umbracoContent.GetElementById(_pageXPathQuery.Trim());
- else {
+ else
+ {
HttpContext.Current.Trace.Write("umbracoRequestHandler",
"pageXPathQueryStart: '" + pageXPathQueryStart + "'");
- currentPage = umbracoContent.SelectSingleNode(pageXPathQueryStart + _pageXPathQuery);
- if (currentPage == null) {
+ currentPage = umbracoContent.SelectSingleNode(pageXPathQueryStart + _pageXPathQuery);
+ if (currentPage == null)
+ {
// If no node found, then try with a relative page query
currentPage = umbracoContent.SelectSingleNode("/" + _pageXPathQuery);
}
// Add to url cache
- if (currentPage != null && !_doNotCache) {
+ if (currentPage != null && !_doNotCache)
+ {
string prefixUrl = "";
if (Domain.Exists(currentDomain))
prefixUrl = currentDomain;
@@ -282,16 +307,17 @@ namespace umbraco {
}
}
- if (currentPage == null)
+ if (currentPage == null)
{
// No node found, try custom url handlers defined in /config/404handlers.config
- if (_customHandlers == null) {
+ if (_customHandlers == null)
+ {
_customHandlers = new XmlDocument();
_customHandlers.Load(
- IOHelper.MapPath( SystemFiles.NotFoundhandlersConfig ) );
+ IOHelper.MapPath(SystemFiles.NotFoundhandlersConfig));
}
- foreach (XmlNode notFoundHandler in _customHandlers.DocumentElement.SelectNodes("notFound"))
+ foreach (XmlNode notFoundHandler in _customHandlers.DocumentElement.SelectNodes("notFound"))
{
// Load handler
@@ -302,19 +328,22 @@ namespace umbraco {
if (notFoundHandler.Attributes.GetNamedItem("namespace") != null)
_chNameSpace = notFoundHandler.Attributes.GetNamedItem("namespace").Value;
- try {
+ try
+ {
// Reflect to execute and check whether the type is umbraco.main.IFormhandler
HttpContext.Current.Trace.Write("notFoundHandler",
string.Format("Trying NotFoundHandler '{0}.{1}'...", _chAssembly, _chType));
Assembly assembly =
Assembly.LoadFrom(
- IOHelper.MapPath( SystemDirectories.Bin + "/" + _chAssembly + ".dll"));
+ IOHelper.MapPath(SystemDirectories.Bin + "/" + _chAssembly + ".dll"));
Type type = assembly.GetType(_chNameSpace + "." + _chType);
INotFoundHandler typeInstance = Activator.CreateInstance(type) as INotFoundHandler;
- if (typeInstance != null) {
+ if (typeInstance != null)
+ {
typeInstance.Execute(url);
- if (typeInstance.redirectID > 0) {
+ if (typeInstance.redirectID > 0)
+ {
int redirectID = typeInstance.redirectID;
currentPage = umbracoContent.GetElementById(redirectID.ToString());
HttpContext.Current.Trace.Write("notFoundHandler",
@@ -322,7 +351,8 @@ namespace umbraco {
_chAssembly, _chType, url, redirectID));
// check for caching
- if (typeInstance.CacheUrl) {
+ if (typeInstance.CacheUrl)
+ {
if (url.Substring(0, 1) != "/")
url = "/" + url;
@@ -346,7 +376,9 @@ namespace umbraco {
break;
}
}
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
HttpContext.Current.Trace.Warn("notFoundHandler",
"Error implementing notfoundHandler '" + _chAssembly + "." +
_chType + "'", e);
@@ -357,17 +389,21 @@ namespace umbraco {
HttpContext.Current.Trace.Write("umbracoRequestHandler", "After xPath query");
// Check for internal redirects
- if (currentPage != null) {
+ if (currentPage != null)
+ {
XmlNode internalRedirect = currentPage.SelectSingleNode(UmbracoSettings.UseLegacyXmlSchema ? "data [@alias = 'umbracoInternalRedirectId']" : "umbracoInternalRedirectId");
- if (internalRedirect != null && internalRedirect.FirstChild != null && !String.IsNullOrEmpty(internalRedirect.FirstChild.Value)) {
+ if (internalRedirect != null && internalRedirect.FirstChild != null && !String.IsNullOrEmpty(internalRedirect.FirstChild.Value))
+ {
HttpContext.Current.Trace.Write("internalRedirection", "Found internal redirect id via umbracoInternalRedirectId property alias");
int internalRedirectId = 0;
- if (int.TryParse(internalRedirect.FirstChild.Value, out internalRedirectId) && internalRedirectId > 0) {
+ if (int.TryParse(internalRedirect.FirstChild.Value, out internalRedirectId) && internalRedirectId > 0)
+ {
currentPage =
umbracoContent.GetElementById(
internalRedirectId.ToString());
HttpContext.Current.Trace.Write("internalRedirection", "Redirecting to " + internalRedirect.FirstChild.Value);
- } else
+ }
+ else
HttpContext.Current.Trace.Warn("internalRedirection", "The redirect id is not an integer: " + internalRedirect.FirstChild.Value);
}
@@ -375,242 +411,74 @@ namespace umbraco {
// Check access
HttpContext.Current.Trace.Write("umbracoRequestHandler", "Access checking started");
- if (currentPage != null) {
+ if (currentPage != null)
+ {
int id = int.Parse(currentPage.Attributes.GetNamedItem("id").Value);
string path = currentPage.Attributes.GetNamedItem("path").Value;
- if (Access.IsProtected(id, path)) {
+ if (Access.IsProtected(id, path))
+ {
HttpContext.Current.Trace.Write("umbracoRequestHandler", "Page protected");
var user = System.Web.Security.Membership.GetUser();
- if (user == null || !library.IsLoggedOn()) {
+ if (user == null || !library.IsLoggedOn())
+ {
HttpContext.Current.Trace.Write("umbracoRequestHandler", "Not logged in - redirecting to login page...");
currentPage = umbracoContent.GetElementById(Access.GetLoginPage(path).ToString());
- } else {
+ }
+ else
+ {
+
+ if (user != null && !Access.HasAccces(id, user.ProviderUserKey))
+ {
- if (user != null && !Access.HasAccces(id, user.ProviderUserKey)) {
-
HttpContext.Current.Trace.Write("umbracoRequestHandler", "Member has not access - redirecting to error page...");
currentPage = content.Instance.XmlContent.GetElementById(Access.GetErrorPage(path).ToString());
}
}
- } else
+ }
+ else
HttpContext.Current.Trace.Write("umbracoRequestHandler", "Page not protected");
}
HttpContext.Current.Trace.Write("umbracoRequestHandler", "Access checking ended");
-
+
}
}
- public class SearchForAlias : INotFoundHandler {
- private int _redirectID = -1;
- private bool _cacheUrl = true;
-
- #region INotFoundHandler Members
-
- public bool Execute(string url) {
- bool _succes = false;
- string tempUrl = url.Trim('/').Replace(".aspx", string.Empty).ToLower();
- if (tempUrl.Length > 0) {
- HttpContext.Current.Trace.Write("urlAlias", "'" + tempUrl + "'");
-
- // Check for domain
- string currentDomain = System.Web.HttpContext.Current.Request.ServerVariables["SERVER_NAME"];
- string prefixXPath = "";
- if (Domain.Exists(currentDomain)) {
- string xpathDomain = UmbracoSettings.UseLegacyXmlSchema ? "//node [@id = '{0}']" : "//* [@isDoc and @id = '{0}']";
- prefixXPath = string.Format(xpathDomain, Domain.GetRootFromDomain(currentDomain));
- _cacheUrl = false;
- }
-
-
- // the reason we have almost two identical queries in the xpath is to support scenarios where the user have
- // entered "/my-url" instead of "my-url" (ie. added a beginning slash)
- string xpath = UmbracoSettings.UseLegacyXmlSchema ? "//node [contains(concat(',',translate(data [@alias = 'umbracoUrlAlias'], ' ', ''),','),',{0},') or contains(concat(',',translate(data [@alias = 'umbracoUrlAlias'], ' ', ''),','),',{1},')]" :
- "//* [@isDoc and (contains(concat(',',translate(umbracoUrlAlias, ' ', ''),','),',{0},') or contains(concat(',',translate(umbracoUrlAlias, ' ', ''),','),',{1},'))]";
- string query = String.Format(prefixXPath + xpath, tempUrl, "/" + tempUrl);
- XmlNode redir =
- content.Instance.XmlContent.DocumentElement.SelectSingleNode(query);
- if (redir != null) {
- _succes = true;
- _redirectID = int.Parse(redir.Attributes.GetNamedItem("id").Value);
- }
- }
- return _succes;
+ [Obsolete("This has been replaced with ScriptingMacroResult instead")]
+ public class DLRMacroResult
+ {
+ public DLRMacroResult()
+ {
}
- public bool CacheUrl {
- get { return _cacheUrl; }
+ public DLRMacroResult(Control control, Exception resultException)
+ {
+ Control = control;
+ ResultException = resultException;
}
- public int redirectID {
- get {
- // TODO: Add SearchForAlias.redirectID getter implementation
- return _redirectID;
- }
- }
-
- #endregion
+ public Control Control { get; set; }
+ public Exception ResultException { get; set; }
}
- public class SearchForProfile : INotFoundHandler {
- private static int _profileId = -1;
+ [Obsolete("This class is no longer used, use Umbraco.Web.Cache.MacroCacheRefresher instead")]
+ public class macroCacheRefresh : Umbraco.Web.Cache.MacroCacheRefresher
+ {
- private int _redirectID = -1;
-
- #region INotFoundHandler Members
-
- public bool CacheUrl {
- get {
- // Do not cache profile urls, we need to store the login name
- return false;
- }
- }
-
- public bool Execute(string url) {
- bool _succes = false;
- url = url.Replace(".aspx", string.Empty);
- if (url.Length > 0) {
- if (url.Substring(0, 1) == "/")
- url = url.Substring(1, url.Length - 1);
-
- if (url.IndexOf("/") > 0) {
- // Check if we're at the profile page
- if (url.Substring(0, url.IndexOf("/")) == GlobalSettings.ProfileUrl) {
- if (_profileId < 0) {
- // /root added to query to solve umbRuntime bug
- string _tempQuery =
- requestHandler.CreateXPathQuery(url.Substring(0, url.IndexOf("/")), false);
- _profileId =
- int.Parse(
- content.Instance.XmlContent.SelectSingleNode(_tempQuery).Attributes.GetNamedItem(
- "id").Value);
- }
-
- HttpContext.Current.Items["umbMemberLogin"] =
- url.Substring(url.IndexOf("/") + 1, url.Length - url.IndexOf("/") - 1);
- _succes = true;
- _redirectID = _profileId;
- }
- }
- }
- return _succes;
- }
-
- public int redirectID {
- get {
- // TODO: Add SearchForProfile.redirectID getter implementation
- return _redirectID;
- }
- }
-
- #endregion
}
- public class SearchForTemplate : INotFoundHandler {
- private int _redirectID = -1;
+ [Obsolete("This class is no longer used, use Umbraco.Web.Cache.LibraryCacheRefresher instead")]
+ public class LibraryCacheRefresher : Umbraco.Web.Cache.CacheRefresherEventHandler
+ {
- #region INotFoundHandler Members
-
- public bool CacheUrl {
- get {
- // Do not cache profile urls, we need to store the login name
- return false;
- }
- }
-
- public bool Execute(string url) {
- bool _succes = false;
- url = url.Replace(".aspx", string.Empty);
- string currentDomain = HttpContext.Current.Request.ServerVariables["SERVER_NAME"];
- if (url.Length > 0) {
- if (url.Substring(0, 1) == "/")
- url = url.Substring(1, url.Length - 1);
-
- XmlNode urlNode = null;
- string templateAlias = "";
-
- // We're at domain root
- if (url.IndexOf("/") == -1)
- {
- if (Domain.Exists(currentDomain))
- urlNode = content.Instance.XmlContent.GetElementById(Domain.GetRootFromDomain(currentDomain).ToString());
- else
- urlNode = content.Instance.XmlContent.GetElementById(Document.GetRootDocuments()[0].Id.ToString());
- templateAlias = url.ToLower();
- }
- else
- {
- string theRealUrl = url.Substring(0, url.LastIndexOf("/"));
- string realUrlXPath = requestHandler.CreateXPathQuery(theRealUrl, true);
- urlNode = content.Instance.XmlContent.SelectSingleNode(realUrlXPath);
- templateAlias =
- url.Substring(url.LastIndexOf("/") + 1, url.Length - url.LastIndexOf(("/")) - 1).ToLower();
- }
-
- if (urlNode != null && Template.GetTemplateIdFromAlias(templateAlias) != 0)
- {
- _redirectID = int.Parse(urlNode.Attributes.GetNamedItem("id").Value);
-
- HttpContext.Current.Items["altTemplate"] = templateAlias;
- HttpContext.Current.Trace.Write("umbraco.altTemplateHandler",
- string.Format("Templated changed to: '{0}'",
- HttpContext.Current.Items["altTemplate"]));
- _succes = true;
- }
- }
- return _succes;
- }
-
- public int redirectID {
- get {
- // TODO: Add SearchForProfile.redirectID getter implementation
- return _redirectID;
- }
- }
-
- #endregion
}
- public class handle404 : INotFoundHandler {
- #region INotFoundHandler Members
+ [Obsolete("This class is no longer used, use Umbraco.Web.Cache.TemplateCacheRefresher instead")]
+ public class templateCacheRefresh : Umbraco.Web.Cache.TemplateCacheRefresher
+ {
- private int _redirectID = 0;
-
- public bool CacheUrl {
- get {
- return false;
- }
- }
-
- public bool Execute(string url) {
- try
- {
- LogHelper.Info(string.Format("NotFound url {0} (from '{1}')", url, HttpContext.Current.Request.UrlReferrer));
-
- // Test if the error404 not child elements
- string error404 = umbraco.library.GetCurrentNotFoundPageId();
-
-
- _redirectID = int.Parse(error404);
- HttpContext.Current.Response.StatusCode = 404;
- return true;
- }
- catch (Exception err)
- {
- LogHelper.Error("An error occurred", err);
- return false;
- }
- }
-
- public int redirectID {
- get {
- return _redirectID;
- }
- }
-
- #endregion
}
-}
\ No newline at end of file
+}
diff --git a/src/Umbraco.Web/umbraco.presentation/LibraryCacheRefresher.cs b/src/Umbraco.Web/umbraco.presentation/LibraryCacheRefresher.cs
deleted file mode 100644
index 3cb9133552..0000000000
--- a/src/Umbraco.Web/umbraco.presentation/LibraryCacheRefresher.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System;
-using umbraco.businesslogic;
-using umbraco.cms.businesslogic;
-using umbraco.cms.businesslogic.media;
-using umbraco.cms.businesslogic.member;
-using umbraco.interfaces;
-
-namespace umbraco
-{
-
- [Obsolete("This class is no longer used, use Umbraco.Web.Cache.LibraryCacheRefresher instead")]
- public class LibraryCacheRefresher : Umbraco.Web.Cache.CacheRefresherEventHandler
- {
-
- }
-}
\ No newline at end of file
diff --git a/src/Umbraco.Web/umbraco.presentation/NotFoundHandlers.cs b/src/Umbraco.Web/umbraco.presentation/NotFoundHandlers.cs
new file mode 100644
index 0000000000..ac449e8118
--- /dev/null
+++ b/src/Umbraco.Web/umbraco.presentation/NotFoundHandlers.cs
@@ -0,0 +1,228 @@
+using System;
+using System.Collections;
+using System.Diagnostics;
+using System.Reflection;
+using System.Web;
+using System.Xml;
+using Umbraco.Core.Logging;
+using umbraco.BusinessLogic;
+using umbraco.cms.businesslogic.member;
+using umbraco.cms.businesslogic.template;
+using umbraco.cms.businesslogic.web;
+using umbraco.interfaces;
+using umbraco.IO;
+using umbraco.NodeFactory;
+
+namespace umbraco {
+
+
+ public class SearchForAlias : INotFoundHandler {
+ private int _redirectID = -1;
+ private bool _cacheUrl = true;
+
+ #region INotFoundHandler Members
+
+ public bool Execute(string url) {
+ bool _succes = false;
+ string tempUrl = url.Trim('/').Replace(".aspx", string.Empty).ToLower();
+ if (tempUrl.Length > 0) {
+ HttpContext.Current.Trace.Write("urlAlias", "'" + tempUrl + "'");
+
+ // Check for domain
+ string currentDomain = System.Web.HttpContext.Current.Request.ServerVariables["SERVER_NAME"];
+ string prefixXPath = "";
+ if (Domain.Exists(currentDomain)) {
+ string xpathDomain = UmbracoSettings.UseLegacyXmlSchema ? "//node [@id = '{0}']" : "//* [@isDoc and @id = '{0}']";
+ prefixXPath = string.Format(xpathDomain, Domain.GetRootFromDomain(currentDomain));
+ _cacheUrl = false;
+ }
+
+
+ // the reason we have almost two identical queries in the xpath is to support scenarios where the user have
+ // entered "/my-url" instead of "my-url" (ie. added a beginning slash)
+ string xpath = UmbracoSettings.UseLegacyXmlSchema ? "//node [contains(concat(',',translate(data [@alias = 'umbracoUrlAlias'], ' ', ''),','),',{0},') or contains(concat(',',translate(data [@alias = 'umbracoUrlAlias'], ' ', ''),','),',{1},')]" :
+ "//* [@isDoc and (contains(concat(',',translate(umbracoUrlAlias, ' ', ''),','),',{0},') or contains(concat(',',translate(umbracoUrlAlias, ' ', ''),','),',{1},'))]";
+ string query = String.Format(prefixXPath + xpath, tempUrl, "/" + tempUrl);
+ XmlNode redir =
+ content.Instance.XmlContent.DocumentElement.SelectSingleNode(query);
+ if (redir != null) {
+ _succes = true;
+ _redirectID = int.Parse(redir.Attributes.GetNamedItem("id").Value);
+ }
+ }
+ return _succes;
+ }
+
+ public bool CacheUrl {
+ get { return _cacheUrl; }
+ }
+
+ public int redirectID {
+ get {
+ // TODO: Add SearchForAlias.redirectID getter implementation
+ return _redirectID;
+ }
+ }
+
+ #endregion
+ }
+
+ public class SearchForProfile : INotFoundHandler {
+ private static int _profileId = -1;
+
+ private int _redirectID = -1;
+
+ #region INotFoundHandler Members
+
+ public bool CacheUrl {
+ get {
+ // Do not cache profile urls, we need to store the login name
+ return false;
+ }
+ }
+
+ public bool Execute(string url) {
+ bool _succes = false;
+ url = url.Replace(".aspx", string.Empty);
+ if (url.Length > 0) {
+ if (url.Substring(0, 1) == "/")
+ url = url.Substring(1, url.Length - 1);
+
+ if (url.IndexOf("/") > 0) {
+ // Check if we're at the profile page
+ if (url.Substring(0, url.IndexOf("/")) == GlobalSettings.ProfileUrl) {
+ if (_profileId < 0) {
+ // /root added to query to solve umbRuntime bug
+ string _tempQuery =
+ requestHandler.CreateXPathQuery(url.Substring(0, url.IndexOf("/")), false);
+ _profileId =
+ int.Parse(
+ content.Instance.XmlContent.SelectSingleNode(_tempQuery).Attributes.GetNamedItem(
+ "id").Value);
+ }
+
+ HttpContext.Current.Items["umbMemberLogin"] =
+ url.Substring(url.IndexOf("/") + 1, url.Length - url.IndexOf("/") - 1);
+ _succes = true;
+ _redirectID = _profileId;
+ }
+ }
+ }
+ return _succes;
+ }
+
+ public int redirectID {
+ get {
+ // TODO: Add SearchForProfile.redirectID getter implementation
+ return _redirectID;
+ }
+ }
+
+ #endregion
+ }
+
+ public class SearchForTemplate : INotFoundHandler {
+ private int _redirectID = -1;
+
+ #region INotFoundHandler Members
+
+ public bool CacheUrl {
+ get {
+ // Do not cache profile urls, we need to store the login name
+ return false;
+ }
+ }
+
+ public bool Execute(string url) {
+ bool _succes = false;
+ url = url.Replace(".aspx", string.Empty);
+ string currentDomain = HttpContext.Current.Request.ServerVariables["SERVER_NAME"];
+ if (url.Length > 0) {
+ if (url.Substring(0, 1) == "/")
+ url = url.Substring(1, url.Length - 1);
+
+ XmlNode urlNode = null;
+ string templateAlias = "";
+
+ // We're at domain root
+ if (url.IndexOf("/") == -1)
+ {
+ if (Domain.Exists(currentDomain))
+ urlNode = content.Instance.XmlContent.GetElementById(Domain.GetRootFromDomain(currentDomain).ToString());
+ else
+ urlNode = content.Instance.XmlContent.GetElementById(Document.GetRootDocuments()[0].Id.ToString());
+ templateAlias = url.ToLower();
+ }
+ else
+ {
+ string theRealUrl = url.Substring(0, url.LastIndexOf("/"));
+ string realUrlXPath = requestHandler.CreateXPathQuery(theRealUrl, true);
+ urlNode = content.Instance.XmlContent.SelectSingleNode(realUrlXPath);
+ templateAlias =
+ url.Substring(url.LastIndexOf("/") + 1, url.Length - url.LastIndexOf(("/")) - 1).ToLower();
+ }
+
+ if (urlNode != null && Template.GetTemplateIdFromAlias(templateAlias) != 0)
+ {
+ _redirectID = int.Parse(urlNode.Attributes.GetNamedItem("id").Value);
+
+ HttpContext.Current.Items["altTemplate"] = templateAlias;
+ HttpContext.Current.Trace.Write("umbraco.altTemplateHandler",
+ string.Format("Templated changed to: '{0}'",
+ HttpContext.Current.Items["altTemplate"]));
+ _succes = true;
+ }
+ }
+ return _succes;
+ }
+
+ public int redirectID {
+ get {
+ // TODO: Add SearchForProfile.redirectID getter implementation
+ return _redirectID;
+ }
+ }
+
+ #endregion
+ }
+
+ public class handle404 : INotFoundHandler {
+ #region INotFoundHandler Members
+
+ private int _redirectID = 0;
+
+ public bool CacheUrl {
+ get {
+ return false;
+ }
+ }
+
+ public bool Execute(string url) {
+ try
+ {
+ LogHelper.Info(string.Format("NotFound url {0} (from '{1}')", url, HttpContext.Current.Request.UrlReferrer));
+
+ // Test if the error404 not child elements
+ string error404 = umbraco.library.GetCurrentNotFoundPageId();
+
+
+ _redirectID = int.Parse(error404);
+ HttpContext.Current.Response.StatusCode = 404;
+ return true;
+ }
+ catch (Exception err)
+ {
+ LogHelper.Error("An error occurred", err);
+ return false;
+ }
+ }
+
+ public int redirectID {
+ get {
+ return _redirectID;
+ }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Web/umbraco.presentation/macroCacheRefresh.cs b/src/Umbraco.Web/umbraco.presentation/macroCacheRefresh.cs
deleted file mode 100644
index fc8bee701a..0000000000
--- a/src/Umbraco.Web/umbraco.presentation/macroCacheRefresh.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System;
-using umbraco.interfaces;
-
-namespace umbraco
-{
- [Obsolete("This class is no longer used, use Umbraco.Web.Cache.MacroCacheRefresher instead")]
- public class macroCacheRefresh : Umbraco.Web.Cache.MacroCacheRefresher
- {
-
- }
-}
\ No newline at end of file
diff --git a/src/Umbraco.Web/umbraco.presentation/template.cs b/src/Umbraco.Web/umbraco.presentation/template.cs
index 45367d290d..6063bca584 100644
--- a/src/Umbraco.Web/umbraco.presentation/template.cs
+++ b/src/Umbraco.Web/umbraco.presentation/template.cs
@@ -574,10 +574,6 @@ namespace umbraco
#endregion
}
- [Obsolete("This class is no longer used, use Umbraco.Web.Cache.TemplateCacheRefresher instead")]
- public class templateCacheRefresh : Umbraco.Web.Cache.TemplateCacheRefresher
- {
-
- }
+
}