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

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


        Set<UserId> userIds = request.getUsers();
        String msgCollId = request.getParameter("msgCollId");
        List<String> messageIds = request.getListParameter("messageIds");

        CollectionOptions options = new CollectionOptions(request);

        HandlerPreconditions.requireNotEmpty(userIds, "No userId specified");
        HandlerPreconditions.requireSingular(userIds, "Multiple userIds not supported");

        UserId user = request.getUsers().iterator().next();
View Full Code Here


  public Future<?> get(SocialRequestItem request)
      throws ProtocolException {
    Set<UserId> userIds = request.getUsers();
    Set<String> optionalActivityIds = ImmutableSet.copyOf(request.getListParameter("activityId"));

    CollectionOptions options = new CollectionOptions(request);

    // Preconditions
    HandlerPreconditions.requireNotEmpty(userIds, "No userId specified");
    if (userIds.size() > 1 && !optionalActivityIds.isEmpty()) {
      throw new IllegalArgumentException("Cannot fetch same activityIds for multiple userIds");
View Full Code Here

    Set<UserId> userIds = request.getUsers();
    String msgCollId = request.getParameter("msgCollId");
    List<String> messageIds = request.getListParameter("messageIds");

    CollectionOptions options = new CollectionOptions(request);

    HandlerPreconditions.requireNotEmpty(userIds, "No userId specified");
    HandlerPreconditions.requireSingular(userIds, "Multiple userIds not supported");

    UserId user = request.getUsers().iterator().next();
View Full Code Here

    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());
View Full Code Here

  }
 
  @Test
  public void getJohnDoeFriendsOrderedByName() throws Exception {
    // Set collection options
    CollectionOptions collectionOptions = new CollectionOptions();
    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();
View Full Code Here

 
 
  @Test
  public void getJohnDoeFriendsOrderedByNameWithPagination() throws Exception {   
    // Set collection options
    CollectionOptions collectionOptions = new CollectionOptions();
    collectionOptions.setSortBy("name");
    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();   
View Full Code Here

    public void getPeople_GroupFilterField() throws ExecutionException, InterruptedException {
        Set<UserId> ids = getUserIdSet();
        GroupId groupId = new GroupId(GroupId.Type.groupId, GROUP_ID);
        replay(token);

        CollectionOptions options = new CollectionOptions();
        String field = Person.Field.ABOUT_ME.toString();
        String value = "AAA";
        options.setFilter(field);
        options.setFilterOperation(FilterOperation.contains);
        options.setFilterValue(value);

        expect(repository.findByGroup(GROUP_ID, field, FilterOperation.contains, value)).andReturn(getDbPersonList());
        replay(repository);

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

    public void getPeople_AllFilterField() throws ExecutionException, InterruptedException {
        Set<UserId> ids = getUserIdSet();
        GroupId groupId = new GroupId(GroupId.Type.all, GROUP_ID);
        replay(token);

        CollectionOptions options = new CollectionOptions();
        String field = Person.Field.ABOUT_ME.toString();
        String value = "AAA";
        options.setFilter(field);
        options.setFilterOperation(FilterOperation.contains);
        options.setFilterValue(value);

        expect(repository.findAllConnectedPeople(ID_2, field, FilterOperation.contains, value)).andReturn(getDbPersonList());
        expect(repository.findAllConnectedPeople(ID_3, field, FilterOperation.contains, value)).andReturn(getDbPersonList());
        replay(repository);
View Full Code Here

    public void getPeople_FriendsFilterField() throws ExecutionException, InterruptedException {
        Set<UserId> ids = getUserIdSet();
        GroupId groupId = new GroupId(GroupId.Type.friends, GROUP_ID);
        replay(token);

        CollectionOptions options = new CollectionOptions();
        String field = Person.Field.ABOUT_ME.toString();
        String value = "AAA";
        options.setFilter(field);
        options.setFilterOperation(FilterOperation.contains);
        options.setFilterValue(value);

        expect(repository.findFriends(ID_2, field, FilterOperation.contains, value)).andReturn(getDbPersonList());
        expect(repository.findFriends(ID_3, field, FilterOperation.contains, value)).andReturn(getDbPersonList());
        replay(repository);
View Full Code Here

    public void getPeople_FriendsAllFilterField() throws ExecutionException, InterruptedException {
        Set<UserId> ids = getUserIdSet();
        GroupId groupId = new GroupId(GroupId.Type.friends, GROUP_ID);
        replay(token);

        CollectionOptions options = new CollectionOptions();
        String field = PersonService.ALL_FILTER;
        String value = "AAA";
        options.setFilter(field);
        options.setFilterOperation(FilterOperation.contains);
        options.setFilterValue(value);

        expect(repository.findFriends(ID_2)).andReturn(getDbPersonList());
        expect(repository.findFriends(ID_3)).andReturn(getDbPersonList());
        replay(repository);
View Full Code Here

TOP

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

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.