Program: 102574
Project: 102574
Buggy source:
/** 
 * Gets activity stream of a specified identity, could be user identity, space identity or any type of identities.
 * @param uriInfo             The uri info
 * @param portalContainerName the portal container name
 * @param identityId          The identity id.There is one special identityId: "me" standing for the authenticated user who make this request.
 * @param format              The response format type, for example: json, xml...
 * @param limit               Specifies the number of activities to retrieve. Must be less than or equal to 100.The value you pass as limit is a maximum number of activities to be returned. The actual number of activities you receive maybe less than limit. If no specified, 100 will be the default value.
 * @param sinceId             Returns the activities having the created timestamps greater thanthe specified sinceId's created timestamp
 * @param maxId               Returns the activities having the created timestamp less than the specified maxId's createdtimestamp. Note that sinceId and maxId must not be defined in one request, if they are, the sinceId query param is chosen.
 * @param numberOfComments    Specifies the latest number of comments to be displayed along with each activity.By default, numberOfComments=0. If numberOfComments is a positive number, this number is considered as a limit number that must be equal or less than 100. If the actual number of comments is less than the provided positive number, the number of actual comments must be returned. If the total number of comments is more than 100, it's recommended to use: "activity/:activityId/comments.format" instead
 * @param numberOfLikes       Specifies the latest number of detailed likes to be returned along with this activity.By default, numberOfLikes=0. If numberOfLikes is a positive number, this number is considered as a limit number that must be equal or less than 100. If the actual number of likes is less than the provided positive number, the number of actual likes must be returned. If the total number of likes is more than 100, it's recommended to use: "activity/:activityId/likes.format" instead.
 * @return the response
 */
@GET @Path("String_Node_Str") public Response getActivityStreamByIdentityId(@Context UriInfo uriInfo,@PathParam("String_Node_Str") String portalContainerName,@PathParam("String_Node_Str") String identityId,@PathParam("String_Node_Str") String format,@QueryParam("String_Node_Str") int limit,@QueryParam("String_Node_Str") String sinceId,@QueryParam("String_Node_Str") String maxId,@QueryParam("String_Node_Str") int numberOfComments,@QueryParam("String_Node_Str") int numberOfLikes){
  checkAuthenticatedRequest();
  PortalContainer portalContainer=checkValidPortalContainerName(portalContainerName);
  MediaType mediaType=checkSupportedFormat(format,SUPPORTED_FORMATS);
  Identity targetIdentity=Util.getIdentityManager(portalContainerName).getIdentity(identityId,false);
  if (targetIdentity == null) {
    throw new WebApplicationException(Response.Status.NOT_FOUND);
  }
  boolean canAccess=SecurityManager.canAccessActivityStream(portalContainer,SecurityManager.getAuthenticatedUserIdentity(),targetIdentity);
  if (!canAccess) {
    throw new WebApplicationException(Response.Status.FORBIDDEN);
  }
  int maxLimit=limit == 0 ? MAX_LIMIT : limit;
  ExoSocialActivity baseActivity=null;
  boolean getOlder=false;
  ActivityManager activityManager=Util.getActivityManager(portalContainerName);
  try {
    if (sinceId != null) {
      baseActivity=activityManager.getActivity(sinceId);
    }
 else     if (maxId != null) {
      getOlder=true;
      baseActivity=activityManager.getActivity(maxId);
    }
  }
 catch (  UndeclaredThrowableException udte) {
    if (udte.getCause() instanceof ActivityStorageException) {
      throw new WebApplicationException(Response.Status.NOT_FOUND);
    }
 else {
      throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
    }
  }
  RealtimeListAccess<ExoSocialActivity> rala=activityManager.getActivitiesWithListAccess(targetIdentity);
  List<ExoSocialActivity> activityList;
  if (getOlder) {
    activityList=rala.loadOlder(baseActivity,maxLimit);
  }
 else   if (sinceId != null) {
    activityList=rala.loadNewer(baseActivity,maxLimit);
  }
 else {
    activityList=rala.loadAsList(0,maxLimit);
  }
  ActivityRestListOut arlo=new ActivityRestListOut(activityList,numberOfComments,numberOfLikes,portalContainerName);
  return Util.getResponse(arlo,uriInfo,mediaType,Response.Status.OK);
}

