From 4b66e2d03a47020b6cca9c1b9c05a6842550088f Mon Sep 17 00:00:00 2001 From: Boubaker Khanfir Date: Tue, 29 Oct 2024 07:22:19 +0100 Subject: [PATCH] feat: Drop Pages and Navigation of deleted Site - Meeds-io/MIPs#165 --- .../java/io/meeds/layout/service/SiteLayoutService.java | 6 ++++++ .../java/io/meeds/layout/service/SiteLayoutServiceTest.java | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/layout-service/src/main/java/io/meeds/layout/service/SiteLayoutService.java b/layout-service/src/main/java/io/meeds/layout/service/SiteLayoutService.java index 6f2f3c62..920b5691 100644 --- a/layout-service/src/main/java/io/meeds/layout/service/SiteLayoutService.java +++ b/layout-service/src/main/java/io/meeds/layout/service/SiteLayoutService.java @@ -37,6 +37,7 @@ import org.exoplatform.portal.mop.SiteKey; import org.exoplatform.portal.mop.SiteType; import org.exoplatform.portal.mop.service.LayoutService; +import org.exoplatform.portal.mop.service.NavigationService; import org.exoplatform.portal.mop.user.UserPortal; import org.exoplatform.services.resources.LocaleConfig; import org.exoplatform.services.resources.LocaleConfigService; @@ -55,6 +56,9 @@ public class SiteLayoutService { @Autowired private LayoutService layoutService; + @Autowired + private NavigationService navigationService; + @Autowired private LocaleConfigService localeConfigService; @@ -151,6 +155,8 @@ public void deleteSite(SiteKey siteKey, String username) throws IllegalAccessExc } else if (!aclService.canEditSite(siteKey, username)) { throw new IllegalAccessException(String.format("Site with key %s can't be deleted by user %s", siteKey, username)); } + navigationService.destroyNavigation(siteKey); + layoutService.removePages(siteKey); layoutService.remove(portalConfig); } diff --git a/layout-service/src/test/java/io/meeds/layout/service/SiteLayoutServiceTest.java b/layout-service/src/test/java/io/meeds/layout/service/SiteLayoutServiceTest.java index 4ac06435..db83ac10 100644 --- a/layout-service/src/test/java/io/meeds/layout/service/SiteLayoutServiceTest.java +++ b/layout-service/src/test/java/io/meeds/layout/service/SiteLayoutServiceTest.java @@ -50,6 +50,7 @@ import org.exoplatform.portal.config.model.PortalConfig; import org.exoplatform.portal.mop.SiteKey; import org.exoplatform.portal.mop.service.LayoutService; +import org.exoplatform.portal.mop.service.NavigationService; import org.exoplatform.portal.mop.user.UserPortal; import org.exoplatform.services.resources.LocaleConfig; import org.exoplatform.services.resources.LocaleConfigService; @@ -75,6 +76,9 @@ public class SiteLayoutServiceTest { @MockBean private LayoutService layoutService; + @MockBean + private NavigationService navigationService; + @MockBean private UserPortalConfigService portalConfigService;