Uploaded image for project: 'Rave'
  1. Rave
  2. RAVE-599

OpenSocial query for listing viewer friends returns always zero results

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 0.11
    • 0.12
    • Windows 7, Tomcat 7

    Description

      OSAPI query for retrieving friends is not returning any records.

      It seems to be a problem between DefaultPersonService and its connections with PersonRepository and Person classes. Inside the DefaultPersonService, the userID (instead of the username) is passed as the USERNAME parameter, necessary to the named query Person.FIND_FRIENDS_BY_USERNAME. Hence, the query will always results in an empty dataset.

      I've fixed it passing the username to the PersonRepository findFriends method, but I don't know if it's the better solution (I've started to study Rave about a week ago).

      See the example bellow:
      JS call:
      osapi.people.get(

      {userId: '@viewer', groupId: '@friends'}

      ).execute(listFriends);

      calls DefaultPersonService.getUniqueListOfFriends method:
      for (UserId id : userIds)

      { //ORIGINAL CODE: passes the userID to the repository object //CollectionUtils.addUniqueValues(getFriendsFromRepository(collectionOptions, token.getAppId(), id.getUserId(token)), people); //MY WORKARROUND CODE...: passes the username to the repository object org.apache.rave.portal.model.Person person = this.getPersonForId(id, token); CollectionUtils.addUniqueValues(getFriendsFromRepository(collectionOptions, token.getAppId(), person.getUsername()), people); }

      NamedQuery called:
      @NamedQuery(name = Person.FIND_FRIENDS_BY_USERNAME, query = "select a.followed from PersonAssociation a where a.follower.username = :username")

      Attachments

        Activity

          People

            Unassigned Unassigned
            fernandopinhati Fernando Pinhati
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment