View Javadoc

1   /**
2    * This file Copyright (c) 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.googlesitemap.setup;
35  
36  import info.magnolia.cms.security.Permission;
37  import info.magnolia.module.DefaultModuleVersionHandler;
38  import info.magnolia.module.InstallContext;
39  import info.magnolia.module.delta.AddPermissionTask;
40  import info.magnolia.module.delta.BootstrapSingleModuleResource;
41  import info.magnolia.module.delta.DeltaBuilder;
42  import info.magnolia.module.delta.PartialBootstrapTask;
43  import info.magnolia.module.delta.RemoveNodeTask;
44  import info.magnolia.module.delta.SetupModuleRepositoriesTask;
45  import info.magnolia.module.delta.Task;
46  import info.magnolia.module.googlesitemap.setup.migration.SiteMapDefinitionMigrationTask;
47  import info.magnolia.module.inplacetemplating.setup.TemplatesInstallTask;
48  import info.magnolia.repository.RepositoryConstants;
49  import info.magnolia.ui.dialog.setup.DialogMigrationTask;
50  
51  import java.util.ArrayList;
52  import java.util.List;
53  
54  
55  /**
56   * Default version handler.
57   * @version $Id$
58   *
59   */
60  public class GoogleSiteMapVersionHandler extends DefaultModuleVersionHandler {
61  
62      public GoogleSiteMapVersionHandler() {
63          register(DeltaBuilder.update("1.2.1", "")
64                  .addTask(new RemoveNodeTask("Obsolete folder: templates", "Templates folder has to be removed", "config", "/modules/google-sitemap/templates"))
65                  .addTask(new RemoveNodeTask("Obsolete folder: dialog", "Dialogs folder has to be removed", "config", "/modules/google-sitemap/dialogs"))
66                  .addTask(new RemoveNodeTask("Obsolete SiteMap site sample definition", "", "website", "google-sitemap"))
67                  .addTask(new BootstrapSingleModuleResource("SiteMap new Config", "Setup Config", "config.modules.google-sitemap.config.xml"))
68                  .addTask(new BootstrapSingleModuleResource("SiteMap new Template", "Setup Template", "config.modules.google-sitemap.templates.xml")));
69          register(DeltaBuilder.update("2.0", "")
70                  .addTask(new SiteMapDefinitionMigrationTask("Migrate M4.5 site map definition into the new App", "", RepositoryConstants.WEBSITE, "/"))
71                  .addTask(new DialogMigrationTask("Migrate M4.5 dialog definition", "Create the new M5 dialog definition. Add actions, tabs and fields definition", "google-sitemap"))
72                  .addTask(new PartialBootstrapTask("Bootstrap tab", "Bootstrap  site map properties tab",
73                                                       "/mgnl-bootstrap/google-sitemap/dialogs/config.modules.google-sitemap.dialogs.components.xml",
74                                                       "/components/content/siteComponentTab/form/tabs/siteMap"))
75                  .addTask(new BootstrapSingleModuleResource("SiteMap app", "Add SiteMap app", "app/config.modules.google-sitemap.apps.xml"))
76                  .addTask(new BootstrapSingleModuleResource("SiteMap app App Launcher", "Add SiteMap app to App Launcher", "app/config.modules.ui-admincentral.config.appLauncherLayout.groups.stk.apps.siteMaps.xml"))
77                  .addTask(new BootstrapSingleModuleResource("Field Types", "Install new field types", "fieldtypes/config.modules.google-sitemap.fieldTypes.xml"))
78                  .addTask(new BootstrapSingleModuleResource("Repository Mapping", "Add Google SiteMap worksapce mapping", "config/config.server.URI2RepositoryMapping.mappings.sitemaps.xml"))
79                  .addTask(new BootstrapSingleModuleResource("Virtual URI Mapping", "Add Google SiteMap virtual URI mapping", "virtualurimappings/config.modules.google-sitemap.virtualURIMapping.xml"))
80                  .addTask(new SetupModuleRepositoriesTask())
81                  .addTask(new AddPermissionTask("Anonymous permissions for the new workspace", "", "anonymous", "googleSitemaps", "/", Permission.READ, true)));
82      }
83  
84      /**
85       * Export the FTL to the Resource folder menu from the Admin central.
86       */
87      @Override
88      protected List<Task> getExtraInstallTasks(InstallContext ctx) {
89          final List<Task> tasks = new ArrayList<Task>();
90          tasks.add(new TemplatesInstallTask("/sitemap/.*\\.ftl", true));
91          tasks.add(new AddPermissionTask("Anonymous permissions for the new workspace", "", "anonymous", "googleSitemaps", "/", Permission.READ, true));
92          return tasks;
93      }
94  }