Program: 102438
Project: 102438
Buggy source:
@GET @RolesAllowed("String_Node_Str") @ApiOperation(value="String_Node_Str",httpMethod="String_Node_Str",response=Response.class,notes="String_Node_Str") @ApiResponses(value={@ApiResponse(code=200,message="String_Node_Str"),@ApiResponse(code=500,message="String_Node_Str"),@ApiResponse(code=400,message="String_Node_Str")}) public Response getActivitiesOfCurrentUser(@Context UriInfo uriInfo,@ApiParam(value="String_Node_Str",required=false,defaultValue="String_Node_Str") @QueryParam("String_Node_Str") int offset,@ApiParam(value="String_Node_Str",required=false,defaultValue="String_Node_Str") @QueryParam("String_Node_Str") int limit,@ApiParam(value="String_Node_Str",defaultValue="String_Node_Str") @QueryParam("String_Node_Str") boolean returnSize,@ApiParam(value="String_Node_Str",required=false) @QueryParam("String_Node_Str") String expand) throws Exception {
  String authenticatedUser=ConversationState.getCurrent().getIdentity().getUserId();
  Identity currentUser=CommonsUtils.getService(IdentityManager.class).getOrCreateIdentity(OrganizationIdentityProvider.NAME,authenticatedUser,true);
  ActivityManager activityManager=CommonsUtils.getService(ActivityManager.class);
  RealtimeListAccess<ExoSocialActivity> listAccess=activityManager.getActivitiesWithListAccess(currentUser);
  List<ExoSocialActivity> activities=listAccess.loadAsList(offset,limit);
  List<DataEntity> activityEntities=new ArrayList<DataEntity>();
  for (  ExoSocialActivity activity : activities) {
    DataEntity as=EntityBuilder.getActivityStream(activity,currentUser);
    if (as == null)     continue;
    ActivityEntity activityEntity=EntityBuilder.buildEntityFromActivity(activity,uriInfo.getPath(),expand);
    activityEntity.setActivityStream(as);
    activityEntities.add(activityEntity.getDataEntity());
  }
  CollectionEntity collectionActivity=new CollectionEntity(activityEntities,EntityBuilder.ACTIVITIES_TYPE,offset,limit);
  if (returnSize) {
    collectionActivity.setSize(listAccess.getSize());
  }
  return EntityBuilder.getResponse(collectionActivity,uriInfo,RestUtils.getJsonMediaType(),Response.Status.OK);
}

Fixed version (ground truth):
@GET @RolesAllowed("String_Node_Str") @ApiOperation(value="String_Node_Str",httpMethod="String_Node_Str",response=Response.class,notes="String_Node_Str") @ApiResponses(value={@ApiResponse(code=200,message="String_Node_Str"),@ApiResponse(code=500,message="String_Node_Str"),@ApiResponse(code=400,message="String_Node_Str")}) public Response getActivitiesOfCurrentUser(@Context UriInfo uriInfo,@ApiParam(value="String_Node_Str",required=false,defaultValue="String_Node_Str") @QueryParam("String_Node_Str") int offset,@ApiParam(value="String_Node_Str",required=false,defaultValue="String_Node_Str") @QueryParam("String_Node_Str") int limit,@ApiParam(value="String_Node_Str",defaultValue="String_Node_Str") @QueryParam("String_Node_Str") boolean returnSize,@ApiParam(value="String_Node_Str",required=false) @QueryParam("String_Node_Str") String expand) throws Exception {
  String authenticatedUser=ConversationState.getCurrent().getIdentity().getUserId();
  Identity currentUser=CommonsUtils.getService(IdentityManager.class).getOrCreateIdentity(OrganizationIdentityProvider.NAME,authenticatedUser,true);
  ActivityManager activityManager=CommonsUtils.getService(ActivityManager.class);
  RealtimeListAccess<ExoSocialActivity> listAccess=activityManager.getActivityFeedWithListAccess(currentUser);
  List<ExoSocialActivity> activities=listAccess.loadAsList(offset,limit);
  List<DataEntity> activityEntities=new ArrayList<DataEntity>();
  for (  ExoSocialActivity activity : activities) {
    DataEntity as=EntityBuilder.getActivityStream(activity,currentUser);
    if (as == null)     continue;
    ActivityEntity activityEntity=EntityBuilder.buildEntityFromActivity(activity,uriInfo.getPath(),expand);
    activityEntity.setActivityStream(as);
    activityEntities.add(activityEntity.getDataEntity());
  }
  CollectionEntity collectionActivity=new CollectionEntity(activityEntities,EntityBuilder.ACTIVITIES_TYPE,offset,limit);
  if (returnSize) {
    collectionActivity.setSize(listAccess.getSize());
  }
  return EntityBuilder.getResponse(collectionActivity,uriInfo,RestUtils.getJsonMediaType(),Response.Status.OK);
}