Example usage for com.liferay.portal.kernel.util PortletKeys NESTED_PORTLETS

List of usage examples for com.liferay.portal.kernel.util PortletKeys NESTED_PORTLETS

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util PortletKeys NESTED_PORTLETS.

Prototype

String NESTED_PORTLETS

To view the source code for com.liferay.portal.kernel.util PortletKeys NESTED_PORTLETS.

Click Source Link

Usage

From source file:com.liferay.exportimport.resources.importer.internal.util.FileSystemImporter.java

License:Open Source License

protected void addLayoutColumnPortlet(Layout layout, String columnId, JSONObject portletJSONObject)
        throws Exception {

    LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType();

    String rootPortletId = portletJSONObject.getString("portletId");

    if (Validator.isNull(rootPortletId)) {
        throw new ImporterException("portletId is not specified");
    }/*from  w w  w  . j av  a2  s  .  c o m*/

    PortletPreferencesTranslator portletPreferencesTranslator = portletPreferencesTranslators
            .get(rootPortletId);

    String portletId = layoutTypePortlet.addPortletId(userId, rootPortletId, columnId, -1, false);

    if (portletId == null) {
        return;
    }

    JSONObject portletPreferencesJSONObject = portletJSONObject.getJSONObject("portletPreferences");

    if ((portletPreferencesJSONObject == null) || (portletPreferencesJSONObject.length() == 0)) {

        return;
    }

    if (portletPreferencesTranslator != null) {
        PortletPreferencesIds portletPreferencesIds = PortletPreferencesFactoryUtil
                .getPortletPreferencesIds(layout.getGroupId(), 0, layout, portletId, false);

        PortletPreferences portletSetup = PortletPreferencesLocalServiceUtil
                .getPreferences(portletPreferencesIds);

        Iterator<String> iterator = portletPreferencesJSONObject.keys();

        while (iterator.hasNext()) {
            String key = iterator.next();

            portletPreferencesTranslator.translate(portletPreferencesJSONObject, key, portletSetup);
        }

        portletSetup.store();
    }

    if (rootPortletId.equals(PortletKeys.NESTED_PORTLETS)) {
        JSONArray columnsJSONArray = portletPreferencesJSONObject.getJSONArray("columns");

        StringBundler sb = new StringBundler(4);

        sb.append(StringPool.UNDERLINE);
        sb.append(portletId);
        sb.append(StringPool.DOUBLE_UNDERLINE);
        sb.append(LayoutTypePortletConstants.COLUMN_PREFIX);

        addLayoutColumns(layout, sb.toString(), columnsJSONArray);
    }
}