Package org.apache.shindig.social.opensocial.model

Examples of org.apache.shindig.social.opensocial.model.Activity


    assertEquals(actual.getTitle(), expected.getTitle());
    assertEquals(actual.getBody(), expected.getBody());
  }

  public static Activity buildTestActivity(String id, String userId, String title, String body) {
    Activity activity = new ActivityImpl(id, userId);
    activity.setTitle(title);
    activity.setBody(body);
    return activity;
  }
View Full Code Here


  /* (non-Javadoc)
   * @see org.apache.shindig.social.opensocial.spi.ActivityService#getActivity(org.apache.shindig.social.opensocial.spi.UserId, org.apache.shindig.social.opensocial.spi.GroupId, java.lang.String, java.util.Set, java.lang.String, org.apache.shindig.auth.SecurityToken)
   */
  public Future<Activity> getActivity(UserId userId, GroupId groupId, String appId,
      Set<String> fields, String activityId, SecurityToken token) throws ProtocolException {
    Activity activity = getActivities(userId, activityId,  token);
    if ( activity != null  ) {
      return ImmediateFuture.newInstance(activity);
    }
    throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST,"Cant find activity");
  }
View Full Code Here

  }

  @Test
  public void getJohnDoeActivityWithAppId1() throws Exception {
    Future<Activity> result = this.activityServiceDb.getActivity(new UserId(Type.userId, "john.doe"), new GroupId(GroupId.Type.self, "@self"), null, ACTIVITY_ALL_FIELDS, "1", SpiTestUtil.DEFAULT_TEST_SECURITY_TOKEN);
    Activity activity = result.get();
    SpiTestUtil.assertActivityEquals(activity, testActivity);
  }
View Full Code Here

  @Test
  public void createNewActivityForJohnDoe() throws Exception {
    // Create new activity
    final String title = "hi mom!";
    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.getEntry().get(1);
    assertEquals(activity.getTitle(), title);
    assertEquals(activity.getBody(), body);
  }
View Full Code Here

    assertSame(3, responseItem.getTotalResults());
  }

  @Test
  public void testGetExpectedActivity() throws Exception {
    Activity activity = db.getActivity(
        CANON_USER, SELF_GROUP, APP_ID,
        ImmutableSet.of("appId", "body", "mediaItems"), APP_ID, new FakeGadgetToken()).get();
    assertNotNull(activity);
    // Check that some fields are fetched and others are not
    assertNotNull(activity.getBody());
    assertNull(activity.getBodyId());
  }
View Full Code Here

  /* (non-Javadoc)
   * @see org.apache.shindig.social.opensocial.spi.ActivityService#getActivity(org.apache.shindig.social.opensocial.spi.UserId, org.apache.shindig.social.opensocial.spi.GroupId, java.lang.String, java.util.Set, java.lang.String, org.apache.shindig.auth.SecurityToken)
   */
  public Future<Activity> getActivity(UserId userId, GroupId groupId, String appId,
      Set<String> fields, String activityId, SecurityToken token) throws ProtocolException {
    Activity activity = getActivities(userId, activityId,  token);
    if ( activity != null  ) {
      return ImmediateFuture.newInstance(activity);
    }
    throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST,"Cant find activity");
  }
