Program: 102548
Project: 102548
Buggy source:
/** 
 * Create an activity to an identity's activity stream. If no identity_id is specified, the activity will be created to the authenticated identity's activity stream.
 * @param uriInfo the uri request info
 * @param portalContainerName The associated portal container name.
 * @param format The expected returned format.
 * @param identityIdStream The optional identity stream to post this new activity to.
 * @param newActivity A new activity instance.
 * @anchor SOCref.DevelopersReferences.RestService_APIs_v1alpha3.ActivityResource.Activity.Post
 * @authentication
 * @request {code} POST: http://cloud-workspaces.com/rest/private/api/social/v1-alpha3/portal/activity.json BODY: {"title": "Hello World!!!"} {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", "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 } {code}
 * @return a response object
 */
@POST @Path("String_Node_Str") @Produces(MediaType.APPLICATION_JSON) public Response createNewActivity(@Context UriInfo uriInfo,@PathParam("String_Node_Str") String portalContainerName,@PathParam("String_Node_Str") String format,@QueryParam("String_Node_Str") String identityIdStream,ActivityRestIn newActivity){
  RestChecker.checkAuthenticatedRequest();
  PortalContainer portalContainer=RestChecker.checkValidPortalContainerName(portalContainerName);
  if (newActivity == null || newActivity.getTitle() == null || newActivity.getTitle().trim().equals("String_Node_Str")) {
    throw new WebApplicationException(Response.Status.BAD_REQUEST);
  }
  MediaType mediaType=RestChecker.checkSupportedFormat(format,SUPPORTED_FORMAT);
  Identity postToIdentity;
  Identity authenticatedUserIdentity=Util.getAuthenticatedUserIdentity(portalContainerName);
  ActivityManager activityManager=Util.getActivityManager(portalContainerName);
  IdentityManager identityManager=Util.getIdentityManager(portalContainerName);
  if (identityIdStream != null && !identityIdStream.equals("String_Node_Str")) {
    postToIdentity=identityManager.getIdentity(identityIdStream,false);
    if (postToIdentity == null) {
      throw new WebApplicationException(Response.Status.NOT_FOUND);
    }
  }
 else {
    postToIdentity=authenticatedUserIdentity;
  }
  if (!SecurityManager.canPostActivity(portalContainer,authenticatedUserIdentity,postToIdentity)) {
    throw new WebApplicationException(Response.Status.FORBIDDEN);
  }
  ExoSocialActivity activity=new ExoSocialActivityImpl();
  activity.setTitle(newActivity.getTitle());
  activity.setType(newActivity.getType());
  activity.setPriority(newActivity.getPriority());
  activity.setTitleId(newActivity.getTitleId());
  activity.setTemplateParams(newActivity.getTemplateParams());
  activity.setUserId(authenticatedUserIdentity.getId());
  activityManager.saveActivityNoReturn(postToIdentity,activity);
  ActivityRestOut model=new ActivityRestOut(activity,portalContainerName);
  model.setIdentityId(postToIdentity.getId());
  return Util.getResponse(model,uriInfo,mediaType,Response.Status.OK);
}

Fixed version (ground truth):
/** 
 * Create an activity to an identity's activity stream. If no identity\_id is specified, the activity will be created to the authenticated identity's activity stream.
 * @param uriInfo the uri request info
 * @param portalContainerName The associated portal container name.
 * @param format The expected returned format.
 * @param identityIdStream The optional identity stream to post this new activity to.
 * @param newActivity A new activity instance.
 * @anchor SOCref.DevelopersReferences.RestService_APIs_v1alpha3.ActivityResource.Activity.Post
 * @authentication
 * @request {code} POST: http://cloud-workspaces.com/rest/private/api/social/v1-alpha3/portal/activity.json BODY: {"title": "Hello World!!!"} {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", "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 } {code}
 * @return a response object
 */
@POST @Path("String_Node_Str") @Produces(MediaType.APPLICATION_JSON) public Response createNewActivity(@Context UriInfo uriInfo,@PathParam("String_Node_Str") String portalContainerName,@PathParam("String_Node_Str") String format,@QueryParam("String_Node_Str") String identityIdStream,ActivityRestIn newActivity){
  RestChecker.checkAuthenticatedRequest();
  PortalContainer portalContainer=RestChecker.checkValidPortalContainerName(portalContainerName);
  if (newActivity == null || newActivity.getTitle() == null || newActivity.getTitle().trim().equals("String_Node_Str")) {
    throw new WebApplicationException(Response.Status.BAD_REQUEST);
  }
  MediaType mediaType=RestChecker.checkSupportedFormat(format,SUPPORTED_FORMAT);
  Identity postToIdentity;
  Identity authenticatedUserIdentity=Util.getAuthenticatedUserIdentity(portalContainerName);
  ActivityManager activityManager=Util.getActivityManager(portalContainerName);
  IdentityManager identityManager=Util.getIdentityManager(portalContainerName);
  if (identityIdStream != null && !identityIdStream.equals("String_Node_Str")) {
    postToIdentity=identityManager.getIdentity(identityIdStream,false);
    if (postToIdentity == null) {
      throw new WebApplicationException(Response.Status.NOT_FOUND);
    }
  }
 else {
    postToIdentity=authenticatedUserIdentity;
  }
  if (!SecurityManager.canPostActivity(portalContainer,authenticatedUserIdentity,postToIdentity)) {
    throw new WebApplicationException(Response.Status.FORBIDDEN);
  }
  ExoSocialActivity activity=new ExoSocialActivityImpl();
  activity.setTitle(newActivity.getTitle());
  activity.setType(newActivity.getType());
  activity.setPriority(newActivity.getPriority());
  activity.setTitleId(newActivity.getTitleId());
  activity.setTemplateParams(newActivity.getTemplateParams());
  activity.setUserId(authenticatedUserIdentity.getId());
  activityManager.saveActivityNoReturn(postToIdentity,activity);
  ActivityRestOut model=new ActivityRestOut(activity,portalContainerName);
  model.setIdentityId(postToIdentity.getId());
  return Util.getResponse(model,uriInfo,mediaType,Response.Status.OK);
}