View Javadoc

1   /**
2    * This file Copyright (c) 2003-2011 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.blossom.setup;
35  
36  import java.util.ArrayList;
37  import java.util.List;
38  
39  import info.magnolia.module.AbstractModuleVersionHandler;
40  import info.magnolia.module.InstallContext;
41  import info.magnolia.module.admininterface.dialogs.ParagraphEditDialog;
42  import info.magnolia.module.admininterface.dialogs.ParagraphSelectDialog;
43  import info.magnolia.module.blossom.preexecution.BlossomFilter;
44  import info.magnolia.module.delta.BootstrapSingleResource;
45  import info.magnolia.module.delta.CheckAndModifyPropertyValueTask;
46  import info.magnolia.module.delta.DeltaBuilder;
47  import info.magnolia.module.delta.MoveNodeTask;
48  import info.magnolia.module.delta.OrderNodeBeforeTask;
49  import info.magnolia.module.delta.RemoveNodeTask;
50  import info.magnolia.module.delta.Task;
51  import info.magnolia.module.delta.WarnTask;
52  import info.magnolia.repository.RepositoryConstants;
53  
54  /**
55   * VersionHandler for upgrading and installing the module. Note that this VersionHandler does not inherit from
56   * DefaultModuleVersionHandler and has no default behaviour such as installing all bootstrap xml files. They need to
57   * be explicitly installed.
58   *
59   * @since 0.5
60   */
61  public class BlossomVersionHandler extends AbstractModuleVersionHandler {
62  
63      public BlossomVersionHandler() {
64  
65          // 2.0.1 adds a warning about the migration steps necessary
66          register(DeltaBuilder.update("2.0.1", "")
67                  .addTask(new WarnTask("Blossom templates", "Naming convention for Blossom templates changed between versions 1.x and 2.0. It is not possible to automatically convert between them using a migration script. You can write an update task to change the old names to the new ones. Have a look at http://wiki.magnolia-cms.com/display/WIKI/Migrating+content+when+upgrading+to+Blossom+2"))
68          );
69  
70          // 2.0 adds new renderer for Magnolia 4.5 rendering, removes the old renderers the placeholder paragraph and the blossom dialog
71          register(DeltaBuilder.update("2.0", "")
72                  .addTask(new BootstrapSingleResource(
73                          "New renderer",
74                          "Bootstraps the Blossom renderer.",
75                          "/mgnl-bootstrap/blossom/config.modules.blossom.renderers.blossom.xml"))
76                  .addTask(new OrderNodeBeforeTask(
77                          "Order Blossom filter",
78                          "",
79                          RepositoryConstants.CONFIG,
80                          "/server/filters/cms/blossom",
81                          "rendering"))
82                  .addTask(new RemoveNodeTask(
83                          "Remove obsolete template renderer",
84                          "",
85                          RepositoryConstants.CONFIG,
86                          "/modules/blossom/template-renderers"))
87                  .addTask(new RemoveNodeTask(
88                          "Remove obsolete paragraph renderer",
89                          "",
90                          RepositoryConstants.CONFIG,
91                          "/modules/blossom/paragraph-renderers"))
92                  .addTask(new RemoveNodeTask(
93                          "Remove paragraphs folder",
94                          "",
95                          RepositoryConstants.CONFIG,
96                          "/modules/blossom/paragraphs"))
97                  .addTask(new RemoveNodeTask(
98                          "Remove dialogs folder",
99                          "",
100                         RepositoryConstants.CONFIG,
101                         "/modules/blossom/dialogs"))
102 
103                         // Restores the edit dialog for paragraphs to the original value. In earlier versions Blossom customized this dialog
104                         // and the class name changed twice so we check if its any of the three variations used and change it back.
105                 .addTask(new MultiCheckAndModifyPropertyValueTask(
106                         "Uninstall custom dialog for editing paragraphs",
107                         "Changes to the default Magnolia dialog",
108                         "/modules/adminInterface/dialogs/editParagraph",
109                         "class",
110                         new String[]{
111                                 "se.issi.magnolia.module.blossom.gui.BlossomParagraphEditDialog",
112                                 "info.magnolia.module.blossom.gui.BlossomParagraphEditDialog",
113                                 "info.magnolia.module.blossom.paragraph.BlossomParagraphEditDialog"},
114                         ParagraphEditDialog.class.getName()
115                 ))
116         );
117 
118         // 1.2 Moves the blossom filter deeper in the chain and removes the custom ParagraphEditDialog
119         register(DeltaBuilder.update("1.2", "")
120                 .addTask(new MoveNodeTask(
121                         "Move the Blossom filter in chain",
122                         "",
123                         RepositoryConstants.CONFIG,
124                         "/server/filters/blossom",
125                         "/server/filters/cms/blossom",
126                         false))
127         );
128 
129         // 1.1.1 adds support for VirtualUriMappings and multipart
130         register(DeltaBuilder.update("1.1.1", "")
131                 .addTask(new BootstrapSingleResource(
132                         "VirtualURIMapping",
133                         "Bootstraps the Blossom VirtualURIMapping.",
134                         "/mgnl-bootstrap/blossom/config.modules.blossom.virtualURIMapping.xml"))
135         );
136 
137         // 1.1 changes package names to info.magnolia and removes the custom ParagraphSelectDialog
138         register(DeltaBuilder.update("1.1", "")
139                 .addTask(new CheckAndModifyPropertyValueTask(
140                         "Uninstall custom dialog for selecting paragraphs",
141                         "Changes to the default Magnolia select dialog",
142                         RepositoryConstants.CONFIG,
143                         "/modules/adminInterface/dialogs/selectParagraph",
144                         "class",
145                         "se.issi.magnolia.module.blossom.gui.BlossomParagraphSelectDialog",
146                         ParagraphSelectDialog.class.getName()))
147                 .addTask(new CheckAndModifyPropertyValueTask(
148                         "Update class name for BlossomFilter",
149                         "Changes the class name of the BlossomFilter",
150                         RepositoryConstants.CONFIG,
151                         "/server/filters/blossom",
152                         "class",
153                         "se.issi.magnolia.module.blossom.preexecution.BlossomFilter",
154                         BlossomFilter.class.getName()))
155         );
156     }
157 
158     @Override
159     protected List<Task> getBasicInstallTasks(InstallContext installContext) {
160         List<Task> tasks = new ArrayList<Task>();
161 
162         tasks.add(new BootstrapSingleResource(
163                 "New filter",
164                 "Bootstraps the Blossom pre-execution filter.",
165                 "/mgnl-bootstrap/blossom/config.server.filters.cms.blossom.xml"));
166         tasks.add(new OrderNodeBeforeTask(
167                 "Order Blossom filter",
168                 "",
169                 RepositoryConstants.CONFIG,
170                 "/server/filters/cms/blossom",
171                 "rendering"));
172         tasks.add(new BootstrapSingleResource(
173                 "New renderer",
174                 "Bootstraps the Blossom renderer.",
175                 "/mgnl-bootstrap/blossom/config.modules.blossom.renderers.blossom.xml"));
176         tasks.add(new BootstrapSingleResource(
177                 "VirtualURIMapping",
178                 "Bootstraps the Blossom VirtualURIMapping.",
179                 "/mgnl-bootstrap/blossom/config.modules.blossom.virtualURIMapping.xml"));
180 
181         return tasks;
182     }
183 
184 }