From 393f52129a72c9fb281b968ee2eceb2f2e3bcef3 Mon Sep 17 00:00:00 2001
From: Marvin Kerkhoff <marvin.kerkhoff@arvato-systems.ch>
Date: Mon, 10 Sep 2018 16:46:05 +0200
Subject: [PATCH] LIVECOPY-41

---
 .../PropagateMasterContentChangesAction.java  | 19 ++++++++++++-------
 ....actions.propagateMasterContentChanges.xml |  3 +++
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/magnolia-livecopy/src/main/java/info/magnolia/liveCopy/actions/PropagateMasterContentChangesAction.java b/magnolia-livecopy/src/main/java/info/magnolia/liveCopy/actions/PropagateMasterContentChangesAction.java
index b83e73b..67cb9dc 100644
--- a/magnolia-livecopy/src/main/java/info/magnolia/liveCopy/actions/PropagateMasterContentChangesAction.java
+++ b/magnolia-livecopy/src/main/java/info/magnolia/liveCopy/actions/PropagateMasterContentChangesAction.java
@@ -14,6 +14,8 @@
  */
 package info.magnolia.liveCopy.actions;
 
+import java.util.List;
+
 import javax.inject.Inject;
 import javax.inject.Named;
 import javax.jcr.Node;
@@ -23,12 +25,14 @@ import info.magnolia.event.EventBus;
 import info.magnolia.i18nsystem.SimpleTranslator;
 import info.magnolia.module.site.SiteManager;
 import info.magnolia.objectfactory.Components;
+import info.magnolia.ui.api.action.AbstractAction;
 import info.magnolia.ui.api.action.ActionExecutionException;
 import info.magnolia.ui.api.app.AppEventBus;
 import info.magnolia.ui.api.context.UiContext;
 import info.magnolia.ui.api.overlay.ConfirmationCallback;
 import info.magnolia.ui.framework.action.AbstractRepositoryAction;
 import info.magnolia.ui.vaadin.integration.jcr.JcrItemAdapter;
+import info.magnolia.ui.vaadin.integration.jcr.JcrItemUtil;
 import info.magnolia.ui.vaadin.overlay.MessageStyleTypeEnum;
 
 /**
@@ -36,22 +40,22 @@ import info.magnolia.ui.vaadin.overlay.MessageStyleTypeEnum;
  *
  * @author schulteja
  */
-public class PropagateMasterContentChangesAction extends AbstractRepositoryAction<PropagateMasterContentChangesActionDefinition> {
+public class PropagateMasterContentChangesAction extends AbstractAction<PropagateMasterContentChangesActionDefinition> {
 
 
 
 
     private final UiContext uiContext;
     private final SimpleTranslator i18n;
-    private final JcrItemAdapter itemAdapter;
+    private final List<JcrItemAdapter> source;
 
     @Inject
-    public PropagateMasterContentChangesAction(PropagateMasterContentChangesActionDefinition definition, JcrItemAdapter item, @Named(AppEventBus.NAME) EventBus eventBus,
+    public PropagateMasterContentChangesAction(PropagateMasterContentChangesActionDefinition definition, List<JcrItemAdapter> source, @Named(AppEventBus.NAME) EventBus eventBus,
             UiContext uiContext, SimpleTranslator i18n, SiteManager sitemaManager) {
-        super(definition, item, eventBus);
+        super(definition);
         this.uiContext = uiContext;
         this.i18n = i18n;
-        this.itemAdapter = item;
+        this.source = source;
     }
 
     @Override
@@ -64,7 +68,9 @@ public class PropagateMasterContentChangesAction extends AbstractRepositoryActio
                     @Override
                     public void onSuccess() {
                         try {
-                            onExecute(itemAdapter);
+                            for (JcrItemAdapter itemAdapter : source) {
+                            	onExecute(itemAdapter);
+                            }
                         } catch (RepositoryException e) {
                             throw new RuntimeException(e);
                         }
@@ -81,7 +87,6 @@ public class PropagateMasterContentChangesAction extends AbstractRepositoryActio
         return i18n.translate("propagateMasterContentChangesAction.actions.confirmationQuestion");
     }
 
-    @Override
     protected void onExecute(JcrItemAdapter item) throws RepositoryException {
         PropagateMasterContentChangesUtil propagateMasterContentChangesUtil = Components.getComponent(PropagateMasterContentChangesUtil.class);
         propagateMasterContentChangesUtil.performMasterContentPropagation((Node) item.getJcrItem());
diff --git a/magnolia-livecopy/src/main/resources/mgnl-bootstrap/livecopy/config.modules.pages.apps.pages.subApps.browser.actions.propagateMasterContentChanges.xml b/magnolia-livecopy/src/main/resources/mgnl-bootstrap/livecopy/config.modules.pages.apps.pages.subApps.browser.actions.propagateMasterContentChanges.xml
index eb311e9..7a65189 100644
--- a/magnolia-livecopy/src/main/resources/mgnl-bootstrap/livecopy/config.modules.pages.apps.pages.subApps.browser.actions.propagateMasterContentChanges.xml
+++ b/magnolia-livecopy/src/main/resources/mgnl-bootstrap/livecopy/config.modules.pages.apps.pages.subApps.browser.actions.propagateMasterContentChanges.xml
@@ -25,6 +25,9 @@
     <sv:property sv:name="writePermissionRequired" sv:type="Boolean">
       <sv:value>true</sv:value>
     </sv:property>
+    <sv:property sv:name="multiple" sv:type="Boolean">
+      <sv:value>true</sv:value>
+    </sv:property>
     <sv:node sv:name="rules">
       <sv:property sv:name="jcr:primaryType" sv:type="Name">
         <sv:value>mgnl:contentNode</sv:value>
-- 
2.17.1.windows.2

