Skip to content

Commit 049a8cb

Browse files
authored
Merge branch 'dev' into feat_inc_environment_service_coverage
2 parents 86d8ac5 + 2263455 commit 049a8cb

File tree

85 files changed

+2715
-637
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+2715
-637
lines changed

dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/audit/AuditMessage.java

Lines changed: 0 additions & 96 deletions
This file was deleted.

dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/audit/AuditPublishService.java

Lines changed: 0 additions & 92 deletions
This file was deleted.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.dolphinscheduler.api.audit;
19+
20+
import org.apache.dolphinscheduler.api.audit.enums.AuditType;
21+
22+
import java.lang.annotation.Documented;
23+
import java.lang.annotation.ElementType;
24+
import java.lang.annotation.Retention;
25+
import java.lang.annotation.RetentionPolicy;
26+
import java.lang.annotation.Target;
27+
28+
/**
29+
* Custom annotation for logging and auditing operator actions in the system.
30+
* This annotation can be applied to methods to indicate the type of operation, object type,
31+
* and specific parameters to be recorded in the logs.
32+
*/
33+
@Target(ElementType.METHOD)
34+
@Retention(RetentionPolicy.RUNTIME)
35+
@Documented
36+
public @interface OperatorLog {
37+
38+
AuditType auditType();
39+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.dolphinscheduler.api.audit;
19+
20+
import org.apache.dolphinscheduler.api.audit.operator.AuditOperator;
21+
import org.apache.dolphinscheduler.service.bean.SpringApplicationContext;
22+
23+
import java.lang.reflect.Method;
24+
25+
import lombok.extern.slf4j.Slf4j;
26+
27+
import org.aspectj.lang.ProceedingJoinPoint;
28+
import org.aspectj.lang.annotation.Around;
29+
import org.aspectj.lang.annotation.Aspect;
30+
import org.aspectj.lang.annotation.Pointcut;
31+
import org.aspectj.lang.reflect.MethodSignature;
32+
import org.springframework.stereotype.Component;
33+
34+
import io.swagger.v3.oas.annotations.Operation;
35+
36+
@Aspect
37+
@Slf4j
38+
@Component
39+
public class OperatorLogAspect {
40+
41+
@Pointcut("@annotation(org.apache.dolphinscheduler.api.audit.OperatorLog)")
42+
public void logPointCut() {
43+
}
44+
45+
@Around("logPointCut()")
46+
public Object around(ProceedingJoinPoint point) throws Throwable {
47+
MethodSignature signature = (MethodSignature) point.getSignature();
48+
Method method = signature.getMethod();
49+
50+
OperatorLog operatorLog = method.getAnnotation(OperatorLog.class);
51+
52+
Operation operation = method.getAnnotation(Operation.class);
53+
if (operation == null) {
54+
log.warn("Operation is null of method: {}", method.getName());
55+
return point.proceed();
56+
}
57+
58+
AuditOperator operator = SpringApplicationContext.getBean(operatorLog.auditType().getOperatorClass());
59+
return operator.recordAudit(point, operation.description(), operatorLog.auditType());
60+
}
61+
}

0 commit comments

Comments
 (0)