Source:
<code>private boolean checkIfImageDiskCanBeAdded(VM vm) { boolean returnValue; StorageDomainValidator validator = new StorageDomainValidator(getStorageDomain()); returnValue = validator.isDomainExistAndActive(getReturnValue().getCanDoActionMessages()); if (returnValue && vm != null && getStoragePoolIsoMapDao().get(new StoragePoolIsoMapId( getStorageDomainId().getValue(), vm.getstorage_pool_id())) == null) { returnValue = false; addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_POOL_NOT_MATCH); } returnValue = returnValue && checkImageConfiguration() && (vm == null || isDiskPassPCIAndIDELimit(getParameters().getDiskInfo())); returnValue = returnValue && (vm == null || performImagesChecks(vm)); if (returnValue && !hasFreeSpace(getStorageDomain())) { returnValue = false; addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_DISK_SPACE_LOW); } if (returnValue && isExceedMaxBlockDiskSize()) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_DISK_MAX_SIZE_EXCEEDED); getReturnValue().getCanDoActionMessages().add( String.format("$max_disk_size %1$s", Config.<Integer> GetValue(ConfigValues.MaxBlockDiskSize))); returnValue = false; } <START> if (getParameters().getDiskInfo().isShareable()) { <END> if (returnValue && !Config.<Boolean> GetValue(ConfigValues.ShareableDiskEnabled, getStoragePool().getcompatibility_version().getValue())) { returnValue = false; addCanDoActionMessage(VdcBllMessages.ACTION_NOT_SUPPORTED_FOR_CLUSTER_POOL_LEVEL); } else if (returnValue && !isVolumeFormatSupportedForShareable( ((DiskImage) getParameters().getDiskInfo()).getvolume_format())) { returnValue = false; addCanDoActionMessage(VdcBllMessages.SHAREABLE_DISK_IS_NOT_SUPPORTED_BY_VOLUME_FORMAT); } } return returnValue && (vm == null || validate(getSnapshotValidator().vmNotDuringSnapshot(vm.getId()))); }</code><technical_language>early return in this entire block - more readable</technical_language>

Target:
private boolean checkIfImageDiskCanBeAdded(VM vm) { boolean returnValue; StorageDomainValidator validator = new StorageDomainValidator(getStorageDomain()); returnValue = validator.isDomainExistAndActive(getReturnValue().getCanDoActionMessages()); if (returnValue && vm != null && getStoragePoolIsoMapDao().get(new StoragePoolIsoMapId( getStorageDomainId().getValue(), vm.getstorage_pool_id())) == null) { returnValue = false; addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_POOL_NOT_MATCH); } returnValue = returnValue && checkImageConfiguration() && (vm == null || isDiskPassPCIAndIDELimit(getParameters().getDiskInfo())); returnValue = returnValue && (vm == null || performImagesChecks(vm)); if (returnValue && !hasFreeSpace(getStorageDomain())) { returnValue = false; addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_DISK_SPACE_LOW); } if (returnValue && isExceedMaxBlockDiskSize()) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_DISK_MAX_SIZE_EXCEEDED); getReturnValue().getCanDoActionMessages().add( String.format("$max_disk_size %1$s", Config.<Integer> GetValue(ConfigValues.MaxBlockDiskSize))); returnValue = false; } if (returnValue && getParameters().getDiskInfo().isShareable()) { if (!Config.<Boolean> GetValue(ConfigValues.ShareableDiskEnabled, getStoragePool().getcompatibility_version().getValue())) { returnValue = false; addCanDoActionMessage(VdcBllMessages.ACTION_NOT_SUPPORTED_FOR_CLUSTER_POOL_LEVEL); } else if (!isVolumeFormatSupportedForShareable( ((DiskImage) getParameters().getDiskInfo()).getvolume_format())) { returnValue = false; addCanDoActionMessage(VdcBllMessages.SHAREABLE_DISK_IS_NOT_SUPPORTED_BY_VOLUME_FORMAT); } } return returnValue && (vm == null || validate(getSnapshotValidator().vmNotDuringSnapshot(vm.getId()))); }