Skip to content

Commit

Permalink
Refactor BrokersController (#556)
Browse files Browse the repository at this point in the history
  • Loading branch information
hadisfr committed Sep 25, 2024
1 parent 4d573cd commit f803510
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions api/src/main/java/io/kafbat/ui/controller/BrokersController.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package io.kafbat.ui.controller;

import io.kafbat.ui.api.BrokersApi;
import io.kafbat.ui.config.Config;
import io.kafbat.ui.exception.ClusterNotFoundException;
import io.kafbat.ui.mapper.ClusterMapper;
import io.kafbat.ui.model.BrokerConfigDTO;
import io.kafbat.ui.model.BrokerConfigItemDTO;
Expand Down Expand Up @@ -32,7 +30,6 @@ public class BrokersController extends AbstractController implements BrokersApi

private final BrokerService brokerService;
private final ClusterMapper clusterMapper;
private final Config config;

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

Flux<BrokerConfigDTO> brokerConfigs = brokerService.getBrokerConfig(getCluster(clusterName), id)
var kafkaCluster = getCluster(clusterName);
Flux<BrokerConfigDTO> brokerConfigs = brokerService.getBrokerConfig(kafkaCluster, id)
.map(clusterMapper::toBrokerConfig);

var kafkaCluster = clustersStorage.getClusterByName(clusterName)
.orElseThrow(
() -> new ClusterNotFoundException(
String.format("No cluster for name '%s'", clusterName)));

if (kafkaCluster.isReadOnly()) {
brokerConfigs = brokerConfigs.map(config -> {
config.setIsReadOnly(true);
Expand Down

0 comments on commit f803510

Please sign in to comment.