void validate()

in ingest/src/main/java/com/microsoft/azure/kusto/ingest/IngestionProperties.java [337:377]


    void validate() throws IngestionClientException {
        Ensure.stringIsNotBlank(databaseName, "databaseName");
        Ensure.stringIsNotBlank(tableName, "tableName");
        Ensure.argIsNotNull(reportMethod, "reportMethod");

        String mappingReference = ingestionMapping.getIngestionMappingReference();
        IngestionMapping.IngestionMappingKind ingestionMappingKind = ingestionMapping.getIngestionMappingKind();
        TextStringBuilder message = new TextStringBuilder();

        if ((ingestionMapping.getColumnMappings() == null) && StringUtils.isBlank(mappingReference)) {
            if (ingestionMappingKind != null) {
                message.appendln("IngestionMappingKind was defined ('%s'), so a mapping must be defined as well.", ingestionMappingKind);
            }
        } else { // a mapping was provided
            if (dataFormat.getIngestionMappingKind() != null && !dataFormat.getIngestionMappingKind().equals(ingestionMappingKind)) {
                message.appendln("Wrong ingestion mapping for format '%s'; mapping kind should be '%s', but was '%s'.",
                        dataFormat.getKustoValue(), dataFormat.getIngestionMappingKind().getKustoValue(),
                        ingestionMappingKind != null ? ingestionMappingKind.getKustoValue() : "null");
            }

            if (ingestionMapping.getColumnMappings() != null) {
                if (StringUtils.isNotBlank(mappingReference)) {
                    message.appendln("Both mapping reference '%s' and column mappings were defined.", mappingReference);
                }

                if (ingestionMappingKind != null) {
                    for (ColumnMapping column : ingestionMapping.getColumnMappings()) {
                        if (!column.isValid(ingestionMappingKind)) {
                            message.appendln("Column mapping '%s' is invalid.", column.getColumnName());
                        }
                    }
                }
            }
        }

        if (!message.isEmpty()) {
            String messageStr = message.build();
            log.error(messageStr);
            throw new IngestionClientException(messageStr);
        }
    }