Program: 106391
Project: 106391
Buggy source:
@Override @DB public NetworkOfferingVO createNetworkOffering(String name,String displayText,TrafficType trafficType,String tags,boolean specifyVlan,Availability availability,Integer networkRate,Map<Service,Set<Provider>> serviceProviderMap,boolean isDefault,Network.GuestType type,boolean systemOnly,Long serviceOfferingId,boolean conserveMode,Map<Service,Map<Capability,String>> serviceCapabilityMap,boolean specifyIpRanges){
  String multicastRateStr=_configDao.getValue("String_Node_Str");
  int multicastRate=((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr));
  tags=cleanupTags(tags);
  if (specifyVlan != specifyIpRanges) {
    throw new InvalidParameterValueException("String_Node_Str" + specifyIpRanges);
  }
  if (!specifyVlan && type == GuestType.Shared) {
    throw new InvalidParameterValueException("String_Node_Str" + type);
  }
  if (specifyVlan && type == GuestType.Isolated && serviceProviderMap.containsKey(Service.SourceNat)) {
    throw new InvalidParameterValueException("String_Node_Str" + type + "String_Node_Str"+ Service.SourceNat.getName()+ "String_Node_Str");
  }
  if (availability == NetworkOffering.Availability.Required) {
    boolean canOffBeRequired=(type == GuestType.Isolated && serviceProviderMap.containsKey(Service.SourceNat));
    if (!canOffBeRequired) {
      throw new InvalidParameterValueException("String_Node_Str" + NetworkOffering.Availability.Required + "String_Node_Str"+ GuestType.Isolated+ "String_Node_Str"+ Service.SourceNat.getName()+ "String_Node_Str");
    }
    List<NetworkOfferingVO> offerings=_networkOfferingDao.listByAvailability(Availability.Required,false);
    if (!offerings.isEmpty()) {
      throw new InvalidParameterValueException("String_Node_Str" + offerings.get(0).getId() + "String_Node_Str"+ Availability.Required);
    }
  }
  boolean dedicatedLb=false;
  boolean elasticLb=false;
  boolean sharedSourceNat=false;
  boolean redundantRouter=false;
  boolean elasticIp=false;
  boolean inline=false;
  if (serviceCapabilityMap != null && !serviceCapabilityMap.isEmpty()) {
    Map<Capability,String> lbServiceCapabilityMap=serviceCapabilityMap.get(Service.Lb);
    if ((lbServiceCapabilityMap != null) && (!lbServiceCapabilityMap.isEmpty())) {
      String isolationCapability=lbServiceCapabilityMap.get(Capability.SupportedLBIsolation);
      if (isolationCapability != null) {
        _networkModel.checkCapabilityForProvider(serviceProviderMap.get(Service.Lb),Service.Lb,Capability.SupportedLBIsolation,isolationCapability);
        dedicatedLb=isolationCapability.contains("String_Node_Str");
      }
 else {
        dedicatedLb=true;
      }
      String param=lbServiceCapabilityMap.get(Capability.ElasticLb);
      if (param != null) {
        elasticLb=param.contains("String_Node_Str");
      }
      String inlineMode=lbServiceCapabilityMap.get(Capability.InlineMode);
      if (inlineMode != null) {
        _networkMgr.checkCapabilityForProvider(serviceProviderMap.get(Service.Lb),Service.Lb,Capability.InlineMode,inlineMode);
        inline=inlineMode.contains("String_Node_Str");
      }
 else {
        inline=false;
      }
    }
    Map<Capability,String> sourceNatServiceCapabilityMap=serviceCapabilityMap.get(Service.SourceNat);
    if ((sourceNatServiceCapabilityMap != null) && (!sourceNatServiceCapabilityMap.isEmpty())) {
      String sourceNatType=sourceNatServiceCapabilityMap.get(Capability.SupportedSourceNatTypes);
      if (sourceNatType != null) {
        _networkModel.checkCapabilityForProvider(serviceProviderMap.get(Service.SourceNat),Service.SourceNat,Capability.SupportedSourceNatTypes,sourceNatType);
        sharedSourceNat=sourceNatType.contains("String_Node_Str");
      }
      String param=sourceNatServiceCapabilityMap.get(Capability.RedundantRouter);
      if (param != null) {
        _networkModel.checkCapabilityForProvider(serviceProviderMap.get(Service.SourceNat),Service.SourceNat,Capability.RedundantRouter,param);
        redundantRouter=param.contains("String_Node_Str");
      }
    }
    Map<Capability,String> staticNatServiceCapabilityMap=serviceCapabilityMap.get(Service.StaticNat);
    if ((staticNatServiceCapabilityMap != null) && (!staticNatServiceCapabilityMap.isEmpty())) {
      String param=staticNatServiceCapabilityMap.get(Capability.ElasticIp);
      if (param != null) {
        elasticIp=param.contains("String_Node_Str");
      }
    }
  }
  NetworkOfferingVO offering=new NetworkOfferingVO(name,displayText,trafficType,systemOnly,specifyVlan,networkRate,multicastRate,isDefault,availability,tags,type,conserveMode,dedicatedLb,sharedSourceNat,redundantRouter,elasticIp,elasticLb,specifyIpRanges,inline);
  if (serviceOfferingId != null) {
    offering.setServiceOfferingId(serviceOfferingId);
  }
  Transaction txn=Transaction.currentTxn();
  txn.start();
  s_logger.debug("String_Node_Str" + offering);
  offering=_networkOfferingDao.persist(offering);
  if (serviceProviderMap != null) {
    for (    Network.Service service : serviceProviderMap.keySet()) {
      Set<Provider> providers=serviceProviderMap.get(service);
      if (providers != null && !providers.isEmpty()) {
        boolean vpcOff=false;
        for (        Network.Provider provider : providers) {
          if (provider == Provider.VPCVirtualRouter) {
            vpcOff=true;
          }
          NetworkOfferingServiceMapVO offService=new NetworkOfferingServiceMapVO(offering.getId(),service,provider);
          _ntwkOffServiceMapDao.persist(offService);
          s_logger.trace("String_Node_Str" + offService + "String_Node_Str"+ provider.getName());
        }
        if (vpcOff) {
          List<Service> supportedSvcs=new ArrayList<Service>();
          supportedSvcs.addAll(serviceProviderMap.keySet());
          _vpcMgr.validateNtwkOffForVpc(offering,supportedSvcs);
        }
      }
 else {
        NetworkOfferingServiceMapVO offService=new NetworkOfferingServiceMapVO(offering.getId(),service,null);
        _ntwkOffServiceMapDao.persist(offService);
        s_logger.trace("String_Node_Str" + offService + "String_Node_Str");
      }
    }
  }
  txn.commit();
  UserContext.current().setEventDetails("String_Node_Str" + offering.getId() + "String_Node_Str"+ name);
  return offering;
}

