diff --git a/data-upgrade-app-registry/pom.xml b/data-upgrade-app-registry/pom.xml
index 4d5551a6d..9af983045 100644
--- a/data-upgrade-app-registry/pom.xml
+++ b/data-upgrade-app-registry/pom.xml
@@ -32,7 +32,7 @@
eXo Add-on:: Data Upgrade Add-on - ApplicationRegistery - Upgrade
- 0.80
+ 0.78
diff --git a/data-upgrade-app-registry/src/main/java/org/exoplatform/application/upgrade/CleanAppRegistryCategoryUpgradePlugin.java b/data-upgrade-app-registry/src/main/java/org/exoplatform/application/upgrade/CleanAppRegistryCategoryUpgradePlugin.java
index a6a781b53..e91466a3f 100644
--- a/data-upgrade-app-registry/src/main/java/org/exoplatform/application/upgrade/CleanAppRegistryCategoryUpgradePlugin.java
+++ b/data-upgrade-app-registry/src/main/java/org/exoplatform/application/upgrade/CleanAppRegistryCategoryUpgradePlugin.java
@@ -19,8 +19,10 @@
import jakarta.persistence.EntityManager;
import jakarta.persistence.Query;
+import org.exoplatform.application.registry.impl.JDBCApplicationRegistryService;
import org.exoplatform.commons.persistence.impl.EntityManagerService;
import org.exoplatform.commons.upgrade.UpgradeProductPlugin;
+import org.exoplatform.commons.utils.CommonsUtils;
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.container.PortalContainer;
import org.exoplatform.container.component.RequestLifeCycle;
@@ -75,10 +77,20 @@ public void processUpgrade(String oldVersion, String newVersion) {
}
} finally {
RequestLifeCycle.end();
+ restartApplicationRegistryService();
}
}
-
public int getCleanedCategoriesCount() {
return cleanedCategoriesCount;
}
+
+ private void restartApplicationRegistryService() {
+ try {
+ JDBCApplicationRegistryService applicationRegistryService = CommonsUtils.getService(JDBCApplicationRegistryService.class);
+ applicationRegistryService.stop();
+ applicationRegistryService.start();
+ } catch (Exception e) {
+ LOG.info("Error encountered when restarting {} during the clean application registry upgrade plugin", JDBCApplicationRegistryService.class);
+ }
+ }
}
diff --git a/data-upgrade-app-registry/src/test/java/org/exoplatform/category/upgrade/CleanAppRegistryCategoryUpgradePluginTest.java b/data-upgrade-app-registry/src/test/java/org/exoplatform/category/upgrade/CleanAppRegistryCategoryUpgradePluginTest.java
index 5d752f588..bd6d6b3cb 100644
--- a/data-upgrade-app-registry/src/test/java/org/exoplatform/category/upgrade/CleanAppRegistryCategoryUpgradePluginTest.java
+++ b/data-upgrade-app-registry/src/test/java/org/exoplatform/category/upgrade/CleanAppRegistryCategoryUpgradePluginTest.java
@@ -27,6 +27,7 @@
@ConfiguredBy({
@ConfigurationUnit(scope = ContainerScope.PORTAL, path = "conf/portal/configuration.xml"),
@ConfigurationUnit(scope = ContainerScope.PORTAL, path = "conf/exo.portal.component.application-registry-configuration-local.xml"),
+ @ConfigurationUnit(scope = ContainerScope.PORTAL, path = "conf/portal/application-registry-initializer-configuration.xml"),
})
public class CleanAppRegistryCategoryUpgradePluginTest extends AbstractKernelTest {
@@ -59,9 +60,9 @@ public void testAppRegistryCategoryUpgradePlugin() throws Exception {
valueParam.setValue("org.exoplatform.platform");
initParams.addParameter(valueParam);
- String toolCategoryName = "Tools";
+ String toolsCategoryName = "Tools";
String analyticsCategoryName = "Analytics";
- ApplicationCategory toolsCategory = createAppCategory(toolCategoryName, "None");
+ ApplicationCategory toolsCategory = createAppCategory(toolsCategoryName, "None");
ApplicationCategory analytics = createAppCategory(analyticsCategoryName, "None");
applicationRegistryService.save(toolsCategory);
applicationRegistryService.save(analytics);
@@ -75,6 +76,16 @@ public void testAppRegistryCategoryUpgradePlugin() throws Exception {
List cats = applicationRegistryService.getApplicationCategories();
assertFalse(apps.isEmpty());
assertFalse(cats.isEmpty());
+ // assert that the tools category is created with the iframe portlet as the application
+ ApplicationCategory tools = applicationRegistryService.getApplicationCategory(toolsCategoryName);
+ assertNotNull(tools);
+ assertTrue(tools.getApplications().size() == 2);
+ assertTrue(tools.getApplications().stream().anyMatch(application -> application.getApplicationName().equals("IFramePortlet")));
+ //assert that the analytics category is created with the AnalyticsPortlet as the application
+ ApplicationCategory analyticsCategory = applicationRegistryService.getApplicationCategory(analyticsCategoryName);
+ assertNotNull(analyticsCategory);
+ assertTrue(analyticsCategory.getApplications().size() == 1);
+ assertTrue(analyticsCategory.getApplications().stream().anyMatch(application -> application.getApplicationName().equals("AnalyticsPortlet")));
} catch (Exception e) {
fail();
}
@@ -86,9 +97,17 @@ public void testAppRegistryCategoryUpgradePlugin() throws Exception {
appRegistryCategoryUpgradePlugin.processUpgrade(null, null);
try {
List apps = applicationRegistryService.getAllApplications();
- assertTrue(apps.isEmpty());
+ assertTrue(!apps.isEmpty());
List cats = applicationRegistryService.getApplicationCategories();
- assertTrue(cats.isEmpty());
+ assertTrue(!cats.isEmpty());
+ // assert that the tools category is recreated with the WhoIsOnLinePortlet as the application
+ ApplicationCategory tools = applicationRegistryService.getApplicationCategory(toolsCategoryName);
+ assertNotNull(tools);
+ assertTrue(tools.getApplications().size() == 1);
+ assertTrue(tools.getApplications().get(0).getApplicationName().equals("WhoIsOnLinePortlet"));
+ // assert that the analytics category is removed
+ ApplicationCategory analyticsCategory = applicationRegistryService.getApplicationCategory(analyticsCategoryName);
+ assertNull(analyticsCategory);
} catch (Exception e) {
fail();
}
diff --git a/data-upgrade-app-registry/src/test/resources/conf/portal/application-registry-initializer-configuration.xml b/data-upgrade-app-registry/src/test/resources/conf/portal/application-registry-initializer-configuration.xml
new file mode 100644
index 000000000..cd53d7552
--- /dev/null
+++ b/data-upgrade-app-registry/src/test/resources/conf/portal/application-registry-initializer-configuration.xml
@@ -0,0 +1,96 @@
+
+
+
+
+
+ org.exoplatform.application.registry.ApplicationRegistryService
+
+ Tools.portlets.registry
+ initListener
+ org.exoplatform.application.registry.ApplicationCategoriesPlugins
+ this listener init the portlets are registered in PortletRegister
+
+
+ merge
+ true
+
+
+ system
+ true
+
+
+ tools
+
+
+
+
+
+
\ No newline at end of file