Skip to content

Commit f803510

Browse files
committed
Refactor BrokersController (kafbat#556)
1 parent 4d573cd commit f803510

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

api/src/main/java/io/kafbat/ui/controller/BrokersController.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package io.kafbat.ui.controller;
22

33
import io.kafbat.ui.api.BrokersApi;
4-
import io.kafbat.ui.config.Config;
5-
import io.kafbat.ui.exception.ClusterNotFoundException;
64
import io.kafbat.ui.mapper.ClusterMapper;
75
import io.kafbat.ui.model.BrokerConfigDTO;
86
import io.kafbat.ui.model.BrokerConfigItemDTO;
@@ -32,7 +30,6 @@ public class BrokersController extends AbstractController implements BrokersApi
3230

3331
private final BrokerService brokerService;
3432
private final ClusterMapper clusterMapper;
35-
private final Config config;
3633

3734
@Override
3835
public Mono<ResponseEntity<Flux<BrokerDTO>>> getBrokers(String clusterName,
@@ -97,14 +94,10 @@ public Mono<ResponseEntity<Flux<BrokerConfigDTO>>> getBrokerConfig(String cluste
9794
.operationParams(Map.of(BROKER_ID, id))
9895
.build();
9996

100-
Flux<BrokerConfigDTO> brokerConfigs = brokerService.getBrokerConfig(getCluster(clusterName), id)
97+
var kafkaCluster = getCluster(clusterName);
98+
Flux<BrokerConfigDTO> brokerConfigs = brokerService.getBrokerConfig(kafkaCluster, id)
10199
.map(clusterMapper::toBrokerConfig);
102100

103-
var kafkaCluster = clustersStorage.getClusterByName(clusterName)
104-
.orElseThrow(
105-
() -> new ClusterNotFoundException(
106-
String.format("No cluster for name '%s'", clusterName)));
107-
108101
if (kafkaCluster.isReadOnly()) {
109102
brokerConfigs = brokerConfigs.map(config -> {
110103
config.setIsReadOnly(true);

0 commit comments

Comments
 (0)