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.blossom;
35  
36  import info.magnolia.cms.beans.config.ContentRepository;
37  import info.magnolia.module.AbstractModuleVersionHandler;
38  import info.magnolia.module.InstallContext;
39  import info.magnolia.module.admininterface.dialogs.ParagraphSelectDialog;
40  import info.magnolia.module.blossom.gui.BlossomParagraphEditDialog;
41  import info.magnolia.module.blossom.preexecution.BlossomFilter;
42  import info.magnolia.module.blossom.render.BlossomParagraphRenderer;
43  import info.magnolia.module.blossom.render.BlossomTemplateRenderer;
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.FilterOrderingTask;
48  import info.magnolia.module.delta.Task;
49  
50  import java.util.ArrayList;
51  import java.util.List;
52  
53  /**
54   * VersionHandler for upgrading and installing the module.
55   */
56  public class BlossomVersionHandler extends AbstractModuleVersionHandler {
57  
58      public BlossomVersionHandler() {
59          register(DeltaBuilder.update("1.1.1", "")
60                  .addTask(new FilterOrderingTask(
61                          "blossom",
62                          "Places the Blossom filter in chain.",
63                          new String[]{"context", "multipartRequest"}))
64                  .addTask(new BootstrapSingleResource(
65                          "VirtualURIMapping",
66                          "Bootstraps the Blossom VirtualURIMapping.",
67                          "/mgnl-bootstrap/blossom/config.modules.blossom.virtualURIMapping.xml"))
68          );
69          register(DeltaBuilder.update("1.0", "")
70                  .addTask(new BootstrapSingleResource(
71                  "Template renderer",
72                  "Bootstraps the Blossom template renderer.",
73                  "/mgnl-bootstrap/blossom/config.modules.blossom.template-renderers.xml"))
74          );
75          register(DeltaBuilder.update("1.1", "")
76                  .addTask(new CheckAndModifyPropertyValueTask(
77                          "Uninstall custom dialog for selecting paragraphs",
78                          "Changes to the default Magnolia select dialog",
79                          ContentRepository.CONFIG,
80                          "/modules/adminInterface/dialogs/selectParagraph",
81                          "class",
82                          "se.issi.magnolia.module.blossom.gui.BlossomParagraphSelectDialog",
83                          ParagraphSelectDialog.class.getName()))
84                  .addTask(new CheckAndModifyPropertyValueTask(
85                          "Update class name of custom dialog for editing paragraphs",
86                          "Changes the class name of BlossomParagraphEditDialog",
87                          ContentRepository.CONFIG,
88                          "/modules/adminInterface/dialogs/editParagraph",
89                          "class",
90                          "se.issi.magnolia.module.blossom.gui.BlossomParagraphEditDialog",
91                          BlossomParagraphEditDialog.class.getName()))
92                  .addTask(new CheckAndModifyPropertyValueTask(
93                          "Update class name for ParagraphRenderer",
94                          "Changes the class name of the ParagraphRenderer",
95                          ContentRepository.CONFIG,
96                          "/modules/blossom/paragraph-renderers/blossom",
97                          "class",
98                          "se.issi.magnolia.module.blossom.render.BlossomParagraphRenderer",
99                          BlossomParagraphRenderer.class.getName()))
100                 .addTask(new CheckAndModifyPropertyValueTask(
101                         "Update class name for TemplateRenderer",
102                         "Changes the class name of the TemplateRenderer",
103                         ContentRepository.CONFIG,
104                         "/modules/blossom/template-renderers/blossom",
105                         "renderer",
106                         "se.issi.magnolia.module.blossom.render.BlossomTemplateRenderer",
107                         BlossomTemplateRenderer.class.getName()))
108                 .addTask(new CheckAndModifyPropertyValueTask(
109                         "Update class name for BlossomFilter",
110                         "Changes the class name of the BlossomFilter",
111                         ContentRepository.CONFIG,
112                         "/server/filters/blossom",
113                         "class",
114                         "se.issi.magnolia.module.blossom.preexecution.BlossomFilter",
115                         BlossomFilter.class.getName()))
116         );
117     }
118 
119     @Override
120     protected List getBasicInstallTasks(InstallContext installContext) {
121         ArrayList<Task> tasks = new ArrayList<Task>();
122 
123         tasks.add(new BootstrapSingleResource(
124                 "New paragraph renderer",
125                 "Bootstraps the Blossom paragraph renderer.",
126                 "/mgnl-bootstrap/blossom/config.modules.blossom.paragraph-renderers.xml"));
127 
128         tasks.add(new BootstrapSingleResource(
129                 "New dialog",
130                 "Bootstraps the Blossom dialog.",
131                 "/mgnl-bootstrap/blossom/config.modules.blossom.dialogs.xml"));
132 
133         tasks.add(new BootstrapSingleResource(
134                 "New paragraph",
135                 "Bootstraps the Blossom paragraph.",
136                 "/mgnl-bootstrap/blossom/config.modules.blossom.paragraphs.xml"));
137 
138         tasks.add(new CheckAndModifyPropertyValueTask(
139                 "Custom dialog for editing paragraphs",
140                 "Changes the default Magnolia edit dialog",
141                 ContentRepository.CONFIG,
142                 "/modules/adminInterface/dialogs/editParagraph",
143                 "class",
144                 "info.magnolia.module.admininterface.dialogs.ParagraphEditDialog",
145                 BlossomParagraphEditDialog.class.getName()));
146 
147         tasks.add(new BootstrapSingleResource(
148                 "New filter",
149                 "Bootstraps the Blossom pre-execution filter.",
150                 "/mgnl-bootstrap/blossom/config.server.filters.blossom.xml"));
151 
152         tasks.add(new FilterOrderingTask(
153                 "blossom",
154                 "Places the Blossom filter in chain.",
155                 new String[]{"context", "multipartRequest"}));
156 
157         tasks.add(new BootstrapSingleResource(
158                 "Template renderer",
159                 "Bootstraps the Blossom template renderer.",
160                 "/mgnl-bootstrap/blossom/config.modules.blossom.template-renderers.xml"));
161 
162         tasks.add(new BootstrapSingleResource(
163                 "VirtualURIMapping",
164                 "Bootstraps the Blossom VirtualURIMapping.",
165                 "/mgnl-bootstrap/blossom/config.modules.blossom.virtualURIMapping.xml"));
166 
167         return tasks;
168     }
169 }