Example usage for com.liferay.portal.kernel.portlet DisplayInformationProvider getClassPK

List of usage examples for com.liferay.portal.kernel.portlet DisplayInformationProvider getClassPK

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.portlet DisplayInformationProvider getClassPK.

Prototype

public String getClassPK(PortletPreferences portletPreferences);

Source Link

Usage

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  a va  2 s  .  c  om

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