View Javadoc

1   /**
2    * This file Copyright (c) 2008-2012 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.rssaggregator.setup;
35  
36  import info.magnolia.migration.task.SimpleSTKRelatedModuleMigrationTask;
37  import info.magnolia.module.DefaultModuleVersionHandler;
38  import info.magnolia.module.InstallContext;
39  import info.magnolia.module.data.setup.RegisterNodeTypeTask;
40  import info.magnolia.module.delta.ArrayDelegateTask;
41  import info.magnolia.module.delta.BootstrapConditionally;
42  import info.magnolia.module.delta.BootstrapSingleResource;
43  import info.magnolia.module.delta.CheckAndModifyPropertyValueTask;
44  import info.magnolia.module.delta.CheckOrCreatePropertyTask;
45  import info.magnolia.module.delta.CreateNodeTask;
46  import info.magnolia.module.delta.DeltaBuilder;
47  import info.magnolia.module.delta.ModuleDependencyBootstrapTask;
48  import info.magnolia.module.delta.NodeExistsDelegateTask;
49  import info.magnolia.module.delta.Task;
50  import info.magnolia.module.model.Version;
51  import info.magnolia.repository.RepositoryConstants;
52  
53  import java.util.ArrayList;
54  import java.util.Arrays;
55  import java.util.List;
56  
57  // import info.magnolia.module.delta.BootstrapResourcesTask;
58  
59  /**
60   * Version handler.
61   *
62   * @author had
63   */
64  public class RSSAggregatorVersionHandler extends DefaultModuleVersionHandler {
65  
66      public RSSAggregatorVersionHandler() {
67  
68          register(DeltaBuilder.checkPrecondition("1.2.2", "1.3"));
69  
70          register(DeltaBuilder.update("1.3", "")
71                  .addTask(new SimpleSTKRelatedModuleMigrationTask("Migration task: Migrate RSS configuration repository", "Migrate configuration of templates, dialogs and site definitions", "rssaggregator", false, Arrays.asList("")))
72                  .addTask(new NodeExistsDelegateTask("Renamed modelClass", "", RepositoryConstants.CONFIG, "/modules/rssaggregator/paragraphs",
73                          new ArrayDelegateTask("Renamed modelClass ", "",
74                                  new CheckAndModifyPropertyValueTask("Renamed modelClass of the combinedFeedsParagraph node", "", RepositoryConstants.CONFIG, "/modules/rssaggregator/paragraphs/combinedFeedsParagraph", "modelClass", "info.magnolia.module.rssaggregator.CombinedFeedAction", "info.magnolia.module.rssaggregator.templates.components.CombinedFeedModel"),
75                                  new CheckAndModifyPropertyValueTask("Renamed modelClass of the feedListParagraph node", "", RepositoryConstants.CONFIG, "/modules/rssaggregator/paragraphs/feedListParagraph", "modelClass", "info.magnolia.module.rssaggregator.FeedListAction", "info.magnolia.module.rssaggregator.templates.components.FeedListModel")),
76                          new ArrayDelegateTask("Renamed modelClass ", "",
77                                  new CheckAndModifyPropertyValueTask("Renamed modelClass of the combinedFeedsParagraph node", "", RepositoryConstants.CONFIG, "/modules/rssaggregator/templates/components/combinedFeedsParagraph", "modelClass", "info.magnolia.module.rssaggregator.CombinedFeedAction", "info.magnolia.module.rssaggregator.templates.components.CombinedFeedModel"),
78                                  new CheckAndModifyPropertyValueTask("Renamed modelClass of the feedListParagraph node", "", RepositoryConstants.CONFIG, "/modules/rssaggregator/templates/components/feedListParagraph", "modelClass", "info.magnolia.module.rssaggregator.FeedListAction", "info.magnolia.module.rssaggregator.templates.components.FeedListModel"))
79                  )
80                  )
81          );
82  
83          register(DeltaBuilder.update("1.4", "")
84                  .addTask(new BootstrapSingleResource("Planet feed component.", "", "/mgnl-bootstrap/rssaggregator/templates/components/config.modules.rssaggregator.templates.components.planetFeeds.xml"))
85                  .addTask(new BootstrapSingleResource("Planet feed dialog.", "", "/mgnl-bootstrap/rssaggregator/dialogs/config.modules.rssaggregator.dialogs.planetFeeds.xml"))
86                  .addTask(new BootstrapSingleResource("Planet feed statistics component.", "", "/mgnl-bootstrap/rssaggregator/templates/components/config.modules.rssaggregator.templates.components.feedStatistics.xml"))
87                  .addTask(new BootstrapSingleResource("Planet feed statistics dialog.", "", "/mgnl-bootstrap/rssaggregator/dialogs/config.modules.rssaggregator.dialogs.feedStatistics.xml"))
88                  .addTask(new BootstrapSingleResource("Planet feed subcriptions component.", "", "/mgnl-bootstrap/rssaggregator/templates/components/config.modules.rssaggregator.templates.components.feedSubscriptions.xml"))
89                  .addTask(new BootstrapSingleResource("Planet feed subcriptions dialog.", "", "/mgnl-bootstrap/rssaggregator/dialogs/config.modules.rssaggregator.dialogs.feedSubscriptions.xml"))
90                          // settings for feed syndication
91                  .addTask(new BootstrapSingleResource("Virtual URI mapping for planet feeds.", "", "/mgnl-bootstrap/rssaggregator/config.modules.adminInterface.virtualURIMapping.planetFeeds.xml"))
92                  .addTask(new BootstrapSingleResource("Feed generator for planet feeds.", "", "/mgnl-bootstrap/rssaggregator/config/feedGenerators/config.modules.rssaggregator.config.feedGenerators.planet.xml"))
93                  .addTask(new BootstrapSingleResource("Feed syndication component.", "", "/mgnl-bootstrap/rssaggregator/templates/components/config.modules.rssaggregator.templates.components.feedSyndication.xml"))
94                  .addTask(new BootstrapSingleResource("Feed syndication dialog.", "", "/mgnl-bootstrap/rssaggregator/dialogs/config.modules.rssaggregator.dialogs.feedSyndication.xml"))
95                          // planet commands
96                  .addTask(new BootstrapConditionally("Commands for planet RSS.", "", "/mgnl-bootstrap/rssaggregator/config/commands/config.modules.rssaggregator.commands.xml"))
97                  .addTask(new BootstrapConditionally("Scheduled job for planet archive.", "", "/mgnl-bootstrap/rssaggregator/config/commands/config.modules.scheduler.config.jobs.generatePlanetData.xml"))
98                  .addTask(new BootstrapConditionally("Scheduled job for planet statistics.", "", "/mgnl-bootstrap/rssaggregator/config/commands/config.modules.scheduler.config.jobs.collectPlanetStatistics.xml"))
99                          // add planet feed option to RSSAggregator dialog
100                 .addTask(new CreateNodeTask("Planet feed option for combined RSS feeds.", "Add an option to check if an RSS feed is a planet feed.",
101                         RepositoryConstants.CONFIG, "/modules/data/dialogs/RssAggregator/mainTab", "planetFeed", "mgnl:contentNode"))
102                 .addTask(new CheckOrCreatePropertyTask("Control property for planet option.", "",
103                         RepositoryConstants.CONFIG, "/modules/data/dialogs/RssAggregator/mainTab/planetFeed", "controlType", "checkboxSwitch"))
104                 .addTask(new CheckOrCreatePropertyTask("Control property for planet option.", "Add a property for the RSS feed dialog.",
105                         RepositoryConstants.CONFIG, "/modules/data/dialogs/RssAggregator/mainTab/planetFeed", "description", "rssaggregator.data.dialog.planetFeed.description"))
106                 .addTask(new CheckOrCreatePropertyTask("Control property for planet option.", "Add a property for the RSS feed dialog.",
107                         RepositoryConstants.CONFIG, "/modules/data/dialogs/RssAggregator/mainTab/planetFeed", "label", "rssaggregator.data.dialog.planetFeed.label"))
108                 .addTask(new CheckOrCreatePropertyTask("Control property for planet option.", "Add a property for the RSS feed dialog.",
109                         RepositoryConstants.CONFIG, "/modules/data/dialogs/RssAggregator/mainTab/planetFeed", "selected", "false"))
110                 .addTask(new CheckOrCreatePropertyTask("Control property for planet option.", "Add a property for the RSS feed dialog.",
111                         RepositoryConstants.CONFIG, "/modules/data/dialogs/RssAggregator/mainTab/planetFeed", "type", "String"))
112                         // add config options for planet
113                 .addTask(new CreateNodeTask("Planet feed options.", "Add options for planet feeds to the RSSAggregator module.",
114                         RepositoryConstants.CONFIG, "/modules/rssaggregator/config", "planetOptions", "mgnl:contentNode"))
115                 .addTask(new CheckOrCreatePropertyTask("Option for relevant months to be included in statistics", "",
116                         RepositoryConstants.CONFIG, "/modules/rssaggregator/config/planetOptions", "lastMonthsIncluded", "3"))
117         );
118 
119     }
120 
121     @Override
122     protected List<Task> getBasicInstallTasks(InstallContext installContext) {
123         final List<Task> installTasks = new ArrayList<Task>();
124         // make sure we register the type before doing anything else
125         installTasks.add(new RegisterNodeTypeTask("RssAggregator"));
126         installTasks.addAll(super.getBasicInstallTasks(installContext));
127         return installTasks;
128     }
129 
130     @Override
131     protected List<Task> getExtraInstallTasks(InstallContext installContext) {
132         List<Task> tasks = new ArrayList<Task>();
133         tasks.add(new ModuleDependencyBootstrapTask("observation"));
134         tasks.addAll(super.getExtraInstallTasks(installContext));
135         return tasks;
136     }
137 
138     @Override
139     protected List<Task> getDefaultUpdateTasks(Version forVersion) {
140         final List<Task> tasks = new ArrayList<Task>();
141         tasks.addAll(super.getDefaultUpdateTasks(forVersion));
142         return tasks;
143     }
144 }