Currently I would like to have ability for copy layout content type from one site to another as draft. But it can't do that with the code below:
private void copyLayout(final Layout srclayout, Layout destLayout) throws Exception {
Layout destDraftLayout = LayoutLocalServiceUtil.fetchLayout(
PortalUtil.getClassNameId(Layout.class), destLayout.getPlid());
if (Validator.isNotNull(layout) && Validator.isNotNull(destLayout)) {
destDraftLayout = layoutCopyHelper.copyLayout(srclayout, destDraftLayout);
layoutLocalService.updateLayout(destDraftLayout);
}
The content always blank. Please help, I don't know how to solve this problem.
Above code working fine with the current site
I found the solution now. I create the new implementation and copy all code from https://github.com/liferay/liferay-portal/blob/ded0e9390637985231e962e4ad4cfa4639eabb26/modules/apps/layout/layout-impl/src/main/java/com/liferay/layout/internal/util/LayoutCopyHelperImpl.java.
And add this code
newFragmentEntryLink.setGroupId(targetLayout.getGroupId());
https://github.com/liferay/liferay-portal/blob/ded0e9390637985231e962e4ad4cfa4639eabb26/modules/apps/layout/layout-impl/src/main/java/com/liferay/layout/internal/util/LayoutCopyHelperImpl.java#L237