@Override public void setLayoutTemplateId( long userId, String newLayoutTemplateId, boolean checkPermission) { if (checkPermission && !PluginSettingLocalServiceUtil.hasPermission( userId, newLayoutTemplateId, Plugin.TYPE_LAYOUT_TEMPLATE)) { return; } LayoutTemplate oldLayoutTemplate = getLayoutTemplate(); String themeId = getThemeId(); LayoutTemplate newLayoutTemplate = LayoutTemplateLocalServiceUtil.getLayoutTemplate(newLayoutTemplateId, false, themeId); if (newLayoutTemplate == null) { if (_log.isWarnEnabled()) { _log.warn("Unable to find layout template " + newLayoutTemplateId); } return; } setTypeSettingsProperty(LayoutTypePortletConstants.LAYOUT_TEMPLATE_ID, newLayoutTemplateId); List<String> oldColumns = oldLayoutTemplate.getColumns(); List<String> newColumns = newLayoutTemplate.getColumns(); reorganizePortlets(newColumns, oldColumns); }
@Override public LayoutTemplate getLayoutTemplate() { String themeId = getThemeId(); LayoutTemplate layoutTemplate = LayoutTemplateLocalServiceUtil.getLayoutTemplate(getLayoutTemplateId(), false, themeId); if (layoutTemplate == null) { layoutTemplate = new LayoutTemplateImpl(StringPool.BLANK, StringPool.BLANK); List<String> columns = new ArrayList<>(); for (int i = 1; i <= 10; i++) { columns.add(LayoutTypePortletConstants.COLUMN_PREFIX + i); } layoutTemplate.setColumns(columns); } return layoutTemplate; }