Example usage for com.liferay.portal.kernel.model Layout setTypeSettingsProperties

List of usage examples for com.liferay.portal.kernel.model Layout setTypeSettingsProperties

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.model Layout setTypeSettingsProperties.

Prototype

public void setTypeSettingsProperties(com.liferay.portal.kernel.util.UnicodeProperties typeSettingsProperties);

Source Link

Usage

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

License:Open Source License

protected void resetLayoutColumns(Layout layout) {
    UnicodeProperties typeSettings = layout.getTypeSettingsProperties();

    Set<Map.Entry<String, String>> set = typeSettings.entrySet();

    Iterator<Map.Entry<String, String>> iterator = set.iterator();

    while (iterator.hasNext()) {
        Map.Entry<String, String> entry = iterator.next();

        String key = entry.getKey();

        if (!key.startsWith("column-")) {
            continue;
        }// w  ww.  j  a va  2 s  .  c  o m

        String[] portletIds = StringUtil.split(entry.getValue());

        for (String portletId : portletIds) {
            try {
                portletPreferencesLocalService.deletePortletPreferences(PortletKeys.PREFS_OWNER_ID_DEFAULT,
                        PortletKeys.PREFS_OWNER_TYPE_LAYOUT, layout.getPlid(), portletId);
            } catch (PortalException pe) {
                if (_log.isWarnEnabled()) {
                    _log.warn("Unable to delete portlet preferences for " + "portlet " + portletId, pe);
                }
            }
        }

        iterator.remove();
    }

    layout.setTypeSettingsProperties(typeSettings);

    layoutLocalService.updateLayout(layout);
}

From source file:com.liferay.exportimport.staging.StagingImpl.java

License:Open Source License

@Override
public void updateLastImportSettings(Element layoutElement, Layout layout,
        PortletDataContext portletDataContext) {

    Map<String, String[]> parameterMap = portletDataContext.getParameterMap();

    String cmd = MapUtil.getString(parameterMap, Constants.CMD);

    if (!cmd.equals(Constants.PUBLISH_TO_LIVE) && !cmd.equals("schedule_publish_to_live")) {

        return;// w  ww. ja  v a 2  s .c  o  m
    }

    UnicodeProperties typeSettingsProperties = layout.getTypeSettingsProperties();

    typeSettingsProperties.setProperty("last-import-date", String.valueOf(System.currentTimeMillis()));

    String layoutRevisionId = GetterUtil.getString(layoutElement.attributeValue("layout-revision-id"));

    typeSettingsProperties.setProperty("last-import-layout-revision-id", layoutRevisionId);

    String layoutSetBranchId = MapUtil.getString(parameterMap, "layoutSetBranchId");

    typeSettingsProperties.setProperty("last-import-layout-set-branch-id", layoutSetBranchId);

    String layoutSetBranchName = MapUtil.getString(parameterMap, "layoutSetBranchName");

    typeSettingsProperties.setProperty("last-import-layout-set-branch-name", layoutSetBranchName);

    String lastImportUserName = MapUtil.getString(parameterMap, "lastImportUserName");

    typeSettingsProperties.setProperty("last-import-user-name", lastImportUserName);

    String lastImportUserUuid = MapUtil.getString(parameterMap, "lastImportUserUuid");

    typeSettingsProperties.setProperty("last-import-user-uuid", lastImportUserUuid);

    String layoutBranchId = GetterUtil.getString(layoutElement.attributeValue("layout-branch-id"));

    typeSettingsProperties.setProperty("last-import-layout-branch-id", layoutBranchId);

    String layoutBranchName = GetterUtil.getString(layoutElement.attributeValue("layout-branch-name"));

    typeSettingsProperties.setProperty("last-import-layout-branch-name", layoutBranchName);

    layout.setTypeSettingsProperties(typeSettingsProperties);
}

From source file:com.liferay.exportimport.test.LayoutSetPrototypePropagationTest.java

License:Open Source License

protected Layout setLayoutUpdateable(Layout layout, boolean layoutUpdateable) throws Exception {

    UnicodeProperties typeSettingsProperties = layout.getTypeSettingsProperties();

    typeSettingsProperties.put(Sites.LAYOUT_UPDATEABLE, String.valueOf(layoutUpdateable));

    layout.setTypeSettingsProperties(typeSettingsProperties);

    return LayoutLocalServiceUtil.updateLayout(layout);
}

From source file:com.liferay.layout.admin.web.internal.exportimport.data.handler.LayoutStagedModelDataHandler.java

License:Open Source License

protected void updateTypeSettings(Layout importedLayout, Layout layout) throws PortalException {

    long groupId = layout.getGroupId();

    try {//from ww  w  .  j a  v a  2  s. c  om
        LayoutTypePortlet importedLayoutType = (LayoutTypePortlet) importedLayout.getLayoutType();

        List<String> importedPortletIds = importedLayoutType.getPortletIds();

        layout.setGroupId(importedLayout.getGroupId());

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

        importedPortletIds.removeAll(layoutTypePortlet.getPortletIds());

        if (!importedPortletIds.isEmpty()) {
            _portletLocalService.deletePortlets(importedLayout.getCompanyId(),
                    importedPortletIds.toArray(new String[importedPortletIds.size()]),
                    importedLayout.getPlid());
        }

        importedLayout.setTypeSettingsProperties(layoutTypePortlet.getTypeSettingsProperties());
    } finally {
        layout.setGroupId(groupId);
    }
}

From source file:com.liferay.nested.portlets.web.internal.portlet.NestedPortletsPortlet.java

License:Open Source License

protected void checkLayout(Layout layout, Collection<String> columnIds) {
    UnicodeProperties typeSettingsProperties = layout.getTypeSettingsProperties();

    String[] layoutColumnIds = StringUtil
            .split(typeSettingsProperties.get(LayoutTypePortletConstants.NESTED_COLUMN_IDS));

    boolean updateColumnIds = false;

    for (String columnId : columnIds) {
        String portletIds = typeSettingsProperties.getProperty(columnId);

        if (Validator.isNotNull(portletIds) && !ArrayUtil.contains(layoutColumnIds, columnId)) {

            layoutColumnIds = ArrayUtil.append(layoutColumnIds, columnId);

            updateColumnIds = true;/*  ww w. j  ava 2 s.c  o m*/
        }
    }

    if (updateColumnIds) {
        typeSettingsProperties.setProperty(LayoutTypePortletConstants.NESTED_COLUMN_IDS,
                StringUtil.merge(layoutColumnIds));

        layout.setTypeSettingsProperties(typeSettingsProperties);

        try {
            _layoutLocalService.updateLayout(layout.getGroupId(), layout.isPrivateLayout(),
                    layout.getLayoutId(), layout.getTypeSettings());
        } catch (Exception e) {
            if (_log.isWarnEnabled()) {
                _log.warn(e, e);
            }
        }
    }
}