Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Sometimes you may find it necessary to uninstall a module you had previously installed.

Warning

The following is a working draft of how to go about uninstalling a module. It is not yet finished, nor has it yet been vetted.

About the example

Note: The example used here is the SimpleMedia module. The choice to use it as the example for how to uninstall should NOT be interpreted as a slight of any kind. Indeed, IMHO, the module is extremely well done. I only use it here as an example because the uninstall process is a bit more complicated than simply removing the jar from WEB-INF/lib and deleting the modules config directory.

Getting Started

  1. If you are using Maven to manage your project, remove (or comment out) the dependency on that module from your POM, for example, in the case of SimpleMedia this would be the following POM snippet:
    pom.xml
    
    <dependency>
      <groupId>net.sourceforge.openutils</groupId>
      <artifactId>openutils-mgnlmedia</artifactId>
      <version>4.1</version>
    </dependency>
    
    
  2. If you are not using Maven, then make sure your app is shutdown and remove the module's JAR file from WEB-INF/lib

Become a Detective

  1. Download the source code for the module that you want to uninstall, make sure you grab the source for the version you currently have installed
  2. Open the VersionHandler for the module you want to uninstall. Review the install and update tasks included in it, paying special attention to tasks that install or modify configuration outside of it's own module node. For instance, it's common for modules to install items under /config/modules/adminInterface and /config/modules/standard-templating-kit
  3. Review the list of Bootstrap files located under the modules /resources/mgnl-bootstrap directory. The names are pretty self-explanatory, so take note of the files that don't start with config.modules.THE_MODULE_YOU_ARE_GOING_TO_UNINSTALL
  4. With this information, go to your own project's version handler, and open it up in an editor, what we're going to do in our version handler, is reverse the install and update tasks for the module we want to uninstall.

Example: Uninstall SimpleMedia Module

