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

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

Introduction

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

Prototype

public List<String> getPortletIds();

Source Link

Usage

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

License:Open Source License

@Override
public void afterPropertiesSet() throws Exception {
    User user = UserLocalServiceUtil.getDefaultUser(companyId);

    userId = user.getUserId();//  www  . java  2  s . co m

    if (isCompanyGroup()) {
        return;
    }

    Group group = null;

    if (targetClassName.equals(LayoutSetPrototype.class.getName())) {
        LayoutSetPrototype layoutSetPrototype = getLayoutSetPrototype(companyId, targetValue);

        if (layoutSetPrototype != null) {
            existing = true;
        } else {
            layoutSetPrototype = LayoutSetPrototypeLocalServiceUtil.addLayoutSetPrototype(userId, companyId,
                    getTargetValueMap(), new HashMap<Locale, String>(), true, true, new ServiceContext());
        }

        group = layoutSetPrototype.getGroup();

        targetClassPK = layoutSetPrototype.getLayoutSetPrototypeId();
    } else if (targetClassName.equals(Group.class.getName())) {
        if (targetValue.equals(GroupConstants.GLOBAL)) {
            group = GroupLocalServiceUtil.getCompanyGroup(companyId);
        } else if (targetValue.equals(GroupConstants.GUEST)) {
            group = GroupLocalServiceUtil.getGroup(companyId, GroupConstants.GUEST);

            List<Layout> layouts = LayoutLocalServiceUtil.getLayouts(group.getGroupId(), false,
                    LayoutConstants.DEFAULT_PARENT_LAYOUT_ID, false, 0, 1);

            if (!layouts.isEmpty()) {
                Layout layout = layouts.get(0);

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

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

                if (portletIds.size() != 2) {
                    existing = true;
                }

                for (String portletId : portletIds) {
                    if (!portletId.equals("47") && !portletId.equals("58")) {

                        existing = true;
                    }
                }
            }
        } else {
            group = GroupLocalServiceUtil.fetchGroup(companyId, targetValue);

            if (group != null) {
                int privateLayoutPageCount = group.getPrivateLayoutsPageCount();

                int publicLayoutPageCount = group.getPublicLayoutsPageCount();

                if ((privateLayoutPageCount != 0) || (publicLayoutPageCount != 0)) {

                    existing = true;
                }
            } else {
                group = GroupLocalServiceUtil.addGroup(userId, GroupConstants.DEFAULT_PARENT_GROUP_ID,
                        StringPool.BLANK, GroupConstants.DEFAULT_PARENT_GROUP_ID,
                        GroupConstants.DEFAULT_LIVE_GROUP_ID, getMap(targetValue), null,
                        GroupConstants.TYPE_SITE_OPEN, true, GroupConstants.DEFAULT_MEMBERSHIP_RESTRICTION,
                        null, true, true, new ServiceContext());
            }
        }

        targetClassPK = group.getGroupId();
    }

    if (group != null) {
        groupId = group.getGroupId();
    }
}

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 w w . j  a v a 2  s .c o  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.journal.service.impl.JournalContentSearchLocalServiceImpl.java

License:Open Source License

@Override
public void checkContentSearches(long companyId) throws PortalException {
    if (_log.isInfoEnabled()) {
        _log.info("Checking journal content search for " + companyId);
    }/*w  w w  .j av a 2s . c o  m*/

    List<Layout> layouts = new ArrayList<>();

    List<Group> groups = groupLocalService.search(companyId, null, null, null, QueryUtil.ALL_POS,
            QueryUtil.ALL_POS);

    for (Group group : groups) {

        // Private layouts

        deleteOwnerContentSearches(group.getGroupId(), true);

        layouts.addAll(layoutLocalService.getLayouts(group.getGroupId(), true));

        // Public layouts

        deleteOwnerContentSearches(group.getGroupId(), false);

        layouts.addAll(layoutLocalService.getLayouts(group.getGroupId(), false));
    }

    for (Layout layout : layouts) {
        LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType();

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

        for (String portletId : portletIds) {
            String rootPortletId = PortletConstants.getRootPortletId(portletId);

            DisplayInformationProvider displayInformationProvider = _serviceTrackerMap
                    .getService(rootPortletId);

            if (displayInformationProvider == null) {
                continue;
            }

            PortletPreferences portletPreferences = portletPreferencesLocalService.getPreferences(
                    layout.getCompanyId(), PortletKeys.PREFS_OWNER_ID_DEFAULT,
                    PortletKeys.PREFS_OWNER_TYPE_LAYOUT, layout.getPlid(), portletId);

            String classPK = displayInformationProvider.getClassPK(portletPreferences);

            updateContentSearch(layout.getGroupId(), layout.isPrivateLayout(), layout.getLayoutId(), portletId,
                    classPK);
        }
    }
}

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  w w  w .ja 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);
    }
}