Program: 102549
Project: 102549
Buggy source:
/** 
 * Get all the identities who like an existing activity.
 * @param uriInfo The uri request uri
 * @param portalContainerName The associated portal container name.
 * @param activityId The specified activity ID.
 * @param format The expected returned format.
 * @anchor SOCref.DevelopersReferences.RestService_APIs_v1alpha3.ActivityResource.ActivityLikes.GET
 * @authenticated
 * @request {code} GET: http://localhost:8080/rest-socialdemo/private/api/social/v1-alpha3/socialdemo/activity/1a2b3c4d5e/likes.json {code}
 * @response {code:json} { totalNumberOfLikes: 2, likesByIdentities: [ { "id":1234567, "providerId":"organization", "remoteId":"demo", "profile": { "fullName":"Demo GTN", "avatarUrl":"http://localhost:8080/profile/u/demo/avatar.jpg?u=12345" } }, { "id":23456, "providerId":"organization", "remoteId":"root", "profile": { "fullName":"Root GTN", "avatarUrl":"http://localhost:8080/profile/u/root/avatar.jpg?u=12345" } }, ] } {code}
 * @return
 */
@GET @Path("String_Node_Str") @Produces(MediaType.APPLICATION_JSON) public Response getLikesFromIdentityId(@Context UriInfo uriInfo,@PathParam("String_Node_Str") String portalContainerName,@PathParam("String_Node_Str") String activityId,@PathParam("String_Node_Str") String format){
  RestChecker.checkAuthenticatedRequest();
  PortalContainer portalContainer=RestChecker.checkValidPortalContainerName(portalContainerName);
  MediaType mediaType=RestChecker.checkSupportedFormat(format,SUPPORTED_FORMAT);
  Identity authenticatedIdentity=Util.getAuthenticatedUserIdentity(portalContainerName);
  ActivityManager activityManager=Util.getActivityManager(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 (!SecurityManager.canAccessActivity(portalContainer,authenticatedIdentity,activity)) {
    throw new WebApplicationException(Response.Status.FORBIDDEN);
  }
  HashMap<String,Object> hashmapResult=new HashMap<String,Object>();
  if (activity.getLikeIdentityIds() != null && activity.getLikeIdentityIds().length > 0) {
    int numberOfLikeLimited=Math.min(MAX_NUMBER_OF_LIKE,activity.getLikeIdentityIds().length);
    List<IdentityRestOut> likedIdentitiesLimited=null;
    String[] getLikeIdentityIds=activity.getLikeIdentityIds();
    likedIdentitiesLimited=new ArrayList<IdentityRestOut>(numberOfLikeLimited);
    for (int i=0; i < numberOfLikeLimited; i++) {
      likedIdentitiesLimited.add(new IdentityRestOut(getLikeIdentityIds[getLikeIdentityIds.length - i - 1],portalContainerName));
    }
    hashmapResult.put("String_Node_Str",activity.getLikeIdentityIds().length);
    hashmapResult.put("String_Node_Str",likedIdentitiesLimited);
  }
 else {
    hashmapResult.put("String_Node_Str",0);
    hashmapResult.put("String_Node_Str",new ArrayList<IdentityRestOut>());
  }
  return Util.getResponse(hashmapResult,uriInfo,mediaType,Response.Status.OK);
}

Fixed version (ground truth):
/** 
 * Get all the identities who like an existing activity.
 * @param uriInfo The uri request uri
 * @param portalContainerName The associated portal container name.
 * @param activityId The specified activity Id.
 * @param format The expected returned format.
 * @anchor SOCref.DevelopersReferences.RestService_APIs_v1alpha3.ActivityResource.ActivityLikes.GET
 * @authenticated
 * @request {code} GET: http://localhost:8080/rest-socialdemo/private/api/social/v1-alpha3/socialdemo/activity/1a2b3c4d5e/likes.json {code}
 * @response {code:json} { totalNumberOfLikes: 2, likesByIdentities: [ { "id":1234567, "providerId":"organization", "remoteId":"demo", "profile": { "fullName":"Demo GTN", "avatarUrl":"http://localhost:8080/profile/u/demo/avatar.jpg?u=12345" } }, { "id":23456, "providerId":"organization", "remoteId":"root", "profile": { "fullName":"Root GTN", "avatarUrl":"http://localhost:8080/profile/u/root/avatar.jpg?u=12345" } }, ] } {code}
 * @return
 */
@GET @Path("String_Node_Str") @Produces(MediaType.APPLICATION_JSON) public Response getLikesFromIdentityId(@Context UriInfo uriInfo,@PathParam("String_Node_Str") String portalContainerName,@PathParam("String_Node_Str") String activityId,@PathParam("String_Node_Str") String format){
  RestChecker.checkAuthenticatedRequest();
  PortalContainer portalContainer=RestChecker.checkValidPortalContainerName(portalContainerName);
  MediaType mediaType=RestChecker.checkSupportedFormat(format,SUPPORTED_FORMAT);
  Identity authenticatedIdentity=Util.getAuthenticatedUserIdentity(portalContainerName);
  ActivityManager activityManager=Util.getActivityManager(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 (!SecurityManager.canAccessActivity(portalContainer,authenticatedIdentity,activity)) {
    throw new WebApplicationException(Response.Status.FORBIDDEN);
  }
  HashMap<String,Object> hashmapResult=new HashMap<String,Object>();
  if (activity.getLikeIdentityIds() != null && activity.getLikeIdentityIds().length > 0) {
    int numberOfLikeLimited=Math.min(MAX_NUMBER_OF_LIKE,activity.getLikeIdentityIds().length);
    List<IdentityRestOut> likedIdentitiesLimited=null;
    String[] getLikeIdentityIds=activity.getLikeIdentityIds();
    likedIdentitiesLimited=new ArrayList<IdentityRestOut>(numberOfLikeLimited);
    for (int i=0; i < numberOfLikeLimited; i++) {
      likedIdentitiesLimited.add(new IdentityRestOut(getLikeIdentityIds[getLikeIdentityIds.length - i - 1],portalContainerName));
    }
    hashmapResult.put("String_Node_Str",activity.getLikeIdentityIds().length);
    hashmapResult.put("String_Node_Str",likedIdentitiesLimited);
  }
 else {
    hashmapResult.put("String_Node_Str",0);
    hashmapResult.put("String_Node_Str",new ArrayList<IdentityRestOut>());
  }
  return Util.getResponse(hashmapResult,uriInfo,mediaType,Response.Status.OK);
}