Example usage for com.liferay.portal.kernel.service UserLocalServiceUtil getSocialUsers

List of usage examples for com.liferay.portal.kernel.service UserLocalServiceUtil getSocialUsers

Introduction

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

Prototype

public static java.util.List<com.liferay.portal.kernel.model.User> getSocialUsers(long userId1, long userId2,
        int start, int end,
        com.liferay.portal.kernel.util.OrderByComparator<com.liferay.portal.kernel.model.User> obc)
        throws com.liferay.portal.kernel.exception.PortalException 

Source Link

Document

Returns an ordered range of all the users with a mutual social relation with both of the given users.

Usage

From source file:com.liferay.microblogs.web.internal.util.MicroblogsWebUtil.java

License:Open Source License

public static JSONArray getJSONRecipients(long userId, ThemeDisplay themeDisplay) throws PortalException {

    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();

    List<User> users = UserLocalServiceUtil.getSocialUsers(userId, SocialRelationConstants.TYPE_BI_CONNECTION,
            QueryUtil.ALL_POS, QueryUtil.ALL_POS, new UserFirstNameComparator(true));

    for (User user : users) {
        if (user.isDefaultUser() || (userId == user.getUserId())) {
            continue;
        }/*from  w  ww  . j  a v a  2s . c  o  m*/

        JSONObject userJSONObject = JSONFactoryUtil.createJSONObject();

        userJSONObject.put("emailAddress", user.getEmailAddress());
        userJSONObject.put("fullName", user.getFullName());
        userJSONObject.put("jobTitle", user.getJobTitle());
        userJSONObject.put("portraitURL", user.getPortraitURL(themeDisplay));
        userJSONObject.put("screenName", user.getScreenName());
        userJSONObject.put("userId", user.getUserId());

        jsonArray.put(userJSONObject);
    }

    return jsonArray;
}

From source file:com.liferay.social.activity.service.test.SocialRelationLocalServiceTest.java

License:Open Source License

@Test
public void testGetMutualRelations() throws Exception {
    User dlc1User = UserLocalServiceUtil.getUserByScreenName(TestPropsValues.getCompanyId(), "dlc1");

    User dlc2User = UserLocalServiceUtil.getUserByScreenName(TestPropsValues.getCompanyId(), "dlc2");

    // Do dlc1 and dlc2 have 4 mutual relations?

    List<User> users = UserLocalServiceUtil.getSocialUsers(dlc1User.getUserId(), dlc2User.getUserId(),
            QueryUtil.ALL_POS, QueryUtil.ALL_POS, new UserScreenNameComparator(true));

    Assert.assertEquals(users.toString(), 4, users.size());
}