public CacheModuleVersionHandler() { register(DeltaBuilder.checkPrecondition("4.4.6", "4.5")); register(DeltaBuilder.update("4.5", "") .addTask(placeGzipFitler) .addTask(placeCacheFilter) .addTask(new BootstrapSingleResource( "Register Virtual Uri Mapping", "Add Virtual Uri for static resources", "/mgnl-bootstrap/cache/config.modules.cache.virtualURIMapping.xml")) ); }
/** * The minimal delta to be applied for each update, even if no delta was specifically registered * for the version being installed. */ protected Delta getDefaultUpdate(InstallContext installContext) { final Version toVersion = installContext.getCurrentModuleDefinition().getVersion(); final List<Task> defaultUpdateTasks = getDefaultUpdateTasks(toVersion); final List<Condition> defaultUpdateConditions = getDefaultUpdateConditions(toVersion); return DeltaBuilder.update(toVersion, "").addTasks(defaultUpdateTasks).addConditions(defaultUpdateConditions); }
public static DeltaBuilder checkPrecondition(String minimalVersion, String newVersion) { return update(minimalVersion, "minimal version required for updating to " + newVersion).addCondition( new FalseCondition("checkPrerequisite", "Updating to " + newVersion + " is only supported from " + minimalVersion + " or higher.")); }
register(DeltaBuilder.update("4.0", "New samples module, replaces the old one.") .addTask(new NodeExistsDelegateTask("Backup samples config", "Creates a backup", "config", "/modules/samples", new BackupTask("config", "/modules/samples", true))) .addTask(new NodeExistsDelegateTask("Backup samples website samples", "Creates a backup", "website", "/help", new BackupTask("website", "/help", true))) .addTask(new NodeExistsDelegateTask("Backup samples website samples", "Creates a backup", "website", "/mailform", new BackupTask("website", "/mailform", true))) .addTask(new NodeExistsDelegateTask("Backup samples website samples", "Creates a backup", "website", "/mails", new BackupTask("website", "/mails", true))) .addTask(new BootstrapResourcesTask("New configuration", "Bootstraps new default samples configuration.") { protected String[] getResourcesToBootstrap(final InstallContext installContext) { return new String[]{ .addTask(new BootstrapSingleResource("Sample VirtualUri", "Adds a sample", "/mgnl-bootstrap-samples/samples/config.modules.samples.virtualURIMapping.xml")) .addTask(new BootstrapSingleResource("Sample how to freemarker", "Adds a sample", "/mgnl-bootstrap-samples/samples/website.howTo-freemarker.xml")) .addTask(new BootstrapSingleResource("Sample how to jsp", "Adds a sample", "/mgnl-bootstrap-samples/samples/website.howTo-jsp.xml")) .addTask(new BootstrapSingleResource("Sample of search result", "Adds a sample", "/mgnl-bootstrap-samples/samples/website.searchResult-jsp.xml")) .addTask(new BootstrapSingleResource("Sample using wirtual uri", "Adds a sample", "/mgnl-bootstrap-samples/samples/website.products-freemarker.xml")) .addTask(new BootstrapConditionally("Samples developers", "Adds developers group if does not exist", "/mgnl-bootstrap-samples/samples/usergroups.developers.xml")) .addTask(new BootstrapConditionally("Samples employees", "Adds employees group if does not exist", "/mgnl-bootstrap-samples/samples/usergroups.employees.xml")) .addTask(new BootstrapConditionally("Samples editor", "Adds editor role if does not exist", "/mgnl-bootstrap-samples/samples/userroles.editor.xml"))
@Test public void testDescriptionForInstallsAndUpdates() { final ModuleManager.ModuleManagementState state = new ModuleManager.ModuleManagementState(); state.addModule(new ModuleDefinition("a", v10, null, null), v01, Arrays.<Delta>asList( DeltaBuilder.update(v10, "").addTask(new WarnTask("", "")), DeltaBuilder.update(v05, "").addTask(new WarnTask("", "")) )); state.addModule(new ModuleDefinition("b", v10, null, null), null, Arrays.<Delta>asList( DeltaBuilder.install(v10, "").addTask(new WarnTask("", "")) )); assertEquals(2, state.getDeltaTypes().size()); assertTrue(state.getDeltaTypes().contains(DeltaType.install)); assertTrue(state.getDeltaTypes().contains(DeltaType.update)); assertEquals("installs and updates", state.getDeltaTypesDescription(TEXTS)); } }
register(DeltaBuilder.checkPrecondition("4.5", "5.0")); register(DeltaBuilder.update("4.5.2", "") .addTask(new HasPropertyDelegateTask("Fix property name", "", RepositoryConstants.CONFIG, "/server/security/userManagers/system", "realName", new MoveAndRenamePropertyTask("Fix propertyName", "/server/security/userManagers/system", "realName", "/server/security/userManagers/system", "realmName"))) .addTask(new HasPropertyDelegateTask("Fix property name", "", RepositoryConstants.CONFIG, "/server/security/userManagers/admin", "realName", new MoveAndRenamePropertyTask("Fix propertyName", "/server/security/userManagers/admin", "realName", "/server/security/userManagers/admin", "realmName")))); register((DeltaBuilder.update("4.5.9", "")) .addTask(new NodeExistsDelegateTask("AuditLogging configurations", "Add auditLogging configurations for delete action", "config", "/server/auditLogging/logConfigurations/delete", null, new PartialBootstrapTask("", "", "/mgnl-bootstrap/core/config.server.auditLogging.xml", "/auditLogging/logConfigurations/delete", ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW))) .addTask(new CheckAndModifyPropertyValueTask("AuditLogging configurations", "Change auditLogging class", "config", "/server/auditLogging", "class", "info.magnolia.logging.AuditLoggingManager", "info.magnolia.audit.AuditLoggingManager"))); register(DeltaBuilder.update("5.0", "") .addTask(new Register50NodeTypeTask("Register the new M5 node Type", "", RepositoryConstants.CONFIG)) .addTask(new RemoveMetaDataInNodeTypeDefinitionTask("Un register the metaData child node", "", RepositoryConstants.CONFIG)) .addTask(new ConvertMetaDataUpdateTask("Convert MetaData Task", "Remove the metaData sub node and replace them with mixIn when appropriate")) .addTask(new RemoveNodeTask("Remove PageEditorServlet", "Remove obsolete PageEditorServlet configuration.", RepositoryConstants.CONFIG, "/server/filters/servlets/PageEditorServlet")) .addTask(new RemoveNodeTask("Remove obsolete 'templating-editor' configuration", "", RepositoryConstants.CONFIG, "/modules/magnolia-templating-editor")) .addTask(new BootstrapSingleModuleResource("Bootstrap link transformers", "Bootstrap 'server/rendering/linkManagement/transformers", "config.server.rendering.linkManagement.xml", "/linkManagement/transformers"))); register((DeltaBuilder.update("5.0.1", "")) .addTask(new CheckAndModifyPropertyValueTask("MIMEMapping", "Change xsl extension mime-type from text/xml to application/xml", RepositoryConstants.CONFIG, "/server/MIMEMapping/xsl", "mime-type", "text/xml", "application/xml")) .addTask(new CheckAndModifyPropertyValueTask("MIMEMapping", "Change xml extension mime-type from text/xml to application/xml", RepositoryConstants.CONFIG, "/server/MIMEMapping/xml", "mime-type", "text/xml", "application/xml"))); register((DeltaBuilder.update("5.0.3", "")) .addTask(new BootstrapSingleModuleResource("JSON", "Add JSON mime-type", "config.server.MIMEMapping.xml", "/MIMEMapping/json"))); register((DeltaBuilder.update("5.1", "")) .addTask(new WarnTask("respectOrderDocument parameter", "As of Magnolia 5.1, the respectOrderDocument parameter has been reintroduced in repo config files and set to true by default. You will need to set it manually for each workspace in your installation. Please, refer to the release notes for more details.")) .addTask(new RemoveNodeTask("Remove intercept filter", "Removes no longer used intercept filter.", RepositoryConstants.CONFIG, "/server/filters/cms/intercept"))); register((DeltaBuilder.update("5.1.1", "")) .addTask(new NodeExistsDelegateTask("Set mgnl:lastActivated date of the user superuser", "Set mgnl:lastActivated date of the user superuser (if not set yet)", RepositoryConstants.USERS, "/system/superuser", new CheckOrCreateLastActivatedPropertyTask("", "", RepositoryConstants.USERS, "/system/superuser"))) .addTask(new NodeExistsDelegateTask("Set mgnl:lastActivated date of the user anonymous", "Set mgnl:lastActivated date of the user anonymous (if not set yet)", RepositoryConstants.USERS, "/system/anonymous",
public static DeltaBuilder update(String toVersionString, String description) { return update(Version.parseVersion(toVersionString), description); }
private void addLabelRemovalTasks(DeltaBuilder delta, String dialogName) { delta.addTask(new RemovePropertyTask("Remove commit action label from dialog " + dialogName, "Remove commit action label from dialog " + dialogName, RepositoryConstants.CONFIG, DIALOGS_PATH + dialogName + COMMIT_ACTION, "label")); delta.addTask(new RemovePropertyTask("Remove cancel action label from dialog " + dialogName, "Remove cancel action label from dialog " + dialogName, RepositoryConstants.CONFIG, DIALOGS_PATH + dialogName + CANCEL_ACTION, "label")); } }
@Test public void testDescriptionForInstallsOnly() { final ModuleManager.ModuleManagementState state = new ModuleManager.ModuleManagementState(); state.addModule(new ModuleDefinition("a", v10, null, null), null, Arrays.<Delta>asList( DeltaBuilder.install(v10, "").addTask(new WarnTask("", "")) )); state.addModule(new ModuleDefinition("b", v10, null, null), null, Arrays.<Delta>asList( DeltaBuilder.install(v10, "").addTask(new WarnTask("", "")) )); assertEquals(1, state.getDeltaTypes().size()); assertTrue(state.getDeltaTypes().contains(DeltaType.install)); assertEquals("installs only", state.getDeltaTypesDescription(TEXTS)); }
public WorkflowModuleVersionHandler() { register(DeltaBuilder.checkPrecondition("4.4.6", "4.5")); }
/** * @see #getBasicInstallTasks(InstallContext) override this method if you need a different set of default install tasks. * @see #getExtraInstallTasks(InstallContext) override this method if you need extra tasks for install. */ protected Delta getInstall(InstallContext installContext) { final List<Task> installTasks = new ArrayList<>(); installTasks.addAll(getBasicInstallTasks(installContext)); installTasks.addAll(getExtraInstallTasks(installContext)); installTasks.add(new ModuleVersionToLatestTask()); final List<Condition> conditions = getInstallConditions(); final Version version = installContext.getCurrentModuleDefinition().getVersion(); return DeltaBuilder.install(version, "").addTasks(installTasks).addConditions(conditions); }
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"))); }
private void doTestTemplate(String templateName) throws ModuleManagementException { final WebContext context = mock(WebContext.class); when(context.getLocale()).thenReturn(Locale.ENGLISH); when(context.getContextPath()).thenReturn("/bibabu"); MgnlContext.setInstance(context); final ModuleDefinition mod1 = new ModuleDefinition("foo", Version.parseVersion("1.0"), null, null); final ModuleDefinition mod2 = new ModuleDefinition("bar", Version.parseVersion("2.0"), null, null); final InstallContextImpl ctx = new InstallContextImpl(new ModuleRegistryImpl()); ctx.setCurrentModule(mod1); ctx.info("trala"); ctx.info("trululu"); ctx.warn("boo !"); ctx.setCurrentModule(mod2); ctx.error("hoolala", new Exception("booh-ooh!")); final ModuleManager moduleManager = mock(ModuleManager.class); final ModuleManager.ModuleManagementState state = new ModuleManager.ModuleManagementState(); state.getList().add(new ModuleManager.ModuleAndDeltas(mod1, null, Arrays.<Delta>asList( DeltaBuilder.install(Version.parseVersion("1.0"), "") .addTask(new WarnTask("a", "")) .addTask(new WarnTask("b", "")) ))); state.getList().add(new ModuleManager.ModuleAndDeltas(mod2, null, Arrays.<Delta>asList( DeltaBuilder.update("1.0", "").addTask(new WarnTask("q", "")), DeltaBuilder.update("1.1", "").addTask(new WarnTask("w", "")) ))); when(moduleManager.getStatus()).thenReturn(state); when(moduleManager.getInstallContext()).thenReturn(ctx); final StringWriter out = new StringWriter(); new ModuleManagerWebUI(moduleManager).render(templateName, out); }
Delta delta = DeltaBuilder.update(to, "Update to current version"); addModuleConfigBootstrapTasks(modulename, delta); delta.getTasks().add(new BootstrapMissingNodesTask(modulename + "-nooverwrite"));
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); }
public RestEasyClientModuleVersionHandler() { register(DeltaBuilder.update("1.0.4", "") .addTask(installRenderContextAttribute) ); register(DeltaBuilder.update("1.0.8", "") .addTask(new MigrateClientFiltersToComponentsTask()) ); register(DeltaBuilder.update("1.1.1", "") .addTask(installRestEasyJacksonDelegateProvider) ); }