List of usage examples for com.liferay.portal.kernel.model Layout getIconImage
public boolean getIconImage();
true if the current layout has a configured icon. From source file:com.liferay.exportimport.resources.importer.internal.util.FileSystemImporter.java
License:Open Source License
protected void addLayout(boolean privateLayout, long parentLayoutId, JSONObject layoutJSONObject) throws Exception { if (targetClassName.equals(LayoutSetPrototype.class.getName())) { privateLayout = true;/*from w w w . j av a2s.co m*/ } Map<Locale, String> nameMap = getMap(layoutJSONObject, "name"); Map<Locale, String> titleMap = getMap(layoutJSONObject, "title"); String type = layoutJSONObject.getString("type"); if (Validator.isNull(type)) { type = LayoutConstants.TYPE_PORTLET; } String typeSettings = layoutJSONObject.getString("typeSettings"); boolean hidden = layoutJSONObject.getBoolean("hidden"); String themeId = layoutJSONObject.getString("themeId"); String layoutCss = layoutJSONObject.getString("layoutCss"); String colorSchemeId = layoutJSONObject.getString("colorSchemeId"); Map<Locale, String> friendlyURLMap = new HashMap<>(); String friendlyURL = layoutJSONObject.getString("friendlyURL"); if (Validator.isNotNull(friendlyURL) && !friendlyURL.startsWith(StringPool.SLASH)) { friendlyURL = StringPool.SLASH + friendlyURL; } friendlyURLMap.put(LocaleUtil.getDefault(), friendlyURL); ServiceContext serviceContext = new ServiceContext(); serviceContext.setCompanyId(companyId); serviceContext.setScopeGroupId(groupId); serviceContext.setUserId(userId); ServiceContextThreadLocal.pushServiceContext(serviceContext); try { String layoutPrototypeName = layoutJSONObject.getString("layoutPrototypeName"); String layoutPrototypeUuid = null; if (Validator.isNotNull(layoutPrototypeName)) { LayoutPrototype layoutPrototype = getLayoutPrototype(companyId, layoutPrototypeName); layoutPrototypeUuid = layoutPrototype.getUuid(); } else { layoutPrototypeUuid = layoutJSONObject.getString("layoutPrototypeUuid"); } if (Validator.isNotNull(layoutPrototypeUuid)) { boolean layoutPrototypeLinkEnabled = GetterUtil .getBoolean(layoutJSONObject.getString("layoutPrototypeLinkEnabled")); serviceContext.setAttribute("layoutPrototypeLinkEnabled", layoutPrototypeLinkEnabled); serviceContext.setAttribute("layoutPrototypeUuid", layoutPrototypeUuid); } Layout layout = layoutLocalService.fetchLayoutByFriendlyURL(groupId, privateLayout, friendlyURL); if (layout != null) { if (!developerModeEnabled) { if (_log.isInfoEnabled()) { _log.info("Layout with friendly URL " + friendlyURL + " already exists"); } return; } if (!updateModeEnabled) { layoutLocalService.deleteLayout(layout); } } if (!updateModeEnabled || (layout == null)) { layout = layoutLocalService.addLayout(userId, groupId, privateLayout, parentLayoutId, nameMap, titleMap, null, null, null, type, typeSettings, hidden, friendlyURLMap, serviceContext); } else { resetLayoutColumns(layout); layout = layoutLocalService.updateLayout(groupId, privateLayout, layout.getLayoutId(), parentLayoutId, nameMap, titleMap, layout.getDescriptionMap(), layout.getKeywordsMap(), layout.getRobotsMap(), type, hidden, friendlyURLMap, layout.getIconImage(), null, serviceContext); } if (Validator.isNotNull(themeId) || Validator.isNotNull(colorSchemeId)) { // If the theme ID or the color scheme ID are not null, then the // layout has a custom look and feel and should be updated in // the database layoutLocalService.updateLookAndFeel(groupId, privateLayout, layout.getLayoutId(), themeId, colorSchemeId, layoutCss); } LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType(); String layoutTemplateId = layoutJSONObject.getString("layoutTemplateId", _defaultLayoutTemplateId); if (Validator.isNotNull(layoutTemplateId)) { layoutTypePortlet.setLayoutTemplateId(userId, layoutTemplateId, false); } JSONArray columnsJSONArray = layoutJSONObject.getJSONArray("columns"); addLayoutColumns(layout, LayoutTypePortletConstants.COLUMN_PREFIX, columnsJSONArray); layoutLocalService.updateLayout(groupId, layout.isPrivateLayout(), layout.getLayoutId(), layout.getTypeSettings()); JSONArray layoutsJSONArray = layoutJSONObject.getJSONArray("layouts"); addLayouts(privateLayout, layout.getLayoutId(), layoutsJSONArray); } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn("Unable to import layout " + layoutJSONObject, e); } throw e; } finally { ServiceContextThreadLocal.popServiceContext(); } }
From source file:com.liferay.layout.service.test.LayoutServiceTest.java
License:Open Source License
@Test public void testUpdateLayoutFriendlyURLMap() throws Exception { Layout layout = LayoutTestUtil.addLayout(_group); long userId = layout.getUserId(); layout.setUserId(-1);/*from w ww . j a v a 2s . c o m*/ LayoutLocalServiceUtil.updateLayout(layout); Map<Locale, String> friendlyURLMap = layout.getFriendlyURLMap(); friendlyURLMap.put(LocaleUtil.GERMANY, StringPool.SLASH + RandomTestUtil.randomString()); ServiceContext serviceContext = new ServiceContext(); serviceContext.setUserId(userId); LayoutLocalServiceUtil.updateLayout(_group.getGroupId(), layout.isPrivateLayout(), layout.getLayoutId(), layout.getParentLayoutId(), layout.getNameMap(), layout.getTitleMap(), layout.getDescriptionMap(), layout.getKeywordsMap(), layout.getRobotsMap(), layout.getType(), layout.isHidden(), friendlyURLMap, layout.getIconImage(), null, serviceContext); }