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);
  }
  protected Activity getExternalActivity(SocialActivity socialActivity) throws Exception {

    Activity activity =
        new ActivityImpl(
            String.valueOf(socialActivity.getClassPK()),
            String.valueOf(socialActivity.getUserId()));

    JSONObject extraDataJSONObject =
        JSONFactoryUtil.createJSONObject(socialActivity.getExtraData());

    SerializerUtil.copyProperties(extraDataJSONObject, activity, _ACTIVITY_FIELDS);

    return activity;
  }