Fixed version (ground truth):
@Override @DB public NetworkOfferingVO createNetworkOffering(String name,String displayText,TrafficType trafficType,String tags,boolean specifyVlan,Availability availability,Integer networkRate,Map<Service,Set<Provider>> serviceProviderMap,boolean isDefault,Network.GuestType type,boolean systemOnly,Long serviceOfferingId,boolean conserveMode,Map<Service,Map<Capability,String>> serviceCapabilityMap,boolean specifyIpRanges){
  String multicastRateStr=_configDao.getValue("String_Node_Str");
  int multicastRate=((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr));
  tags=cleanupTags(tags);
  if (specifyVlan != specifyIpRanges) {
    throw new InvalidParameterValueException("String_Node_Str" + specifyIpRanges);
  }
  if (!specifyVlan && type == GuestType.Shared) {
    throw new InvalidParameterValueException("String_Node_Str" + type);
  }
  if (specifyVlan && type == GuestType.Isolated && serviceProviderMap.containsKey(Service.SourceNat)) {
    throw new InvalidParameterValueException("String_Node_Str" + type + "String_Node_Str"+ Service.SourceNat.getName()+ "String_Node_Str");
  }
  if (availability == NetworkOffering.Availability.Required) {
    boolean canOffBeRequired=(type == GuestType.Isolated && serviceProviderMap.containsKey(Service.SourceNat));
    if (!canOffBeRequired) {
      throw new InvalidParameterValueException("String_Node_Str" + NetworkOffering.Availability.Required + "String_Node_Str"+ GuestType.Isolated+ "String_Node_Str"+ Service.SourceNat.getName()+ "String_Node_Str");
    }
    List<NetworkOfferingVO> offerings=_networkOfferingDao.listByAvailability(Availability.Required,false);
    if (!offerings.isEmpty()) {
      throw new InvalidParameterValueException("String_Node_Str" + offerings.get(0).getId() + "String_Node_Str"+ Availability.Required);
    }
  }
  boolean dedicatedLb=false;
  boolean elasticLb=false;
  boolean sharedSourceNat=false;
  boolean redundantRouter=false;
  boolean elasticIp=false;
  boolean inline=false;
  if (serviceCapabilityMap != null && !serviceCapabilityMap.isEmpty()) {
    Map<Capability,String> lbServiceCapabilityMap=serviceCapabilityMap.get(Service.Lb);
    if ((lbServiceCapabilityMap != null) && (!lbServiceCapabilityMap.isEmpty())) {
      String isolationCapability=lbServiceCapabilityMap.get(Capability.SupportedLBIsolation);
      if (isolationCapability != null) {
        _networkModel.checkCapabilityForProvider(serviceProviderMap.get(Service.Lb),Service.Lb,Capability.SupportedLBIsolation,isolationCapability);
        dedicatedLb=isolationCapability.contains("String_Node_Str");
      }
 else {
        dedicatedLb=true;
      }
      String param=lbServiceCapabilityMap.get(Capability.ElasticLb);
      if (param != null) {
        elasticLb=param.contains("String_Node_Str");
      }
      String inlineMode=lbServiceCapabilityMap.get(Capability.InlineMode);
      if (inlineMode != null) {
        _networkModel.checkCapabilityForProvider(serviceProviderMap.get(Service.Lb),Service.Lb,Capability.InlineMode,inlineMode);
        inline=inlineMode.contains("String_Node_Str");
      }
 else {
        inline=false;
      }
    }
    Map<Capability,String> sourceNatServiceCapabilityMap=serviceCapabilityMap.get(Service.SourceNat);
    if ((sourceNatServiceCapabilityMap != null) && (!sourceNatServiceCapabilityMap.isEmpty())) {
      String sourceNatType=sourceNatServiceCapabilityMap.get(Capability.SupportedSourceNatTypes);
      if (sourceNatType != null) {
        _networkModel.checkCapabilityForProvider(serviceProviderMap.get(Service.SourceNat),Service.SourceNat,Capability.SupportedSourceNatTypes,sourceNatType);
        sharedSourceNat=sourceNatType.contains("String_Node_Str");
      }
      String param=sourceNatServiceCapabilityMap.get(Capability.RedundantRouter);
      if (param != null) {
        _networkModel.checkCapabilityForProvider(serviceProviderMap.get(Service.SourceNat),Service.SourceNat,Capability.RedundantRouter,param);
        redundantRouter=param.contains("String_Node_Str");
      }
    }
    Map<Capability,String> staticNatServiceCapabilityMap=serviceCapabilityMap.get(Service.StaticNat);
    if ((staticNatServiceCapabilityMap != null) && (!staticNatServiceCapabilityMap.isEmpty())) {
      String param=staticNatServiceCapabilityMap.get(Capability.ElasticIp);
      if (param != null) {
        elasticIp=param.contains("String_Node_Str");
      }
    }
  }
  NetworkOfferingVO offering=new NetworkOfferingVO(name,displayText,trafficType,systemOnly,specifyVlan,networkRate,multicastRate,isDefault,availability,tags,type,conserveMode,dedicatedLb,sharedSourceNat,redundantRouter,elasticIp,elasticLb,specifyIpRanges,inline);
  if (serviceOfferingId != null) {
    offering.setServiceOfferingId(serviceOfferingId);
  }
  Transaction txn=Transaction.currentTxn();
  txn.start();
  s_logger.debug("String_Node_Str" + offering);
  offering=_networkOfferingDao.persist(offering);
  if (serviceProviderMap != null) {
    for (    Network.Service service : serviceProviderMap.keySet()) {
      Set<Provider> providers=serviceProviderMap.get(service);
      if (providers != null && !providers.isEmpty()) {
        boolean vpcOff=false;
        for (        Network.Provider provider : providers) {
          if (provider == Provider.VPCVirtualRouter) {
            vpcOff=true;
          }
          NetworkOfferingServiceMapVO offService=new NetworkOfferingServiceMapVO(offering.getId(),service,provider);
          _ntwkOffServiceMapDao.persist(offService);
          s_logger.trace("String_Node_Str" + offService + "String_Node_Str"+ provider.getName());
        }
        if (vpcOff) {
          List<Service> supportedSvcs=new ArrayList<Service>();
          supportedSvcs.addAll(serviceProviderMap.keySet());
          _vpcMgr.validateNtwkOffForVpc(offering,supportedSvcs);
        }
      }
 else {
        NetworkOfferingServiceMapVO offService=new NetworkOfferingServiceMapVO(offering.getId(),service,null);
        _ntwkOffServiceMapDao.persist(offService);
        s_logger.trace("String_Node_Str" + offService + "String_Node_Str");
      }
    }
  }
  txn.commit();
  UserContext.current().setEventDetails("String_Node_Str" + offering.getId() + "String_Node_Str"+ name);
  return offering;
}