Program: 105535
Project: 105535
Buggy source:
@Override @DB @ActionEvent(eventType=EventTypes.EVENT_VLAN_IP_RANGE_DEDICATE,eventDescription="String_Node_Str",async=false) public Vlan dedicatePublicIpRange(DedicatePublicIpRangeCmd cmd) throws ResourceAllocationException {
  Long vlanDbId=cmd.getId();
  String accountName=cmd.getAccountName();
  Long domainId=cmd.getDomainId();
  Long projectId=cmd.getProjectId();
  Account vlanOwner=null;
  if (projectId != null) {
    if (accountName != null) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
    Project project=_projectMgr.getProject(projectId);
    if (project == null) {
      throw new InvalidParameterValueException("String_Node_Str" + projectId);
    }
    vlanOwner=_accountMgr.getAccount(project.getProjectAccountId());
  }
  if ((accountName != null) && (domainId != null)) {
    vlanOwner=_accountDao.findActiveAccount(accountName,domainId);
    if (vlanOwner == null) {
      throw new InvalidParameterValueException("String_Node_Str" + accountName);
    }
 else     if (vlanOwner.getId() == Account.ACCOUNT_ID_SYSTEM) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
  }
  VlanVO vlan=_vlanDao.findById(vlanDbId);
  if (vlan == null) {
    throw new InvalidParameterValueException("String_Node_Str" + vlanDbId);
  }
  List<AccountVlanMapVO> maps=_accountVlanMapDao.listAccountVlanMapsByVlan(vlanDbId);
  if (maps != null && !maps.isEmpty()) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  Long zoneId=vlan.getDataCenterId();
  DataCenterVO zone=_zoneDao.findById(zoneId);
  if (zone == null) {
    throw new InvalidParameterValueException("String_Node_Str" + zoneId);
  }
  if (zone.getNetworkType() == NetworkType.Basic) {
    throw new InvalidParameterValueException("String_Node_Str" + NetworkType.Advanced);
  }
  int accountPublicIpRange=_publicIpAddressDao.countIPs(zoneId,vlanDbId,false);
  _resourceLimitMgr.checkResourceLimit(vlanOwner,ResourceType.public_ip,accountPublicIpRange);
  List<IPAddressVO> ips=_publicIpAddressDao.listByVlanId(vlanDbId);
  for (  IPAddressVO ip : ips) {
    Long allocatedToAccountId=ip.getAllocatedToAccountId();
    if (allocatedToAccountId != null) {
      Account accountAllocatedTo=_accountMgr.getActiveAccountById(allocatedToAccountId);
      if (!accountAllocatedTo.getAccountName().equalsIgnoreCase(accountName))       throw new InvalidParameterValueException(ip.getAddress() + "String_Node_Str");
    }
  }
  AccountVlanMapVO accountVlanMapVO=new AccountVlanMapVO(vlanOwner.getId(),vlan.getId());
  _accountVlanMapDao.persist(accountVlanMapVO);
  for (  IPAddressVO ip : ips) {
    UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NET_IP_ASSIGN,vlanOwner.getId(),ip.getDataCenterId(),ip.getId(),ip.getAddress().toString(),ip.isSourceNat(),vlan.getVlanType().toString(),ip.getSystem(),ip.getClass().getName(),ip.getUuid());
  }
  _resourceLimitMgr.incrementResourceCount(vlanOwner.getId(),ResourceType.public_ip,new Long(ips.size()));
  return vlan;
}

Fixed version (ground truth):
@Override @DB @ActionEvent(eventType=EventTypes.EVENT_VLAN_IP_RANGE_DEDICATE,eventDescription="String_Node_Str",async=false) public Vlan dedicatePublicIpRange(DedicatePublicIpRangeCmd cmd) throws ResourceAllocationException {
  Long vlanDbId=cmd.getId();
  String accountName=cmd.getAccountName();
  Long domainId=cmd.getDomainId();
  Long projectId=cmd.getProjectId();
  Account vlanOwner=null;
  if (projectId != null) {
    if (accountName != null) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
    Project project=_projectMgr.getProject(projectId);
    if (project == null) {
      throw new InvalidParameterValueException("String_Node_Str" + projectId);
    }
    vlanOwner=_accountMgr.getAccount(project.getProjectAccountId());
  }
  if ((accountName != null) && (domainId != null)) {
    vlanOwner=_accountDao.findActiveAccount(accountName,domainId);
  }
  if (vlanOwner == null) {
    throw new InvalidParameterValueException("String_Node_Str" + accountName);
  }
 else   if (vlanOwner.getId() == Account.ACCOUNT_ID_SYSTEM) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  VlanVO vlan=_vlanDao.findById(vlanDbId);
  if (vlan == null) {
    throw new InvalidParameterValueException("String_Node_Str" + vlanDbId);
  }
  List<AccountVlanMapVO> maps=_accountVlanMapDao.listAccountVlanMapsByVlan(vlanDbId);
  if (maps != null && !maps.isEmpty()) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  Long zoneId=vlan.getDataCenterId();
  DataCenterVO zone=_zoneDao.findById(zoneId);
  if (zone == null) {
    throw new InvalidParameterValueException("String_Node_Str" + zoneId);
  }
  if (zone.getNetworkType() == NetworkType.Basic) {
    throw new InvalidParameterValueException("String_Node_Str" + NetworkType.Advanced);
  }
  int accountPublicIpRange=_publicIpAddressDao.countIPs(zoneId,vlanDbId,false);
  _resourceLimitMgr.checkResourceLimit(vlanOwner,ResourceType.public_ip,accountPublicIpRange);
  List<IPAddressVO> ips=_publicIpAddressDao.listByVlanId(vlanDbId);
  for (  IPAddressVO ip : ips) {
    Long allocatedToAccountId=ip.getAllocatedToAccountId();
    if (allocatedToAccountId != null) {
      Account accountAllocatedTo=_accountMgr.getActiveAccountById(allocatedToAccountId);
      if (!accountAllocatedTo.getAccountName().equalsIgnoreCase(accountName))       throw new InvalidParameterValueException(ip.getAddress() + "String_Node_Str");
    }
  }
  AccountVlanMapVO accountVlanMapVO=new AccountVlanMapVO(vlanOwner.getId(),vlan.getId());
  _accountVlanMapDao.persist(accountVlanMapVO);
  for (  IPAddressVO ip : ips) {
    UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NET_IP_ASSIGN,vlanOwner.getId(),ip.getDataCenterId(),ip.getId(),ip.getAddress().toString(),ip.isSourceNat(),vlan.getVlanType().toString(),ip.getSystem(),ip.getClass().getName(),ip.getUuid());
  }
  _resourceLimitMgr.incrementResourceCount(vlanOwner.getId(),ResourceType.public_ip,new Long(ips.size()));
  return vlan;
}