|
@@ -4,6 +4,7 @@ import static org.springframework.http.HttpStatus.NOT_FOUND;
|
|
|
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
|
|
|
|
|
|
import com.provectus.kafka.ui.exception.DuplicateEntityException;
|
|
|
+import com.provectus.kafka.ui.exception.SchemaFailedToDeleteException;
|
|
|
import com.provectus.kafka.ui.exception.SchemaNotFoundException;
|
|
|
import com.provectus.kafka.ui.exception.SchemaTypeIsNotSupportedException;
|
|
|
import com.provectus.kafka.ui.exception.UnprocessableEntityException;
|
|
@@ -32,6 +33,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.http.HttpMethod;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -156,16 +158,16 @@ public class SchemaRegistryService {
|
|
|
).toBodilessEntity();
|
|
|
}
|
|
|
|
|
|
- public Mono<ResponseEntity<Void>> deleteSchemaSubjectEntirely(KafkaCluster cluster,
|
|
|
+ public Mono<Void> deleteSchemaSubjectEntirely(KafkaCluster cluster,
|
|
|
String schemaName) {
|
|
|
return configuredWebClient(
|
|
|
cluster,
|
|
|
HttpMethod.DELETE,
|
|
|
URL_SUBJECT, schemaName)
|
|
|
.retrieve()
|
|
|
- .onStatus(NOT_FOUND::equals,
|
|
|
- throwIfNotFoundStatus(formatted(NO_SUCH_SCHEMA, schemaName)))
|
|
|
- .toBodilessEntity();
|
|
|
+ .onStatus(HttpStatus::isError, errorOnSchemaDeleteFailure(schemaName))
|
|
|
+ .toBodilessEntity()
|
|
|
+ .then();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -335,4 +337,13 @@ public class SchemaRegistryService {
|
|
|
private boolean isUnrecognizedFieldSchemaTypeMessage(String errorMessage) {
|
|
|
return errorMessage.contains(UNRECOGNIZED_FIELD_SCHEMA_TYPE);
|
|
|
}
|
|
|
+
|
|
|
+ private Function<ClientResponse, Mono<? extends Throwable>> errorOnSchemaDeleteFailure(String schemaName) {
|
|
|
+ return resp -> {
|
|
|
+ if (NOT_FOUND.equals(resp.statusCode())) {
|
|
|
+ return Mono.error(new SchemaNotFoundException(schemaName));
|
|
|
+ }
|
|
|
+ return Mono.error(new SchemaFailedToDeleteException(schemaName));
|
|
|
+ };
|
|
|
+ }
|
|
|
}
|