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"))) ); }
@Override public void execute(InstallContext ctx) { try { final Session session = ctx.getJCRSession(workspaceName); final Node node = session.getNode(nodePath); checkAndModifyPropertyValue(ctx, node, propertyName, expectedCurrentValues, newValue); } catch (RepositoryException e) { ctx.error(format("Could not check property {0} of node at {1}. Please create it with value {2}.", propertyName, nodePath, newValue), e); } } }
@Test public void nonExistingPropertyDoesNotThrowNullPointerException() throws Exception { // GIVEN final CheckAndModifyPropertyValueTask task = new CheckAndModifyPropertyValueTask("", "", "config", "/foo", "bar", "old-value", "newValue"); // WHEN // THEN no NPE is thrown assertThat(() -> task.execute(installContext), throwsNothing()); }
public UpdateSendMailOnPagesNotificationTask() { super("Update sendMailOnPageChanges configuration", "Updates sendMailOnPageChanges listener configuration in order to use a freemarker template for sending an email.", new RemovePropertyTask("", "", RepositoryConstants.CONFIG, listenerParams, "from"), new RemovePropertyTask("", "", RepositoryConstants.CONFIG, listenerParams, "subject"), new RemovePropertyTask("", "", RepositoryConstants.CONFIG, listenerParams, "text"), new PropertyExistsDelegateTask("", "", RepositoryConstants.CONFIG, listenerParams, "type", new CheckAndModifyPropertyValueTask("", "", RepositoryConstants.CONFIG, listenerParams, "type", "text", "freemarker")), new PropertyExistsDelegateTask("", "", RepositoryConstants.CONFIG, listenerParams, "mailTemplate", new SetPropertyTask("", RepositoryConstants.CONFIG, listenerParams, "mailTemplate", "pageChangeNotification")), new PartialBootstrapTask("", "", "/mgnl-bootstrap/listenerConfigs/config.modules.observation.config.xml", "/config/listenerConfigurations/sendMailOnPageChanges/listener/params/model")); } }
@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; }
@Test public void autoGeneratedDescription() throws Exception { // GIVEN Task task = new CheckAndModifyPropertyValueTask("/nodePath", "propertyName", "expectedCurrentValue", "newValue"); // WHEN // THEN assertEquals("Changes property '/nodePath/propertyName' to 'newValue' if it has value 'expectedCurrentValue'.", task.getDescription()); }
new CheckAndModifyPropertyValueTask("", "", RepositoryConstants.CONFIG, "/modules/standard-templating-kit/config/site/templates/prototype/areas/main/areas/comments/availableComponents/stkComments", "id", "standard-templating-kit:components/features/stkComments", "commenting:components/comments"))); tasks.add(new STKLegacyUiToMagnolia5AppProviderTask("Provide STK with a Magnolia 5 UI", "Turns legacy UI into a Magnolia 5 browser app.")); tasks.add(new OrderNodeAfterTask("STK AppLauncher group ordering", "Moves the stk app group after the tools group", RepositoryConstants.CONFIG, "/modules/ui-admincentral/config/appLauncherLayout/groups/stk", "tools"));
new CheckAndModifyPropertyValueTask("/modules/standard-templating-kit/templates/components/pur/stkPURPasswordChangeForm", "modelClass", "info.magnolia.module.publicuserregistration.frontend.action.RegistrationModel", "info.magnolia.module.form.templates.components.FormModel"))) .addTask(new NodeExistsDelegateTask("Update template 'stkPURPasswordForm'", "/modules/standard-templating-kit/templates/components/pur/stkPURPasswordForm", new CheckAndModifyPropertyValueTask("/modules/standard-templating-kit/templates/components/pur/stkPURPasswordForm", "modelClass", "info.magnolia.module.publicuserregistration.frontend.action.RegistrationModel", "info.magnolia.module.form.templates.components.FormModel"))) .addTask(new NodeExistsDelegateTask("Update template 'stkPURRegistrationForm'", "/modules/standard-templating-kit/templates/components/pur/stkPURRegistrationForm", new CheckAndModifyPropertyValueTask("/modules/standard-templating-kit/templates/components/pur/stkPURRegistrationForm", "modelClass", "info.magnolia.module.publicuserregistration.frontend.action.RegistrationModel", "info.magnolia.module.form.templates.components.FormModel"))) .addTask(new NodeExistsDelegateTask("Update template 'stkPURUpdateForm'", "/modules/standard-templating-kit/templates/components/pur/stkPURUpdateForm", new CheckAndModifyPropertyValueTask("/modules/standard-templating-kit/templates/components/pur/stkPURUpdateForm", "modelClass", "info.magnolia.module.publicuserregistration.frontend.action.RegistrationModel", "info.magnolia.module.form.templates.components.FormModel")))
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) ); }
.addTask(new CheckAndModifyPropertyValueTask("Config", "Commands configuration", RepositoryConstants.CONFIG, "/modules/inplace-templating/commands/templating/versionTemplate/extractComment", "class", Arrays.asList("info.magnolia.module.inplacetemplating.ExtractCommentCommand", "info.magnolia.module.admininterface.commands.ExtractCommentCommand"), "info.magnolia.commands.impl.ExtractCommentCommand"))); new CheckAndModifyPropertyValueTask("/modules/inplace-templating/apps/inplace-templating/subApps/detail/editor/form/tabs/content/fields/text", "class", "info.magnolia.ui.form.field.definition.BasicTextCodeFieldDefinition", CodeFieldDefinition.class.getName()))));
"Add plaintext renderer Attribute", "/mgnl-bootstrap/templating/config.modules.templating.renderers.plaintext.xml")) .addTask(new CheckAndModifyPropertyValueTask( "Update implementation for accessing template definition parameters", "Change class for RenderableDefinitionModel",
new RemoveNodeTask("", "", RepositoryConstants.CONFIG, "/modules/activation/apps/activationMonitor")), new PropertyExistsDelegateTask("Update appClass from 'info.magnolia.ui.framework.app.BaseApp' to 'info.magnolia.module.activation.app.ActivationBaseApp'", "", RepositoryConstants.CONFIG, "/modules/activation/apps/activation", "appClass", new CheckAndModifyPropertyValueTask("", "", RepositoryConstants.CONFIG, "/modules/activation/apps/activation", "appClass", BaseApp.class.getName(), ActivationBaseApp.class.getName())) )) );
new CheckAndModifyPropertyValueTask("/modules/rssaggregator/templates/components/feedStatistics", "renderType", "stk", "freemarker"))) .addTask(new NodeExistsDelegateTask("Updates renderType of component feedSubscriptions", "/modules/rssaggregator/templates/components/feedSubscriptions", new CheckAndModifyPropertyValueTask("/modules/rssaggregator/templates/components/feedSubscriptions", "renderType", "stk", "freemarker"))) .addTask(new NodeExistsDelegateTask("Updates renderType of component feedSyndication", "/modules/rssaggregator/templates/components/feedSyndication", new CheckAndModifyPropertyValueTask("/modules/rssaggregator/templates/components/feedSyndication", "renderType", "stk", "freemarker"))) .addTask(new NodeExistsDelegateTask("Updates renderType of component planetFeeds", "/modules/rssaggregator/templates/components/planetFeeds", new CheckAndModifyPropertyValueTask("/modules/rssaggregator/templates/components/planetFeeds", "renderType", "stk", "freemarker"))) .addTask(new NodeExistsDelegateTask("Updates class of templateContent feed generator", "/modules/rssaggregator/config/feedGenerators/templateContent", new CheckAndModifyPropertyValueTask("/modules/rssaggregator/config/feedGenerators/templateContent", "class", "info.magnolia.module.templatingkit.syndication.PageSyndicator", PageSyndicator.class.getName()))) .addTask(new NodeExistsDelegateTask("Updates extended tabPagination of planetFeeds dialog", "/modules/rssaggregator/dialogs/planetFeeds/form/tabs/tabPagination", new CheckAndModifyPropertyValueTask("/modules/rssaggregator/dialogs/planetFeeds/form/tabs/tabPagination", "extends", "/modules/standard-templating-kit/dialogs/generic/pages/tabPagination", "/modules/mte/dialogs/generic/tabPagination"))));
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.10", "") .addTask(new NodeExistsDelegateTask("Change validators email expression data", "Change data (^$|^\\S+@\\S+$) in /modules/form/config/validators/email/expression from to (^([a-zA-Z0-9_\\.\\-+])+@(([a-zA-Z0-9-])+\\.)+([a-zA-Z0-9]{2,4})+$).", RepositoryConstants.CONFIG, PATH_VALIDATORS_EMAIL, new CheckAndModifyPropertyValueTask(PATH_VALIDATORS_EMAIL, "expression", "(^$|^\\S+@\\S+$)", "(^([a-zA-Z0-9_\\.\\-+])+@(([a-zA-Z0-9-])+\\.)+([a-zA-Z0-9]{2,4})+$)"))) ); .addTask(new ArrayDelegateTask("Replace deprecated BasicTextCodeFieldDefinition to CodeFieldDefinition", new NodeExistsDelegateTask("", "/modules/form/dialogs/form/form/tabs/tabContactEmail/fields/contentType/fields/html", new CheckAndModifyPropertyValueTask("/modules/form/dialogs/form/form/tabs/tabContactEmail/fields/contentType/fields/html", "class", "info.magnolia.ui.form.field.definition.BasicTextCodeFieldDefinition", CodeFieldDefinition.class.getName())), new NodeExistsDelegateTask("", "/modules/form/dialogs/form/form/tabs/tabConfirmEmail/fields/confirmContentType/fields/code", new CheckAndModifyPropertyValueTask("/modules/form/dialogs/form/form/tabs/tabConfirmEmail/fields/confirmContentType/fields/code", "class", "info.magnolia.ui.form.field.definition.BasicTextCodeFieldDefinition", CodeFieldDefinition.class.getName())) new CheckAndModifyPropertyValueTask("/modules/form/templates/components/formSummary", "modelClass", "info.magnolia.module.form.templates.components.FormSummaryModel", FormSummaryParagraphModel.class.getName()))) );
new CheckAndModifyPropertyValueTask("Update template", "Update template to new name", ResourcesModule.DEFAULT_WORKSPACE, "/sample-css/MetaData", "mgnl:template", ResourceTypes.PROCESSED_CSS_SUFFIX, ResourceTypes.PROCESSED_CSS)))); .addTask(new CheckAndModifyPropertyValueTask( "Update component class", "Update cms context attribute/componentClass in text resource renderer", "config", "/modules/resources/renderers/textResource/contextAttributes/cms/", "componentClass", "info.magnolia.templating.freemarker.Directives", new CheckAndModifyPropertyValueTask("Update extractComment commands class", "Commands configuration", RepositoryConstants.CONFIG, "/modules/resources/commands/resources/versionResources/extractComment", "class", Arrays.asList("info.magnolia.module.resources.commands.ExtractCommentCommand", "info.magnolia.module.admininterface.commands.ExtractCommentCommand"), "info.magnolia.commands.impl.ExtractCommentCommand"))));
new OrderNodeAfterTask("", "", RepositoryConstants.CONFIG, "/modules/contacts/apps/contacts/subApps/browser/actionbar/sections/contact/groups/versionsActions/items/restoreVersion", "showVersions"))))) .addTask(new CheckAndModifyPropertyValueTask("/modules/contacts/apps/contacts", "class", ConfiguredAppDescriptor.class.getName(), ConfiguredContentAppDescriptor.class.getName())) .addTask(new CheckAndModifyPropertyValueTask("/modules/contacts/apps/contacts/subApps/detail", "subAppClass", DetailSubApp.class.getName(), ContactDetailSubApp.class.getName()))); .addTask(new SetWritePermissionForActionsTask("/modules/contacts/apps/contacts/subApps/browser/actions/", "addContact", "editContact", "delete", "addFolder", "editFolder", "renameContact", "activate", "deactivate", "import", "restorePreviousVersion", "activateDeleted", "restoreVersion", "confirmDeleteContact")) .addTask(new NodeExistsDelegateTask("Change zip code type value. From Long to String", "", RepositoryConstants.CONFIG, "/modules/contacts/apps/contacts/subApps/detail/editor/form/tabs/address/fields/zipCode", new CheckAndModifyPropertyValueTask("/modules/contacts/apps/contacts/subApps/detail/editor/form/tabs/address/fields/zipCode", "type", "Long", "String")))); new CheckAndModifyPropertyValueTask("/modules/contacts/apps/contacts/subApps/browser/actions/confirmDeleteContact", "class", ConfirmationActionDefinition.class.getName(), DeleteConfirmationActionDefinition.class.getName()))));
new CheckAndModifyPropertyValueTask("", "", RepositoryConstants.CONFIG, "/server/filters/cache", AbstractCacheModule.DEFAULT_CACHE_CONFIG, "default", "defaultPageCache") .addTask(new RemoveNodeWoChildren("Remove pages node if there are no pages registered.", "/modules/cache/pages")) .addTask(new RemoveVirtualUriMappingTask()) .addTask(new CheckAndModifyPropertyValueTask("Browser cache policy for far-future caching", "Fixes pattern for far-future browser cache policy.", RepositoryConstants.CONFIG, "/modules/cache/config/contentCaching/defaultPageCache/browserCachePolicy/policies/farFuture/voters/dotCacheExtension", "pattern", ".*\\.cache\\.[^\\.]*", ".*[~.]cache\\.[^\\.]*")) );
.addTask(new CheckAndModifyPropertyValueTask("Rendering filter", "The rendering filter is now part of the templating module.", ContentRepository.CONFIG, "/server/filters/cms/rendering", "class", "info.magnolia.cms.filters.RenderingFilter", "info.magnolia.module.templating.RenderingFilter")) .addTask(new BootstrapSingleResource("Freemarker Model for RenderableDefinition", "Plugs in a specific Freemarker model for RenderableDefinition implementations.", "/mgnl-bootstrap/templating/config.server.rendering.freemarker.modelFactories.renderable.xml")) .addTask(new RenamePropertyAllModulesNodeTask("Templates configuration", "Property path is now templatePath.", "templates", "path", "templatePath"))
new CheckAndModifyPropertyValueTask("/modules/categorization/templates/components/catCloud", "renderType", "stk", "freemarker"))) .addTask(new NodeExistsDelegateTask("Updates renderType of component catCloudWide", "/modules/categorization/templates/components/catCloudWide", new CheckAndModifyPropertyValueTask("/modules/categorization/templates/components/catCloudWide", "renderType", "stk", "freemarker"))) .addTask(new NodeExistsDelegateTask("Updates renderType of component catCloudExtras", "/modules/categorization/templates/components/catCloudExtras", new CheckAndModifyPropertyValueTask("/modules/categorization/templates/components/catCloudExtras", "renderType", "stk", "freemarker"))) .addTask(new NodeExistsDelegateTask("Updates renderType of component categoryRSSFeed", "/modules/categorization/templates/components/categoryRSSFeed", new CheckAndModifyPropertyValueTask("/modules/categorization/templates/components/categoryRSSFeed", "renderType", "stk", "freemarker"))) .addTask(new InstallRendererContextAttributeTask("rendering", "freemarker", "catfn", CategorizationTemplatingFunctions.class.getName())) );
.addTask(new IsModuleInstalledOrRegistered("Use PublicationCommand when publishing-core installed.", "publishing-core", new NodeExistsDelegateTask("Use PublicationCommand instead of ActivationCommand when publishing-core is installed.", "/modules/forum/commands/forum/activate", new CheckAndModifyPropertyValueTask("/modules/forum/commands/forum/activate", "class", "info.magnolia.module.activation.commands.ActivationCommand", "info.magnolia.publishing.command.PublicationCommand")))) );