Updated DocumentRequest so that it doesn't actually do the searching, it acts more like a model.

The DocumentSearcher now performs the searching and sets the properties on the DocumentRequest, this
simplifies the dependencies between the contexts. Updated the LookupByNiceUrlTests unit test, now all
initialization is working and the test runs which will be the basis for testing all of the IDocumentLookups.
This commit is contained in:
shannon@ShandemVaio
2012-08-09 04:15:35 +06:00
parent 739de3ef78
commit 2e5db72a09
19 changed files with 587 additions and 454 deletions

View File

@@ -64,6 +64,7 @@ namespace Umbraco.Web
var niceUrls = new NiceUrlProvider(contentStore, umbracoContext);
//create the RoutingContext
var routingContext = new RoutingContext(
umbracoContext,
DocumentLookupsResolver.Current.DocumentLookups,
LastChanceLookupResolver.Current.LastChanceLookup,
contentStore,
@@ -83,8 +84,8 @@ namespace Umbraco.Web
//Create a document request since we are rendering a document on the front-end
// create the new document request which will cleanup the uri once and for all
var docreq = new DocumentRequest(uri, umbracoContext);
//assign the routing context to the umbraco context
var docreq = new DocumentRequest(uri, routingContext);
//assign the document request to the umbraco context now that we know its a front end request
umbracoContext.DocumentRequest = docreq;
// note - at that point the original legacy module did something do handle IIS custom 404 errors
@@ -95,14 +96,21 @@ namespace Umbraco.Web
// to trigger Umbraco's not-found, one should configure IIS and/or ASP.NET custom 404 errors
// so that they point to a non-existing page eg /redirect-404.aspx
docreq.LookupDomain();
//create the searcher
var searcher = new DocumentSearcher(docreq);
//find domain
searcher.LookupDomain();
//redirect if it has been flagged
if (docreq.IsRedirect)
httpContext.Response.Redirect(docreq.RedirectUrl, true);
//set the culture on the thread
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture = docreq.Culture;
docreq.LookupDocument();
//find the document
searcher.LookupDocument();
//redirect if it has been flagged
if (docreq.IsRedirect)
httpContext.Response.Redirect(docreq.RedirectUrl, true);
//if no doc is found, send to our not found handler
if (docreq.Is404)
{
httpContext.RemapHandler(new DocumentNotFoundHttpHandler());