Fixed version (ground truth):
/** 
 * Gets activity stream of a specified identity, could be user identity, space identity or any type of identities.
 * @param uriInfo             The uri info
 * @param portalContainerName the portal container name
 * @param identityId          The identity id.There is one special identityId: "me" standing for the authenticated user who make this request.
 * @param format              The response format type, for example: json, xml...
 * @param limit               Specifies the number of activities to retrieve. Must be less than or equal to 100.The value you pass as limit is a maximum number of activities to be returned. The actual number of activities you receive maybe less than limit. If no specified, 100 will be the default value.
 * @param sinceId             Returns the activities having the created timestamps greater thanthe specified sinceId's created timestamp
 * @param maxId               Returns the activities having the created timestamp less than the specified maxId's createdtimestamp. Note that sinceId and maxId must not be defined in one request, if they are, the sinceId query param is chosen.
 * @param numberOfComments    Specifies the latest number of comments to be displayed along with each activity.By default, numberOfComments=0. If numberOfComments is a positive number, this number is considered as a limit number that must be equal or less than 100. If the actual number of comments is less than the provided positive number, the number of actual comments must be returned. If the total number of comments is more than 100, it's recommended to use: "activity/:activityId/comments.format" instead
 * @param numberOfLikes       Specifies the latest number of detailed likes to be returned along with this activity.By default, numberOfLikes=0. If numberOfLikes is a positive number, this number is considered as a limit number that must be equal or less than 100. If the actual number of likes is less than the provided positive number, the number of actual likes must be returned. If the total number of likes is more than 100, it's recommended to use: "activity/:activityId/likes.format" instead.
 * @return the response
 */
@GET @Path("String_Node_Str") public Response getActivityStreamByIdentityId(@Context UriInfo uriInfo,@PathParam("String_Node_Str") String portalContainerName,@PathParam("String_Node_Str") String identityId,@PathParam("String_Node_Str") String format,@QueryParam("String_Node_Str") int limit,@QueryParam("String_Node_Str") String sinceId,@QueryParam("String_Node_Str") String maxId,@QueryParam("String_Node_Str") int numberOfComments,@QueryParam("String_Node_Str") int numberOfLikes){
  checkAuthenticatedRequest();
  PortalContainer portalContainer=checkValidPortalContainerName(portalContainerName);
  MediaType mediaType=checkSupportedFormat(format,SUPPORTED_FORMATS);
  Identity targetIdentity;
  if ("String_Node_Str".equals(identityId)) {
    targetIdentity=Util.getAuthenticatedUserIdentity(portalContainerName);
  }
 else {
    targetIdentity=Util.getIdentityManager(portalContainerName).getIdentity(identityId,false);
  }
  if (targetIdentity == null) {
    throw new WebApplicationException(Response.Status.NOT_FOUND);
  }
  boolean canAccess=SecurityManager.canAccessActivityStream(portalContainer,Util.getAuthenticatedUserIdentity(portalContainerName),targetIdentity);
  if (!canAccess) {
    throw new WebApplicationException(Response.Status.FORBIDDEN);
  }
  int maxLimit=limit <= 0 ? MAX_LIMIT : Math.min(limit,MAX_LIMIT);
  ExoSocialActivity baseActivity=null;
  boolean getOlder=false;
  ActivityManager activityManager=Util.getActivityManager(portalContainerName);
  try {
    if (sinceId != null) {
      baseActivity=activityManager.getActivity(sinceId);
    }
 else     if (maxId != null) {
      getOlder=true;
      baseActivity=activityManager.getActivity(maxId);
    }
  }
 catch (  UndeclaredThrowableException udte) {
    if (udte.getCause() instanceof ActivityStorageException) {
      throw new WebApplicationException(Response.Status.NOT_FOUND);
    }
 else {
      throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
    }
  }
  RealtimeListAccess<ExoSocialActivity> rala=activityManager.getActivitiesWithListAccess(targetIdentity);
  List<ExoSocialActivity> activityList;
  if (getOlder) {
    activityList=rala.loadOlder(baseActivity,maxLimit);
  }
 else   if (sinceId != null) {
    activityList=rala.loadNewer(baseActivity,maxLimit);
  }
 else {
    activityList=rala.loadAsList(0,maxLimit);
  }
  ActivityRestListOut arlo=new ActivityRestListOut(activityList,numberOfComments,numberOfLikes,portalContainerName);
  return Util.getResponse(arlo,uriInfo,mediaType,Response.Status.OK);
}