public AddMailTemplateTask(String templateName, String description, String from, String subject, String templatePath, String type) { super("Mail template", "Adds the " + templateName + " " + description + ".", new CreateNodeTask(null, null, RepositoryConstants.CONFIG, "/modules/mail/config/templatesConfiguration", templateName, NodeTypes.ContentNode.NAME), new NewPropertyTask(null, null, RepositoryConstants.CONFIG, "/modules/mail/config/templatesConfiguration/" + templateName, "from", from), new NewPropertyTask(null, null, RepositoryConstants.CONFIG, "/modules/mail/config/templatesConfiguration/" + templateName, "subject", subject), new NewPropertyTask(null, null, RepositoryConstants.CONFIG, "/modules/mail/config/templatesConfiguration/" + templateName, "templateFile", templatePath), new NewPropertyTask(null, null, RepositoryConstants.CONFIG, "/modules/mail/config/templatesConfiguration/" + templateName, "type", type)); } }
@Override public void execute(InstallContext ctx) { try { final Session session = ctx.getJCRSession(workspaceName); final Node node = session.getNode(nodePath); newProperty(ctx, node, propertyName, value); } catch (RepositoryException e) { ctx.error(format("Could not create property {0} at {1}, please create it with value {2}.", propertyName, nodePath, value), e); } } }
@Override protected void doExecute(InstallContext ctx) throws RepositoryException, TaskExecutionException { Session session = ctx.getJCRSession(RepositoryConstants.CONFIG); for (Node node : NodeUtil.getNodes(session.getRootNode().getNode("server").getNode("security").getNode("userManagers"), NodeTypes.ContentNode.NAME)) { if (node.hasProperty("class")) { String className = node.getProperty("class").getString(); if (className.equals("info.magnolia.cms.security.MgnlUserManager") || className.equals("info.magnolia.cms.security.SystemUserManager")) { Task updateTask = new HasPropertyDelegateTask("", "", RepositoryConstants.CONFIG, "/server" + StringUtils.substringAfter(node.getPath(), "/server"), "maxFailedLoginAttempts", null, new NewPropertyTask("", "", RepositoryConstants.CONFIG, "/server" + StringUtils.substringAfter(node.getPath(), "/server"), "maxFailedLoginAttempts", "5")); Task updateTask2 = new HasPropertyDelegateTask("", "", RepositoryConstants.CONFIG, "/server" + StringUtils.substringAfter(node.getPath(), "/server"), "lockTimePeriod", null, new NewPropertyTask("", "", RepositoryConstants.CONFIG, "/server" + StringUtils.substringAfter(node.getPath(), "/server"), "lockTimePeriod", "0")); updateTask.execute(ctx); updateTask2.execute(ctx); } } } } }
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))))); }
@Test public void testWithoutThePath() throws Exception { // GIVEN Task task = new NewPropertyTask("", "", RepositoryConstants.CONFIG, "/test1", "testProp", "testValue"); // WHEN task.execute(installContext); // THEN verify(installContext).error(eq("Could not create property testProp at /test1, please create it with value testValue."), isA(PathNotFoundException.class)); } }
@Test public void testAutogeneratedDescription() throws Exception { // GIVEN Task task; // WHEN task = new NewPropertyTask("name", "/nodePath", "propertyName", "value"); // THEN assertEquals("Create property 'config:/nodePath/propertyName' with value 'value'.", task.getDescription()); }
@Test public void testWithExpectedPathExisting() throws Exception { // GIVEN Task task = new NewPropertyTask("", "", RepositoryConstants.CONFIG, "/test", "testProp", "testValue"); // WHEN task.execute(installContext); // THEN assertThat(sessionMock.getNode("/test"), hasProperty("testProp")); }
new RemoveNodeTask("", "", RepositoryConstants.CONFIG, "/modules/ui-admincentral/config/appLauncherLayout/groups/tools/apps/activationMonitor")), new NodeExistsDelegateTask("Add subApps labels", "", RepositoryConstants.CONFIG, "/modules/activation/apps/activation/subApps/activation", new NewPropertyTask("", "", RepositoryConstants.CONFIG, "/modules/activation/apps/activation/subApps/activation", "label", "Tools")), new NodeExistsDelegateTask("Add subApps labels", "", RepositoryConstants.CONFIG, "/modules/activation/apps/activation/subApps/monitor", new NewPropertyTask("", "", RepositoryConstants.CONFIG, "/modules/activation/apps/activation/subApps/monitor", "label", "Monitor")), new NodeExistsDelegateTask("Delete activationMonitor App from activation apps", "", RepositoryConstants.CONFIG, "/modules/activation/apps/activationMonitor", new RemoveNodeTask("", "", RepositoryConstants.CONFIG, "/modules/activation/apps/activationMonitor")),
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) ); }
new ArrayDelegateTask("", new MoveNodeTask("", "", RepositoryConstants.USERS, "/anonymous", "/system/anonymous", false), new NewPropertyTask("Anonymous user", "Anonymous user must have a password.", RepositoryConstants.USERS, "/system/anonymous", "pswd", new String(Base64.encodeBase64("anonymous".getBytes()))) )),
.addTask(new NodeExistsDelegateTask("Change validators email expression data", "Change data ^\\S+@\\S+$ in /modules/form/config/validators/email/expression from to (^$|^\\S+@\\S+$).", RepositoryConstants.CONFIG, PATH_VALIDATORS_EMAIL, new CheckAndModifyPropertyValueTask(PATH_VALIDATORS_EMAIL, "expression", "^\\S+@\\S+$", "(^$|^\\S+@\\S+$)"))) .addTask(new NodeExistsDelegateTask("Add default value to HoneyPot field", "/modules/form/dialogs/formHoneypot/form/tabs/tabMain/fields/validation", new NewPropertyTask("Add default value to HoneyPot field", "/modules/form/dialogs/formHoneypot/form/tabs/tabMain/fields/validation", "defaultValue", "empty"))) ); ); register(DeltaBuilder.update("2.2.7", "") .addTask(new NewPropertyTask("Escape Html", "Skips the default HTML escaping in password component.", RepositoryConstants.CONFIG, "/modules/form/templates/components/formPassword", "escapeHtml", false))); .addTask(new NewPropertyTask("Set template class to formPassword field", "/modules/form/templates/components/formPassword", "class", FormFieldTemplate.class.getName())));
.addTask(new PartialBootstrapTask("Bootstrap action", "Place import action to action bar", "/mgnl-bootstrap/rssaggregator/app/config.modules.rssaggregator.apps.xml", "/apps/rssAggregator/subApps/browser/actionbar/sections/rssAggregator/groups/feedImportActions", ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW)) .addTask(new OrderNodeBeforeTask("Order action bar", "Place import feed action to proper place", RepositoryConstants.CONFIG, "/modules/rssaggregator/apps/rssAggregator/subApps/browser/actionbar/sections/rssAggregator/groups/feedImportActions", "importExportActions")) .addTask(new NodeExistsDelegateTask("Add property", "Add property for vertical layout of fields", RepositoryConstants.CONFIG, "/modules/rssaggregator/apps/rssAggregator/subApps/detail/editor/form/tabs/mainTab/fields/feeds/field", new NewPropertyTask("", "", RepositoryConstants.CONFIG, "/modules/rssaggregator/apps/rssAggregator/subApps/detail/editor/form/tabs/mainTab/fields/feeds/field", "layout", "vertical"))) .addTask(new NodeExistsDelegateTask("Add property", "Add property for vertical layout of fields", RepositoryConstants.CONFIG, "/modules/rssaggregator/apps/rssAggregator/subApps/detail/editor/form/tabs/mainTab/fields/filters/field", new NewPropertyTask("", "", RepositoryConstants.CONFIG, "/modules/rssaggregator/apps/rssAggregator/subApps/detail/editor/form/tabs/mainTab/fields/filters/field", "layout", "vertical"))) .addTask(new NodeExistsDelegateTask("Change save action", "Replace form save action with RSS specific one.", RepositoryConstants.CONFIG, "/modules/rssaggregator/apps/rssAggregator/subApps/detail/actions/commit", new SetPropertyTask("", RepositoryConstants.CONFIG, "/modules/rssaggregator/apps/rssAggregator/subApps/detail/actions/commit", "implementationClass", "info.magnolia.module.rssaggregator.action.SaveRSSAction"))) .addTask(new NodeExistsDelegateTask("Add transformer", "Add proper transformer class for name field.", RepositoryConstants.CONFIG, "/modules/rssaggregator/apps/rssAggregator/subApps/detail/editor/form/tabs/mainTab/fields/name", new SetPropertyTask("", RepositoryConstants.CONFIG, "/modules/rssaggregator/apps/rssAggregator/subApps/detail/editor/form/tabs/mainTab/fields/name", "transformerClass", "info.magnolia.module.rssaggregator.action.RSSBasicTransformer")))
.addTask(new PartialBootstrapTask("Bootstrap new actionbar section in Contacts app.", "", "/mgnl-bootstrap/contacts/config.modules.contacts.apps.contacts.xml", "/contacts/subApps/browser/actionbar/sections/multiple")) .addTask(new PartialBootstrapTask("Bootstrap new action in Contacts app.", "", "/mgnl-bootstrap/contacts/config.modules.contacts.apps.contacts.xml", "/contacts/subApps/browser/actions/confirmDeleteItems")) .addTask(new NewPropertyTask("Set Delete actions multi-item", "Sets multiple=true in ConfirmDelete actions' availability, i.e. Delete action now supports multiple items.", RepositoryConstants.CONFIG, "/modules/contacts/apps/contacts/subApps/browser/actions/confirmDeleteContact/availability", "multiple", "true"))
.addTask(new BootstrapSingleModuleResource("Bootstrap new actionbar section in Categories app.", "", "config.modules.categorization.apps.categories.xml", "/categories/subApps/browser/actionbar/sections/multiple")) .addTask(new BootstrapSingleModuleResource("Bootstrap new action in Categories app.", "", "config.modules.categorization.apps.categories.xml", "/categories/subApps/browser/actions/confirmDeleteItems")) .addTask(new NewPropertyTask("Set Delete actions multi-item", "Sets multiple=true in ConfirmDelete actions' availability, i.e. Delete action now supports multiple items.", RepositoryConstants.CONFIG, "/modules/categorization/apps/categories/subApps/browser/actions/confirmDeleteCategory/availability", "multiple", "true")) .addTask(new NodeExistsDelegateTask("", "", RepositoryConstants.CONFIG, "/modules/categorization/apps/categories/subApps/browser/actions/activate", new NewPropertyTask("Set recursive publication action", "Sets recursive=true in Publication actions, i.e. Publication action now also published the related category .", RepositoryConstants.CONFIG, "/modules/categorization/apps/categories/subApps/browser/actions/activate", "recursive", "true"))));
.addTask(new NewPropertyTask("Set Delete actions multi-item", "Sets multiple=true in ConfirmDelete actions' availability, i.e. Delete action now supports multiple items.", RepositoryConstants.CONFIG, "/modules/dam/apps/assets/subApps/browser/actions/confirmDeleteAsset/availability", "multiple", "true"))