List of usage examples for com.liferay.portal.kernel.model Layout getAllChildren
public java.util.List<Layout> getAllChildren();
From source file:com.liferay.exportimport.internal.background.task.LayoutRemoteStagingBackgroundTaskExecutor.java
License:Open Source License
protected File exportLayoutsAsFile(ExportImportConfiguration exportImportConfiguration, Map<Long, Boolean> layoutIdMap, long remoteGroupId, HttpPrincipal httpPrincipal) throws PortalException { List<Layout> layouts = new ArrayList<>(); if (layoutIdMap != null) { for (Map.Entry<Long, Boolean> entry : layoutIdMap.entrySet()) { long plid = GetterUtil.getLong(String.valueOf(entry.getKey())); boolean includeChildren = entry.getValue(); Layout layout = LayoutLocalServiceUtil.getLayout(plid); if (!layouts.contains(layout)) { layouts.add(layout);/*from ww w .j a v a 2 s . c om*/ } List<Layout> parentLayouts = getMissingRemoteParentLayouts(httpPrincipal, layout, remoteGroupId); for (Layout parentLayout : parentLayouts) { if (!layouts.contains(parentLayout)) { layouts.add(parentLayout); } } if (includeChildren) { for (Layout childLayout : layout.getAllChildren()) { if (!layouts.contains(childLayout)) { layouts.add(childLayout); } } } } } long[] layoutIds = ExportImportHelperUtil.getLayoutIds(layouts); Map<String, Serializable> settingsMap = exportImportConfiguration.getSettingsMap(); settingsMap.remove("layoutIdMap"); settingsMap.put("layoutIds", layoutIds); return ExportImportLocalServiceUtil.exportLayoutsAsFile(exportImportConfiguration); }
From source file:com.liferay.exportimport.lar.ExportImportHelperImpl.java
License:Open Source License
@Override public long[] getLayoutIds(Map<Long, Boolean> layoutIdMap, long targetGroupId) throws PortalException { if (MapUtil.isEmpty(layoutIdMap)) { return new long[0]; }//from w ww .j a va 2s. co m List<Layout> layouts = new ArrayList<>(); for (Map.Entry<Long, Boolean> entry : layoutIdMap.entrySet()) { long plid = GetterUtil.getLong(String.valueOf(entry.getKey())); Layout layout = new LayoutImpl(); if (plid == 0) { layout.setPlid(LayoutConstants.DEFAULT_PLID); layout.setLayoutId(LayoutConstants.DEFAULT_PLID); layout.setParentLayoutId(LayoutConstants.DEFAULT_PARENT_LAYOUT_ID); } else { layout = _layoutLocalService.getLayout(plid); } if (!layouts.contains(layout)) { layouts.add(layout); } if (layout.getPlid() == LayoutConstants.DEFAULT_PLID) { continue; } List<Layout> parentLayouts = Collections.emptyList(); if (targetGroupId != GroupConstants.DEFAULT_LIVE_GROUP_ID) { parentLayouts = getMissingParentLayouts(layout, targetGroupId); } for (Layout parentLayout : parentLayouts) { if (!layouts.contains(parentLayout)) { layouts.add(parentLayout); } } boolean includeChildren = entry.getValue(); if (includeChildren) { for (Layout childLayout : layout.getAllChildren()) { if (!layouts.contains(childLayout)) { layouts.add(childLayout); } } } } return getLayoutIds(layouts); }
From source file:com.liferay.exportimport.staging.StagingImpl.java
License:Open Source License
@Override public long publishLayout(long userId, long plid, long liveGroupId, boolean includeChildren) throws PortalException { Map<String, String[]> parameterMap = ExportImportConfigurationParameterMapFactory.buildParameterMap(); parameterMap.put(PortletDataHandlerKeys.DELETE_MISSING_LAYOUTS, new String[] { Boolean.FALSE.toString() }); Layout layout = _layoutLocalService.getLayout(plid); List<Layout> layouts = new ArrayList<>(); layouts.add(layout);//from w ww .j ava 2s .c o m List<Layout> parentLayouts = _exportImportHelper.getMissingParentLayouts(layout, liveGroupId); layouts.addAll(parentLayouts); if (includeChildren) { layouts.addAll(layout.getAllChildren()); } long[] layoutIds = _exportImportHelper.getLayoutIds(layouts); return publishLayouts(userId, layout.getGroupId(), liveGroupId, layout.isPrivateLayout(), layoutIds, parameterMap); }