View Full Code Here

     * @param activityObj org.wso2.carbon.social.activity.Activity object
     * @return org.apache.shindig.social.opensocial.model.Activity object
     */

    private Activity convertToShindigActivity(org.wso2.carbon.registry.social.api.activity.Activity activityObj) {
        Activity resultObj = new ActivityImpl();
        if (activityObj.getAppId() != null) {
            resultObj.setAppId(activityObj.getAppId());
        }
        if (activityObj.getBody() != null) {
            resultObj.setBody(activityObj.getBody());
        }
        if (activityObj.getBodyId() != null) {
            resultObj.setBodyId(activityObj.getBodyId());
        }
        if (activityObj.getExternalId() != null) {
            resultObj.setExternalId(activityObj.getExternalId());
        }
        if (activityObj.getId() != null) {
            resultObj.setId(activityObj.getId());
        }
        if (activityObj.getPostedTime() != null) {
            resultObj.setPostedTime(activityObj.getPostedTime());
        }
        if (activityObj.getPriority() != null) {
            resultObj.setPriority(activityObj.getPriority());
        }
        if (activityObj.getStreamFaviconUrl() != null) {
            resultObj.setStreamFaviconUrl(activityObj.getStreamFaviconUrl());
        }
        if (activityObj.getStreamSourceUrl() != null) {
            resultObj.setStreamSourceUrl(activityObj.getStreamSourceUrl());
        }
        if (activityObj.getStreamTitle() != null) {
            resultObj.setStreamTitle(activityObj.getStreamTitle());
        }
        if (activityObj.getStreamUrl() != null) {
            resultObj.setStreamUrl(activityObj.getStreamUrl());
        }
        if (activityObj.getTemplateParams() != null) {
            resultObj.setTemplateParams(activityObj.getTemplateParams());
        }
        if (activityObj.getTitle() != null) {
            resultObj.setTitle(activityObj.getTitle());
        }
        if (activityObj.getTitleId() != null) {
            resultObj.setTitleId(activityObj.getTitleId());
        }
        if (activityObj.getUpdated() != null) {
            resultObj.setUpdated(activityObj.getUpdated());
        }
        if (activityObj.getUrl() != null) {
            resultObj.setUrl(activityObj.getUrl());
        }
        if (activityObj.getUserId() != null) {
            resultObj.setUserId(activityObj.getUserId());
        }
        List<MediaItem> mediaItemList = new ArrayList<MediaItem>();

        if (activityObj.getMediaItems() != null) {
            for (org.wso2.carbon.registry.social.api.activity.MediaItem item : activityObj.getMediaItems()) {
                MediaItem itemObj = new MediaItemImpl();
                if (item != null) {
                    if (item.getMimeType() != null) {
                        itemObj.setMimeType(item.getMimeType());
                    }
                    if (item.getThumbnailUrl() != null) {
                        itemObj.setThumbnailUrl(item.getThumbnailUrl());
                    }
                    if (item.getType() != null) {
                        org.wso2.carbon.registry.social.api.activity.MediaItem.Type itemType = item.getType();
                        if (itemType.name().equals(MEDIA_ITEM_TYPE_AUDIO)) {
                            itemObj.setType(MediaItem.Type.AUDIO);
                        }
                        if (itemType.name().equals(MEDIA_ITEM_TYPE_IMAGE)) {
                            itemObj.setType(MediaItem.Type.IMAGE);
                        }
                        if (itemType.name().equals(MEDIA_ITEM_TYPE_VIDEO)) {
                            itemObj.setType(MediaItem.Type.VIDEO);
                        }

                    }
                    if (item.getUrl() != null) {
                        itemObj.setUrl(item.getUrl());
                    }
                    mediaItemList.add(itemObj);
                }

            }
            resultObj.setMediaItems(mediaItemList);

        }

        return resultObj;
    }
View Full Code Here

    assertEquals(actual.getTitle(), expected.getTitle());
    assertEquals(actual.getBody(), expected.getBody());
  }
 
  public static Activity buildTestActivity(String id, String userId, String title, String body) {
    Activity activity = new ActivityImpl(id, userId);
    activity.setTitle(title);
    activity.setBody(body);
    return activity;
  }
View Full Code Here

  }

  @Test
  public void getJohnDoeActivityWithAppId1() throws Exception {
    Future<Activity> result = this.activityServiceDb.getActivity(new UserId(Type.userId, "john.doe"), new GroupId(GroupId.Type.self, "@self"), null, ACTIVITY_ALL_FIELDS, "1", SpiTestUtil.DEFAULT_TEST_SECURITY_TOKEN);
    Activity activity = result.get();
    SpiTestUtil.assertActivityEquals(activity, testActivity);
  }
View Full Code Here

  @Test
  public void createNewActivityForJohnDoe() throws Exception {
    // Create new activity
    final String title = "hi mom!";
    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);
    assertEquals(activity.getBody(), body);
  }
View Full Code Here

TOP

Related Classes of org.apache.shindig.social.opensocial.model.Activity

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.