in client/src/main/java/com/epam/eco/schemacatalog/client/SchemaCatalogClientImpl.java [137:169]
public void updateMetadata(MetadataBatchUpdateParams params) {
Validate.notNull(params, "Params can't be null");
Map<String, MetadataRequest> requestMap = new HashMap<>();
for (Map.Entry<MetadataKey, MetadataUpdateParams> entry : params.getOperations().entrySet()) {
MetadataKey key = entry.getKey();
MetadataUpdateParams value = entry.getValue();
if (value == null) {
requestMap.put(JsonMapper.toJson(key), null);
} else {
requestMap.put(
JsonMapper.toJson(key),
new MetadataRequest(value.getDoc(), value.getAttributes()));
}
}
Map<String, String> response = restTemplate.exchange(
"/api/metadata/schemas/$batch",
HttpMethod.PUT,
new HttpEntity<>(requestMap),
new ParameterizedTypeReference<Map<String, String>>() {
}).getBody();
if (response != null && !response.isEmpty()) {
StringJoiner logJoiner = new StringJoiner(",\n");
response.forEach((key, value) -> logJoiner.add(key + " : " + value));
LOGGER.error(logJoiner.toString());
StringJoiner joiner = new StringJoiner(", ");
response.keySet().forEach(joiner::add);
throw new RuntimeException(
String.format("Can't update metadata for '%s' keys", joiner.toString()));
}
}