Program: 102449
Project: 102449
Buggy source:
@POST @Path("String_Node_Str") @Produces(MediaType.APPLICATION_JSON) @RolesAllowed("String_Node_Str") @ApiOperation(value="String_Node_Str",httpMethod="String_Node_Str",response=Response.class,notes="String_Node_Str") @ApiResponses(value={@ApiResponse(code=200,message="String_Node_Str"),@ApiResponse(code=500,message="String_Node_Str"),@ApiResponse(code=400,message="String_Node_Str")}) public Response postComment(@Context UriInfo uriInfo,@ApiParam(value="String_Node_Str",required=true) @PathParam("String_Node_Str") String id,@ApiParam(value="String_Node_Str",required=false) @QueryParam("String_Node_Str") String expand,@ApiParam(value="String_Node_Str",required=true) CommentEntity model) throws Exception {
  if (model == null || model.getBody() == null || model.getBody().length() == 0) {
    throw new WebApplicationException(Response.Status.UNAUTHORIZED);
  }
  String authenticatedUser=ConversationState.getCurrent().getIdentity().getUserId();
  Identity currentUser=CommonsUtils.getService(IdentityManager.class).getOrCreateIdentity(OrganizationIdentityProvider.NAME,authenticatedUser,true);
  ActivityManager activityManager=CommonsUtils.getService(ActivityManager.class);
  ExoSocialActivity activity=activityManager.getActivity(id);
  if (activity == null) {
    throw new WebApplicationException(Response.Status.UNAUTHORIZED);
  }
  if (EntityBuilder.getActivityStream(activity,currentUser) == null) {
    throw new WebApplicationException(Response.Status.UNAUTHORIZED);
  }
  ExoSocialActivity comment=new ExoSocialActivityImpl();
  comment.setTitle(model.getBody());
  comment.setBody(model.getBody());
  comment.setUserId(currentUser.getId());
  activityManager.saveComment(activity,comment);
  return EntityBuilder.getResponse(EntityBuilder.buildEntityFromActivity(activityManager.getActivity(comment.getId()),uriInfo.getPath(),expand),uriInfo,RestUtils.getJsonMediaType(),Response.Status.OK);
}

Fixed version (ground truth):
@POST @Path("String_Node_Str") @Produces(MediaType.APPLICATION_JSON) @RolesAllowed("String_Node_Str") @ApiOperation(value="String_Node_Str",httpMethod="String_Node_Str",response=Response.class,notes="String_Node_Str") @ApiResponses(value={@ApiResponse(code=200,message="String_Node_Str"),@ApiResponse(code=500,message="String_Node_Str"),@ApiResponse(code=400,message="String_Node_Str")}) public Response postComment(@Context UriInfo uriInfo,@ApiParam(value="String_Node_Str",required=true) @PathParam("String_Node_Str") String id,@ApiParam(value="String_Node_Str",required=false) @QueryParam("String_Node_Str") String expand,@ApiParam(value="String_Node_Str",required=true) CommentEntity model) throws Exception {
  if (model == null || model.getTitle() == null || model.getTitle().length() == 0) {
    throw new WebApplicationException(Response.Status.UNAUTHORIZED);
  }
  String authenticatedUser=ConversationState.getCurrent().getIdentity().getUserId();
  Identity currentUser=CommonsUtils.getService(IdentityManager.class).getOrCreateIdentity(OrganizationIdentityProvider.NAME,authenticatedUser,true);
  ActivityManager activityManager=CommonsUtils.getService(ActivityManager.class);
  ExoSocialActivity activity=activityManager.getActivity(id);
  if (activity == null) {
    throw new WebApplicationException(Response.Status.UNAUTHORIZED);
  }
  if (EntityBuilder.getActivityStream(activity,currentUser) == null) {
    throw new WebApplicationException(Response.Status.UNAUTHORIZED);
  }
  ExoSocialActivity comment=new ExoSocialActivityImpl();
  comment.setTitle(model.getTitle());
  comment.setUserId(currentUser.getId());
  activityManager.saveComment(activity,comment);
  return EntityBuilder.getResponse(EntityBuilder.buildEntityFromActivity(activityManager.getActivity(comment.getId()),uriInfo.getPath(),expand),uriInfo,RestUtils.getJsonMediaType(),Response.Status.OK);
}