List of usage examples for com.liferay.portal.kernel.poller PollerRequest getUserId
public long getUserId()
From source file:com.liferay.chat.poller.ChatPollerProcessor.java
License:Open Source License
protected void addEntry(PollerRequest pollerRequest) throws Exception { long toUserId = getLong(pollerRequest, "toUserId"); String content = getString(pollerRequest, "content"); if (toUserId > 0) { EntryLocalServiceUtil.addEntry(pollerRequest.getTimestamp(), pollerRequest.getUserId(), toUserId, content);//from www . j ava 2s . c o m } }
From source file:com.liferay.chat.poller.ChatPollerProcessor.java
License:Open Source License
protected void getBuddies(PollerRequest pollerRequest, PollerResponse pollerResponse) throws Exception { List<Object[]> buddies = BuddyFinderUtil.getBuddies(pollerRequest.getCompanyId(), pollerRequest.getUserId()); JSONArray buddiesJSONArray = JSONFactoryUtil.createJSONArray(); for (Object[] buddy : buddies) { boolean awake = (Boolean) buddy[0]; String firstName = (String) buddy[1]; long groupId = (Long) buddy[2]; String lastName = (String) buddy[3]; boolean male = (Boolean) buddy[4]; String middleName = (String) buddy[5]; long portraitId = (Long) buddy[6]; String screenName = (String) buddy[7]; long userId = (Long) buddy[8]; String userUuid = (String) buddy[9]; JSONObject curUserJSONObject = JSONFactoryUtil.createJSONObject(); Status buddyStatus = StatusLocalServiceUtil.getUserStatus(userId); awake = buddyStatus.getAwake();//from w ww .ja v a2s . c o m curUserJSONObject.put("awake", awake); String fullName = ContactConstants.getFullName(firstName, middleName, lastName); curUserJSONObject.put("fullName", fullName); curUserJSONObject.put("groupId", groupId); curUserJSONObject.put("portraitId", portraitId); String portraitURL = UserConstants.getPortraitURL(StringPool.BLANK, male, portraitId, userUuid); curUserJSONObject.put("portraitURL", portraitURL); curUserJSONObject.put("screenName", screenName); String statusMessage = buddyStatus.getMessage(); curUserJSONObject.put("statusMessage", statusMessage); curUserJSONObject.put("userId", userId); buddiesJSONArray.put(curUserJSONObject); } pollerResponse.setParameter("buddies", buddiesJSONArray); }
From source file:com.liferay.chat.poller.ChatPollerProcessor.java
License:Open Source License
protected void getEntries(PollerRequest pollerRequest, PollerResponse pollerResponse) throws Exception { Status status = StatusLocalServiceUtil.getUserStatus(pollerRequest.getUserId()); long createDate = 0; if (pollerRequest.isInitialRequest()) { createDate = status.getModifiedDate() - Time.DAY; }/*w w w. j a va2 s . c o m*/ List<Entry> entries = EntryLocalServiceUtil.getNewEntries(pollerRequest.getUserId(), createDate, 0, PortletPropsValues.BUDDY_LIST_MAX_BUDDIES); entries = ListUtil.copy(entries); Collections.reverse(entries); JSONArray entriesJSONArray = JSONFactoryUtil.createJSONArray(); for (Entry entry : entries) { JSONObject entryJSONObject = JSONFactoryUtil.createJSONObject(); entryJSONObject.put("entryId", entry.getEntryId()); entryJSONObject.put("createDate", entry.getCreateDate()); entryJSONObject.put("fromUserId", entry.getFromUserId()); if (entry.getFromUserId() != pollerRequest.getUserId()) { try { User fromUser = UserLocalServiceUtil.getUserById(entry.getFromUserId()); entryJSONObject.put("fromFullName", fromUser.getFullName()); entryJSONObject.put("fromPortraitId", fromUser.getPortraitId()); } catch (NoSuchUserException nsue) { continue; } } entryJSONObject.put("toUserId", entry.getToUserId()); entryJSONObject.put("content", HtmlUtil.escape(entry.getContent())); entryJSONObject.put("flag", entry.getFlag()); entriesJSONArray.put(entryJSONObject); } pollerResponse.setParameter("entries", entriesJSONArray); if (!entries.isEmpty()) { pollerResponse.setParameter(PollerResponse.POLLER_HINT_HIGH_CONNECTIVITY, Boolean.TRUE.toString()); } boolean updatePresence = getBoolean(pollerRequest, "updatePresence"); if (updatePresence) { } else if (!entries.isEmpty()) { updatePresence = true; } else { long onlineTimestamp = status.getModifiedDate() + ChatConstants.ONLINE_DELTA - ChatConstants.MAX_POLL_LATENCY; if (onlineTimestamp < pollerRequest.getTimestamp()) { updatePresence = true; } } if (updatePresence) { StatusLocalServiceUtil.updateStatus(pollerRequest.getUserId(), pollerRequest.getTimestamp()); } }
From source file:com.liferay.chat.poller.ChatPollerProcessor.java
License:Open Source License
protected void updateStatus(PollerRequest pollerRequest) throws Exception { long timestamp = -1; int online = getInteger(pollerRequest, "online"); int awake = getInteger(pollerRequest, "awake"); String activePanelIds = getString(pollerRequest, "activePanelIds"); String statusMessage = getString(pollerRequest, "statusMessage"); int playSound = getInteger(pollerRequest, "playSound"); if ((online != -1) || (awake != -1) || (activePanelIds != null) || (statusMessage != null) || (playSound != -1)) {/*from w w w. jav a2 s. co m*/ StatusLocalServiceUtil.updateStatus(pollerRequest.getUserId(), timestamp, online, awake, activePanelIds, statusMessage, playSound); } }
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); }//from www . j ava 2 s. 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.chat.video.poller.ChatVideoPollerProcessor.java
License:Open Source License
@Override protected void doSend(PollerRequest pollerRequest) throws Exception { long destinationUserId = getLong(pollerRequest, "destinationUserId"); String messageType = getString(pollerRequest, "type"); if (messageType.equals("answer")) { boolean answer = getBoolean(pollerRequest, "answer"); _webRTCManager.answer(pollerRequest.getUserId(), destinationUserId, answer); } else if (messageType.equals("call")) { _webRTCManager.call(pollerRequest.getUserId(), destinationUserId); } else if (messageType.equals("hangUp")) { _webRTCManager.hangUp(pollerRequest.getUserId(), destinationUserId); } else if (messageType.equals("ice")) { String candidate = getString(pollerRequest, "candidate"); _webRTCManager.pushICECandidateWebRTCMail(pollerRequest.getUserId(), destinationUserId, candidate); } else if (messageType.equals("reset")) { _webRTCManager.resetWebRTCClient(pollerRequest.getUserId()); } else if (messageType.equals("sdp")) { String description = getString(pollerRequest, "description"); _webRTCManager.pushDescriptionWebRTCSDPMail(pollerRequest.getUserId(), destinationUserId, description); } else if (messageType.equals("setAvailability")) { boolean available = getBoolean(pollerRequest, "available"); _webRTCManager.updateWebRTCClientAvailability(pollerRequest.getUserId(), available); } else if (messageType.equals("updatePresence")) { _webRTCManager.updateWebRTCClientPresence(pollerRequest.getUserId()); }/*from ww w . j av a 2 s . c om*/ }
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 {/*from w ww . java2 s . c o 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; }
From source file:org.opencps.notification.dockbarnotifications.poller.DockbarNotificationsPollerProcessor.java
License:Open Source License
protected void setUserNotificationsCount(PollerRequest pollerRequest, PollerResponse pollerResponse) throws Exception { pollerResponse.setParameter("timestamp", String.valueOf(System.currentTimeMillis())); int unreadUserNotificationsCount = UserNotificationEventLocalServiceUtil .getArchivedUserNotificationEventsCount(pollerRequest.getUserId(), false); pollerResponse.setParameter("unreadUserNotificationsCount", String.valueOf(unreadUserNotificationsCount)); }