View Javadoc

1   /**
2    * This file Copyright (c) 2003-2010 Magnolia International
3    * Ltd.  (http://www.magnolia-cms.com). All rights reserved.
4    *
5    *
6    * This file is dual-licensed under both the Magnolia
7    * Network Agreement and the GNU General Public License.
8    * You may elect to use one or the other of these licenses.
9    *
10   * This file is distributed in the hope that it will be
11   * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
12   * implied warranty of MERCHANTABILITY or FITNESS FOR A
13   * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
14   * Redistribution, except as permitted by whichever of the GPL
15   * or MNA you select, is prohibited.
16   *
17   * 1. For the GPL license (GPL), you can redistribute and/or
18   * modify this file under the terms of the GNU General
19   * Public License, Version 3, as published by the Free Software
20   * Foundation.  You should have received a copy of the GNU
21   * General Public License, Version 3 along with this program;
22   * if not, write to the Free Software Foundation, Inc., 51
23   * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24   *
25   * 2. For the Magnolia Network Agreement (MNA), this file
26   * and the accompanying materials are made available under the
27   * terms of the MNA which accompanies this distribution, and
28   * is available at http://www.magnolia-cms.com/mna.html
29   *
30   * Any modifications to this file must keep this entire header
31   * intact.
32   *
33   */
34  package info.magnolia.module.admininterface.setup;
35  
36  import info.magnolia.cms.beans.config.ContentRepository;
37  import info.magnolia.module.DefaultModuleVersionHandler;
38  import info.magnolia.module.InstallContext;
39  import info.magnolia.module.admininterface.setup.for4_0.UpdatedDefaultPublicURIWarning;
40  import info.magnolia.module.admininterface.setup.for4_3.ReplaceWrongDialogNodeTypeTask;
41  import info.magnolia.module.admininterface.setup.for4_4.ContentDeletionTasks;
42  import info.magnolia.module.admininterface.setup.for4_4.RegisterMgnlDeletedType;
43  import info.magnolia.module.admininterface.trees.WebsiteTreeHandler;
44  import info.magnolia.module.delta.ArrayDelegateTask;
45  import info.magnolia.module.delta.BootstrapConditionally;
46  import info.magnolia.module.delta.BootstrapSingleModuleResource;
47  import info.magnolia.module.delta.BootstrapSingleResource;
48  import info.magnolia.module.delta.CheckAndModifyPropertyValueTask;
49  import info.magnolia.module.delta.ChildrenExistsDelegateTask;
50  import info.magnolia.module.delta.DeltaBuilder;
51  import info.magnolia.module.delta.MoveNodeTask;
52  import info.magnolia.module.delta.NodeExistsDelegateTask;
53  import info.magnolia.module.delta.PropertyValueDelegateTask;
54  import info.magnolia.module.delta.RegisterModuleServletsTask;
55  import info.magnolia.module.delta.RemoveNodeTask;
56  import info.magnolia.module.delta.RemovePropertyTask;
57  import info.magnolia.module.delta.SetPropertyTask;
58  import info.magnolia.module.delta.Task;
59  
60  import java.util.ArrayList;
61  import java.util.List;
62  
63  /**
64   * @author philipp
65   * @version $Id: AdminModuleVersionHandler.java 38709 2010-11-02 17:40:05Z had $
66   */
67  public class AdminModuleVersionHandler extends DefaultModuleVersionHandler {
68      private final AddSubMenuItemTask sysUsersSubMenu = new AddSubMenuItemTask("security", "usersSystem", "menu.security.usersSystem", null, "MgnlAdminCentral.showTree('usersSystem')", "/.resources/icons/16/pawn_glass_red.gif", "groups");
69      private final AddSubMenuItemTask adminUsersSubMenu = new AddSubMenuItemTask("security", "usersAdmin", "menu.security.usersAdmin", null, "MgnlAdminCentral.showTree('usersAdmin')", "/.resources/icons/16/pawn_glass_yellow.gif", "groups");
70      private final AddSubMenuItemTask subscribersMenu = new AddSubMenuItemTask("config", "subscribers", "menu.config.subscribers", "info.magnolia.module.admininterface.messages", "MgnlAdminCentral.showTree('config','/server/activation/subscribers')", "/.resources/icons/16/dot.gif", "cache");
71  
72      public AdminModuleVersionHandler() {
73          final String pathToRestartPage = "/modules/adminInterface/pages/restart";
74          register(DeltaBuilder.update("3.5", "")
75                  // sets a default virtual uri mapping - only if node doesn't exist. This is also bootstrapped on installs, but overridden by SetDefaultPublicURI on public instances.
76                  .addTask(new BootstrapConditionally("Install VirtualURI mappings", "Installs new configuration of virtualURI mappings.", "/mgnl-bootstrap/adminInterface/config.modules.adminInterface.virtualURIMapping.default.xml"))
77  
78                  .addTask(new BootstrapSingleResource("New ACL configuration", "Bootstraps the new configuration for the ACL dialogs.", "/mgnl-bootstrap/adminInterface/config.modules.adminInterface.config.securityConfiguration.xml"))
79                  .addTask(new RemoveNodeTask("New ACL Dialog", "Deletes the old ACL page.", ContentRepository.CONFIG, "/modules/adminInterface/pages/rolesACL"))
80                  .addTask(new RemovePropertyTask("New ACL Dialog", "Removes the include property.", ContentRepository.CONFIG, "/modules/adminInterface/dialogs/roleedit", "file"))
81                  .addTask(new CheckAndModifyPropertyValueTask("New ACL Dialog", "Changes the control type for the ACL.", ContentRepository.CONFIG, "/modules/adminInterface/dialogs/roleedit/tabACL/aCL", "controlType", "include", "info.magnolia.module.admininterface.dialogs.ACLSDialogControl"))
82                  .addTask(new ArrayDelegateTask("Users menu", "System and admin users are now differentiated, creating two sub menus.", new Task[]{
83                          new RemoveNodeTask(null, null, ContentRepository.CONFIG, "/modules/adminInterface/config/menu/security/users"),
84                          adminUsersSubMenu,
85                          sysUsersSubMenu}))
86                          .addTask(new ArrayDelegateTask("Menu", "Updates subscriber menu item in config menu", new Task[]{
87                                  new RemoveNodeTask(null, null, ContentRepository.CONFIG, "/modules/adminInterface/config/menu/config/subscriber"),
88                                  subscribersMenu}))
89                                  .addTask(new NodeExistsDelegateTask("Remove Kupu richEdit control", "Checks for previous Kupu editor installation and removes richEdit control if existent.", ContentRepository.CONFIG, "/modules/adminInterface/controls/richEdit",
90                                          new RemoveNodeTask("Remove Kupu richEdit control", "Removes the richEdit control from Admin Interface since the Kupu Module is not delivered anymore.", ContentRepository.CONFIG, "/modules/adminInterface/controls/richEdit")))
91                                          .addTask(new PropertyValueDelegateTask("Unused page", "Removes the now unused \"restart\" page.", ContentRepository.CONFIG, pathToRestartPage, "class", "info.magnolia.module.admininterface.pages.RestartPage", false,
92                                                  new RemoveNodeTask(null, null, ContentRepository.CONFIG, pathToRestartPage)))
93                                                  .addTask(new RegisterModuleServletsTask())
94          );
95  
96          register(DeltaBuilder.update("3.5.9", "")
97                  .addTask(new RemoveNodeTask("Remove Secured URIs menu item", "Removes deprecated menu iten, since secured URIs are now handled through the anonymous user's permissions.", ContentRepository.CONFIG, "/modules/adminInterface/config/menu/config/secureURIs"))
98          );
99  
100         register(DeltaBuilder.update("3.6", "")
101                 .addTask(new SetPropertyTask(ContentRepository.CONFIG, "/modules/adminInterface/trees/website", "class", WebsiteTreeHandler.class.getName()))
102                 .addTask(new BootstrapSingleResource("JavaScript messages", "Adds dynamic virtual url.", "/mgnl-bootstrap/adminInterface/config.modules.adminInterface.virtualURIMapping.messages.xml"))
103                 .addTask(new BootstrapSingleResource("JavaScript messages", "Adds page to provide i18n messages in JavaScript.", "/mgnl-bootstrap/adminInterface/config.modules.adminInterface.pages.messages.xml"))
104         );
105 
106         register(DeltaBuilder.update("3.6.4", "")
107                 .addTask(new ArrayDelegateTask("Update groups tree",new MoveNodeTask("Update groups tree", "Updates incorrectly named usergroup tree",ContentRepository.CONFIG, "/modules/adminInterface/trees/groups", "/modules/adminInterface/trees/usergroups", false),
108                         new CheckAndModifyPropertyValueTask("Update Group tree reference", "Updates reference to new usergroups tree name.", ContentRepository.CONFIG, "/modules/adminInterface/config/menu/security/groups", "onclick", "MgnlAdminCentral.showTree('groups')", "MgnlAdminCentral.showTree('usergroups')"),
109                         new CheckAndModifyPropertyValueTask("Update User dialog", "Updates reference to new usergroups tree name.", ContentRepository.CONFIG, "/modules/adminInterface/dialogs/useredit/tabUser/groups", "chooseOnclick", "mgnlOpenTreeBrowserWithControl($('${prefix}'), 'groups');", "mgnlOpenTreeBrowserWithControl($('${prefix}'), 'usergroups');"),
110                         new CheckAndModifyPropertyValueTask("Update Group dialog", "Updates reference to new usergroups tree name.", ContentRepository.CONFIG, "/modules/adminInterface/dialogs/groupedit/tabGroup/groups", "chooseOnclick", "mgnlOpenTreeBrowserWithControl($('${prefix}'), 'groups');", "mgnlOpenTreeBrowserWithControl($('${prefix}'), 'usergroups');")))
111         );
112 
113         final String pathToDeploymentUtilsPage = "/modules/adminInterface/pages/deploymentUtils";
114         register(DeltaBuilder.update("4.0", "")
115                 .addTask(new PropertyValueDelegateTask("Unused page", "Removes the now unused \"deployment\" page.", ContentRepository.CONFIG,
116                         // if still using the original class, we can go and ahead and delete:
117                         pathToDeploymentUtilsPage, "class", "info.magnolia.module.admininterface.pages.DeploymentUtilsPage", false,
118                         new ArrayDelegateTask(null,
119                                 new RemoveNodeTask(null, null, ContentRepository.CONFIG, pathToDeploymentUtilsPage),
120                                 new RemoveNodeTask(null, null, ContentRepository.CONFIG, "/modules/adminInterface/config/menu/tools/deployment"))))
121 
122                                 .addTask(new BootstrapSingleResource("Paragraph edit dialog", "The paragraph edition dialog is now a regular dialog.", "/mgnl-bootstrap/adminInterface/config.modules.adminInterface.dialogs.editParagraph.xml"))
123                                 .addTask(new BootstrapSingleResource("Quickstart page", "Registers the page to be displayed as default in case there are no templates defined yet.", "/mgnl-bootstrap/adminInterface/config.modules.adminInterface.pages.quickstart.xml"))
124                                 .addTask(new BootstrapSingleResource("User preferences dialog", "The user preferences dialog is not the user edit dialog anymore.", "/mgnl-bootstrap/adminInterface/config.modules.adminInterface.dialogs.userpreferences.xml"))
125         );
126 
127         register(DeltaBuilder.update("4.1.1", "")
128                 // defaultPublicURI was updated in 4.0, and it shoudn't have.
129                 // This warns that defaultPublicURI was changed on 4.0, needs to be fixed for 4.0.3 and 4.1.1
130                 // This task is registered on the 4.0.3 version in the 4.0 branch.
131                 .addTask(new UpdatedDefaultPublicURIWarning())
132         );
133 
134         register(DeltaBuilder.update("4.3", "")
135                 .addTask(new BootstrapSingleModuleResource("New i18n authoring support", "Adds i18n authoring configuration to /server/i18n.", "config.server.i18n.authoring.xml"))
136                 .addTask(new ReplaceWrongDialogNodeTypeTask())
137                 .addTask(new BootstrapSingleModuleResource("Folders in users tree", "Adds a new tree configuration with the correct root path.", "config.modules.adminInterface.trees.usersAdmin.xml"))
138                 .addTask(new BootstrapSingleModuleResource("Folders in users tree", "Adds a new tree configuration with the correct root path.", "config.modules.adminInterface.trees.usersSystem.xml"))
139                 // use the new trees
140                 .addTask(new CheckAndModifyPropertyValueTask("Folders in users tree","Change JavaScript of the system users menu point.", "config", "/modules/adminInterface/config/menu/security/usersSystem", "onclick", "MgnlAdminCentral.showTree('users', '/system', true)", "MgnlAdminCentral.showTree('usersSystem')"))
141                 .addTask(new CheckAndModifyPropertyValueTask("Folders in users tree","Change JavaScript of the users menu point.","config", "/modules/adminInterface/config/menu/security/usersAdmin", "onclick", "MgnlAdminCentral.showTree('users', '/admin', true)", "MgnlAdminCentral.showTree('usersAdmin')"))
142                 .addTask(new PropertyValueDelegateTask("Security", "Updates users tree configuration.", ContentRepository.CONFIG, "/modules/adminInterface/trees/users", "class", "info.magnolia.module.admininterface.AdminTreeMVCHandler", true, null, new CheckAndModifyPropertyValueTask("Security", "Updates users tree configuration.", ContentRepository.CONFIG, "/modules/adminInterface/trees/users", "class", "info.magnolia.module.admininterface.AdminTreeMVCHandler", "info.magnolia.module.admininterface.trees.UsersTreeHandler")))
143         );
144         register(DeltaBuilder.update("4.3.2", "")
145                 .addTask(new PropertyValueDelegateTask("Security", "Updates users tree configuration.", ContentRepository.CONFIG, "/modules/adminInterface/trees/usersAdmin", "class", "info.magnolia.module.admininterface.AdminTreeMVCHandler", true, null, new CheckAndModifyPropertyValueTask("", "", ContentRepository.CONFIG, "/modules/adminInterface/trees/usersAdmin", "class", "info.magnolia.module.admininterface.AdminTreeMVCHandler", "info.magnolia.module.admininterface.trees.UsersTreeHandler")))
146                 .addTask(new PropertyValueDelegateTask("Security", "Updates users tree configuration.", ContentRepository.CONFIG, "/modules/adminInterface/trees/usersSystem", "class", "info.magnolia.module.admininterface.AdminTreeMVCHandler", true, null, new CheckAndModifyPropertyValueTask("", "", ContentRepository.CONFIG, "/modules/adminInterface/trees/usersSystem", "class", "info.magnolia.module.admininterface.AdminTreeMVCHandler", "info.magnolia.module.admininterface.trees.UsersTreeHandler")))
147         );
148 
149         register(DeltaBuilder.update("4.3.3", "")
150                 .addTask(new NodeExistsDelegateTask("Intercept","Checks if intercept node exists", ContentRepository.CONFIG, "/modules/adminInterface/filters/intercept", new RemoveNodeTask("Remove intercept", "Removes unneeded intercept node", ContentRepository.CONFIG, "/modules/adminInterface/filters/intercept")))
151                 .addTask(new NodeExistsDelegateTask("Filters","Checks if filters node exists", ContentRepository.CONFIG, "/modules/adminInterface/filters", new ChildrenExistsDelegateTask("Filters","Checks if filters node has children", ContentRepository.CONFIG, "/modules/adminInterface/filters", null, null, new RemoveNodeTask("Removes filters","Remove unneeded filters node", ContentRepository.CONFIG, "/modules/adminInterface/filters"))))
152         );
153         register(DeltaBuilder.update("4.4","")
154                 .addTask(new BootstrapSingleResource("Messages bundles for js", "Bundles here will be used to generate i18n messages available in javascript.", "/mgnl-bootstrap/adminInterface/config.modules.adminInterface.pages.messages.bundles.xml"))
155                 .addTask(new ContentDeletionTasks()));
156     }
157 
158     protected List<Task> getExtraInstallTasks(InstallContext installContext) {
159         final List<Task> tasks = new ArrayList<Task>();
160         tasks.add(new AddMainMenuItemTask("security", "menu.security", "info.magnolia.modules.admininterface.messages", "", "/.resources/icons/24/key1.gif", "config"));
161         tasks.add(new AddSubMenuItemTask("security", "groups", "menu.groups", "MgnlAdminCentral.showTree('usergroups')", "/.resources/icons/16/group.gif"));
162         tasks.add(new AddSubMenuItemTask("security", "roles", "menu.roles", "MgnlAdminCentral.showTree('userroles')", "/.resources/icons/16/hat_white.gif"));
163         tasks.add(adminUsersSubMenu);
164         tasks.add(sysUsersSubMenu);
165         tasks.add(subscribersMenu);
166 
167         //set public uri only on installation
168         tasks.add(new SetDefaultPublicURI("defaultPublicURI"));
169 
170         return tasks;
171     }
172 
173     @Override
174     protected List<Task> getBasicInstallTasks(InstallContext installContext) {
175         List<Task> tasks = new ArrayList<Task>();
176         tasks.add(new RegisterMgnlDeletedType());
177         tasks.addAll(super.getBasicInstallTasks(installContext));
178         return tasks;
179     }
180 }