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.fckeditor;
35  
36  import info.magnolia.cms.core.ItemType;
37  import info.magnolia.module.DefaultModuleVersionHandler;
38  import info.magnolia.module.InstallContext;
39  import info.magnolia.module.delta.ArrayDelegateTask;
40  import info.magnolia.module.delta.BootstrapSingleResource;
41  import info.magnolia.module.delta.CheckAndModifyPropertyValueTask;
42  import info.magnolia.module.delta.CreateNodeTask;
43  import info.magnolia.module.delta.DeltaBuilder;
44  import info.magnolia.module.delta.MoveNodeTask;
45  import info.magnolia.module.delta.NodeExistsDelegateTask;
46  import info.magnolia.module.delta.RegisterModuleServletsTask;
47  import info.magnolia.module.fckeditor.dialogs.FckEditorDialog;
48  import info.magnolia.module.fckeditor.servlets.FCKEditorSimpleUploadServlet;
49  
50  import java.util.ArrayList;
51  import java.util.List;
52  
53  /**
54   * @author vsteller
55   */
56  public class FCKEditorModuleVersionHandler extends DefaultModuleVersionHandler {
57  
58      public FCKEditorModuleVersionHandler() {
59          register(DeltaBuilder.update("4.0", "")
60                  .addTask(new CheckAndModifyPropertyValueTask("Dialog", "Replaces the deprecated dialog class by a new one.", "config",
61                          "/modules/fckEditor/controls/fckEdit", "class", "info.magnolia.cms.gui.dialog.DialogFckEdit", FckEditorDialog.class.getName()))
62                  .addTask(new CheckAndModifyPropertyValueTask("Servlet", "Replaces the deprecated servlet class by a new one.", "config",
63                  "/server/filters/servlets/FCKEditorSimpleUploadServlet", "servletClass", "info.magnolia.cms.gui.fckeditor.FCKEditorSimpleUploadServlet", FCKEditorSimpleUploadServlet.class.getName()))
64          );
65      }
66  
67      protected List getBasicInstallTasks(InstallContext installContext) {
68          final List basicInstallTasks = new ArrayList();
69          basicInstallTasks.add(new BootstrapSingleResource("New FCKEditor browser", "Bootstraps the new configuration for the browser page", "/mgnl-bootstrap/fckEditor/config.modules.fckEditor.pages.repositoryBrowser.xml"));
70          basicInstallTasks.add(new BootstrapSingleResource("Browsable repositories", "Bootstraps the default configuration for the browsable repositories", "/mgnl-bootstrap/fckEditor/config.modules.fckEditor.config.browsableRepositories.xml"));
71          basicInstallTasks.add(new NodeExistsDelegateTask("Check for existing fckEdit control", "Check if fckEdit control is registered in adminInterface module", "config", "/modules/adminInterface/controls/fckEdit",
72                  new ArrayDelegateTask("Add fckEdit control",
73                          new CreateNodeTask("Create controls node", "Add the controls node in the FCKEditor module", "config", "/modules/fckEditor", "controls", ItemType.CONTENT.getSystemName()),
74                          new MoveNodeTask("Move fckEdit control", "Move fckEdit control to FCKEditor module since it is a separate module now", "config", "/modules/adminInterface/controls/fckEdit", "/modules/fckEditor/controls/fckEdit", true)
75                  ),
76                  new BootstrapSingleResource("Add fckEdit control", "Bootstraps the configuration of the fckEdit control", "/mgnl-bootstrap/fckEditor/config.modules.fckEditor.controls.fckEdit.xml")));
77          basicInstallTasks.add(new RegisterModuleServletsTask());
78          return basicInstallTasks;
79      }
80  }