Skip to content

Commit

Permalink
Revert "LPS-200477 Moves logic to Service class, we should check here…
Browse files Browse the repository at this point in the history
… if we can delete the page template entry or not"

This reverts commit 728be91.
  • Loading branch information
ealonso authored and brianchandotcom committed Dec 4, 2023
1 parent 6cb0893 commit b94e62b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit b94e62b

Please sign in to comment.