Example usage for com.liferay.portal.kernel.service SubscriptionLocalServiceUtil addSubscription

List of usage examples for com.liferay.portal.kernel.service SubscriptionLocalServiceUtil addSubscription

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.service SubscriptionLocalServiceUtil addSubscription.

Prototype

public static com.liferay.portal.kernel.model.Subscription addSubscription(long userId, long groupId,
        String className, long classPK, String frequency)
        throws com.liferay.portal.kernel.exception.PortalException 

Source Link

Document

Subscribes the user to the entity, notifying him at the given frequency.

Usage

From source file:com.liferay.owxp.subscribe.portlet.OWXPSubscribePortlet.java

License:Open Source License

public void subscribe(ActionRequest actionRequest, ActionResponse actionResponse) throws PortalException {

    long companyId = GetterUtil.getLong(actionRequest.getParameter("companyId"));
    long subscriberId = GetterUtil.getLong(actionRequest.getParameter("subscriberId"));
    long subscribeToId = GetterUtil.getLong(actionRequest.getParameter("subscribeToId"));

    if (SubscriptionLocalServiceUtil.isSubscribed(companyId, subscriberId, User.class.getName(),
            subscribeToId)) {//  w  w  w .j ava 2  s.c  o m

        SubscriptionLocalServiceUtil.deleteSubscription(subscriberId, User.class.getName(), subscribeToId);
    } else {
        SubscriptionLocalServiceUtil.addSubscription(subscriberId, 0, User.class.getName(), subscribeToId,
                "instant");
    }
}