Program: 89431
Project: 89431
Buggy source:
@Override public AccountResponse createAccountResponse(Account account){
  boolean accountIsAdmin=(account.getType() == Account.ACCOUNT_TYPE_ADMIN);
  AccountResponse accountResponse=new AccountResponse();
  accountResponse.setId(account.getId());
  accountResponse.setName(account.getAccountName());
  accountResponse.setAccountType(account.getType());
  accountResponse.setDomainId(account.getDomainId());
  accountResponse.setDomainName(ApiDBUtils.findDomainById(account.getDomainId()).getName());
  accountResponse.setState(account.getState().toString());
  List<UserStatisticsVO> stats=ApiDBUtils.listUserStatsBy(account.getId());
  if (stats == null) {
    throw new ServerApiException(BaseCmd.INTERNAL_ERROR,"String_Node_Str");
  }
  Long bytesSent=0L;
  Long bytesReceived=0L;
  for (  UserStatisticsVO stat : stats) {
    Long rx=stat.getNetBytesReceived() + stat.getCurrentBytesReceived();
    Long tx=stat.getNetBytesSent() + stat.getCurrentBytesSent();
    bytesReceived=bytesReceived + Long.valueOf(rx);
    bytesSent=bytesSent + Long.valueOf(tx);
  }
  accountResponse.setBytesReceived(bytesReceived);
  accountResponse.setBytesSent(bytesSent);
  Long vmLimit=ApiDBUtils.findCorrectResourceLimit(ResourceType.user_vm,account.getId());
  String vmLimitDisplay=(accountIsAdmin || vmLimit == -1) ? "String_Node_Str" : String.valueOf(vmLimit);
  Long vmTotal=ApiDBUtils.getResourceCount(ResourceType.user_vm,account.getId());
  String vmAvail=(accountIsAdmin || vmLimit == -1) ? "String_Node_Str" : String.valueOf(vmLimit - vmTotal);
  accountResponse.setVmLimit(vmLimitDisplay);
  accountResponse.setVmTotal(vmTotal);
  accountResponse.setVmAvailable(vmAvail);
  Long ipLimit=ApiDBUtils.findCorrectResourceLimit(ResourceType.public_ip,account.getId());
  String ipLimitDisplay=(accountIsAdmin || ipLimit == -1) ? "String_Node_Str" : String.valueOf(ipLimit);
  Long ipTotal=ApiDBUtils.getResourceCount(ResourceType.public_ip,account.getId());
  String ipAvail=(accountIsAdmin || ipLimit == -1) ? "String_Node_Str" : String.valueOf(ipLimit - ipTotal);
  accountResponse.setIpLimit(ipLimitDisplay);
  accountResponse.setIpTotal(ipTotal);
  accountResponse.setIpAvailable(ipAvail);
  Long volumeLimit=ApiDBUtils.findCorrectResourceLimit(ResourceType.volume,account.getId());
  String volumeLimitDisplay=(accountIsAdmin || volumeLimit == -1) ? "String_Node_Str" : String.valueOf(volumeLimit);
  Long volumeTotal=ApiDBUtils.getResourceCount(ResourceType.volume,account.getId());
  String volumeAvail=(accountIsAdmin || volumeLimit == -1) ? "String_Node_Str" : String.valueOf(volumeLimit - volumeTotal);
  accountResponse.setVolumeLimit(volumeLimitDisplay);
  accountResponse.setVolumeTotal(volumeTotal);
  accountResponse.setVolumeAvailable(volumeAvail);
  Long snapshotLimit=ApiDBUtils.findCorrectResourceLimit(ResourceType.snapshot,account.getId());
  String snapshotLimitDisplay=(accountIsAdmin || snapshotLimit == -1) ? "String_Node_Str" : String.valueOf(snapshotLimit);
  Long snapshotTotal=ApiDBUtils.getResourceCount(ResourceType.snapshot,account.getId());
  String snapshotAvail=(accountIsAdmin || snapshotLimit == -1) ? "String_Node_Str" : String.valueOf(snapshotLimit - snapshotTotal);
  accountResponse.setSnapshotLimit(snapshotLimitDisplay);
  accountResponse.setSnapshotTotal(snapshotTotal);
  accountResponse.setSnapshotAvailable(snapshotAvail);
  Long templateLimit=ApiDBUtils.findCorrectResourceLimit(ResourceType.template,account.getId());
  String templateLimitDisplay=(accountIsAdmin || templateLimit == -1) ? "String_Node_Str" : String.valueOf(templateLimit);
  Long templateTotal=ApiDBUtils.getResourceCount(ResourceType.template,account.getId());
  String templateAvail=(accountIsAdmin || templateLimit == -1) ? "String_Node_Str" : String.valueOf(templateLimit - templateTotal);
  accountResponse.setTemplateLimit(templateLimitDisplay);
  accountResponse.setTemplateTotal(templateTotal);
  accountResponse.setTemplateAvailable(templateAvail);
  int vmStopped=0;
  int vmRunning=0;
  Long[] accountIds=new Long[1];
  accountIds[0]=account.getId();
  Criteria c1=new Criteria();
  c1.addCriteria(Criteria.ACCOUNTID,accountIds);
  List<? extends UserVm> virtualMachines=ApiDBUtils.searchForUserVMs(c1);
  for (Iterator<? extends UserVm> iter=virtualMachines.iterator(); iter.hasNext(); ) {
    UserVm vm=iter.next();
    if (vm.getState() == State.Stopped) {
      vmStopped++;
    }
 else     if (vm.getState() == State.Running) {
      vmRunning++;
    }
  }
  accountResponse.setVmStopped(vmStopped);
  accountResponse.setVmRunning(vmRunning);
  accountResponse.setObjectName("String_Node_Str");
  List<UserVO> usersForAccount=ApiDBUtils.listUsersByAccount(account.getAccountId());
  List<UserResponse> userResponseList=new ArrayList<UserResponse>();
  for (  UserVO user : usersForAccount) {
    UserResponse userResponse=new UserResponse();
    userResponse.setAccountName(account.getAccountName());
    userResponse.setAccountType(account.getType());
    userResponse.setApiKey(user.getApiKey());
    userResponse.setCreated(user.getCreated());
    userResponse.setDomainId(account.getDomainId());
    userResponse.setDomainName(ApiDBUtils.findDomainById(account.getDomainId()).getName());
    userResponse.setEmail(user.getEmail());
    userResponse.setFirstname(user.getFirstname());
    userResponse.setId(user.getId());
    userResponse.setSecretKey(user.getSecretKey());
    userResponse.setLastname(user.getLastname());
    userResponse.setState(user.getState().toString());
    userResponse.setTimezone(user.getTimezone());
    userResponse.setUsername(user.getUsername());
    userResponseList.add(userResponse);
  }
  accountResponse.setUsers(userResponseList);
  return accountResponse;
}

