Merge branch '1.9.x' into dev

This commit is contained in:
Sebastien Ros
2015-06-18 14:20:08 -07:00
9 changed files with 46 additions and 11 deletions

View File

@@ -29,6 +29,7 @@ using Orchard.Tests.Environment.Extensions;
using Orchard.Tests.Environment.Features;
using Orchard.Tests.Stubs;
using IPackageManager = Orchard.Packaging.Services.IPackageManager;
using Orchard.Tests.Modules.Recipes.Services;
namespace Orchard.Tests.Modules.Recipes.RecipeHandlers {
[TestFixture]
@@ -66,6 +67,7 @@ namespace Orchard.Tests.Modules.Recipes.RecipeHandlers {
builder.RegisterType<ShellStateManager>().As<IShellStateManager>().SingleInstance();
builder.RegisterType<StubEventBus>().As<IEventBus>().SingleInstance();
builder.RegisterType<ModuleRecipeHandler>();
builder.RegisterType<StubRecipeJournal>().As<IRecipeJournal>();
builder.RegisterSource(new EventsRegistrationSource());
}

View File

@@ -24,11 +24,13 @@
<li data-shape-type="@placement.ShapeType" data-shape-differentiator="@placement.Differentiator" data-shape-zone="Content" data-shape-position="@placement.Position">
<div class="shape-type"><h3>@placement.ShapeType @placement.Differentiator</h3></div>
@try {
<div class="shape-editor">@Display(Model.AllPlacements[i].Shape)</div>
}
catch {
}
<div class="shape-editor">
@try {
@Display(Model.AllPlacements[i].Shape)
}
catch {
}
</div>
@* @shape.Position @(Model.PlacementSettings.Any(x => x.Equals(shape)))*@
@Html.HiddenFor(m => m.AllPlacements[i].PlacementSettings.ShapeType, new { @class = "type" })

View File

@@ -13,9 +13,11 @@ namespace Orchard.Recipes.RecipeHandlers {
public class CommandRecipeHandler : IRecipeHandler {
private readonly ICommandManager _commandManager;
private readonly CommandParser _commandParser;
private readonly IRecipeJournal _recipeJournal;
public CommandRecipeHandler (ICommandManager commandManager) {
public CommandRecipeHandler(ICommandManager commandManager, IRecipeJournal recipeJournal) {
_commandManager = commandManager;
_recipeJournal = recipeJournal;
_commandParser = new CommandParser();
Logger = NullLogger.Instance;
T = NullLocalizer.Instance;
@@ -44,6 +46,9 @@ namespace Orchard.Recipes.RecipeHandlers {
foreach (var command in commands) {
if (!String.IsNullOrEmpty(command)) {
if (!String.IsNullOrEmpty(recipeContext.ExecutionId)) {
_recipeJournal.WriteJournalEntry(recipeContext.ExecutionId, T("Commands: Executing item {0}.", command).Text);
}
var commandParameters = _commandParser.ParseCommandParameters(command);
var input = new StringReader("");
var output = new StringWriter();

View File

@@ -12,10 +12,12 @@ namespace Orchard.Recipes.RecipeHandlers {
public class DataRecipeHandler : IRecipeHandler {
private readonly IOrchardServices _orchardServices;
private readonly ITransactionManager _transactionManager;
private readonly IRecipeJournal _recipeJournal;
public DataRecipeHandler(IOrchardServices orchardServices, ITransactionManager transactionManager) {
public DataRecipeHandler(IOrchardServices orchardServices, ITransactionManager transactionManager, IRecipeJournal recipeJournal) {
_orchardServices = orchardServices;
_transactionManager = transactionManager;
_recipeJournal = recipeJournal;
Logger = NullLogger.Instance;
T = NullLocalizer.Instance;
}
@@ -53,6 +55,10 @@ namespace Orchard.Recipes.RecipeHandlers {
//so that dependencies can be managed within the same transaction
var nextIdentity = importContentSession.GetNextInBatch();
while (nextIdentity != null) {
if (!string.IsNullOrEmpty(recipeContext.ExecutionId) && elementDictionary[nextIdentity.ToString()].HasAttributes) {
var itemId = elementDictionary[nextIdentity.ToString()].FirstAttribute.Value;
_recipeJournal.WriteJournalEntry(recipeContext.ExecutionId, T("Data: Importing {0}.", itemId).Text);
}
_orchardServices.ContentManager.Import(
elementDictionary[nextIdentity.ToString()],
importContentSession);

View File

@@ -17,14 +17,17 @@ namespace Orchard.Recipes.RecipeHandlers {
private readonly IPackagingSourceManager _packagingSourceManager;
private readonly IPackageManager _packageManager;
private readonly IExtensionManager _extensionManager;
private readonly IRecipeJournal _recipeJournal;
public ModuleRecipeHandler(
IPackagingSourceManager packagingSourceManager,
IPackageManager packageManager,
IExtensionManager extensionManager) {
IExtensionManager extensionManager,
IRecipeJournal recipeJournal) {
_packagingSourceManager = packagingSourceManager;
_packageManager = packageManager;
_extensionManager = extensionManager;
_recipeJournal = recipeJournal;
Logger = NullLogger.Instance;
T = NullLocalizer.Instance;
@@ -87,6 +90,9 @@ namespace Orchard.Recipes.RecipeHandlers {
if (packagingEntry != null) {
if (!ModuleAlreadyInstalled(packagingEntry.PackageId)) {
if (!string.IsNullOrEmpty(recipeContext.ExecutionId)) {
_recipeJournal.WriteJournalEntry(recipeContext.ExecutionId, T("Installing module: {0}.", packagingEntry.Title).Text);
}
_packageManager.Install(packagingEntry.PackageId, packagingEntry.Version, packagingSource.FeedUrl, HostingEnvironment.MapPath("~/"));
}
installed = true;

View File

@@ -16,11 +16,13 @@ namespace Orchard.Recipes.RecipeHandlers {
private readonly ISiteService _siteService;
private readonly IContentManager _contentManager;
private readonly Lazy<IEnumerable<IContentHandler>> _handlers;
private readonly IRecipeJournal _recipeJournal;
public SettingsRecipeHandler(ISiteService siteService, IContentManager contentManager, Lazy<IEnumerable<IContentHandler>> handlers) {
public SettingsRecipeHandler(ISiteService siteService, IContentManager contentManager, Lazy<IEnumerable<IContentHandler>> handlers, IRecipeJournal recipeJournal) {
_siteService = siteService;
_contentManager = contentManager;
_handlers = handlers;
_recipeJournal = recipeJournal;
Logger = NullLogger.Instance;
T = NullLocalizer.Instance;
}
@@ -56,6 +58,10 @@ namespace Orchard.Recipes.RecipeHandlers {
continue;
}
if (!string.IsNullOrEmpty(recipeContext.ExecutionId)) {
_recipeJournal.WriteJournalEntry(recipeContext.ExecutionId, T("Setting: {0}.", contentPart.PartDefinition.Name).Text);
}
ImportSettingPart(contentPart, partElement);
}

View File

@@ -34,7 +34,7 @@ namespace Orchard.Recipes.Services {
return false;
}
_recipeJournal.WriteJournalEntry(executionId, string.Format("Executing step {0}.", nextRecipeStep.Name));
var recipeContext = new RecipeContext { RecipeStep = nextRecipeStep, Executed = false };
var recipeContext = new RecipeContext { RecipeStep = nextRecipeStep, Executed = false, ExecutionId = executionId };
try {
_recipeExecuteEventHandler.RecipeStepExecuting(executionId, recipeContext);
foreach (var recipeHandler in _recipeHandlers) {

View File

@@ -14,13 +14,16 @@ namespace Orchard.Roles.ImportExport {
private readonly IRoleService _roleService;
private readonly IRepository<RoleRecord> _roleRecordRepository;
private readonly IRepository<PermissionRecord> _permissionRepository;
private readonly IRecipeJournal _recipeJournal;
public RolesRecipeHandler(IRoleService roleService,
IRepository<RoleRecord> roleRecordRepository,
IRepository<PermissionRecord> permissionRepository) {
IRepository<PermissionRecord> permissionRepository,
IRecipeJournal recipeJournal) {
_roleService = roleService;
_roleRecordRepository = roleRecordRepository;
_permissionRepository = permissionRepository;
_recipeJournal = recipeJournal;
Logger = NullLogger.Instance;
T = NullLocalizer.Instance;
}
@@ -38,6 +41,10 @@ namespace Orchard.Roles.ImportExport {
foreach (var roleElement in recipeContext.RecipeStep.Step.Elements()) {
var roleName = roleElement.Attribute("Name").Value;
if (string.IsNullOrEmpty(recipeContext.ExecutionId)) {
_recipeJournal.WriteJournalEntry(recipeContext.ExecutionId, T("Roles: Executing item {0}.", roleName).Text);
}
var role = _roleService.GetRoleByName(roleName);
if (role == null) {
_roleService.CreateRole(roleName);

View File

@@ -2,5 +2,6 @@
public class RecipeContext {
public RecipeStep RecipeStep { get; set; }
public bool Executed { get; set; }
public string ExecutionId { get; set; }
}
}