Example usage for com.liferay.portal.kernel.poller PollerRequest createPollerResponse

List of usage examples for com.liferay.portal.kernel.poller PollerRequest createPollerResponse

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.poller PollerRequest createPollerResponse.

Prototype

public PollerResponse createPollerResponse() 

Source Link

Usage

From source file:com.liferay.chat.poller.ChatPollerProcessor.java

License:Open Source License

@Override
protected PollerResponse doReceive(PollerRequest pollerRequest) throws Exception {

    PollerResponse pollerResponse = pollerRequest.createPollerResponse();

    getBuddies(pollerRequest, pollerResponse);
    getEntries(pollerRequest, pollerResponse);

    return pollerResponse;
}

From source file:com.liferay.chat.video.poller.ChatVideoPollerProcessor.java

License:Open Source License

@Override
protected PollerResponse doReceive(PollerRequest pollerRequest) throws Exception {

    PollerResponse pollerResponse = pollerRequest.createPollerResponse();

    JSONObject webRTCResponseJSONObject = JSONFactoryUtil.createJSONObject();

    JSONArray webRTCClientsJSONArray = JSONFactoryUtil.createJSONArray();

    for (Long userId : _webRTCManager.getAvailableWebRTCClientIds()) {
        if (userId != pollerRequest.getUserId()) {
            webRTCClientsJSONArray.put(userId);
        }//w  w w  .java 2s.  c o m
    }

    webRTCResponseJSONObject.put("clients", webRTCClientsJSONArray);

    WebRTCClient webRTCClient = _webRTCManager.getWebRTCClient(pollerRequest.getUserId());

    JSONArray webRTCMailsJSONArray = JSONFactoryUtil.createJSONArray();

    if (webRTCClient != null) {
        WebRTCMailbox webRTCMailbox = webRTCClient.getOutgoingWebRTCMailbox();

        List<WebRTCMail> webRTCMails = webRTCMailbox.popWebRTCMails();

        for (WebRTCMail webRTCMail : webRTCMails) {
            JSONObject mailJSONObject = JSONFactoryUtil.createJSONObject();

            mailJSONObject.put("message", webRTCMail.getMessageJSONObject());
            mailJSONObject.put("sourceUserId", webRTCMail.getSourceUserId());
            mailJSONObject.put("type", webRTCMail.getMessageType());

            webRTCMailsJSONArray.put(mailJSONObject);
        }
    }

    webRTCResponseJSONObject.put("mails", webRTCMailsJSONArray);

    pollerResponse.setParameter("webRTCResponse", webRTCResponseJSONObject);

    return pollerResponse;
}

From source file:com.liferay.notifications.dockbarnotifications.poller.DockbarNotificationsPollerProcessor.java

License:Open Source License

protected PollerResponse setUserNotificationsCount(PollerRequest pollerRequest) throws Exception {

    PollerResponse pollerResponse = pollerRequest.createPollerResponse();

    pollerResponse.setParameter("timestamp", String.valueOf(System.currentTimeMillis()));

    if (PortletPropsValues.USER_NOTIFICATION_DOCKBAR_SPLIT) {
        int newActionableUserNotificationsCount = UserNotificationEventLocalServiceUtil
                .getDeliveredUserNotificationEventsCount(pollerRequest.getUserId(),
                        UserNotificationDeliveryConstants.TYPE_WEBSITE, false, true);

        pollerResponse.setParameter("newActionableUserNotificationsCount",
                String.valueOf(newActionableUserNotificationsCount));

        int newNonactionableUserNotificationsCount = UserNotificationEventLocalServiceUtil
                .getDeliveredUserNotificationEventsCount(pollerRequest.getUserId(),
                        UserNotificationDeliveryConstants.TYPE_WEBSITE, false, false);

        pollerResponse.setParameter("newNonactionableUserNotificationsCount",
                String.valueOf(newNonactionableUserNotificationsCount));

        int unreadActionableUserNotificationsCount = UserNotificationEventLocalServiceUtil
                .getArchivedUserNotificationEventsCount(pollerRequest.getUserId(),
                        UserNotificationDeliveryConstants.TYPE_WEBSITE, true, false);

        pollerResponse.setParameter("unreadActionableUserNotificationsCount",
                String.valueOf(unreadActionableUserNotificationsCount));

        int unreadNonactionableUserNotificationsCount = UserNotificationEventLocalServiceUtil
                .getArchivedUserNotificationEventsCount(pollerRequest.getUserId(),
                        UserNotificationDeliveryConstants.TYPE_WEBSITE, false, false);

        pollerResponse.setParameter("unreadNonactionableUserNotificationsCount",
                String.valueOf(unreadNonactionableUserNotificationsCount));
    } else {//  w w  w .jav a  2  s . co m
        int newUserNotificationsCount = UserNotificationEventLocalServiceUtil
                .getDeliveredUserNotificationEventsCount(pollerRequest.getUserId(),
                        UserNotificationDeliveryConstants.TYPE_WEBSITE, false);

        pollerResponse.setParameter("newUserNotificationsCount", String.valueOf(newUserNotificationsCount));

        int unreadUserNotificationsCount = UserNotificationEventLocalServiceUtil
                .getArchivedUserNotificationEventsCount(pollerRequest.getUserId(),
                        UserNotificationDeliveryConstants.TYPE_WEBSITE, false);

        pollerResponse.setParameter("unreadUserNotificationsCount",
                String.valueOf(unreadUserNotificationsCount));
    }

    return pollerResponse;
}

From source file:com.liferay.notifications.web.internal.poller.NotificationsPollerProcessor.java

License:Open Source License

protected PollerResponse setUserNotificationsCount(PollerRequest pollerRequest) throws Exception {

    PollerResponse pollerResponse = pollerRequest.createPollerResponse();

    pollerResponse.setParameter("timestamp", String.valueOf(System.currentTimeMillis()));

    int newUserNotificationsCount = _userNotificationEventLocalService.getDeliveredUserNotificationEventsCount(
            pollerRequest.getUserId(), UserNotificationDeliveryConstants.TYPE_WEBSITE, false);

    pollerResponse.setParameter("newUserNotificationsCount", String.valueOf(newUserNotificationsCount));

    int unreadUserNotificationsCount = _userNotificationEventLocalService
            .getArchivedUserNotificationEventsCount(pollerRequest.getUserId(),
                    UserNotificationDeliveryConstants.TYPE_WEBSITE, false);

    pollerResponse.setParameter("unreadUserNotificationsCount", String.valueOf(unreadUserNotificationsCount));

    return pollerResponse;
}