Source:
private boolean updateStorageDomainsInDb() { boolean result = TransactionSupport.executeInNewTransaction(() -> { for (Guid storageDomainId : getParameters().getStorages()) { StorageDomain storageDomain = storageDomainDao.get(storageDomainId); if (storageDomain != null) { StoragePoolIsoMap mapFromDB = storagePoolIsoMapDao.get(new StoragePoolIsoMapId(storageDomain.getId(), getStoragePool().getId())); boolean existingInDb = mapFromDB != null; if (existingInDb) { getCompensationContext().snapshotEntity(mapFromDB); } final StorageDomainStatic staticDomain = storageDomain.getStorageStaticData(); boolean staticDomainChanged = false; StorageFormatType requiredFormatType = VersionStorageFormatUtil.getForVersion(getStoragePool().getCompatibilityVersion()); if (staticDomain.getStorageFormat().compareTo(requiredFormatType) < 0) { if (!staticDomainChanged) { getCompensationContext().snapshotEntity(staticDomain); } staticDomain.setStorageFormat(requiredFormatType); staticDomainChanged = true; } storageDomain.setStoragePoolId(getStoragePool().getId()); if (masterStorageDomain == null && storageDomain.getStorageDomainType() == StorageDomainType.Data) { if (!staticDomainChanged) { getCompensationContext().snapshotEntity(staticDomain); } storageDomain.setStorageDomainType(StorageDomainType.Master); staticDomainChanged = true; masterStorageDomain = storageDomain; updateStoragePoolMasterDomainVersionInDiffTransaction(); } if (staticDomainChanged) { storageDomainStaticDao.update(staticDomain); } storageDomain.setStatus(StorageDomainStatus.Locked); if (existingInDb) { storagePoolIsoMapDao.update(storageDomain.getStoragePoolIsoMapData()); } else { storagePoolIsoMapDao.save(storageDomain.getStoragePoolIsoMapData()); getCompensationContext().snapshotNewEntity(storageDomain.getStoragePoolIsoMapData()); } } else { return false; } } getCompensationContext().stateChanged(); return true; }); return result && masterStorageDomain != null; }

Target:
private boolean updateStorageDomainsInDb() { boolean result = TransactionSupport.executeInNewTransaction(() -> { for (Guid storageDomainId : getParameters().getStorages()) { StorageDomain storageDomain = storageDomainDao.get(storageDomainId); if (storageDomain != null) { StoragePoolIsoMap mapFromDB = storagePoolIsoMapDao.get(new StoragePoolIsoMapId(storageDomain.getId(), getStoragePool().getId())); boolean existingInDb = mapFromDB != null; if (existingInDb) { getCompensationContext().snapshotEntity(mapFromDB); } final StorageDomainStatic staticDomain = storageDomain.getStorageStaticData(); boolean staticDomainChanged = false; StorageFormatType requiredFormatType = VersionStorageFormatUtil.getForVersion(getStoragePool().getCompatibilityVersion()); if (staticDomain.getStorageFormat().compareTo(requiredFormatType) < 0) { if (!staticDomainChanged) { getCompensationContext().snapshotEntity(staticDomain); } staticDomain.setStorageFormat(requiredFormatType); staticDomainChanged = true; } storageDomain.setStoragePoolId(getStoragePool().getId()); if (masterStorageDomain == null && storageDomain.getStorageDomainType() == StorageDomainType.Data && !storageDomain.isBackup()) { if (!staticDomainChanged) { getCompensationContext().snapshotEntity(staticDomain); } storageDomain.setStorageDomainType(StorageDomainType.Master); staticDomainChanged = true; masterStorageDomain = storageDomain; updateStoragePoolMasterDomainVersionInDiffTransaction(); } if (staticDomainChanged) { storageDomainStaticDao.update(staticDomain); } storageDomain.setStatus(StorageDomainStatus.Locked); if (existingInDb) { storagePoolIsoMapDao.update(storageDomain.getStoragePoolIsoMapData()); } else { storagePoolIsoMapDao.save(storageDomain.getStoragePoolIsoMapData()); getCompensationContext().snapshotNewEntity(storageDomain.getStoragePoolIsoMapData()); } } else { return false; } } getCompensationContext().stateChanged(); return true; }); return result && masterStorageDomain != null; }