class CloudStorageValidationUtil {

    public boolean isCloudStorageConfigured(CloudStorageBase cloudStorageRequest) {
        ValidationResultBuilder validationBuilder = new ValidationResultBuilder();
        if (cloudStorageRequest != null) {
            if (CollectionUtils.isEmpty(cloudStorageRequest.getLocations()) && CollectionUtils.isEmpty(cloudStorageRequest.getIdentities())) {
                return false;
            }
            if (!containsOnlyLogIdentity(cloudStorageRequest.getIdentities())) {
                validationBuilder.ifError(() -> CollectionUtils.isEmpty(cloudStorageRequest.getLocations())
                                && CollectionUtils.isEmpty(cloudStorageRequest.getIdentities()),
                        "Either 'locations' or 'identities' in 'cloudStorage' must not be empty!");
            }
            ValidationResult validationResult = validationBuilder.build();
            if (validationResult.hasError()) {
                throw new BadRequestException(validationResult.getFormattedErrors());
            }
            return true;
        } else {
            return false;
        }
    }

}