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

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

Introduction

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

Prototype

public long getCompanyId() 

Source Link

Usage

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());//w w  w  .ja  v a 2 s.  com

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

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