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.templating.setup;
35  
36  import info.magnolia.cms.beans.config.ContentRepository;
37  import info.magnolia.cms.core.ItemType;
38  import info.magnolia.module.DefaultModuleVersionHandler;
39  import info.magnolia.module.InstallContext;
40  import info.magnolia.module.delta.BootstrapSingleModuleResource;
41  import info.magnolia.module.delta.BootstrapSingleResource;
42  import info.magnolia.module.delta.BootstrapSingleResourceAndOrderBefore;
43  import info.magnolia.module.delta.CheckAndModifyPropertyValueTask;
44  import info.magnolia.module.delta.DeltaBuilder;
45  import info.magnolia.module.delta.OrderNodeBeforeTask;
46  import info.magnolia.module.delta.Task;
47  import info.magnolia.module.templating.setup.for3_5.IntroduceParagraphRenderers;
48  import info.magnolia.module.templating.setup.for4_0.DeprecateDialogPathAllModules;
49  import info.magnolia.module.templating.setup.for4_0.FixTemplatePathTask;
50  import info.magnolia.module.templating.setup.for4_0.RenamePropertyAllModulesNodeTask;
51  import info.magnolia.module.templating.setup.for4_0.NestPropertiesAllModulesNodeTask;
52  
53  import java.util.ArrayList;
54  import java.util.Arrays;
55  import java.util.List;
56  
57  
58  /**
59   * @author gjoseph
60   * @version $Revision: $ ($Author: $)
61   */
62  public class TemplatingModuleVersionHandler extends DefaultModuleVersionHandler {
63  
64      private OrderNodeBeforeTask orderBackwardCompatibilityFilter = new OrderNodeBeforeTask("Move backward compatiblity filter", "", ContentRepository.CONFIG, "/server/filters/cms/backwardCompatibility", "rendering");
65  
66      public TemplatingModuleVersionHandler() {
67          register(DeltaBuilder.update("3.5", "")
68                  .addTask(new IntroduceParagraphRenderers())
69                  .addTask(new BootstrapSingleResourceAndOrderBefore(
70                  "Compatibility Filter",
71                  "${actpage} is deprecated. Adds a compatibility filter still supporting it but writing warn messages to the log.",
72                  "/mgnl-bootstrap/templating/config.server.filters.cms.backwardCompatibility.xml",
73                  "rendering"))
74          );
75  
76          // move the filter in case it is in the wrong place
77          // this happened in case of a fresh install of former version
78          register(DeltaBuilder.update("3.5.4", "")
79                  .addTask(orderBackwardCompatibilityFilter)
80          );
81  
82          register(DeltaBuilder.update("4.0", "")
83                  .addTask(new BootstrapSingleResource("Freemarker Template Renderer", "Adds Freemarker template renderer configuration.", "/mgnl-bootstrap/templating/config.modules.templating.template-renderers.freemarker.xml"))
84                  .addTask(new CheckAndModifyPropertyValueTask("Rendering filter", "The rendering filter is now part of the templating module.", ContentRepository.CONFIG, "/server/filters/cms/rendering", "class", "info.magnolia.cms.filters.RenderingFilter", "info.magnolia.module.templating.RenderingFilter"))
85                  .addTask(new BootstrapSingleResource("Freemarker Model for RenderableDefinition", "Plugs in a specific Freemarker model for RenderableDefinition implementations.", "/mgnl-bootstrap/templating/config.server.rendering.freemarker.modelFactories.renderable.xml"))
86                  .addTask(new RenamePropertyAllModulesNodeTask("Templates configuration", "Property path is now templatePath.", "templates", "path", "templatePath"))
87                  .addTask(new NestPropertiesAllModulesNodeTask("Templates configuration", "Property path is now templatePath.", "templates",
88                          Arrays.asList(new String[]{"name", "type", "templatePath", "title", "description", "i18nBasename", "visible", "class"}), "parameters", ItemType.CONTENTNODE.getSystemName()))
89                  .addTask(new RenamePropertyAllModulesNodeTask("Paragraphs configuration", "Property templateType is now type.", "paragraphs", "templateType", "type"))
90                  .addTask(new DeprecateDialogPathAllModules("Paragraphs configuration", "Property dialogPath changed to dialog."))
91          );
92  
93          // TODO 4.1
94          // .addTask( move from admin module: ("Paragraph edit dialog", "The paragraph edition dialog is now a regular dialog.", "/mgnl-bootstrap/templating/config.modules.templating.dialogs.editParagraph.xml"))
95  //                .addTask(new ArrayDelegateTask("Paragraph selection dialog", "The paragraph selection dialog is now part of the Templating module.",
96  //                        new RemoveNodeTask(null, null, ContentRepository.CONFIG, "/modules/adminInterface/dialogs/selectParagraph"),
97  //                        new CreateNodeTask(null, null, ContentRepository.CONFIG, "/modules/templating/dialogs", "selectParagraph", ItemType.CONTENT.getSystemName()),
98  //                        new NewPropertyTask(null, null, ContentRepository.CONFIG, "/modules/templating/dialogs/selectParagraph", "class", ParagraphSelectDialog.class.getName())))
99  
100       //since 4.0 templatePath property was moved into parameters content node
101         //has to be fixed in 4.0.3 and 4.1.1
102         register(DeltaBuilder.update("4.0.3", "")
103                 .addTask(new FixTemplatePathTask("Fix templatePath property", "Moves templatePath property if is not set correct."))
104         );
105 
106         //since 4.0 templatePath property was moved into parameters content node
107         //has to be fixed in 4.0.3 and 4.1.1
108         register(DeltaBuilder.update("4.1.1", "")
109                 .addTask(new FixTemplatePathTask("Fix templatePath property", "Moves templatePath property if is not set correct."))
110         );
111         
112         register(DeltaBuilder.update("4.3", "")
113             .addTask(new BootstrapSingleModuleResource("Rendering Engine", "Add configuration for the new rendering engine", "config.server.rendering.engine.xml"))
114         );
115     }
116 
117     protected List<Task> getExtraInstallTasks(InstallContext installContext) {
118         final ArrayList<Task> tasks = new ArrayList<Task>();
119         tasks.add(orderBackwardCompatibilityFilter);
120         // TODO : make sure the RenderingFilter is the last one ?
121         return tasks;
122     }
123 
124 }