Clover Coverage Report - Google Sitemap Module 2.0
Coverage timestamp: Fri Nov 22 2013 10:43:46 CET
../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
7   116   2   3.5
0   67   0.29   2
2     1  
1    
 
  GoogleSiteMapVersionHandler       Line # 64 7 0% 2 0 100% 1.0
 
No Tests
 
1    /**
2    * This file Copyright (c) 2012-2013 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.BootstrapSingleResourceAndOrderBefore;
42    import info.magnolia.module.delta.CheckAndModifyPropertyValueTask;
43    import info.magnolia.module.delta.DeltaBuilder;
44    import info.magnolia.module.delta.NewPropertyTask;
45    import info.magnolia.module.delta.NodeExistsDelegateTask;
46    import info.magnolia.module.delta.OrderNodeBeforeTask;
47    import info.magnolia.module.delta.RemoveNodeTask;
48    import info.magnolia.module.delta.SetupModuleRepositoriesTask;
49    import info.magnolia.module.delta.Task;
50    import info.magnolia.module.googlesitemap.app.field.transformer.SiteMapTransformer;
51    import info.magnolia.module.googlesitemap.setup.migration.Removei18nKeysInSiteMapMigrationTask;
52    import info.magnolia.module.googlesitemap.setup.migration.SiteMapDefinitionMigrationTask;
53    import info.magnolia.module.googlesitemap.setup.migration.SiteMapDialogMigrationTask;
54    import info.magnolia.module.inplacetemplating.setup.TemplatesInstallTask;
55    import info.magnolia.repository.RepositoryConstants;
56   
57    import java.util.ArrayList;
58    import java.util.List;
59   
60   
61    /**
62    * Default version handler.
63    */
 
