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

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


  }

  @Operation(httpMethods = "GET")
  public Future<?> get(SocialRequestItem request) throws ProtocolException {
    Set<UserId> userIds = request.getUsers();
    CollectionOptions options = new CollectionOptions(request);

    // Preconditions
    HandlerPreconditions.requireNotEmpty(userIds, "No userId specified");
    HandlerPreconditions.requireSingular(userIds, "Only one userId must be specified");
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 activities by ID for multiple users");
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.getFilter() != null) {
            Future<RestfulCollection<Person>> people = personService.getPeople(
                userIds, groupId, options, fields, request.getToken());
            return firstItem(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.getList();
    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.getList();
View Full Code Here

    SpiTestUtil.assertActivityEquals(activity, testActivity);
  }

  @Test
  public void getJohnDoeActivities() throws Exception {
    Future<RestfulCollection<Activity>> result = this.activityServiceDb.getActivities(SpiTestUtil.buildUserIds("john.doe"), new GroupId(GroupId.Type.self, "@self"), null, ACTIVITY_ALL_FIELDS, new CollectionOptions(), SpiTestUtil.DEFAULT_TEST_SECURITY_TOKEN);
    RestfulCollection<Activity> activityCollection = result.get();
    assertEquals(1, activityCollection.getTotalResults());
    assertEquals(0, activityCollection.getStartIndex());
    SpiTestUtil.assertActivityEquals(activityCollection.getList().get(0), testActivity);
  }
View Full Code Here

    SpiTestUtil.assertActivityEquals(activityCollection.getList().get(0), testActivity);
  }

  @Test
  public void getJohnDoeFriendsActivities() throws Exception {
    Future<RestfulCollection<Activity>> result = this.activityServiceDb.getActivities(SpiTestUtil.buildUserIds("john.doe"), new GroupId(GroupId.Type.friends, "@friends"), null, ACTIVITY_ALL_FIELDS, new CollectionOptions(), SpiTestUtil.DEFAULT_TEST_SECURITY_TOKEN);
    RestfulCollection<Activity> activityCollection = result.get();
    assertEquals(2, activityCollection.getTotalResults());
    assertEquals(0, activityCollection.getStartIndex());
  }
View Full Code Here

    final String body = "and dad.";
    Activity activity = SpiTestUtil.buildTestActivity("2", "john.doe", title, body);
    this.activityServiceDb.createActivity(new UserId(Type.userId, "john.doe"), new GroupId(GroupId.Type.self, "@self"), "2", ACTIVITY_ALL_FIELDS, activity, SpiTestUtil.DEFAULT_TEST_SECURITY_TOKEN);

    // Check activity was created as expected
    Future<RestfulCollection<Activity>> result = this.activityServiceDb.getActivities(SpiTestUtil.buildUserIds("john.doe"), new GroupId(GroupId.Type.self, "@self"), null, ACTIVITY_ALL_FIELDS, new CollectionOptions(), SpiTestUtil.DEFAULT_TEST_SECURITY_TOKEN);
    RestfulCollection<Activity> activityCollection = result.get();
    assertEquals(2, activityCollection.getTotalResults());
    assertEquals(0, activityCollection.getStartIndex());
    activity = activityCollection.getList().get(1);
    assertEquals(activity.getTitle(), title);
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.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 testHandleGetFriendsWithParams() throws Exception {
    String path = "/people/john.doe/@friends";
    RestHandler operation = registry.getRestHandler(path, "GET");

    CollectionOptions options = new CollectionOptions();
    options.setSortBy(Person.Field.NAME.toString());
    options.setSortOrder(SortOrder.descending);
    options.setFilter(PersonService.TOP_FRIENDS_FILTER);
    options.setFilterOperation(FilterOperation.present);
    options.setFilterValue("cassie");
    options.setFirst(5);
    options.setMax(10);

    Map<String, String[]> params = Maps.newHashMap();
    params.put("sortBy", new String[]{options.getSortBy()});
    params.put("sortOrder", new String[]{options.getSortOrder().toString()});
    params.put("filterBy", new String[]{options.getFilter()});
    params.put("filterOp", new String[]{options.getFilterOperation().toString()});
    params.put("filterValue", new String[]{options.getFilterValue()});
    params.put("startIndex", new String[]{"5"});
    params.put("count", new String[]{"10"});
    params.put("fields", new String[]{"money,fame,fortune"});

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.