Search in sources :

Example 1 with Activity

use of org.apache.shindig.social.opensocial.model.Activity in project liferay-ide by liferay.

the class LiferayActivityService method doGetActivities.

public RestfulCollection<Activity> doGetActivities(Set<UserId> userIds, GroupId groupId, String appId, Set<String> fields, CollectionOptions collectionOptions, SecurityToken securityToken) throws Exception {
    ThemeDisplay themeDisplay = getThemeDisplay(securityToken);
    List<Activity> activities = new ArrayList<Activity>();
    for (UserId userId : userIds) {
        long userIdLong = GetterUtil.getLong(userId.getUserId(securityToken));
        List<Activity> personActivities = getActivities(themeDisplay, userIdLong);
        activities.addAll(personActivities);
    }
    return new RestfulCollection<Activity>(activities, collectionOptions.getFirst(), activities.size(), collectionOptions.getMax());
}
Also used : UserId(org.apache.shindig.social.opensocial.spi.UserId) ArrayList(java.util.ArrayList) SocialActivity(com.liferay.portlet.social.model.SocialActivity) Activity(org.apache.shindig.social.opensocial.model.Activity) RestfulCollection(org.apache.shindig.protocol.RestfulCollection) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 2 with Activity

use of org.apache.shindig.social.opensocial.model.Activity in project liferay-ide by liferay.

the class LiferayActivityService method doGetActivities.

public RestfulCollection<Activity> doGetActivities(UserId userId, GroupId groupId, String appId, Set<String> fields, CollectionOptions collectionOptions, Set<String> activityIds, SecurityToken securityToken) throws Exception {
    ThemeDisplay themeDisplay = getThemeDisplay(securityToken);
    long userIdLong = GetterUtil.getLong(userId.getUserId(securityToken));
    List<Activity> activities = getActivities(themeDisplay, userIdLong);
    return new RestfulCollection<Activity>(activities, collectionOptions.getFirst(), activities.size(), collectionOptions.getMax());
}
Also used : SocialActivity(com.liferay.portlet.social.model.SocialActivity) Activity(org.apache.shindig.social.opensocial.model.Activity) RestfulCollection(org.apache.shindig.protocol.RestfulCollection) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 3 with Activity

use of org.apache.shindig.social.opensocial.model.Activity in project liferay-ide by liferay.

the class LiferayActivityService method getActivity.

protected Activity getActivity(ThemeDisplay themeDisplay, SocialActivity socialActivity) throws Exception {
    Activity activity = null;
    String className = socialActivity.getClassName();
    if (className.equals(Activity.class.getName())) {
        activity = getExternalActivity(socialActivity);
    } else {
        activity = new ActivityImpl(String.valueOf(socialActivity.getClassPK()), String.valueOf(socialActivity.getUserId()));
        HttpServletRequest request = HttpServletRequestThreadLocal.getHttpServletRequest();
        request.setAttribute(WebKeys.THEME_DISPLAY, themeDisplay);
        ServiceContext serviceContext = ServiceContextFactory.getInstance(request);
        serviceContext.setCompanyId(themeDisplay.getCompanyId());
        serviceContext.setUserId(themeDisplay.getUserId());
        SocialActivityFeedEntry socialActivityFeedEntry = SocialActivityInterpreterLocalServiceUtil.interpret(StringPool.BLANK, socialActivity, serviceContext);
        activity.setBody(socialActivityFeedEntry.getBody());
        activity.setTitle(socialActivityFeedEntry.getTitle());
        activity.setUrl(socialActivityFeedEntry.getLink());
    }
    return activity;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ActivityImpl(org.apache.shindig.social.core.model.ActivityImpl) ServiceContext(com.liferay.portal.service.ServiceContext) SocialActivity(com.liferay.portlet.social.model.SocialActivity) Activity(org.apache.shindig.social.opensocial.model.Activity) SocialActivityFeedEntry(com.liferay.portlet.social.model.SocialActivityFeedEntry)

Example 4 with Activity

use of org.apache.shindig.social.opensocial.model.Activity in project liferay-ide by liferay.

the class LiferayActivityService method doCreateActivity.

public void doCreateActivity(UserId userId, GroupId groupId, String appId, Set<String> fields, Activity activity, SecurityToken securityToken) throws Exception {
    long userIdLong = GetterUtil.getLong(userId.getUserId(securityToken));
    String activityAppId = activity.getAppId();
    JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject();
    SerializerUtil.copyProperties(activity, extraDataJSONObject, _ACTIVITY_FIELDS);
    SocialActivityLocalServiceUtil.addActivity(userIdLong, 0L, Activity.class.getName(), activity.getPostedTime(), activityAppId.hashCode(), extraDataJSONObject.toString(), 0L);
}
Also used : JSONObject(com.liferay.portal.kernel.json.JSONObject) SocialActivity(com.liferay.portlet.social.model.SocialActivity) Activity(org.apache.shindig.social.opensocial.model.Activity)

Example 5 with Activity

use of org.apache.shindig.social.opensocial.model.Activity in project liferay-ide by liferay.

the class LiferayActivityService method getActivities.

protected List<Activity> getActivities(ThemeDisplay themeDisplay, long userId) throws Exception {
    List<Activity> activities = new ArrayList<Activity>();
    List<SocialActivity> socialActivities = SocialActivityLocalServiceUtil.getUserActivities(userId, 0, 20);
    for (SocialActivity socialActivity : socialActivities) {
        Activity activity = getActivity(themeDisplay, socialActivity);
        activities.add(activity);
    }
    return activities;
}
Also used : ArrayList(java.util.ArrayList) SocialActivity(com.liferay.portlet.social.model.SocialActivity) Activity(org.apache.shindig.social.opensocial.model.Activity) SocialActivity(com.liferay.portlet.social.model.SocialActivity)

Aggregations

SocialActivity (com.liferay.portlet.social.model.SocialActivity)6 Activity (org.apache.shindig.social.opensocial.model.Activity)6 JSONObject (com.liferay.portal.kernel.json.JSONObject)2 ThemeDisplay (com.liferay.portal.theme.ThemeDisplay)2 ArrayList (java.util.ArrayList)2 RestfulCollection (org.apache.shindig.protocol.RestfulCollection)2 ActivityImpl (org.apache.shindig.social.core.model.ActivityImpl)2 ServiceContext (com.liferay.portal.service.ServiceContext)1 SocialActivityFeedEntry (com.liferay.portlet.social.model.SocialActivityFeedEntry)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 UserId (org.apache.shindig.social.opensocial.spi.UserId)1