64    public class GoogleSiteMapVersionHandler extends DefaultModuleVersionHandler {
65   
 
66  1 toggle public GoogleSiteMapVersionHandler() {
67  1 register(DeltaBuilder.update("1.2.1", "")
68    .addTask(new RemoveNodeTask("Obsolete folder: templates", "Templates folder has to be removed", "config", "/modules/google-sitemap/templates"))
69    .addTask(new RemoveNodeTask("Obsolete folder: dialog", "Dialogs folder has to be removed", "config", "/modules/google-sitemap/dialogs"))
70    .addTask(new RemoveNodeTask("Obsolete SiteMap site sample definition", "", "website", "google-sitemap"))
71    .addTask(new BootstrapSingleModuleResource("SiteMap new Config", "Setup Config", "config.modules.google-sitemap.config.xml"))
72    .addTask(new BootstrapSingleModuleResource("SiteMap new Template", "Setup Template", "config.modules.google-sitemap.templates.xml")));
73   
74  1 register(DeltaBuilder.update("2.0", "")
75    .addTask(new SiteMapDefinitionMigrationTask("Migrate M4.5 site map definition into the new App", "", RepositoryConstants.WEBSITE, "/"))
76    .addTask(new SiteMapDialogMigrationTask("Migrate M4.5 dialog definition", "Create the new M5 dialog definition. Add actions, tabs and fields definition", "google-sitemap"))
77    .addTask(new BootstrapSingleResourceAndOrderBefore("Bootstrap tab", "Bootstrap site map properties tab",
78    "/mgnl-bootstrap/google-sitemap/dialogs/config.modules.google-sitemap.dialogs.components.content.siteComponentTab.form.tabs.siteMap.xml", "tabSites"))
79    .addTask(new BootstrapSingleModuleResource("SiteMap app", "Add SiteMap app", "app/config.modules.google-sitemap.apps.xml"))
80    .addTask(new BootstrapSingleModuleResource("SiteMap app App Launcher", "Add SiteMap app to App Launcher", "app/config.modules.ui-admincentral.config.appLauncherLayout.groups.manage.apps.siteMaps.xml"))
81    .addTask(new BootstrapSingleModuleResource("Field Types", "Install new field types", "fieldtypes/config.modules.google-sitemap.fieldTypes.xml"))
82    .addTask(new BootstrapSingleModuleResource("Repository Mapping", "Add Google SiteMap worksapce mapping", "config/config.server.URI2RepositoryMapping.mappings.sitemaps.xml"))
83    .addTask(new BootstrapSingleModuleResource("Virtual URI Mapping", "Add Google SiteMap virtual URI mapping", "virtualurimappings/config.modules.google-sitemap.virtualURIMapping.xml"))
84    .addTask(new SetupModuleRepositoriesTask())
85    .addTask(new AddPermissionTask("Anonymous permissions for the new workspace", "", "anonymous", "googleSitemaps", "/", Permission.READ, true))
86   
87    .addTask(new NewPropertyTask("Add default value transformer", "Set a transformer that display the default field value in case the stored value is null", RepositoryConstants.CONFIG, "/modules/google-sitemap/dialogs/generic/controls/googleSiteMapTab/form/tabs/tabGoogleSitemapProps/fields/googleSitemapPriority", "transformerClass", SiteMapTransformer.class.getName()))
88    .addTask(new NewPropertyTask("Add default value transformer", "Set a transformer that display the default field value in case the stored value is null", RepositoryConstants.CONFIG, "/modules/google-sitemap/dialogs/generic/controls/googleSiteMapTab/form/tabs/tabGoogleSitemapProps/fields/googleSitemapChangefreq", "transformerClass", SiteMapTransformer.class.getName()))
89    .addTask(new NewPropertyTask("Add default value transformer", "Set a transformer that display the default field value in case the stored value is null", RepositoryConstants.CONFIG, "/modules/google-sitemap/dialogs/generic/controls/googleVirtualUriMapTab/form/tabs/tabGoogleSitemapProps/fields/googleSitemapPriority", "transformerClass", SiteMapTransformer.class.getName()))
90    .addTask(new NewPropertyTask("Add default value transformer", "Set a transformer that display the default field value in case the stored value is null", RepositoryConstants.CONFIG, "/modules/google-sitemap/dialogs/generic/controls/googleVirtualUriMapTab/form/tabs/tabGoogleSitemapProps/fields/googleSitemapChangefreq", "transformerClass", SiteMapTransformer.class.getName()))
91   
92    .addTask(new NodeExistsDelegateTask("Remove area definition from the pages templates", "Remove areas definition in /modules/google-sitemap/templates/pages/siteMapsConfiguration/areas", RepositoryConstants.CONFIG, "/modules/google-sitemap/templates/pages/siteMapsConfiguration/areas",
93    new RemoveNodeTask("", "", RepositoryConstants.CONFIG, "/modules/google-sitemap/templates/pages/siteMapsConfiguration/areas")))
94    .addTask(new NodeExistsDelegateTask("Remove components definition from templates", "Remove areas definition in /modules/google-sitemap/templates/components", RepositoryConstants.CONFIG, "/modules/google-sitemap/templates/components",
95    new RemoveNodeTask("", "", RepositoryConstants.CONFIG, "/modules/google-sitemap/templates/components")))
96   
97    .addTask(new Removei18nKeysInSiteMapMigrationTask("google-sitemap", "Remove M4.5 i18n support"))
98    .addTask(new NodeExistsDelegateTask("Reorder Sitemaps in MANAGE group", "This reorders the Sitemaps app before Configuration in the Manage group of the applauncher.", RepositoryConstants.CONFIG, "/modules/ui-admincentral/config/appLauncherLayout/groups/manage/apps/configuration",
99    new OrderNodeBeforeTask("", "", RepositoryConstants.CONFIG, "/modules/ui-admincentral/config/appLauncherLayout/groups/manage/apps/siteMaps", "configuration")))
100    .addTask(new CheckAndModifyPropertyValueTask("Set Page template not visible", "", RepositoryConstants.CONFIG, "/modules/google-sitemap/templates/pages/siteMapsConfiguration", "visible", "true", "false"))
101    );
102    }
103   
104    /**
105    * Export the FTL to the Resource folder menu from the Admin central.
106    */
 
107  1 toggle @Override
108    protected List<Task> getExtraInstallTasks(InstallContext ctx) {
109  1 final List<Task> tasks = new ArrayList<Task>();
110  1 tasks.add(new TemplatesInstallTask("/sitemap/.*\\.ftl", true));
111  1 tasks.add(new AddPermissionTask("Anonymous permissions for the new workspace", "", "anonymous", "googleSitemaps", "/", Permission.READ, true));
112  1 tasks.add(new NodeExistsDelegateTask("Reorder Sitemaps in MANAGE group", "This reorders the Sitemaps app before Configuration in the Manage group of the applauncher.", RepositoryConstants.CONFIG, "/modules/ui-admincentral/config/appLauncherLayout/groups/manage/apps/configuration",
113    new OrderNodeBeforeTask("", "", RepositoryConstants.CONFIG, "/modules/ui-admincentral/config/appLauncherLayout/groups/manage/apps/siteMaps", "configuration")));
114  1 return tasks;
115    }
116    }