Program: 102551
Project: 102551
Buggy source:
/** 
 * Post a new comment on an existing activity. The poster of this comment is an authenticated identity.
 * @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.Activitycomments.Post
 * @authentication
 * @request {code} POST: http://cloud-workspaces.com/rest/private/api/social/v1-alpha3/portal/activity/1a2b3c4d5e/comment.json BODY: {"text": "My comment here!!!"} {code}
 * @response {code:json} { "id": "123456" "identityId": "12345abcde", "text": "My comment here!!!", "postedTime": 123456789, "createdAt": "Fri Jun 17 06:42:26 +0000 2011" } {code}
 * @return a response object
 */
@POST @Path("String_Node_Str") @Produces(MediaType.APPLICATION_JSON) public Response createCommentActivityById(@Context UriInfo uriInfo,@PathParam("String_Node_Str") String portalContainerName,@PathParam("String_Node_Str") String activityId,@PathParam("String_Node_Str") String format,CommentRestIn comment){
  RestChecker.checkAuthenticatedRequest();
  PortalContainer portalContainer=RestChecker.checkValidPortalContainerName(portalContainerName);
  if (comment == null || comment.getText() == null || comment.getText().trim().equals("String_Node_Str")) {
    throw new WebApplicationException(Response.Status.BAD_REQUEST);
  }
  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.canCommentToActivity(portalContainer,authenticatedIdentity,activity)) {
    throw new WebApplicationException(Response.Status.FORBIDDEN);
  }
  ExoSocialActivity commentActivity=new ExoSocialActivityImpl();
  commentActivity.setTitle(comment.getText());
  commentActivity.setUserId(authenticatedIdentity.getId());
  activityManager.saveComment(activity,commentActivity);
  CommentRestOut commentOut=new CommentRestOut(commentActivity,portalContainerName);
  return Util.getResponse(commentOut,uriInfo,mediaType,Response.Status.OK);
}

Fixed version (ground truth):
/** 
 * Post a new comment on an existing activity. The poster of this comment is an authenticated identity.
 * @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.Activitycomments.Post
 * @authentication
 * @request {code} POST: http://cloud-workspaces.com/rest/private/api/social/v1-alpha3/portal/activity/1a2b3c4d5e/comment.json BODY: {"text": "My comment here!!!"} {code}
 * @response {code:json} { "id": "123456" "identityId": "12345abcde", "text": "My comment here!!!", "postedTime": 123456789, "createdAt": "Fri Jun 17 06:42:26 +0000 2011" } {code}
 * @return a response object
 */
@POST @Path("String_Node_Str") @Produces(MediaType.APPLICATION_JSON) public Response createCommentActivityById(@Context UriInfo uriInfo,@PathParam("String_Node_Str") String portalContainerName,@PathParam("String_Node_Str") String activityId,@PathParam("String_Node_Str") String format,CommentRestIn comment){
  RestChecker.checkAuthenticatedRequest();
  PortalContainer portalContainer=RestChecker.checkValidPortalContainerName(portalContainerName);
  if (comment == null || comment.getText() == null || comment.getText().trim().equals("String_Node_Str")) {
    throw new WebApplicationException(Response.Status.BAD_REQUEST);
  }
  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.canCommentToActivity(portalContainer,authenticatedIdentity,activity)) {
    throw new WebApplicationException(Response.Status.FORBIDDEN);
  }
  ExoSocialActivity commentActivity=new ExoSocialActivityImpl();
  commentActivity.setTitle(comment.getText());
  commentActivity.setUserId(authenticatedIdentity.getId());
  activityManager.saveComment(activity,commentActivity);
  CommentRestOut commentOut=new CommentRestOut(commentActivity,portalContainerName);
  return Util.getResponse(commentOut,uriInfo,mediaType,Response.Status.OK);
}