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 PagesModuleVersionHandler() {
75 super();
76
77 register(DeltaBuilder.update("5.0", "Configuration update for Magnolia 5.0")
78 .addTask(new IsModuleInstalledOrRegistered("", "", "adminInterface",
79 new BootstrapConditionally("Bootstrap activation commands", "Bootstraps the default activation and deletion commands which no longer reside under adminInterface.", "config.modules.pages.commands.xml")))
80 .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)));
81
82
83 register(DeltaBuilder.update("5.0.1", "")
84 .addTask(new NodeExistsDelegateTask("Remove dialog links Node", "Remove dialog definition in pages/dialogs/links", RepositoryConstants.CONFIG, "/modules/pages/dialogs/link",
85 new RemoveNodeTask("Remove dialog links Node", "Remove dialog definition in pages/dialogs/links", RepositoryConstants.CONFIG, "/modules/pages/dialogs/link")))
86 .addTask(new NodeExistsDelegateTask("Add title to CreatePage dialog", "", RepositoryConstants.CONFIG, "/modules/pages/dialogs/createPage/form",
87 new NewPropertyTask("Add title to CreatePage dialog", "", RepositoryConstants.CONFIG, "/modules/pages/dialogs/createPage/form", "label", "pages.dialog.add_page"))));
88
89 register(DeltaBuilder.update("5.0.2", "")
90
91 .addTask(new PartialBootstrapTask("Add new confirmation action definition", "", "/mgnl-bootstrap/pages/config.modules.pages.apps.pages.xml", "/pages/subApps/browser/actions/confirmDeletion"))
92
93 .addTask(new NodeExistsDelegateTask("Remove action availability from delete action", "", RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/browser/actions/delete/availability",
94 new RemoveNodeTask("", "", RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/browser/actions/delete/availability")))
95 .addTask(new PropertyExistsDelegateTask("Remove label for delete action", "", RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/browser/actions/delete", "label",
96 new RemovePropertyTask("", "", RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/browser/actions/delete", "label")))
97 .addTask(new PropertyExistsDelegateTask("Remove icon for delete action", "", RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/browser/actions/delete", "icon",
98 new RemovePropertyTask("", "", RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/browser/actions/delete", "icon")))
99
100
101 .addTask(new NodeExistsDelegateTask("Update actionbar configuration", "Rename action mapping to new confirmation action", RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/browser/actionbar",
102 new RenameNodesTask("Rename action bar items", "Rename delete to confirmDeletion", RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/browser/actionbar", "delete", "confirmDeletion", NodeTypes.ContentNode.NAME))));
103
104 register(DeltaBuilder.update("5.1", "")
105 .addTask(new NodeExistsDelegateTask("", "", RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/browser/actions/confirmDeletion",
106 new NewPropertyTask("", "", RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/browser/actions/confirmDeletion/availability", "multiple", true)))
107
108
109
110
111 .addTask(new NodeBuilderTask("Create showVersions action", "", ErrorHandling.logging, RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/browser/actions",
112 addNode("showVersions", NodeTypes.ContentNode.NAME).then(
113 addProperty("class", ShowVersionsActionDefinition.class.getName()),
114 addProperty("icon", "icon-show-versions"),
115 addNode("availability", NodeTypes.ContentNode.NAME).then(
116 addProperty("ruleClass", "info.magnolia.ui.api.availability.HasVersionsRule")
117 )
118 )
119 ))
120
121 .addTask(new NodeExistsDelegateTask("Bootstrap actionbar section group for versionActions", "", RepositoryConstants.CONFIG, "/pages/subApps/browser/actionbar/sections/pageActions/groups/versionActions", null,
122 new PartialBootstrapTask("", "", "/mgnl-bootstrap/pages/config.modules.pages.apps.pages.xml", "/pages/subApps/browser/actionbar/sections/pageActions/groups/versionActions")
123 ))
124
125
126 .addTask(new RemoveHardcodedI18nPropertiesFromSubappsTask("pages"))
127
128
129 .addTask(new NodeExistsDelegateTask("remove the activate command chain from pages app", "", RepositoryConstants.CONFIG, "/modules/pages/commands/website/activate",
130 new RemoveNodeTask("", "", RepositoryConstants.CONFIG, "/modules/pages/commands/website/activate")))
131 .addTask(new NodeExistsDelegateTask("remove the deactivate command chain from pages app", "", RepositoryConstants.CONFIG, "/modules/pages/commands/website/deactivate",
132 new RemoveNodeTask("", "", RepositoryConstants.CONFIG, "/modules/pages/commands/website/deactivate")))
133
134 .addTask(new PartialBootstrapTask("Bootstrap new activate commands to website catalog.", "", "/mgnl-bootstrap/pages/config.modules.pages.commands.xml", "/commands/website/activate"))
135 .addTask(new PartialBootstrapTask("Bootstrap new deactivate commands to website catalog.", "", "/mgnl-bootstrap/pages/config.modules.pages.commands.xml", "/commands/website/deactivate"))
136
137
138 .addTask(new NodeBuilderTask("Add availability rule to edit action", "", ErrorHandling.logging, RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/detail/actions/edit",
139 addNode("availability", NodeTypes.ContentNode.NAME).then(
140 addProperty("ruleClass", IsNotVersionedDetailLocationRule.class.getName())
141 )
142 ))
143 .addTask(new NodeBuilderTask("Add availability rule to activate action", "", ErrorHandling.logging, RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/detail/actions/activate",
144 addNode("availability", NodeTypes.ContentNode.NAME).then(
145 addProperty("ruleClass", IsNotVersionedDetailLocationRule.class.getName())
146 )
147 ))
148 .addTask(new NodeBuilderTask("Add availability rule to deactivate action", "", ErrorHandling.logging, RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/detail/actions/deactivate",
149 addNode("availability", NodeTypes.ContentNode.NAME).then(
150 addProperty("ruleClass", IsNotVersionedDetailLocationRule.class.getName())
151 )
152 ))
153
154 .addTask(new PartialBootstrapTask("Bootstrap move action in Pages app", "",
155 "/mgnl-bootstrap/pages/config.modules.pages.apps.pages.xml", "/pages/subApps/browser/actions/move"))
156 .addTask(new PartialBootstrapTask("Bootstrap move action to Pages app actionbar", "Adds action move to folder/editingActions section in actionbar.",
157 "/mgnl-bootstrap/pages/config.modules.pages.apps.pages.xml", "/pages/subApps/browser/actionbar/sections/pageActions/groups/editingActions/items/move"))
158 );
159
160 register(DeltaBuilder.update("5.1.1", "")
161 .addTask(new NodeExistsDelegateTask("Add root availability to import", "Add root availability to import action in Pages app", RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/browser/actions/import/availability",
162 new NewPropertyTask("Add root availability to import", "Add root availability to import action in Pages app", RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/browser/actions/import/availability", "root", true)))
163 );
164
165 register(DeltaBuilder.update("5.2.2", "")
166 .addTask(new RemoveHardcodedI18nPropertiesFromDialogsTask("pages"))
167 .addTask(new SetPropertyTask(RepositoryConstants.CONFIG, "/modules/pages/apps/pages", "class", ConfiguredContentAppDescriptor.class.getName()))
168 .addTask(new SetPropertyTask(RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/browser/actions/import/availability", "root", "true"))
169 .addTask(new PartialBootstrapTask("Bootstrap restore version action", "", "/mgnl-bootstrap/pages/config.modules.pages.apps.pages.xml", "/pages/subApps/browser/actions/restoreVersion"))
170 .addTask(new NodeExistsDelegateTask("Bootstrap restore version action to actionbar", "", RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/browser/actionbar/sections/pageActions/groups/versionActions/items",
171 new ArrayDelegateTask("",
172 new PartialBootstrapTask("", "", "/mgnl-bootstrap/pages/config.modules.pages.apps.pages.xml", "/pages/subApps/browser/actionbar/sections/pageActions/groups/versionActions/items/restoreVersion"),
173 new NodeExistsDelegateTask("", "", RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/browser/actionbar/sections/pageActions/groups/versionActions/items/showVersions",
174 new OrderNodeAfterTask("", "", RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/browser/actionbar/sections/pageActions/groups/versionActions/items/restoreVersion", "showVersions")))))
175 );
176
177 register(DeltaBuilder.update("5.2.3", "")
178 .addTask(new SetWritePermissionForActionsTask("/modules/pages/apps/pages/subApps/browser/actions",
179 new String[] { "add", "confirmDeletion", "edit", "editPageName", "editTemplate", "restorePreviousVersion", "import", "move", "restoreVersion" }))
180 .addTask(new SetWritePermissionForActionsTask("/modules/pages/apps/pages/subApps/detail/actions", new String[] { "edit" }))
181 );
182 register(DeltaBuilder.update("5.2.5", "")
183 .addTask(new IsModuleInstalledOrRegistered("Configure recursive activation and deletion as asynchronous", "scheduler", new ArrayDelegateTask("",
184 new NodeExistsDelegateTask("Configure recursive activation as asynchronous", "/modules/pages/apps/pages/subApps/browser/actions/activateRecursive",
185 new SetPropertyTask(RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/browser/actions/activateRecursive", "asynchronous", "true")),
186 new NodeExistsDelegateTask("Configure deletion as asynchronous", "/modules/pages/apps/pages/subApps/browser/actions/delete",
187 new SetPropertyTask(RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/browser/actions/delete", "asynchronous", "true"))
188 ))));
189 }
190
191 @Override
192 protected List<Task> getExtraInstallTasks(InstallContext installContext) {
193 List<Task> tasks = new ArrayList<Task>();
194 tasks.addAll(super.getExtraInstallTasks(installContext));
195 tasks.add(new IsModuleInstalledOrRegistered("Configure recursive activation and deletion as asynchronous", "scheduler", new ArrayDelegateTask("",
196 new NodeExistsDelegateTask("Configure recursive activation as asynchronous", "/modules/pages/apps/pages/subApps/browser/actions/activateRecursive",
197 new SetPropertyTask(RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/browser/actions/activateRecursive", "asynchronous", "true")),
198 new NodeExistsDelegateTask("Configure deletion as asynchronous", "/modules/pages/apps/pages/subApps/browser/actions/delete",
199 new SetPropertyTask(RepositoryConstants.CONFIG, "/modules/pages/apps/pages/subApps/browser/actions/delete", "asynchronous", "true"))
200 )));
201 return tasks;
202 }
203 }