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.repository.RepositoryConstants;
52  
53  /**
54   * VersionHandler for upgrading and installing the module. Note that this VersionHandler does not inherit from
55   * DefaultModuleVersionHandler and has no default behaviour such as installing all bootstrap xml files. They need to
56   * be explicitly installed.
57   *
58   * @since 0.5
59   */
60  public class BlossomVersionHandler extends AbstractModuleVersionHandler {
61  
62      public BlossomVersionHandler() {
63          register(DeltaBuilder.update("2.0", "")
64                  .addTask(new BootstrapSingleResource(
65                          "New renderer",
66                          "Bootstraps the Blossom renderer.",
67                          "/mgnl-bootstrap/blossom/config.modules.blossom.renderers.blossom.xml"))
68                  .addTask(new OrderNodeBeforeTask(
69                          "Order Blossom filter",
70                          "",
71                          RepositoryConstants.CONFIG,
72                          "/server/filters/cms/blossom",
73                          "rendering"))
74                  .addTask(new RemoveNodeTask(
75                          "Remove obsolete template renderer",
76                          "",
77                          RepositoryConstants.CONFIG,
78                          "/modules/blossom/template-renderers"))
79                  .addTask(new RemoveNodeTask(
80                          "Remove obsolete paragraph renderer",
81                          "",
82                          RepositoryConstants.CONFIG,
83                          "/modules/blossom/paragraph-renderers"))
84                  .addTask(new RemoveNodeTask(
85                          "Remove paragraphs folder",
86                          "",
87                          RepositoryConstants.CONFIG,
88                          "/modules/blossom/paragraphs"))
89                  .addTask(new RemoveNodeTask(
90                          "Remove dialogs folder",
91                          "",
92                          RepositoryConstants.CONFIG,
93                          "/modules/blossom/dialogs"))
94  
95                          // Restores the edit dialog for paragraphs to the original value. In earlier versions Blossom customized this dialog
96                          // and the class name changed twice so we check if its any of the three variations used and change it back.
97                  .addTask(new MultiCheckAndModifyPropertyValueTask(
98                          "Uninstall custom dialog for editing paragraphs",
99                          "Changes to the default Magnolia dialog",
100                         "/modules/adminInterface/dialogs/editParagraph",
101                         "class",
102                         new String[]{
103                                 "se.issi.magnolia.module.blossom.gui.BlossomParagraphEditDialog",
104                                 "info.magnolia.module.blossom.gui.BlossomParagraphEditDialog",
105                                 "info.magnolia.module.blossom.paragraph.BlossomParagraphEditDialog"},
106                         ParagraphEditDialog.class.getName()
107                 ))
108         );
109 
110         // 1.2 Moves the blossom filter deeper in the chain and removes the custom ParagraphEditDialog
111         register(DeltaBuilder.update("1.2", "")
112                 .addTask(new MoveNodeTask(
113                         "Move the Blossom filter in chain",
114                         "",
115                         RepositoryConstants.CONFIG,
116                         "/server/filters/blossom",
117                         "/server/filters/cms/blossom",
118                         false))
119         );
120 
121         // 1.1.1 adds support for VirtualUriMappings and multipart
122         register(DeltaBuilder.update("1.1.1", "")
123                 .addTask(new BootstrapSingleResource(
124                         "VirtualURIMapping",
125                         "Bootstraps the Blossom VirtualURIMapping.",
126                         "/mgnl-bootstrap/blossom/config.modules.blossom.virtualURIMapping.xml"))
127         );
128 
129         // 1.1 changes package names to info.magnolia and removes the custom ParagraphSelectDialog
130         register(DeltaBuilder.update("1.1", "")
131                 .addTask(new CheckAndModifyPropertyValueTask(
132                         "Uninstall custom dialog for selecting paragraphs",
133                         "Changes to the default Magnolia select dialog",
134                         RepositoryConstants.CONFIG,
135                         "/modules/adminInterface/dialogs/selectParagraph",
136                         "class",
137                         "se.issi.magnolia.module.blossom.gui.BlossomParagraphSelectDialog",
138                         ParagraphSelectDialog.class.getName()))
139                 .addTask(new CheckAndModifyPropertyValueTask(
140                         "Update class name for BlossomFilter",
141                         "Changes the class name of the BlossomFilter",
142                         RepositoryConstants.CONFIG,
143                         "/server/filters/blossom",
144                         "class",
145                         "se.issi.magnolia.module.blossom.preexecution.BlossomFilter",
146                         BlossomFilter.class.getName()))
147         );
148     }
149 
150     @Override
151     protected List<Task> getBasicInstallTasks(InstallContext installContext) {
152         List<Task> tasks = new ArrayList<Task>();
153 
154         tasks.add(new BootstrapSingleResource(
155                 "New filter",
156                 "Bootstraps the Blossom pre-execution filter.",
157                 "/mgnl-bootstrap/blossom/config.server.filters.cms.blossom.xml"));
158         tasks.add(new OrderNodeBeforeTask(
159                 "Order Blossom filter",
160                 "",
161                 RepositoryConstants.CONFIG,
162                 "/server/filters/cms/blossom",
163                 "rendering"));
164         tasks.add(new BootstrapSingleResource(
165                 "New renderer",
166                 "Bootstraps the Blossom renderer.",
167                 "/mgnl-bootstrap/blossom/config.modules.blossom.renderers.blossom.xml"));
168         tasks.add(new BootstrapSingleResource(
169                 "VirtualURIMapping",
170                 "Bootstraps the Blossom VirtualURIMapping.",
171                 "/mgnl-bootstrap/blossom/config.modules.blossom.virtualURIMapping.xml"));
172 
173         return tasks;
174     }
175 
176 }