From e0d6af71c32d0fa23ca4e95c5e17df964ee69d81 Mon Sep 17 00:00:00 2001 From: abirembaut Date: Tue, 5 Sep 2023 11:30:41 +0200 Subject: [PATCH] feat(maintenance): no longer delete session on pause (#2694) * also no longer pause permission when pausing tenant * add missing AvailableWhenTenantIsPaused on PermissionAPI * remove useless pause resume methods overriding Covers [DEV-478](https://bonitasoft.atlassian.net/browse/DEV-478) Co-authored-by: passga --- .../engine/api/impl/PermissionAPIImpl.java | 1 + .../authorization/PermissionServiceImpl.java | 10 ---------- .../TenantElementsRestartSupervisorLocal.java | 4 ---- .../engine/tenant/TenantStateManager.java | 1 - .../PermissionServiceImplTest.java | 20 ------------------- .../engine/tenant/TenantStateManagerTest.java | 12 +---------- .../classloader/ClassLoaderServiceImpl.java | 8 -------- .../command/api/impl/CommandServiceImpl.java | 14 ------------- .../engine/service/BonitaTaskExecutor.java | 9 --------- .../engine/work/WorkServiceImpl.java | 4 ---- 10 files changed, 2 insertions(+), 81 deletions(-) diff --git a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/api/impl/PermissionAPIImpl.java b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/api/impl/PermissionAPIImpl.java index 0d8f4278907..0555a429c68 100644 --- a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/api/impl/PermissionAPIImpl.java +++ b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/api/impl/PermissionAPIImpl.java @@ -29,6 +29,7 @@ * @author Baptiste Mesta */ @Slf4j +@AvailableWhenTenantIsPaused public class PermissionAPIImpl implements PermissionAPI { @Override diff --git a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/authorization/PermissionServiceImpl.java b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/authorization/PermissionServiceImpl.java index 8e0f048f52d..97952ba0044 100644 --- a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/authorization/PermissionServiceImpl.java +++ b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/authorization/PermissionServiceImpl.java @@ -172,16 +172,6 @@ public void stop() { } } - @Override - public void pause() { - stop(); - } - - @Override - public void resume() throws SBonitaException { - start(); - } - @Override public boolean isAuthorized(APICallContext apiCallContext) throws SExecutionException { if (log.isTraceEnabled()) { diff --git a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/tenant/TenantElementsRestartSupervisorLocal.java b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/tenant/TenantElementsRestartSupervisorLocal.java index 7d64266d351..749b9d7e08b 100644 --- a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/tenant/TenantElementsRestartSupervisorLocal.java +++ b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/tenant/TenantElementsRestartSupervisorLocal.java @@ -38,10 +38,6 @@ public void pause() { areTenantsElementsAlreadyRestarted = false; } - @Override - public void resume() { - } - @Override public boolean shouldRestartElements() { return !areTenantsElementsAlreadyRestarted; diff --git a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/tenant/TenantStateManager.java b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/tenant/TenantStateManager.java index c116f27ba26..be676d34bc2 100644 --- a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/tenant/TenantStateManager.java +++ b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/tenant/TenantStateManager.java @@ -126,7 +126,6 @@ public synchronized void pause() throws Exception { if (!tenant.isActivated()) { throw new UpdateException("Can't pause a tenant in state " + tenant.getStatus()); } - sessionService.deleteSessionsOfTenantExceptTechnicalUser(tenantId); pauseTenantInTransaction(); pauseSchedulerJobsInTransaction(tenantId); tenantServicesManager.pause(); diff --git a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/authorization/PermissionServiceImplTest.java b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/authorization/PermissionServiceImplTest.java index 0af7802b345..01d49d791f5 100644 --- a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/authorization/PermissionServiceImplTest.java +++ b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/authorization/PermissionServiceImplTest.java @@ -122,26 +122,6 @@ public void should_start_then_stop_forbid_to_check_api() throws SBonitaException permissionService.checkAPICallWithScript("plop", new APICallContext(), false); } - @Test - public void should_resume_call_start() throws SBonitaException { - //when - permissionService.resume(); - //then - verify(permissionService).start(); - } - - @Test - public void should_pause_call_stop() throws SBonitaException { - //given - permissionService.start(); - - //when - permissionService.pause(); - - //then - verify(permissionService).stop(); - } - @Test public void should_pause_call_stop_tow_times() { //when diff --git a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/tenant/TenantStateManagerTest.java b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/tenant/TenantStateManagerTest.java index 60839bdd73a..66cb805bfa9 100644 --- a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/tenant/TenantStateManagerTest.java +++ b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/tenant/TenantStateManagerTest.java @@ -203,17 +203,7 @@ public void resume_should_throw_UpdateException_on_a_deactivated_tenant() throws } @Test - public void pause_should_delete_sessions() throws Exception { - whenTenantIsInState(STenant.ACTIVATED); - doReturn(okFuture()).when(broadcastService).executeOnOthersAndWait(any(), eq(TENANT_ID)); - - tenantStateManager.pause(); - - verify(sessionService).deleteSessionsOfTenantExceptTechnicalUser(TENANT_ID); - } - - @Test - public void resume_should_delete_sessions() throws Exception { + public void resume_should_not_delete_sessions() throws Exception { whenTenantIsInState(STenant.PAUSED); doReturn(okFuture()).when(broadcastService).executeOnOthersAndWait(any(), eq(TENANT_ID)); diff --git a/services/bonita-classloader/src/main/java/org/bonitasoft/engine/classloader/ClassLoaderServiceImpl.java b/services/bonita-classloader/src/main/java/org/bonitasoft/engine/classloader/ClassLoaderServiceImpl.java index fdbcbd205b9..8bc31213c00 100644 --- a/services/bonita-classloader/src/main/java/org/bonitasoft/engine/classloader/ClassLoaderServiceImpl.java +++ b/services/bonita-classloader/src/main/java/org/bonitasoft/engine/classloader/ClassLoaderServiceImpl.java @@ -228,14 +228,6 @@ private void destroyAllLocalClassLoaders() { classLoaders.clear(); } - @Override - public void pause() { - } - - @Override - public void resume() { - } - @Override public boolean addListener(ClassLoaderIdentifier identifier, SingleClassLoaderListener singleClassLoaderListener) { log.debug("Added listener {} on {}", singleClassLoaderListener, identifier); diff --git a/services/bonita-command/src/main/java/org/bonitasoft/engine/command/api/impl/CommandServiceImpl.java b/services/bonita-command/src/main/java/org/bonitasoft/engine/command/api/impl/CommandServiceImpl.java index 64a1af45d4b..ab85641b59a 100644 --- a/services/bonita-command/src/main/java/org/bonitasoft/engine/command/api/impl/CommandServiceImpl.java +++ b/services/bonita-command/src/main/java/org/bonitasoft/engine/command/api/impl/CommandServiceImpl.java @@ -384,18 +384,4 @@ private Map toCommandDeploymentMap(List