1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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.ArrayDelegateTask;
41 import info.magnolia.module.delta.BootstrapSingleModuleResource;
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.NewPropertyTask;
46 import info.magnolia.module.delta.NodeExistsDelegateTask;
47 import info.magnolia.module.delta.OrderNodeBeforeTask;
48 import info.magnolia.module.delta.RemoveNodeTask;
49 import info.magnolia.module.delta.RemovePropertyTask;
50 import info.magnolia.module.delta.SetPropertyTask;
51 import info.magnolia.module.delta.SetupModuleRepositoriesTask;
52 import info.magnolia.module.delta.Task;
53 import info.magnolia.module.googlesitemap.app.field.transformer.SiteMapTransformer;
54 import info.magnolia.module.googlesitemap.setup.migration.Removei18nKeysInSiteMapMigrationTask;
55 import info.magnolia.module.googlesitemap.setup.migration.SiteMapDefinitionMigrationTask;
56 import info.magnolia.module.googlesitemap.setup.migration.SiteMapDialogMigrationTask;
57 import info.magnolia.module.inplacetemplating.setup.TemplatesInstallTask;
58 import info.magnolia.repository.RepositoryConstants;
59
60 import java.util.ArrayList;
61 import java.util.List;
62
63
64
65
66
67 public class GoogleSiteMapVersionHandler extends DefaultModuleVersionHandler {
68
69 public GoogleSiteMapVersionHandler() {
70 register(DeltaBuilder.update("1.2.1", "")
71 .addTask(new RemoveNodeTask("Obsolete folder: templates", "Templates folder has to be removed", "config", "/modules/google-sitemap/templates"))
72 .addTask(new RemoveNodeTask("Obsolete folder: dialog", "Dialogs folder has to be removed", "config", "/modules/google-sitemap/dialogs"))
73 .addTask(new RemoveNodeTask("Obsolete SiteMap site sample definition", "", "website", "google-sitemap"))
74 .addTask(new BootstrapSingleModuleResource("SiteMap new Config", "Setup Config", "config.modules.google-sitemap.config.xml"))
75 .addTask(new BootstrapSingleModuleResource("SiteMap new Template", "Setup Template", "config.modules.google-sitemap.templates.xml")));
76
77 register(DeltaBuilder.update("2.0", "")
78 .addTask(new SiteMapDefinitionMigrationTask("Migrate M4.5 site map definition into the new App", "", RepositoryConstants.WEBSITE, "/"))
79 .addTask(new SiteMapDialogMigrationTask("Migrate M4.5 dialog definition", "Create the new M5 dialog definition. Add actions, tabs and fields definition", "google-sitemap"))
80 .addTask(new BootstrapSingleResourceAndOrderBefore("Bootstrap tab", "Bootstrap site map properties tab",
81 "/mgnl-bootstrap/google-sitemap/dialogs/config.modules.google-sitemap.dialogs.components.content.siteComponentTab.form.tabs.siteMap.xml", "tabSites"))
82 .addTask(new BootstrapSingleModuleResource("SiteMap app", "Add SiteMap app", "app/config.modules.google-sitemap.apps.xml"))
83 .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"))
84 .addTask(new BootstrapSingleModuleResource("Field Types", "Install new field types", "fieldtypes/config.modules.google-sitemap.fieldTypes.xml"))
85 .addTask(new BootstrapSingleModuleResource("Repository Mapping", "Add Google SiteMap worksapce mapping", "config/config.server.URI2RepositoryMapping.mappings.sitemaps.xml"))
86 .addTask(new BootstrapSingleModuleResource("Virtual URI Mapping", "Add Google SiteMap virtual URI mapping", "virtualurimappings/config.modules.google-sitemap.virtualURIMapping.xml"))
87 .addTask(new SetupModuleRepositoriesTask())
88 .addTask(new AddPermissionTask("Anonymous permissions for the new workspace", "", "anonymous", "googleSitemaps", "/", Permission.READ, true))
89
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/googleSiteMapTab/form/tabs/tabGoogleSitemapProps/fields/googleSitemapPriority", "transformerClass", SiteMapTransformer.class.getName()))
91 .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()))
92 .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()))
93 .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()))
94
95 .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",
96 new RemoveNodeTask("", "", RepositoryConstants.CONFIG, "/modules/google-sitemap/templates/pages/siteMapsConfiguration/areas")))
97 .addTask(new NodeExistsDelegateTask("Remove components definition from templates", "Remove areas definition in /modules/google-sitemap/templates/components", RepositoryConstants.CONFIG, "/modules/google-sitemap/templates/components",
98 new RemoveNodeTask("", "", RepositoryConstants.CONFIG, "/modules/google-sitemap/templates/components")))
99
100 .addTask(new Removei18nKeysInSiteMapMigrationTask("google-sitemap", "Remove M4.5 i18n support"))
101 .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",
102 new OrderNodeBeforeTask("", "", RepositoryConstants.CONFIG, "/modules/ui-admincentral/config/appLauncherLayout/groups/manage/apps/siteMaps", "configuration")))
103 .addTask(new CheckAndModifyPropertyValueTask("Set Page template not visible", "", RepositoryConstants.CONFIG, "/modules/google-sitemap/templates/pages/siteMapsConfiguration", "visible", "true", "false"))
104 );
105
106 register(DeltaBuilder.update("2.0.1", "")
107 .addTask(new RemoveNodeTask("Remove dialog", "Remove obsolete dialog.", RepositoryConstants.CONFIG, "/modules/google-sitemap/dialogs/pages"))
108 .addTask(new ArrayDelegateTask("Rename property", "Rename property [workspace] to [targetWorkspace].",
109 new RemovePropertyTask("", "", RepositoryConstants.CONFIG, "/modules/google-sitemap/dialogs/components/content/siteComponentTab/form/tabs/tabSites/fields/sites/field", "workspace"),
110 new SetPropertyTask("", RepositoryConstants.CONFIG, "/modules/google-sitemap/dialogs/components/content/siteComponentTab/form/tabs/tabSites/fields/sites/field", "targetWorkspace", RepositoryConstants.WEBSITE)))
111 .addTask(new RemovePropertyTask("Remove unused property", "Remove unused property called identifier.", RepositoryConstants.CONFIG, "/modules/google-sitemap/dialogs/components/content/siteComponentTab/form/tabs/tabSites/fields/sites/field", "identifier"))
112 .addTask(new RemovePropertyTask("Remove unused property", "Remove unused property called dialog.", RepositoryConstants.CONFIG, "/modules/google-sitemap/templates/pages/siteMapsConfiguration", "dialog"))
113 .addTask(new RemovePropertyTask("Remove unused property", "Remove unused property called sitemapType.", RepositoryConstants.CONFIG, "/modules/google-sitemap/templates/pages/siteMapsConfiguration", "sitemapType"))
114 );
115 }
116
117
118
119
120 @Override
121 protected List<Task> getExtraInstallTasks(InstallContext ctx) {
122 final List<Task> tasks = new ArrayList<Task>();
123 tasks.add(new TemplatesInstallTask("/sitemap/.*\\.ftl", true));
124 tasks.add(new AddPermissionTask("Anonymous permissions for the new workspace", "", "anonymous", "googleSitemaps", "/", Permission.READ, true));
125 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",
126 new OrderNodeBeforeTask("", "", RepositoryConstants.CONFIG, "/modules/ui-admincentral/config/appLauncherLayout/groups/manage/apps/siteMaps", "configuration")));
127 return tasks;
128 }
129 }