diff --git a/modules/apps/headless/headless-admin-site/headless-admin-site-impl/src/main/java/com/liferay/headless/admin/site/internal/resource/util/layout/structure/LayoutStructureUtil.java b/modules/apps/headless/headless-admin-site/headless-admin-site-impl/src/main/java/com/liferay/headless/admin/site/internal/resource/util/layout/structure/LayoutStructureUtil.java new file mode 100644 index 00000000000000..1a0848237fdd38 --- /dev/null +++ b/modules/apps/headless/headless-admin-site/headless-admin-site-impl/src/main/java/com/liferay/headless/admin/site/internal/resource/util/layout/structure/LayoutStructureUtil.java @@ -0,0 +1,30 @@ +/** + * SPDX-FileCopyrightText: (c) 2024 Liferay, Inc. https://liferay.com + * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06 + */ + +package com.liferay.headless.admin.site.internal.resource.util.layout.structure; + +import com.liferay.headless.admin.site.dto.v1_0.PageElement; +import com.liferay.layout.util.structure.LayoutStructure; +import com.liferay.portal.kernel.util.Validator; + +/** + * @author Eudaldo Alonso + */ +public class LayoutStructureUtil { + + public static String getParentExternalReferenceCode( + PageElement pageElement, LayoutStructure layoutStructure) { + + String parentExternalReferenceCode = + pageElement.getParentExternalReferenceCode(); + + if (Validator.isNotNull(parentExternalReferenceCode)) { + return parentExternalReferenceCode; + } + + return layoutStructure.getMainItemId(); + } + +} \ No newline at end of file diff --git a/modules/apps/headless/headless-admin-site/headless-admin-site-impl/src/main/java/com/liferay/headless/admin/site/internal/resource/v1_0/PageElementResourceImpl.java b/modules/apps/headless/headless-admin-site/headless-admin-site-impl/src/main/java/com/liferay/headless/admin/site/internal/resource/v1_0/PageElementResourceImpl.java index 14b319a6759d5e..02442d65b0fe2f 100644 --- a/modules/apps/headless/headless-admin-site/headless-admin-site-impl/src/main/java/com/liferay/headless/admin/site/internal/resource/v1_0/PageElementResourceImpl.java +++ b/modules/apps/headless/headless-admin-site/headless-admin-site-impl/src/main/java/com/liferay/headless/admin/site/internal/resource/v1_0/PageElementResourceImpl.java @@ -10,6 +10,7 @@ import com.liferay.fragment.service.FragmentEntryLocalService; import com.liferay.headless.admin.site.dto.v1_0.PageElement; import com.liferay.headless.admin.site.internal.resource.util.GroupUtil; +import com.liferay.headless.admin.site.internal.resource.util.layout.structure.LayoutStructureUtil; import com.liferay.headless.admin.site.internal.resource.util.layout.structure.item.importer.CollectionItemLayoutStructureItemImporter; import com.liferay.headless.admin.site.internal.resource.util.layout.structure.item.importer.CollectionLayoutStructureItemImporter; import com.liferay.headless.admin.site.internal.resource.util.layout.structure.item.importer.ColumnLayoutStructureItemImporter; @@ -33,7 +34,6 @@ import com.liferay.portal.kernel.feature.flag.FeatureFlagManagerUtil; import com.liferay.portal.kernel.model.Layout; import com.liferay.portal.kernel.service.LayoutLocalService; -import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.vulcan.dto.converter.DTOConverter; import com.liferay.portal.vulcan.dto.converter.DTOConverterContext; import com.liferay.portal.vulcan.dto.converter.DefaultDTOConverterContext; @@ -383,7 +383,8 @@ public PageElement putSiteSiteByExternalReferenceCodePageElement( layoutStructure.moveLayoutStructureItem( layoutStructureItem.getItemId(), - _getParentExternalReferenceCode(pageElement, layoutStructure), + LayoutStructureUtil.getParentExternalReferenceCode( + pageElement, layoutStructure), pageElement.getPosition()); _layoutPageTemplateStructureLocalService. @@ -488,19 +489,6 @@ private DTOConverterContext _getDTOConverterContext( return dtoConverterContext; } - private String _getParentExternalReferenceCode( - PageElement pageElement, LayoutStructure layoutStructure) { - - String parentExternalReferenceCode = - pageElement.getParentExternalReferenceCode(); - - if (Validator.isNotNull(parentExternalReferenceCode)) { - return parentExternalReferenceCode; - } - - return layoutStructure.getMainItemId(); - } - @Reference private FragmentCollectionContributorRegistry _fragmentCollectionContributorRegistry;