public UpdateURI2RepositoryMappings() { super("Update URI2Repository mappings", "The structure of the URI2Repository mappings have changed in 3.5", RepositoryConstants.CONFIG, SERVER_URI2REPOSITORY_MAPPING); subTasks = new ArrayDelegateTask("Move URI2Repository mapping nodes"); }
protected Task updateSecurityBaseRolePermissions() { ArrayDelegateTask permissionsTask = new ArrayDelegateTask("Update security-base role", "Disallows access to some sensitive URIs and grants basic access to AdminCentral."); for (String path : PERMISSIONS_FOR_LEGACY_PAGES) { permissionsTask.addTask(new RemovePermissionTask("", SECURITY_BASE_ROLE, "uri", path, AddURIPermissionTask.DENY)); } permissionsTask.addTask(new RemovePermissionTask("", SECURITY_BASE_ROLE, RepositoryConstants.USER_ROLES, "/" + SECURITY_BASE_ROLE, Permission.READ)); return permissionsTask; }
@Override public void execute(InstallContext ctx) throws TaskExecutionException { try { final ModuleDefinition def = ctx.getCurrentModuleDefinition(); // register repositories for (RepositoryDefinition repDef : def.getRepositories()) { for (final String workspace : repDef.getWorkspaces()) { ArrayDelegateTask arrayDelegateTask = new ArrayDelegateTask(String.format("Bootstrap the %s if empty, grant it to superuser and subscribe it if activation is installed so that activation can be used.", workspace), new InitializeWorkspaceTask("", "", workspace), new AddPermissionTask("", "superuser", workspace, "/*", Permission.ALL, false), new SubscribeWorkspaceTask(workspace)); arrayDelegateTask.execute(ctx); } } } catch (Throwable e) { throw new TaskExecutionException("Could not bootstrap workspace: " + e.getMessage(), e); } }
/** * Moves every node to the mappings node. */ @Override protected void operateOnChildNode(Content node, InstallContext ctx) throws RepositoryException, TaskExecutionException { final String oldHandle = node.getHandle(); final String newHandle = SERVER_URI2REPOSITORY_MAPPING + "/mappings/" + node.getName(); subTasks.addTask(new MoveNodeTask("Move " + oldHandle + " to " + newHandle + "", "Moves the " + oldHandle + " node to its new location", RepositoryConstants.CONFIG, oldHandle, newHandle, true)); }
@Override public void execute(InstallContext ctx) throws TaskExecutionException { super.execute(ctx); if (info) { ctx.info("Stored a backup of node " + workspace + ":" + path + " in " + backupPath + "."); } }
/** * Creates the mappings node and delegates to the super {@link #doExecute(InstallContext)} method. */ @Override protected void doExecute(InstallContext ctx) throws RepositoryException, TaskExecutionException { final Content parentNode = getParentNode(ctx); super.doExecute(ctx); parentNode.createContent("mappings"); NodeDataUtil.getOrCreate(parentNode, "class").setValue(info.magnolia.cms.beans.config.URI2RepositoryManager.class.getName()); subTasks.execute(ctx); }
@Override protected List<Task> getExtraInstallTasks(InstallContext installContext) { final List<Task> tasks = new ArrayList<Task>(); tasks.add(new BootstrapConditionally("Observation listeners", "Installs observation listeners by keeping already existing ones, possibly provided by other modules.", "/mgnl-bootstrap/listenerConfigs/config.modules.observation.config.xml", new ArrayDelegateTask("", new PartialBootstrapTask("", "", "/mgnl-bootstrap/listenerConfigs/config.modules.observation.config.xml", "/config/listenerConfigurations/sendMailOnPageChanges"), new PartialBootstrapTask("", "", "/mgnl-bootstrap/listenerConfigs/config.modules.observation.config.xml", "/config/listenerConfigurations/activateAddedPages")))); tasks.add(usePublicationCommand); return tasks; } }
private Task getRemoveLegacyAppsTask(String name, String description) { ArrayDelegateTask removeLegacyAppsTask = new ArrayDelegateTask(name, description); try { Node appsNode = SessionUtil.getNode(RepositoryConstants.CONFIG, "/modules/ui-admincentral/config/appLauncherLayout/groups/data/apps"); if (appsNode != null) { NodeIterator nodeIterator = appsNode.getNodes(); while (nodeIterator.hasNext()) { String appName = ((Node) nodeIterator.next()).getName(); removeLegacyAppsTask.addTask(new RemoveNodeTask("Remove data legacy app " + appName, "This removes configuration for the data legacy app " + appName, RepositoryConstants.CONFIG, "/modules/ui-admincentral/apps/" + appName)); removeLegacyAppsTask.addTask(new RemoveNodeTask("Remove " + appName + " launcher", "This task removes the applauncher configuration for the data legacy app " + appName, RepositoryConstants.CONFIG, "/modules/ui-admincentral/config/appLauncherLayout/groups/data/apps/" + appName)); } } } catch (RepositoryException e) { log.warn("Couldn't fetch data app configuration in appLauncherLayout", e); } return removeLegacyAppsTask; }
@Override public void execute(InstallContext installContext) throws TaskExecutionException { final ModuleDefinition moduleDefinition = installContext.getCurrentModuleDefinition(); // register servlets for (ServletDefinition servletDefinition : moduleDefinition.getServlets()) { addTask(new RegisterServletTask(servletDefinition)); } super.execute(installContext); } }
protected List<Task> getCommonTasks() { final List<Task> commonTasks = new ArrayList<>(); commonTasks.add(new IsInstallSamplesTask("Re-Bootstrap website content for sample pages", "Re-bootstrap website content to account for all changes", new ArrayDelegateTask("", new BootstrapSingleResource("", "", "/mgnl-bootstrap-samples/samples/website.ftl-sample-site.xml"), new BootstrapSingleResource("", "", "/mgnl-bootstrap-samples/samples/dam.samples.xml", ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING)))); // We re-bootstrap twice because a simple (and single) re-bootstrap (using ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING) would NOT // "move" an existing site definition (which might actually exist from a previous version) in the site module commonTasks.add(new BootstrapSingleModuleResource("config.modules.samples.config.xml", ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING)); commonTasks.add(new BootstrapSingleModuleResource("config.modules.samples.config.xml", ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW)); return commonTasks; }
private Task getSampleRegistrationTypeTask(Task... additionalTasks) { ArrayDelegateTask task = new ArrayDelegateTask("", "", new RegisterNodeTypeTask("company"), new RegisterNodeTypeTask("department"), new RegisterNodeTypeTask("employees"), new RegisterNodeTypeTask("director"), new RegisterNodeTypeTask("manager"), new RegisterNodeTypeTask("developer")); for (Task t : additionalTasks) { task.addTask(t); } return new IsInstallSamplesTask("Samples installation", "Register sample of hierarchical node types", task); } }
public ReplaceIfExistsTask(String name, String description, String warningMessageIfNotExisting, String workspaceName, String pathToCheck, String bootstrapFile) { super(name, description, workspaceName, pathToCheck, new ArrayDelegateTask("", new RemoveNodeTask("", "", workspaceName, pathToCheck), new BootstrapSingleResource(name, description, bootstrapFile) ), new WarnTask(name, warningMessageIfNotExisting)); } }
@Override protected List<Task> getExtraInstallTasks(InstallContext installContext) { List<Task> list = new ArrayList<Task>(); // We have to enable PUT/DELETE method in /server/IPConfig/allow-all.methods list.add(new CheckAndModifyPropertyValueTask("Enable PUT method", "Enables PUT method in '/server/IPConfig/allow-all.methods'", RepositoryConstants.CONFIG, "/server/IPConfig/allow-all", "methods", "GET,POST", "GET,POST,PUT,DELETE")); list.add(new ArrayDelegateTask("Update 'rest-editor' role", new AddPermissionTask("Update 'rest-editor' role", "Allows access to the REST API documentation interface residing under '/.rest/api-docs' in role 'rest-editor'.", "rest-editor", "uri", "/.rest/commands*", Permission.NONE, false), new AddPermissionTask("Update 'rest-editor' role", "Denies access to the 'nodes' endpoint.", "rest-editor", "uri", "/.rest/nodes*", Permission.NONE, false), new AddPermissionTask("Update 'rest-editor' role", "Allows access to the 'nodes' endpoint for workspace 'website'.", "rest-editor", "uri", "/.rest/nodes/v1/website*", Permission.ALL, false), new AddPermissionTask("Update 'rest-editor' role", "Denies access to the 'properties' endpoint.", "rest-editor", "uri", "/.rest/properties*", Permission.NONE, false), new AddPermissionTask("Update 'rest-editor' role", "Allows access to the 'nodes' properties for workspace 'website'.", "rest-editor", "uri", "/.rest/properties/v1/website*", Permission.ALL, false) )); return list; }
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))))); }
tasks.add(new IsModuleInstalledOrRegistered("Configure STK site for multisite", "multisite", new NodeExistsDelegateTask("Check if stk can be moved to the multisite", "/modules/standard-templating-kit/config/site", new ArrayDelegateTask("", "", new NodeExistsDelegateTask("Check for default site", "Check whether default site already exists or not - if no, site from stk will be copied to multisite", RepositoryConstants.CONFIG, "/modules/multisite/config/sites/default", new WarnTask("Default already site exists", "Default site already exists. No actions will be taken."), new ArrayDelegateTask("", "", new CreateNodePathTask("", "/modules/multisite/config/sites/", NodeTypes.ContentNode.NAME), new CopyNodeTask("Default site configuration", "Copy the configuration of the STK site", "config", "/modules/standard-templating-kit/config/site", "/modules/multisite/config/sites/default", false),
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))) ); } }
)); tasks.add(new AppLauncherReorderingTask("assets", "edit", Order.AFTER, "pages")); tasks.add(new ArrayDelegateTask("Configure icons for assets app", new NodeExistsDelegateTask("", "/server/MIMEMapping/txt", new SetPropertyTask(RepositoryConstants.CONFIG, "/server/MIMEMapping/txt", "iconStyle", "icon-file-text")),
public SiteModuleVersionHandler() { register(DeltaBuilder.update("1.0.1", "") .addTask(updateI18nContentSupport)); register(DeltaBuilder.update("1.0.3", "") .addTask(new NodeExistsDelegateTask("Create empty site definition node if it does not exist", "/modules/site/config/site", null, new BootstrapSingleModuleResource("config.modules.site.config.site.xml")))); register(DeltaBuilder.update("1.0.5", "") .addTask(new BootstrapConditionally("Add site-aware JSP renderer if it does not exist", "/mgnl-bootstrap/site/config.modules.site.renderers.site-jsp.xml")) .addTask(new PropertyValueDelegateTask("Reconfigure site renderer to delegate to freemarker renderer", "/modules/site/renderers/site", "class", SiteAwareFreemarkerRenderer.class.getName(), true, new ArrayDelegateTask("", new SetPropertyTask(RepositoryConstants.CONFIG, "/modules/site/renderers/site", "wrappedRendererType", "freemarker"), new SetPropertyTask(RepositoryConstants.CONFIG, "/modules/site/renderers/site", "class", SiteAwareRendererWrapper.class.getName()), new RemoveNodeTask("", "/modules/site/renderers/site/contextAttributes"), new RemovePropertyTask("", "/modules/site/renderers/site/", "type")))) .addTask(orderSiteMergeFilter) //fix incorrect order of siteMerge filter after update from M5.3 which is before multiSite filter ); register(DeltaBuilder.update("1.1", "") .addTask(new NodeExistsDelegateTask("Remove themes folder if empty", "Location /modules/site/config/themes is deprecated but still supported", RepositoryConstants.CONFIG, "/modules/site/config/themes", new RemoveNodeWithoutChildren("/modules/site/config/themes")))); }
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")) )); }
.addTask(new ArrayDelegateTask("Remove deprecated configuration", new RemoveNodeTask("Remove obsolete compressible configuration.", "/" + OBSOLETE_COMPRESSIBLE_CONFIGURATION_PATH), new MoveNodeTask("", OBSOLETE_DEFAULT_CONFIGURATION_PATH + "cachePolicy/voters", OBSOLETE_DEFAULT_CONFIGURATION_PATH + "cachePolicy/shouldBypassVoters", false), )) .addTask(new ArrayDelegateTask("Renaming of 'configurations' to 'contentCaching'", String.format("Renames the 'configurations' nodes of the cache module to 'contentCaching'. Also renames the 'cacheConfigurationName' property of the cache filter to '%s'.", AbstractCacheModule.DEFAULT_CACHE_CONFIG), new RenameNodeTask("", RepositoryConstants.CONFIG, "/modules/cache/config", "configurations", "contentCaching", false), ); register(DeltaBuilder.update("5.5.2", "") .addTask(new ArrayDelegateTask("Disable browser cache only when magnolia.develop=true", new RemoveNodeTask("", "/modules/cache/config/contentCaching/defaultPageCache/browserCachePolicy/policies/never"), new PartialBootstrapTask("", "/mgnl-bootstrap/cache/config.modules.cache.config.contentCaching.defaultPageCache.xml", "/defaultPageCache/browserCachePolicy/policies/disableBrowserCacheInDevelopMode"), .addTask(new BootstrapSingleModuleResource("config.modules.cache.config.contentCaching.defaultPageCache.flushPolicy.policies.lightModule.xml")) .addTask(new NodeExistsDelegateTask("If compression config exists, update JS mime types", "/modules/cache/config/compression/voters/contentType/allowed", new ArrayDelegateTask("Update compression config", new CheckOrCreatePropertyTask("Add gzip support for new JS mime type", "/modules/cache/config/compression/voters/contentType/allowed", "4", "application/javascript"), new HasPropertyDelegateTask("If javascript property is present...", BROWSER_CACHE_POLICIES_CONTENT_TYPE_ALLOWED, "javascript", new ArrayDelegateTask("Rename property and set new value", new RenamePropertyTask("Rename old JS mimetype property in caching policy", RepositoryConstants.CONFIG, BROWSER_CACHE_POLICIES_CONTENT_TYPE_ALLOWED, "javascript", "x-javascript", true),