Example usage for com.liferay.portal.kernel.model PortletPreferencesIds getOwnerType

List of usage examples for com.liferay.portal.kernel.model PortletPreferencesIds getOwnerType

Introduction

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

Prototype

public int getOwnerType() 

Source Link

Usage

From source file:com.liferay.asset.publisher.web.util.AssetPublisherUtil.java

License:Open Source License

public static long getSubscriptionClassPK(long ownerId, int ownerType, long plid, String portletId)
        throws PortalException {

    if (plid != LayoutConstants.DEFAULT_PLID) {
        Layout layout = _layoutLocalService.fetchLayout(plid);

        if (layout != null) {
            long userId = 0;

            if (PortletIdCodec.hasUserId(portletId)) {
                userId = PortletIdCodec.decodeUserId(portletId);
            }/*ww  w  .jav a2 s  .c  o  m*/

            PortletPreferencesIds portletPreferencesIds = _portletPreferencesFactory
                    .getPortletPreferencesIds(layout.getGroupId(), userId, layout, portletId, false);

            ownerId = portletPreferencesIds.getOwnerId();
            ownerType = portletPreferencesIds.getOwnerType();
            plid = portletPreferencesIds.getPlid();
            portletId = portletPreferencesIds.getPortletId();
        }
    }

    if (PortletIdCodec.hasUserId(portletId)) {
        ownerId = PortletIdCodec.decodeUserId(portletId);
        ownerType = PortletKeys.PREFS_OWNER_TYPE_USER;
    }

    com.liferay.portal.kernel.model.PortletPreferences portletPreferencesModel = _portletPreferencesLocalService
            .getPortletPreferences(ownerId, ownerType, plid, portletId);

    return portletPreferencesModel.getPortletPreferencesId();
}