in source/src/main/java/com/amazonaws/comprehend/esproxy/lambda/utils/serializer/ConfigSerializer.java [83:104]
public static Map<String, ComprehendConfiguration> transformConfigRequestToConfigMap(
@NonNull PreprocessingConfigRequest configRequest) {
List<ComprehendConfiguration> configList = configRequest.getComprehendConfigurations();
// all key/value shall exist
try {
Map<String, ComprehendConfiguration> configMap = configList.stream()
.filter(config -> !config.configIsInvalid())
.collect(Collectors.toMap(
value -> String.format("%s_%s", value.getIndexName(), value.getFieldName()),
value -> value));
// all configs should be valid
if (configMap.size() != configList.size()) {
throw new InvalidRequestException(CustomerMessage.CONFIG_FIELD_MISSING_OR_EMPTY_ERROR);
}
return configMap;
} catch (IllegalStateException e) {
// the exception will be thrown when the list tried to put duplicated indexName_fieldName pair into the map
// the indexName_fieldName pair should be unique
throw new InvalidRequestException(CustomerMessage.CONFIG_FIELD_NAME_DUPLICATED_ERROR);
}
}