Uninstall tasks within MyProjectModuleVersionHandler

        register(DeltaBuilder.update("1.5.0", "Update various configurations for this module and uninstall SimpleMedia module")
            .addTask(
                new IsModuleInstalledOrRegistered("Uninstall OpenUtils SimpleMedia Module",
                    "Uninstalls OpenUtils SimpleMedia Module if it is installed",
                    "media",
                    new ArrayDelegateTask("Uninstall OpenUtils SimpleMedia module", 
                        "Removes all configuration related to the OpenUtils SimpleMedia module",
                        new CheckAndModifyPropertyValueTask("Update Magnolia Standard Templating Kit template-renderers", 
                            "Update Magnolia Standard Templating Kit template-renderers back to the default since we are removing the OpenUtils SimpleMedia module", 
                            ContentRepository.CONFIG, 
                            "/modules/standard-templating-kit/template-renderers/stk", 
                            "renderer", 
                            "net.sourceforge.openutils.mgnlmedia.freemarker.SktSimpleMediaTemplateRenderer", 
                            "info.magnolia.module.templatingkit.renderers.STKTemplateRenderer"),
                        new CheckAndModifyPropertyValueTask("Update Magnolia Standard Templating Kit paragraph-renderers", 
                            "Update Magnolia Standard Templating Kit paragraph-renderers back to the default since we are removing the OpenUtils SimpleMedia module", 
                            ContentRepository.CONFIG, 
                            "/modules/standard-templating-kit/paragraph-renderers/stk", 
                            "class", 
                            "net.sourceforge.openutils.mgnlmedia.freemarker.SktSimpleMediaParagraphRenderer", 
                            "info.magnolia.module.templatingkit.renderers.STKParagraphRenderer"),
                        new NodeExistsDelegateTask("Remove 'activateMedia' command from adminInterface configuration", 
                            "Removes 'activateMedia' command if it exists", 
                            ContentRepository.CONFIG,  
                            "/modules/adminInterface/commands/default/activateMedia",
                            new RemoveNodeTask("Remove 'activateMedia' command", 
                                "", 
                                ContentRepository.CONFIG, 
                                "/modules/adminInterface/commands/default/activateMedia")
                        ),
                        new NodeExistsDelegateTask("Remove 'media' menu from adminInterface configuration", 
                            "Removes 'media' menu if it exists", 
                            ContentRepository.CONFIG,  
                            "/modules/adminInterface/config/menu/media",
                            new RemoveNodeTask("Remove 'media' menu", 
                                "", 
                                ContentRepository.CONFIG, 
                                "/modules/adminInterface/config/menu/media")
                        ),
                        new NodeExistsDelegateTask("Remove 'mediaJCR' menu from adminInterface configuration", 
                            "Removes 'mediaJCR' menu if it exists", 
                            ContentRepository.CONFIG,  
                            "/modules/adminInterface/config/menu/tools/mediaJCR",
                            new RemoveNodeTask("Remove 'mediaJCR' menu", 
                                "", 
                                ContentRepository.CONFIG, 
                                "/modules/adminInterface/config/menu/tools/mediaJCR")
                        ),
                        new NodeExistsDelegateTask("Remove 'media-selector' from fckEditor configuration", 
                            "Removes 'media-selector' menu if it exists", 
                            ContentRepository.CONFIG,  
                            "/modules/fckEditor/config/browsableRepositories/media-selector",
                            new RemoveNodeTask("Remove 'media-selector' menu", 
                                "", 
                                ContentRepository.CONFIG, 
                                "/modules/fckEditor/config/browsableRepositories/media-selector")
                        ),
                        new NodeExistsDelegateTask("Remove 'media' handler from standard-templating-kit damSupport configuration", 
                            "Removes 'media' handler from standard-templating-kit damSupport configuration if it exists", 
                            ContentRepository.CONFIG,  
                            "/modules/standard-templating-kit/config/site/damSupport/handlers/media",
                            new RemoveNodeTask("Remove 'media' handler", 
                                "", 
                                ContentRepository.CONFIG, 
                                "/modules/standard-templating-kit/config/site/damSupport/handlers/media")
                        ),
                        new NodeExistsDelegateTask("Remove 'media' module configuration", 
                            "Removes all 'media' module configuration if it exists", 
                            ContentRepository.CONFIG,  
                            "/modules/media",
                            new RemoveNodeTask("Remove all 'media' module configuration", 
                                "", 
                                ContentRepository.CONFIG, 
                                "/modules/media")
                        ),
                        new NodeExistsDelegateTask("Remove 'media' mappings from server URI2RespositoryMapping configuration", 
                            "Removes 'media' mappings from server URI2RespositoryMapping if it exists", 
                            ContentRepository.CONFIG,  
                            "/server/URI2RepositoryMapping/mappings/media",
                            new RemoveNodeTask("Remove 'media' mappings from server URI2RespositoryMapping", 
                                "", 
                                ContentRepository.CONFIG, 
                                "/server/URI2RepositoryMapping/mappings/media")
                        ),
                        new NodeExistsDelegateTask("Remove 'sample-simplemedia' website", 
                            "Removes 'sample-simplemedia' website if it exists", 
                            ContentRepository.WEBSITE,  
                            "/sample-simplemedia",
                            new RemoveNodeTask("Remove 'sample-simplemedia' website", 
                                "", 
                                ContentRepository.WEBSITE, 
                                "/sample-simplemedia")
                        ),
                        new WarnTask("Note: OpenUtils SimpleMedia module configuration and sample content has been removed", 
                            "All configuration and sample content related to OpenUtils SimpleMedia module has been removed.\n" +
                            "IMPORTANT: Please make sure to:\n" +
                            "1. Shutdown Magnolia\n" +
                            "2. Drop the tables prefixed with 'media_' or 'MEDIA_'.\n" +
                            "3. Delete the 'media' workspace directory from your Magnolia Repositories.\n" +
                            "4. Delete the 'templates/samples-media' directory from your webapps root directory.\n" +                                                             
                            "5. Startup Magnolia")
                    )
                )
            )
        );

— TO BE CONTINUED —

  • No labels