From b94e62bf1cfc312157f0a2125df50c3cc9087135 Mon Sep 17 00:00:00 2001 From: Eudaldo Alonso Date: Mon, 4 Dec 2023 08:40:58 +0000 Subject: [PATCH] Revert "LPS-200477 Moves logic to Service class, we should check here if we can delete the page template entry or not" This reverts commit 728be9177b325f9dbace31321eedc3bc6c3d3d3d. --- ...youtPageTemplateEntryMVCActionCommand.java | 26 +++++++++++++++++-- ...youtPageTemplateEntryLocalServiceImpl.java | 18 ------------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/modules/apps/layout/layout-page-template-admin-web/src/main/java/com/liferay/layout/page/template/admin/web/internal/portlet/action/DeleteLayoutPageTemplateEntryMVCActionCommand.java b/modules/apps/layout/layout-page-template-admin-web/src/main/java/com/liferay/layout/page/template/admin/web/internal/portlet/action/DeleteLayoutPageTemplateEntryMVCActionCommand.java index c18cd3a1c58942..6a8099852be45d 100644 --- a/modules/apps/layout/layout-page-template-admin-web/src/main/java/com/liferay/layout/page/template/admin/web/internal/portlet/action/DeleteLayoutPageTemplateEntryMVCActionCommand.java +++ b/modules/apps/layout/layout-page-template-admin-web/src/main/java/com/liferay/layout/page/template/admin/web/internal/portlet/action/DeleteLayoutPageTemplateEntryMVCActionCommand.java @@ -5,7 +5,9 @@ package com.liferay.layout.page.template.admin.web.internal.portlet.action; +import com.liferay.asset.display.page.service.AssetDisplayPageEntryLocalService; import com.liferay.layout.page.template.admin.constants.LayoutPageTemplateAdminPortletKeys; +import com.liferay.layout.page.template.exception.RequiredLayoutPageTemplateEntryException; import com.liferay.layout.page.template.service.LayoutPageTemplateEntryService; import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.language.Language; @@ -65,9 +67,25 @@ protected void doProcessAction( for (long deleteLayoutPageTemplateEntryId : deleteLayoutPageTemplateEntryIds) { + int assetDisplayPageEntriesCount = + _assetDisplayPageEntryLocalService. + getAssetDisplayPageEntriesCountByLayoutPageTemplateEntryId( + deleteLayoutPageTemplateEntryId); + try { - _layoutPageTemplateEntryService.deleteLayoutPageTemplateEntry( - deleteLayoutPageTemplateEntryId); + if (assetDisplayPageEntriesCount > 0) { + deleteLayoutPageTemplateIdsList.add( + deleteLayoutPageTemplateEntryId); + + SessionErrors.add( + actionRequest, + RequiredLayoutPageTemplateEntryException.class); + } + else { + _layoutPageTemplateEntryService. + deleteLayoutPageTemplateEntry( + deleteLayoutPageTemplateEntryId); + } } catch (PortalException portalException) { if (_log.isDebugEnabled()) { @@ -101,6 +119,10 @@ else if (deleteLayoutPageTemplateEntryIds.length > 0) { private static final Log _log = LogFactoryUtil.getLog( DeleteLayoutPageTemplateEntryMVCActionCommand.class); + @Reference + private AssetDisplayPageEntryLocalService + _assetDisplayPageEntryLocalService; + @Reference private Language _language; diff --git a/modules/apps/layout/layout-page-template-service/src/main/java/com/liferay/layout/page/template/service/impl/LayoutPageTemplateEntryLocalServiceImpl.java b/modules/apps/layout/layout-page-template-service/src/main/java/com/liferay/layout/page/template/service/impl/LayoutPageTemplateEntryLocalServiceImpl.java index cb707daf807700..8c94e25a7451ab 100644 --- a/modules/apps/layout/layout-page-template-service/src/main/java/com/liferay/layout/page/template/service/impl/LayoutPageTemplateEntryLocalServiceImpl.java +++ b/modules/apps/layout/layout-page-template-service/src/main/java/com/liferay/layout/page/template/service/impl/LayoutPageTemplateEntryLocalServiceImpl.java @@ -5,7 +5,6 @@ package com.liferay.layout.page.template.service.impl; -import com.liferay.asset.display.page.service.AssetDisplayPageEntryLocalService; import com.liferay.asset.kernel.NoSuchClassTypeException; import com.liferay.document.library.kernel.service.DLFileEntryLocalService; import com.liferay.dynamic.data.mapping.service.DDMStructureLinkLocalService; @@ -18,7 +17,6 @@ import com.liferay.layout.page.template.constants.LayoutPageTemplateEntryTypeConstants; import com.liferay.layout.page.template.exception.LayoutPageTemplateEntryNameException; import com.liferay.layout.page.template.exception.NoSuchPageTemplateEntryException; -import com.liferay.layout.page.template.exception.RequiredLayoutPageTemplateEntryException; import com.liferay.layout.page.template.internal.validator.LayoutPageTemplateEntryValidator; import com.liferay.layout.page.template.model.LayoutPageTemplateEntry; import com.liferay.layout.page.template.service.base.LayoutPageTemplateEntryLocalServiceBaseImpl; @@ -60,7 +58,6 @@ import com.liferay.portal.kernel.systemevent.SystemEvent; import com.liferay.portal.kernel.util.Constants; import com.liferay.portal.kernel.util.File; -import com.liferay.portal.kernel.util.GroupThreadLocal; import com.liferay.portal.kernel.util.LocaleUtil; import com.liferay.portal.kernel.util.Localization; import com.liferay.portal.kernel.util.OrderByComparator; @@ -323,17 +320,6 @@ public LayoutPageTemplateEntry deleteLayoutPageTemplateEntry( LayoutPageTemplateEntry layoutPageTemplateEntry) throws PortalException { - if (!GroupThreadLocal.isDeleteInProcess()) { - int assetDisplayPageEntriesCount = - _assetDisplayPageEntryLocalService. - getAssetDisplayPageEntriesCountByLayoutPageTemplateEntryId( - layoutPageTemplateEntry.getLayoutPageTemplateEntryId()); - - if (assetDisplayPageEntriesCount > 0) { - throw new RequiredLayoutPageTemplateEntryException(); - } - } - // Layout page template layoutPageTemplateEntryPersistence.remove(layoutPageTemplateEntry); @@ -1111,10 +1097,6 @@ private void _validate(long groupId, String name, int type) private static final Log _log = LogFactoryUtil.getLog( LayoutPageTemplateEntryLocalServiceImpl.class); - @Reference - private AssetDisplayPageEntryLocalService - _assetDisplayPageEntryLocalService; - @Reference private ClassNameLocalService _classNameLocalService;