diff --git a/src/Orchard.Web/Modules/Orchard.Autoroute/Orchard.Autoroute.csproj b/src/Orchard.Web/Modules/Orchard.Autoroute/Orchard.Autoroute.csproj
index a2644d32c..edcf11fed 100644
--- a/src/Orchard.Web/Modules/Orchard.Autoroute/Orchard.Autoroute.csproj
+++ b/src/Orchard.Web/Modules/Orchard.Autoroute/Orchard.Autoroute.csproj
@@ -96,6 +96,8 @@
+
+
diff --git a/src/Orchard.Web/Modules/Orchard.Autoroute/Services/IAutorouteService.cs b/src/Orchard.Web/Modules/Orchard.Autoroute/Services/IAutorouteService.cs
index bcaffbff0..d7c93aebe 100644
--- a/src/Orchard.Web/Modules/Orchard.Autoroute/Services/IAutorouteService.cs
+++ b/src/Orchard.Web/Modules/Orchard.Autoroute/Services/IAutorouteService.cs
@@ -11,9 +11,7 @@ namespace Orchard.Autoroute.Services {
string GenerateAlias(AutoroutePart part);
void PublishAlias(AutoroutePart part);
-
void RemoveAliases(AutoroutePart part);
-
void CreatePattern(string contentType, string name, string pattern, string description, bool makeDefault);
RoutePattern GetDefaultPattern(string contentType);
IEnumerable GetPatterns(string contentType);
diff --git a/src/Orchard.Web/Modules/Orchard.Autoroute/Services/IPathResolutionService.cs b/src/Orchard.Web/Modules/Orchard.Autoroute/Services/IPathResolutionService.cs
new file mode 100644
index 000000000..91543fb90
--- /dev/null
+++ b/src/Orchard.Web/Modules/Orchard.Autoroute/Services/IPathResolutionService.cs
@@ -0,0 +1,8 @@
+using Orchard.Autoroute.Models;
+
+namespace Orchard.Autoroute.Services {
+
+ public interface IPathResolutionService : IDependency {
+ AutoroutePart GetPath(string path);
+ }
+}
diff --git a/src/Orchard.Web/Modules/Orchard.Autoroute/Services/PathResolutionService.cs b/src/Orchard.Web/Modules/Orchard.Autoroute/Services/PathResolutionService.cs
new file mode 100644
index 000000000..22cf06e50
--- /dev/null
+++ b/src/Orchard.Web/Modules/Orchard.Autoroute/Services/PathResolutionService.cs
@@ -0,0 +1,20 @@
+using System.Linq;
+using Orchard.Autoroute.Models;
+using Orchard.ContentManagement;
+
+namespace Orchard.Autoroute.Services {
+ public class PathResolutionService : IPathResolutionService {
+ private readonly IContentManager _contentManager;
+
+ public PathResolutionService(IContentManager contentManager) {
+ _contentManager = contentManager;
+ }
+
+ public AutoroutePart GetPath(string path) {
+ return _contentManager.Query()
+ .Where(part => part.DisplayAlias == path)
+ .Slice(0, 1)
+ .FirstOrDefault();
+ }
+ }
+}
diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Handlers/BlogPartHandler.cs b/src/Orchard.Web/Modules/Orchard.Blogs/Handlers/BlogPartHandler.cs
index 1f19d71cb..b5d91ce1d 100644
--- a/src/Orchard.Web/Modules/Orchard.Blogs/Handlers/BlogPartHandler.cs
+++ b/src/Orchard.Web/Modules/Orchard.Blogs/Handlers/BlogPartHandler.cs
@@ -1,28 +1,21 @@
using System.Web.Routing;
using JetBrains.Annotations;
using Orchard.Blogs.Models;
-using Orchard.Blogs.Routing;
using Orchard.ContentManagement;
-using Orchard.ContentManagement.Aspects;
using Orchard.ContentManagement.Handlers;
using Orchard.Data;
namespace Orchard.Blogs.Handlers {
[UsedImplicitly]
public class BlogPartHandler : ContentHandler {
- private readonly IBlogPathConstraint _blogPathConstraint;
- public BlogPartHandler(IRepository repository, IBlogPathConstraint blogPathConstraint) {
- _blogPathConstraint = blogPathConstraint;
+ public BlogPartHandler(IRepository repository) {
Filters.Add(StorageFilter.For(repository));
OnGetDisplayShape((context, blog) => {
context.Shape.Description = blog.Description;
context.Shape.PostCount = blog.PostCount;
});
-
- OnPublished((context, blog) => _blogPathConstraint.AddPath(blog.As().Path));
- OnUnpublished((context, blog) => _blogPathConstraint.RemovePath(blog.As().Path));
}
protected override void GetItemMetadata(GetContentItemMetadataContext context) {
diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Orchard.Blogs.csproj b/src/Orchard.Web/Modules/Orchard.Blogs/Orchard.Blogs.csproj
index 37eb0d8ae..b645dcc39 100644
--- a/src/Orchard.Web/Modules/Orchard.Blogs/Orchard.Blogs.csproj
+++ b/src/Orchard.Web/Modules/Orchard.Blogs/Orchard.Blogs.csproj
@@ -85,13 +85,10 @@
-
-
-
diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Routing/ArchiveConstraint.CS b/src/Orchard.Web/Modules/Orchard.Blogs/Routing/ArchiveConstraint.CS
index f5e4ad05f..20d30d7b5 100644
--- a/src/Orchard.Web/Modules/Orchard.Blogs/Routing/ArchiveConstraint.CS
+++ b/src/Orchard.Web/Modules/Orchard.Blogs/Routing/ArchiveConstraint.CS
@@ -1,14 +1,16 @@
using System;
using System.Web;
using System.Web.Routing;
+using Orchard.Autoroute.Services;
using Orchard.Blogs.Models;
+using Orchard.ContentManagement;
namespace Orchard.Blogs.Routing {
public class ArchiveConstraint : IArchiveConstraint {
- private readonly IBlogPathConstraint _blogPathConstraint;
+ private readonly IPathResolutionService _pathResolutionService;
- public ArchiveConstraint(IBlogPathConstraint blogPathConstraint) {
- _blogPathConstraint = blogPathConstraint;
+ public ArchiveConstraint(IPathResolutionService pathResolutionService) {
+ _pathResolutionService = pathResolutionService;
}
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) {
@@ -35,7 +37,9 @@ namespace Orchard.Blogs.Routing {
return false;
}
- return _blogPathConstraint.FindPath(path) != null;
+ var autoroute = _pathResolutionService.GetPath(path);
+
+ return autoroute != null && autoroute.Is();
}
return false;
diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Routing/BlogPathConstraint.cs b/src/Orchard.Web/Modules/Orchard.Blogs/Routing/BlogPathConstraint.cs
deleted file mode 100644
index 6fb86ae45..000000000
--- a/src/Orchard.Web/Modules/Orchard.Blogs/Routing/BlogPathConstraint.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-using System;
-using System.Collections.Concurrent;
-using System.Collections.Generic;
-using System.Linq;
-using System.Web;
-using System.Web.Routing;
-using JetBrains.Annotations;
-using Orchard.Logging;
-
-namespace Orchard.Blogs.Routing {
- [UsedImplicitly]
- public class BlogPathConstraint : IBlogPathConstraint {
- private readonly ConcurrentDictionary _paths = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase);
-
- public BlogPathConstraint() {
- Logger = NullLogger.Instance;
- }
-
- public ILogger Logger { get; set; }
-
- public void SetPaths(IEnumerable paths) {
- _paths.Clear();
- foreach(var path in paths) {
- AddPath(path);
- }
-
- Logger.Debug("Blog paths: {0}", string.Join(", ", paths.ToArray()));
- }
-
- public string FindPath(string path) {
- string actual;
- // path can be null for homepage
- path = path ?? String.Empty;
-
- return _paths.TryGetValue(path, out actual) ? actual : path;
- }
-
- public void AddPath(string path) {
- // path can be null for homepage
- path = path ?? String.Empty;
-
- _paths[path] = path;
- }
-
- public void RemovePath(string path) {
- // path can be null for homepage
- path = path ?? String.Empty;
-
- _paths.TryRemove(path, out path);
- }
-
- public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) {
- if (routeDirection == RouteDirection.UrlGeneration)
- return true;
-
- object value;
- if (values.TryGetValue(parameterName, out value)) {
- var parameterValue = Convert.ToString(value);
-
- return _paths.ContainsKey(parameterValue);
- }
-
- return false;
- }
- }
-}
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Routing/BlogPathConstraintUpdator.cs b/src/Orchard.Web/Modules/Orchard.Blogs/Routing/BlogPathConstraintUpdator.cs
deleted file mode 100644
index 5a35dac9c..000000000
--- a/src/Orchard.Web/Modules/Orchard.Blogs/Routing/BlogPathConstraintUpdator.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using System.Linq;
-using JetBrains.Annotations;
-using Orchard.Blogs.Services;
-using Orchard.ContentManagement;
-using Orchard.ContentManagement.Aspects;
-using Orchard.Environment;
-using Orchard.Tasks;
-
-namespace Orchard.Blogs.Routing {
- [UsedImplicitly]
- public class BlogPathConstraintUpdator : IOrchardShellEvents, IBackgroundTask {
- private readonly IBlogPathConstraint _blogPathConstraint;
- private readonly IBlogService _blogService;
-
- public BlogPathConstraintUpdator(IBlogPathConstraint blogPathConstraint, IBlogService blogService) {
- _blogPathConstraint = blogPathConstraint;
- _blogService = blogService;
- }
-
- void IOrchardShellEvents.Activated() {
- Refresh();
- }
-
- void IOrchardShellEvents.Terminating() {
- }
-
- void IBackgroundTask.Sweep() {
- Refresh();
- }
-
- private void Refresh() {
- _blogPathConstraint.SetPaths(_blogService.Get().Select(b => b.As().Path).ToList());
- }
- }
-}
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Routing/IBlogPathConstraint.cs b/src/Orchard.Web/Modules/Orchard.Blogs/Routing/IBlogPathConstraint.cs
deleted file mode 100644
index a3742cb29..000000000
--- a/src/Orchard.Web/Modules/Orchard.Blogs/Routing/IBlogPathConstraint.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System.Collections.Generic;
-using System.Web.Routing;
-
-namespace Orchard.Blogs.Routing {
- public interface IBlogPathConstraint : IRouteConstraint, ISingletonDependency {
- void SetPaths(IEnumerable paths);
- string FindPath(string path);
- void AddPath(string path);
- void RemovePath(string path);
- }
-}
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Routing/RsdConstraint.CS b/src/Orchard.Web/Modules/Orchard.Blogs/Routing/RsdConstraint.CS
index 9eb29fed1..d8ec635d2 100644
--- a/src/Orchard.Web/Modules/Orchard.Blogs/Routing/RsdConstraint.CS
+++ b/src/Orchard.Web/Modules/Orchard.Blogs/Routing/RsdConstraint.CS
@@ -1,13 +1,16 @@
using System;
using System.Web;
using System.Web.Routing;
+using Orchard.Autoroute.Services;
+using Orchard.Blogs.Models;
+using Orchard.ContentManagement;
namespace Orchard.Blogs.Routing {
public class RsdConstraint : IRsdConstraint {
- private readonly IBlogPathConstraint _blogPathConstraint;
+ private readonly IPathResolutionService _pathResolutionService;
- public RsdConstraint(IBlogPathConstraint blogPathConstraint) {
- _blogPathConstraint = blogPathConstraint;
+ public RsdConstraint(IPathResolutionService pathResolutionService) {
+ _pathResolutionService = pathResolutionService;
}
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) {
@@ -23,7 +26,9 @@ namespace Orchard.Blogs.Routing {
return false;
}
- return _blogPathConstraint.FindPath(path) != null;
+ var autoroute = _pathResolutionService.GetPath(path);
+
+ return autoroute != null && autoroute.Is();
}
return false;
diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Services/BlogPostService.cs b/src/Orchard.Web/Modules/Orchard.Blogs/Services/BlogPostService.cs
index 5c144a140..6eed51ab5 100644
--- a/src/Orchard.Web/Modules/Orchard.Blogs/Services/BlogPostService.cs
+++ b/src/Orchard.Web/Modules/Orchard.Blogs/Services/BlogPostService.cs
@@ -1,15 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Reflection;
using JetBrains.Annotations;
using Orchard.Blogs.Models;
using Orchard.ContentManagement;
-using Orchard.ContentManagement.Aspects;
using Orchard.ContentManagement.MetaData;
using Orchard.Core.Common.Models;
using Orchard.Data;
-using Orchard.Data.Conventions;
using Orchard.Tasks.Scheduling;
namespace Orchard.Blogs.Services {
diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Services/BlogService.cs b/src/Orchard.Web/Modules/Orchard.Blogs/Services/BlogService.cs
index 6bc664967..c7be9aada 100644
--- a/src/Orchard.Web/Modules/Orchard.Blogs/Services/BlogService.cs
+++ b/src/Orchard.Web/Modules/Orchard.Blogs/Services/BlogService.cs
@@ -3,20 +3,16 @@ using System.Linq;
using JetBrains.Annotations;
using Orchard.Autoroute.Models;
using Orchard.Blogs.Models;
-using Orchard.Blogs.Routing;
using Orchard.ContentManagement;
-using Orchard.ContentManagement.Aspects;
using Orchard.Core.Title.Models;
namespace Orchard.Blogs.Services {
[UsedImplicitly]
public class BlogService : IBlogService {
private readonly IContentManager _contentManager;
- private readonly IBlogPathConstraint _blogPathConstraint;
- public BlogService(IContentManager contentManager, IBlogPathConstraint blogPathConstraint) {
+ public BlogService(IContentManager contentManager) {
_contentManager = contentManager;
- _blogPathConstraint = blogPathConstraint;
}
public BlogPart Get(string path) {
@@ -41,7 +37,6 @@ namespace Orchard.Blogs.Services {
public void Delete(ContentItem blog) {
_contentManager.Remove(blog);
- _blogPathConstraint.RemovePath(blog.As().Path);
}
}
}
\ No newline at end of file