1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package info.magnolia.pages.setup;
35
36 import static info.magnolia.nodebuilder.Ops.*;
37
38 import info.magnolia.i18nsystem.setup.RemoveHardcodedI18nPropertiesFromDialogsTask;
39 import info.magnolia.i18nsystem.setup.RemoveHardcodedI18nPropertiesFromSubappsTask;
40 import info.magnolia.jcr.util.NodeTypes;
41 import info.magnolia.module.DefaultModuleVersionHandler;
42 import info.magnolia.module.InstallContext;
43 import info.magnolia.module.delta.ArrayDelegateTask;
44 import info.magnolia.module.delta.BootstrapConditionally;
45 import info.magnolia.module.delta.DeltaBuilder;
46 import info.magnolia.module.delta.IsModuleInstalledOrRegistered;
47 import info.magnolia.module.delta.NewPropertyTask;
48 import info.magnolia.module.delta.NodeExistsDelegateTask;
49 import info.magnolia.module.delta.OrderNodeAfterTask;
50 import info.magnolia.module.delta.PartialBootstrapTask;
51 import info.magnolia.module.delta.PropertyExistsDelegateTask;
52 import info.magnolia.module.delta.RemoveNodeTask;
53 import info.magnolia.module.delta.RemovePropertyTask;
54 import info.magnolia.module.delta.RenameNodesTask;
55 import info.magnolia.module.delta.SetPropertyTask;
56 import info.magnolia.module.delta.Task;
57 import info.magnolia.nodebuilder.task.ErrorHandling;
58 import info.magnolia.nodebuilder.task.NodeBuilderTask;
59 import info.magnolia.repository.RepositoryConstants;
60 import info.magnolia.ui.admincentral.setup.ConvertAclToAppPermissionTask;
61 import info.magnolia.ui.contentapp.ConfiguredContentAppDescriptor;
62 import info.magnolia.ui.contentapp.availability.IsNotVersionedDetailLocationRule;
63 import info.magnolia.ui.contentapp.browser.action.ShowVersionsActionDefinition;
64 import info.magnolia.ui.framework.setup.SetWritePermissionForActionsTask;
65
66 import java.util.ArrayList;
67 import java.util.List;
68
69
70
71
72 public class PagesModuleVersionHandler extends DefaultModuleVersionHandler {
73
74 public static final String PAGES_APP_ACTIONS = "/modules/pages/apps/pages/subApps/browser/actions/";
75
76 public PagesModuleVersionHandler() {
77 super();
78
79 register(DeltaBuilder.update("5.0", "Configuration update for Magnolia 5.0")
80 .addTask(new IsModuleInstalledOrRegistered("", "", "adminInterface",
81 new BootstrapConditionally("Bootstrap activation commands", "Bootstraps the default activation and deletion commands which no longer reside under adminInterface.", "config.modules.pages.commands.xml")))
82 .addTask(new ConvertAclToAppPermissionTask("Convert permissions for Pages app", "Convert ACL permissions for old 'Website' menu to new 'pages-app' permission", "/modules/adminInterface/config/menu/website", "/modules/pages/apps/pages", true)));
83
84
85 register(DeltaBuilder.update("5.0.1", "")
86 .addTask(new NodeExistsDelegateTask("Remove dialog links Node", "Remove dialog definition in pages/dialogs/links", RepositoryConstants.CONFIG, "/modules/pages/dialogs/link",
87 new RemoveNodeTask("Remove dialog links Node", "Remove dialog definition in pages/dialogs/links", RepositoryConstants.CONFIG, "/modules/pages/dialogs/link")))
88 .addTask(new NodeExistsDelegateTask("Add title to CreatePage dialog", "", RepositoryConstants.CONFIG, "/modules/pages/dialogs/createPage/form",
89 new NewPropertyTask("Add title to CreatePage dialog", "", RepositoryConstants.CONFIG, "/modules/pages/dialogs/createPage/form", "label", "pages.dialog.add_page"))));
90
91 register(DeltaBuilder.update("5.0.2", "")
92
93 .addTask(new PartialBootstrapTask("Add new confirmation action definition", "", "/mgnl-bootstrap/pages/config.modules.pages.apps.pages.xml", "/pages/subApps/browser/actions/confirmDeletion"))
94
95 .addTask(new NodeExistsDelegateTask("Remove action availability from delete action", "", RepositoryConstants.CONFIG, PAGES_APP_ACTIONS + "delete/availability",
96 new RemoveNodeTask("", "", RepositoryConstants.CONFIG, PAGES_APP_ACTIONS + "delete/availability")))
97 .addTask(new PropertyExistsDelegateTask("Remove label for delete action", "", RepositoryConstants.CONFIG, PAGES_APP_ACTIONS + "delete", "label",
98 new RemovePropertyTask("", "", RepositoryConstants.CONFIG, PAGES_APP_ACTIONS + "delete", "label")))
99 .addTask(new PropertyExistsDelegateTask("Remove icon for delete action", "", RepositoryConstants.CONFIG, PAGES_APP_ACTIONS + "delete", "icon",
100 new RemovePropertyTask("", "", RepositoryConstants.CONFIG, PAGES_APP_ACTIONS + "delete", "icon")))
101
102
103 .addTask(new NodeExistsDelegateTask("Update actionbar configuration", "Rename action mapping to new confirmation action", RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/browser/actionbar",
104 new RenameNodesTask("Rename action bar items", "Rename delete to confirmDeletion", RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/browser/actionbar", "delete", "confirmDeletion", NodeTypes.ContentNode.NAME))));
105
106 register(DeltaBuilder.update("5.1", "")
107 .addTask(new NodeExistsDelegateTask("", "", RepositoryConstants.CONFIG, PAGES_APP_ACTIONS + "confirmDeletion",
108 new NewPropertyTask("", "", RepositoryConstants.CONFIG, PAGES_APP_ACTIONS + "confirmDeletion/availability", "multiple", true)))
109
110
111
112
113 .addTask(new NodeBuilderTask("Create showVersions action", "", ErrorHandling.logging, RepositoryConstants.CONFIG, PAGES_APP_ACTIONS,
114 addNode("showVersions", NodeTypes.ContentNode.NAME).then(
115 addProperty("class", ShowVersionsActionDefinition.class.getName()),
116 addProperty("icon", "icon-show-versions"),
117 addNode("availability", NodeTypes.ContentNode.NAME).then(
118 addProperty("ruleClass", "info.magnolia.ui.api.availability.HasVersionsRule")
119 )
120 )
121 ))
122
123 .addTask(new NodeExistsDelegateTask("Bootstrap actionbar section group for versionActions", "", RepositoryConstants.CONFIG, "/pages/subApps/browser/actionbar/sections/pageActions/groups/versionActions", null,
124 new PartialBootstrapTask("", "", "/mgnl-bootstrap/pages/config.modules.pages.apps.pages.xml", "/pages/subApps/browser/actionbar/sections/pageActions/groups/versionActions")
125 ))
126
127
128 .addTask(new RemoveHardcodedI18nPropertiesFromSubappsTask("pages"))
129
130
131 .addTask(new NodeExistsDelegateTask("remove the activate command chain from pages app", "", RepositoryConstants.CONFIG, "/modules/pages/commands/website/activate",
132 new RemoveNodeTask("", "", RepositoryConstants.CONFIG, "/modules/pages/commands/website/activate")))
133 .addTask(new NodeExistsDelegateTask("remove the deactivate command chain from pages app", "", RepositoryConstants.CONFIG, "/modules/pages/commands/website/deactivate",
134 new RemoveNodeTask("", "", RepositoryConstants.CONFIG, "/modules/pages/commands/website/deactivate")))
135
136 .addTask(new PartialBootstrapTask("Bootstrap new activate commands to website catalog.", "", "/mgnl-bootstrap/pages/config.modules.pages.commands.xml", "/commands/website/activate"))
137 .addTask(new PartialBootstrapTask("Bootstrap new deactivate commands to website catalog.", "", "/mgnl-bootstrap/pages/config.modules.pages.commands.xml", "/commands/website/deactivate"))
138
139
140 .addTask(new NodeBuilderTask("Add availability rule to edit action", "", ErrorHandling.logging, RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/detail/actions/edit",
141 addNode("availability", NodeTypes.ContentNode.NAME).then(
142 addProperty("ruleClass", IsNotVersionedDetailLocationRule.class.getName())
143 )
144 ))
145 .addTask(new NodeBuilderTask("Add availability rule to activate action", "", ErrorHandling.logging, RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/detail/actions/activate",
146 addNode("availability", NodeTypes.ContentNode.NAME).then(
147 addProperty("ruleClass", IsNotVersionedDetailLocationRule.class.getName())
148 )
149 ))
150 .addTask(new NodeBuilderTask("Add availability rule to deactivate action", "", ErrorHandling.logging, RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/detail/actions/deactivate",
151 addNode("availability", NodeTypes.ContentNode.NAME).then(
152 addProperty("ruleClass", IsNotVersionedDetailLocationRule.class.getName())
153 )
154 ))
155
156 .addTask(new PartialBootstrapTask("Bootstrap move action in Pages app", "",
157 "/mgnl-bootstrap/pages/config.modules.pages.apps.pages.xml", "/pages/subApps/browser/actions/move"))
158 .addTask(new PartialBootstrapTask("Bootstrap move action to Pages app actionbar", "Adds action move to folder/editingActions section in actionbar.",
159 "/mgnl-bootstrap/pages/config.modules.pages.apps.pages.xml", "/pages/subApps/browser/actionbar/sections/pageActions/groups/editingActions/items/move"))
160 );
161
162 register(DeltaBuilder.update("5.1.1", "")
163 .addTask(new NodeExistsDelegateTask("Add root availability to import", "Add root availability to import action in Pages app", RepositoryConstants.CONFIG, PAGES_APP_ACTIONS + "import/availability",
164 new NewPropertyTask("Add root availability to import", "Add root availability to import action in Pages app", RepositoryConstants.CONFIG,
165 PAGES_APP_ACTIONS + "import/availability", "root", true))));
166
167 register(DeltaBuilder.update("5.2.2", "")
168 .addTask(new RemoveHardcodedI18nPropertiesFromDialogsTask("pages"))
169 .addTask(new SetPropertyTask(RepositoryConstants.CONFIG, "/modules/pages/apps/pages", "class", ConfiguredContentAppDescriptor.class.getName()))
170 .addTask(new SetPropertyTask(RepositoryConstants.CONFIG, PAGES_APP_ACTIONS + "import/availability", "root", "true"))
171 .addTask(new PartialBootstrapTask("Bootstrap restore version action", "", "/mgnl-bootstrap/pages/config.modules.pages.apps.pages.xml", "pages/subApps/browser/actions/restoreVersion"))
172 .addTask(new NodeExistsDelegateTask("Bootstrap restore version action to actionbar", "", RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/browser/actionbar/sections/pageActions/groups/versionActions/items",
173 new ArrayDelegateTask("",
174 new PartialBootstrapTask("", "", "/mgnl-bootstrap/pages/config.modules.pages.apps.pages.xml", "/pages/subApps/browser/actionbar/sections/pageActions/groups/versionActions/items/restoreVersion"),
175 new NodeExistsDelegateTask("", "", RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/browser/actionbar/sections/pageActions/groups/versionActions/items/showVersions",
176 new OrderNodeAfterTask("", "", RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/browser/actionbar/sections/pageActions/groups/versionActions/items/restoreVersion", "showVersions")))))
177 );
178
179 register(DeltaBuilder.update("5.2.3", "")
180 .addTask(new SetWritePermissionForActionsTask(PAGES_APP_ACTIONS,
181 new String[] { "add", "confirmDeletion", "edit", "editPageName", "editTemplate", "restorePreviousVersion", "import", "move", "restoreVersion" }))
182 .addTask(new SetWritePermissionForActionsTask("/modules/pages/apps/pages/subApps/detail/actions", new String[] { "edit" }))
183 );
184 register(DeltaBuilder.update("5.2.5", "")
185 .addTask(new IsModuleInstalledOrRegistered("Configure recursive activation and deletion as asynchronous", "scheduler", new ArrayDelegateTask("",
186 new NodeExistsDelegateTask("Configure recursive activation as asynchronous", PAGES_APP_ACTIONS + "activateRecursive",
187 new SetPropertyTask(RepositoryConstants.CONFIG, PAGES_APP_ACTIONS + "activateRecursive", "asynchronous", "true")),
188 new NodeExistsDelegateTask("Configure deletion as asynchronous", PAGES_APP_ACTIONS + "delete",
189 new SetPropertyTask(RepositoryConstants.CONFIG, PAGES_APP_ACTIONS + "delete", "asynchronous", "true"))
190 ))));
191
192 register(DeltaBuilder.update("5.2.7", "")
193 .addTask(new SetWritePermissionForActionsTask(PAGES_APP_ACTIONS, new String [] { "activate", "activateRecursive", "deactivate", "activateDeletion" }))
194 );
195 }
196
197 @Override
198 protected List<Task> getExtraInstallTasks(InstallContext installContext) {
199 List<Task> tasks = new ArrayList<Task>();
200 tasks.addAll(super.getExtraInstallTasks(installContext));
201 tasks.add(new IsModuleInstalledOrRegistered("Configure recursive activation and deletion as asynchronous", "scheduler", new ArrayDelegateTask("",
202 new NodeExistsDelegateTask("Configure recursive activation as asynchronous", PAGES_APP_ACTIONS + "activateRecursive",
203 new SetPropertyTask(RepositoryConstants.CONFIG, PAGES_APP_ACTIONS + "activateRecursive", "asynchronous", "true")),
204 new NodeExistsDelegateTask("Configure deletion as asynchronous", PAGES_APP_ACTIONS + "delete",
205 new SetPropertyTask(RepositoryConstants.CONFIG, PAGES_APP_ACTIONS + "delete", "asynchronous", "true"))
206 )));
207 return tasks;
208 }
209 }