1. Project Clover database Fri Apr 29 2016 13:24:33 CEST
  2. Package info.magnolia.module.blossom.setup

File BlossomVersionHandler.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart0.png
65% of files have more coverage

Code metrics

0
13
2
1
209
140
2
0.15
6.5
2
1

Classes

Class Line # Actions
BlossomVersionHandler 59 13 0% 2 15
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

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