private Task moveExistingApps(String dest) { String src = "/modules/forum/apps"; Task moveAppsTask = new MoveNodeTask("Move " + src + " to " + dest, "Moving " + src + " to " + dest, RepositoryConstants.CONFIG, src, dest, false); Task checkNodeTask = new NodeExistsDelegateTask("Check if " + src + " exists.", "Check if " + src + " exists.", RepositoryConstants.CONFIG, "/modules/forum/apps", moveAppsTask); return checkNodeTask; }
@Override protected List<Task> getExtraInstallTasks(InstallContext installContext) { final List<Task> tasks = new ArrayList<>(); tasks.add(new NodeExistsDelegateTask("Reorder Mail in TOOLS", "This reorders the Mail tools app before Cache tools in the Tools group of the applauncher.", RepositoryConstants.CONFIG, "/modules/ui-admincentral/config/appLauncherLayout/groups/tools/apps/cacheTools", new OrderNodeBeforeTask("", "", RepositoryConstants.CONFIG, "/modules/ui-admincentral/config/appLauncherLayout/groups/tools/apps/mail", "cacheTools"))); return tasks; } }
private Task configureActionsAsAsynchronous() { return new IsModuleInstalledOrRegistered("Configure actions as asynchronous", "Configure actions as asynchronous if scheduler module is installed", "scheduler", new ArrayDelegateTask("", "", new NodeExistsDelegateTask("Configure activation as asynchronous", "/modules/dam/apps/assets/subApps/browser/actions/activate", new SetPropertyTask(RepositoryConstants.CONFIG, "/modules/dam/apps/assets/subApps/browser/actions/activate", "asynchronous", "true")), new NodeExistsDelegateTask("Configure recursive activation as asynchronous", "/modules/dam/apps/assets/subApps/browser/actions/activateRecursive", new SetPropertyTask(RepositoryConstants.CONFIG, "/modules/dam/apps/assets/subApps/browser/actions/activateRecursive", "asynchronous", "true")), new NodeExistsDelegateTask("Configure deletion as asynchronous", "/modules/dam/apps/assets/subApps/browser/actions/delete", new SetPropertyTask(RepositoryConstants.CONFIG, "/modules/dam/apps/assets/subApps/browser/actions/delete", "asynchronous", "true")), new NodeExistsDelegateTask("Configure deletion of folder as asynchronous", "/modules/dam/apps/assets/subApps/browser/actions/deleteFolder", new SetPropertyTask(RepositoryConstants.CONFIG, "/modules/dam/apps/assets/subApps/browser/actions/deleteFolder", "asynchronous", "true")) )); }
@Override protected List<Task> getBasicInstallTasks(InstallContext installContext) { // Since this module was introduced in 5.4, we need to conditionally update the existing config or install it fresh final NodeExistsDelegateTask config = new NodeExistsDelegateTask("Install or update FreeMarker support configuration", "Installs or updates the FreeMarker support configuration, introduces a new TemplateLoader.", RepositoryConstants.CONFIG, "/server/rendering/freemarker", // if freemarker config exists, then check loaders; if they're default, replace, if not just warn // if not, bootstrap (or use node builder) checkAndAddTemplateLoader(), freshConfig()); return Collections.<Task>singletonList(config); }
@Override public void execute(InstallContext installContext) throws TaskExecutionException { for (Entry<String, String> entry : properties.entrySet()) { new NodeExistsDelegateTask("", PARENT_PATH + "/" + entry.getKey(), new RenameNodeTask("", "", RepositoryConstants.CONFIG, PARENT_PATH, entry.getKey(), entry.getValue(), false)).execute(installContext); } } }
@Override protected List<Task> getExtraInstallTasks(InstallContext installContext) { List<Task> tasks = new ArrayList<Task>(); tasks.add(new ModuleDependencyBootstrapTask("observation")); tasks.add(new ModuleDependencyBootstrapTask("scheduler")); tasks.add(addReadRoleToAnonymousUser); tasks.add(grantReadPermissionToAnonymousUser); tasks.add(new NodeExistsDelegateTask("Reorder Categories in MANAGE group", "This reorders the Categories app before RSS in the Manage group of the applauncher.", RepositoryConstants.CONFIG, "/modules/ui-admincentral/config/appLauncherLayout/groups/manage/apps/rssAggregator", new OrderNodeBeforeTask("", "", RepositoryConstants.CONFIG, "/modules/ui-admincentral/config/appLauncherLayout/groups/manage/apps/categories", "rssAggregator"))); tasks.add(new InstallRendererContextAttributeTask("rendering", "freemarker", "catfn", CategorizationTemplatingFunctions.class.getName())); return tasks; }
@Override protected List<Task> getBasicInstallTasks(InstallContext installContext) { final List<Task> installTasks = new ArrayList<Task>(); // Remove RelatedCategories if needed. This will be bootstrap later on. installTasks.add(new NodeExistsDelegateTask("STK RelatedCategories Link List removal", "Remove the STK Related Categories Link List if it exists. The new definition will then be bootstrapped.", RepositoryConstants.CONFIG, "/modules/standard-templating-kit/dialogs/paragraphs/features/stkRelatedCategoriesLinkList", new RemoveNodeTask("Remove RelatedCategories", "", RepositoryConstants.CONFIG, "/modules/standard-templating-kit/dialogs/paragraphs/features/stkRelatedCategoriesLinkList"), null)); installTasks.addAll(super.getBasicInstallTasks(installContext)); return installTasks; }
@Override protected List<Task> getExtraInstallTasks(InstallContext installContext) { List<Task> tasks = new ArrayList<Task>(); tasks.add(new RegisterWorkspaceForCacheFlushingTask("data")); tasks.add(new NodeExistsDelegateTask("Bootstrap data applauncher group if not existing", "/config.modules.ui-admincentral/config/appLauncherLayout/groups/data", null, new BootstrapSingleResource("", "", "/mgnl-bootstrap/ui-admincentral/config.modules.ui-admincentral.config.appLauncherLayout.groups.data.xml"))); tasks.add(new OrderNodeBeforeTask("Data AppLauncher group ordering", "Moves the data app group before tools group", RepositoryConstants.CONFIG, "/modules/ui-admincentral/config/appLauncherLayout/groups/data", "tools")); return tasks; }
private void addCancelButtonTextFieldToFormSubmitTemplate(DeltaBuilder delta) { final String parentPath = "/modules/form/dialogs/formSubmit/form/tabs/tabMain/fields"; String generalDescTxt = " an additional field 'cancelButtonLabel' to" + parentPath + "."; Task bootstrapSingleModuleResource = new BootstrapSingleModuleResource("Add" + generalDescTxt, "Adds" + generalDescTxt, "dialogs/config.modules.form.dialogs.formSubmit.yaml", "/formSubmit/form/tabs/tabMain/fields/cancelButtonText"); NodeExistsDelegateTask nodeExistsDelegateTask = new NodeExistsDelegateTask("Conditionally add" + generalDescTxt + "(If " + parentPath + " exists.)", parentPath, bootstrapSingleModuleResource); delta.addTask(nodeExistsDelegateTask); }
@Override protected List<Task> getExtraInstallTasks(InstallContext installContext) { final List<Task> tasks = new ArrayList<Task>(); tasks.add(grantAllToSuperuser); tasks.add(new AppLauncherReorderingTask("forum", "edit", Order.AFTER, "assets")); tasks.add(new NodeExistsDelegateTask("Order 'messageAdd' dialog to the first position", "", RepositoryConstants.CONFIG, "/modules/forum/dialogs/messageAdd", new OrderNodeToFirstPositionTask("", "modules/forum/dialogs/messageAdd"))); tasks.add(new ModuleDependencyBootstrapTask("publishing-core")); tasks.add(new ModuleDependencyBootstrapTask("activation")); return tasks; }
@Override protected List<Task> getExtraInstallTasks(InstallContext installContext) { List<Task> tasks = new ArrayList<Task>(); tasks.add(new ModuleDependencyBootstrapTask("observation")); tasks.add(new IsInstallSamplesTask("Install STK sample component availability", "Adds components of RSS aggregator to component availability of STK when installed", new ModuleDependencyBootstrapTask("standard-templating-kit"))); tasks.addAll(super.getExtraInstallTasks(installContext)); tasks.add(new NodeExistsDelegateTask("Reorder RSS in MANAGE group", "This reorders the RSS app before Config in the Manage group of the applauncher.", RepositoryConstants.CONFIG, "/modules/ui-admincentral/config/appLauncherLayout/groups/manage/apps/configuration", new OrderNodeBeforeTask("", "", RepositoryConstants.CONFIG, "/modules/ui-admincentral/config/appLauncherLayout/groups/manage/apps/rssAggregator", "configuration"))); tasks.add(setDefaultValues); return tasks; }
@Override public void execute(InstallContext context) throws TaskExecutionException { ModuleDefinition moduleDefinition = context.getCurrentModuleDefinition(); String defaultURI = StringUtils.isNotEmpty(moduleProperty) ? moduleDefinition.getProperty(moduleProperty) : moduleDefinition.getProperty(DEFAULT_PUBLIC_URI_PROPERTY); Task setPublicTask = new IsAdminInstanceDelegateTask("", "Set default virtual URI on public instances.", null, new NodeExistsDelegateTask(String.format("Set default virtual URI to old mapping path '%s'", OLD_DEFAULT_URI_MAPPING_PATH), OLD_DEFAULT_URI_MAPPING_PATH, new SetPropertyTask(RepositoryConstants.CONFIG, OLD_DEFAULT_URI_MAPPING_PATH, "toURI", defaultURI), new NodeExistsDelegateTask(String.format("Set default virtual URI to new mapping path '%s'", NEW_DEFAULT_URI_MAPPING_PATH), NEW_DEFAULT_URI_MAPPING_PATH, new SetPropertyTask(RepositoryConstants.CONFIG, NEW_DEFAULT_URI_MAPPING_PATH, "toUri", defaultURI), new WarnTask("Default URI", "Could not set defaultPublicURI, default mapping was not found.")))); setPublicTask.execute(context); } }
public SamplesVersionHandler() { register(DeltaBuilder.update("5.4.1", "") .addTask(new ArrayDelegateTask("Remove samples configuration from JCR", new NodeExistsDelegateTask("", "/modules/samples/dialogs", new RemoveNodeTask("", "/modules/samples/dialogs")), new NodeExistsDelegateTask("", "/modules/samples/templates", new RemoveNodeTask("", "/modules/samples/templates")), new NodeExistsDelegateTask("", "/modules/samples/virtualURIMapping", new RemoveNodeTask("", "/modules/samples/virtualURIMapping")))) .addTasks(getCommonTasks())); register(DeltaBuilder.update("6.0", "") .addTask(new RemoveNodeTask("Remove JSP sample site", "Magnolia Templating JSP is deprecated as of 6.0.", WEBSITE, "/jsp-sample-site"))); }
public MigrationTasks(String name, String description) { super(name, description, new ConfigureSTKAppGroupTask(), new ReplaceIfExistsTask("", "Replaces stkImageGallery component configuration.", "Did not find expected path /modules/standard-templating-kit/dialogs/components/features/stkImageGallery.", RepositoryConstants.CONFIG, "/modules/standard-templating-kit/dialogs/components/features/stkImageGallery", "/mgnl-bootstrap/standard-templating-kit/dialogs/components/features/config.modules.standard-templating-kit.dialogs.components.features.stkImageGallery.xml"), new ReplaceIfExistsTask("", "Replaces stkDownloadLink component configuration.", "Did not find expected path /modules/standard-templating-kit/dialogs/components/links/stkDownloadLink.", RepositoryConstants.CONFIG, "/modules/standard-templating-kit/dialogs/components/links/stkDownloadLink", "/mgnl-bootstrap/standard-templating-kit/dialogs/components/links/config.modules.standard-templating-kit.dialogs.components.links.stkDownloadLink.xml"), new ReplaceIfExistsTask("", "Replaces baseTeaserDownload component configuration.", "Did not find expected path /modules/standard-templating-kit/dialogs/generic/master/baseTeaserDownload.", RepositoryConstants.CONFIG, "/modules/standard-templating-kit/dialogs/generic/master/baseTeaserDownload", "/mgnl-bootstrap/standard-templating-kit/dialogs/generic/master/config.modules.standard-templating-kit.dialogs.generic.master.baseTeaserDownload.xml"), new NodeExistsDelegateTask("", "Bootstraps stkContact component if not existing.", RepositoryConstants.CONFIG, "/modules/standard-templating-kit/templates/components/content/stkContact", null, new BootstrapSingleResource("", "", "/info/magnolia/module/standard-templating-kit/setup/contacts/config.modules.standard-templating-kit.templates.components.content.stkContact.xml")), new NodeExistsDelegateTask("", "Makes stkContact component available under stk article area.", RepositoryConstants.CONFIG, "/modules/standard-templating-kit/templates/pages/stkArticle/areas/main/areas/content/availableComponents/stkContact", null, new BootstrapSingleResource("", "", "/info/magnolia/module/standard-templating-kit/setup/contacts/config.modules.standard-templating-kit.templates.pages.stkArticle.areas.main.areas.content.availableComponents.stkContact.xml")), new RemoveRepositoryPropertyTask()); }
private Task addBypassToResourcesServlet() { return new ArrayDelegateTask("Add delegateResourceVoter to ResourcesServlet.", new NodeExistsDelegateTask("", "/server/filters/servlets/ResourcesServlet", new NodeExistsDelegateTask("", "/server/filters/servlets/ResourcesServlet/bypasses", new WarnTask("", "DelegateResourceVoter couldn't be installed since there is already a bypass defined for ResourcesServlet."), new ArrayDelegateTask("", new CreateNodeTask("", "/server/filters/servlets/ResourcesServlet", "bypasses", NodeTypes.ContentNode.NAME), new CreateNodeTask("", "/server/filters/servlets/ResourcesServlet/bypasses", "bypassWhenNotInResourceFilter", NodeTypes.ContentNode.NAME), new NewPropertyTask("", "/server/filters/servlets/ResourcesServlet/bypasses/bypassWhenNotInResourceFilter", "class", "info.magnolia.module.resources.DelegateResourceVoter"), new NewPropertyTask("", "/server/filters/servlets/ResourcesServlet/bypasses/bypassWhenNotInResourceFilter", "not", true))))); }
public RestServicesModuleVersionHandler() { register(DeltaBuilder.update("1.1", "") .addTask(new CheckAndModifyPropertyValueTask("/modules/rest-services/rest-endpoints/commands", "implementationClass", "info.magnolia.rest.service.command.v1.CommandEndpoint", "info.magnolia.rest.service.command.v2.CommandEndpoint")) ); register(DeltaBuilder.update("2.0", "") .addTask(new NodeExistsDelegateTask("Update activate command rest role to rest-editor", "/modules/rest-services/rest-endpoints/commands/enabledCommands/activate/access/roles", new CheckAndModifyPropertyValueTask("/modules/rest-services/rest-endpoints/commands/enabledCommands/activate/access/roles", "rest", "rest", "rest-editor"))) .addTask(new NodeExistsDelegateTask("Update markAsDeleted command rest role to rest-editor", "/modules/rest-services/rest-endpoints/commands/enabledCommands/markAsDeleted/access/roles", new CheckAndModifyPropertyValueTask("/modules/rest-services/rest-endpoints/commands/enabledCommands/markAsDeleted/access/roles", "rest", "rest", "rest-editor"))) ); }
public DamTemplatingVersionHandler() { register(DeltaBuilder.update("2.0", "") .addTask(new NodeExistsDelegateTask("Remove AssetMapModel declaration from freemarker modelFactory. With DAM 2.0 this is replaced by a normal Map", "/server/rendering/freemarker/modelFactories/damModelFactory", new RemoveNodeTask("", "/server/rendering/freemarker/modelFactories/damModelFactory")))); register(DeltaBuilder.update("2.1", "") .addTask(new InstallRendererContextAttributeTask("rendering", "freemarker", "damfn", DamTemplatingFunctions.class.getName()))); }
public MigrateValidationSelectFieldToTwinColSelectFieldTask(String name, String[] fields) { super(name); for (String field : fields) { addTask(new NodeExistsDelegateTask(String.format("Migrate 'validation' field '%s' to multi select field.", field), field, new ArrayDelegateTask("", new RemovePropertyTask(String.format("Remove property 'buttonLabel' for validation field in '%s'", field), field, "buttonLabel"), new RemovePropertyTask(String.format("Remove property 'type' for validation field in '%s'", field), field, "type"), new ValueOfPropertyDelegateTask("", field, "class", "info.magnolia.ui.form.field.definition.SelectFieldDefinition", false, new SetPropertyTask(RepositoryConstants.CONFIG, field, "class", "info.magnolia.ui.form.field.definition.TwinColSelectFieldDefinition")), new SetPropertyTask(RepositoryConstants.CONFIG, field, "leftColumnCaption", "dialog.form.edit.tabMain.validation.leftColumnCaption"), new SetPropertyTask(RepositoryConstants.CONFIG, field, "rightColumnCaption", "dialog.form.edit.tabMain.validation.rightColumnCaption") ), new WarnTask("Unable to migrate validation field", String.format(WARNING_MESSAGE_FORMAT, field))) ); } }
@Test public void testAutogeneratedDescription() throws Exception { // GIVEN Task task; // WHEN task = new NodeExistsDelegateTask("name", "/pathToCheck", new AddURIPermissionsToAllRoles(true)); // THEN assertEquals( "Execute task [Introduction of URI-based security. All existing roles will have GET/POST permissions on /*.] if node '/pathToCheck' exists or [do nothing] if not.", task.getDescription()); } }
public ObservationModuleVersionHandler() { register(DeltaBuilder.update("2.0", "") .addTask(new CheckAndModifyPropertyValueTask("Replace activation command", "Replaces old activation command with the new one provided by the activation module.", RepositoryConstants.CONFIG, "/modules/observation/config/listenerConfigurations/activateAddedPages/listener/command", "class", "info.magnolia.module.admininterface.commands.ActivationCommand", "info.magnolia.module.activation.commands.ActivationCommand")) .addTask(new CheckAndModifyPropertyValueTask("Replace node type", "Replaces the node type to be used for added pages activation from mgnl:content to mgnl:page.", RepositoryConstants.CONFIG, "/modules/observation/config/listenerConfigurations/activateAddedPages/listener", "nodeType", "mgnl:content", "mgnl:page"))); register(DeltaBuilder.update("2.0.1", "") .addTask(new ArrayDelegateTask("Move repository property", "Moves repository property for activateAddedPages configuration to command params.", new RemovePropertyTask("", "", RepositoryConstants.CONFIG, "/modules/observation/config/listenerConfigurations/activateAddedPages/listener/command", "repository"), new NodeExistsDelegateTask("", "", RepositoryConstants.CONFIG, "/modules/observation/config/listenerConfigurations/activateAddedPages/listener/params", null, new CreateNodePathTask("", "", RepositoryConstants.CONFIG, "/modules/observation/config/listenerConfigurations/activateAddedPages/listener/params")), new NewPropertyTask("", "", RepositoryConstants.CONFIG, "/modules/observation/config/listenerConfigurations/activateAddedPages/listener/params", "repository", "website")))); register(DeltaBuilder.update("2.0.2", "") .addTask(new BootstrapSingleResource("foo", "bar", "/mgnl-bootstrap/observation/setup/mail/config.modules.mail.config.templatesConfiguration.pageChangeNotification.xml")) .addTask(new UpdateSendMailOnPagesNotificationTask())); register(DeltaBuilder.update("2.1", "") .addTask(usePublicationCommand) ); }