Source:
<code>protected void AddVmInterfaces() { String macRegex = "^(\\p{XDigit}{2}:){5}\\p{XDigit}{2}$"; List<VmNetworkInterface> interfaces = getVmTemplate().getInterfaces(); String networkName; for (VmNetworkInterface iface : interfaces) { if (iface.getId() == null) { iface.setId(Guid.NewGuid()); } networkName = iface.getNetworkName(); iface.setVmId(getVmTemplateId()); VmNetworkInterface iDynamic = new VmNetworkInterface(); VmNetworkStatistics iStat = new VmNetworkStatistics(); iDynamic.setStatistics(iStat); iDynamic.setId(iface.getId()); iStat.setId(iface.getId()); iStat.setVmId(getVmTemplateId()); iDynamic.setVmTemplateId(getVmTemplateId()); iDynamic.setName(iface.getName()); if (VmInterfaceManager.isValidVmNetwork(iface, getVmTemplate().getvds_group_id())) { iDynamic.setNetworkName(networkName); } else { log.warnFormat("Imported template interface {0} has an invalid network name {1}, network name was set to empty string" , iface.getName(), networkName); iDynamic.setNetworkName(StringUtils.EMPTY); } iDynamic.setSpeed(iface.getSpeed()); iDynamic.setType(iface.getType()); <START> if (StringHelper.isNullOrEmpty(iface.getMacAddress())) { <END> iface.setMacAddress(MacPoolManager.getInstance().allocateNewMac()); } if (!Regex.IsMatch(iface.getMacAddress(), macRegex)) { AuditLogableBase logable = new AuditLogableBase(); logable.AddCustomValue("MacAddress", iface.getMacAddress()); logable.AddCustomValue("IfaceName", iface.getName()); AuditLogDirector.log(logable, AuditLogType.IMPORTEXPORT_IMPORT_INTERFACES_WITH_INVALID_MAC_ADDRESS); } DbFacade.getInstance().getVmNetworkInterfaceDAO().save(iDynamic); getCompensationContext().snapshotNewEntity(iDynamic); DbFacade.getInstance().getVmNetworkStatisticsDAO().save(iStat); getCompensationContext().snapshotNewEntity(iStat); } }</code><technical_language>is this code copy-pasted? 2 classes inherit base class, put in a method</technical_language>

Target:
protected void AddVmInterfaces() { List<VmNetworkInterface> interfaces = getVmTemplate().getInterfaces(); String networkName; for (VmNetworkInterface iface : interfaces) { if (iface.getId() == null) { iface.setId(Guid.NewGuid()); } networkName = iface.getNetworkName(); iface.setVmId(getVmTemplateId()); VmNetworkInterface iDynamic = new VmNetworkInterface(); VmNetworkStatistics iStat = new VmNetworkStatistics(); iDynamic.setStatistics(iStat); iDynamic.setId(iface.getId()); iStat.setId(iface.getId()); iStat.setVmId(getVmTemplateId()); iDynamic.setVmTemplateId(getVmTemplateId()); iDynamic.setName(iface.getName()); if (VmInterfaceManager.isValidVmNetwork(iface, getVmTemplate().getvds_group_id())) { iDynamic.setNetworkName(networkName); } else { log.warnFormat("Imported template interface {0} has an invalid network name {1}, network name was set to empty string" , iface.getName(), networkName); iDynamic.setNetworkName(StringUtils.EMPTY); } iDynamic.setSpeed(iface.getSpeed()); iDynamic.setType(iface.getType()); validateImportMacAddress(iface); DbFacade.getInstance().getVmNetworkInterfaceDAO().save(iDynamic); getCompensationContext().snapshotNewEntity(iDynamic); DbFacade.getInstance().getVmNetworkStatisticsDAO().save(iStat); getCompensationContext().snapshotNewEntity(iStat); } }