Merge branch 'dev' into feature/recipesteps

Conflicts:
	src/Orchard.Tests.Modules/Recipes/Services/RecipeManagerTests.cs
	src/Orchard.Web/Modules/Orchard.ImportExport/Controllers/AdminController.cs
This commit is contained in:
Sipke Schoorstra
2015-07-16 19:21:12 +01:00
9 changed files with 67 additions and 33 deletions

View File

@@ -19,7 +19,9 @@ using Orchard.Recipes.Services;
using Orchard.Services; using Orchard.Services;
using Orchard.Tests.Stubs; using Orchard.Tests.Stubs;
using Orchard.Recipes.Events; using Orchard.Recipes.Events;
using Orchard.Tests.ContentManagement; using Orchard.Data;
using System;
using System.Linq.Expressions;
namespace Orchard.Tests.Modules.Recipes.Services { namespace Orchard.Tests.Modules.Recipes.Services {
[TestFixture] [TestFixture]
@@ -100,9 +102,7 @@ namespace Orchard.Tests.Modules.Recipes.Services {
builder.RegisterType<RecipeParser>().As<IRecipeParser>(); builder.RegisterType<RecipeParser>().As<IRecipeParser>();
builder.RegisterType<StubWebSiteFolder>().As<IWebSiteFolder>(); builder.RegisterType<StubWebSiteFolder>().As<IWebSiteFolder>();
builder.RegisterType<CustomRecipeHandler>().As<IRecipeHandler>(); builder.RegisterType<CustomRecipeHandler>().As<IRecipeHandler>();
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>)); builder.RegisterInstance(new StubRecipeStepResultRecordRepository()).As<IRepository<RecipeStepResultRecord>>();
_session = _sessionFactory.OpenSession();
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>();
_container = builder.Build(); _container = builder.Build();
_recipeManager = _container.Resolve<IRecipeManager>(); _recipeManager = _container.Resolve<IRecipeManager>();
@@ -117,7 +117,7 @@ namespace Orchard.Tests.Modules.Recipes.Services {
[Test] [Test]
public void HarvestRecipesFailsToFindRecipesWhenCalledWithNotExistingExtension() { public void HarvestRecipesFailsToFindRecipesWhenCalledWithNotExistingExtension() {
var recipes = (List<Recipe>) _recipeHarvester.HarvestRecipes("cantfindme"); var recipes = (List<Recipe>)_recipeHarvester.HarvestRecipes("cantfindme");
Assert.That(recipes.Count, Is.EqualTo(0)); Assert.That(recipes.Count, Is.EqualTo(0));
} }
@@ -130,7 +130,7 @@ namespace Orchard.Tests.Modules.Recipes.Services {
[Test] [Test]
public void ParseRecipeLoadsRecipeMetaDataIntoModel() { public void ParseRecipeLoadsRecipeMetaDataIntoModel() {
var recipes = (List<Recipe>) _recipeHarvester.HarvestRecipes("Sample1"); var recipes = (List<Recipe>)_recipeHarvester.HarvestRecipes("Sample1");
Assert.That(recipes.Count, Is.EqualTo(1)); Assert.That(recipes.Count, Is.EqualTo(1));
var sampleRecipe = recipes[0]; var sampleRecipe = recipes[0];
@@ -149,7 +149,7 @@ namespace Orchard.Tests.Modules.Recipes.Services {
Assert.That(recipes.Count, Is.EqualTo(1)); Assert.That(recipes.Count, Is.EqualTo(1));
var sampleRecipe = recipes[0]; var sampleRecipe = recipes[0];
var recipeSteps = (List<RecipeStep>) sampleRecipe.RecipeSteps; var recipeSteps = (List<RecipeStep>)sampleRecipe.RecipeSteps;
Assert.That(recipeSteps.Count, Is.EqualTo(9)); Assert.That(recipeSteps.Count, Is.EqualTo(9));
} }
@@ -183,6 +183,22 @@ namespace Orchard.Tests.Modules.Recipes.Services {
} }
} }
public class StubRecipeStepResultRecordRepository : IRepository<RecipeStepResultRecord> {
private List<RecipeStepResultRecord> _records = new List<RecipeStepResultRecord>();
public IQueryable<RecipeStepResultRecord> Table { get { return _records.AsQueryable(); } }
public void Copy(RecipeStepResultRecord source, RecipeStepResultRecord target) { }
public int Count(Expression<Func<RecipeStepResultRecord, bool>> predicate) { return _records.Count; }
public void Create(RecipeStepResultRecord entity) { _records.Add(entity); }
public void Delete(RecipeStepResultRecord entity) { _records.Remove(entity); }
public IEnumerable<RecipeStepResultRecord> Fetch(Expression<Func<RecipeStepResultRecord, bool>> predicate) { throw new NotImplementedException(); }
public IEnumerable<RecipeStepResultRecord> Fetch(Expression<Func<RecipeStepResultRecord, bool>> predicate, Action<Orderable<RecipeStepResultRecord>> order) { throw new NotImplementedException(); }
public IEnumerable<RecipeStepResultRecord> Fetch(Expression<Func<RecipeStepResultRecord, bool>> predicate, Action<Orderable<RecipeStepResultRecord>> order, int skip, int count) { throw new NotImplementedException(); }
public void Flush() { }
public RecipeStepResultRecord Get(Expression<Func<RecipeStepResultRecord, bool>> predicate) { throw new NotImplementedException(); }
public RecipeStepResultRecord Get(int id) { throw new NotImplementedException(); }
public void Update(RecipeStepResultRecord entity) { }
}
public class StubRecipeScheduler : IRecipeScheduler { public class StubRecipeScheduler : IRecipeScheduler {
private readonly IRecipeStepExecutor _recipeStepExecutor; private readonly IRecipeStepExecutor _recipeStepExecutor;
@@ -197,7 +213,7 @@ namespace Orchard.Tests.Modules.Recipes.Services {
public class CustomRecipeHandler : IRecipeHandler { public class CustomRecipeHandler : IRecipeHandler {
public static string AttributeValue; public static string AttributeValue;
public string[] _handles = {"Module", "Theme", "Migration", "Custom1", "Custom2", "Command", "Metadata", "Feature", "Settings"}; public string[] _handles = { "Module", "Theme", "Migration", "Custom1", "Custom2", "Command", "Metadata", "Feature", "Settings" };
public void ExecuteRecipeStep(RecipeContext recipeContext) { public void ExecuteRecipeStep(RecipeContext recipeContext) {
if (_handles.Contains(recipeContext.RecipeStep.Name)) { if (_handles.Contains(recipeContext.RecipeStep.Name)) {

View File

@@ -9,9 +9,14 @@ namespace Orchard.Core.Contents.Controllers {
[Themed] [Themed]
public class ItemController : Controller { public class ItemController : Controller {
private readonly IContentManager _contentManager; private readonly IContentManager _contentManager;
private readonly IHttpContextAccessor _hca;
public ItemController(IContentManager contentManager, IShapeFactory shapeFactory, IOrchardServices services) { public ItemController(IContentManager contentManager,
IShapeFactory shapeFactory,
IOrchardServices services,
IHttpContextAccessor hca) {
_contentManager = contentManager; _contentManager = contentManager;
_hca = hca;
Shape = shapeFactory; Shape = shapeFactory;
Services = services; Services = services;
T = NullLocalizer.Instance; T = NullLocalizer.Instance;
@@ -39,6 +44,10 @@ namespace Orchard.Core.Contents.Controllers {
} }
var model = _contentManager.BuildDisplay(contentItem); var model = _contentManager.BuildDisplay(contentItem);
if (_hca.Current().Request.IsAjaxRequest()) {
return new ShapePartialResult(this,model);
}
return View(model); return View(model);
} }
@@ -62,6 +71,10 @@ namespace Orchard.Core.Contents.Controllers {
} }
var model = _contentManager.BuildDisplay(contentItem); var model = _contentManager.BuildDisplay(contentItem);
if (_hca.Current().Request.IsAjaxRequest()) {
return new ShapePartialResult(this, model);
}
return View(model); return View(model);
} }
} }

View File

@@ -52,9 +52,6 @@ namespace Orchard.ImportExport.Controllers {
if (!Services.Authorizer.Authorize(Permissions.Import, T("Not allowed to import."))) if (!Services.Authorizer.Authorize(Permissions.Import, T("Not allowed to import.")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
// Sets the request timeout to 10 minutes to give enough time to execute custom recipes.
Services.WorkContext.HttpContext.Server.ScriptTimeout = 600;
var actions = _importActions.OrderByDescending(x => x.Priority).ToList(); var actions = _importActions.OrderByDescending(x => x.Priority).ToList();
var viewModel = new ImportViewModel { var viewModel = new ImportViewModel {
Actions = actions.Select(x => new ImportActionViewModel { Actions = actions.Select(x => new ImportActionViewModel {

View File

@@ -132,6 +132,9 @@ namespace Orchard.ImportExport.Providers.ImportActions {
if (RecipeDocument == null) if (RecipeDocument == null)
return; return;
// Sets the request timeout to 10 minutes to give enough time to execute custom recipes.
_orchardServices.WorkContext.HttpContext.Server.ScriptTimeout = 600;
var executionId = ResetSite ? Setup() : ExecuteRecipe(); var executionId = ResetSite ? Setup() : ExecuteRecipe();
context.ActionResult = new RedirectToRouteResult(new RouteValueDictionary(new { action = "ImportResult", controller = "Admin", area = "Orchard.ImportExport", executionId = executionId })); context.ActionResult = new RedirectToRouteResult(new RouteValueDictionary(new { action = "ImportResult", controller = "Admin", area = "Orchard.ImportExport", executionId = executionId }));
} }

View File

@@ -112,8 +112,8 @@ namespace Orchard.MultiTenancy.Commands {
DataTablePrefix = DataTablePrefix, DataTablePrefix = DataTablePrefix,
RequestUrlHost = UrlHost, RequestUrlHost = UrlHost,
RequestUrlPrefix = UrlPrefix, RequestUrlPrefix = UrlPrefix,
Themes = Themes.Split(';'), Themes = Themes != null ? Themes.Split(';') : new string[] { },
Modules = Modules.Split(';') Modules = Modules != null ? Modules.Split(';') : new string[] { }
}); });
} }

View File

@@ -1,26 +1,30 @@
using System.Web.Mvc; using System;
using System.Linq;
using System.Web.Mvc;
using Orchard.Environment.Configuration; using Orchard.Environment.Configuration;
namespace Orchard.MultiTenancy.Extensions { namespace Orchard.MultiTenancy.Extensions {
public static class UrlHelperExtensions { public static class UrlHelperExtensions {
public static string Tenant(this UrlHelper urlHelper, ShellSettings tenantShellSettings) { public static string Tenant(this UrlHelper urlHelper, ShellSettings tenantShellSettings) {
var requestUrlHost = tenantShellSettings.RequestUrlHost.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).First();
//info: (heskew) might not keep the port/vdir insertion around beyond... //info: (heskew) might not keep the port/vdir insertion around beyond...
var port = string.Empty; var port = string.Empty;
string host = urlHelper.RequestContext.HttpContext.Request.Headers["Host"]; var host = urlHelper.RequestContext.HttpContext.Request.Headers["Host"];
if (host.Contains(":")) if (host.Contains(":"))
port = host.Substring(host.IndexOf(":")); port = host.Substring(host.IndexOf(":"));
var result = string.Format("{0}://{1}", var result = String.Format("{0}://{1}",
urlHelper.RequestContext.HttpContext.Request.Url.Scheme, urlHelper.RequestContext.HttpContext.Request.Url.Scheme,
!string.IsNullOrEmpty(tenantShellSettings.RequestUrlHost) !String.IsNullOrEmpty(requestUrlHost) ? requestUrlHost + port : host);
? tenantShellSettings.RequestUrlHost + port : host);
var applicationPath = urlHelper.RequestContext.HttpContext.Request.ApplicationPath; var applicationPath = urlHelper.RequestContext.HttpContext.Request.ApplicationPath;
if (!string.IsNullOrEmpty(applicationPath) && !string.Equals(applicationPath, "/")) if (!String.IsNullOrEmpty(applicationPath) && applicationPath != "/")
result += applicationPath; result += applicationPath;
if (!string.IsNullOrEmpty(tenantShellSettings.RequestUrlPrefix)) if (!String.IsNullOrEmpty(tenantShellSettings.RequestUrlPrefix))
result += "/" + tenantShellSettings.RequestUrlPrefix; result += "/" + tenantShellSettings.RequestUrlPrefix;
return result; return result;

View File

@@ -24,14 +24,15 @@ namespace Orchard.MultiTenancy.Services {
/// <summary> /// <summary>
/// Resets a tenant to its uninitialized state. /// Resets a tenant to its uninitialized state.
/// </summary> /// </summary>
/// <param name="tenantName">A ShellSettings object for the tenant to reset.</param> /// <param name="settings">A ShellSettings object to identify the tenant to reset.</param>
/// <param name="dropDatabaseTables">A boolean indicated whether tenant database tables should be dropped also.</param> /// <param name="dropDatabaseTables">A boolean indicated whether tenant database tables should be dropped also.</param>
void ResetTenant(ShellSettings settings, bool dropDatabaseTables); void ResetTenant(ShellSettings settings, bool dropDatabaseTables);
/// <summary> /// <summary>
/// Returns a list of all known database tables in a tenant. /// Returns a list of all known database tables in a tenant.
/// </summary> /// </summary>
/// <returns>A ShellSettings object for the tenant.</returns> /// <param name="settings">A ShellSettings object to identify the tenant.</param>
/// <returns>A list of known database table names for the tenant.</returns>
IEnumerable<string> GetTenantDatabaseTableNames(ShellSettings settings); IEnumerable<string> GetTenantDatabaseTableNames(ShellSettings settings);
/// <summary> /// <summary>

View File

@@ -16,9 +16,9 @@
<h2>@Model.Name</h2> <h2>@Model.Name</h2>
</div> </div>
<div> <div>
<label for="@Html.FieldIdFor(m => m.RequestUrlHost)">@T("Host")</label> <label for="@Html.FieldIdFor(m => m.RequestUrlHost)">@T("URL host")</label>
@Html.TextBoxFor(m => m.RequestUrlHost, new { @class = "text medium" }) @Html.TextBoxFor(m => m.RequestUrlHost, new { @class = "text medium" })
<span class="hint">@T("Example: If host is \"orchardproject.net\", the tenant site URL is \"http://orchardproject.net/\"")</span> <span class="hint">@T("Example: If host is \"orchardproject.net\", the tenant site URL is \"http://orchardproject.net/\". Multiple hosts can be separated by a comma.")</span>
</div> </div>
<div> <div>
<label for="@Html.FieldIdFor(m => m.RequestUrlPrefix)">@T("URL prefix")</label> <label for="@Html.FieldIdFor(m => m.RequestUrlPrefix)">@T("URL prefix")</label>