diff --git a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/api/impl/application/installer/CustomOrDefaultApplicationInstaller.java b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/api/impl/application/installer/CustomOrDefaultApplicationInstaller.java index 4845db05fac..828e6805ab1 100644 --- a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/api/impl/application/installer/CustomOrDefaultApplicationInstaller.java +++ b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/api/impl/application/installer/CustomOrDefaultApplicationInstaller.java @@ -94,7 +94,7 @@ public void autoDeployDetectedCustomApplication(PlatformStartedEvent event) log.info("Bonita now tries to install it automatically..."); applicationInstaller.install(applicationArchive); } else { - var currentVersion = platformService.getPlatform().getApplicationVersion(); + var currentVersion = getInstalledApplicationVersion(); log.info("Detected application version: '{}'; Current deployed version: '{}'", applicationArchive.getVersion(), currentVersion); @@ -113,6 +113,11 @@ public void autoDeployDetectedCustomApplication(PlatformStartedEvent event) } } + String getInstalledApplicationVersion() throws Exception { + return applicationInstaller.inSession( + () -> applicationInstaller.inTransaction(() -> platformService.getPlatform().getApplicationVersion())); + } + boolean isPlatformFirstInitialization() { return mandatoryLivingApplicationImporter.isFirstRun(); } diff --git a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/api/impl/application/installer/CustomOrDefaultApplicationInstallerTest.java b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/api/impl/application/installer/CustomOrDefaultApplicationInstallerTest.java index 0c8c1e1ca5e..316772b1e7e 100644 --- a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/api/impl/application/installer/CustomOrDefaultApplicationInstallerTest.java +++ b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/api/impl/application/installer/CustomOrDefaultApplicationInstallerTest.java @@ -27,8 +27,6 @@ import org.bonitasoft.engine.business.application.importer.DefaultLivingApplicationImporter; import org.bonitasoft.engine.exception.ApplicationInstallationException; -import org.bonitasoft.engine.platform.PlatformService; -import org.bonitasoft.engine.platform.model.SPlatform; import org.bonitasoft.engine.tenant.TenantServicesManager; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; @@ -60,10 +58,6 @@ class CustomOrDefaultApplicationInstallerTest { DefaultLivingApplicationImporter defaultLivingApplicationImporter; @Mock TenantServicesManager tenantServicesManager; - @Mock - PlatformService platformService; - @Mock - SPlatform platform; @Mock private ApplicationArchiveReader applicationArchiveReader; @@ -75,7 +69,6 @@ class CustomOrDefaultApplicationInstallerTest { void before() throws Exception { doAnswer(inv -> callableCaptor.getValue().call()).when(tenantServicesManager) .inTenantSessionTransaction(callableCaptor.capture()); - doReturn(platform).when(platformService).getPlatform(); } @Test @@ -170,7 +163,7 @@ void should_update_custom_application_if_detected_version_superior_to_deployed_v applicationArchive.setVersion("1.0.1"); doReturn(applicationArchive).when(applicationArchiveReader).read(resourceStream1); doReturn(false).when(listener).isPlatformFirstInitialization(); - doReturn("1.0.0").when(platform).getApplicationVersion(); + doReturn("1.0.0").when(listener).getInstalledApplicationVersion(); //when listener.autoDeployDetectedCustomApplication(any()); @@ -190,7 +183,7 @@ void should_update_conf_if_detected_version_equal_to_deployed_version() applicationArchive.setVersion("1.0.0"); doReturn(applicationArchive).when(listener).createApplicationArchive(resource1); doReturn(false).when(listener).isPlatformFirstInitialization(); - doReturn("1.0.0").when(platform).getApplicationVersion(); + doReturn("1.0.0").when(listener).getInstalledApplicationVersion(); //when listener.autoDeployDetectedCustomApplication(any()); @@ -212,7 +205,7 @@ void should_throw_an_exception_if_detected_version_inferior_to_deployed_version( applicationArchive.setVersion("0.0.9-SNAPSHOT"); doReturn(applicationArchive).when(listener).createApplicationArchive(resource1); doReturn(false).when(listener).isPlatformFirstInitialization(); - doReturn("1.0.0").when(platform).getApplicationVersion(); + doReturn("1.0.0").when(listener).getInstalledApplicationVersion(); //when String exceptionMessage = Assertions.assertThrows(ApplicationInstallationException.class, () -> listener.autoDeployDetectedCustomApplication(any())).getMessage(); diff --git a/bpm/bonita-web-server/src/main/webapp/WEB-INF/web.xml b/bpm/bonita-web-server/src/main/webapp/WEB-INF/web.xml index ef2dfb96356..e3e41cd7832 100644 --- a/bpm/bonita-web-server/src/main/webapp/WEB-INF/web.xml +++ b/bpm/bonita-web-server/src/main/webapp/WEB-INF/web.xml @@ -153,7 +153,7 @@ org.bonitasoft.console.common.server.filter.CacheFilter duration - 15768000 + 36000 alwaysCaching