List of usage examples for com.liferay.portal.kernel.service LayoutServiceUtil getLayoutName
public static String getLayoutName(long groupId, boolean privateLayout, long layoutId, String languageId) throws com.liferay.portal.kernel.exception.PortalException
From source file:com.liferay.dynamic.data.mapping.internal.render.LinkToPageDDMFormFieldValueRenderer.java
License:Open Source License
@Override protected ValueAccessor getValueAcessor(Locale locale) { return new ValueAccessor(locale) { @Override/*from w w w . j a va 2 s . c o m*/ public String get(DDMFormFieldValue ddmFormFieldValue) { Value value = ddmFormFieldValue.getValue(); JSONObject jsonObject = createJSONObject(value.getString(locale)); long groupId = jsonObject.getLong("groupId"); boolean privateLayout = jsonObject.getBoolean("privateLayout"); long layoutId = jsonObject.getLong("layoutId"); if ((groupId == 0) && (layoutId == 0)) { return StringPool.BLANK; } try { return LayoutServiceUtil.getLayoutName(groupId, privateLayout, layoutId, LanguageUtil.getLanguageId(locale)); } catch (PortalException pe) { if (_log.isWarnEnabled()) { _log.warn(pe, pe); } return LanguageUtil.format(locale, "is-temporarily-unavailable", "content"); } } protected JSONObject createJSONObject(String json) { try { return JSONFactoryUtil.createJSONObject(json); } catch (JSONException jsone) { throw new ValueAccessorException(jsone); } } }; }
From source file:com.liferay.dynamic.data.mapping.render.DDMFormFieldValueRendererTest.java
License:Open Source License
protected void setUpLayoutServiceUtil() throws Exception { mockStatic(LayoutServiceUtil.class); when(LayoutServiceUtil.getLayoutName(Matchers.anyLong(), Matchers.anyBoolean(), Matchers.anyLong(), Matchers.eq("en_US"))).thenReturn("Layout Name"); when(LayoutServiceUtil.getLayoutName(Matchers.anyLong(), Matchers.anyBoolean(), Matchers.anyLong(), Matchers.eq("pt_BR"))).thenReturn("Nome da Pagina"); }
From source file:com.liferay.dynamic.data.mapping.storage.impl.LinkToPageFieldRenderer.java
License:Open Source License
protected String handleJSON(String value, Locale locale) { JSONObject jsonObject = null;// ww w . j ava2 s . co m try { jsonObject = JSONFactoryUtil.createJSONObject(value); } catch (JSONException jsone) { if (_log.isDebugEnabled()) { _log.debug("Unable to parse JSON", jsone); } return StringPool.BLANK; } long groupId = jsonObject.getLong("groupId"); boolean privateLayout = jsonObject.getBoolean("privateLayout"); long layoutId = jsonObject.getLong("layoutId"); try { return LayoutServiceUtil.getLayoutName(groupId, privateLayout, layoutId, LanguageUtil.getLanguageId(locale)); } catch (Exception e) { if (e instanceof NoSuchLayoutException || e instanceof PrincipalException) { return LanguageUtil.format(locale, "is-temporarily-unavailable", "content"); } } return StringPool.BLANK; }