|
@@ -5,6 +5,7 @@ import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
|
|
|
|
|
|
import com.provectus.kafka.ui.exception.DuplicateEntityException;
|
|
|
import com.provectus.kafka.ui.exception.SchemaNotFoundException;
|
|
|
+import com.provectus.kafka.ui.exception.SchemaTypeIsNotSupportedException;
|
|
|
import com.provectus.kafka.ui.exception.UnprocessableEntityException;
|
|
|
import com.provectus.kafka.ui.exception.ValidationException;
|
|
|
import com.provectus.kafka.ui.mapper.ClusterMapper;
|
|
@@ -51,6 +52,8 @@ public class SchemaRegistryService {
|
|
|
private static final String URL_SUBJECT_BY_VERSION = "/subjects/{schemaName}/versions/{version}";
|
|
|
private static final String LATEST = "latest";
|
|
|
|
|
|
+ private static final String UNRECOGNIZED_FIELD_SCHEMA_TYPE = "Unrecognized field: schemaType";
|
|
|
+
|
|
|
private final ClusterMapper mapper;
|
|
|
private final WebClient webClient;
|
|
|
|
|
@@ -195,7 +198,9 @@ public class SchemaRegistryService {
|
|
|
.retrieve()
|
|
|
.onStatus(UNPROCESSABLE_ENTITY::equals,
|
|
|
r -> r.bodyToMono(ErrorResponse.class)
|
|
|
- .flatMap(x -> Mono.error(new UnprocessableEntityException(x.getMessage()))))
|
|
|
+ .flatMap(x -> Mono.error(isUnrecognizedFieldSchemaTypeMessage(x.getMessage())
|
|
|
+ ? new SchemaTypeIsNotSupportedException()
|
|
|
+ : new UnprocessableEntityException(x.getMessage()))))
|
|
|
.bodyToMono(SubjectIdResponse.class);
|
|
|
}
|
|
|
|
|
@@ -213,7 +218,9 @@ public class SchemaRegistryService {
|
|
|
.onStatus(NOT_FOUND::equals, res -> Mono.empty())
|
|
|
.onStatus(UNPROCESSABLE_ENTITY::equals,
|
|
|
r -> r.bodyToMono(ErrorResponse.class)
|
|
|
- .flatMap(x -> Mono.error(new UnprocessableEntityException(x.getMessage()))))
|
|
|
+ .flatMap(x -> Mono.error(isUnrecognizedFieldSchemaTypeMessage(x.getMessage())
|
|
|
+ ? new SchemaTypeIsNotSupportedException()
|
|
|
+ : new UnprocessableEntityException(x.getMessage()))))
|
|
|
.bodyToMono(SchemaSubjectDTO.class)
|
|
|
.filter(s -> Objects.isNull(s.getId()))
|
|
|
.switchIfEmpty(Mono.error(new DuplicateEntityException("Such schema already exists")));
|
|
@@ -321,4 +328,8 @@ public class SchemaRegistryService {
|
|
|
.uri(schemaRegistry.getFirstUrl() + uri, params)
|
|
|
.headers(headers -> setBasicAuthIfEnabled(schemaRegistry, headers));
|
|
|
}
|
|
|
+
|
|
|
+ private boolean isUnrecognizedFieldSchemaTypeMessage(String errorMessage) {
|
|
|
+ return errorMessage.contains(UNRECOGNIZED_FIELD_SCHEMA_TYPE);
|
|
|
+ }
|
|
|
}
|