protected void exportImportLayouts(long[] layoutIds, Map<String, String[]> parameterMap) throws Exception { larFile = LayoutLocalServiceUtil.exportLayoutsAsFile( group.getGroupId(), false, layoutIds, getExportParameterMap(), null, null); LayoutLocalServiceUtil.importLayouts( TestPropsValues.getUserId(), importedGroup.getGroupId(), false, parameterMap, larFile); }
protected File exportLayoutsAsFile( long sourceGroupId, boolean privateLayout, Map<Long, Boolean> layoutIdMap, Map<String, String[]> parameterMap, long remoteGroupId, Date startDate, Date endDate, 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); } 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); return LayoutLocalServiceUtil.exportLayoutsAsFile( sourceGroupId, privateLayout, layoutIds, parameterMap, startDate, endDate); }
@Override public BackgroundTaskResult execute(BackgroundTask backgroundTask) throws PortalException { ExportImportConfiguration exportImportConfiguration = getExportImportConfiguration(backgroundTask); Map<String, Serializable> settingsMap = exportImportConfiguration.getSettingsMap(); long userId = MapUtil.getLong(settingsMap, "userId"); long groupId = MapUtil.getLong(settingsMap, "sourceGroupId"); boolean privateLayout = MapUtil.getBoolean(settingsMap, "privateLayout"); long[] layoutIds = GetterUtil.getLongValues(settingsMap.get("layoutIds")); Map<String, String[]> parameterMap = (Map<String, String[]>) settingsMap.get("parameterMap"); DateRange dateRange = ExportImportDateUtil.getDateRange( exportImportConfiguration, ExportImportDateUtil.RANGE_ALL); StringBundler sb = new StringBundler(4); sb.append( StringUtil.replace( exportImportConfiguration.getName(), StringPool.SPACE, StringPool.UNDERLINE)); sb.append(StringPool.DASH); sb.append(Time.getShortTimestamp()); sb.append(".lar"); File larFile = LayoutLocalServiceUtil.exportLayoutsAsFile( groupId, privateLayout, layoutIds, parameterMap, dateRange.getStartDate(), dateRange.getEndDate()); BackgroundTaskLocalServiceUtil.addBackgroundTaskAttachment( userId, backgroundTask.getBackgroundTaskId(), sb.toString(), larFile); boolean updateLastPublishDate = MapUtil.getBoolean(parameterMap, PortletDataHandlerKeys.UPDATE_LAST_PUBLISH_DATE); if (updateLastPublishDate) { ExportImportDateUtil.updateLastPublishDate( groupId, privateLayout, dateRange, dateRange.getEndDate()); } return BackgroundTaskResult.SUCCESS; }