code: public CmsReplaceModuleInfo replaceModule(CmsObject cms, String importFile, I_CmsReport report)
      throws CmsException {
  
          CmsModule module = CmsModuleImportExportHandler.readModuleFromImport(importFile);
  
          boolean hasModule = hasModule(module.getName());
          boolean usedNewUpdate = false;
          if (hasModule) {
              Optional<CmsModuleUpdater> optModuleUpdater = CmsModuleUpdater.create(cms, importFile, report);
              if (optModuleUpdater.isPresent()) {
                  usedNewUpdate = true;
                  optModuleUpdater.get().run();
              } else {
                  deleteModule(cms, module.getName(), true, report);
                  CmsImportParameters params = new CmsImportParameters(importFile, "/", true);
                  OpenCms.getImportExportManager().importData(cms, report, params);
              }
  
          } else {
              CmsImportParameters params = new CmsImportParameters(importFile, "/", true);
              OpenCms.getImportExportManager().importData(cms, report, params);
          }
          return new CmsReplaceModuleInfo(module, usedNewUpdate);
      }
docs: Replaces an existing module with the one read from an import ZIP file.<p>
  
  If there is not already a module with the same name installed, then the module will just be imported normally.
  
  @param cms the CMS context
  @param importFile the import file
  @param report the report
  
  @return the module replacement status
  @throws CmsException if something goes wrong