Skip to content

Commit 99bd0d5

Browse files
authored
fix(audit): add intsance migrate audit meta data
* add audit log * fix * fix * fix * fix
1 parent 71dbe70 commit 99bd0d5

12 files changed

Lines changed: 52 additions & 10 deletions

File tree

server/integration-test/src/test/java/com/oceanbase/odc/service/audit/AuditEventMapperTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ public void test_EntityToModel_Success() {
5252
.organizationId(1L)
5353
.taskId("1")
5454
.action(AuditEventAction.UPDATE_PERSONAL_CONFIGURATION)
55+
.actionName(AuditEventAction.UPDATE_PERSONAL_CONFIGURATION.getLocalizedMessage())
5556
.type(AuditEventType.PERSONAL_CONFIGURATION)
57+
.typeName(AuditEventType.PERSONAL_CONFIGURATION.getLocalizedMessage())
5658
.userId(1L)
5759
.username("account")
5860
.result(AuditEventResult.SUCCESS)

server/integration-test/src/test/java/com/oceanbase/odc/service/audit/AuditEventMetaMapperTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ public void test_EntityToModel_Success() {
3939

4040
AuditEventMeta expected = AuditEventMeta.builder()
4141
.action(AuditEventAction.UPDATE_PERSONAL_CONFIGURATION)
42+
.actionName(AuditEventAction.UPDATE_PERSONAL_CONFIGURATION.getLocalizedMessage())
4243
.type(AuditEventType.PERSONAL_CONFIGURATION)
44+
.typeName(AuditEventType.PERSONAL_CONFIGURATION.getLocalizedMessage())
4345
.enabled(true)
4446
.inConnection(true)
4547
.methodSignature("controller")

server/odc-core/src/main/java/com/oceanbase/odc/core/shared/constant/AuditEventAction.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,10 @@ public enum AuditEventAction implements Translatable {
422422

423423
DELETE_DATABASE_CHANGE_CHANGING_ORDER_TEMPLATE,
424424

425+
BATCH_TERMINAL_TASKS,
426+
427+
BATCH_EXPORT_TASKS
428+
425429
;
426430

427431
@Override

server/odc-core/src/main/java/com/oceanbase/odc/core/shared/constant/AuditEventType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public enum AuditEventType implements Translatable {
100100

101101
DATABASE_CHANGE_CHANGING_ORDER_TEMPLATE_MANAGEMENT,
102102

103-
;
103+
INSTANCE_MIGRATION;
104104

105105

106106
@Override

server/odc-core/src/main/resources/i18n/BusinessMessages.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,8 @@ com.oceanbase.odc.AuditEventAction.DISABLE_SENSITIVE_COLUMN=Disable sensitive co
333333
com.oceanbase.odc.AuditEventAction.CREATE_DATABASE_CHANGE_CHANGING_ORDER_TEMPLATE=Create database change order template
334334
com.oceanbase.odc.AuditEventAction.UPDATE_DATABASE_CHANGE_CHANGING_ORDER_TEMPLATE=Update database change order template
335335
com.oceanbase.odc.AuditEventAction.DELETE_DATABASE_CHANGE_CHANGING_ORDER_TEMPLATE=Delete database change order template
336+
com.oceanbase.odc.AuditEventAction.BATCH_TERMINAL_TASKS=Batch terminal tasks
337+
com.oceanbase.odc.AuditEventAction.BATCH_EXPORT_TASKS=Batch export tasks
336338

337339

338340
#
@@ -377,6 +379,7 @@ com.oceanbase.odc.AuditEventType.NOTIFICATION_MANAGEMENT=Notification management
377379
com.oceanbase.odc.AuditEventType.SENSITIVE_COLUMN_MANAGEMENT=Sensitive column management
378380
com.oceanbase.odc.AuditEventType.STRUCTURE_COMPARISON=Structure comparison
379381
com.oceanbase.odc.AuditEventType.DATABASE_CHANGE_CHANGING_ORDER_TEMPLATE_MANAGEMENT=Database change order template management
382+
com.oceanbase.odc.AuditEventType.INSTANCE_MIGRATION=Instance migration
380383

381384

382385
#

server/odc-core/src/main/resources/i18n/BusinessMessages_zh_CN.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,8 @@ com.oceanbase.odc.AuditEventAction.DISABLE_SENSITIVE_COLUMN=禁用敏感列
338338
com.oceanbase.odc.AuditEventAction.CREATE_DATABASE_CHANGE_CHANGING_ORDER_TEMPLATE=创建数据库变更顺序模板
339339
com.oceanbase.odc.AuditEventAction.UPDATE_DATABASE_CHANGE_CHANGING_ORDER_TEMPLATE=更新数据库变更顺序模板
340340
com.oceanbase.odc.AuditEventAction.DELETE_DATABASE_CHANGE_CHANGING_ORDER_TEMPLATE=删除数据库变更顺序模板
341-
341+
com.oceanbase.odc.AuditEventAction.BATCH_TERMINAL_TASKS=批量终止任务
342+
com.oceanbase.odc.AuditEventAction.BATCH_EXPORT_TASKS=批量导出任务
342343

343344
#
344345
# AuditEventType
@@ -382,6 +383,7 @@ com.oceanbase.odc.AuditEventType.AUTOMATION_RULE_MANAGEMENT=自动授权规则
382383
com.oceanbase.odc.AuditEventType.NOTIFICATION_MANAGEMENT=消息推送管理
383384
com.oceanbase.odc.AuditEventType.SENSITIVE_COLUMN_MANAGEMENT=敏感列管理
384385
com.oceanbase.odc.AuditEventType.DATABASE_CHANGE_CHANGING_ORDER_TEMPLATE_MANAGEMENT=数据库变更顺序模板管理
386+
com.oceanbase.odc.AuditEventType.INSTANCE_MIGRATION=实例迁移
385387

386388
#
387389
# AuditEventResult result type

server/odc-core/src/main/resources/i18n/BusinessMessages_zh_TW.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,8 @@ com.oceanbase.odc.AuditEventAction.DISABLE_SENSITIVE_COLUMN=禁用敏感列
338338
com.oceanbase.odc.AuditEventAction.CREATE_DATABASE_CHANGE_CHANGING_ORDER_TEMPLATE=創建數據庫變更順序模板
339339
com.oceanbase.odc.AuditEventAction.UPDATE_DATABASE_CHANGE_CHANGING_ORDER_TEMPLATE=更新數據庫變更順序模板
340340
com.oceanbase.odc.AuditEventAction.DELETE_DATABASE_CHANGE_CHANGING_ORDER_TEMPLATE=刪除數據庫變更順序模板
341-
341+
com.oceanbase.odc.AuditEventAction.BATCH_TERMINAL_TASKS=批量終止任務
342+
com.oceanbase.odc.AuditEventAction.BATCH_EXPORT_TASKS=批量導出任務
342343
#
343344
# AuditEventType
344345
#
@@ -381,6 +382,7 @@ com.oceanbase.odc.AuditEventType.AUTOMATION_RULE_MANAGEMENT=自動授權規則
381382
com.oceanbase.odc.AuditEventType.NOTIFICATION_MANAGEMENT=消息推送管理
382383
com.oceanbase.odc.AuditEventType.SENSITIVE_COLUMN_MANAGEMENT=敏感列管理
383384
com.oceanbase.odc.AuditEventType.DATABASE_CHANGE_CHANGING_ORDER_TEMPLATE_MANAGEMENT=數據庫變更順序模板管理
385+
com.oceanbase.odc.AuditEventType.INSTANCE_MIGRATION=實例遷移
384386

385387
#
386388
# AuditEventResult result type

server/odc-migrate/src/main/resources/init-config/default-audit-event-meta.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,3 +571,20 @@
571571
in_connection: 0
572572
enabled: 1
573573
id: 102
574+
575+
576+
- type: "INSTANCE_MIGRATION"
577+
action: "BATCH_TERMINAL_TASKS"
578+
method_signature: "com.oceanbase.odc.server.web.controller.cloud.OcpConsoleController.terminateTask"
579+
sid_extract_expression: ""
580+
in_connection: 0
581+
enabled: 1
582+
id: 103
583+
584+
- type: "INSTANCE_MIGRATION"
585+
action: "BATCH_EXPORT_TASKS"
586+
method_signature: "com.oceanbase.odc.server.web.controller.cloud.OcpConsoleController.export"
587+
sid_extract_expression: ""
588+
in_connection: 0
589+
enabled: 1
590+
id: 104

server/odc-service/src/main/java/com/oceanbase/odc/service/audit/AuditEventService.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,9 @@ public Page<AuditEvent> listOrganizationAuditEvents(@NotNull QueryAuditEventPara
124124

125125
private Page<AuditEvent> list(Specification<AuditEventEntity> specs, Pageable pageable) {
126126
return auditEventRepository.findAll(specs, pageable)
127-
.map(entity -> {
128-
AuditEvent event = mapper.entityToModel(entity);
129-
event.setActionName(entity.getAction().getLocalizedMessage());
130-
event.setTypeName(entity.getType().getLocalizedMessage());
131-
return event;
132-
});
127+
.map(entity -> mapper.entityToModel(entity));
133128
}
134129

135-
136130
@PreAuthenticate(actions = "read", resourceType = "ODC_AUDIT_EVENT", isForAll = true)
137131
public Stats stats(@NotNull QueryAuditEventParams params) {
138132
return new Stats().andDistinct("userIds",

server/odc-service/src/main/java/com/oceanbase/odc/service/audit/model/AuditEventMeta.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,21 @@ public class AuditEventMeta {
4545
*/
4646
private AuditEventType type;
4747

48+
/**
49+
* Audit event name
50+
*/
51+
private String typeName;
52+
4853
/**
4954
* Audit event action
5055
*/
5156
private AuditEventAction action;
5257

58+
/**
59+
* Audit event action name
60+
*/
61+
private String actionName;
62+
5363
/**
5464
* sid extract expression which is an SpEL
5565
*/

0 commit comments

Comments
 (0)