Program: 102439
Project: 102439
Buggy source:
/** 
 * {@inheritDoc}
 */
@GET @Path("String_Node_Str") @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 getRelationshipsOfIdentity(@Context UriInfo uriInfo,@ApiParam(value="String_Node_Str",required=true) @PathParam("String_Node_Str") String id,@ApiParam(value="String_Node_Str") @QueryParam("String_Node_Str") String with,@ApiParam(value="String_Node_Str",defaultValue="String_Node_Str") @QueryParam("String_Node_Str") boolean returnSize,@ApiParam(value="String_Node_Str",required=false,defaultValue="String_Node_Str") @QueryParam("String_Node_Str") int offset,@ApiParam(value="String_Node_Str",required=false,defaultValue="String_Node_Str") @QueryParam("String_Node_Str") int limit,@ApiParam(value="String_Node_Str",required=false) @QueryParam("String_Node_Str") String expand) throws Exception {
  IdentityManager identityManager=CommonsUtils.getService(IdentityManager.class);
  Identity identity=identityManager.getIdentity(id,true);
  if (identity == null) {
    throw new WebApplicationException(Response.Status.NOT_FOUND);
  }
  RelationshipManager relationshipManager=CommonsUtils.getService(RelationshipManager.class);
  if (with != null && with.length() > 0) {
    Identity withUser=identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME,with,true);
    if (withUser == null) {
      throw new WebApplicationException(Response.Status.UNAUTHORIZED);
    }
    Relationship relationship=relationshipManager.get(identity,withUser);
    if (relationship == null) {
      throw new WebApplicationException(Response.Status.UNAUTHORIZED);
    }
    return EntityBuilder.getResponse(EntityBuilder.buildEntityRelationship(relationship,uriInfo.getPath(),expand,false),uriInfo,RestUtils.getJsonMediaType(),Response.Status.OK);
  }
  List<Relationship> relationships=relationshipManager.getRelationshipsByStatus(identity,Relationship.Type.ALL,offset,limit);
  List<DataEntity> relationshipEntities=EntityBuilder.buildRelationshipEntities(relationships,uriInfo);
  CollectionEntity collectionRelationship=new CollectionEntity(relationshipEntities,RestProperties.RELATIONSHIPS,offset,limit);
  if (returnSize) {
    collectionRelationship.setSize(relationshipManager.getRelationshipsCountByStatus(identity,Relationship.Type.ALL));
  }
  return EntityBuilder.getResponse(collectionRelationship,uriInfo,RestUtils.getJsonMediaType(),Response.Status.OK);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@GET @Path("String_Node_Str") @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 getRelationshipsOfIdentity(@Context UriInfo uriInfo,@ApiParam(value="String_Node_Str",required=true) @PathParam("String_Node_Str") String id,@ApiParam(value="String_Node_Str") @QueryParam("String_Node_Str") String with,@ApiParam(value="String_Node_Str",defaultValue="String_Node_Str") @QueryParam("String_Node_Str") boolean returnSize,@ApiParam(value="String_Node_Str",required=false,defaultValue="String_Node_Str") @QueryParam("String_Node_Str") int offset,@ApiParam(value="String_Node_Str",required=false,defaultValue="String_Node_Str") @QueryParam("String_Node_Str") int limit,@ApiParam(value="String_Node_Str",required=false) @QueryParam("String_Node_Str") String expand) throws Exception {
  IdentityManager identityManager=CommonsUtils.getService(IdentityManager.class);
  Identity identity=identityManager.getIdentity(id,true);
  if (identity == null) {
    throw new WebApplicationException(Response.Status.NOT_FOUND);
  }
  RelationshipManager relationshipManager=CommonsUtils.getService(RelationshipManager.class);
  if (with != null && with.length() > 0) {
    Identity withUser=identityManager.getIdentity(with,true);
    if (withUser == null) {
      throw new WebApplicationException(Response.Status.UNAUTHORIZED);
    }
    Relationship relationship=relationshipManager.get(identity,withUser);
    if (relationship == null) {
      throw new WebApplicationException(Response.Status.UNAUTHORIZED);
    }
    return EntityBuilder.getResponse(EntityBuilder.buildEntityRelationship(relationship,uriInfo.getPath(),expand,false),uriInfo,RestUtils.getJsonMediaType(),Response.Status.OK);
  }
  List<Relationship> relationships=relationshipManager.getRelationshipsByStatus(identity,Relationship.Type.ALL,offset,limit);
  List<DataEntity> relationshipEntities=EntityBuilder.buildRelationshipEntities(relationships,uriInfo);
  CollectionEntity collectionRelationship=new CollectionEntity(relationshipEntities,RestProperties.RELATIONSHIPS,offset,limit);
  if (returnSize) {
    collectionRelationship.setSize(relationshipManager.getRelationshipsCountByStatus(identity,Relationship.Type.ALL));
  }
  return EntityBuilder.getResponse(collectionRelationship,uriInfo,RestUtils.getJsonMediaType(),Response.Status.OK);
}