From b1eecead79bfe3fbb4cfef9082d22e82b2f19a30 Mon Sep 17 00:00:00 2001 From: muralibasani Date: Mon, 17 Oct 2022 18:45:46 +0200 Subject: [PATCH 1/6] Adding enum for kafka protocols --- .../EnvsClustersTenantsController.java | 9 ++++ .../java/io/aiven/klaw/dao/KwClusters.java | 4 +- .../klaw/model/KafkaSupportedProtocol.java | 25 +++++++++++ .../io/aiven/klaw/model/KwClustersModel.java | 4 +- .../klaw/model/cluster/ClusterAclRequest.java | 3 +- .../cluster/ClusterConnectorRequest.java | 3 +- .../model/cluster/ClusterSchemaRequest.java | 3 +- .../model/cluster/ClusterTopicRequest.java | 3 +- .../service/AclSyncControllerService.java | 3 +- .../aiven/klaw/service/ClusterApiService.java | 43 ++++++++++++------- .../EnvsClustersTenantsControllerService.java | 24 +++++++++-- .../KafkaConnectControllerService.java | 3 +- .../validation/KafkaClusterValidator.java | 21 +++++++++ .../validation/KafkaClusterValidatorImpl.java | 18 ++++++++ src/main/resources/application.properties | 3 +- src/main/resources/static/js/envs.js | 18 +++++++- src/main/resources/static/js/modifyEnvs.js | 16 ++++++- src/main/resources/templates/addCluster.html | 21 +++------ .../resources/templates/modifyCluster.html | 16 +++---- src/test/java/io/aiven/klaw/MockMethods.java | 2 +- .../io/aiven/klaw/TopicAclControllerIT.java | 13 ++++-- .../service/AclControllerServiceTest.java | 5 ++- .../klaw/service/ClusterApiServiceTest.java | 29 ++++++++----- .../service/TopicControllerServiceTest.java | 6 ++- 24 files changed, 218 insertions(+), 77 deletions(-) create mode 100644 src/main/java/io/aiven/klaw/model/KafkaSupportedProtocol.java create mode 100644 src/main/java/io/aiven/klaw/validation/KafkaClusterValidator.java create mode 100644 src/main/java/io/aiven/klaw/validation/KafkaClusterValidatorImpl.java diff --git a/src/main/java/io/aiven/klaw/controller/EnvsClustersTenantsController.java b/src/main/java/io/aiven/klaw/controller/EnvsClustersTenantsController.java index 3d85668e9a..6db23ae028 100644 --- a/src/main/java/io/aiven/klaw/controller/EnvsClustersTenantsController.java +++ b/src/main/java/io/aiven/klaw/controller/EnvsClustersTenantsController.java @@ -306,4 +306,13 @@ public ResponseEntity> getClusterInfoFromEnv( envsClustersTenantsControllerService.getClusterInfoFromEnv(envSelected, envType), HttpStatus.OK); } + + @RequestMapping( + value = "/getKafkaProtocols", + method = RequestMethod.GET, + produces = {MediaType.APPLICATION_JSON_VALUE}) + public ResponseEntity>> getSupportedKafkaProtocols() { + return new ResponseEntity<>( + envsClustersTenantsControllerService.getSupportedKafkaProtocols(), HttpStatus.OK); + } } diff --git a/src/main/java/io/aiven/klaw/dao/KwClusters.java b/src/main/java/io/aiven/klaw/dao/KwClusters.java index d816281867..ffbc13255e 100644 --- a/src/main/java/io/aiven/klaw/dao/KwClusters.java +++ b/src/main/java/io/aiven/klaw/dao/KwClusters.java @@ -1,5 +1,6 @@ package io.aiven.klaw.dao; +import io.aiven.klaw.model.KafkaSupportedProtocol; import java.io.Serializable; import javax.persistence.*; import lombok.Getter; @@ -29,7 +30,8 @@ public class KwClusters implements Serializable { private String bootstrapServers; @Column(name = "protocol") - private String protocol; + @Enumerated(EnumType.STRING) + private KafkaSupportedProtocol protocol; @Column(name = "clustertype") private String clusterType; diff --git a/src/main/java/io/aiven/klaw/model/KafkaSupportedProtocol.java b/src/main/java/io/aiven/klaw/model/KafkaSupportedProtocol.java new file mode 100644 index 0000000000..44426846e3 --- /dev/null +++ b/src/main/java/io/aiven/klaw/model/KafkaSupportedProtocol.java @@ -0,0 +1,25 @@ +package io.aiven.klaw.model; + +public enum KafkaSupportedProtocol { + PLAINTEXT("PLAINTEXT"), + SSL("SSL"), + SASL_PLAIN("SASL_PLAIN"), + SASL_SSL_PLAIN_MECHANISM("SASL_SSL/PLAIN"), + SASL_SSL_GSSAPI_MECHANISM("SASL_SSL/GSSAPI"), + SASL_SSL_SCRAM_MECHANISM_256("SASL_SSL/SCRAM-SHA-256"), + SASL_SSL_SCRAM_MECHANISM_512("SASL_SSL/SCRAM-SHA-512"); + + private final String value; + + public String getName() { + return name(); + } + + public String getValue() { + return value; + } + + KafkaSupportedProtocol(String value) { + this.value = value; + } +} diff --git a/src/main/java/io/aiven/klaw/model/KwClustersModel.java b/src/main/java/io/aiven/klaw/model/KwClustersModel.java index 37ae6bcb63..af273b9964 100644 --- a/src/main/java/io/aiven/klaw/model/KwClustersModel.java +++ b/src/main/java/io/aiven/klaw/model/KwClustersModel.java @@ -1,5 +1,6 @@ package io.aiven.klaw.model; +import io.aiven.klaw.validation.KafkaClusterValidator; import java.io.Serializable; import java.util.List; import javax.validation.constraints.NotNull; @@ -12,6 +13,7 @@ @ToString @Getter @Setter +@KafkaClusterValidator public class KwClustersModel implements Serializable { private Integer clusterId; @@ -26,7 +28,7 @@ public class KwClustersModel implements Serializable { private String bootstrapServers; @NotNull(message = "Protocol cannot be null") - private String protocol; + private KafkaSupportedProtocol protocol; @NotNull private String clusterType; diff --git a/src/main/java/io/aiven/klaw/model/cluster/ClusterAclRequest.java b/src/main/java/io/aiven/klaw/model/cluster/ClusterAclRequest.java index cd396a2370..f03050aae3 100644 --- a/src/main/java/io/aiven/klaw/model/cluster/ClusterAclRequest.java +++ b/src/main/java/io/aiven/klaw/model/cluster/ClusterAclRequest.java @@ -1,6 +1,7 @@ package io.aiven.klaw.model.cluster; import com.fasterxml.jackson.annotation.JsonProperty; +import io.aiven.klaw.model.KafkaSupportedProtocol; import io.aiven.klaw.model.RequestOperationType; import java.io.Serializable; import lombok.Builder; @@ -20,7 +21,7 @@ public class ClusterAclRequest implements Serializable { @JsonProperty private String env; - @JsonProperty private String protocol; + @JsonProperty private KafkaSupportedProtocol protocol; @JsonProperty private String clusterName; diff --git a/src/main/java/io/aiven/klaw/model/cluster/ClusterConnectorRequest.java b/src/main/java/io/aiven/klaw/model/cluster/ClusterConnectorRequest.java index f49ae24bfa..d22bc625d3 100644 --- a/src/main/java/io/aiven/klaw/model/cluster/ClusterConnectorRequest.java +++ b/src/main/java/io/aiven/klaw/model/cluster/ClusterConnectorRequest.java @@ -1,6 +1,7 @@ package io.aiven.klaw.model.cluster; import com.fasterxml.jackson.annotation.JsonProperty; +import io.aiven.klaw.model.KafkaSupportedProtocol; import java.io.Serializable; import lombok.Builder; @@ -9,7 +10,7 @@ public class ClusterConnectorRequest implements Serializable { @JsonProperty private String env; - @JsonProperty private String protocol; + @JsonProperty private KafkaSupportedProtocol protocol; @JsonProperty private String connectorConfig; diff --git a/src/main/java/io/aiven/klaw/model/cluster/ClusterSchemaRequest.java b/src/main/java/io/aiven/klaw/model/cluster/ClusterSchemaRequest.java index 5ee5de9adc..076416e2d8 100644 --- a/src/main/java/io/aiven/klaw/model/cluster/ClusterSchemaRequest.java +++ b/src/main/java/io/aiven/klaw/model/cluster/ClusterSchemaRequest.java @@ -1,6 +1,7 @@ package io.aiven.klaw.model.cluster; import com.fasterxml.jackson.annotation.JsonProperty; +import io.aiven.klaw.model.KafkaSupportedProtocol; import java.io.Serializable; import lombok.Builder; @@ -9,7 +10,7 @@ public class ClusterSchemaRequest implements Serializable { @JsonProperty private String env; - @JsonProperty private String protocol; + @JsonProperty private KafkaSupportedProtocol protocol; @JsonProperty private String topicName; diff --git a/src/main/java/io/aiven/klaw/model/cluster/ClusterTopicRequest.java b/src/main/java/io/aiven/klaw/model/cluster/ClusterTopicRequest.java index af822eeafe..28cbd007a0 100644 --- a/src/main/java/io/aiven/klaw/model/cluster/ClusterTopicRequest.java +++ b/src/main/java/io/aiven/klaw/model/cluster/ClusterTopicRequest.java @@ -1,6 +1,7 @@ package io.aiven.klaw.model.cluster; import com.fasterxml.jackson.annotation.JsonProperty; +import io.aiven.klaw.model.KafkaSupportedProtocol; import java.io.Serializable; import lombok.Builder; @@ -13,7 +14,7 @@ public class ClusterTopicRequest implements Serializable { @JsonProperty private short replicationFactor; - @JsonProperty private String protocol; + @JsonProperty private KafkaSupportedProtocol protocol; @JsonProperty private String clusterName; diff --git a/src/main/java/io/aiven/klaw/service/AclSyncControllerService.java b/src/main/java/io/aiven/klaw/service/AclSyncControllerService.java index f8d180a201..709ef2b5ee 100644 --- a/src/main/java/io/aiven/klaw/service/AclSyncControllerService.java +++ b/src/main/java/io/aiven/klaw/service/AclSyncControllerService.java @@ -17,6 +17,7 @@ import io.aiven.klaw.model.ApiResultStatus; import io.aiven.klaw.model.KafkaClustersType; import io.aiven.klaw.model.KafkaFlavors; +import io.aiven.klaw.model.KafkaSupportedProtocol; import io.aiven.klaw.model.PermissionType; import io.aiven.klaw.model.RequestOperationType; import io.aiven.klaw.model.SyncAclUpdates; @@ -221,7 +222,7 @@ private void approveSyncBackAcls( private List> getAclListFromCluster( String bootstrapHost, Env envSelected, - String protocol, + KafkaSupportedProtocol protocol, String clusterName, String topicNameSearch, int tenantId) diff --git a/src/main/java/io/aiven/klaw/service/ClusterApiService.java b/src/main/java/io/aiven/klaw/service/ClusterApiService.java index b78444992c..0903e0892a 100644 --- a/src/main/java/io/aiven/klaw/service/ClusterApiService.java +++ b/src/main/java/io/aiven/klaw/service/ClusterApiService.java @@ -17,6 +17,7 @@ import io.aiven.klaw.model.ClusterStatus; import io.aiven.klaw.model.KafkaClustersType; import io.aiven.klaw.model.KafkaFlavors; +import io.aiven.klaw.model.KafkaSupportedProtocol; import io.aiven.klaw.model.RequestOperationType; import io.aiven.klaw.model.cluster.ClusterAclRequest; import io.aiven.klaw.model.cluster.ClusterConnectorRequest; @@ -170,7 +171,7 @@ String getSchemaClusterStatus(String host, int tenantId) { String getKafkaClusterStatus( String bootstrapHost, - String protocol, + KafkaSupportedProtocol protocol, String clusterIdentification, String clusterType, int tenantId) { @@ -184,7 +185,7 @@ String getKafkaClusterStatus( + uriEnvStatus + bootstrapHost + URL_DELIMITER - + String.join(URL_DELIMITER, protocol, clusterIdentification, clusterType); + + String.join(URL_DELIMITER, protocol.getName(), clusterIdentification, clusterType); ResponseEntity resultBody = getRestTemplate().exchange(uri, HttpMethod.GET, getHttpEntity(), ClusterStatus.class); @@ -197,7 +198,7 @@ String getKafkaClusterStatus( public List> getConsumerOffsets( String bootstrapHost, - String protocol, + KafkaSupportedProtocol protocol, String clusterIdentification, String topic, String consumerGroupId, @@ -213,7 +214,8 @@ public List> getConsumerOffsets( + url + bootstrapHost + URL_DELIMITER - + String.join(URL_DELIMITER, protocol, clusterIdentification, consumerGroupId, topic); + + String.join( + URL_DELIMITER, protocol.getName(), clusterIdentification, consumerGroupId, topic); ResponseEntity>> resultBody = getRestTemplate() @@ -230,7 +232,7 @@ public List> getConsumerOffsets( public Map getTopicEvents( String bootstrapHost, - String protocol, + KafkaSupportedProtocol protocol, String clusterIdentification, String topic, String offsetId, @@ -249,7 +251,12 @@ public Map getTopicEvents( + bootstrapHost + URL_DELIMITER + String.join( - URL_DELIMITER, protocol, clusterIdentification, consumerGroupId, topic, offsetId); + URL_DELIMITER, + protocol.getName(), + clusterIdentification, + consumerGroupId, + topic, + offsetId); ResponseEntity> resultBody = getRestTemplate() @@ -265,7 +272,8 @@ public Map getTopicEvents( } public List> getAcls( - String bootstrapHost, Env envSelected, String protocol, int tenantId) throws KlawException { + String bootstrapHost, Env envSelected, KafkaSupportedProtocol protocol, int tenantId) + throws KlawException { log.info("getAcls {} {} {}", bootstrapHost, protocol, tenantId); getClusterApiProperties(tenantId); @@ -288,7 +296,7 @@ public List> getAcls( + String.join( URL_DELIMITER, AclsNativeType.AIVEN.name(), - protocol, + protocol.getName(), kwClusters.getClusterName() + kwClusters.getClusterId(), kwClusters.getProjectName(), kwClusters.getServiceName()); @@ -301,7 +309,7 @@ public List> getAcls( + String.join( URL_DELIMITER, AclsNativeType.NATIVE.name(), - protocol, + protocol.getName(), kwClusters.getClusterName() + kwClusters.getClusterId(), "na", "na"); @@ -320,7 +328,10 @@ public List> getAcls( } public List> getAllTopics( - String bootstrapHost, String protocol, String clusterIdentification, int tenantId) + String bootstrapHost, + KafkaSupportedProtocol protocol, + String clusterIdentification, + int tenantId) throws Exception { log.info("getAllTopics {} {}", bootstrapHost, protocol); getClusterApiProperties(tenantId); @@ -332,7 +343,7 @@ public List> getAllTopics( + uriGetTopics + bootstrapHost + URL_DELIMITER - + String.join(URL_DELIMITER, protocol, clusterIdentification); + + String.join(URL_DELIMITER, protocol.getName(), clusterIdentification); HttpEntity entity = getHttpEntity(); ResponseEntity>> s = @@ -350,7 +361,7 @@ public List> getAllTopics( public String approveConnectorRequests( String connectorName, - String protocol, + KafkaSupportedProtocol protocol, String connectorType, String connectorConfig, String kafkaConnectHost, @@ -586,7 +597,7 @@ ResponseEntity postSchema( public TreeMap> getAvroSchema( String schemaRegistryHost, - String protocol, + KafkaSupportedProtocol protocol, String clusterName, String topicName, int tenantId) @@ -602,7 +613,7 @@ public TreeMap> getAvroSchema( + uriGetSchema + schemaRegistryHost + URL_DELIMITER - + String.join(URL_DELIMITER, protocol, clusterName, topicName); + + String.join(URL_DELIMITER, protocol.getName(), clusterName, topicName); ResponseEntity>> treeMapResponseEntity = getRestTemplate() @@ -626,7 +637,7 @@ public TreeMap> getAvroSchema( } public Map getConnectorDetails( - String connectorName, String kafkaConnectHost, String protocol, int tenantId) + String connectorName, String kafkaConnectHost, KafkaSupportedProtocol protocol, int tenantId) throws KlawException { log.info("getConnectorDetails {} {}", connectorName, kafkaConnectHost); getClusterApiProperties(tenantId); @@ -637,7 +648,7 @@ public Map getConnectorDetails( "/topics/getConnectorDetails", connectorName, kafkaConnectHost, - protocol); + protocol.getName()); String uriGetConnectorsFull = clusterConnUrl + uriGetTopics; ResponseEntity> s = diff --git a/src/main/java/io/aiven/klaw/service/EnvsClustersTenantsControllerService.java b/src/main/java/io/aiven/klaw/service/EnvsClustersTenantsControllerService.java index 958311f9b3..a8213d56e9 100644 --- a/src/main/java/io/aiven/klaw/service/EnvsClustersTenantsControllerService.java +++ b/src/main/java/io/aiven/klaw/service/EnvsClustersTenantsControllerService.java @@ -210,7 +210,11 @@ public List getClustersPaginated( List envListMap3 = kwClustersModelList.stream() .filter( - env -> env.getProtocol().toLowerCase().contains(searchClusterParam.toLowerCase())) + env -> + env.getProtocol() + .getName() + .toLowerCase() + .contains(searchClusterParam.toLowerCase())) .collect(Collectors.toList()); envListMap1.addAll(envListMap2); envListMap1.addAll(envListMap3); @@ -573,7 +577,7 @@ public List getSchemaRegEnvsStatus() { .getClusters(KafkaClustersType.SCHEMA_REGISTRY.value, tenantId) .get(oneEnv.getClusterId()) .getProtocol() - .equalsIgnoreCase("plaintext")) + .equals(KafkaSupportedProtocol.PLAINTEXT)) status = clusterApiService.getSchemaClusterStatus( manageDatabase @@ -688,7 +692,7 @@ public ApiResponse addNewEnv(EnvModel newEnv) throws KlawException { } public ApiResponse addNewCluster(KwClustersModel kwClustersModel) { - log.info("addNewCluster {}", kwClustersModel.getClusterName()); + log.info("addNewCluster {}", kwClustersModel); Map resultMap = new HashMap<>(); int tenantId = commonUtilsService.getTenantId(getUserName()); @@ -722,7 +726,7 @@ public ApiResponse addNewCluster(KwClustersModel kwClustersModel) { kwCluster.setClusterName(kwCluster.getClusterName().toUpperCase()); // only for new cluster requests on saas - if ("SSL".equals(kwCluster.getProtocol()) + if (KafkaSupportedProtocol.SSL.equals(kwCluster.getProtocol()) && kwCluster.getClusterId() == null && "saas".equals(kwInstallationType)) { if (!savePublicKey(kwClustersModel, resultMap, tenantId, kwCluster)) { @@ -1243,4 +1247,16 @@ public Map getClusterInfoFromEnv(String envSelected, String clus return clusterInfo; } + + public List> getSupportedKafkaProtocols() { + List> supportedProtocols = new ArrayList<>(); + for (KafkaSupportedProtocol kafkaSupportedProtocol : KafkaSupportedProtocol.values()) { + Map protocolValues = new HashMap<>(); + protocolValues.put("name", kafkaSupportedProtocol.getName()); + protocolValues.put("value", kafkaSupportedProtocol.getValue()); + supportedProtocols.add(protocolValues); + } + + return supportedProtocols; + } } diff --git a/src/main/java/io/aiven/klaw/service/KafkaConnectControllerService.java b/src/main/java/io/aiven/klaw/service/KafkaConnectControllerService.java index f0bf80fb5d..79e574fedc 100644 --- a/src/main/java/io/aiven/klaw/service/KafkaConnectControllerService.java +++ b/src/main/java/io/aiven/klaw/service/KafkaConnectControllerService.java @@ -27,6 +27,7 @@ import io.aiven.klaw.model.KafkaClustersType; import io.aiven.klaw.model.KafkaConnectorModel; import io.aiven.klaw.model.KafkaConnectorRequestModel; +import io.aiven.klaw.model.KafkaSupportedProtocol; import io.aiven.klaw.model.PermissionType; import io.aiven.klaw.model.RequestOperationType; import io.aiven.klaw.model.RequestStatus; @@ -562,7 +563,7 @@ public ApiResponse approveConnectorRequests(String connectorId) throws KlawExcep manageDatabase .getClusters(KafkaClustersType.KAFKA_CONNECT.value, tenantId) .get(envSelected.getClusterId()); - String protocol = kwClusters.getProtocol(); + KafkaSupportedProtocol protocol = kwClusters.getProtocol(); String kafkaConnectHost = kwClusters.getBootstrapServers(); if (RequestOperationType.UPDATE.value.equals( diff --git a/src/main/java/io/aiven/klaw/validation/KafkaClusterValidator.java b/src/main/java/io/aiven/klaw/validation/KafkaClusterValidator.java new file mode 100644 index 0000000000..514362d4ba --- /dev/null +++ b/src/main/java/io/aiven/klaw/validation/KafkaClusterValidator.java @@ -0,0 +1,21 @@ +package io.aiven.klaw.validation; + +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; +import javax.validation.Constraint; +import javax.validation.Payload; + +@Target({TYPE, ANNOTATION_TYPE}) +@Retention(RUNTIME) +@Constraint(validatedBy = KafkaClusterValidatorImpl.class) +public @interface KafkaClusterValidator { + String message() default "Invalid kafka cluster details provided !"; + + Class[] groups() default {}; + + Class[] payload() default {}; +} diff --git a/src/main/java/io/aiven/klaw/validation/KafkaClusterValidatorImpl.java b/src/main/java/io/aiven/klaw/validation/KafkaClusterValidatorImpl.java new file mode 100644 index 0000000000..23ff702cde --- /dev/null +++ b/src/main/java/io/aiven/klaw/validation/KafkaClusterValidatorImpl.java @@ -0,0 +1,18 @@ +package io.aiven.klaw.validation; + +import io.aiven.klaw.model.KwClustersModel; +import javax.validation.ConstraintValidator; +import javax.validation.ConstraintValidatorContext; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class KafkaClusterValidatorImpl + implements ConstraintValidator { + @Override + public boolean isValid( + KwClustersModel KwClustersModel, ConstraintValidatorContext constraintValidatorContext) { + + return true; + // add validations for bootstrap servers .. + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 504ab9218f..7aee27bce2 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -170,4 +170,5 @@ klaw.max.tenants=200 # log file settings #logging.level.root=debug logging.level.org.hibernate.SQL=off -logging.file.name=./../logs/kw-uiapi.log \ No newline at end of file +logging.file.name=./../logs/kw-uiapi.log +spring.mvc.log-resolved-exception=true \ No newline at end of file diff --git a/src/main/resources/static/js/envs.js b/src/main/resources/static/js/envs.js index ab04cbf376..31ec87b71c 100644 --- a/src/main/resources/static/js/envs.js +++ b/src/main/resources/static/js/envs.js @@ -813,7 +813,7 @@ app.controller("envsCtrl", function($scope, $http, $location, $window) { return; } - // Prefix and suffix validations + // Prefix and suffix validation if($scope.addNewEnv.topicprefix && $scope.addNewEnv.topicprefix.length > 0) $scope.addNewEnv.topicprefix = $scope.addNewEnv.topicprefix.trim(); @@ -1042,7 +1042,6 @@ app.controller("envsCtrl", function($scope, $http, $location, $window) { } $scope.getKafkaConnectEnvs = function() { - $http({ method: "GET", url: "getKafkaConnectEnvs", @@ -1074,6 +1073,21 @@ app.controller("envsCtrl", function($scope, $http, $location, $window) { $scope.showSuccessToast(); } + $scope.getKafkaSupportedProtocols = function() { + $http({ + method: "GET", + url: "getKafkaProtocols", + headers : { 'Content-Type' : 'application/json' } + }).success(function(output) { + $scope.kafkaProtocols = output; + }).error( + function(error) + { + $scope.alert = error; + } + ); + } + $scope.refreshPage = function(){ $window.location.reload(); } diff --git a/src/main/resources/static/js/modifyEnvs.js b/src/main/resources/static/js/modifyEnvs.js index 4db1ef1f8b..b78bc779a0 100644 --- a/src/main/resources/static/js/modifyEnvs.js +++ b/src/main/resources/static/js/modifyEnvs.js @@ -694,9 +694,23 @@ app.controller("modifyEnvsCtrl", function($scope, $http, $location, $window) { $scope.handleValidationErrors(error); } ); - }; + $scope.getKafkaSupportedProtocols = function() { + $http({ + method: "GET", + url: "getKafkaProtocols", + headers : { 'Content-Type' : 'application/json' } + }).success(function(output) { + $scope.kafkaProtocols = output; + }).error( + function(error) + { + $scope.alert = error; + } + ); + } + $scope.refreshPage = function(){ $window.location.reload(); } diff --git a/src/main/resources/templates/addCluster.html b/src/main/resources/templates/addCluster.html index 711814d947..259e7c8d92 100644 --- a/src/main/resources/templates/addCluster.html +++ b/src/main/resources/templates/addCluster.html @@ -419,7 +419,7 @@

Shortcuts

-
+
@@ -559,13 +559,9 @@

Shortcuts

-
@@ -575,12 +571,9 @@

Shortcuts

-
diff --git a/src/main/resources/templates/modifyCluster.html b/src/main/resources/templates/modifyCluster.html index d2737b6b26..a32cf7d6f3 100644 --- a/src/main/resources/templates/modifyCluster.html +++ b/src/main/resources/templates/modifyCluster.html @@ -450,7 +450,7 @@

Shortcuts

-
+
@@ -495,13 +495,9 @@

Shortcuts

-
@@ -510,8 +506,6 @@

Shortcuts

- -
@@ -525,7 +519,7 @@

Shortcuts

-
+
diff --git a/src/test/java/io/aiven/klaw/MockMethods.java b/src/test/java/io/aiven/klaw/MockMethods.java index ce17a8cf2b..1a2ad862b7 100644 --- a/src/test/java/io/aiven/klaw/MockMethods.java +++ b/src/test/java/io/aiven/klaw/MockMethods.java @@ -52,7 +52,7 @@ public KwClustersModel getClusterModel(String dev_cluster) { KwClustersModel kwClustersModel = new KwClustersModel(); kwClustersModel.setClusterName(dev_cluster); kwClustersModel.setBootstrapServers("localhost:9092"); - kwClustersModel.setProtocol("PLAINTEXT"); + kwClustersModel.setProtocol(KafkaSupportedProtocol.PLAINTEXT); kwClustersModel.setClusterType(KafkaClustersType.KAFKA.value); kwClustersModel.setKafkaFlavor("Apache Kafka"); diff --git a/src/test/java/io/aiven/klaw/TopicAclControllerIT.java b/src/test/java/io/aiven/klaw/TopicAclControllerIT.java index ba714b6788..0126cbc4b9 100644 --- a/src/test/java/io/aiven/klaw/TopicAclControllerIT.java +++ b/src/test/java/io/aiven/klaw/TopicAclControllerIT.java @@ -22,6 +22,7 @@ import io.aiven.klaw.model.ApiResultStatus; import io.aiven.klaw.model.EnvModel; import io.aiven.klaw.model.KafkaClustersType; +import io.aiven.klaw.model.KafkaSupportedProtocol; import io.aiven.klaw.model.KwClustersModel; import io.aiven.klaw.model.KwPropertiesModel; import io.aiven.klaw.model.RequestOperationType; @@ -418,7 +419,8 @@ public void deleteTopicRequest() throws Exception { @Order(12) @Test public void getTopicsFromCluster() throws Exception { - when(clusterApiService.getAllTopics(anyString(), eq("PLAINTEXT"), anyString(), anyInt())) + when(clusterApiService.getAllTopics( + anyString(), eq(KafkaSupportedProtocol.PLAINTEXT), anyString(), anyInt())) .thenReturn(utilMethods.getClusterApiTopics(topicName, 10)); String res = @@ -444,7 +446,8 @@ public void getTopicsFromCluster() throws Exception { @Order(13) @Test public void getOnlyTopicNames() throws Exception { - when(clusterApiService.getAllTopics(anyString(), eq("PLAINTEXT"), anyString(), anyInt())) + when(clusterApiService.getAllTopics( + anyString(), eq(KafkaSupportedProtocol.PLAINTEXT), anyString(), anyInt())) .thenReturn(utilMethods.getClusterApiTopics(topicName, 10)); String res = @@ -687,7 +690,8 @@ public void deleteAclReq() throws Exception { @Test public void getAclsWithSearch() throws Exception { List> aclInfo = new ArrayList<>(utilMethods.getClusterAcls2()); - when(clusterApiService.getAcls(anyString(), any(), eq("PLAINTEXT"), anyInt())) + when(clusterApiService.getAcls( + anyString(), any(), eq(KafkaSupportedProtocol.PLAINTEXT), anyInt())) .thenReturn(aclInfo); String res = @@ -712,7 +716,8 @@ public void getAclsWithSearch() throws Exception { public void getAclsToBeSynced() throws Exception { List> aclInfo = utilMethods.getClusterAcls(); - when(clusterApiService.getAcls(anyString(), any(), eq("PLAINTEXT"), anyInt())) + when(clusterApiService.getAcls( + anyString(), any(), eq(KafkaSupportedProtocol.PLAINTEXT), anyInt())) .thenReturn(aclInfo); String res = diff --git a/src/test/java/io/aiven/klaw/service/AclControllerServiceTest.java b/src/test/java/io/aiven/klaw/service/AclControllerServiceTest.java index 2a92f7f5c1..5058185dec 100644 --- a/src/test/java/io/aiven/klaw/service/AclControllerServiceTest.java +++ b/src/test/java/io/aiven/klaw/service/AclControllerServiceTest.java @@ -26,6 +26,7 @@ import io.aiven.klaw.model.AclType; import io.aiven.klaw.model.ApiResponse; import io.aiven.klaw.model.ApiResultStatus; +import io.aiven.klaw.model.KafkaSupportedProtocol; import io.aiven.klaw.model.SyncAclUpdates; import java.sql.Timestamp; import java.util.ArrayList; @@ -426,7 +427,7 @@ public void getAclsSyncTrue1() throws KlawException { when(manageDatabase.getTeamsAndAllowedEnvs(anyInt(), anyInt())) .thenReturn(Collections.singletonList("1")); when(manageDatabase.getKafkaEnvList(anyInt())).thenReturn(utilMethods.getEnvLists()); - when(clusterApiService.getAcls(anyString(), any(), anyString(), anyInt())) + when(clusterApiService.getAcls(anyString(), any(), any(KafkaSupportedProtocol.class), anyInt())) .thenReturn(utilMethods.getClusterAcls()); when(handleDbRequests.selectAllTeamsOfUsers(anyString(), anyInt())) .thenReturn(getAvailableTeams()); @@ -452,7 +453,7 @@ public void getAclsSyncTrue2() throws KlawException { when(manageDatabase.getTeamsAndAllowedEnvs(anyInt(), anyInt())) .thenReturn(Collections.singletonList("1")); when(manageDatabase.getKafkaEnvList(anyInt())).thenReturn(utilMethods.getEnvLists()); - when(clusterApiService.getAcls(anyString(), any(), anyString(), anyInt())) + when(clusterApiService.getAcls(anyString(), any(), any(KafkaSupportedProtocol.class), anyInt())) .thenReturn(utilMethods.getClusterAcls()); when(handleDbRequests.selectAllTeamsOfUsers(anyString(), anyInt())) .thenReturn(getAvailableTeams()); diff --git a/src/test/java/io/aiven/klaw/service/ClusterApiServiceTest.java b/src/test/java/io/aiven/klaw/service/ClusterApiServiceTest.java index c1d04a9c33..fc7dc24502 100644 --- a/src/test/java/io/aiven/klaw/service/ClusterApiServiceTest.java +++ b/src/test/java/io/aiven/klaw/service/ClusterApiServiceTest.java @@ -21,6 +21,7 @@ import io.aiven.klaw.model.ApiResponse; import io.aiven.klaw.model.ApiResultStatus; import io.aiven.klaw.model.ClusterStatus; +import io.aiven.klaw.model.KafkaSupportedProtocol; import io.aiven.klaw.model.RequestOperationType; import java.util.ArrayList; import java.util.HashSet; @@ -92,7 +93,8 @@ public void getStatusSuccess() { result = clusterApiService.getSchemaClusterStatus("", 1); assertThat(result).isEqualTo(ClusterStatus.ONLINE.value); - result = clusterApiService.getKafkaClusterStatus("", "PLAINTEXT", "", "", 1); + result = + clusterApiService.getKafkaClusterStatus("", KafkaSupportedProtocol.PLAINTEXT, "", "", 1); assertThat(result).isEqualTo(ClusterStatus.ONLINE.value); } @@ -110,7 +112,8 @@ public void getStatusFailure() { result = clusterApiService.getSchemaClusterStatus("", 1); assertThat(result).isEqualTo("OFFLINE"); - result = clusterApiService.getKafkaClusterStatus("", "PLAINTEXT", "", "", 1); + result = + clusterApiService.getKafkaClusterStatus("", KafkaSupportedProtocol.PLAINTEXT, "", "", 1); assertThat(result).isEqualTo("NOT_KNOWN"); } @@ -131,7 +134,8 @@ public void getAclsSuccess() throws KlawException { (ParameterizedTypeReference) any())) .thenReturn(response); - List> result = clusterApiService.getAcls("", env, "PLAINTEXT", 1); + List> result = + clusterApiService.getAcls("", env, KafkaSupportedProtocol.PLAINTEXT, 1); assertThat(result).isEqualTo(new ArrayList<>(aclListOriginal)); } @@ -143,7 +147,8 @@ public void getAclsFailure() { Mockito.anyString(), eq(HttpMethod.GET), Mockito.any(), eq(Set.class))) .thenThrow(new RuntimeException("error")); - assertThatThrownBy(() -> clusterApiService.getAcls("", env, "PLAINTEXT", 1)) + assertThatThrownBy( + () -> clusterApiService.getAcls("", env, KafkaSupportedProtocol.PLAINTEXT, 1)) .isInstanceOf(KlawException.class); } @@ -160,7 +165,8 @@ public void getAllTopicsSuccess() throws Exception { (ParameterizedTypeReference) any())) .thenReturn(response); - List> result = clusterApiService.getAllTopics("", "PLAINTEXT", "", 1); + List> result = + clusterApiService.getAllTopics("", KafkaSupportedProtocol.PLAINTEXT, "", 1); assertThat(result).isEqualTo(new ArrayList<>(topicsList)); } @@ -172,7 +178,8 @@ public void getAllTopicsFailure() throws Exception { Mockito.anyString(), eq(HttpMethod.GET), Mockito.any(), eq(Set.class))) .thenThrow(new RuntimeException("error")); - assertThatThrownBy(() -> clusterApiService.getAllTopics("", "PLAINTEXT", "", 1)) + assertThatThrownBy( + () -> clusterApiService.getAllTopics("", KafkaSupportedProtocol.PLAINTEXT, "", 1)) .isInstanceOf(KlawException.class); } @@ -194,7 +201,7 @@ public void approveTopicRequestsSuccess() throws KlawException { when(manageDatabase.getClusters(anyString(), anyInt())).thenReturn(clustersHashMap); when(clustersHashMap.get(any())).thenReturn(kwClusters); when(kwClusters.getBootstrapServers()).thenReturn("clusters"); - when(kwClusters.getProtocol()).thenReturn("PLAINTEXT"); + when(kwClusters.getProtocol()).thenReturn(KafkaSupportedProtocol.PLAINTEXT); when(kwClusters.getClusterName()).thenReturn("cluster"); when(restTemplate.postForEntity(Mockito.anyString(), Mockito.any(), eq(ApiResponse.class))) .thenReturn(response); @@ -219,7 +226,7 @@ public void approveTopicRequestsFailure() { when(manageDatabase.getClusters(anyString(), anyInt())).thenReturn(clustersHashMap); when(clustersHashMap.get(any())).thenReturn(kwClusters); when(kwClusters.getBootstrapServers()).thenReturn("clusters"); - when(kwClusters.getProtocol()).thenReturn("PLAINTEXT"); + when(kwClusters.getProtocol()).thenReturn(KafkaSupportedProtocol.PLAINTEXT); when(kwClusters.getClusterName()).thenReturn("cluster"); when(restTemplate.postForEntity(Mockito.anyString(), Mockito.any(), eq(ApiResponse.class))) .thenThrow(new RuntimeException("error")); @@ -248,7 +255,7 @@ public void approveAclRequestsSuccess1() throws KlawException { when(manageDatabase.getClusters(anyString(), anyInt())).thenReturn(clustersHashMap); when(clustersHashMap.get(any())).thenReturn(kwClusters); when(kwClusters.getBootstrapServers()).thenReturn("clusters"); - when(kwClusters.getProtocol()).thenReturn("PLAINTEXT"); + when(kwClusters.getProtocol()).thenReturn(KafkaSupportedProtocol.PLAINTEXT); when(kwClusters.getClusterName()).thenReturn("cluster"); when(kwClusters.getKafkaFlavor()).thenReturn("Apache Kafka"); when(restTemplate.exchange( @@ -279,7 +286,7 @@ public void approveAclRequestsSuccess2() throws KlawException { when(manageDatabase.getClusters(anyString(), anyInt())).thenReturn(clustersHashMap); when(clustersHashMap.get(any())).thenReturn(kwClusters); when(kwClusters.getBootstrapServers()).thenReturn("clusters"); - when(kwClusters.getProtocol()).thenReturn("PLAINTEXT"); + when(kwClusters.getProtocol()).thenReturn(KafkaSupportedProtocol.PLAINTEXT); when(kwClusters.getClusterName()).thenReturn("cluster"); when(kwClusters.getKafkaFlavor()).thenReturn("Apache Kafka"); when(restTemplate.exchange( @@ -321,7 +328,7 @@ public void postSchemaSucess() throws KlawException { when(manageDatabase.getClusters(anyString(), anyInt())).thenReturn(clustersHashMap); when(clustersHashMap.get(any())).thenReturn(kwClusters); when(kwClusters.getBootstrapServers()).thenReturn("clusters"); - when(kwClusters.getProtocol()).thenReturn("PLAINTEXT"); + when(kwClusters.getProtocol()).thenReturn(KafkaSupportedProtocol.PLAINTEXT); when(kwClusters.getClusterName()).thenReturn("cluster"); when(restTemplate.postForEntity(Mockito.anyString(), Mockito.any(), eq(ApiResponse.class))) .thenReturn(response); diff --git a/src/test/java/io/aiven/klaw/service/TopicControllerServiceTest.java b/src/test/java/io/aiven/klaw/service/TopicControllerServiceTest.java index 028dc91d53..3ff1d570f6 100644 --- a/src/test/java/io/aiven/klaw/service/TopicControllerServiceTest.java +++ b/src/test/java/io/aiven/klaw/service/TopicControllerServiceTest.java @@ -19,6 +19,7 @@ import io.aiven.klaw.helpers.db.rdbms.HandleDbRequestsJdbc; import io.aiven.klaw.model.ApiResponse; import io.aiven.klaw.model.ApiResultStatus; +import io.aiven.klaw.model.KafkaSupportedProtocol; import io.aiven.klaw.model.KwTenantConfigModel; import io.aiven.klaw.model.RequestOperationType; import io.aiven.klaw.model.SyncTopicUpdates; @@ -427,14 +428,15 @@ public void getSyncTopics() throws Exception { stubUserInfo(); when(manageDatabase.getKafkaEnvList(anyInt())).thenReturn(utilMethods.getEnvLists()); - when(clusterApiService.getAllTopics(anyString(), anyString(), anyString(), anyInt())) + when(clusterApiService.getAllTopics( + anyString(), any(KafkaSupportedProtocol.class), anyString(), anyInt())) .thenReturn(utilMethods.getClusterApiTopics("topic", 10)); when(handleDbRequests.selectAllTeamsOfUsers(anyString(), anyInt())) .thenReturn(getAvailableTeams()); when(manageDatabase.getClusters(anyString(), anyInt())).thenReturn(clustersHashMap); when(clustersHashMap.get(any())).thenReturn(kwClusters); when(kwClusters.getBootstrapServers()).thenReturn("clusters"); - when(kwClusters.getProtocol()).thenReturn("PLAINTEXT"); + when(kwClusters.getProtocol()).thenReturn(KafkaSupportedProtocol.PLAINTEXT); when(kwClusters.getClusterName()).thenReturn("cluster"); when(rolesPermissionsControllerService.getApproverRoles(anyString(), anyInt())) .thenReturn(List.of("USER")); From a0044bffa838447728532e161ff50b678632a766 Mon Sep 17 00:00:00 2001 From: muralibasani Date: Mon, 17 Oct 2022 19:03:44 +0200 Subject: [PATCH 2/6] Adding enum for kafka protocols --- .../java/io/aiven/klaw/service/AclControllerServiceTest.java | 2 +- src/test/java/io/aiven/klaw/service/ClusterApiServiceTest.java | 2 +- .../java/io/aiven/klaw/service/TopicControllerServiceTest.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/io/aiven/klaw/service/AclControllerServiceTest.java b/src/test/java/io/aiven/klaw/service/AclControllerServiceTest.java index e252a5b107..133ae965c5 100644 --- a/src/test/java/io/aiven/klaw/service/AclControllerServiceTest.java +++ b/src/test/java/io/aiven/klaw/service/AclControllerServiceTest.java @@ -26,8 +26,8 @@ import io.aiven.klaw.model.AclType; import io.aiven.klaw.model.ApiResponse; import io.aiven.klaw.model.ApiResultStatus; -import io.aiven.klaw.model.KafkaSupportedProtocol; import io.aiven.klaw.model.KafkaClustersType; +import io.aiven.klaw.model.KafkaSupportedProtocol; import io.aiven.klaw.model.SyncAclUpdates; import java.sql.Timestamp; import java.util.ArrayList; diff --git a/src/test/java/io/aiven/klaw/service/ClusterApiServiceTest.java b/src/test/java/io/aiven/klaw/service/ClusterApiServiceTest.java index d629775a20..7a1a2456d5 100644 --- a/src/test/java/io/aiven/klaw/service/ClusterApiServiceTest.java +++ b/src/test/java/io/aiven/klaw/service/ClusterApiServiceTest.java @@ -21,8 +21,8 @@ import io.aiven.klaw.model.ApiResponse; import io.aiven.klaw.model.ApiResultStatus; import io.aiven.klaw.model.ClusterStatus; -import io.aiven.klaw.model.KafkaSupportedProtocol; import io.aiven.klaw.model.KafkaClustersType; +import io.aiven.klaw.model.KafkaSupportedProtocol; import io.aiven.klaw.model.RequestOperationType; import java.util.ArrayList; import java.util.HashSet; diff --git a/src/test/java/io/aiven/klaw/service/TopicControllerServiceTest.java b/src/test/java/io/aiven/klaw/service/TopicControllerServiceTest.java index 2392ff3d0e..2558d54bab 100644 --- a/src/test/java/io/aiven/klaw/service/TopicControllerServiceTest.java +++ b/src/test/java/io/aiven/klaw/service/TopicControllerServiceTest.java @@ -19,8 +19,8 @@ import io.aiven.klaw.helpers.db.rdbms.HandleDbRequestsJdbc; import io.aiven.klaw.model.ApiResponse; import io.aiven.klaw.model.ApiResultStatus; -import io.aiven.klaw.model.KafkaSupportedProtocol; import io.aiven.klaw.model.KafkaClustersType; +import io.aiven.klaw.model.KafkaSupportedProtocol; import io.aiven.klaw.model.KwTenantConfigModel; import io.aiven.klaw.model.RequestOperationType; import io.aiven.klaw.model.SyncTopicUpdates; From 6ec34ef32f2e57abfee5343122d11dd5465e7a9f Mon Sep 17 00:00:00 2001 From: muralibasani Date: Mon, 17 Oct 2022 19:10:29 +0200 Subject: [PATCH 3/6] Adding enum for kafka protocols --- .../klaw/service/EnvsClustersTenantsControllerService.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/aiven/klaw/service/EnvsClustersTenantsControllerService.java b/src/main/java/io/aiven/klaw/service/EnvsClustersTenantsControllerService.java index 23bc058b75..4955bf2e8a 100644 --- a/src/main/java/io/aiven/klaw/service/EnvsClustersTenantsControllerService.java +++ b/src/main/java/io/aiven/klaw/service/EnvsClustersTenantsControllerService.java @@ -576,8 +576,7 @@ public List getSchemaRegEnvsStatus() { if (manageDatabase .getClusters(KafkaClustersType.SCHEMA_REGISTRY, tenantId) .get(oneEnv.getClusterId()) - .getProtocol() - .equals(KafkaSupportedProtocol.PLAINTEXT)) + .getProtocol() == KafkaSupportedProtocol.PLAINTEXT) status = clusterApiService.getSchemaClusterStatus( manageDatabase @@ -726,7 +725,7 @@ public ApiResponse addNewCluster(KwClustersModel kwClustersModel) { kwCluster.setClusterName(kwCluster.getClusterName().toUpperCase()); // only for new cluster requests on saas - if (KafkaSupportedProtocol.SSL.equals(kwCluster.getProtocol()) + if (KafkaSupportedProtocol.SSL == kwCluster.getProtocol() && kwCluster.getClusterId() == null && "saas".equals(kwInstallationType)) { if (!savePublicKey(kwClustersModel, resultMap, tenantId, kwCluster)) { From 346fdbe4443fb5f1c4ea812f89e0bf4f1392e389 Mon Sep 17 00:00:00 2001 From: muralibasani Date: Mon, 17 Oct 2022 19:11:47 +0200 Subject: [PATCH 4/6] Adding enum for kafka protocols --- .../klaw/service/EnvsClustersTenantsControllerService.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/aiven/klaw/service/EnvsClustersTenantsControllerService.java b/src/main/java/io/aiven/klaw/service/EnvsClustersTenantsControllerService.java index 4955bf2e8a..0a697fe439 100644 --- a/src/main/java/io/aiven/klaw/service/EnvsClustersTenantsControllerService.java +++ b/src/main/java/io/aiven/klaw/service/EnvsClustersTenantsControllerService.java @@ -574,9 +574,10 @@ public List getSchemaRegEnvsStatus() { String status; if (manageDatabase - .getClusters(KafkaClustersType.SCHEMA_REGISTRY, tenantId) - .get(oneEnv.getClusterId()) - .getProtocol() == KafkaSupportedProtocol.PLAINTEXT) + .getClusters(KafkaClustersType.SCHEMA_REGISTRY, tenantId) + .get(oneEnv.getClusterId()) + .getProtocol() + == KafkaSupportedProtocol.PLAINTEXT) status = clusterApiService.getSchemaClusterStatus( manageDatabase From b0fff7376d26bda9f1fb3cbbfb7a396c0ca63468 Mon Sep 17 00:00:00 2001 From: muralibasani Date: Tue, 18 Oct 2022 09:16:40 +0200 Subject: [PATCH 5/6] Removed unused call to get schema registry env based on plaintext protocol --- .../EnvsClustersTenantsController.java | 9 - .../EnvsClustersTenantsControllerService.java | 38 ---- src/main/resources/static/index.html | 206 ++++++++---------- src/main/resources/static/js/index.js | 18 -- .../controller/UiConfigControllerTest.java | 43 +--- 5 files changed, 104 insertions(+), 210 deletions(-) diff --git a/src/main/java/io/aiven/klaw/controller/EnvsClustersTenantsController.java b/src/main/java/io/aiven/klaw/controller/EnvsClustersTenantsController.java index 6db23ae028..523e646fc5 100644 --- a/src/main/java/io/aiven/klaw/controller/EnvsClustersTenantsController.java +++ b/src/main/java/io/aiven/klaw/controller/EnvsClustersTenantsController.java @@ -167,15 +167,6 @@ public ResponseEntity> getKafkaConnectEnvs() { envsClustersTenantsControllerService.getKafkaConnectEnvs(), HttpStatus.OK); } - @RequestMapping( - value = "/getSchemaRegEnvsStatus", - method = RequestMethod.GET, - produces = {MediaType.APPLICATION_JSON_VALUE}) - public ResponseEntity> getSchemaRegEnvsStatus() { - return new ResponseEntity<>( - envsClustersTenantsControllerService.getSchemaRegEnvsStatus(), HttpStatus.OK); - } - @PostMapping(value = "/addNewEnv") public ResponseEntity addNewEnv(@Valid @RequestBody EnvModel newEnv) throws KlawException { diff --git a/src/main/java/io/aiven/klaw/service/EnvsClustersTenantsControllerService.java b/src/main/java/io/aiven/klaw/service/EnvsClustersTenantsControllerService.java index 0a697fe439..95c75c79e6 100644 --- a/src/main/java/io/aiven/klaw/service/EnvsClustersTenantsControllerService.java +++ b/src/main/java/io/aiven/klaw/service/EnvsClustersTenantsControllerService.java @@ -557,44 +557,6 @@ public List getKafkaConnectEnvs() { return envModelList; } - public List getSchemaRegEnvsStatus() { - List listEnvs = - manageDatabase - .getHandleDbRequests() - .selectAllSchemaRegEnvs(commonUtilsService.getTenantId(getUserName())); - int tenantId = commonUtilsService.getTenantId(getUserName()); - List allowedEnvIdList = getEnvsFromUserId(); - listEnvs = - listEnvs.stream() - .filter(env -> allowedEnvIdList.contains(env.getId())) - .collect(Collectors.toList()); - - List newListEnvs = new ArrayList<>(); - for (Env oneEnv : listEnvs) { - String status; - - if (manageDatabase - .getClusters(KafkaClustersType.SCHEMA_REGISTRY, tenantId) - .get(oneEnv.getClusterId()) - .getProtocol() - == KafkaSupportedProtocol.PLAINTEXT) - status = - clusterApiService.getSchemaClusterStatus( - manageDatabase - .getClusters(KafkaClustersType.SCHEMA_REGISTRY, tenantId) - .get(oneEnv.getClusterId()) - .getBootstrapServers(), - tenantId); - else { - status = "NOT_KNOWN"; - } - oneEnv.setEnvStatus(status); - newListEnvs.add(oneEnv); - } - - return getEnvModels(newListEnvs, KafkaClustersType.SCHEMA_REGISTRY, tenantId); - } - public ApiResponse addNewEnv(EnvModel newEnv) throws KlawException { log.info("addNewEnv {}", newEnv); int tenantId = getUserDetails(getUserName()).getTenantId(); diff --git a/src/main/resources/static/index.html b/src/main/resources/static/index.html index f565136214..57d2004a6c 100644 --- a/src/main/resources/static/index.html +++ b/src/main/resources/static/index.html @@ -8,25 +8,15 @@ - - - - - - - + + + @@ -35,15 +25,19 @@ - + - + + + + + @@ -55,6 +49,7 @@ + @@ -76,9 +71,9 @@ @@ -107,6 +102,7 @@

{{ companyinfo }}

+
  • My Profile
  • -
  • My Tenant Info
  • +
  • My Tenant Info
  • Change Password
  • Logout
  • @@ -236,6 +232,14 @@

    Contact Administrator

    Help

  • @@ -284,7 +296,7 @@

    Shortcuts

  • @@ -294,7 +306,7 @@

    Shortcuts

    @@ -326,22 +338,22 @@

    Shortcuts

  • Settings
  • -
  • +
  • -
  • - -
  • -
  • +
  • + +
  • +
  • @@ -391,7 +403,7 @@

    Shortcuts

  • Topic Request
  • Acl Request
  • Schema Request
  • -
  • KafkaConnect Request
  • +
  • KafkaConnect Request
  • User Request
  • @@ -400,6 +412,9 @@

    Shortcuts

    +
    + {{ dashboardDetails.broadcastText }} +
    @@ -419,8 +434,8 @@

    Shortcuts

    -
    -
    +
    + - - -
    - - -
    -
    -
    +
    + -
    -
    + +
    - - -
    -
    - +
    +
    +
    + +
    -
    - - - + +
    - - -
    + - - - - - - - - -
    - - -
    +
    -
    -
    -

    -
    -
    -

    {{ allenv.name }}

    - -
    - ONLINE -
    -
    - {{allenv.envStatus}} -
    - -
    +
    +
    -
    + +
    {{ alert }}
    + +
    @@ -720,6 +699,7 @@
    + diff --git a/src/main/resources/static/js/index.js b/src/main/resources/static/js/index.js index 12bf389cf4..f19451534c 100644 --- a/src/main/resources/static/js/index.js +++ b/src/main/resources/static/js/index.js @@ -60,24 +60,6 @@ app.controller("dashboardCtrl", function($scope, $http, $location, $window, $ro $scope.showProgressBar = "true"; } - $scope.getSchemaRegEnvs = function() { - - - $http({ - method: "GET", - url: "getSchemaRegEnvsStatus", - headers : { 'Content-Type' : 'application/json' } - }).success(function(output) { - $scope.allschenvs = output; - }).error( - function(error) - { - $scope.alert = error; - } - ); - - } - $scope.onClickRefresh = function(){ $scope.showServerStatus = "false"; $scope.showProgressBar = "false"; diff --git a/src/test/java/io/aiven/klaw/controller/UiConfigControllerTest.java b/src/test/java/io/aiven/klaw/controller/UiConfigControllerTest.java index 4410f463d1..b7977821a9 100644 --- a/src/test/java/io/aiven/klaw/controller/UiConfigControllerTest.java +++ b/src/test/java/io/aiven/klaw/controller/UiConfigControllerTest.java @@ -151,27 +151,6 @@ public void getSchemaRegEnvs() throws Exception { @Test @Order(5) - public void getSchemaRegEnvsStatus() throws Exception { - List envList = utilMethods.getEnvList(); - when(envsClustersTenantsControllerService.getSchemaRegEnvsStatus()).thenReturn(envList); - - String res = - mvcEnvs - .perform( - MockMvcRequestBuilders.get("/getSchemaRegEnvsStatus") - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andReturn() - .getResponse() - .getContentAsString(); - - List response = OBJECT_MAPPER.readValue(res, List.class); - assertThat(response).hasSize(1); - } - - @Test - @Order(6) public void getAllTeamsSU() throws Exception { List teamList = utilMethods.getTeamsModel(); when(usersTeamsControllerService.getAllTeamsSU()).thenReturn(teamList); @@ -192,7 +171,7 @@ public void getAllTeamsSU() throws Exception { } @Test - @Order(7) + @Order(6) public void getAllTeamsSUOnly() throws Exception { List teamList = utilMethods.getAllTeamsSUOnly(); when(usersTeamsControllerService.getAllTeamsSUOnly()).thenReturn(teamList); @@ -213,7 +192,7 @@ public void getAllTeamsSUOnly() throws Exception { } @Test - @Order(8) + @Order(7) public void addNewEnv() throws Exception { EnvModel env = utilMethods.getEnvList().get(0); String jsonReq = OBJECT_MAPPER.writer().writeValueAsString(env); @@ -237,7 +216,7 @@ public void addNewEnv() throws Exception { } @Test - @Order(9) + @Order(8) public void deleteEnv() throws Exception { ApiResponse apiResponse = ApiResponse.builder().result(ApiResultStatus.SUCCESS.value).build(); when(envsClustersTenantsControllerService.deleteEnvironment(anyString(), anyString())) @@ -261,7 +240,7 @@ public void deleteEnv() throws Exception { } @Test - @Order(10) + @Order(9) public void deleteTeam() throws Exception { ApiResponse apiResponse = ApiResponse.builder().result(ApiResultStatus.SUCCESS.value).build(); when(usersTeamsControllerService.deleteTeam(any())).thenReturn(apiResponse); @@ -283,7 +262,7 @@ public void deleteTeam() throws Exception { } @Test - @Order(11) + @Order(10) public void deleteUser() throws Exception { ApiResponse apiResponse = ApiResponse.builder().result(ApiResultStatus.SUCCESS.value).build(); when(usersTeamsControllerService.deleteUser(anyString(), anyBoolean())).thenReturn(apiResponse); @@ -305,7 +284,7 @@ public void deleteUser() throws Exception { } @Test - @Order(12) + @Order(11) public void addNewUser() throws Exception { ApiResponse apiResponse = ApiResponse.builder().result(ApiResultStatus.SUCCESS.value).build(); UserInfoModel userInfo = utilMethods.getUserInfoMock(); @@ -328,7 +307,7 @@ public void addNewUser() throws Exception { } @Test - @Order(13) + @Order(12) public void addNewTeam() throws Exception { Team team = utilMethods.getTeams().get(0); String jsonReq = OBJECT_MAPPER.writer().writeValueAsString(team); @@ -351,7 +330,7 @@ public void addNewTeam() throws Exception { } @Test - @Order(14) + @Order(13) public void changePwd() throws Exception { ApiResponse apiResponse = ApiResponse.builder().result(ApiResultStatus.SUCCESS.value).build(); when(usersTeamsControllerService.changePwd(any())).thenReturn(apiResponse); @@ -372,7 +351,7 @@ public void changePwd() throws Exception { } @Test - @Order(15) + @Order(14) public void showUsers() throws Exception { List userList = utilMethods.getUserInfoListModel("uiuser", "ADMIN"); when(usersTeamsControllerService.showUsers(any(), any(), any())).thenReturn(userList); @@ -395,7 +374,7 @@ public void showUsers() throws Exception { } @Test - @Order(16) + @Order(15) public void getMyProfileInfo() throws Exception { UserInfoModel userInfo = utilMethods.getUserInfoMock(); when(usersTeamsControllerService.getMyProfileInfo()).thenReturn(userInfo); @@ -416,7 +395,7 @@ public void getMyProfileInfo() throws Exception { } @Test - @Order(17) + @Order(16) public void showActivityLog() throws Exception { List activityLogs = utilMethods.getLogs(); when(uiConfigControllerService.showActivityLog(anyString(), anyString(), anyString())) From 8343af9713f1a8859047e39cd5b2a1545a40d7ae Mon Sep 17 00:00:00 2001 From: muralibasani Date: Thu, 20 Oct 2022 09:20:12 +0200 Subject: [PATCH 6/6] Adding enum for kafka protocols --- .../service/EnvsClustersTenantsControllerService.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/aiven/klaw/service/EnvsClustersTenantsControllerService.java b/src/main/java/io/aiven/klaw/service/EnvsClustersTenantsControllerService.java index 95c75c79e6..22af955a88 100644 --- a/src/main/java/io/aiven/klaw/service/EnvsClustersTenantsControllerService.java +++ b/src/main/java/io/aiven/klaw/service/EnvsClustersTenantsControllerService.java @@ -1215,10 +1215,12 @@ public Map getClusterInfoFromEnv(String envSelected, String clus public List> getSupportedKafkaProtocols() { List> supportedProtocols = new ArrayList<>(); for (KafkaSupportedProtocol kafkaSupportedProtocol : KafkaSupportedProtocol.values()) { - Map protocolValues = new HashMap<>(); - protocolValues.put("name", kafkaSupportedProtocol.getName()); - protocolValues.put("value", kafkaSupportedProtocol.getValue()); - supportedProtocols.add(protocolValues); + supportedProtocols.add( + Map.of( + "name", + kafkaSupportedProtocol.getName(), + "value", + kafkaSupportedProtocol.getValue())); } return supportedProtocols;