Fixed version (ground truth):
@Override public AccountResponse createAccountResponse(Account account){
  boolean accountIsAdmin=(account.getType() == Account.ACCOUNT_TYPE_ADMIN);
  AccountResponse accountResponse=new AccountResponse();
  accountResponse.setId(account.getId());
  accountResponse.setName(account.getAccountName());
  accountResponse.setAccountType(account.getType());
  accountResponse.setDomainId(account.getDomainId());
  accountResponse.setDomainName(ApiDBUtils.findDomainById(account.getDomainId()).getName());
  accountResponse.setState(account.getState().toString());
  accountResponse.setNetworkDomain(account.getNetworkDomain());
  List<UserStatisticsVO> stats=ApiDBUtils.listUserStatsBy(account.getId());
  if (stats == null) {
    throw new ServerApiException(BaseCmd.INTERNAL_ERROR,"String_Node_Str");
  }
  Long bytesSent=0L;
  Long bytesReceived=0L;
  for (  UserStatisticsVO stat : stats) {
    Long rx=stat.getNetBytesReceived() + stat.getCurrentBytesReceived();
    Long tx=stat.getNetBytesSent() + stat.getCurrentBytesSent();
    bytesReceived=bytesReceived + Long.valueOf(rx);
    bytesSent=bytesSent + Long.valueOf(tx);
  }
  accountResponse.setBytesReceived(bytesReceived);
  accountResponse.setBytesSent(bytesSent);
  Long vmLimit=ApiDBUtils.findCorrectResourceLimit(ResourceType.user_vm,account.getId());
  String vmLimitDisplay=(accountIsAdmin || vmLimit == -1) ? "String_Node_Str" : String.valueOf(vmLimit);
  Long vmTotal=ApiDBUtils.getResourceCount(ResourceType.user_vm,account.getId());
  String vmAvail=(accountIsAdmin || vmLimit == -1) ? "String_Node_Str" : String.valueOf(vmLimit - vmTotal);
  accountResponse.setVmLimit(vmLimitDisplay);
  accountResponse.setVmTotal(vmTotal);
  accountResponse.setVmAvailable(vmAvail);
  Long ipLimit=ApiDBUtils.findCorrectResourceLimit(ResourceType.public_ip,account.getId());
  String ipLimitDisplay=(accountIsAdmin || ipLimit == -1) ? "String_Node_Str" : String.valueOf(ipLimit);
  Long ipTotal=ApiDBUtils.getResourceCount(ResourceType.public_ip,account.getId());
  String ipAvail=(accountIsAdmin || ipLimit == -1) ? "String_Node_Str" : String.valueOf(ipLimit - ipTotal);
  accountResponse.setIpLimit(ipLimitDisplay);
  accountResponse.setIpTotal(ipTotal);
  accountResponse.setIpAvailable(ipAvail);
  Long volumeLimit=ApiDBUtils.findCorrectResourceLimit(ResourceType.volume,account.getId());
  String volumeLimitDisplay=(accountIsAdmin || volumeLimit == -1) ? "String_Node_Str" : String.valueOf(volumeLimit);
  Long volumeTotal=ApiDBUtils.getResourceCount(ResourceType.volume,account.getId());
  String volumeAvail=(accountIsAdmin || volumeLimit == -1) ? "String_Node_Str" : String.valueOf(volumeLimit - volumeTotal);
  accountResponse.setVolumeLimit(volumeLimitDisplay);
  accountResponse.setVolumeTotal(volumeTotal);
  accountResponse.setVolumeAvailable(volumeAvail);
  Long snapshotLimit=ApiDBUtils.findCorrectResourceLimit(ResourceType.snapshot,account.getId());
  String snapshotLimitDisplay=(accountIsAdmin || snapshotLimit == -1) ? "String_Node_Str" : String.valueOf(snapshotLimit);
  Long snapshotTotal=ApiDBUtils.getResourceCount(ResourceType.snapshot,account.getId());
  String snapshotAvail=(accountIsAdmin || snapshotLimit == -1) ? "String_Node_Str" : String.valueOf(snapshotLimit - snapshotTotal);
  accountResponse.setSnapshotLimit(snapshotLimitDisplay);
  accountResponse.setSnapshotTotal(snapshotTotal);
  accountResponse.setSnapshotAvailable(snapshotAvail);
  Long templateLimit=ApiDBUtils.findCorrectResourceLimit(ResourceType.template,account.getId());
  String templateLimitDisplay=(accountIsAdmin || templateLimit == -1) ? "String_Node_Str" : String.valueOf(templateLimit);
  Long templateTotal=ApiDBUtils.getResourceCount(ResourceType.template,account.getId());
  String templateAvail=(accountIsAdmin || templateLimit == -1) ? "String_Node_Str" : String.valueOf(templateLimit - templateTotal);
  accountResponse.setTemplateLimit(templateLimitDisplay);
  accountResponse.setTemplateTotal(templateTotal);
  accountResponse.setTemplateAvailable(templateAvail);
  int vmStopped=0;
  int vmRunning=0;
  Long[] accountIds=new Long[1];
  accountIds[0]=account.getId();
  Criteria c1=new Criteria();
  c1.addCriteria(Criteria.ACCOUNTID,accountIds);
  List<? extends UserVm> virtualMachines=ApiDBUtils.searchForUserVMs(c1);
  for (Iterator<? extends UserVm> iter=virtualMachines.iterator(); iter.hasNext(); ) {
    UserVm vm=iter.next();
    if (vm.getState() == State.Stopped) {
      vmStopped++;
    }
 else     if (vm.getState() == State.Running) {
      vmRunning++;
    }
  }
  accountResponse.setVmStopped(vmStopped);
  accountResponse.setVmRunning(vmRunning);
  accountResponse.setObjectName("String_Node_Str");
  List<UserVO> usersForAccount=ApiDBUtils.listUsersByAccount(account.getAccountId());
  List<UserResponse> userResponseList=new ArrayList<UserResponse>();
  for (  UserVO user : usersForAccount) {
    UserResponse userResponse=new UserResponse();
    userResponse.setAccountName(account.getAccountName());
    userResponse.setAccountType(account.getType());
    userResponse.setApiKey(user.getApiKey());
    userResponse.setCreated(user.getCreated());
    userResponse.setDomainId(account.getDomainId());
    userResponse.setDomainName(ApiDBUtils.findDomainById(account.getDomainId()).getName());
    userResponse.setEmail(user.getEmail());
    userResponse.setFirstname(user.getFirstname());
    userResponse.setId(user.getId());
    userResponse.setSecretKey(user.getSecretKey());
    userResponse.setLastname(user.getLastname());
    userResponse.setState(user.getState().toString());
    userResponse.setTimezone(user.getTimezone());
    userResponse.setUsername(user.getUsername());
    userResponseList.add(userResponse);
  }
  accountResponse.setUsers(userResponseList);
  return accountResponse;
}