Source:
public static ValidationResult setAndValidateDiskProfiles(Map<DiskImage, Guid> map, Version version, DbUser user) { if (map == null || !FeatureSupported.storageQoS(version)) { return ValidationResult.VALID; } Map<Guid, List<DiskProfile>> storageDiskProfilesMap = new HashMap<>(); Set<Guid> permittedDiskProfilesIds = new HashSet<>(); for (Entry<DiskImage, Guid> entry : map.entrySet()) { DiskImage diskImage = entry.getKey(); Guid storageDomainId = entry.getValue(); if (diskImage.getDiskStorageType() != DiskStorageType.IMAGE) { continue; } if (diskImage.getDiskProfileId() == null && storageDomainId != null) { List<DiskProfile> diskProfilesList = storageDiskProfilesMap.get(storageDomainId); if (diskProfilesList == null) { diskProfilesList = getDiskProfileDao().getAllForStorageDomain(storageDomainId); storageDiskProfilesMap.put(storageDomainId, diskProfilesList); } if (!updateDiskProfileForBackwardCompatibility(diskImage, diskProfilesList, permittedDiskProfilesIds, user)) { return new ValidationResult(VdcBllMessages.USER_NOT_AUTHORIZED_TO_ATTACH_DISK_PROFILE); } } else { DiskProfile diskProfile = getDiskProfileDao().get(diskImage.getDiskProfileId()); ValidationResult result = new DiskProfileValidator(diskProfile).isParentEntityValid(storageDomainId); if (result != ValidationResult.VALID) { return result; } if (!isDiskProfilePermitted(diskProfile, permittedDiskProfilesIds, user)) { return new ValidationResult(VdcBllMessages.USER_NOT_AUTHORIZED_TO_ATTACH_DISK_PROFILE); } } } return ValidationResult.VALID; }

Target:
public static ValidationResult setAndValidateDiskProfiles(Map<DiskImage, Guid> map, Version version, DbUser user) { if (map == null || !FeatureSupported.storageQoS(version)) { return ValidationResult.VALID; } Map<Guid, List<DiskProfile>> storageDiskProfilesMap = new HashMap<>(); Set<Guid> permittedDiskProfilesIds = new HashSet<>(); for (Entry<DiskImage, Guid> entry : map.entrySet()) { DiskImage diskImage = entry.getKey(); Guid storageDomainId = entry.getValue(); if (diskImage.getDiskStorageType() != DiskStorageType.IMAGE) { log.info("Disk profiles is not supported for storage type '{}' (Disk '{}')", diskImage.getDiskStorageType(), diskImage.getDiskAlias()); continue; } if (diskImage.getDiskProfileId() == null && storageDomainId != null) { List<DiskProfile> diskProfilesList = storageDiskProfilesMap.get(storageDomainId); if (diskProfilesList == null) { diskProfilesList = getDiskProfileDao().getAllForStorageDomain(storageDomainId); storageDiskProfilesMap.put(storageDomainId, diskProfilesList); } if (!updateDiskProfileForBackwardCompatibility(diskImage, diskProfilesList, permittedDiskProfilesIds, user)) { return new ValidationResult(VdcBllMessages.USER_NOT_AUTHORIZED_TO_ATTACH_DISK_PROFILE); } } else { DiskProfile diskProfile = getDiskProfileDao().get(diskImage.getDiskProfileId()); ValidationResult result = new DiskProfileValidator(diskProfile).isParentEntityValid(storageDomainId); if (result != ValidationResult.VALID) { return result; } if (!isDiskProfilePermitted(diskProfile, permittedDiskProfilesIds, user)) { return new ValidationResult(VdcBllMessages.USER_NOT_AUTHORIZED_TO_ATTACH_DISK_PROFILE); } } } return ValidationResult.VALID; }