From d91d6fd878ce9202d234d4543c5407a6b5cb9581 Mon Sep 17 00:00:00 2001 From: muralibasani Date: Wed, 3 Jan 2024 17:05:15 +0100 Subject: [PATCH 1/7] Updating activitylog on approvals Signed-off-by: muralibasani --- .../aiven/klaw/helpers/HandleDbRequests.java | 9 ++ .../db/rdbms/HandleDbRequestsJdbc.java | 13 ++ .../klaw/helpers/db/rdbms/InsertDataJdbc.java | 135 ++++++------------ .../klaw/service/AclControllerService.java | 16 +++ .../KafkaConnectControllerService.java | 9 ++ .../service/OperationalRequestsService.java | 15 ++ .../SchemaRegistryControllerService.java | 13 ++ .../klaw/service/TopicControllerService.java | 8 ++ .../service/UiConfigControllerService.java | 4 +- .../main/resources/templates/activityLog.html | 17 +-- 10 files changed, 132 insertions(+), 107 deletions(-) diff --git a/core/src/main/java/io/aiven/klaw/helpers/HandleDbRequests.java b/core/src/main/java/io/aiven/klaw/helpers/HandleDbRequests.java index 4e79b7b5d5..7ec7c86f63 100644 --- a/core/src/main/java/io/aiven/klaw/helpers/HandleDbRequests.java +++ b/core/src/main/java/io/aiven/klaw/helpers/HandleDbRequests.java @@ -57,6 +57,15 @@ public interface HandleDbRequests { String insertMetrics(KwMetrics kwMetrics); + void insertIntoActivityLog( + String requestType, + int tenantId, + String operationType, + int teamId, + String details, + String envId, + String requestor); + /*--------------------Select */ List getAllTopicsByTopicNameAndTeamIdAndTenantId( diff --git a/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/HandleDbRequestsJdbc.java b/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/HandleDbRequestsJdbc.java index 43052572ef..022d65dc4c 100644 --- a/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/HandleDbRequestsJdbc.java +++ b/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/HandleDbRequestsJdbc.java @@ -123,6 +123,19 @@ public String insertMetrics(KwMetrics kwMetrics) { return jdbcInsertHelper.insertMetrics(kwMetrics); } + @Override + public void insertIntoActivityLog( + String requestType, + int tenantId, + String operationType, + int teamId, + String details, + String envId, + String requestor) { + jdbcInsertHelper.insertIntoActivityLog( + requestType, tenantId, operationType, teamId, details, envId, requestor); + } + @Override public List getAllTopicsByTopicNameAndTeamIdAndTenantId( String topicName, int teamId, int tenantId) { diff --git a/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/InsertDataJdbc.java b/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/InsertDataJdbc.java index c0d9666829..126845d20c 100644 --- a/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/InsertDataJdbc.java +++ b/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/InsertDataJdbc.java @@ -108,24 +108,7 @@ public synchronized Map insertIntoRequestTopic(TopicRequest topi topicRequest.setRequesttime((new Timestamp(System.currentTimeMillis()))); topicRequestsRepo.save(topicRequest); - UserInfo userInfo = jdbcSelectHelper.selectUserInfo(topicRequest.getRequestor()); - - ActivityLog activityLog = new ActivityLog(); - activityLog.setReq_no(getNextActivityLogRequestId(topicRequest.getTenantId())); - activityLog.setActivityName("TopicRequest"); - activityLog.setActivityType(topicRequest.getRequestOperationType()); - activityLog.setActivityTime(new Timestamp(System.currentTimeMillis())); - activityLog.setTeamId(userInfo.getTeamId()); - activityLog.setDetails(topicRequest.getTopicname()); - activityLog.setUser(topicRequest.getRequestor()); - activityLog.setEnv(topicRequest.getEnvironment()); - activityLog.setTenantId(topicRequest.getTenantId()); - - if (ApiResultStatus.SUCCESS.value.equals(insertIntoActivityLog(activityLog))) { - hashMap.put("result", ApiResultStatus.SUCCESS.value); - } else { - hashMap.put("result", ApiResultStatus.FAILURE.value); - } + hashMap.put("result", ApiResultStatus.SUCCESS.value); return hashMap; } @@ -144,25 +127,20 @@ public synchronized Map insertIntoRequestConnector( connectorRequest.setRequesttime((new Timestamp(System.currentTimeMillis()))); kafkaConnectorRequestsRepo.save(connectorRequest); - UserInfo userInfo = jdbcSelectHelper.selectUserInfo(connectorRequest.getRequestor()); + // ActivityLog activityLog = new ActivityLog(); + // activityLog.setReq_no(getNextActivityLogRequestId(connectorRequest.getTenantId())); + // activityLog.setActivityName("ConnectorRequest"); + // activityLog.setActivityType(connectorRequest.getRequestOperationType()); + // activityLog.setActivityTime(new Timestamp(System.currentTimeMillis())); + // activityLog.setTeamId(userInfo.getTeamId()); + // activityLog.setDetails( + // connectorRequest.getConnectorName() + "," + + // connectorRequest.getRequestOperationType()); + // activityLog.setUser(connectorRequest.getRequestor()); + // activityLog.setEnv(connectorRequest.getEnvironment()); + // activityLog.setTenantId(connectorRequest.getTenantId()); - ActivityLog activityLog = new ActivityLog(); - activityLog.setReq_no(getNextActivityLogRequestId(connectorRequest.getTenantId())); - activityLog.setActivityName("ConnectorRequest"); - activityLog.setActivityType(connectorRequest.getRequestOperationType()); - activityLog.setActivityTime(new Timestamp(System.currentTimeMillis())); - activityLog.setTeamId(userInfo.getTeamId()); - activityLog.setDetails( - connectorRequest.getConnectorName() + "," + connectorRequest.getRequestOperationType()); - activityLog.setUser(connectorRequest.getRequestor()); - activityLog.setEnv(connectorRequest.getEnvironment()); - activityLog.setTenantId(connectorRequest.getTenantId()); - - if (ApiResultStatus.SUCCESS.value.equals(insertIntoActivityLog(activityLog))) { - hashMap.put("result", ApiResultStatus.SUCCESS.value); - } else { - hashMap.put("result", ApiResultStatus.FAILURE.value); - } + hashMap.put("result", ApiResultStatus.SUCCESS.value); return hashMap; } @@ -254,28 +232,6 @@ synchronized Map insertIntoRequestAcl(AclRequests aclReq) { aclReq.setRequestingteam(userInfo.getTeamId()); aclRequestsRepo.save(aclReq); - ActivityLog activityLog = new ActivityLog(); - activityLog.setReq_no(getNextActivityLogRequestId(aclReq.getTenantId())); - activityLog.setActivityName("AclRequest"); - activityLog.setActivityType(aclReq.getRequestOperationType()); - activityLog.setActivityTime(new Timestamp(System.currentTimeMillis())); - activityLog.setTeamId(userInfo.getTeamId()); - activityLog.setDetails( - aclReq.getAcl_ip() - + "-" - + aclReq.getTopicname() - + "-" - + aclReq.getAcl_ssl() - + "-" - + aclReq.getConsumergroup() - + "-" - + aclReq.getAclType()); - activityLog.setUser(aclReq.getRequestor()); - activityLog.setEnv(aclReq.getEnvironment()); - activityLog.setTenantId(aclReq.getTenantId()); - - // Insert into acl activity log - insertIntoActivityLog(activityLog); hashMap.put("result", ApiResultStatus.SUCCESS.value); return hashMap; } @@ -294,22 +250,18 @@ synchronized Map insertIntoOperationalRequests( operationalRequest.setRequesttime(new Timestamp(System.currentTimeMillis())); operationalRequestsRepo.save(operationalRequest); - UserInfo userInfo = jdbcSelectHelper.selectUserInfo(operationalRequest.getRequestor()); + // ActivityLog activityLog = new ActivityLog(); + // activityLog.setReq_no(getNextActivityLogRequestId(operationalRequest.getTenantId())); + // activityLog.setActivityName("OperationalRequest"); + // activityLog.setActivityType(operationalRequest.getOperationalRequestType().value); + // activityLog.setActivityTime(new Timestamp(System.currentTimeMillis())); + // activityLog.setTeamId(userInfo.getTeamId()); + // activityLog.setDetails( + // operationalRequest.getTopicname() + "-" + operationalRequest.getConsumerGroup()); + // activityLog.setUser(operationalRequest.getRequestor()); + // activityLog.setEnv(operationalRequest.getEnvironment()); + // activityLog.setTenantId(operationalRequest.getTenantId()); - ActivityLog activityLog = new ActivityLog(); - activityLog.setReq_no(getNextActivityLogRequestId(operationalRequest.getTenantId())); - activityLog.setActivityName("OperationalRequest"); - activityLog.setActivityType(operationalRequest.getOperationalRequestType().value); - activityLog.setActivityTime(new Timestamp(System.currentTimeMillis())); - activityLog.setTeamId(userInfo.getTeamId()); - activityLog.setDetails( - operationalRequest.getTopicname() + "-" + operationalRequest.getConsumerGroup()); - activityLog.setUser(operationalRequest.getRequestor()); - activityLog.setEnv(operationalRequest.getEnvironment()); - activityLog.setTenantId(operationalRequest.getTenantId()); - - // Insert into acl activity log - insertIntoActivityLog(activityLog); hashMap.put("result", ApiResultStatus.SUCCESS.value); return hashMap; } @@ -340,22 +292,6 @@ public synchronized String insertIntoRequestSchema(SchemaRequest schemaRequest) schemaRequestRepo.save(schemaRequest); - UserInfo userInfo = jdbcSelectHelper.selectUserInfo(schemaRequest.getRequestor()); - - ActivityLog activityLog = new ActivityLog(); - activityLog.setReq_no(getNextActivityLogRequestId(schemaRequest.getTenantId())); - activityLog.setActivityName("SchemaRequest"); - activityLog.setActivityType("new"); - activityLog.setActivityTime(new Timestamp(System.currentTimeMillis())); - activityLog.setTeamId(userInfo.getTeamId()); - activityLog.setDetails(schemaRequest.getTopicname() + "-" + schemaRequest.getRemarks()); - activityLog.setUser(schemaRequest.getRequestor()); - activityLog.setEnv(schemaRequest.getEnvironment()); - activityLog.setTenantId(schemaRequest.getTenantId()); - - // Insert into acl activity log - insertIntoActivityLog(activityLog); - return ApiResultStatus.SUCCESS.value; } @@ -626,4 +562,25 @@ public String insertProductDetails(ProductDetails productDetails) { productDetailsRepo.save(productDetails); return ApiResultStatus.SUCCESS.value; } + + public void insertIntoActivityLog( + String requestType, + int tenantId, + String operationType, + int teamId, + String details, + String envId, + String requestor) { + ActivityLog activityLog = new ActivityLog(); + activityLog.setReq_no(getNextActivityLogRequestId(tenantId)); + activityLog.setActivityName(requestType + "Request"); + activityLog.setActivityType(operationType); + activityLog.setActivityTime(new Timestamp(System.currentTimeMillis())); + activityLog.setTeamId(teamId); + activityLog.setDetails(details); + activityLog.setUser(requestor); + activityLog.setEnv(envId); + activityLog.setTenantId(tenantId); + insertIntoActivityLog(activityLog); + } } diff --git a/core/src/main/java/io/aiven/klaw/service/AclControllerService.java b/core/src/main/java/io/aiven/klaw/service/AclControllerService.java index 45dff26f56..599d3e6c77 100644 --- a/core/src/main/java/io/aiven/klaw/service/AclControllerService.java +++ b/core/src/main/java/io/aiven/klaw/service/AclControllerService.java @@ -667,6 +667,22 @@ public ApiResponse approveAclRequests(String req_no) notifyUserType = ACL_REQUEST_FAILURE; } else { saveToTopicHistory(userDetails, tenantId, aclReq); + dbHandle.insertIntoActivityLog( + RequestEntityType.ACL.value, + tenantId, + aclReq.getRequestOperationType(), + aclReq.getTeamId(), + aclReq.getAcl_ip() + + "-" + + aclReq.getTopicname() + + "-" + + aclReq.getAcl_ssl() + + "-" + + aclReq.getConsumergroup() + + "-" + + aclReq.getAclType(), + aclReq.getEnvironment(), + aclReq.getRequestor()); } return emailAndReturnClaimUpdate(aclReq, dbHandle, notifyUserType, updateAclReqStatus); diff --git a/core/src/main/java/io/aiven/klaw/service/KafkaConnectControllerService.java b/core/src/main/java/io/aiven/klaw/service/KafkaConnectControllerService.java index b58f6ef607..98b0013675 100644 --- a/core/src/main/java/io/aiven/klaw/service/KafkaConnectControllerService.java +++ b/core/src/main/java/io/aiven/klaw/service/KafkaConnectControllerService.java @@ -38,6 +38,7 @@ import io.aiven.klaw.model.enums.Order; import io.aiven.klaw.model.enums.PermissionType; import io.aiven.klaw.model.enums.PromotionStatusType; +import io.aiven.klaw.model.enums.RequestEntityType; import io.aiven.klaw.model.enums.RequestOperationType; import io.aiven.klaw.model.enums.RequestStatus; import io.aiven.klaw.model.requests.KafkaConnectorModel; @@ -711,6 +712,14 @@ public ApiResponse approveConnectorRequests(String connectorId) if (Objects.equals(updateConnectorReqStatus, ApiResultStatus.SUCCESS.value)) { setConnectorHistory(connectorRequest, userDetails, tenantId); updateConnectorReqStatus = dbHandle.updateConnectorRequest(connectorRequest, userDetails); + dbHandle.insertIntoActivityLog( + RequestEntityType.CONNECTOR.value, + tenantId, + connectorRequest.getRequestOperationType(), + connectorRequest.getTeamId(), + "Connector : " + connectorRequest.getConnectorName(), + connectorRequest.getEnvironment(), + connectorRequest.getRequestor()); mailService.sendMail( connectorRequest.getConnectorName(), null, diff --git a/core/src/main/java/io/aiven/klaw/service/OperationalRequestsService.java b/core/src/main/java/io/aiven/klaw/service/OperationalRequestsService.java index a81c6870c6..b17b04b724 100644 --- a/core/src/main/java/io/aiven/klaw/service/OperationalRequestsService.java +++ b/core/src/main/java/io/aiven/klaw/service/OperationalRequestsService.java @@ -25,6 +25,7 @@ import io.aiven.klaw.model.enums.OperationalRequestType; import io.aiven.klaw.model.enums.Order; import io.aiven.klaw.model.enums.PermissionType; +import io.aiven.klaw.model.enums.RequestEntityType; import io.aiven.klaw.model.enums.RequestStatus; import io.aiven.klaw.model.requests.ConsumerOffsetResetRequestModel; import io.aiven.klaw.model.response.EnvIdInfo; @@ -442,6 +443,20 @@ public ApiResponse approveOperationalRequests(String reqId) { dbHandle.updateOperationalChangeRequest( operationalRequest, userName, RequestStatus.APPROVED); + dbHandle.insertIntoActivityLog( + RequestEntityType.OPERATIONAL.value, + tenantId, + OperationalRequestType.RESET_CONSUMER_OFFSETS.value, + operationalRequest.getRequestingTeamId(), + "Topic : " + + operationalRequest.getTopicname() + + " ConsumerGroup : " + + operationalRequest.getConsumerGroup() + + " ResetType :" + + operationalRequest.getOffsetResetType(), + operationalRequest.getEnvironment(), + operationalRequest.getRequestor()); + mailService.sendMail( operationalRequest.getTopicname(), offsetResetDetails, diff --git a/core/src/main/java/io/aiven/klaw/service/SchemaRegistryControllerService.java b/core/src/main/java/io/aiven/klaw/service/SchemaRegistryControllerService.java index 2dfc716f27..1e5ea23a55 100644 --- a/core/src/main/java/io/aiven/klaw/service/SchemaRegistryControllerService.java +++ b/core/src/main/java/io/aiven/klaw/service/SchemaRegistryControllerService.java @@ -268,6 +268,19 @@ public ApiResponse execSchemaRequests(String avroSchemaId) throws KlawException String responseDb = dbHandle.updateSchemaRequest(schemaRequest, userDetails); if (responseDb.equals(ApiResultStatus.SUCCESS.value)) { saveToTopicHistory(userDetails, tenantId, schemaRequest); + dbHandle.insertIntoActivityLog( + RequestEntityType.SCHEMA.value, + tenantId, + schemaRequest.getRequestOperationType(), + schemaRequest.getTeamId(), + "Topic : " + + schemaRequest.getTopicname() + + " version : " + + registerSchemaCustomResponse.get("version") + + " id : " + + registerSchemaCustomResponse.get("id"), + schemaRequest.getEnvironment(), + schemaRequest.getRequestor()); } // send mail to producers and consumers diff --git a/core/src/main/java/io/aiven/klaw/service/TopicControllerService.java b/core/src/main/java/io/aiven/klaw/service/TopicControllerService.java index 846a6bf5f1..c45a67c7d1 100644 --- a/core/src/main/java/io/aiven/klaw/service/TopicControllerService.java +++ b/core/src/main/java/io/aiven/klaw/service/TopicControllerService.java @@ -761,6 +761,14 @@ public ApiResponse approveTopicRequests(String topicId) throws KlawException { } if (updateTopicReqStatus.equals(ApiResultStatus.SUCCESS.value)) { + dbHandle.insertIntoActivityLog( + RequestEntityType.TOPIC.value, + tenantId, + topicRequest.getRequestOperationType(), + topicRequest.getTeamId(), + RequestEntityType.TOPIC.value + " : " + topicRequest.getTopicname(), + topicRequest.getEnvironment(), + topicRequest.getRequestor()); commonUtilsService.updateMetadata( tenantId, EntityType.TOPICS, MetadataOperationType.CREATE, null); } diff --git a/core/src/main/java/io/aiven/klaw/service/UiConfigControllerService.java b/core/src/main/java/io/aiven/klaw/service/UiConfigControllerService.java index e481b3ab51..bfb73cc274 100644 --- a/core/src/main/java/io/aiven/klaw/service/UiConfigControllerService.java +++ b/core/src/main/java/io/aiven/klaw/service/UiConfigControllerService.java @@ -81,12 +81,12 @@ public List showActivityLog(String env, String pageNo, String curre public String getEnvName(String envId, String activityName, int tenantId) { Optional envFound; - if ("SchemaRequest".equals(activityName)) { + if ("SchemaRequest".equalsIgnoreCase(activityName)) { envFound = manageDatabase.getSchemaRegEnvList(tenantId).stream() .filter(env -> Objects.equals(env.getId(), envId)) .findFirst(); - } else if ("ConnectorRequest".equals(activityName)) { + } else if ("ConnectorRequest".equalsIgnoreCase(activityName)) { envFound = manageDatabase.getKafkaConnectEnvList(tenantId).stream() .filter(env -> Objects.equals(env.getId(), envId)) diff --git a/core/src/main/resources/templates/activityLog.html b/core/src/main/resources/templates/activityLog.html index c3eadeee4a..5c5db98f09 100644 --- a/core/src/main/resources/templates/activityLog.html +++ b/core/src/main/resources/templates/activityLog.html @@ -486,26 +486,11 @@

Shortcuts

-
+
Activity
{{ resultBrowset.activityName }}
-
-
Activity
- {{ resultBrowset.activityName }} - -
-
-
Activity
- {{ resultBrowset.activityName }} - -
-
-
Activity
- {{ resultBrowset.activityName }} - -
Environment
From 341af6f2c237c88f1a74f75b16a9fe32b941da7e Mon Sep 17 00:00:00 2001 From: muralibasani Date: Thu, 4 Jan 2024 10:01:39 +0100 Subject: [PATCH 2/7] Update tests, model Signed-off-by: muralibasani --- .../klaw/controller/UiConfigController.java | 4 +- .../io/aiven/klaw/model/ActivityLogModel.java | 31 +- .../service/UiConfigControllerService.java | 20 +- .../resources/static/js/showActivityLog.js | 8 +- .../test/java/io/aiven/klaw/UtilMethods.java | 8 + .../controller/UiConfigControllerTest.java | 4 +- .../service/AclControllerServiceTest.java | 1 + .../SchemaRegistryControllerServiceTest.java | 1 + openapi.yaml | 635 +----------------- 9 files changed, 88 insertions(+), 624 deletions(-) diff --git a/core/src/main/java/io/aiven/klaw/controller/UiConfigController.java b/core/src/main/java/io/aiven/klaw/controller/UiConfigController.java index c8c846c869..3a3906d954 100644 --- a/core/src/main/java/io/aiven/klaw/controller/UiConfigController.java +++ b/core/src/main/java/io/aiven/klaw/controller/UiConfigController.java @@ -1,6 +1,6 @@ package io.aiven.klaw.controller; -import io.aiven.klaw.dao.ActivityLog; +import io.aiven.klaw.model.ActivityLogModel; import io.aiven.klaw.model.ApiResponse; import io.aiven.klaw.model.response.DbAuthInfo; import io.aiven.klaw.service.UiConfigControllerService; @@ -50,7 +50,7 @@ public ResponseEntity sendMessageToAdmin( value = "/getActivityLogPerEnv", method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE}) - public ResponseEntity> showActivityLog( + public ResponseEntity> showActivityLog( @RequestParam(value = "env", defaultValue = "") String env, @RequestParam("pageNo") String pageNo, @RequestParam(value = "currentPage", defaultValue = "") String currentPage) { diff --git a/core/src/main/java/io/aiven/klaw/model/ActivityLogModel.java b/core/src/main/java/io/aiven/klaw/model/ActivityLogModel.java index c087baab7e..8f0b421099 100644 --- a/core/src/main/java/io/aiven/klaw/model/ActivityLogModel.java +++ b/core/src/main/java/io/aiven/klaw/model/ActivityLogModel.java @@ -1,5 +1,6 @@ package io.aiven.klaw.model; +import jakarta.validation.constraints.NotNull; import java.io.Serializable; import java.sql.Timestamp; import java.util.List; @@ -12,25 +13,33 @@ @ToString public class ActivityLogModel implements Serializable { - private Integer req_no; + @NotNull private Integer req_no; - private String activityName; + @NotNull private String activityName; - private String activityType; + @NotNull private String activityType; - private Timestamp activityTime; + @NotNull private Timestamp activityTime; - private String activityTimeString; + @NotNull private String activityTimeString; - private String details; + @NotNull private String details; - private String user; + @NotNull private String user; - private String team; + @NotNull private String team; - private String env; + @NotNull private Integer teamId; - private String totalNoPages; + @NotNull private String env; - private List allPageNos; + @NotNull private int tenantId; + + @NotNull private String envName; + + @NotNull private String totalNoPages; + + @NotNull private List allPageNos; + + @NotNull private String currentPage; } diff --git a/core/src/main/java/io/aiven/klaw/service/UiConfigControllerService.java b/core/src/main/java/io/aiven/klaw/service/UiConfigControllerService.java index bfb73cc274..5aa39b578d 100644 --- a/core/src/main/java/io/aiven/klaw/service/UiConfigControllerService.java +++ b/core/src/main/java/io/aiven/klaw/service/UiConfigControllerService.java @@ -1,11 +1,13 @@ package io.aiven.klaw.service; import static io.aiven.klaw.model.enums.AuthenticationType.DATABASE; +import static org.springframework.beans.BeanUtils.copyProperties; import io.aiven.klaw.config.ManageDatabase; import io.aiven.klaw.dao.ActivityLog; import io.aiven.klaw.dao.Env; import io.aiven.klaw.helpers.Pager; +import io.aiven.klaw.model.ActivityLogModel; import io.aiven.klaw.model.ApiResponse; import io.aiven.klaw.model.enums.PermissionType; import io.aiven.klaw.model.response.DbAuthInfo; @@ -43,7 +45,7 @@ private String getUserName() { return mailService.getUserName(getPrincipal()); } - public List showActivityLog(String env, String pageNo, String currentPage) { + public List showActivityLog(String env, String pageNo, String currentPage) { log.debug("showActivityLog {} {}", env, pageNo); String userName = getUserName(); List origActivityList; @@ -66,15 +68,17 @@ public List showActivityLog(String env, String pageNo, String curre currentPage, origActivityList, (pageContext, activityLog) -> { - activityLog.setEnvName( + ActivityLogModel activityLogModel = new ActivityLogModel(); + copyProperties(activityLog, activityLogModel); + activityLogModel.setEnvName( getEnvName(activityLog.getEnv(), activityLog.getActivityName(), tenantId)); - activityLog.setDetails(activityLog.getDetails().replaceAll("null", "")); - activityLog.setAllPageNos(pageContext.getAllPageNos()); - activityLog.setTotalNoPages(pageContext.getTotalPages()); - activityLog.setCurrentPage(pageContext.getPageNo()); - activityLog.setTeam( + activityLogModel.setDetails(activityLog.getDetails().replaceAll("null", "")); + activityLogModel.setAllPageNos(pageContext.getAllPageNos()); + activityLogModel.setTotalNoPages(pageContext.getTotalPages()); + activityLogModel.setCurrentPage(pageContext.getPageNo()); + activityLogModel.setTeam( manageDatabase.getTeamNameFromTeamId(tenantId, activityLog.getTeamId())); - return activityLog; + return activityLogModel; }); } diff --git a/core/src/main/resources/static/js/showActivityLog.js b/core/src/main/resources/static/js/showActivityLog.js index 211398381b..4bd0039c19 100644 --- a/core/src/main/resources/static/js/showActivityLog.js +++ b/core/src/main/resources/static/js/showActivityLog.js @@ -213,9 +213,11 @@ app.controller("showActivityLogCtrl", function($scope, $http, $location, $window $scope.getActivityLog = function(pageNoSelected) { var serviceInput = {}; - - if($scope.resultPageSelected && $scope.resultPageSelected == pageNoSelected) - return; + if($scope.resultPageSelected && $scope.resultPageSelected === pageNoSelected){ + if(!$scope.getActivityLog.envId){ + return; + } + } //serviceInput['clusterType'] = $scope.getTopics.clusterType.value; serviceInput['env'] = $scope.getActivityLog.envId; diff --git a/core/src/test/java/io/aiven/klaw/UtilMethods.java b/core/src/test/java/io/aiven/klaw/UtilMethods.java index 20aeb38849..26ea18aa05 100644 --- a/core/src/test/java/io/aiven/klaw/UtilMethods.java +++ b/core/src/test/java/io/aiven/klaw/UtilMethods.java @@ -187,6 +187,14 @@ public List getLogs() { return activityLogs; } + public List getLogModels() { + List activityLogs = new ArrayList<>(); + ActivityLogModel activityLog = new ActivityLogModel(); + activityLog.setActivityTime(new Timestamp(System.currentTimeMillis())); + activityLogs.add(activityLog); + return activityLogs; + } + public Topic getTopic(String topicName) { Topic topic = new Topic(); topic.setTeamId(3); diff --git a/core/src/test/java/io/aiven/klaw/controller/UiConfigControllerTest.java b/core/src/test/java/io/aiven/klaw/controller/UiConfigControllerTest.java index ebfad368cb..c62ca91e5e 100644 --- a/core/src/test/java/io/aiven/klaw/controller/UiConfigControllerTest.java +++ b/core/src/test/java/io/aiven/klaw/controller/UiConfigControllerTest.java @@ -9,8 +9,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import io.aiven.klaw.UtilMethods; -import io.aiven.klaw.dao.ActivityLog; import io.aiven.klaw.dao.Team; +import io.aiven.klaw.model.ActivityLogModel; import io.aiven.klaw.model.ApiResponse; import io.aiven.klaw.model.enums.ApiResultStatus; import io.aiven.klaw.model.enums.KafkaClustersType; @@ -391,7 +391,7 @@ public void getMyProfileInfo() throws Exception { @Test @Order(20) public void showActivityLog() throws Exception { - List activityLogs = utilMethods.getLogs(); + List activityLogs = utilMethods.getLogModels(); when(uiConfigControllerService.showActivityLog(anyString(), anyString(), anyString())) .thenReturn(activityLogs); diff --git a/core/src/test/java/io/aiven/klaw/service/AclControllerServiceTest.java b/core/src/test/java/io/aiven/klaw/service/AclControllerServiceTest.java index 33b269ba2e..b06e7658cd 100644 --- a/core/src/test/java/io/aiven/klaw/service/AclControllerServiceTest.java +++ b/core/src/test/java/io/aiven/klaw/service/AclControllerServiceTest.java @@ -1101,6 +1101,7 @@ private AclRequests getAclRequestDao() { aclReq.setReq_no(112); aclReq.setEnvironment("1"); aclReq.setRequestor("kwuserb"); + aclReq.setTeamId(1001); aclReq.setRequestStatus(RequestStatus.CREATED.value); aclReq.setAcl_ip("1.2.3.4"); aclReq.setAclIpPrincipleType(AclIPPrincipleType.IP_ADDRESS); diff --git a/core/src/test/java/io/aiven/klaw/service/SchemaRegistryControllerServiceTest.java b/core/src/test/java/io/aiven/klaw/service/SchemaRegistryControllerServiceTest.java index f4e1ca506d..6c8ae48c5c 100644 --- a/core/src/test/java/io/aiven/klaw/service/SchemaRegistryControllerServiceTest.java +++ b/core/src/test/java/io/aiven/klaw/service/SchemaRegistryControllerServiceTest.java @@ -212,6 +212,7 @@ public void execSchemaRequestsSuccess() throws KlawException { schemaRequest.setRequestor("kwuserb"); schemaRequest.setEnvironment("1"); schemaRequest.setTopicname("topic"); + schemaRequest.setTeamId(1001); stubUserInfo(); when(handleDbRequests.getSchemaRequest(anyInt(), anyInt())).thenReturn(schemaRequest); diff --git a/openapi.yaml b/openapi.yaml index f441c384a1..c2a87c34dd 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -813,7 +813,6 @@ "content" : { "application/json" : { "schema" : { - "type" : "array", "items" : { "$ref" : "#/components/schemas/ApiResponse" } @@ -826,7 +825,6 @@ "content" : { "application/json" : { "schema" : { - "type" : "array", "items" : { "$ref" : "#/components/schemas/ApiResponse" } @@ -839,7 +837,6 @@ "content" : { "application/json" : { "schema" : { - "type" : "array", "items" : { "$ref" : "#/components/schemas/ApiResponse" } @@ -852,7 +849,6 @@ "content" : { "application/json" : { "schema" : { - "type" : "array", "items" : { "$ref" : "#/components/schemas/ApiResponse" } @@ -885,7 +881,6 @@ "content" : { "application/json" : { "schema" : { - "type" : "array", "items" : { "$ref" : "#/components/schemas/ApiResponse" } @@ -898,7 +893,6 @@ "content" : { "application/json" : { "schema" : { - "type" : "array", "items" : { "$ref" : "#/components/schemas/ApiResponse" } @@ -911,7 +905,6 @@ "content" : { "application/json" : { "schema" : { - "type" : "array", "items" : { "$ref" : "#/components/schemas/ApiResponse" } @@ -924,7 +917,6 @@ "content" : { "application/json" : { "schema" : { - "type" : "array", "items" : { "$ref" : "#/components/schemas/ApiResponse" } @@ -957,7 +949,6 @@ "content" : { "application/json" : { "schema" : { - "type" : "array", "items" : { "$ref" : "#/components/schemas/ApiResponse" } @@ -970,7 +961,6 @@ "content" : { "application/json" : { "schema" : { - "type" : "array", "items" : { "$ref" : "#/components/schemas/ApiResponse" } @@ -983,7 +973,6 @@ "content" : { "application/json" : { "schema" : { - "type" : "array", "items" : { "$ref" : "#/components/schemas/ApiResponse" } @@ -996,7 +985,6 @@ "content" : { "application/json" : { "schema" : { - "type" : "array", "items" : { "$ref" : "#/components/schemas/ApiResponse" } @@ -5268,7 +5256,7 @@ "schema" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/ActivityLog" + "$ref" : "#/components/schemas/ActivityLogModel" } } } @@ -5938,9 +5926,7 @@ "debugMessage" : { "type" : "string" }, - "data" : { - "type" : "object" - }, + "data" : { }, "timestamp" : { "type" : "string", "format" : "date-time" @@ -6001,16 +5987,6 @@ }, "required" : [ "fullname", "role", "switchTeams", "teamId", "userPassword", "username" ] }, - "TopicConfigEntry" : { - "properties" : { - "configKey" : { - "type" : "string" - }, - "configValue" : { - "type" : "string" - } - } - }, "TopicUpdateRequestModel" : { "properties" : { "requestOperationType" : { @@ -6196,9 +6172,7 @@ }, "topicDetails" : { "type" : "array", - "items" : { - "type" : "object" - } + "items" : { } }, "topicSearchFilter" : { "type" : "string" @@ -6857,142 +6831,6 @@ }, "required" : [ "connectorName", "env" ] }, - "AclApproval" : { - "properties" : { - "approvalId" : { - "type" : "integer", - "format" : "int32" - }, - "approvalType" : { - "type" : "string", - "enum" : [ "RESOURCE_TEAM_OWNER", "ACL_TEAM_OWNER", "TEAM" ] - }, - "requiredApprover" : { - "type" : "string" - }, - "approverName" : { - "type" : "string" - }, - "approverTeamId" : { - "type" : "integer", - "format" : "int32" - }, - "approverTeamName" : { - "type" : "string" - }, - "parent" : { - "$ref" : "#/components/schemas/AclRequests" - } - } - }, - "AclRequests" : { - "properties" : { - "req_no" : { - "type" : "integer", - "format" : "int32" - }, - "tenantId" : { - "type" : "integer", - "format" : "int32" - }, - "topicname" : { - "type" : "string" - }, - "environment" : { - "type" : "string" - }, - "environmentName" : { - "type" : "string" - }, - "teamId" : { - "type" : "integer", - "format" : "int32" - }, - "requestingteam" : { - "type" : "integer", - "format" : "int32" - }, - "appname" : { - "type" : "string" - }, - "aclType" : { - "type" : "string" - }, - "consumergroup" : { - "type" : "string" - }, - "requestor" : { - "type" : "string" - }, - "requesttime" : { - "type" : "string", - "format" : "date-time" - }, - "requesttimestring" : { - "type" : "string" - }, - "requestStatus" : { - "type" : "string" - }, - "remarks" : { - "type" : "string" - }, - "acl_ip" : { - "type" : "string" - }, - "acl_ssl" : { - "type" : "string" - }, - "approver" : { - "type" : "string" - }, - "approvingtime" : { - "type" : "string", - "format" : "date-time" - }, - "requestOperationType" : { - "type" : "string" - }, - "aclPatternType" : { - "type" : "string" - }, - "aclResourceType" : { - "type" : "string" - }, - "transactionalId" : { - "type" : "string" - }, - "otherParams" : { - "type" : "string" - }, - "jsonParams" : { - "type" : "object", - "additionalProperties" : { - "type" : "string" - } - }, - "aclIpPrincipleType" : { - "type" : "string", - "enum" : [ "IP_ADDRESS", "PRINCIPAL", "USERNAME" ] - }, - "associatedAclId" : { - "type" : "integer", - "format" : "int32" - }, - "totalNoPages" : { - "type" : "string" - }, - "currentPage" : { - "type" : "string" - }, - "allPageNos" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - } - }, "AclRequestsModel" : { "properties" : { "requestOperationType" : { @@ -7026,15 +6864,13 @@ "acl_ip" : { "type" : "array", "items" : { - "type" : "string", - "pattern" : "^$|^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\\.(?!$)|$)){4}$" + "type" : "string" } }, "acl_ssl" : { "type" : "array", "items" : { - "type" : "string", - "pattern" : "^$|^[a-zA-Z 0-9_.,=-]{3,}$" + "type" : "string" } }, "aclPatternType" : { @@ -7522,53 +7358,6 @@ }, "required" : [ "fullname", "mailid", "role", "switchTeams", "team", "teamId", "tenantId", "username" ] }, - "SchemaSubjectInfoResponse" : { - "properties" : { - "topic" : { - "type" : "string" - }, - "schemaVersions" : { - "type" : "array", - "items" : { - "type" : "integer", - "format" : "int32" - }, - "uniqueItems" : true - }, - "teamname" : { - "type" : "string" - }, - "teamId" : { - "type" : "integer", - "format" : "int32" - }, - "possibleTeams" : { - "type" : "array", - "items" : { - "type" : "string" - } - }, - "remarks" : { - "type" : "string" - }, - "envId" : { - "type" : "string" - }, - "currentPage" : { - "type" : "string" - }, - "totalNoPages" : { - "type" : "string" - }, - "allPageNos" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - }, - "required" : [ "allPageNos", "currentPage", "totalNoPages" ] - }, "SyncSchemasList" : { "properties" : { "schemaSubjectInfoResponseList" : { @@ -7688,40 +7477,6 @@ }, "required" : [ "allPageNos", "approvingTeamDetails", "currentPage", "environment", "environmentName", "forceRegister", "req_no", "requestOperationType", "requestStatus", "requestor", "requesttime", "requesttimestring", "schemafull", "teamId", "teamname", "topicname", "totalNoPages" ] }, - "RequestEntityStatusCount" : { - "properties" : { - "requestEntityType" : { - "type" : "string", - "enum" : [ "TOPIC", "ACL", "SCHEMA", "CONNECTOR", "OPERATIONAL", "USER" ] - }, - "requestStatusCountSet" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/RequestStatusCount" - }, - "uniqueItems" : true - }, - "requestsOperationTypeCountSet" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/RequestsOperationTypeCount" - }, - "uniqueItems" : true - } - } - }, - "RequestStatusCount" : { - "properties" : { - "requestStatus" : { - "type" : "string", - "enum" : [ "CREATED", "DELETED", "DECLINED", "APPROVED", "ALL" ] - }, - "count" : { - "type" : "integer", - "format" : "int64" - } - } - }, "RequestsCountOverview" : { "properties" : { "requestEntityStatistics" : { @@ -7733,18 +7488,6 @@ } } }, - "RequestsOperationTypeCount" : { - "properties" : { - "requestOperationType" : { - "type" : "string", - "enum" : [ "CREATE", "UPDATE", "PROMOTE", "CLAIM", "DELETE", "ALL" ] - }, - "count" : { - "type" : "integer", - "format" : "int64" - } - } - }, "OperationalRequestsResponseModel" : { "properties" : { "topicname" : { @@ -7944,128 +7687,36 @@ }, "required" : [ "status" ] }, - "AclOverviewInfo" : { + "PromotionStatus" : { "properties" : { - "req_no" : { - "type" : "string" + "status" : { + "type" : "string", + "enum" : [ "SUCCESS", "NOT_AUTHORIZED", "REQUEST_OPEN", "NO_PROMOTION", "FAILURE" ] }, - "aclPatternType" : { + "sourceEnv" : { "type" : "string" }, - "environment" : { + "targetEnv" : { "type" : "string" }, - "environmentName" : { + "targetEnvId" : { "type" : "string" }, - "kafkaFlavorType" : { - "type" : "string", - "enum" : [ "APACHE_KAFKA", "AIVEN_FOR_APACHE_KAFKA", "CONFLUENT", "CONFLUENT_CLOUD", "OTHERS" ] + "error" : { + "type" : "string" }, - "showDeleteAcl" : { + "topicName" : { + "type" : "string" + } + }, + "required" : [ "status" ] + }, + "TopicOverview" : { + "properties" : { + "topicExists" : { "type" : "boolean" }, - "showClaimAcl" : { - "type" : "boolean" - }, - "teamid" : { - "type" : "integer", - "format" : "int32" - }, - "teamname" : { - "type" : "string" - }, - "topicname" : { - "type" : "string" - }, - "topictype" : { - "type" : "string" - }, - "acl_ip" : { - "type" : "string" - }, - "acl_ssl" : { - "type" : "string" - }, - "acl_ips" : { - "type" : "array", - "items" : { - "type" : "string" - }, - "uniqueItems" : true - }, - "acl_ssls" : { - "type" : "array", - "items" : { - "type" : "string" - }, - "uniqueItems" : true - }, - "consumergroup" : { - "type" : "string" - }, - "transactionalId" : { - "type" : "string" - } - }, - "required" : [ "aclPatternType", "environment", "environmentName", "kafkaFlavorType", "req_no", "showClaimAcl", "showDeleteAcl", "teamid", "teamname", "topicname", "topictype" ] - }, - "PromotionStatus" : { - "properties" : { - "status" : { - "type" : "string", - "enum" : [ "SUCCESS", "NOT_AUTHORIZED", "REQUEST_OPEN", "NO_PROMOTION", "FAILURE" ] - }, - "sourceEnv" : { - "type" : "string" - }, - "targetEnv" : { - "type" : "string" - }, - "targetEnvId" : { - "type" : "string" - }, - "error" : { - "type" : "string" - }, - "topicName" : { - "type" : "string" - } - }, - "required" : [ "status" ] - }, - "ResourceHistory" : { - "properties" : { - "environmentName" : { - "type" : "string" - }, - "teamName" : { - "type" : "string" - }, - "requestedBy" : { - "type" : "string" - }, - "requestedTime" : { - "type" : "string" - }, - "approvedBy" : { - "type" : "string" - }, - "approvedTime" : { - "type" : "string" - }, - "remarks" : { - "type" : "string" - } - }, - "required" : [ "approvedBy", "approvedTime", "environmentName", "remarks", "requestedBy", "requestedTime", "teamName" ] - }, - "TopicOverview" : { - "properties" : { - "topicExists" : { - "type" : "boolean" - }, - "schemaExists" : { + "schemaExists" : { "type" : "boolean" }, "prefixAclsExists" : { @@ -8126,86 +7777,6 @@ }, "required" : [ "availableEnvironments", "createSchemaAllowed", "prefixAclsExists", "schemaExists", "topicExists", "topicIdForDocumentation", "topicInfoList", "topicPromotionDetails", "txnAclsExists" ] }, - "TopicOverviewInfo" : { - "properties" : { - "topicName" : { - "type" : "string" - }, - "noOfPartitions" : { - "type" : "integer", - "format" : "int32" - }, - "noOfReplicas" : { - "type" : "string" - }, - "description" : { - "type" : "string" - }, - "advancedTopicConfiguration" : { - "type" : "object", - "additionalProperties" : { - "type" : "string" - } - }, - "teamname" : { - "type" : "string" - }, - "teamId" : { - "type" : "integer", - "format" : "int32" - }, - "envId" : { - "type" : "string" - }, - "envName" : { - "type" : "string" - }, - "showEditTopic" : { - "type" : "boolean" - }, - "showDeleteTopic" : { - "type" : "boolean" - }, - "topicDeletable" : { - "type" : "boolean" - }, - "topicOwner" : { - "type" : "boolean" - }, - "highestEnv" : { - "type" : "boolean" - }, - "hasOpenRequest" : { - "type" : "boolean" - }, - "hasOpenTopicRequest" : { - "type" : "boolean" - }, - "hasOpenACLRequest" : { - "type" : "boolean" - }, - "hasOpenSchemaRequest" : { - "type" : "boolean" - }, - "hasOpenClaimRequest" : { - "type" : "boolean" - }, - "hasOpenRequestOnAnyEnv" : { - "type" : "boolean" - }, - "hasACL" : { - "type" : "boolean" - }, - "hasSchema" : { - "type" : "boolean" - }, - "clusterId" : { - "type" : "integer", - "format" : "int32" - } - }, - "required" : [ "clusterId", "description", "envId", "envName", "hasACL", "hasOpenACLRequest", "hasOpenClaimRequest", "hasOpenRequest", "hasOpenRequestOnAnyEnv", "hasOpenSchemaRequest", "hasOpenTopicRequest", "hasSchema", "highestEnv", "noOfPartitions", "noOfReplicas", "showDeleteTopic", "showEditTopic", "teamId", "teamname", "topicDeletable", "topicName", "topicOwner" ] - }, "TopicBaseConfig" : { "properties" : { "topicName" : { @@ -8387,22 +7958,6 @@ } } }, - "YAx" : { - "properties" : { - "id" : { - "type" : "string" - }, - "type" : { - "type" : "string" - }, - "display" : { - "type" : "boolean" - }, - "position" : { - "type" : "string" - } - } - }, "SyncTopicsList" : { "properties" : { "resultSet" : { @@ -8424,123 +7979,6 @@ } } }, - "TopicSyncResponseModel" : { - "properties" : { - "environment" : { - "type" : "string" - }, - "environmentName" : { - "type" : "string" - }, - "requestor" : { - "type" : "string" - }, - "teamId" : { - "type" : "integer", - "format" : "int32" - }, - "teamname" : { - "type" : "string" - }, - "requestOperationType" : { - "type" : "string", - "enum" : [ "CREATE", "UPDATE", "PROMOTE", "CLAIM", "DELETE", "ALL" ] - }, - "requestStatus" : { - "type" : "string", - "enum" : [ "CREATED", "DELETED", "DECLINED", "APPROVED", "ALL" ] - }, - "requesttime" : { - "type" : "string", - "format" : "date-time" - }, - "requesttimestring" : { - "type" : "string" - }, - "currentPage" : { - "type" : "string" - }, - "totalNoPages" : { - "type" : "string" - }, - "allPageNos" : { - "type" : "array", - "items" : { - "type" : "string" - } - }, - "approvingTeamDetails" : { - "type" : "string" - }, - "approver" : { - "type" : "string" - }, - "approvingtime" : { - "type" : "string", - "format" : "date-time" - }, - "remarks" : { - "type" : "string" - }, - "appname" : { - "type" : "string" - }, - "otherParams" : { - "type" : "string" - }, - "topicname" : { - "type" : "string" - }, - "topicpartitions" : { - "type" : "integer", - "format" : "int32" - }, - "replicationfactor" : { - "type" : "string" - }, - "description" : { - "type" : "string" - }, - "topicid" : { - "type" : "integer", - "format" : "int32" - }, - "deleteAssociatedSchema" : { - "type" : "boolean" - }, - "advancedTopicConfigEntries" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/TopicConfigEntry" - } - }, - "approvingTeamId" : { - "type" : "string" - }, - "sequence" : { - "type" : "string" - }, - "possibleTeams" : { - "type" : "array", - "items" : { - "type" : "string" - } - }, - "validationStatus" : { - "type" : "string" - }, - "validatedTopic" : { - "type" : "boolean" - }, - "deletable" : { - "type" : "boolean" - }, - "editable" : { - "type" : "boolean" - } - }, - "required" : [ "advancedTopicConfigEntries", "allPageNos", "approvingTeamDetails", "currentPage", "deleteAssociatedSchema", "description", "environment", "environmentName", "replicationfactor", "requestOperationType", "requestStatus", "requestor", "requesttime", "requesttimestring", "teamId", "teamname", "topicid", "topicname", "topicpartitions", "totalNoPages" ] - }, "KafkaConnectorModelResponse" : { "properties" : { "sequence" : { @@ -9403,16 +8841,12 @@ } } }, - "ActivityLog" : { + "ActivityLogModel" : { "properties" : { "req_no" : { "type" : "integer", "format" : "int32" }, - "tenantId" : { - "type" : "integer", - "format" : "int32" - }, "activityName" : { "type" : "string" }, @@ -9432,6 +8866,9 @@ "user" : { "type" : "string" }, + "team" : { + "type" : "string" + }, "teamId" : { "type" : "integer", "format" : "int32" @@ -9439,25 +8876,27 @@ "env" : { "type" : "string" }, - "envName" : { - "type" : "string" + "tenantId" : { + "type" : "integer", + "format" : "int32" }, - "team" : { + "envName" : { "type" : "string" }, "totalNoPages" : { "type" : "string" }, - "currentPage" : { - "type" : "string" - }, "allPageNos" : { "type" : "array", "items" : { "type" : "string" } + }, + "currentPage" : { + "type" : "string" } - } + }, + "required" : [ "activityName", "activityTime", "activityTimeString", "activityType", "allPageNos", "currentPage", "details", "env", "envName", "req_no", "team", "teamId", "tenantId", "totalNoPages", "user" ] }, "AclsCountPerEnv" : { "properties" : { From 572dc55be63d596ce41604bab6bb54c73bd52c74 Mon Sep 17 00:00:00 2001 From: muralibasani Date: Thu, 4 Jan 2024 10:03:15 +0100 Subject: [PATCH 3/7] Update ts Signed-off-by: muralibasani --- coral/types/api.d.ts | 260 ++++++------------------------------------- 1 file changed, 32 insertions(+), 228 deletions(-) diff --git a/coral/types/api.d.ts b/coral/types/api.d.ts index e555a2b1e3..96da90ab1a 100644 --- a/coral/types/api.d.ts +++ b/coral/types/api.d.ts @@ -556,7 +556,7 @@ export type components = { errCode?: string; message: string; debugMessage?: string; - data?: Record; + data?: unknown; /** Format: date-time */ timestamp?: string; }; @@ -574,10 +574,6 @@ export type components = { /** Format: int32 */ tenantId?: number; }; - TopicConfigEntry: { - configKey?: string; - configValue?: string; - }; TopicUpdateRequestModel: { /** @enum {string} */ requestOperationType: "CREATE" | "UPDATE" | "PROMOTE" | "CLAIM" | "DELETE" | "ALL"; @@ -639,7 +635,7 @@ export type components = { sourceEnv?: string; selectedTeam?: string; typeOfSync?: string; - topicDetails?: Record[]; + topicDetails?: unknown[]; topicSearchFilter?: string; }; SyncConnectorUpdates: { @@ -871,60 +867,6 @@ export type components = { connectorName: string; env: string; }; - AclApproval: { - /** Format: int32 */ - approvalId?: number; - /** @enum {string} */ - approvalType?: "TOPIC_TEAM_OWNER" | "CONNECTOR_TEAM_OWNER" | "ACL_TEAM_OWNER" | "TEAM"; - requiredApprover?: string; - approverName?: string; - /** Format: int32 */ - approverTeamId?: number; - approverTeamName?: string; - parent?: components["schemas"]["AclRequests"]; - }; - AclRequests: { - /** Format: int32 */ - req_no?: number; - /** Format: int32 */ - tenantId?: number; - topicname?: string; - environment?: string; - environmentName?: string; - /** Format: int32 */ - teamId?: number; - /** Format: int32 */ - requestingteam?: number; - appname?: string; - aclType?: string; - consumergroup?: string; - requestor?: string; - /** Format: date-time */ - requesttime?: string; - requesttimestring?: string; - requestStatus?: string; - remarks?: string; - acl_ip?: string; - acl_ssl?: string; - approver?: string; - /** Format: date-time */ - approvingtime?: string; - requestOperationType?: string; - aclPatternType?: string; - aclResourceType?: string; - transactionalId?: string; - otherParams?: string; - jsonParams?: { - [key: string]: string; - }; - /** @enum {string} */ - aclIpPrincipleType?: "IP_ADDRESS" | "PRINCIPAL" | "USERNAME"; - /** Format: int32 */ - associatedAclId?: number; - totalNoPages?: string; - currentPage?: string; - allPageNos?: string[]; - }; AclRequestsModel: { /** @enum {string} */ requestOperationType: "CREATE" | "UPDATE" | "PROMOTE" | "CLAIM" | "DELETE" | "ALL"; @@ -1102,19 +1044,6 @@ export type components = { totalNoPages?: string; allPageNos?: string[]; }; - SchemaSubjectInfoResponse: { - topic?: string; - schemaVersions?: number[]; - teamname?: string; - /** Format: int32 */ - teamId?: number; - possibleTeams?: string[]; - remarks?: string; - envId?: string; - currentPage: string; - totalNoPages: string; - allPageNos: string[]; - }; SyncSchemasList: { schemaSubjectInfoResponseList?: components["schemas"]["SchemaSubjectInfoResponse"][]; /** Format: int32 */ @@ -1159,27 +1088,9 @@ export type components = { deletable?: boolean; editable?: boolean; }; - RequestEntityStatusCount: { - /** @enum {string} */ - requestEntityType?: "TOPIC" | "ACL" | "SCHEMA" | "CONNECTOR" | "OPERATIONAL" | "USER"; - requestStatusCountSet?: components["schemas"]["RequestStatusCount"][]; - requestsOperationTypeCountSet?: components["schemas"]["RequestsOperationTypeCount"][]; - }; - RequestStatusCount: { - /** @enum {string} */ - requestStatus?: "CREATED" | "DELETED" | "DECLINED" | "APPROVED" | "ALL"; - /** Format: int64 */ - count?: number; - }; RequestsCountOverview: { requestEntityStatistics?: components["schemas"]["RequestEntityStatusCount"][]; }; - RequestsOperationTypeCount: { - /** @enum {string} */ - requestOperationType?: "CREATE" | "UPDATE" | "PROMOTE" | "CLAIM" | "DELETE" | "ALL"; - /** Format: int64 */ - count?: number; - }; OperationalRequestsResponseModel: { topicname: string; consumerGroup: string; @@ -1255,27 +1166,6 @@ export type components = { error?: string; status: boolean; }; - AclOverviewInfo: { - req_no: string; - aclPatternType: string; - environment: string; - environmentName: string; - /** @enum {string} */ - kafkaFlavorType: "APACHE_KAFKA" | "AIVEN_FOR_APACHE_KAFKA" | "CONFLUENT" | "CONFLUENT_CLOUD" | "OTHERS"; - showDeleteAcl: boolean; - showClaimAcl: boolean; - /** Format: int32 */ - teamid: number; - teamname: string; - topicname: string; - topictype: string; - acl_ip?: string; - acl_ssl?: string; - acl_ips?: string[]; - acl_ssls?: string[]; - consumergroup?: string; - transactionalId?: string; - }; PromotionStatus: { /** @enum {string} */ status: "SUCCESS" | "NOT_AUTHORIZED" | "REQUEST_OPEN" | "NO_PROMOTION" | "FAILURE"; @@ -1285,15 +1175,6 @@ export type components = { error?: string; topicName?: string; }; - ResourceHistory: { - environmentName: string; - teamName: string; - requestedBy: string; - requestedTime: string; - approvedBy: string; - approvedTime: string; - remarks: string; - }; TopicOverview: { topicExists: boolean; schemaExists: boolean; @@ -1311,36 +1192,6 @@ export type components = { /** Format: int32 */ topicIdForDocumentation: number; }; - TopicOverviewInfo: { - topicName: string; - /** Format: int32 */ - noOfPartitions: number; - noOfReplicas: string; - description: string; - advancedTopicConfiguration?: { - [key: string]: string; - }; - teamname: string; - /** Format: int32 */ - teamId: number; - envId: string; - envName: string; - showEditTopic: boolean; - showDeleteTopic: boolean; - topicDeletable: boolean; - topicOwner: boolean; - highestEnv: boolean; - hasOpenRequest: boolean; - hasOpenTopicRequest: boolean; - hasOpenACLRequest: boolean; - hasOpenSchemaRequest: boolean; - hasOpenClaimRequest: boolean; - hasOpenRequestOnAnyEnv: boolean; - hasACL: boolean; - hasSchema: boolean; - /** Format: int32 */ - clusterId: number; - }; TopicBaseConfig: { topicName: string; /** Format: int32 */ @@ -1404,12 +1255,6 @@ export type components = { fontFamily?: string; fontStyle?: string; }; - YAx: { - id?: string; - type?: string; - display?: boolean; - position?: string; - }; SyncTopicsList: { resultSet?: components["schemas"]["TopicSyncResponseModel"][]; /** Format: int32 */ @@ -1418,47 +1263,6 @@ export type components = { allTopicWarningsCount?: number; topicsLoadingStatus?: boolean; }; - TopicSyncResponseModel: { - environment: string; - environmentName: string; - requestor: string; - /** Format: int32 */ - teamId: number; - teamname: string; - /** @enum {string} */ - requestOperationType: "CREATE" | "UPDATE" | "PROMOTE" | "CLAIM" | "DELETE" | "ALL"; - /** @enum {string} */ - requestStatus: "CREATED" | "DELETED" | "DECLINED" | "APPROVED" | "ALL"; - /** Format: date-time */ - requesttime: string; - requesttimestring: string; - currentPage: string; - totalNoPages: string; - allPageNos: string[]; - approvingTeamDetails: string; - approver?: string; - /** Format: date-time */ - approvingtime?: string; - remarks?: string; - appname?: string; - otherParams?: string; - topicname: string; - /** Format: int32 */ - topicpartitions: number; - replicationfactor: string; - description: string; - /** Format: int32 */ - topicid: number; - deleteAssociatedSchema: boolean; - advancedTopicConfigEntries: components["schemas"]["TopicConfigEntry"][]; - approvingTeamId?: string; - sequence?: string; - possibleTeams?: string[]; - validationStatus?: string; - validatedTopic?: boolean; - deletable?: boolean; - editable?: boolean; - }; KafkaConnectorModelResponse: { /** Format: int32 */ sequence?: number; @@ -1762,26 +1566,26 @@ export type components = { password?: string; accountFound?: boolean; }; - ActivityLog: { - /** Format: int32 */ - req_no?: number; + ActivityLogModel: { /** Format: int32 */ - tenantId?: number; - activityName?: string; - activityType?: string; + req_no: number; + activityName: string; + activityType: string; /** Format: date-time */ - activityTime?: string; - activityTimeString?: string; - details?: string; - user?: string; + activityTime: string; + activityTimeString: string; + details: string; + user: string; + team: string; /** Format: int32 */ - teamId?: number; - env?: string; - envName?: string; - team?: string; - totalNoPages?: string; - currentPage?: string; - allPageNos?: string[]; + teamId: number; + env: string; + /** Format: int32 */ + tenantId: number; + envName: string; + totalNoPages: string; + allPageNos: string[]; + currentPage: string; }; AclsCountPerEnv: { status?: string; @@ -2248,25 +2052,25 @@ export type operations = { /** @description OK */ 200: { content: { - "application/json": components["schemas"]["ApiResponse"][]; + "application/json": unknown; }; }; /** @description Multi Status */ 207: { content: { - "application/json": components["schemas"]["ApiResponse"][]; + "application/json": unknown; }; }; /** @description Bad Request */ 405: { content: { - "application/json": components["schemas"]["ApiResponse"][]; + "application/json": unknown; }; }; /** @description Internal Server Error */ 500: { content: { - "application/json": components["schemas"]["ApiResponse"][]; + "application/json": unknown; }; }; }; @@ -2285,25 +2089,25 @@ export type operations = { /** @description OK */ 200: { content: { - "application/json": components["schemas"]["ApiResponse"][]; + "application/json": unknown; }; }; /** @description Multi Status */ 207: { content: { - "application/json": components["schemas"]["ApiResponse"][]; + "application/json": unknown; }; }; /** @description Bad Request */ 405: { content: { - "application/json": components["schemas"]["ApiResponse"][]; + "application/json": unknown; }; }; /** @description Internal Server Error */ 500: { content: { - "application/json": components["schemas"]["ApiResponse"][]; + "application/json": unknown; }; }; }; @@ -2322,25 +2126,25 @@ export type operations = { /** @description OK */ 200: { content: { - "application/json": components["schemas"]["ApiResponse"][]; + "application/json": unknown; }; }; /** @description Multi Status */ 207: { content: { - "application/json": components["schemas"]["ApiResponse"][]; + "application/json": unknown; }; }; /** @description Bad Request */ 405: { content: { - "application/json": components["schemas"]["ApiResponse"][]; + "application/json": unknown; }; }; /** @description Internal Server Error */ 500: { content: { - "application/json": components["schemas"]["ApiResponse"][]; + "application/json": unknown; }; }; }; @@ -4247,7 +4051,7 @@ export type operations = { /** @description OK */ 200: { content: { - "application/json": components["schemas"]["ActivityLog"][]; + "application/json": components["schemas"]["ActivityLogModel"][]; }; }; }; From 1445b61ecc47f22c7a52ec9a3848d3f8d23a429c Mon Sep 17 00:00:00 2001 From: muralibasani Date: Thu, 4 Jan 2024 10:09:42 +0100 Subject: [PATCH 4/7] remove commented code Signed-off-by: muralibasani --- .../klaw/helpers/db/rdbms/InsertDataJdbc.java | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/InsertDataJdbc.java b/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/InsertDataJdbc.java index 126845d20c..d2b648caeb 100644 --- a/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/InsertDataJdbc.java +++ b/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/InsertDataJdbc.java @@ -127,19 +127,6 @@ public synchronized Map insertIntoRequestConnector( connectorRequest.setRequesttime((new Timestamp(System.currentTimeMillis()))); kafkaConnectorRequestsRepo.save(connectorRequest); - // ActivityLog activityLog = new ActivityLog(); - // activityLog.setReq_no(getNextActivityLogRequestId(connectorRequest.getTenantId())); - // activityLog.setActivityName("ConnectorRequest"); - // activityLog.setActivityType(connectorRequest.getRequestOperationType()); - // activityLog.setActivityTime(new Timestamp(System.currentTimeMillis())); - // activityLog.setTeamId(userInfo.getTeamId()); - // activityLog.setDetails( - // connectorRequest.getConnectorName() + "," + - // connectorRequest.getRequestOperationType()); - // activityLog.setUser(connectorRequest.getRequestor()); - // activityLog.setEnv(connectorRequest.getEnvironment()); - // activityLog.setTenantId(connectorRequest.getTenantId()); - hashMap.put("result", ApiResultStatus.SUCCESS.value); return hashMap; @@ -250,18 +237,6 @@ synchronized Map insertIntoOperationalRequests( operationalRequest.setRequesttime(new Timestamp(System.currentTimeMillis())); operationalRequestsRepo.save(operationalRequest); - // ActivityLog activityLog = new ActivityLog(); - // activityLog.setReq_no(getNextActivityLogRequestId(operationalRequest.getTenantId())); - // activityLog.setActivityName("OperationalRequest"); - // activityLog.setActivityType(operationalRequest.getOperationalRequestType().value); - // activityLog.setActivityTime(new Timestamp(System.currentTimeMillis())); - // activityLog.setTeamId(userInfo.getTeamId()); - // activityLog.setDetails( - // operationalRequest.getTopicname() + "-" + operationalRequest.getConsumerGroup()); - // activityLog.setUser(operationalRequest.getRequestor()); - // activityLog.setEnv(operationalRequest.getEnvironment()); - // activityLog.setTenantId(operationalRequest.getTenantId()); - hashMap.put("result", ApiResultStatus.SUCCESS.value); return hashMap; } From 97ab499a9dbd7f9bd64c3ff60841896866cb7120 Mon Sep 17 00:00:00 2001 From: muralibasani Date: Thu, 4 Jan 2024 11:13:00 +0100 Subject: [PATCH 5/7] Revert openapi upgrade Signed-off-by: muralibasani --- core/pom.xml | 2 +- openapi.yaml | 570 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 567 insertions(+), 5 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index dec91c4c9b..699dc22014 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -36,7 +36,7 @@ 5.10.0 1.33 1.4 - 2.3.0 + 2.2.0 120 diff --git a/openapi.yaml b/openapi.yaml index c2a87c34dd..68814752ad 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -813,6 +813,7 @@ "content" : { "application/json" : { "schema" : { + "type" : "array", "items" : { "$ref" : "#/components/schemas/ApiResponse" } @@ -825,6 +826,7 @@ "content" : { "application/json" : { "schema" : { + "type" : "array", "items" : { "$ref" : "#/components/schemas/ApiResponse" } @@ -837,6 +839,7 @@ "content" : { "application/json" : { "schema" : { + "type" : "array", "items" : { "$ref" : "#/components/schemas/ApiResponse" } @@ -849,6 +852,7 @@ "content" : { "application/json" : { "schema" : { + "type" : "array", "items" : { "$ref" : "#/components/schemas/ApiResponse" } @@ -881,6 +885,7 @@ "content" : { "application/json" : { "schema" : { + "type" : "array", "items" : { "$ref" : "#/components/schemas/ApiResponse" } @@ -893,6 +898,7 @@ "content" : { "application/json" : { "schema" : { + "type" : "array", "items" : { "$ref" : "#/components/schemas/ApiResponse" } @@ -905,6 +911,7 @@ "content" : { "application/json" : { "schema" : { + "type" : "array", "items" : { "$ref" : "#/components/schemas/ApiResponse" } @@ -917,6 +924,7 @@ "content" : { "application/json" : { "schema" : { + "type" : "array", "items" : { "$ref" : "#/components/schemas/ApiResponse" } @@ -949,6 +957,7 @@ "content" : { "application/json" : { "schema" : { + "type" : "array", "items" : { "$ref" : "#/components/schemas/ApiResponse" } @@ -961,6 +970,7 @@ "content" : { "application/json" : { "schema" : { + "type" : "array", "items" : { "$ref" : "#/components/schemas/ApiResponse" } @@ -973,6 +983,7 @@ "content" : { "application/json" : { "schema" : { + "type" : "array", "items" : { "$ref" : "#/components/schemas/ApiResponse" } @@ -985,6 +996,7 @@ "content" : { "application/json" : { "schema" : { + "type" : "array", "items" : { "$ref" : "#/components/schemas/ApiResponse" } @@ -5926,7 +5938,9 @@ "debugMessage" : { "type" : "string" }, - "data" : { }, + "data" : { + "type" : "object" + }, "timestamp" : { "type" : "string", "format" : "date-time" @@ -5987,6 +6001,16 @@ }, "required" : [ "fullname", "role", "switchTeams", "teamId", "userPassword", "username" ] }, + "TopicConfigEntry" : { + "properties" : { + "configKey" : { + "type" : "string" + }, + "configValue" : { + "type" : "string" + } + } + }, "TopicUpdateRequestModel" : { "properties" : { "requestOperationType" : { @@ -6172,7 +6196,9 @@ }, "topicDetails" : { "type" : "array", - "items" : { } + "items" : { + "type" : "object" + } }, "topicSearchFilter" : { "type" : "string" @@ -6831,6 +6857,142 @@ }, "required" : [ "connectorName", "env" ] }, + "AclApproval" : { + "properties" : { + "approvalId" : { + "type" : "integer", + "format" : "int32" + }, + "approvalType" : { + "type" : "string", + "enum" : [ "TOPIC_TEAM_OWNER", "CONNECTOR_TEAM_OWNER", "ACL_TEAM_OWNER", "TEAM" ] + }, + "requiredApprover" : { + "type" : "string" + }, + "approverName" : { + "type" : "string" + }, + "approverTeamId" : { + "type" : "integer", + "format" : "int32" + }, + "approverTeamName" : { + "type" : "string" + }, + "parent" : { + "$ref" : "#/components/schemas/AclRequests" + } + } + }, + "AclRequests" : { + "properties" : { + "req_no" : { + "type" : "integer", + "format" : "int32" + }, + "tenantId" : { + "type" : "integer", + "format" : "int32" + }, + "topicname" : { + "type" : "string" + }, + "environment" : { + "type" : "string" + }, + "environmentName" : { + "type" : "string" + }, + "teamId" : { + "type" : "integer", + "format" : "int32" + }, + "requestingteam" : { + "type" : "integer", + "format" : "int32" + }, + "appname" : { + "type" : "string" + }, + "aclType" : { + "type" : "string" + }, + "consumergroup" : { + "type" : "string" + }, + "requestor" : { + "type" : "string" + }, + "requesttime" : { + "type" : "string", + "format" : "date-time" + }, + "requesttimestring" : { + "type" : "string" + }, + "requestStatus" : { + "type" : "string" + }, + "remarks" : { + "type" : "string" + }, + "acl_ip" : { + "type" : "string" + }, + "acl_ssl" : { + "type" : "string" + }, + "approver" : { + "type" : "string" + }, + "approvingtime" : { + "type" : "string", + "format" : "date-time" + }, + "requestOperationType" : { + "type" : "string" + }, + "aclPatternType" : { + "type" : "string" + }, + "aclResourceType" : { + "type" : "string" + }, + "transactionalId" : { + "type" : "string" + }, + "otherParams" : { + "type" : "string" + }, + "jsonParams" : { + "type" : "object", + "additionalProperties" : { + "type" : "string" + } + }, + "aclIpPrincipleType" : { + "type" : "string", + "enum" : [ "IP_ADDRESS", "PRINCIPAL", "USERNAME" ] + }, + "associatedAclId" : { + "type" : "integer", + "format" : "int32" + }, + "totalNoPages" : { + "type" : "string" + }, + "currentPage" : { + "type" : "string" + }, + "allPageNos" : { + "type" : "array", + "items" : { + "type" : "string" + } + } + } + }, "AclRequestsModel" : { "properties" : { "requestOperationType" : { @@ -6864,13 +7026,15 @@ "acl_ip" : { "type" : "array", "items" : { - "type" : "string" + "type" : "string", + "pattern" : "^$|^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\\.(?!$)|$)){4}$" } }, "acl_ssl" : { "type" : "array", "items" : { - "type" : "string" + "type" : "string", + "pattern" : "^$|^[a-zA-Z 0-9_.,=-]{3,}$" } }, "aclPatternType" : { @@ -7358,6 +7522,53 @@ }, "required" : [ "fullname", "mailid", "role", "switchTeams", "team", "teamId", "tenantId", "username" ] }, + "SchemaSubjectInfoResponse" : { + "properties" : { + "topic" : { + "type" : "string" + }, + "schemaVersions" : { + "type" : "array", + "items" : { + "type" : "integer", + "format" : "int32" + }, + "uniqueItems" : true + }, + "teamname" : { + "type" : "string" + }, + "teamId" : { + "type" : "integer", + "format" : "int32" + }, + "possibleTeams" : { + "type" : "array", + "items" : { + "type" : "string" + } + }, + "remarks" : { + "type" : "string" + }, + "envId" : { + "type" : "string" + }, + "currentPage" : { + "type" : "string" + }, + "totalNoPages" : { + "type" : "string" + }, + "allPageNos" : { + "type" : "array", + "items" : { + "type" : "string" + } + } + }, + "required" : [ "allPageNos", "currentPage", "totalNoPages" ] + }, "SyncSchemasList" : { "properties" : { "schemaSubjectInfoResponseList" : { @@ -7477,6 +7688,40 @@ }, "required" : [ "allPageNos", "approvingTeamDetails", "currentPage", "environment", "environmentName", "forceRegister", "req_no", "requestOperationType", "requestStatus", "requestor", "requesttime", "requesttimestring", "schemafull", "teamId", "teamname", "topicname", "totalNoPages" ] }, + "RequestEntityStatusCount" : { + "properties" : { + "requestEntityType" : { + "type" : "string", + "enum" : [ "TOPIC", "ACL", "SCHEMA", "CONNECTOR", "OPERATIONAL", "USER" ] + }, + "requestStatusCountSet" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/RequestStatusCount" + }, + "uniqueItems" : true + }, + "requestsOperationTypeCountSet" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/RequestsOperationTypeCount" + }, + "uniqueItems" : true + } + } + }, + "RequestStatusCount" : { + "properties" : { + "requestStatus" : { + "type" : "string", + "enum" : [ "CREATED", "DELETED", "DECLINED", "APPROVED", "ALL" ] + }, + "count" : { + "type" : "integer", + "format" : "int64" + } + } + }, "RequestsCountOverview" : { "properties" : { "requestEntityStatistics" : { @@ -7488,6 +7733,18 @@ } } }, + "RequestsOperationTypeCount" : { + "properties" : { + "requestOperationType" : { + "type" : "string", + "enum" : [ "CREATE", "UPDATE", "PROMOTE", "CLAIM", "DELETE", "ALL" ] + }, + "count" : { + "type" : "integer", + "format" : "int64" + } + } + }, "OperationalRequestsResponseModel" : { "properties" : { "topicname" : { @@ -7687,6 +7944,72 @@ }, "required" : [ "status" ] }, + "AclOverviewInfo" : { + "properties" : { + "req_no" : { + "type" : "string" + }, + "aclPatternType" : { + "type" : "string" + }, + "environment" : { + "type" : "string" + }, + "environmentName" : { + "type" : "string" + }, + "kafkaFlavorType" : { + "type" : "string", + "enum" : [ "APACHE_KAFKA", "AIVEN_FOR_APACHE_KAFKA", "CONFLUENT", "CONFLUENT_CLOUD", "OTHERS" ] + }, + "showDeleteAcl" : { + "type" : "boolean" + }, + "showClaimAcl" : { + "type" : "boolean" + }, + "teamid" : { + "type" : "integer", + "format" : "int32" + }, + "teamname" : { + "type" : "string" + }, + "topicname" : { + "type" : "string" + }, + "topictype" : { + "type" : "string" + }, + "acl_ip" : { + "type" : "string" + }, + "acl_ssl" : { + "type" : "string" + }, + "acl_ips" : { + "type" : "array", + "items" : { + "type" : "string" + }, + "uniqueItems" : true + }, + "acl_ssls" : { + "type" : "array", + "items" : { + "type" : "string" + }, + "uniqueItems" : true + }, + "consumergroup" : { + "type" : "string" + }, + "transactionalId" : { + "type" : "string" + } + }, + "required" : [ "aclPatternType", "environment", "environmentName", "kafkaFlavorType", "req_no", "showClaimAcl", "showDeleteAcl", "teamid", "teamname", "topicname", "topictype" ] + }, "PromotionStatus" : { "properties" : { "status" : { @@ -7711,6 +8034,32 @@ }, "required" : [ "status" ] }, + "ResourceHistory" : { + "properties" : { + "environmentName" : { + "type" : "string" + }, + "teamName" : { + "type" : "string" + }, + "requestedBy" : { + "type" : "string" + }, + "requestedTime" : { + "type" : "string" + }, + "approvedBy" : { + "type" : "string" + }, + "approvedTime" : { + "type" : "string" + }, + "remarks" : { + "type" : "string" + } + }, + "required" : [ "approvedBy", "approvedTime", "environmentName", "remarks", "requestedBy", "requestedTime", "teamName" ] + }, "TopicOverview" : { "properties" : { "topicExists" : { @@ -7777,6 +8126,86 @@ }, "required" : [ "availableEnvironments", "createSchemaAllowed", "prefixAclsExists", "schemaExists", "topicExists", "topicIdForDocumentation", "topicInfoList", "topicPromotionDetails", "txnAclsExists" ] }, + "TopicOverviewInfo" : { + "properties" : { + "topicName" : { + "type" : "string" + }, + "noOfPartitions" : { + "type" : "integer", + "format" : "int32" + }, + "noOfReplicas" : { + "type" : "string" + }, + "description" : { + "type" : "string" + }, + "advancedTopicConfiguration" : { + "type" : "object", + "additionalProperties" : { + "type" : "string" + } + }, + "teamname" : { + "type" : "string" + }, + "teamId" : { + "type" : "integer", + "format" : "int32" + }, + "envId" : { + "type" : "string" + }, + "envName" : { + "type" : "string" + }, + "showEditTopic" : { + "type" : "boolean" + }, + "showDeleteTopic" : { + "type" : "boolean" + }, + "topicDeletable" : { + "type" : "boolean" + }, + "topicOwner" : { + "type" : "boolean" + }, + "highestEnv" : { + "type" : "boolean" + }, + "hasOpenRequest" : { + "type" : "boolean" + }, + "hasOpenTopicRequest" : { + "type" : "boolean" + }, + "hasOpenACLRequest" : { + "type" : "boolean" + }, + "hasOpenSchemaRequest" : { + "type" : "boolean" + }, + "hasOpenClaimRequest" : { + "type" : "boolean" + }, + "hasOpenRequestOnAnyEnv" : { + "type" : "boolean" + }, + "hasACL" : { + "type" : "boolean" + }, + "hasSchema" : { + "type" : "boolean" + }, + "clusterId" : { + "type" : "integer", + "format" : "int32" + } + }, + "required" : [ "clusterId", "description", "envId", "envName", "hasACL", "hasOpenACLRequest", "hasOpenClaimRequest", "hasOpenRequest", "hasOpenRequestOnAnyEnv", "hasOpenSchemaRequest", "hasOpenTopicRequest", "hasSchema", "highestEnv", "noOfPartitions", "noOfReplicas", "showDeleteTopic", "showEditTopic", "teamId", "teamname", "topicDeletable", "topicName", "topicOwner" ] + }, "TopicBaseConfig" : { "properties" : { "topicName" : { @@ -7958,6 +8387,22 @@ } } }, + "YAx" : { + "properties" : { + "id" : { + "type" : "string" + }, + "type" : { + "type" : "string" + }, + "display" : { + "type" : "boolean" + }, + "position" : { + "type" : "string" + } + } + }, "SyncTopicsList" : { "properties" : { "resultSet" : { @@ -7979,6 +8424,123 @@ } } }, + "TopicSyncResponseModel" : { + "properties" : { + "environment" : { + "type" : "string" + }, + "environmentName" : { + "type" : "string" + }, + "requestor" : { + "type" : "string" + }, + "teamId" : { + "type" : "integer", + "format" : "int32" + }, + "teamname" : { + "type" : "string" + }, + "requestOperationType" : { + "type" : "string", + "enum" : [ "CREATE", "UPDATE", "PROMOTE", "CLAIM", "DELETE", "ALL" ] + }, + "requestStatus" : { + "type" : "string", + "enum" : [ "CREATED", "DELETED", "DECLINED", "APPROVED", "ALL" ] + }, + "requesttime" : { + "type" : "string", + "format" : "date-time" + }, + "requesttimestring" : { + "type" : "string" + }, + "currentPage" : { + "type" : "string" + }, + "totalNoPages" : { + "type" : "string" + }, + "allPageNos" : { + "type" : "array", + "items" : { + "type" : "string" + } + }, + "approvingTeamDetails" : { + "type" : "string" + }, + "approver" : { + "type" : "string" + }, + "approvingtime" : { + "type" : "string", + "format" : "date-time" + }, + "remarks" : { + "type" : "string" + }, + "appname" : { + "type" : "string" + }, + "otherParams" : { + "type" : "string" + }, + "topicname" : { + "type" : "string" + }, + "topicpartitions" : { + "type" : "integer", + "format" : "int32" + }, + "replicationfactor" : { + "type" : "string" + }, + "description" : { + "type" : "string" + }, + "topicid" : { + "type" : "integer", + "format" : "int32" + }, + "deleteAssociatedSchema" : { + "type" : "boolean" + }, + "advancedTopicConfigEntries" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/TopicConfigEntry" + } + }, + "approvingTeamId" : { + "type" : "string" + }, + "sequence" : { + "type" : "string" + }, + "possibleTeams" : { + "type" : "array", + "items" : { + "type" : "string" + } + }, + "validationStatus" : { + "type" : "string" + }, + "validatedTopic" : { + "type" : "boolean" + }, + "deletable" : { + "type" : "boolean" + }, + "editable" : { + "type" : "boolean" + } + }, + "required" : [ "advancedTopicConfigEntries", "allPageNos", "approvingTeamDetails", "currentPage", "deleteAssociatedSchema", "description", "environment", "environmentName", "replicationfactor", "requestOperationType", "requestStatus", "requestor", "requesttime", "requesttimestring", "teamId", "teamname", "topicid", "topicname", "topicpartitions", "totalNoPages" ] + }, "KafkaConnectorModelResponse" : { "properties" : { "sequence" : { From 2475d8f46bde9d62c527b19c78eeae721c3d824e Mon Sep 17 00:00:00 2001 From: muralibasani Date: Thu, 4 Jan 2024 11:20:37 +0100 Subject: [PATCH 6/7] Update ts Signed-off-by: muralibasani --- coral/types/api.d.ts | 224 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 210 insertions(+), 14 deletions(-) diff --git a/coral/types/api.d.ts b/coral/types/api.d.ts index 96da90ab1a..55fac5f576 100644 --- a/coral/types/api.d.ts +++ b/coral/types/api.d.ts @@ -556,7 +556,7 @@ export type components = { errCode?: string; message: string; debugMessage?: string; - data?: unknown; + data?: Record; /** Format: date-time */ timestamp?: string; }; @@ -574,6 +574,10 @@ export type components = { /** Format: int32 */ tenantId?: number; }; + TopicConfigEntry: { + configKey?: string; + configValue?: string; + }; TopicUpdateRequestModel: { /** @enum {string} */ requestOperationType: "CREATE" | "UPDATE" | "PROMOTE" | "CLAIM" | "DELETE" | "ALL"; @@ -635,7 +639,7 @@ export type components = { sourceEnv?: string; selectedTeam?: string; typeOfSync?: string; - topicDetails?: unknown[]; + topicDetails?: Record[]; topicSearchFilter?: string; }; SyncConnectorUpdates: { @@ -867,6 +871,60 @@ export type components = { connectorName: string; env: string; }; + AclApproval: { + /** Format: int32 */ + approvalId?: number; + /** @enum {string} */ + approvalType?: "TOPIC_TEAM_OWNER" | "CONNECTOR_TEAM_OWNER" | "ACL_TEAM_OWNER" | "TEAM"; + requiredApprover?: string; + approverName?: string; + /** Format: int32 */ + approverTeamId?: number; + approverTeamName?: string; + parent?: components["schemas"]["AclRequests"]; + }; + AclRequests: { + /** Format: int32 */ + req_no?: number; + /** Format: int32 */ + tenantId?: number; + topicname?: string; + environment?: string; + environmentName?: string; + /** Format: int32 */ + teamId?: number; + /** Format: int32 */ + requestingteam?: number; + appname?: string; + aclType?: string; + consumergroup?: string; + requestor?: string; + /** Format: date-time */ + requesttime?: string; + requesttimestring?: string; + requestStatus?: string; + remarks?: string; + acl_ip?: string; + acl_ssl?: string; + approver?: string; + /** Format: date-time */ + approvingtime?: string; + requestOperationType?: string; + aclPatternType?: string; + aclResourceType?: string; + transactionalId?: string; + otherParams?: string; + jsonParams?: { + [key: string]: string; + }; + /** @enum {string} */ + aclIpPrincipleType?: "IP_ADDRESS" | "PRINCIPAL" | "USERNAME"; + /** Format: int32 */ + associatedAclId?: number; + totalNoPages?: string; + currentPage?: string; + allPageNos?: string[]; + }; AclRequestsModel: { /** @enum {string} */ requestOperationType: "CREATE" | "UPDATE" | "PROMOTE" | "CLAIM" | "DELETE" | "ALL"; @@ -1044,6 +1102,19 @@ export type components = { totalNoPages?: string; allPageNos?: string[]; }; + SchemaSubjectInfoResponse: { + topic?: string; + schemaVersions?: number[]; + teamname?: string; + /** Format: int32 */ + teamId?: number; + possibleTeams?: string[]; + remarks?: string; + envId?: string; + currentPage: string; + totalNoPages: string; + allPageNos: string[]; + }; SyncSchemasList: { schemaSubjectInfoResponseList?: components["schemas"]["SchemaSubjectInfoResponse"][]; /** Format: int32 */ @@ -1088,9 +1159,27 @@ export type components = { deletable?: boolean; editable?: boolean; }; + RequestEntityStatusCount: { + /** @enum {string} */ + requestEntityType?: "TOPIC" | "ACL" | "SCHEMA" | "CONNECTOR" | "OPERATIONAL" | "USER"; + requestStatusCountSet?: components["schemas"]["RequestStatusCount"][]; + requestsOperationTypeCountSet?: components["schemas"]["RequestsOperationTypeCount"][]; + }; + RequestStatusCount: { + /** @enum {string} */ + requestStatus?: "CREATED" | "DELETED" | "DECLINED" | "APPROVED" | "ALL"; + /** Format: int64 */ + count?: number; + }; RequestsCountOverview: { requestEntityStatistics?: components["schemas"]["RequestEntityStatusCount"][]; }; + RequestsOperationTypeCount: { + /** @enum {string} */ + requestOperationType?: "CREATE" | "UPDATE" | "PROMOTE" | "CLAIM" | "DELETE" | "ALL"; + /** Format: int64 */ + count?: number; + }; OperationalRequestsResponseModel: { topicname: string; consumerGroup: string; @@ -1166,6 +1255,27 @@ export type components = { error?: string; status: boolean; }; + AclOverviewInfo: { + req_no: string; + aclPatternType: string; + environment: string; + environmentName: string; + /** @enum {string} */ + kafkaFlavorType: "APACHE_KAFKA" | "AIVEN_FOR_APACHE_KAFKA" | "CONFLUENT" | "CONFLUENT_CLOUD" | "OTHERS"; + showDeleteAcl: boolean; + showClaimAcl: boolean; + /** Format: int32 */ + teamid: number; + teamname: string; + topicname: string; + topictype: string; + acl_ip?: string; + acl_ssl?: string; + acl_ips?: string[]; + acl_ssls?: string[]; + consumergroup?: string; + transactionalId?: string; + }; PromotionStatus: { /** @enum {string} */ status: "SUCCESS" | "NOT_AUTHORIZED" | "REQUEST_OPEN" | "NO_PROMOTION" | "FAILURE"; @@ -1175,6 +1285,15 @@ export type components = { error?: string; topicName?: string; }; + ResourceHistory: { + environmentName: string; + teamName: string; + requestedBy: string; + requestedTime: string; + approvedBy: string; + approvedTime: string; + remarks: string; + }; TopicOverview: { topicExists: boolean; schemaExists: boolean; @@ -1192,6 +1311,36 @@ export type components = { /** Format: int32 */ topicIdForDocumentation: number; }; + TopicOverviewInfo: { + topicName: string; + /** Format: int32 */ + noOfPartitions: number; + noOfReplicas: string; + description: string; + advancedTopicConfiguration?: { + [key: string]: string; + }; + teamname: string; + /** Format: int32 */ + teamId: number; + envId: string; + envName: string; + showEditTopic: boolean; + showDeleteTopic: boolean; + topicDeletable: boolean; + topicOwner: boolean; + highestEnv: boolean; + hasOpenRequest: boolean; + hasOpenTopicRequest: boolean; + hasOpenACLRequest: boolean; + hasOpenSchemaRequest: boolean; + hasOpenClaimRequest: boolean; + hasOpenRequestOnAnyEnv: boolean; + hasACL: boolean; + hasSchema: boolean; + /** Format: int32 */ + clusterId: number; + }; TopicBaseConfig: { topicName: string; /** Format: int32 */ @@ -1255,6 +1404,12 @@ export type components = { fontFamily?: string; fontStyle?: string; }; + YAx: { + id?: string; + type?: string; + display?: boolean; + position?: string; + }; SyncTopicsList: { resultSet?: components["schemas"]["TopicSyncResponseModel"][]; /** Format: int32 */ @@ -1263,6 +1418,47 @@ export type components = { allTopicWarningsCount?: number; topicsLoadingStatus?: boolean; }; + TopicSyncResponseModel: { + environment: string; + environmentName: string; + requestor: string; + /** Format: int32 */ + teamId: number; + teamname: string; + /** @enum {string} */ + requestOperationType: "CREATE" | "UPDATE" | "PROMOTE" | "CLAIM" | "DELETE" | "ALL"; + /** @enum {string} */ + requestStatus: "CREATED" | "DELETED" | "DECLINED" | "APPROVED" | "ALL"; + /** Format: date-time */ + requesttime: string; + requesttimestring: string; + currentPage: string; + totalNoPages: string; + allPageNos: string[]; + approvingTeamDetails: string; + approver?: string; + /** Format: date-time */ + approvingtime?: string; + remarks?: string; + appname?: string; + otherParams?: string; + topicname: string; + /** Format: int32 */ + topicpartitions: number; + replicationfactor: string; + description: string; + /** Format: int32 */ + topicid: number; + deleteAssociatedSchema: boolean; + advancedTopicConfigEntries: components["schemas"]["TopicConfigEntry"][]; + approvingTeamId?: string; + sequence?: string; + possibleTeams?: string[]; + validationStatus?: string; + validatedTopic?: boolean; + deletable?: boolean; + editable?: boolean; + }; KafkaConnectorModelResponse: { /** Format: int32 */ sequence?: number; @@ -2052,25 +2248,25 @@ export type operations = { /** @description OK */ 200: { content: { - "application/json": unknown; + "application/json": components["schemas"]["ApiResponse"][]; }; }; /** @description Multi Status */ 207: { content: { - "application/json": unknown; + "application/json": components["schemas"]["ApiResponse"][]; }; }; /** @description Bad Request */ 405: { content: { - "application/json": unknown; + "application/json": components["schemas"]["ApiResponse"][]; }; }; /** @description Internal Server Error */ 500: { content: { - "application/json": unknown; + "application/json": components["schemas"]["ApiResponse"][]; }; }; }; @@ -2089,25 +2285,25 @@ export type operations = { /** @description OK */ 200: { content: { - "application/json": unknown; + "application/json": components["schemas"]["ApiResponse"][]; }; }; /** @description Multi Status */ 207: { content: { - "application/json": unknown; + "application/json": components["schemas"]["ApiResponse"][]; }; }; /** @description Bad Request */ 405: { content: { - "application/json": unknown; + "application/json": components["schemas"]["ApiResponse"][]; }; }; /** @description Internal Server Error */ 500: { content: { - "application/json": unknown; + "application/json": components["schemas"]["ApiResponse"][]; }; }; }; @@ -2126,25 +2322,25 @@ export type operations = { /** @description OK */ 200: { content: { - "application/json": unknown; + "application/json": components["schemas"]["ApiResponse"][]; }; }; /** @description Multi Status */ 207: { content: { - "application/json": unknown; + "application/json": components["schemas"]["ApiResponse"][]; }; }; /** @description Bad Request */ 405: { content: { - "application/json": unknown; + "application/json": components["schemas"]["ApiResponse"][]; }; }; /** @description Internal Server Error */ 500: { content: { - "application/json": unknown; + "application/json": components["schemas"]["ApiResponse"][]; }; }; }; From 21cd7d6f8525ca3b40b5ef3cd6731ec56c8e523f Mon Sep 17 00:00:00 2001 From: muralibasani Date: Thu, 4 Jan 2024 13:51:25 +0100 Subject: [PATCH 7/7] Review and add test Signed-off-by: muralibasani --- .../klaw/helpers/db/rdbms/InsertDataJdbc.java | 2 +- .../klaw/service/AclControllerService.java | 36 +++++++++--------- .../KafkaConnectControllerService.java | 26 ++++++++----- .../SchemaRegistryControllerService.java | 38 ++++++++++++------- .../klaw/service/TopicControllerService.java | 23 ++++++----- .../service/UiConfigControllerService.java | 6 ++- .../io/aiven/klaw/TopicAclControllerIT.java | 18 +++++++++ 7 files changed, 97 insertions(+), 52 deletions(-) diff --git a/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/InsertDataJdbc.java b/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/InsertDataJdbc.java index d2b648caeb..c972253900 100644 --- a/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/InsertDataJdbc.java +++ b/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/InsertDataJdbc.java @@ -548,7 +548,7 @@ public void insertIntoActivityLog( String requestor) { ActivityLog activityLog = new ActivityLog(); activityLog.setReq_no(getNextActivityLogRequestId(tenantId)); - activityLog.setActivityName(requestType + "Request"); + activityLog.setActivityName(requestType + " Request"); activityLog.setActivityType(operationType); activityLog.setActivityTime(new Timestamp(System.currentTimeMillis())); activityLog.setTeamId(teamId); diff --git a/core/src/main/java/io/aiven/klaw/service/AclControllerService.java b/core/src/main/java/io/aiven/klaw/service/AclControllerService.java index 599d3e6c77..68ac90aad7 100644 --- a/core/src/main/java/io/aiven/klaw/service/AclControllerService.java +++ b/core/src/main/java/io/aiven/klaw/service/AclControllerService.java @@ -666,28 +666,30 @@ public ApiResponse approveAclRequests(String req_no) if (!updateAclReqStatus.equals(ApiResultStatus.SUCCESS.value)) { notifyUserType = ACL_REQUEST_FAILURE; } else { - saveToTopicHistory(userDetails, tenantId, aclReq); - dbHandle.insertIntoActivityLog( - RequestEntityType.ACL.value, - tenantId, - aclReq.getRequestOperationType(), - aclReq.getTeamId(), - aclReq.getAcl_ip() - + "-" - + aclReq.getTopicname() - + "-" - + aclReq.getAcl_ssl() - + "-" - + aclReq.getConsumergroup() - + "-" - + aclReq.getAclType(), - aclReq.getEnvironment(), - aclReq.getRequestor()); + updateAuditAndHistory(userDetails, tenantId, dbHandle, aclReq); } return emailAndReturnClaimUpdate(aclReq, dbHandle, notifyUserType, updateAclReqStatus); } + private void updateAuditAndHistory( + String userDetails, int tenantId, HandleDbRequests dbHandle, AclRequests aclReq) { + saveToTopicHistory(userDetails, tenantId, aclReq); + dbHandle.insertIntoActivityLog( + RequestEntityType.ACL.value, + tenantId, + aclReq.getRequestOperationType(), + aclReq.getTeamId(), + aclReq.getTopicname() + + "-" + + aclReq.getAclType() + + (aclReq.getAcl_ip() != null ? aclReq.getAcl_ip() + "-" : "") + + (aclReq.getAcl_ssl() != null ? aclReq.getAcl_ssl() + "-" : "") + + (aclReq.getConsumergroup() != null ? aclReq.getConsumergroup() : ""), + aclReq.getEnvironment(), + aclReq.getRequestor()); + } + private ApiResponse approveClaimAcl( AclRequests aclReq, String userDetails, int tenantId, HandleDbRequests dbHandle) throws KlawException, KlawBadRequestException { diff --git a/core/src/main/java/io/aiven/klaw/service/KafkaConnectControllerService.java b/core/src/main/java/io/aiven/klaw/service/KafkaConnectControllerService.java index 98b0013675..cfcbdf1967 100644 --- a/core/src/main/java/io/aiven/klaw/service/KafkaConnectControllerService.java +++ b/core/src/main/java/io/aiven/klaw/service/KafkaConnectControllerService.java @@ -710,16 +710,8 @@ public ApiResponse approveConnectorRequests(String connectorId) tenantId); if (Objects.equals(updateConnectorReqStatus, ApiResultStatus.SUCCESS.value)) { - setConnectorHistory(connectorRequest, userDetails, tenantId); updateConnectorReqStatus = dbHandle.updateConnectorRequest(connectorRequest, userDetails); - dbHandle.insertIntoActivityLog( - RequestEntityType.CONNECTOR.value, - tenantId, - connectorRequest.getRequestOperationType(), - connectorRequest.getTeamId(), - "Connector : " + connectorRequest.getConnectorName(), - connectorRequest.getEnvironment(), - connectorRequest.getRequestor()); + updateAuditAndHistory(userDetails, tenantId, connectorRequest, dbHandle); mailService.sendMail( connectorRequest.getConnectorName(), null, @@ -737,6 +729,22 @@ public ApiResponse approveConnectorRequests(String connectorId) : ApiResponse.notOk(updateConnectorReqStatus); } + private void updateAuditAndHistory( + String userDetails, + int tenantId, + KafkaConnectorRequest connectorRequest, + HandleDbRequests dbHandle) { + setConnectorHistory(connectorRequest, userDetails, tenantId); + dbHandle.insertIntoActivityLog( + RequestEntityType.CONNECTOR.value, + tenantId, + connectorRequest.getRequestOperationType(), + connectorRequest.getTeamId(), + "Connector : " + connectorRequest.getConnectorName(), + connectorRequest.getEnvironment(), + connectorRequest.getRequestor()); + } + private void setConnectorHistory( KafkaConnectorRequest connectorRequest, String userName, int tenantId) { try { diff --git a/core/src/main/java/io/aiven/klaw/service/SchemaRegistryControllerService.java b/core/src/main/java/io/aiven/klaw/service/SchemaRegistryControllerService.java index 1e5ea23a55..a9ffaf0832 100644 --- a/core/src/main/java/io/aiven/klaw/service/SchemaRegistryControllerService.java +++ b/core/src/main/java/io/aiven/klaw/service/SchemaRegistryControllerService.java @@ -267,20 +267,8 @@ public ApiResponse execSchemaRequests(String avroSchemaId) throws KlawException } String responseDb = dbHandle.updateSchemaRequest(schemaRequest, userDetails); if (responseDb.equals(ApiResultStatus.SUCCESS.value)) { - saveToTopicHistory(userDetails, tenantId, schemaRequest); - dbHandle.insertIntoActivityLog( - RequestEntityType.SCHEMA.value, - tenantId, - schemaRequest.getRequestOperationType(), - schemaRequest.getTeamId(), - "Topic : " - + schemaRequest.getTopicname() - + " version : " - + registerSchemaCustomResponse.get("version") - + " id : " - + registerSchemaCustomResponse.get("id"), - schemaRequest.getEnvironment(), - schemaRequest.getRequestor()); + updateAuditAndHistory( + userDetails, tenantId, schemaRequest, dbHandle, registerSchemaCustomResponse); } // send mail to producers and consumers @@ -313,6 +301,28 @@ public ApiResponse execSchemaRequests(String avroSchemaId) throws KlawException } } + private void updateAuditAndHistory( + String userDetails, + int tenantId, + SchemaRequest schemaRequest, + HandleDbRequests dbHandle, + Map registerSchemaCustomResponse) { + saveToTopicHistory(userDetails, tenantId, schemaRequest); + dbHandle.insertIntoActivityLog( + RequestEntityType.SCHEMA.value, + tenantId, + schemaRequest.getRequestOperationType(), + schemaRequest.getTeamId(), + "Topic : " + + schemaRequest.getTopicname() + + " version : " + + registerSchemaCustomResponse.get("version") + + " id : " + + registerSchemaCustomResponse.get("id"), + schemaRequest.getEnvironment(), + schemaRequest.getRequestor()); + } + public void notifySubscribers(SchemaRequest schemaRequest, int tenantId) { String topic = schemaRequest.getTopicname(); String schemaRequestEnvironment = schemaRequest.getEnvironment(); diff --git a/core/src/main/java/io/aiven/klaw/service/TopicControllerService.java b/core/src/main/java/io/aiven/klaw/service/TopicControllerService.java index c45a67c7d1..ea272303cb 100644 --- a/core/src/main/java/io/aiven/klaw/service/TopicControllerService.java +++ b/core/src/main/java/io/aiven/klaw/service/TopicControllerService.java @@ -761,14 +761,6 @@ public ApiResponse approveTopicRequests(String topicId) throws KlawException { } if (updateTopicReqStatus.equals(ApiResultStatus.SUCCESS.value)) { - dbHandle.insertIntoActivityLog( - RequestEntityType.TOPIC.value, - tenantId, - topicRequest.getRequestOperationType(), - topicRequest.getTeamId(), - RequestEntityType.TOPIC.value + " : " + topicRequest.getTopicname(), - topicRequest.getEnvironment(), - topicRequest.getRequestor()); commonUtilsService.updateMetadata( tenantId, EntityType.TOPICS, MetadataOperationType.CREATE, null); } @@ -802,7 +794,7 @@ private String invokeClusterApiForTopicRequest( updateTopicReqStatus = Objects.requireNonNull(response.getBody()).getMessage(); if (response.getBody().isSuccess()) { - saveToTopicHistory(userName, tenantId, topicRequest); + updateAuditAndHistory(userName, tenantId, topicRequest, dbHandle); updateTopicReqStatus = dbHandle.updateTopicRequest(topicRequest, userName).getResultStatus(); mailService.sendMail( @@ -820,6 +812,19 @@ private String invokeClusterApiForTopicRequest( return updateTopicReqStatus; } + private void updateAuditAndHistory( + String userName, int tenantId, TopicRequest topicRequest, HandleDbRequests dbHandle) { + saveToTopicHistory(userName, tenantId, topicRequest); + dbHandle.insertIntoActivityLog( + RequestEntityType.TOPIC.value, + tenantId, + topicRequest.getRequestOperationType(), + topicRequest.getTeamId(), + RequestEntityType.TOPIC.value + " : " + topicRequest.getTopicname(), + topicRequest.getEnvironment(), + topicRequest.getRequestor()); + } + private void saveToTopicHistory(String userName, int tenantId, TopicRequest topicRequest) { List topicHistoryList = commonUtilsService.saveTopicHistory( diff --git a/core/src/main/java/io/aiven/klaw/service/UiConfigControllerService.java b/core/src/main/java/io/aiven/klaw/service/UiConfigControllerService.java index 5aa39b578d..da3ccdb781 100644 --- a/core/src/main/java/io/aiven/klaw/service/UiConfigControllerService.java +++ b/core/src/main/java/io/aiven/klaw/service/UiConfigControllerService.java @@ -10,9 +10,11 @@ import io.aiven.klaw.model.ActivityLogModel; import io.aiven.klaw.model.ApiResponse; import io.aiven.klaw.model.enums.PermissionType; +import io.aiven.klaw.model.enums.RequestEntityType; import io.aiven.klaw.model.response.DbAuthInfo; import java.util.*; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.security.core.context.SecurityContextHolder; @@ -85,12 +87,12 @@ public List showActivityLog(String env, String pageNo, String public String getEnvName(String envId, String activityName, int tenantId) { Optional envFound; - if ("SchemaRequest".equalsIgnoreCase(activityName)) { + if (StringUtils.containsIgnoreCase(activityName, RequestEntityType.SCHEMA.value)) { envFound = manageDatabase.getSchemaRegEnvList(tenantId).stream() .filter(env -> Objects.equals(env.getId(), envId)) .findFirst(); - } else if ("ConnectorRequest".equalsIgnoreCase(activityName)) { + } else if (StringUtils.containsIgnoreCase(activityName, RequestEntityType.CONNECTOR.value)) { envFound = manageDatabase.getKafkaConnectEnvList(tenantId).stream() .filter(env -> Objects.equals(env.getId(), envId)) diff --git a/core/src/test/java/io/aiven/klaw/TopicAclControllerIT.java b/core/src/test/java/io/aiven/klaw/TopicAclControllerIT.java index 58ec689661..b5f51eddaa 100644 --- a/core/src/test/java/io/aiven/klaw/TopicAclControllerIT.java +++ b/core/src/test/java/io/aiven/klaw/TopicAclControllerIT.java @@ -21,6 +21,7 @@ import io.aiven.klaw.dao.AclRequests; import io.aiven.klaw.dao.EnvTag; import io.aiven.klaw.model.AclInfo; +import io.aiven.klaw.model.ActivityLogModel; import io.aiven.klaw.model.ApiResponse; import io.aiven.klaw.model.KwPropertiesModel; import io.aiven.klaw.model.ResourceHistory; @@ -462,6 +463,23 @@ public void approveTopic() throws Exception { ApiResponse response1 = OBJECT_MAPPER.readValue(response, new TypeReference<>() {}); assertThat(response1.isSuccess()).isTrue(); + + response = + mvc.perform( + MockMvcRequestBuilders.get("/getActivityLogPerEnv") + .with(user(user2).password(PASSWORD)) + .param("env", "1") + .param("pageNo", "1") + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn() + .getResponse() + .getContentAsString(); + + List response2 = OBJECT_MAPPER.readValue(response, new TypeReference<>() {}); + assertThat(response2.size()).isEqualTo(1); + assertThat(response2.get(0).getDetails()).contains(topicName); } @Test