Package org.apache.shindig.social.opensocial.spi

Examples of org.apache.shindig.social.opensocial.spi.GroupId


    }

    @Test
    public void getPeople_groupIsFriendsWith() throws ExecutionException, InterruptedException {
        Set<UserId> ids = getUserIdSet();
        GroupId groupId = new GroupId(GroupId.Type.groupId, GROUP_ID);
        String appId = "5";
        expect(token.getAppId()).andReturn(appId).anyTimes();
        replay(token);

        CollectionOptions options = new CollectionOptions();
View Full Code Here


    public void getPeople_deleted() throws ExecutionException, InterruptedException {
        String self = ID_1;
        expect(token.getViewerId()).andReturn(self);
        replay(token);
        Set<UserId> ids = getUserIdSet();
        GroupId groupId = new GroupId(GroupId.Type.deleted, GROUP_ID);

        Future<RestfulCollection<Person>> people = service.getPeople(ids, groupId, null, null, token);
    }
View Full Code Here

     * <p/>
     * examples: /people/john.doe/@all /people/john.doe/@friends /people/john.doe/@self
     */
    @Operation(httpMethods = "GET")
    public Future<?> get(SocialRequestItem request) throws ProtocolException {
        GroupId groupId = request.getGroup();
        Set<String> optionalPersonId = ImmutableSet.copyOf(request.getListParameter("personId"));
        Set<String> fields = request.getFields(Person.Field.DEFAULT_FIELDS);
        Set<UserId> userIds = request.getUsers();

        // Preconditions
        HandlerPreconditions.requireNotEmpty(userIds, "No userId specified");
// //   if (userIds.size() > 1 && !optionalPersonId.isEmpty()) {
// //     throw new IllegalArgumentException("Cannot fetch personIds for multiple userIds");
// //  }

        CollectionOptions options = new CollectionOptions(request);

        ////    if (userIds.size() == 1) {
        if (optionalPersonId.isEmpty()) {
            if (groupId.getType() == GroupId.Type.self) {
                // If a filter is set then we have to call getPeople(), otherwise use the simpler getPerson()
                if (options != null && options.getFilter() != null) {
                    Future<RestfulCollection<Person>> people = personService.getPeople(
                            userIds, groupId, options, fields, request.getToken());
                    return FutureUtil.getFirstFromCollection(people);
                } else {
                    return personService.getPerson(userIds.iterator().next(), fields, request.getToken());
                }
            } else {
                return personService.getPeople(userIds, groupId, options, fields, request.getToken());
            }
        } else if (optionalPersonId.size() == 1) {
            // TODO: Add some concept to handle the userId
            Set<UserId> optionalUserIds = ImmutableSet.of(
                    new UserId(UserId.Type.userId, optionalPersonId.iterator().next()));

            Future<RestfulCollection<Person>> people = personService.getPeople(
                    optionalUserIds, new GroupId(GroupId.Type.self, null),
                    options, fields, request.getToken());
            return FutureUtil.getFirstFromCollection(people);
        } else {
            ImmutableSet.Builder<UserId> personIds = ImmutableSet.builder();
            for (String pid : optionalPersonId) {
                personIds.add(new UserId(UserId.Type.userId, pid));
            }
            // Every other case is a collection response of optional person ids
            return personService.getPeople(personIds.build(), new GroupId(GroupId.Type.self, null),
                    options, fields, request.getToken());
        }
        ////   }

        // Every other case is a collection response.
View Full Code Here

   *
   * examples: /people/john.doe/@all /people/john.doe/@friends /people/john.doe/@self
   */
  @Operation(httpMethods = "GET")
  public Future<?> get(SocialRequestItem request) throws ProtocolException {
    GroupId groupId = request.getGroup();
    Set<String> optionalPersonId = ImmutableSet.copyOf(request.getListParameter("personId"));
    Set<String> fields = request.getFields(Person.Field.DEFAULT_FIELDS);
    Set<UserId> userIds = request.getUsers();

    // Preconditions
    HandlerPreconditions.requireNotEmpty(userIds, "No userId specified");
    if (userIds.size() > 1 && !optionalPersonId.isEmpty()) {
      throw new IllegalArgumentException("Cannot fetch personIds for multiple userIds");
    }

    CollectionOptions options = new CollectionOptions(request);

    if (userIds.size() == 1) {
      if (optionalPersonId.isEmpty()) {
        if (groupId.getType() == GroupId.Type.self) {
            // If a filter is set then we have to call getPeople(), otherwise use the simpler getPerson()
          if (options != null && options.getFilter() != null) {
            Future<RestfulCollection<Person>> people = personService.getPeople(
                userIds, groupId, options, fields, request.getToken());
            return FutureUtil.getFirstFromCollection(people);
          } else {
            return personService.getPerson(userIds.iterator().next(), fields, request.getToken());
          }
        } else {
          return personService.getPeople(userIds, groupId, options, fields, request.getToken());
        }
      } else if (optionalPersonId.size() == 1) {
        // TODO: Add some crazy concept to handle the userId?
        Set<UserId> optionalUserIds = ImmutableSet.of(
            new UserId(UserId.Type.userId, optionalPersonId.iterator().next()));

        Future<RestfulCollection<Person>> people = personService.getPeople(
            optionalUserIds, new GroupId(GroupId.Type.self, null),
            options, fields, request.getToken());
        return FutureUtil.getFirstFromCollection(people);
      } else {
        ImmutableSet.Builder<UserId> personIds = ImmutableSet.builder();
        for (String pid : optionalPersonId) {
          personIds.add(new UserId(UserId.Type.userId, pid));
        }
        // Every other case is a collection response of optional person ids
        return personService.getPeople(personIds.build(), new GroupId(GroupId.Type.self, null),
            options, fields, request.getToken());
      }
    }

    // Every other case is a collection response.
View Full Code Here

    collectionOptions.setSortBy("name");
    collectionOptions.setSortOrder(SortOrder.ascending);
    collectionOptions.setMax(20);
   
    // Get all friends of john.doe
    Future<RestfulCollection<Person>> result = this.personServiceDb.getPeople(SpiTestUtil.buildUserIds("john.doe"), new GroupId(GroupId.Type.friends, "@friends"), collectionOptions, Person.Field.ALL_FIELDS, SpiTestUtil.DEFAULT_TEST_SECURITY_TOKEN);
   
    RestfulCollection<Person> peopleCollection = result.get();
    assertEquals(3, peopleCollection.getTotalResults());
    assertEquals(0, peopleCollection.getStartIndex());   
    List<Person> people = peopleCollection.getEntry();   
View Full Code Here

    collectionOptions.setSortOrder(SortOrder.ascending);
    collectionOptions.setFirst(0);
    collectionOptions.setMax(1);
   
    // Get first friend of john.doe
    Future<RestfulCollection<Person>> result = this.personServiceDb.getPeople(SpiTestUtil.buildUserIds("john.doe"), new GroupId(GroupId.Type.friends, "@friends"), collectionOptions, Person.Field.ALL_FIELDS, SpiTestUtil.DEFAULT_TEST_SECURITY_TOKEN);   
    RestfulCollection<Person> peopleCollection = result.get();
    assertEquals(3, peopleCollection.getTotalResults());
    assertEquals(0, peopleCollection.getStartIndex());   
    List<Person> people = peopleCollection.getEntry();   
    SpiTestUtil.assertPersonEquals(people.get(0), "george.doe", "George Doe");
   
    // Get second friend of john.doe
    collectionOptions.setFirst(1);
    result = this.personServiceDb.getPeople(SpiTestUtil.buildUserIds("john.doe"), new GroupId(GroupId.Type.friends, "@friends"), collectionOptions, Person.Field.ALL_FIELDS, SpiTestUtil.DEFAULT_TEST_SECURITY_TOKEN);
    peopleCollection = result.get();
    assertEquals(3, peopleCollection.getTotalResults());
    assertEquals(1, peopleCollection.getStartIndex());   
    people = peopleCollection.getEntry();   
    SpiTestUtil.assertPersonEquals(people.get(0), "jane.doe", "Jane Doe");   
View Full Code Here

    String path = "/appdata/john.doe/@" + group.toString() + "/appId";
    RestHandler operation = registry.getRestHandler(path, "GET");

    DataCollection data = new DataCollection(null);
    org.easymock.EasyMock.expect(appDataService.getPersonData(eq(JOHN_DOE),
        eq(new GroupId(group, null)),
        eq("appId"), eq(ImmutableSet.<String>of()), eq(token)))
        .andReturn(ImmediateFuture.newInstance(data));

    replay();
    assertEquals(data, operation.execute(Maps.<String, String[]>newHashMap(),
View Full Code Here

    DataCollection data = new DataCollection(null);
    Set<UserId> userIdSet = Sets.newLinkedHashSet(JOHN_DOE);
    userIdSet.add(new UserId(UserId.Type.userId, "jane.doe"));
    org.easymock.EasyMock.expect(appDataService.getPersonData(eq(userIdSet),
        eq(new GroupId(GroupId.Type.self, null)),
        eq("appId"), eq(ImmutableSet.<String>of()), eq(token)))
        .andReturn(ImmediateFuture.newInstance(data));

    replay();
    assertEquals(data, operation.execute(Maps.<String, String[]>newHashMap(),
View Full Code Here

    Map<String, String[]> params = Maps.newHashMap();
    params.put("fields", new String[]{"pandas"});

    DataCollection data = new DataCollection(null);
    org.easymock.EasyMock.expect(appDataService.getPersonData(eq(JOHN_DOE),
        eq(new GroupId(GroupId.Type.friends, null)),
        eq("appId"), eq(ImmutableSet.of("pandas")), eq(token)))
        .andReturn(ImmediateFuture.newInstance(data));

    replay();
    assertEquals(data, operation.execute(params, null, token, converter).get());
View Full Code Here

    HashMap<String, String> values = Maps.newHashMap();
    org.easymock.EasyMock.expect(converter.convertToObject(eq(jsonAppData), eq(Map.class)))
        .andReturn(values);

    org.easymock.EasyMock.expect(appDataService.updatePersonData(eq(JOHN_DOE.iterator().next()),
        eq(new GroupId(GroupId.Type.self, null)),
        eq("appId"), eq(ImmutableSet.of("pandas")), eq(values), eq(token)))
        .andReturn(ImmediateFuture.newInstance((Void) null));
    replay();
    return operation.execute(params, new StringReader(jsonAppData), token, converter);
  }
View Full Code Here

TOP

Related Classes of org.apache.shindig.social.opensocial.spi.GroupId

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.