Program: 102547
Project: 102547
Buggy source:
/** 
 * Get an activity by its ID.
 * @param uriInfo The URI request information.
 * @param portalContainerName The associated portal container name.
 * @param activityId The specified activity ID.
 * @param format The expected returned format.
 * @return a response object
 */
@GET @Path("String_Node_Str") public Response getActivityById(@Context UriInfo uriInfo,@PathParam("String_Node_Str") String portalContainerName,@PathParam("String_Node_Str") String activityId,@PathParam("String_Node_Str") String format,@QueryParam("String_Node_Str") String showPosterIdentity,@QueryParam("String_Node_Str") int numberOfComments,@QueryParam("String_Node_Str") String showActivityStream,@QueryParam("String_Node_Str") int numberOfLikes){
  PortalContainer portalContainer=RestChecker.checkValidPortalContainerName(portalContainerName);
  MediaType mediaType=RestChecker.checkSupportedFormat(format,new String[]{"String_Node_Str"});
  ActivityManager activityManager=Util.getActivityManager(portalContainerName);
  IdentityManager identityManager=Util.getIdentityManager(portalContainerName);
  ExoSocialActivity activity=null;
  try {
    activity=activityManager.getActivity(activityId);
  }
 catch (  UndeclaredThrowableException undeclaredThrowableException) {
    if (undeclaredThrowableException.getCause() instanceof ActivityStorageException) {
      throw new WebApplicationException(Response.Status.NOT_FOUND);
    }
 else {
      throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
    }
  }
  if (activity.isComment()) {
    throw new WebApplicationException(Response.Status.NOT_FOUND);
  }
  ActivityRestOut model=new ActivityRestOut();
  model.setId(activity.getId());
  model.setTitle(activity.getTitle());
  model.setPriority(activity.getPriority());
  model.setAppId(activity.getAppId());
  model.setType(activity.getType());
  model.setPostedTime(activity.getPostedTime());
  model.setCreatedAt(Util.convertTimestampToTimeString(activity.getPostedTime()));
  model.setTitleId(activity.getTitleId());
  model.setTemplateParams(activity.getTemplateParams());
  if (activity.getLikeIdentityIds() != null) {
    model.setTotalNumberOfLikes(activity.getLikeIdentityIds().length);
  }
 else {
    model.setTotalNumberOfLikes(null);
  }
  if (Util.isLikedByIdentity(identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME,Util.getViewerId(uriInfo),true).getId(),activity)) {
    model.setLiked(true);
  }
 else {
    model.setLiked(false);
  }
  RealtimeListAccess<ExoSocialActivity> commentRealtimeListAccess=Util.getActivityManager(portalContainerName).getCommentsWithListAccess(activity);
  model.setTotalNumberOfComments(commentRealtimeListAccess.getSize());
  Identity streamOwnerIdentity=Util.getOwnerIdentityIdFromActivity(portalContainerName,activity);
  if (streamOwnerIdentity != null) {
    model.put(Field.IDENTITY_ID.toString(),streamOwnerIdentity.getId());
  }
  if (isPassed(showPosterIdentity)) {
    model.setPosterIdentity(new IdentityRestOut(identityManager.getIdentity(activity.getUserId(),false)));
  }
  if (isPassed(showActivityStream)) {
    model.setActivityStream(new ActivityStreamRestOut(activity.getActivityStream(),portalContainerName));
  }
  model.setNumberOfComments(numberOfComments,activity,portalContainerName);
  return Util.getResponse(model,uriInfo,mediaType,Response.Status.OK);
}

Fixed version (ground truth):
/** 
 * Get an activity by its Id.
 * @param uriInfo The URI request information.
 * @param portalContainerName The associated portal container name.
 * @param activityId The specified activity Id.
 * @param format The expected returned format.
 * @return a response object
 */
@GET @Path("String_Node_Str") public Response getActivityById(@Context UriInfo uriInfo,@PathParam("String_Node_Str") String portalContainerName,@PathParam("String_Node_Str") String activityId,@PathParam("String_Node_Str") String format,@QueryParam("String_Node_Str") String showPosterIdentity,@QueryParam("String_Node_Str") int numberOfComments,@QueryParam("String_Node_Str") String showActivityStream,@QueryParam("String_Node_Str") int numberOfLikes){
  PortalContainer portalContainer=RestChecker.checkValidPortalContainerName(portalContainerName);
  MediaType mediaType=RestChecker.checkSupportedFormat(format,new String[]{"String_Node_Str"});
  ActivityManager activityManager=Util.getActivityManager(portalContainerName);
  IdentityManager identityManager=Util.getIdentityManager(portalContainerName);
  ExoSocialActivity activity=null;
  try {
    activity=activityManager.getActivity(activityId);
  }
 catch (  UndeclaredThrowableException undeclaredThrowableException) {
    if (undeclaredThrowableException.getCause() instanceof ActivityStorageException) {
      throw new WebApplicationException(Response.Status.NOT_FOUND);
    }
 else {
      throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
    }
  }
  if (activity.isComment()) {
    throw new WebApplicationException(Response.Status.NOT_FOUND);
  }
  ActivityRestOut model=new ActivityRestOut();
  model.setId(activity.getId());
  model.setTitle(activity.getTitle());
  model.setPriority(activity.getPriority());
  model.setAppId(activity.getAppId());
  model.setType(activity.getType());
  model.setPostedTime(activity.getPostedTime());
  model.setCreatedAt(Util.convertTimestampToTimeString(activity.getPostedTime()));
  model.setTitleId(activity.getTitleId());
  model.setTemplateParams(activity.getTemplateParams());
  if (activity.getLikeIdentityIds() != null) {
    model.setTotalNumberOfLikes(activity.getLikeIdentityIds().length);
  }
 else {
    model.setTotalNumberOfLikes(null);
  }
  if (Util.isLikedByIdentity(identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME,Util.getViewerId(uriInfo),true).getId(),activity)) {
    model.setLiked(true);
  }
 else {
    model.setLiked(false);
  }
  RealtimeListAccess<ExoSocialActivity> commentRealtimeListAccess=Util.getActivityManager(portalContainerName).getCommentsWithListAccess(activity);
  model.setTotalNumberOfComments(commentRealtimeListAccess.getSize());
  Identity streamOwnerIdentity=Util.getOwnerIdentityIdFromActivity(portalContainerName,activity);
  if (streamOwnerIdentity != null) {
    model.put(Field.IDENTITY_ID.toString(),streamOwnerIdentity.getId());
  }
  if (isPassed(showPosterIdentity)) {
    model.setPosterIdentity(new IdentityRestOut(identityManager.getIdentity(activity.getUserId(),false)));
  }
  if (isPassed(showActivityStream)) {
    model.setActivityStream(new ActivityStreamRestOut(activity.getActivityStream(),portalContainerName));
  }
  model.setNumberOfComments(numberOfComments,activity,portalContainerName);
  return Util.getResponse(model,uriInfo,mediaType,Response.Status.OK);
}