Example usage for com.liferay.portal.kernel.model LayoutTypePortlet getTypeSettingsProperties

List of usage examples for com.liferay.portal.kernel.model LayoutTypePortlet getTypeSettingsProperties

Introduction

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

Prototype

public UnicodeProperties getTypeSettingsProperties();

Source Link

Usage

From source file:com.liferay.grow.layout.helper.service.impl.LayoutHelperServiceImpl.java

License:Open Source License

@Override
public void updateProfilePages() {
    if (_log.isInfoEnabled()) {
        _log.info("Updating Profile Pages...");
    }/*from  w  ww.  ja  v  a  2 s .co m*/

    List<User> users = _userLocalService.getUsers(QueryUtil.ALL_POS, QueryUtil.ALL_POS);

    for (User user : users) {
        try {
            if (user.isDefaultUser()) {
                continue;
            }

            List<Layout> layouts = _layoutLocalService.getLayouts(user.getGroupId(), false);

            if (layouts.size() != 1) {
                if (_log.isInfoEnabled()) {
                    _log.info("User: " + user.getScreenName() + " has " + layouts.size() + " public layout");
                }
            }

            if (layouts.isEmpty()) {
                continue;
            }

            Layout layout = layouts.get(0);

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

            // Update Theme

            layout.setThemeId("frontenduserprofilegrow_WAR_growthemeuserprofile");
            layout.setColorSchemeId("01");

            UnicodeProperties properties = layoutTypePortlet.getTypeSettingsProperties();

            properties.put("layoutUpdateable", Boolean.TRUE.toString());
            properties.put("sitemap-changefreq", "daily");
            properties.put("sitemap-include", "1");

            // Remove OWXPSubscribePortlet

            String owxpSubscribePortletId = "com_liferay_owxp_subscribe_portlet_OWXPSubscribePortlet";

            List<String> portletIds = layoutTypePortlet.getPortletIds();

            for (String portletId : portletIds) {
                if (portletId.startsWith(owxpSubscribePortletId)) {
                    layoutTypePortlet.removePortletId(user.getUserId(), portletId);

                    break;
                }
            }

            _layoutLocalService.updateLayout(layout);

            // Remove the Guest role's View permission from the Profile
            // Pages

            Role guestRole = _roleLocalService.getRole(layout.getCompanyId(), RoleConstants.GUEST);

            _resourcePermissionLocalService.setResourcePermissions(layout.getCompanyId(),
                    Layout.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL,
                    String.valueOf(layout.getPlid()), guestRole.getRoleId(), new String[0]);
        } catch (Exception e) {
            _log.error("Cannot remove View permission for " + user.getScreenName(), e);
        }
    }

    if (_log.isInfoEnabled()) {
        _log.info("Profile Pages have been updated");
    }

}

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 o m
        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);
    }
}