Program: 102556
Project: 102556
Buggy source:
/** 
 * Get an activity object from a specified activity ID.
 * @param uriInfo The uri request info.
 * @param portalContainerName The associated portal container name.
 * @param activityId The specified activity ID.
 * @param format The expected returned format.
 * @param showPosterIdentity When this parameter is set to true, t or 1, the returned activity will provide moreinformation for the user who posted this activity.
 * @param numberOfComments Specify the number of comments to be displayed along with this activity. By default,number_of_comments=0. If number_of_comments 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 is recommended to use activity/:id/comments.format instead.
 * @param numberOfLikes Specify the number of latest detailed likes to be returned along with this activity. Bydefault, *number\_of\_likes=0*. If *number\_of\_likes* is a positive number, this number is considered as a limit number that must be equal or less than 100. If the total 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 is recommended to use _activity/\:activityId/likes.format_ instead.
 * @param showActivityStream When this parameter is set to true, t or 1, the returned activity will provide moreinformation for the activity stream that this activity belongs to.
 * @anchor SOCref.DevelopersReferences.RestService_APIs_v1alpha3.ActivityResource.Activity.Get
 * @authentication
 * @request {code} GET: http://cloud-workspaces.com/rest/private/api/social/v1-alpha3/portal/activity/1a2b3c4d5e6f7g8h9i.json {code}
 * @response {code:json} { "id": "1a2b3c4d5e6f7g8h9j", "title": "Hello World!!!", "appId": "", "type": "exosocial:core", "postedTime": 123456789, //timestamp "createdAt": "Fri Jun 17 06:42:26 +0000 2011", //The Date follows ISO 8601 "priority": 0.5, //between 0.0 and 1.0, higher value => higher priority. "templateParams": {}, "titleId": "", "identityId": "123456789abcdefghi", //the identity id of the user who created this activity "liked": true, //is liked (favorites) by this authenticated identity "likedByIdentities": ["identityId1", "identityId2"], "posterIdentity": {}, //optional "comments": [{}, {}, {}], //optional "totalNumberOfComments": 1234, "activityStream": { "type": "user", // or "space" "prettyId": "root", // or space_abcde "faviconURL": "http://demo3.exoplatform.org/favicons/exo-default.jpg", "title": "Activity Stream of Root Root", "permaLink": "http://cloud-workspaces.com/profile/root" } //optional } {code}
 * @return a response object
 */
@GET @Path("String_Node_Str") @Produces(MediaType.APPLICATION_JSON) 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){
  RestChecker.checkAuthenticatedRequest();
  PortalContainer portalContainer=RestChecker.checkValidPortalContainerName(portalContainerName);
  MediaType mediaType=RestChecker.checkSupportedFormat(format,SUPPORTED_FORMAT);
  Identity authenticatedIdentity=Util.getAuthenticatedUserIdentity(portalContainerName);
  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);
  }
  if (!SecurityManager.canAccessActivity(portalContainer,ConversationState.getCurrent().getIdentity().getUserId(),activity)) {
    throw new WebApplicationException(Response.Status.FORBIDDEN);
  }
  ActivityRestOut model=new ActivityRestOut(activity,portalContainerName);
  model.setNumberOfLikes(numberOfLikes,activity,portalContainerName);
  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 object from a specified activity Id.
 * @param uriInfo The uri request info.
 * @param portalContainerName The associated portal container name.
 * @param activityId The specified activity Id.
 * @param format The expected returned format.
 * @param showPosterIdentity When this parameter is set to true, t or 1, the returned activity will provide moreinformation for the user who posted this activity.
 * @param numberOfComments Specify the number of comments to be displayed along with this activity. By default,number_of_comments=0. If number_of_comments 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 is recommended to use activity/:id/comments.format instead.
 * @param numberOfLikes Specify the number of latest detailed likes to be returned along with this activity. Bydefault, number\_of\_likes=0. If number\_of\_likes is a positive number, this number is considered as a limit number that must be equal or less than 100. If the total 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 is recommended to use _activity/\:activityId/likes.format_ instead.
 * @param showActivityStream When this parameter is set to true, t or 1, the returned activity will provide moreinformation for the activity stream that this activity belongs to.
 * @anchor SOCref.DevelopersReferences.RestService_APIs_v1alpha3.ActivityResource.Activity.Get
 * @authentication
 * @request {code} GET: http://cloud-workspaces.com/rest/private/api/social/v1-alpha3/portal/activity/1a2b3c4d5e6f7g8h9i.json {code}
 * @response {code:json} { "id": "1a2b3c4d5e6f7g8h9j", "title": "Hello World!!!", "appId": "", "type": "exosocial:core", "postedTime": 123456789, //timestamp "createdAt": "Fri Jun 17 06:42:26 +0000 2011", //The Date follows ISO 8601 "priority": 0.5, //between 0.0 and 1.0, higher value => higher priority. "templateParams": {}, "titleId": "", "identityId": "123456789abcdefghi", //the identity id of the user who created this activity "liked": true, //is liked (favorites) by this authenticated identity "likedByIdentities": ["identityId1", "identityId2"], "posterIdentity": {}, //optional "comments": [{}, {}, {}], //optional "totalNumberOfComments": 1234, "activityStream": { "type": "user", // or "space" "prettyId": "root", // or space_abcde "faviconURL": "http://demo3.exoplatform.org/favicons/exo-default.jpg", "title": "Activity Stream of Root Root", "permaLink": "http://cloud-workspaces.com/profile/root" } //optional } {code}
 * @return a response object
 */
@GET @Path("String_Node_Str") @Produces(MediaType.APPLICATION_JSON) 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){
  RestChecker.checkAuthenticatedRequest();
  PortalContainer portalContainer=RestChecker.checkValidPortalContainerName(portalContainerName);
  MediaType mediaType=RestChecker.checkSupportedFormat(format,SUPPORTED_FORMAT);
  Identity authenticatedIdentity=Util.getAuthenticatedUserIdentity(portalContainerName);
  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);
  }
  if (!SecurityManager.canAccessActivity(portalContainer,ConversationState.getCurrent().getIdentity().getUserId(),activity)) {
    throw new WebApplicationException(Response.Status.FORBIDDEN);
  }
  ActivityRestOut model=new ActivityRestOut(activity,portalContainerName);
  model.setNumberOfLikes(numberOfLikes,activity,portalContainerName);
  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);
}