diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index db6a6a4835b..3f90cba463f 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,5 +1,5 @@ # -# Copyright 2023 Apollo Authors +# Copyright 2024 Apollo Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/.github/stale.yml b/.github/stale.yml index b10c08672dc..bbb53492402 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -1,5 +1,5 @@ # -# Copyright 2023 Apollo Authors +# Copyright 2024 Apollo Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 424ee0c4655..7069497e059 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,5 @@ # -# Copyright 2023 Apollo Authors +# Copyright 2024 Apollo Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml index 1e28b3485dd..a6696aaaa69 100644 --- a/.github/workflows/cla.yml +++ b/.github/workflows/cla.yml @@ -1,5 +1,5 @@ # -# Copyright 2023 Apollo Authors +# Copyright 2024 Apollo Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index a92caec65b2..5a1d5c778c9 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -1,5 +1,5 @@ # -# Copyright 2023 Apollo Authors +# Copyright 2024 Apollo Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/.github/workflows/license.yml b/.github/workflows/license.yml index d2b078f7959..557ba26f88d 100644 --- a/.github/workflows/license.yml +++ b/.github/workflows/license.yml @@ -1,5 +1,5 @@ # -# Copyright 2023 Apollo Authors +# Copyright 2024 Apollo Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/.licenserc.yaml b/.licenserc.yaml index dbf7dd5e60e..f29c904e4a5 100644 --- a/.licenserc.yaml +++ b/.licenserc.yaml @@ -1,5 +1,5 @@ # -# Copyright 2023 Apollo Authors +# Copyright 2024 Apollo Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/CHANGES.md b/CHANGES.md index 3996f783893..cccd30b1b50 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,35 +2,13 @@ Changes by Version ================== Release Notes. -Apollo 2.2.0 +Apollo 2.3.0 ------------------ -* [Fix the problem of inconsistent length of appId column](https://github.com/apolloconfig/apollo/pull/4725) -* [Bump springcloud springboot version to solve cve problems](https://github.com/apolloconfig/apollo/pull/4712) -* [rename mysql-connector-java to mysql-connector-j](https://github.com/apolloconfig/apollo/pull/4748) -* [Bump springboot version from 2.7.8 to 2.7.9](https://github.com/apolloconfig/apollo/pull/4750) -* [[Multi-Database Support] Without Reliance on globally_quoted_identifiers Variable](https://github.com/apolloconfig/apollo/pull/4749) -* [[Multi-Database Support] Without Reliance on boolean integer compare](https://github.com/apolloconfig/apollo/pull/4757) -* [[Multi-Database Support] package postgre h2 dependency](https://github.com/apolloconfig/apollo/pull/4763) -* [[Multi-Database Support] Optimize table case](https://github.com/apolloconfig/apollo/pull/4768) -* [Fix OIDC logout unnecessary redirect](https://github.com/apolloconfig/apollo/pull/4773) -* [[Multi-Database Support] Introduce h2 postgre profile properties to let user config database config](https://github.com/apolloconfig/apollo/pull/4766) -* [[Multi-Database Support] Optimize column define case sensitivity](https://github.com/apolloconfig/apollo/pull/4776) -* [[Multi-Database Support][pg] Where clause need escape, otherwise will request postgre use lowwer case](https://github.com/apolloconfig/apollo/pull/4780) -* [Misc dependency updates](https://github.com/apolloconfig/apollo/pull/4784) -* [Fix the problem that the deletion failure of the system rights management page does not prompt](https://github.com/apolloconfig/apollo/pull/4803) -* [Fix the issue of the system permission management page retrieving non-existent users](https://github.com/apolloconfig/apollo/pull/4802) -* [Add release history cleaning function](https://github.com/apolloconfig/apollo/pull/4813) -* [[Multi-Database Support][pg] Make JdbcUserDetailsManager compat with postgre](https://github.com/apolloconfig/apollo/pull/4790) -* [refactor(apollo logging): Simplify the default log path to `/opt/logs`](https://github.com/apolloconfig/apollo/pull/4833) -* [Add a configuration config-service.cache.key.ignore-case to control whether the cache key is case-sensitive](https://github.com/apolloconfig/apollo/pull/4820) -* [feat: check port use by another process or not when startup](https://github.com/apolloconfig/apollo/pull/4656) -* [Bump springboot version from 2.7.9 to 2.7.11](https://github.com/apolloconfig/apollo/pull/4828) -* [[Multi-Database Support][h2] Support run on h2](https://github.com/apolloconfig/apollo/pull/4851) -* [Fix the issue that env special case handling is missing in some case](https://github.com/apolloconfig/apollo/pull/4887) -* [Fix the issue that namespace content being cleared when identical content is pasted into the namespace](https://github.com/apolloconfig/apollo/pull/4922) -* [feat(openapi): allow user create app via openapi](https://github.com/apolloconfig/apollo/pull/4954) -* [Support grayscale feature for non-properties namespaces](https://github.com/apolloconfig/apollo/pull/4952) +* [Fix circular references on LdapAutoConfiguration](https://github.com/apolloconfig/apollo/pull/5055) +* [Add comment for clusters and UI display](https://github.com/apolloconfig/apollo/pull/5072) +* [Fix the issue that the length of private namespaces are mis-calculated](https://github.com/apolloconfig/apollo/pull/5078) + ------------------ -All issues and pull requests are [here](https://github.com/apolloconfig/apollo/milestone/13?closed=1) \ No newline at end of file +All issues and pull requests are [here](https://github.com/apolloconfig/apollo/milestone/14?closed=1) \ No newline at end of file diff --git a/apollo-adminservice/pom.xml b/apollo-adminservice/pom.xml index 6e9b29b48b4..fcfd390eb57 100644 --- a/apollo-adminservice/pom.xml +++ b/apollo-adminservice/pom.xml @@ -1,6 +1,6 @@ org.springframework.cloud diff --git a/apollo-adminservice/src/assembly/assembly-descriptor.xml b/apollo-adminservice/src/assembly/assembly-descriptor.xml index af29b6e80da..bfa147d10b9 100644 --- a/apollo-adminservice/src/assembly/assembly-descriptor.xml +++ b/apollo-adminservice/src/assembly/assembly-descriptor.xml @@ -1,5 +1,5 @@ + + + apollo-audit + com.ctrip.framework.apollo + ${revision} + + 4.0.0 + + apollo-audit-annotation + ${revision} + + \ No newline at end of file diff --git a/apollo-audit/apollo-audit-annotation/src/main/java/com/ctrip/framework/apollo/audit/annotation/ApolloAuditLog.java b/apollo-audit/apollo-audit-annotation/src/main/java/com/ctrip/framework/apollo/audit/annotation/ApolloAuditLog.java new file mode 100644 index 00000000000..f842d3133c9 --- /dev/null +++ b/apollo-audit/apollo-audit-annotation/src/main/java/com/ctrip/framework/apollo/audit/annotation/ApolloAuditLog.java @@ -0,0 +1,69 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Mark which method should be audited, add to controller or service's method. + *

+ * Define the attributes of the operation for persisting and querying. When adding to controller's + * methods, suggested that don't set name, and it will automatically be set to request's url. + *

+ * Example usage: + *
+ * {@code
+ * @ApolloAuditLog(type=OpType.CREATE,name="App.create")
+ * public App create() {
+ *   // ...
+ * }
+ * }
+ * 
+ * + * @author luke0125 + * @since 2.2.0 + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface ApolloAuditLog { + + /** + * Define the type of operation. + * + * @return operation type + */ + OpType type(); + + /** + * Define the name of operation. The requested URL will be taken by default if no specific name is + * specified. + * + * @return operation name + */ + String name() default ""; + + /** + * Define the description of operation. Default is "no description". + * + * @return operation description + */ + String description() default "no description"; +} + diff --git a/apollo-audit/apollo-audit-annotation/src/main/java/com/ctrip/framework/apollo/audit/annotation/ApolloAuditLogDataInfluence.java b/apollo-audit/apollo-audit-annotation/src/main/java/com/ctrip/framework/apollo/audit/annotation/ApolloAuditLogDataInfluence.java new file mode 100644 index 00000000000..bc89934fb33 --- /dev/null +++ b/apollo-audit/apollo-audit-annotation/src/main/java/com/ctrip/framework/apollo/audit/annotation/ApolloAuditLogDataInfluence.java @@ -0,0 +1,45 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Combine with {@link ApolloAuditLog}, mark which method's parameter is audit log's data change. + *

+ * Example usage: + *
+ * {@code
+ * @ApolloAuditLog(type=OpType.DELETE,name="AppNamespace.batchDeleteByAppId")
+ * public AppNamespace batchDeleteByAppId(
+ *            @ApolloAuditLogDataInfluence String appId) {
+ *   // ...
+ * }
+ * }
+ * 
+ * + * @author luke0125 + * @since 2.2.0 + */ +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +public @interface ApolloAuditLogDataInfluence { + +} diff --git a/apollo-audit/apollo-audit-annotation/src/main/java/com/ctrip/framework/apollo/audit/annotation/ApolloAuditLogDataInfluenceTable.java b/apollo-audit/apollo-audit-annotation/src/main/java/com/ctrip/framework/apollo/audit/annotation/ApolloAuditLogDataInfluenceTable.java new file mode 100644 index 00000000000..3398f713ad9 --- /dev/null +++ b/apollo-audit/apollo-audit-annotation/src/main/java/com/ctrip/framework/apollo/audit/annotation/ApolloAuditLogDataInfluenceTable.java @@ -0,0 +1,63 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Mainly used in class definitions, indicates the name of the corresponding audit data table of + * this class. + *

+ * It could also be used on method parameters to express the table name of the class which this + * parameter belongs to. + *

+ * Example usage: + *
+ * {@code
+ * CASE 1:
+ * @ApolloAuditLogDataInfluenceTable(tableName="App")
+ * public class App {
+ *   // ...
+ * }
+ * CASE 2:
+ * @ApolloAuditLog(type=OpType.DELETE,name="AppNamespace.batchDeleteByAppId")
+ * public AppNamespace batchDeleteByAppId(
+ *   @ApolloAuditLogDataInfluence
+ *   @ApolloAuditLogDataInfluenceTable(tableName="AppNamespace") String appId) {
+ *   // ...
+ * }
+ * }
+ * 
+ * + * @author luke0125 + * @since 2.2.0 + */ +@Target({ElementType.TYPE, ElementType.PARAMETER}) +@Retention(RetentionPolicy.RUNTIME) +public @interface ApolloAuditLogDataInfluenceTable { + + /** + * Define the table name(entity name) of audited entity. + * + * @return table name + */ + String tableName(); + +} diff --git a/apollo-audit/apollo-audit-annotation/src/main/java/com/ctrip/framework/apollo/audit/annotation/ApolloAuditLogDataInfluenceTableField.java b/apollo-audit/apollo-audit-annotation/src/main/java/com/ctrip/framework/apollo/audit/annotation/ApolloAuditLogDataInfluenceTableField.java new file mode 100644 index 00000000000..b6b78d20feb --- /dev/null +++ b/apollo-audit/apollo-audit-annotation/src/main/java/com/ctrip/framework/apollo/audit/annotation/ApolloAuditLogDataInfluenceTableField.java @@ -0,0 +1,65 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Mainly used in field definitions, indicates the name of the corresponding audit data table field + * of this member variables(attributes). + *

+ * It could also be used on method parameters to express the field name of the field which this + * parameter matches. + *

+ * Example usage: + *
+ * {@code
+ * CASE 1:
+ * public class App {
+ *   @ApolloAuditLogDataInfluenceTableField(fieldName="AppId")
+ *   private String appId;
+ *   // ...
+ * }
+ * CASE 2:
+ * @ApolloAuditLog(type=OpType.DELETE,name="AppNamespace.batchDeleteByAppId")
+ * public AppNamespace batchDeleteByAppId(
+ *   @ApolloAuditLogDataInfluence
+ *   @ApolloAuditLogDataInfluenceTable(tableName="AppNamespace")
+ *   @ApolloAuditLogDataInfluenceTableField(fieldName="AppId") String appId) {
+ *   // ...
+ * }
+ * }
+ * 
+ * + * @author luke0125 + * @since 2.2.0 + */ +@Target({ElementType.FIELD, ElementType.PARAMETER}) +@Retention(RetentionPolicy.RUNTIME) +public @interface ApolloAuditLogDataInfluenceTableField { + + /** + * Define the field name of audited entity field. + * + * @return field name + */ + String fieldName(); + +} diff --git a/apollo-audit/apollo-audit-annotation/src/main/java/com/ctrip/framework/apollo/audit/annotation/OpType.java b/apollo-audit/apollo-audit-annotation/src/main/java/com/ctrip/framework/apollo/audit/annotation/OpType.java new file mode 100644 index 00000000000..d9c2ea0c202 --- /dev/null +++ b/apollo-audit/apollo-audit-annotation/src/main/java/com/ctrip/framework/apollo/audit/annotation/OpType.java @@ -0,0 +1,27 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.annotation; + +/** + * Includes all types of audit operations. + * + * @author luke0125 + * @since 2.2.0 + */ +public enum OpType { + CREATE, UPDATE, DELETE, RPC +} diff --git a/apollo-audit/apollo-audit-api/pom.xml b/apollo-audit/apollo-audit-api/pom.xml new file mode 100644 index 00000000000..8b8306b0066 --- /dev/null +++ b/apollo-audit/apollo-audit-api/pom.xml @@ -0,0 +1,38 @@ + + + + + apollo-audit + com.ctrip.framework.apollo + ${revision} + + 4.0.0 + + apollo-audit-api + ${revision} + + + + com.ctrip.framework.apollo + apollo-audit-annotation + + + + \ No newline at end of file diff --git a/apollo-audit/apollo-audit-api/src/main/java/com/ctrip/framework/apollo/audit/api/ApolloAuditLogApi.java b/apollo-audit/apollo-audit-api/src/main/java/com/ctrip/framework/apollo/audit/api/ApolloAuditLogApi.java new file mode 100644 index 00000000000..4f9063f20cf --- /dev/null +++ b/apollo-audit/apollo-audit-api/src/main/java/com/ctrip/framework/apollo/audit/api/ApolloAuditLogApi.java @@ -0,0 +1,27 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.api; + +/** + * API interface that integrates all functional interfaces. + * + * @author luke0125 + * @since 2.2.0 + */ +public interface ApolloAuditLogApi extends ApolloAuditLogRecordApi, ApolloAuditLogQueryApi{ + +} diff --git a/apollo-audit/apollo-audit-api/src/main/java/com/ctrip/framework/apollo/audit/api/ApolloAuditLogQueryApi.java b/apollo-audit/apollo-audit-api/src/main/java/com/ctrip/framework/apollo/audit/api/ApolloAuditLogQueryApi.java new file mode 100644 index 00000000000..a14a2ec7d9a --- /dev/null +++ b/apollo-audit/apollo-audit-api/src/main/java/com/ctrip/framework/apollo/audit/api/ApolloAuditLogQueryApi.java @@ -0,0 +1,98 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.api; + +import com.ctrip.framework.apollo.audit.dto.ApolloAuditLogDTO; +import com.ctrip.framework.apollo.audit.dto.ApolloAuditLogDataInfluenceDTO; +import com.ctrip.framework.apollo.audit.dto.ApolloAuditLogDetailsDTO; +import java.util.Date; +import java.util.List; + +/** + * Mainly used to query AuditLogs and DataInfluences. + * + * @author luke0125 + * @since 2.2.0 + */ +public interface ApolloAuditLogQueryApi { + + /** + * Query all AuditLogs by page + * + * @param page index from 0 + * @param size size of a page + * @return List of ApolloAuditLogDTO + */ + List queryLogs(int page, int size); + + /** + * Query AuditLogs by operator name and time limit and page + * + * @param opName operation name of querying + * @param startDate expect result after or equal this time + * @param endDate expect result before or equal this time + * @param page index from 0 + * @param size size of a page + * @return List of ApolloAuditLogDTO + */ + List queryLogsByOpName(String opName, Date startDate, Date endDate, int page, + int size); + + /** + * Query AuditLogDetails by trace id. + *

+ * An AuditLogDetail contains an AuditLog and DataInfluences it caused. + *

+ *
+   * {@code
+   *   An AuditLogDetail:
+   *   {
+   *     LogDTO:{},
+   *     DataInfluencesDTO:[]
+   *   }
+   * }
+   * 
+ * + * @param traceId unique id of a operation trace + * @return List of ApolloAuditLogDetailsDTO + */ + List queryTraceDetails(String traceId); + + /** + * Query DataInfluences by specific entity's specified field and page + * + * @param entityName target entity's name(audit table name) + * @param entityId target entity's id(audit table id) + * @param fieldName target field's name(audit field id) + * @param page index from 0 + * @param size size of a page + * @return List of ApolloAuditLogDetailsDTO + */ + List queryDataInfluencesByField(String entityName, + String entityId, String fieldName, int page, int size); + + /** + * Fuzzy search related AuditLog by query-string and page, page index from 0. + * + * @param query input query string, used to fuzzy search + * @param page index from 0 + * @param size size of a page + * @return List of ApolloAuditLogDetailsDTO + */ + List searchLogByNameOrTypeOrOperator(String query, int page, int size); + +} \ No newline at end of file diff --git a/apollo-audit/apollo-audit-api/src/main/java/com/ctrip/framework/apollo/audit/api/ApolloAuditLogRecordApi.java b/apollo-audit/apollo-audit-api/src/main/java/com/ctrip/framework/apollo/audit/api/ApolloAuditLogRecordApi.java new file mode 100644 index 00000000000..216f2d4dea2 --- /dev/null +++ b/apollo-audit/apollo-audit-api/src/main/java/com/ctrip/framework/apollo/audit/api/ApolloAuditLogRecordApi.java @@ -0,0 +1,85 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.api; + +import com.ctrip.framework.apollo.audit.annotation.OpType; +import java.util.List; + +/** + * Mainly used to Record AuditLogs and DataInfluences. + * + * @author luke0125 + * @since 2.2.0 + */ +public interface ApolloAuditLogRecordApi { + + /** + * Append a new AuditLog by type and name.The operation's description would be default by "no + * description". + *

+ * Functionally aligned with annotations. + *

+ * Need to close the audited scope manually! + * + * @param type operation's type + * @param name operation's name + * @return Returns an AuditScope needs to be closed when the audited operation ends. + */ + AutoCloseable appendAuditLog(OpType type, String name); + + /** + * Append a new AuditLog by type and name and description. + *

+ * Functionally aligned with annotations. + *

+ * Need to close the audited scope manually! + * + * @param type operation's type + * @param name operation's name + * @param description operation's description + * @return Returns an AuditScope needs to be closed when the audited operation ends. + */ + AutoCloseable appendAuditLog(OpType type, String name, String description); + + /** + * Directly append a new DataInfluence by the attributes it should have. + *

+ * Only when there is an active AuditScope in the context at this time can appending DataInfluence + * be performed correctly. It will be considered to be caused by currently active operations. + * + * @param entityName influenced entity's name (audit table name) + * @param entityId influenced entity's id (audit table id) + * @param fieldName influenced entity's field name (audit table field) + * @param fieldCurrentValue influenced entity's field current value + */ + void appendDataInfluence(String entityName, String entityId, String fieldName, + String fieldCurrentValue); + + /** + * Append DataInfluences by a list of entities needs to be audited, and their + * audit-bean-definition. + *

+ * Only when there is an active AuditScope in the context at this time can appending + * DataInfluences be performed correctly. They will be considered to be caused by currently active + * operations. + * + * @param entities entities needs to be audited + * @param beanDefinition entities' audit-bean-definition + */ + void appendDataInfluences(List entities, Class beanDefinition); + +} diff --git a/apollo-audit/apollo-audit-api/src/main/java/com/ctrip/framework/apollo/audit/dto/ApolloAuditLogDTO.java b/apollo-audit/apollo-audit-api/src/main/java/com/ctrip/framework/apollo/audit/dto/ApolloAuditLogDTO.java new file mode 100644 index 00000000000..3bffdddb7ed --- /dev/null +++ b/apollo-audit/apollo-audit-api/src/main/java/com/ctrip/framework/apollo/audit/dto/ApolloAuditLogDTO.java @@ -0,0 +1,113 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.dto; + +import java.util.Date; + +public class ApolloAuditLogDTO { + + private long id; + private String traceId; + private String spanId; + private String parentSpanId; + private String followsFromSpanId; + private String operator; + private String opType; + private String opName; + private String description; + private Date happenedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTraceId() { + return traceId; + } + + public void setTraceId(String traceId) { + this.traceId = traceId; + } + + public String getSpanId() { + return spanId; + } + + public void setSpanId(String spanId) { + this.spanId = spanId; + } + + public String getParentSpanId() { + return parentSpanId; + } + + public void setParentSpanId(String parentSpanId) { + this.parentSpanId = parentSpanId; + } + + public String getFollowsFromSpanId() { + return followsFromSpanId; + } + + public void setFollowsFromSpanId(String followsFromSpanId) { + this.followsFromSpanId = followsFromSpanId; + } + + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } + + public String getOpType() { + return opType; + } + + public void setOpType(String opType) { + this.opType = opType; + } + + public String getOpName() { + return opName; + } + + public void setOpName(String opName) { + this.opName = opName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getHappenedTime() { + return happenedTime; + } + + public void setHappenedTime(Date happenedTime) { + this.happenedTime = happenedTime; + } +} diff --git a/apollo-audit/apollo-audit-api/src/main/java/com/ctrip/framework/apollo/audit/dto/ApolloAuditLogDataInfluenceDTO.java b/apollo-audit/apollo-audit-api/src/main/java/com/ctrip/framework/apollo/audit/dto/ApolloAuditLogDataInfluenceDTO.java new file mode 100644 index 00000000000..e3fac29738d --- /dev/null +++ b/apollo-audit/apollo-audit-api/src/main/java/com/ctrip/framework/apollo/audit/dto/ApolloAuditLogDataInfluenceDTO.java @@ -0,0 +1,95 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.dto; + +import java.util.Date; + +public class ApolloAuditLogDataInfluenceDTO { + + private long id; + private String spanId; + private String influenceEntityName; + private String influenceEntityId; + private String fieldName; + private String fieldOldValue; + private String fieldNewValue; + private Date happenedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getSpanId() { + return spanId; + } + + public void setSpanId(String spanId) { + this.spanId = spanId; + } + + public String getInfluenceEntityName() { + return influenceEntityName; + } + + public void setInfluenceEntityName(String influenceEntityName) { + this.influenceEntityName = influenceEntityName; + } + + public String getInfluenceEntityId() { + return influenceEntityId; + } + + public void setInfluenceEntityId(String influenceEntityId) { + this.influenceEntityId = influenceEntityId; + } + + public String getFieldName() { + return fieldName; + } + + public void setFieldName(String fieldName) { + this.fieldName = fieldName; + } + + public String getFieldOldValue() { + return fieldOldValue; + } + + public void setFieldOldValue(String fieldOldValue) { + this.fieldOldValue = fieldOldValue; + } + + public String getFieldNewValue() { + return fieldNewValue; + } + + public void setFieldNewValue(String fieldNewValue) { + this.fieldNewValue = fieldNewValue; + } + + public Date getHappenedTime() { + return happenedTime; + } + + public void setHappenedTime(Date happenedTime) { + this.happenedTime = happenedTime; + } +} diff --git a/apollo-audit/apollo-audit-api/src/main/java/com/ctrip/framework/apollo/audit/dto/ApolloAuditLogDetailsDTO.java b/apollo-audit/apollo-audit-api/src/main/java/com/ctrip/framework/apollo/audit/dto/ApolloAuditLogDetailsDTO.java new file mode 100644 index 00000000000..3231ec6085a --- /dev/null +++ b/apollo-audit/apollo-audit-api/src/main/java/com/ctrip/framework/apollo/audit/dto/ApolloAuditLogDetailsDTO.java @@ -0,0 +1,54 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.dto; + +import java.util.List; + +/** + * A combine of a log and its data influences + */ +public class ApolloAuditLogDetailsDTO { + + private ApolloAuditLogDTO logDTO; + private List dataInfluenceDTOList; + + public ApolloAuditLogDetailsDTO(ApolloAuditLogDTO logDTO, + List dataInfluenceDTOList) { + this.logDTO = logDTO; + this.dataInfluenceDTOList = dataInfluenceDTOList; + } + + public ApolloAuditLogDetailsDTO() { + } + + public ApolloAuditLogDTO getLogDTO() { + return logDTO; + } + + public void setLogDTO(ApolloAuditLogDTO logDTO) { + this.logDTO = logDTO; + } + + public List getDataInfluenceDTOList() { + return dataInfluenceDTOList; + } + + public void setDataInfluenceDTOList( + List dataInfluenceDTOList) { + this.dataInfluenceDTOList = dataInfluenceDTOList; + } +} diff --git a/apollo-audit/apollo-audit-api/src/main/java/com/ctrip/framework/apollo/audit/event/ApolloAuditLogDataInfluenceEvent.java b/apollo-audit/apollo-audit-api/src/main/java/com/ctrip/framework/apollo/audit/event/ApolloAuditLogDataInfluenceEvent.java new file mode 100644 index 00000000000..5b005c24ef6 --- /dev/null +++ b/apollo-audit/apollo-audit-api/src/main/java/com/ctrip/framework/apollo/audit/event/ApolloAuditLogDataInfluenceEvent.java @@ -0,0 +1,44 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.event; + +public class ApolloAuditLogDataInfluenceEvent { + + private Class beanDefinition; + private Object entity; + + public ApolloAuditLogDataInfluenceEvent(Class beanDefinition, Object entity) { + this.beanDefinition = beanDefinition; + this.entity = entity; + } + + public Class getBeanDefinition() { + return beanDefinition; + } + + public void setBeanDefinition(Class beanDefinition) { + this.beanDefinition = beanDefinition; + } + + public Object getEntity() { + return entity; + } + + public void setEntity(Object entity) { + this.entity = entity; + } +} diff --git a/apollo-audit/apollo-audit-impl/pom.xml b/apollo-audit/apollo-audit-impl/pom.xml new file mode 100644 index 00000000000..ecdabc7f31f --- /dev/null +++ b/apollo-audit/apollo-audit-impl/pom.xml @@ -0,0 +1,59 @@ + + + + + apollo-audit + com.ctrip.framework.apollo + ${revision} + + 4.0.0 + + apollo-audit-impl + ${revision} + + + + com.ctrip.framework.apollo + apollo-audit-annotation + + + + com.ctrip.framework.apollo + apollo-audit-api + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + org.springframework.security + spring-security-core + + + + + \ No newline at end of file diff --git a/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/ApolloAuditProperties.java b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/ApolloAuditProperties.java new file mode 100644 index 00000000000..99c6ae5549b --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/ApolloAuditProperties.java @@ -0,0 +1,33 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +@ConfigurationProperties(prefix = "apollo.audit.log") +public class ApolloAuditProperties { + + private boolean enabled = false; + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } +} diff --git a/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/ApolloAuditRegistrar.java b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/ApolloAuditRegistrar.java new file mode 100644 index 00000000000..8e2d37fde1a --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/ApolloAuditRegistrar.java @@ -0,0 +1,32 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit; + +import org.springframework.beans.factory.support.BeanDefinitionRegistry; +import org.springframework.boot.autoconfigure.AutoConfigurationPackages; +import org.springframework.context.annotation.ImportBeanDefinitionRegistrar; +import org.springframework.core.type.AnnotationMetadata; + +public class ApolloAuditRegistrar implements ImportBeanDefinitionRegistrar { + + @Override + public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, + BeanDefinitionRegistry registry) { + AutoConfigurationPackages.register(registry, "com.ctrip.framework.apollo.audit.entity", + "com.ctrip.framework.apollo.audit.repository"); + } +} diff --git a/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/aop/ApolloAuditSpanAspect.java b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/aop/ApolloAuditSpanAspect.java new file mode 100644 index 00000000000..f191278d678 --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/aop/ApolloAuditSpanAspect.java @@ -0,0 +1,125 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.aop; + +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLog; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLogDataInfluence; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLogDataInfluenceTable; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLogDataInfluenceTableField; +import com.ctrip.framework.apollo.audit.api.ApolloAuditLogApi; +import com.ctrip.framework.apollo.audit.constants.ApolloAuditConstants; +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.util.Collection; +import java.util.Objects; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.Signature; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.aspectj.lang.reflect.MethodSignature; +import org.springframework.cglib.core.ReflectUtils; + +@Aspect +public class ApolloAuditSpanAspect { + + private final ApolloAuditLogApi api; + + public ApolloAuditSpanAspect(ApolloAuditLogApi api) { + this.api = api; + } + + @Pointcut("@annotation(auditLog)") + public void setAuditSpan(ApolloAuditLog auditLog) { + } + + @Around(value = "setAuditSpan(auditLog)") + public Object around(ProceedingJoinPoint pjp, ApolloAuditLog auditLog) throws Throwable { + String opName = auditLog.name(); + try (AutoCloseable scope = api.appendAuditLog(auditLog.type(), opName, + auditLog.description())) { + Object proceed = pjp.proceed(); + auditDataInfluenceArg(pjp); + return proceed; + } + } + + void auditDataInfluenceArg(ProceedingJoinPoint pjp) { + Method method = findMethod(pjp); + if (Objects.isNull(method)) { + return; + } + Object[] args = pjp.getArgs(); + for (int i = 0; i < args.length; i++) { + Object arg = args[i]; + Annotation[] annotations = method.getParameterAnnotations()[i]; + + + boolean needAudit = false; + String entityName = null; + String fieldName = null; + + for (Annotation annotation : annotations) { + if (annotation instanceof ApolloAuditLogDataInfluence) { + needAudit = true; + } + if (annotation instanceof ApolloAuditLogDataInfluenceTable) { + entityName = ((ApolloAuditLogDataInfluenceTable) annotation).tableName(); + } + if (annotation instanceof ApolloAuditLogDataInfluenceTableField) { + fieldName = ((ApolloAuditLogDataInfluenceTableField) annotation).fieldName(); + } + } + + if (needAudit) { + parseArgAndAppend(entityName, fieldName, arg); + } + } + } + + Method findMethod(ProceedingJoinPoint pjp) { + Class clazz = pjp.getTarget().getClass(); + Signature pjpSignature = pjp.getSignature(); + String methodName = pjp.getSignature().getName(); + Class[] parameterTypes = null; + if (pjpSignature instanceof MethodSignature) { + parameterTypes = ((MethodSignature) pjpSignature).getParameterTypes(); + } + try { + Method method = ReflectUtils.findDeclaredMethod(clazz, methodName, parameterTypes); + return method; + } catch (NoSuchMethodException e) { + return null; + } + } + + void parseArgAndAppend(String entityName, String fieldName, Object arg) { + if (entityName == null || fieldName == null || arg == null) { + return; + } + + if (arg instanceof Collection) { + for (Object o : (Collection) arg) { + String matchedValue = String.valueOf(o); + api.appendDataInfluence(entityName, ApolloAuditConstants.ANY_MATCHED_ID, fieldName, matchedValue); + } + } else { + String matchedValue = String.valueOf(arg); + api.appendDataInfluence(entityName, ApolloAuditConstants.ANY_MATCHED_ID, fieldName, matchedValue); + } + } +} diff --git a/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/component/ApolloAuditHttpInterceptor.java b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/component/ApolloAuditHttpInterceptor.java new file mode 100644 index 00000000000..8353a588f44 --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/component/ApolloAuditHttpInterceptor.java @@ -0,0 +1,43 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.component; + +import com.ctrip.framework.apollo.audit.context.ApolloAuditTraceContext; +import java.io.IOException; +import org.springframework.http.HttpRequest; +import org.springframework.http.client.ClientHttpRequestExecution; +import org.springframework.http.client.ClientHttpRequestInterceptor; +import org.springframework.http.client.ClientHttpResponse; + +public class ApolloAuditHttpInterceptor implements ClientHttpRequestInterceptor { + + private final ApolloAuditTraceContext traceContext; + + public ApolloAuditHttpInterceptor(ApolloAuditTraceContext traceContext) { + this.traceContext = traceContext; + } + + @Override + public ClientHttpResponse intercept(HttpRequest request, byte[] body, + ClientHttpRequestExecution execution) throws IOException { + if (traceContext.tracer() != null) { + request = traceContext.tracer().inject(request); + } + ClientHttpResponse response = execution.execute(request, body); + return response; + } +} diff --git a/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/component/ApolloAuditLogApiJpaImpl.java b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/component/ApolloAuditLogApiJpaImpl.java new file mode 100644 index 00000000000..d8489c3b2bd --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/component/ApolloAuditLogApiJpaImpl.java @@ -0,0 +1,158 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.component; + +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLogDataInfluenceTableField; +import com.ctrip.framework.apollo.audit.annotation.OpType; +import com.ctrip.framework.apollo.audit.api.ApolloAuditLogApi; +import com.ctrip.framework.apollo.audit.context.ApolloAuditScope; +import com.ctrip.framework.apollo.audit.context.ApolloAuditTraceContext; +import com.ctrip.framework.apollo.audit.context.ApolloAuditTracer; +import com.ctrip.framework.apollo.audit.dto.ApolloAuditLogDTO; +import com.ctrip.framework.apollo.audit.dto.ApolloAuditLogDataInfluenceDTO; +import com.ctrip.framework.apollo.audit.dto.ApolloAuditLogDetailsDTO; +import com.ctrip.framework.apollo.audit.entity.ApolloAuditLogDataInfluence; +import com.ctrip.framework.apollo.audit.service.ApolloAuditLogDataInfluenceService; +import com.ctrip.framework.apollo.audit.service.ApolloAuditLogService; +import com.ctrip.framework.apollo.audit.util.ApolloAuditUtil; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Objects; + +public class ApolloAuditLogApiJpaImpl implements ApolloAuditLogApi { + + private final ApolloAuditLogService logService; + private final ApolloAuditLogDataInfluenceService dataInfluenceService; + private final ApolloAuditTraceContext traceContext; + + public ApolloAuditLogApiJpaImpl(ApolloAuditLogService logService, + ApolloAuditLogDataInfluenceService dataInfluenceService, ApolloAuditTraceContext traceContext) { + this.logService = logService; + this.dataInfluenceService = dataInfluenceService; + this.traceContext = traceContext; + } + + @Override + public AutoCloseable appendAuditLog(OpType type, String name) { + return appendAuditLog(type, name, "no description"); + } + + @Override + public AutoCloseable appendAuditLog(OpType type, String name, String description) { + ApolloAuditTracer tracer = traceContext.tracer(); + if (Objects.isNull(tracer)) { + return () -> {}; + } + ApolloAuditScope scope = tracer.startActiveSpan(type, name, description); + logService.logSpan(scope.activeSpan()); + return scope; + } + + @Override + public void appendDataInfluence(String entityName, String entityId, String fieldName, + String fieldCurrentValue) { + // might be + if (traceContext.tracer() == null) { + return; + } + if (traceContext.tracer().getActiveSpan() == null) { + return; + } + String spanId = traceContext.tracer().getActiveSpan().spanId(); + OpType type = traceContext.tracer().getActiveSpan().getOpType(); + ApolloAuditLogDataInfluence.Builder builder = ApolloAuditLogDataInfluence.builder().spanId(spanId) + .entityName(entityName).entityId(entityId).fieldName(fieldName); + if (type == null) { + return; + } + switch (type) { + case CREATE: + case UPDATE: + builder.newVal(fieldCurrentValue); + break; + case DELETE: + builder.oldVal(fieldCurrentValue); + } + dataInfluenceService.save(builder.build()); + } + + @Override + public void appendDataInfluences(List entities, Class beanDefinition) { + String tableName = ApolloAuditUtil.getApolloAuditLogTableName(beanDefinition); + if (Objects.isNull(tableName) || tableName.equals("")) { + return; + } + List dataInfluenceFields = ApolloAuditUtil.getAnnotatedFields( + ApolloAuditLogDataInfluenceTableField.class, beanDefinition); + Field idField = ApolloAuditUtil.getPersistenceIdFieldByAnnotation(beanDefinition); + entities.forEach(e -> { + try { + idField.setAccessible(true); + String tableId = idField.get(e).toString(); + for (Field f : dataInfluenceFields) { + f.setAccessible(true); + String val = String.valueOf(f.get(e)); + String fieldName = f.getAnnotation(ApolloAuditLogDataInfluenceTableField.class).fieldName(); + appendDataInfluence(tableName, tableId, fieldName, val); + } + } catch (IllegalAccessException ex) { + throw new IllegalArgumentException("failed append data influence, " + + "might due to wrong beanDefinition for entity audited", ex); + } + }); + } + + @Override + public List queryLogs(int page, int size) { + return ApolloAuditUtil.logListToDTOList(logService.findAll(page, size)); + } + + @Override + public List queryLogsByOpName(String opName, Date startDate, Date endDate, + int page, int size) { + if (startDate == null && endDate == null) { + return ApolloAuditUtil.logListToDTOList(logService.findByOpName(opName, page, size)); + } + return ApolloAuditUtil.logListToDTOList( + logService.findByOpNameAndTime(opName, startDate, endDate, page, size)); + } + + @Override + public List queryTraceDetails(String traceId) { + List detailsDTOList = new ArrayList<>(); + logService.findByTraceId(traceId).forEach(log -> { + detailsDTOList.add(new ApolloAuditLogDetailsDTO(ApolloAuditUtil.logToDTO(log), + ApolloAuditUtil.dataInfluenceListToDTOList( + dataInfluenceService.findBySpanId(log.getSpanId())))); + }); + return detailsDTOList; + } + + @Override + public List queryDataInfluencesByField(String entityName, + String entityId, String fieldName, int page, int size) { + return ApolloAuditUtil.dataInfluenceListToDTOList(dataInfluenceService.findByEntityNameAndEntityIdAndFieldName(entityName, entityId, + fieldName, page, size)); + } + + @Override + public List searchLogByNameOrTypeOrOperator(String query, int page, int size) { + return ApolloAuditUtil.logListToDTOList(logService.searchLogByNameOrTypeOrOperator(query, page, size)); + } +} diff --git a/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/component/ApolloAuditLogApiNoOpImpl.java b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/component/ApolloAuditLogApiNoOpImpl.java new file mode 100644 index 00000000000..6de5f0a018e --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/component/ApolloAuditLogApiNoOpImpl.java @@ -0,0 +1,77 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.component; + +import com.ctrip.framework.apollo.audit.annotation.OpType; +import com.ctrip.framework.apollo.audit.api.ApolloAuditLogApi; +import com.ctrip.framework.apollo.audit.dto.ApolloAuditLogDataInfluenceDTO; +import com.ctrip.framework.apollo.audit.dto.ApolloAuditLogDetailsDTO; +import com.ctrip.framework.apollo.audit.dto.ApolloAuditLogDTO; +import java.util.Date; +import java.util.List; + +public class ApolloAuditLogApiNoOpImpl implements ApolloAuditLogApi { + + //do nothing, for default impl + + @Override + public AutoCloseable appendAuditLog(OpType type, String name) { + return appendAuditLog(type, name, null); + } + + @Override + public AutoCloseable appendAuditLog(OpType type, String name, String description) { + return () -> { + }; + } + + @Override + public void appendDataInfluence(String entityName, String entityId, String fieldName, + String fieldCurrentValue) { + } + + @Override + public void appendDataInfluences(List entities, Class beanDefinition) { + } + + @Override + public List queryLogs(int page, int size) { + return null; + } + + @Override + public List queryLogsByOpName(String opName, Date startDate, + Date endDate, int page, int size) { + return null; + } + + @Override + public List queryTraceDetails(String traceId) { + return null; + } + + @Override + public List queryDataInfluencesByField(String entityName, + String entityId, String fieldName, int page, int size) { + return null; + } + + @Override + public List searchLogByNameOrTypeOrOperator(String query, int page, int size) { + return null; + } +} diff --git a/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/constants/ApolloAuditConstants.java b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/constants/ApolloAuditConstants.java new file mode 100644 index 00000000000..35eaf1f333c --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/constants/ApolloAuditConstants.java @@ -0,0 +1,29 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.constants; + +public interface ApolloAuditConstants { + String TRACE_ID = "Apollo-Audit-TraceId"; + String SPAN_ID = "Apollo-Audit-SpanId"; + String OPERATOR = "Apollo-Audit-Operator"; + String PARENT_ID = "Apollo-Audit-ParentId"; + String FOLLOWS_FROM_ID = "Apollo-Audit-FollowsFromId"; + + String TRACER = "Apollo-Audit-Tracer"; + + String ANY_MATCHED_ID = "AnyMatched"; +} diff --git a/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/context/ApolloAuditScope.java b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/context/ApolloAuditScope.java new file mode 100644 index 00000000000..c9839696a3e --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/context/ApolloAuditScope.java @@ -0,0 +1,54 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.context; + +public class ApolloAuditScope implements AutoCloseable { + + private final ApolloAuditScopeManager manager; + + private ApolloAuditSpan activeSpan; + private ApolloAuditScope hangUp; + private String lastSpanId; + + public ApolloAuditScope(ApolloAuditSpan activeSpan, ApolloAuditScopeManager manager) { + this.hangUp = manager.getScope(); + this.activeSpan = activeSpan; + this.manager = manager; + this.lastSpanId = null; + } + + public ApolloAuditSpan activeSpan() { + return this.activeSpan; + } + + @Override + public void close(){ + // closing span become parent-scope's last span + if (hangUp != null) { + hangUp.setLastSpanId(activeSpan().spanId()); + } + this.manager.setScope(hangUp); + } + + public String getLastSpanId() { + return lastSpanId; + } + + public void setLastSpanId(String lastSpanId) { + this.lastSpanId = lastSpanId; + } +} diff --git a/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/context/ApolloAuditScopeManager.java b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/context/ApolloAuditScopeManager.java new file mode 100644 index 00000000000..1e4bd40041e --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/context/ApolloAuditScopeManager.java @@ -0,0 +1,48 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.context; + +import java.io.IOException; + +public class ApolloAuditScopeManager { + + private ApolloAuditScope scope; + + public ApolloAuditScopeManager() { + } + + public ApolloAuditScope activate(ApolloAuditSpan span) { + setScope(new ApolloAuditScope(span, this)); + return getScope(); + } + + public void deactivate() throws IOException { + getScope().close(); + } + + public ApolloAuditSpan activeSpan() { + return getScope() == null ? null : getScope().activeSpan(); + } + + public ApolloAuditScope getScope() { + return scope; + } + + public void setScope(ApolloAuditScope scope) { + this.scope = scope; + } +} diff --git a/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/context/ApolloAuditSpan.java b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/context/ApolloAuditSpan.java new file mode 100644 index 00000000000..43fd7709c37 --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/context/ApolloAuditSpan.java @@ -0,0 +1,112 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.context; + +import com.ctrip.framework.apollo.audit.annotation.OpType; +import java.util.Date; + +public class ApolloAuditSpan { + + private OpType opType; + private String opName; + private String description; + private Date startTime; + private Date endTime; + + private ApolloAuditSpanContext context; + + public ApolloAuditSpanContext context() { + return this.context; + } + + //just do nothing + public void finish() { + endTime = new Date(); + } + + public void log() { + } + + // sugar method + public String spanId() { + return context.getSpanId(); + } + + public String operator() { + return context.getOperator(); + } + + public String traceId() { + return context.getTraceId(); + } + + public String parentId() { + return context.getParentId(); + } + + public String followsFromId() { + return context.getFollowsFromId(); + } + + public OpType getOpType() { + return opType; + } + + public void setOpType(OpType opType) { + this.opType = opType; + } + + public String getOpName() { + return opName; + } + + public void setOpName(String opName) { + this.opName = opName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public ApolloAuditSpanContext getContext() { + return context; + } + + public void setContext(ApolloAuditSpanContext context) { + this.context = context; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } +} \ No newline at end of file diff --git a/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/context/ApolloAuditSpanContext.java b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/context/ApolloAuditSpanContext.java new file mode 100644 index 00000000000..23519012193 --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/context/ApolloAuditSpanContext.java @@ -0,0 +1,79 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.context; + +public class ApolloAuditSpanContext { + + private String traceId; + private String spanId; + private String operator; + private String parentId; + private String followsFromId; + + public ApolloAuditSpanContext(String traceId, String spanId) { + this.traceId = traceId; + this.spanId = spanId; + } + + public ApolloAuditSpanContext(String traceId, String spanId, String operator, String parentId, String followsFromId) { + this.traceId = traceId; + this.spanId = spanId; + this.operator = operator; + this.parentId = parentId; + this.followsFromId = followsFromId; + } + + public String getTraceId() { + return traceId; + } + + public void setTraceId(String traceId) { + this.traceId = traceId; + } + + public String getSpanId() { + return spanId; + } + + public void setSpanId(String spanId) { + this.spanId = spanId; + } + + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } + + public String getParentId() { + return parentId; + } + + public void setParentId(String parentId) { + this.parentId = parentId; + } + + public String getFollowsFromId() { + return followsFromId; + } + + public void setFollowsFromId(String followsFromId) { + this.followsFromId = followsFromId; + } +} diff --git a/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/context/ApolloAuditTraceContext.java b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/context/ApolloAuditTraceContext.java new file mode 100644 index 00000000000..22270509ee0 --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/context/ApolloAuditTraceContext.java @@ -0,0 +1,58 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.context; + +import com.ctrip.framework.apollo.audit.constants.ApolloAuditConstants; +import com.ctrip.framework.apollo.audit.spi.ApolloAuditOperatorSupplier; +import java.util.Objects; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; + +public class ApolloAuditTraceContext { + + private final ApolloAuditOperatorSupplier operatorSupplier; + + public ApolloAuditTraceContext(ApolloAuditOperatorSupplier operatorSupplier) { + this.operatorSupplier = operatorSupplier; + } + + // if not get one, create one and re-get it + public ApolloAuditTracer tracer() { + RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); + if (requestAttributes != null) { + Object tracer = requestAttributes.getAttribute(ApolloAuditConstants.TRACER, + RequestAttributes.SCOPE_REQUEST); + if (tracer != null) { + return ((ApolloAuditTracer) tracer); + } else { + ApolloAuditTracer newTracer = new ApolloAuditTracer(new ApolloAuditScopeManager(), operatorSupplier); + setTracer(newTracer); + return newTracer; + } + } + return null; + } + + void setTracer(ApolloAuditTracer tracer) { + if (Objects.nonNull(RequestContextHolder.getRequestAttributes())) { + RequestContextHolder.getRequestAttributes() + .setAttribute(ApolloAuditConstants.TRACER, tracer, RequestAttributes.SCOPE_REQUEST); + } + } + + +} diff --git a/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/context/ApolloAuditTracer.java b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/context/ApolloAuditTracer.java new file mode 100644 index 00000000000..bfa4e6c4cee --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/context/ApolloAuditTracer.java @@ -0,0 +1,189 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.context; + +import com.ctrip.framework.apollo.audit.annotation.OpType; +import com.ctrip.framework.apollo.audit.constants.ApolloAuditConstants; +import com.ctrip.framework.apollo.audit.spi.ApolloAuditOperatorSupplier; +import com.ctrip.framework.apollo.audit.util.ApolloAuditUtil; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.servlet.http.HttpServletRequest; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpRequest; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +public class ApolloAuditTracer { + + private final ApolloAuditScopeManager manager; + private final ApolloAuditOperatorSupplier operatorSupplier; + + public ApolloAuditTracer(ApolloAuditScopeManager manager, + ApolloAuditOperatorSupplier operatorSupplier) { + this.manager = manager; + this.operatorSupplier = operatorSupplier; + } + + public ApolloAuditScopeManager scopeManager() { + return manager; + } + + public HttpRequest inject(HttpRequest request) { + Map> map = new HashMap<>(); + if (manager.activeSpan() == null) { + return request; + } + map.put(ApolloAuditConstants.TRACE_ID, + Collections.singletonList(manager.activeSpan().traceId())); + map.put(ApolloAuditConstants.SPAN_ID, + Collections.singletonList(manager.activeSpan().spanId())); + map.put(ApolloAuditConstants.OPERATOR, + Collections.singletonList(manager.activeSpan().operator())); + map.put(ApolloAuditConstants.PARENT_ID, + Collections.singletonList(manager.activeSpan().parentId())); + map.put(ApolloAuditConstants.FOLLOWS_FROM_ID, + Collections.singletonList(manager.activeSpan().followsFromId())); + + HttpHeaders headers = request.getHeaders(); + headers.putAll(map); + + return request; + } + + public ApolloAuditSpan startSpan(OpType type, String name, String description) { + ApolloAuditSpan activeSpan = getActiveSpan(); + AuditSpanBuilder builder = new AuditSpanBuilder(type, name); + builder = builder.description(description); + builder = activeSpan == null ? builder.asRootSpan(operatorSupplier.getOperator()) + : builder.asChildOf(activeSpan); + String followsFromId = scopeManager().getScope() == null ? + null : scopeManager().getScope().getLastSpanId(); + builder = builder.followsFrom(followsFromId); + + return builder.build(); + } + + public ApolloAuditScope startActiveSpan(OpType type, String name, String description) { + ApolloAuditSpan startSpan = startSpan(type, name, description); + return activate(startSpan); + } + + public ApolloAuditScope activate(ApolloAuditSpan span) { + return scopeManager().activate(span); + } + + private ApolloAuditSpan getActiveSpanFromHttp() { + ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + if (servletRequestAttributes == null) { + return null; + } + HttpServletRequest request = servletRequestAttributes.getRequest(); + String traceId = request.getHeader(ApolloAuditConstants.TRACE_ID); + String spanId = request.getHeader(ApolloAuditConstants.SPAN_ID); + String operator = request.getHeader(ApolloAuditConstants.OPERATOR); + String parentId = request.getHeader(ApolloAuditConstants.PARENT_ID); + String followsFromId = request.getHeader(ApolloAuditConstants.FOLLOWS_FROM_ID); + if (Objects.isNull(traceId)) { + return null; + } else { + ApolloAuditSpanContext context = new ApolloAuditSpanContext(traceId, spanId, operator, parentId, followsFromId); + return spanBuilder(null, null).regenerateByContext(context); + } + } + + private ApolloAuditSpan getActiveSpanFromContext() { + return scopeManager().activeSpan(); + } + + public ApolloAuditSpan getActiveSpan() { + ApolloAuditSpan activeSpan = getActiveSpanFromContext(); + if (activeSpan != null) { + return activeSpan; + } + activeSpan = getActiveSpanFromHttp(); + // might be null, root span generate should be done in other place + return activeSpan; + } + + public AuditSpanBuilder spanBuilder(OpType type, String name) { + return new AuditSpanBuilder(type, name); + } + + public static class AuditSpanBuilder { + + private final OpType opType; + private final String opName; + private String spanId; + private String traceId; + private String operator; + private String parentId; + private String followsFromId; + private String description; + + public AuditSpanBuilder(OpType type, String name) { + opType = type; + opName = name; + } + + public AuditSpanBuilder asChildOf(ApolloAuditSpan parent) { + traceId = parent.traceId(); + operator = parent.operator(); + parentId = parent.spanId(); + return this; + } + + public AuditSpanBuilder asRootSpan(String operator) { + traceId = ApolloAuditUtil.generateId(); + this.operator = operator; + return this; + } + + public AuditSpanBuilder followsFrom(String id) { + this.followsFromId = id; + return this; + } + + public AuditSpanBuilder description(String val) { + this.description = val; + return this; + } + + public ApolloAuditSpan regenerateByContext(ApolloAuditSpanContext val) { + ApolloAuditSpan span = new ApolloAuditSpan(); + span.setContext(val); + return span; + } + + public ApolloAuditSpan build() { + ApolloAuditSpan span = new ApolloAuditSpan(); + spanId = ApolloAuditUtil.generateId(); + ApolloAuditSpanContext context = new ApolloAuditSpanContext(traceId, spanId, operator, + parentId, followsFromId); + span.setContext(context); + span.setDescription(description); + span.setOpName(opName); + span.setOpType(opType); + span.setStartTime(new Date()); + return span; + } + } +} diff --git a/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/controller/ApolloAuditController.java b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/controller/ApolloAuditController.java new file mode 100644 index 00000000000..bfdbc98bca5 --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/controller/ApolloAuditController.java @@ -0,0 +1,97 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.controller; + +import com.ctrip.framework.apollo.audit.ApolloAuditProperties; +import com.ctrip.framework.apollo.audit.api.ApolloAuditLogApi; +import com.ctrip.framework.apollo.audit.dto.ApolloAuditLogDTO; +import com.ctrip.framework.apollo.audit.dto.ApolloAuditLogDataInfluenceDTO; +import com.ctrip.framework.apollo.audit.dto.ApolloAuditLogDetailsDTO; +import java.util.Date; +import java.util.List; +import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * About page: index from 0, default size is 10 + * + * @author luke + */ +@RestController +@RequestMapping("/apollo/audit") +public class ApolloAuditController { + + private final ApolloAuditLogApi api; + private final ApolloAuditProperties properties; + + public ApolloAuditController(ApolloAuditLogApi api, ApolloAuditProperties properties) { + this.api = api; + this.properties = properties; + } + + @GetMapping("/properties") + public ApolloAuditProperties getProperties() { + return properties; + } + + @GetMapping("/logs") + @PreAuthorize(value = "@apolloAuditLogQueryApiPreAuthorizer.hasQueryPermission()") + public List findAllAuditLogs(int page, int size) { + List logDTOList = api.queryLogs(page, size); + return logDTOList; + } + + @GetMapping("/trace") + @PreAuthorize(value = "@apolloAuditLogQueryApiPreAuthorizer.hasQueryPermission()") + public List findTraceDetails(@RequestParam String traceId) { + List detailsDTOList = api.queryTraceDetails(traceId); + return detailsDTOList; + } + + @GetMapping("/logs/opName") + @PreAuthorize(value = "@apolloAuditLogQueryApiPreAuthorizer.hasQueryPermission()") + public List findAllAuditLogsByOpNameAndTime(@RequestParam String opName, + @RequestParam int page, @RequestParam int size, + @RequestParam(value = "startDate", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.S") Date startDate, + @RequestParam(value = "endDate", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.S") Date endDate) { + List logDTOList = api.queryLogsByOpName(opName, startDate, endDate, page, + size); + return logDTOList; + } + + @GetMapping("/logs/dataInfluences/field") + @PreAuthorize(value = "@apolloAuditLogQueryApiPreAuthorizer.hasQueryPermission()") + public List findDataInfluencesByField( + @RequestParam String entityName, @RequestParam String entityId, + @RequestParam String fieldName, int page, int size) { + List dataInfluenceDTOList = api.queryDataInfluencesByField( + entityName, entityId, fieldName, page, size); + return dataInfluenceDTOList; + } + + @GetMapping("/logs/by-name-or-type-or-operator") + @PreAuthorize(value = "@apolloAuditLogQueryApiPreAuthorizer.hasQueryPermission()") + public List findAuditLogsByNameOrTypeOrOperator(@RequestParam String query, int page, int size) { + List logDTOList = api.searchLogByNameOrTypeOrOperator(query, page, size); + return logDTOList; + } + +} diff --git a/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/entity/ApolloAuditLog.java b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/entity/ApolloAuditLog.java new file mode 100644 index 00000000000..c97f27fea4a --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/entity/ApolloAuditLog.java @@ -0,0 +1,177 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.entity; + +import java.util.Date; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Table; + +@Entity +@Table(name = "`AuditLog`") +public class ApolloAuditLog extends BaseEntity { + + @Column(name = "TraceId", nullable = false) + private String traceId; + + @Column(name = "SpanId", nullable = false) + private String spanId; + + @Column(name = "ParentSpanId", nullable = true) + private String parentSpanId; + + @Column(name = "FollowsFromSpanId", nullable = true) + private String followsFromSpanId; + + @Column(name = "Operator", nullable = true) + private String operator; + + @Column(name = "OpType", nullable = true) + private String opType; + + @Column(name = "OpName", nullable = true) + private String opName; + + @Column(name = "Description", nullable = true) + private String description; + + public static Builder builder() { + return new Builder(); + } + + public String getTraceId() { + return traceId; + } + + public void setTraceId(String traceId) { + this.traceId = traceId; + } + + public String getSpanId() { + return spanId; + } + + public void setSpanId(String spanId) { + this.spanId = spanId; + } + + public String getParentSpanId() { + return parentSpanId; + } + + public void setParentSpanId(String parentSpanId) { + this.parentSpanId = parentSpanId; + } + + public String getFollowsFromSpanId() { + return followsFromSpanId; + } + + public void setFollowsFromSpanId(String followsFromSpanId) { + this.followsFromSpanId = followsFromSpanId; + } + + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } + + public String getOpType() { + return opType; + } + + public void setOpType(String opType) { + this.opType = opType; + } + + public String getOpName() { + return opName; + } + + public void setOpName(String opName) { + this.opName = opName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public static class Builder { + + ApolloAuditLog auditLog = new ApolloAuditLog(); + + public Builder() { + } + + public Builder traceId(String val) { + auditLog.setTraceId(val); + return this; + } + + public Builder spanId(String val) { + auditLog.setSpanId(val); + return this; + } + + public Builder parentSpanId(String val) { + auditLog.setParentSpanId(val); + return this; + } + + public Builder followsFromSpanId(String val) { + auditLog.setFollowsFromSpanId(val); + return this; + } + + public Builder operator(String val) { + auditLog.setOperator(val); + return this; + } + + public Builder opType(String val) { + auditLog.setOpType(val); + return this; + } + + public Builder opName(String val) { + auditLog.setOpName(val); + return this; + } + + public Builder description(String val) { + auditLog.setDescription(val); + return this; + } + + public Builder happenedTime(Date val) { + auditLog.setDataChangeCreatedTime(val); + return this; + } + + public ApolloAuditLog build() { + return auditLog; + } + + } +} diff --git a/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/entity/ApolloAuditLogDataInfluence.java b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/entity/ApolloAuditLogDataInfluence.java new file mode 100644 index 00000000000..e4ec9677807 --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/entity/ApolloAuditLogDataInfluence.java @@ -0,0 +1,151 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.entity; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Table; + +@Entity +@Table(name = "`AuditLogDataInfluence`") +public class ApolloAuditLogDataInfluence extends BaseEntity { + + @Column(name = "SpanId", nullable = false) + private String spanId; + + @Column(name = "InfluenceEntityName", nullable = false) + private String influenceEntityName; + + @Column(name = "InfluenceEntityId", nullable = false) + private String influenceEntityId; + + @Column(name = "FieldName") + private String fieldName; + + @Column(name = "FieldOldValue") + private String fieldOldValue; + + @Column(name = "FieldNewValue") + private String fieldNewValue; + + public ApolloAuditLogDataInfluence() { + } + + public ApolloAuditLogDataInfluence(String spanId, String entityName, String entityId, + String fieldName, String oldVal, String newVal) { + this.spanId = spanId; + this.influenceEntityName = entityName; + this.influenceEntityId = entityId; + this.fieldName = fieldName; + this.fieldOldValue = oldVal; + this.fieldNewValue = newVal; + } + + public static Builder builder() { + return new Builder(); + } + + public String getSpanId() { + return spanId; + } + + public void setSpanId(String spanId) { + this.spanId = spanId; + } + + public String getInfluenceEntityName() { + return influenceEntityName; + } + + public void setInfluenceEntityName(String influenceEntityName) { + this.influenceEntityName = influenceEntityName; + } + + public String getInfluenceEntityId() { + return influenceEntityId; + } + + public void setInfluenceEntityId(String influenceEntityId) { + this.influenceEntityId = influenceEntityId; + } + + public String getFieldName() { + return fieldName; + } + + public void setFieldName(String fieldName) { + this.fieldName = fieldName; + } + + public String getFieldOldValue() { + return fieldOldValue; + } + + public void setFieldOldValue(String fieldOldValue) { + this.fieldOldValue = fieldOldValue; + } + + public String getFieldNewValue() { + return fieldNewValue; + } + + public void setFieldNewValue(String fieldNewValue) { + this.fieldNewValue = fieldNewValue; + } + + public static class Builder { + + ApolloAuditLogDataInfluence influence = new ApolloAuditLogDataInfluence(); + + public Builder() { + } + + public Builder spanId(String val) { + influence.setSpanId(val); + return this; + } + + public Builder entityId(String val) { + influence.setInfluenceEntityId(val); + return this; + } + + public Builder entityName(String val) { + influence.setInfluenceEntityName(val); + return this; + } + + public Builder fieldName(String val) { + influence.setFieldName(val); + return this; + } + + public Builder oldVal(String val) { + influence.setFieldOldValue(val); + return this; + } + + public Builder newVal(String val) { + influence.setFieldNewValue(val); + return this; + } + + public ApolloAuditLogDataInfluence build() { + return influence; + } + } +} diff --git a/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/entity/BaseEntity.java b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/entity/BaseEntity.java new file mode 100644 index 00000000000..cd209a5e6fb --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/entity/BaseEntity.java @@ -0,0 +1,136 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.entity; + +import java.util.Date; +import javax.persistence.Column; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.MappedSuperclass; +import javax.persistence.PrePersist; +import javax.persistence.PreRemove; +import javax.persistence.PreUpdate; + +@MappedSuperclass +@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) +public abstract class BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "`Id`") + private long id; + + @Column(name = "`IsDeleted`", columnDefinition = "Bit default '0'") + protected boolean isDeleted = false; + + @Column(name = "`DeletedAt`", columnDefinition = "Bigint default '0'") + protected long deletedAt; + + @Column(name = "`DataChange_CreatedBy`") + private String dataChangeCreatedBy; + + @Column(name = "`DataChange_CreatedTime`") + private Date dataChangeCreatedTime; + + @Column(name = "`DataChange_LastModifiedBy`") + private String dataChangeLastModifiedBy; + + @Column(name = "`DataChange_LastTime`") + private Date dataChangeLastModifiedTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public boolean isDeleted() { + return isDeleted; + } + + public void setDeleted(boolean deleted) { + isDeleted = deleted; + if (deleted && this.deletedAt == 0) { + // also set deletedAt value as epoch millisecond + this.deletedAt = System.currentTimeMillis(); + } else if (!deleted) { + this.deletedAt = 0L; + } + } + + public long getDeletedAt() { + return deletedAt; + } + + public String getDataChangeCreatedBy() { + return dataChangeCreatedBy; + } + + public void setDataChangeCreatedBy(String dataChangeCreatedBy) { + this.dataChangeCreatedBy = dataChangeCreatedBy; + } + + public Date getDataChangeCreatedTime() { + return dataChangeCreatedTime; + } + + public void setDataChangeCreatedTime(Date dataChangeCreatedTime) { + this.dataChangeCreatedTime = dataChangeCreatedTime; + } + + public String getDataChangeLastModifiedBy() { + return dataChangeLastModifiedBy; + } + + public void setDataChangeLastModifiedBy(String dataChangeLastModifiedBy) { + this.dataChangeLastModifiedBy = dataChangeLastModifiedBy; + } + + public Date getDataChangeLastModifiedTime() { + return dataChangeLastModifiedTime; + } + + public void setDataChangeLastModifiedTime(Date dataChangeLastModifiedTime) { + this.dataChangeLastModifiedTime = dataChangeLastModifiedTime; + } + + @PrePersist + protected void prePersist() { + if (this.dataChangeCreatedTime == null) { + dataChangeCreatedTime = new Date(); + } + if (this.dataChangeLastModifiedTime == null) { + dataChangeLastModifiedTime = new Date(); + } + } + + @PreUpdate + protected void preUpdate() { + this.dataChangeLastModifiedTime = new Date(); + } + + @PreRemove + protected void preRemove() { + this.dataChangeLastModifiedTime = new Date(); + } + +} diff --git a/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/listener/ApolloAuditLogDataInfluenceEventListener.java b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/listener/ApolloAuditLogDataInfluenceEventListener.java new file mode 100644 index 00000000000..c66488dbe7b --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/listener/ApolloAuditLogDataInfluenceEventListener.java @@ -0,0 +1,37 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.listener; + +import com.ctrip.framework.apollo.audit.api.ApolloAuditLogApi; +import com.ctrip.framework.apollo.audit.event.ApolloAuditLogDataInfluenceEvent; +import java.util.Collections; +import org.springframework.context.event.EventListener; + +public class ApolloAuditLogDataInfluenceEventListener { + + private final ApolloAuditLogApi api; + + public ApolloAuditLogDataInfluenceEventListener(ApolloAuditLogApi api) { + this.api = api; + } + + @EventListener + public void handleEvent(ApolloAuditLogDataInfluenceEvent event) { + Object e = event.getEntity(); + api.appendDataInfluences(Collections.singletonList(e), event.getBeanDefinition()); + } +} diff --git a/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/repository/ApolloAuditLogDataInfluenceRepository.java b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/repository/ApolloAuditLogDataInfluenceRepository.java new file mode 100644 index 00000000000..64cfbaddeba --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/repository/ApolloAuditLogDataInfluenceRepository.java @@ -0,0 +1,35 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.repository; + +import com.ctrip.framework.apollo.audit.entity.ApolloAuditLogDataInfluence; +import java.util.List; +import org.springframework.data.domain.Pageable; +import org.springframework.data.repository.PagingAndSortingRepository; + +public interface ApolloAuditLogDataInfluenceRepository extends + PagingAndSortingRepository { + + List findBySpanId(String spanId); + + List findByInfluenceEntityNameAndInfluenceEntityId( + String influenceEntityName, String influenceEntityId, Pageable page); + + List findByInfluenceEntityNameAndInfluenceEntityIdAndFieldName( + String influenceEntityName, String influenceEntityId, String fieldName, Pageable page); + +} diff --git a/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/repository/ApolloAuditLogRepository.java b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/repository/ApolloAuditLogRepository.java new file mode 100644 index 00000000000..6a5b519cd9f --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/repository/ApolloAuditLogRepository.java @@ -0,0 +1,38 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.repository; + +import com.ctrip.framework.apollo.audit.entity.ApolloAuditLog; +import java.util.Date; +import java.util.List; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.repository.query.Param; + +public interface ApolloAuditLogRepository extends PagingAndSortingRepository { + + List findByTraceIdOrderByDataChangeCreatedTimeDesc(String traceId); + + List findByOpName(String opName, Pageable page); + + List findByOpNameAndDataChangeCreatedTimeGreaterThanEqualAndDataChangeCreatedTimeLessThanEqual( + String opName, Date startDate, Date endDate, Pageable pageable); + + List findByOpNameContainingOrOpTypeContainingOrOperatorContaining(String opName, + String opType, String operator, Pageable pageable); +} diff --git a/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/service/ApolloAuditLogDataInfluenceService.java b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/service/ApolloAuditLogDataInfluenceService.java new file mode 100644 index 00000000000..d6c11ac9f02 --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/service/ApolloAuditLogDataInfluenceService.java @@ -0,0 +1,57 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.service; + +import com.ctrip.framework.apollo.audit.entity.ApolloAuditLogDataInfluence; +import com.ctrip.framework.apollo.audit.repository.ApolloAuditLogDataInfluenceRepository; +import java.util.List; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.domain.Sort.Direction; +import org.springframework.data.domain.Sort.Order; + + +public class ApolloAuditLogDataInfluenceService { + + private final ApolloAuditLogDataInfluenceRepository dataInfluenceRepository; + + public ApolloAuditLogDataInfluenceService( + ApolloAuditLogDataInfluenceRepository dataInfluenceRepository) { + this.dataInfluenceRepository = dataInfluenceRepository; + } + + public ApolloAuditLogDataInfluence save(ApolloAuditLogDataInfluence dataInfluence) { + return dataInfluenceRepository.save(dataInfluence); + } + + public List findBySpanId(String spanId) { + return dataInfluenceRepository.findBySpanId(spanId); + } + + public List findByEntityNameAndEntityIdAndFieldName( + String entityName, String entityId, String fieldName, int page, int size) { + Pageable pageable = pageSortByTime(page, size); + return dataInfluenceRepository.findByInfluenceEntityNameAndInfluenceEntityIdAndFieldName( + entityName, entityId, fieldName, pageable); + } + + Pageable pageSortByTime(int page, int size) { + return PageRequest.of(page, size, Sort.by(new Order(Direction.DESC, "DataChangeCreatedTime"))); + } + +} diff --git a/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/service/ApolloAuditLogService.java b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/service/ApolloAuditLogService.java new file mode 100644 index 00000000000..536dc34825a --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/service/ApolloAuditLogService.java @@ -0,0 +1,89 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.service; + +import com.ctrip.framework.apollo.audit.context.ApolloAuditSpan; +import com.ctrip.framework.apollo.audit.entity.ApolloAuditLog; +import com.ctrip.framework.apollo.audit.repository.ApolloAuditLogRepository; +import java.util.Date; +import java.util.List; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.domain.Sort.Direction; +import org.springframework.data.domain.Sort.Order; + +public class ApolloAuditLogService { + + private final ApolloAuditLogRepository logRepository; + + public ApolloAuditLogService(ApolloAuditLogRepository logRepository) { + this.logRepository = logRepository; + } + + public ApolloAuditLog save(ApolloAuditLog auditLog) { + return logRepository.save(auditLog); + } + + public void logSpan(ApolloAuditSpan span) { + + ApolloAuditLog auditLog = ApolloAuditLog.builder() + .traceId(span.traceId()) + .spanId(span.spanId()) + .parentSpanId(span.parentId()) + .followsFromSpanId(span.followsFromId()) + .operator(span.operator() != null ? span.operator() : "anonymous") + .opName(span.getOpName()) + .opType(span.getOpType().toString()) + .description(span.getDescription()) + .happenedTime(new Date()) + .build(); + logRepository.save(auditLog); + } + + public List findByTraceId(String traceId) { + return logRepository.findByTraceIdOrderByDataChangeCreatedTimeDesc(traceId); + } + + public List findAll(int page, int size) { + Pageable pageable = pageSortByTime(page, size); + return logRepository.findAll(pageable).getContent(); + } + + public List findByOpName(String opName, int page, int size) { + Pageable pageable = pageSortByTime(page, size); + return logRepository.findByOpName(opName, pageable); + } + + public List findByOpNameAndTime(String opName, Date startDate, + Date endDate, int page, int size) { + Pageable pageable = pageSortByTime(page, size); + return logRepository.findByOpNameAndDataChangeCreatedTimeGreaterThanEqualAndDataChangeCreatedTimeLessThanEqual( + opName, startDate, endDate, pageable); + } + + public List searchLogByNameOrTypeOrOperator(String query, int page, int size) { + Pageable pageable = pageSortByTime(page, size); + return logRepository.findByOpNameContainingOrOpTypeContainingOrOperatorContaining(query, query, + query, pageable); + } + + Pageable pageSortByTime(int page, int size) { + return PageRequest.of(page, size, Sort.by(new Order(Direction.DESC, "dataChangeCreatedTime"))); + } + +} diff --git a/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/spi/ApolloAuditLogQueryApiPreAuthorizer.java b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/spi/ApolloAuditLogQueryApiPreAuthorizer.java new file mode 100644 index 00000000000..d0d3e89aea6 --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/spi/ApolloAuditLogQueryApiPreAuthorizer.java @@ -0,0 +1,23 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.spi; + +public interface ApolloAuditLogQueryApiPreAuthorizer { + + boolean hasQueryPermission(); + +} diff --git a/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/spi/ApolloAuditOperatorSupplier.java b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/spi/ApolloAuditOperatorSupplier.java new file mode 100644 index 00000000000..9ce1c2b6b06 --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/spi/ApolloAuditOperatorSupplier.java @@ -0,0 +1,23 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.spi; + +public interface ApolloAuditOperatorSupplier { + + String getOperator(); + +} diff --git a/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/spi/defaultimpl/ApolloAuditLogQueryApiDefaultPreAuthorizer.java b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/spi/defaultimpl/ApolloAuditLogQueryApiDefaultPreAuthorizer.java new file mode 100644 index 00000000000..6ab91300227 --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/spi/defaultimpl/ApolloAuditLogQueryApiDefaultPreAuthorizer.java @@ -0,0 +1,28 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.spi.defaultimpl; + +import com.ctrip.framework.apollo.audit.spi.ApolloAuditLogQueryApiPreAuthorizer; + +public class ApolloAuditLogQueryApiDefaultPreAuthorizer implements + ApolloAuditLogQueryApiPreAuthorizer { + + @Override + public boolean hasQueryPermission() { + return true; + } +} diff --git a/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/spi/defaultimpl/ApolloAuditOperatorDefaultSupplier.java b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/spi/defaultimpl/ApolloAuditOperatorDefaultSupplier.java new file mode 100644 index 00000000000..e52b2075c44 --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/spi/defaultimpl/ApolloAuditOperatorDefaultSupplier.java @@ -0,0 +1,41 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.spi.defaultimpl; + +import com.ctrip.framework.apollo.audit.constants.ApolloAuditConstants; +import com.ctrip.framework.apollo.audit.context.ApolloAuditTracer; +import com.ctrip.framework.apollo.audit.spi.ApolloAuditOperatorSupplier; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; + +public class ApolloAuditOperatorDefaultSupplier implements ApolloAuditOperatorSupplier { + + @Override + public String getOperator() { + RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); + if (requestAttributes != null) { + Object tracer = requestAttributes.getAttribute(ApolloAuditConstants.TRACER, + RequestAttributes.SCOPE_REQUEST); + if (tracer != null) { + return ((ApolloAuditTracer) tracer).scopeManager().activeSpan().operator(); + } else { + return null; + } + } + return null; + } +} diff --git a/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/util/ApolloAuditUtil.java b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/util/ApolloAuditUtil.java new file mode 100644 index 00000000000..8c8d36e4bc6 --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/util/ApolloAuditUtil.java @@ -0,0 +1,121 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.util; + +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLogDataInfluenceTable; +import com.ctrip.framework.apollo.audit.dto.ApolloAuditLogDTO; +import com.ctrip.framework.apollo.audit.dto.ApolloAuditLogDataInfluenceDTO; +import com.ctrip.framework.apollo.audit.entity.ApolloAuditLog; +import com.ctrip.framework.apollo.audit.entity.ApolloAuditLogDataInfluence; +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.UUID; +import java.util.stream.Collectors; +import javax.persistence.Id; + +public class ApolloAuditUtil { + + public static String generateId() { + return UUID.randomUUID().toString().replaceAll("-", ""); + } + + public static List getAnnotatedFields(Class annoClass, + Class clazz) { + return Arrays.stream(clazz.getDeclaredFields()) + .filter(field -> field.isAnnotationPresent(annoClass)).collect(Collectors.toList()); + } + + public static List toList(Object obj) { + if (obj instanceof Collection) { + Collection collection = (Collection) obj; + return new ArrayList<>(collection); + } else { + return Collections.singletonList(obj); + } + } + + public static String getApolloAuditLogTableName(Class clazz) { + return clazz.isAnnotationPresent(ApolloAuditLogDataInfluenceTable.class) ? clazz.getAnnotation( + ApolloAuditLogDataInfluenceTable.class).tableName() : null; + } + + public static Field getPersistenceIdFieldByAnnotation(Class clazz) { + while (clazz != null) { + Field[] fields = clazz.getDeclaredFields(); + for (Field field : fields) { + if (field.isAnnotationPresent(Id.class)) { + field.setAccessible(true); + return field; + } + } + clazz = clazz.getSuperclass(); + } + return null; + } + + public static ApolloAuditLogDTO logToDTO(ApolloAuditLog auditLog) { + ApolloAuditLogDTO dto = new ApolloAuditLogDTO(); + dto.setId(auditLog.getId()); + dto.setOpType(auditLog.getOpType()); + dto.setOpName(auditLog.getOpName()); + dto.setDescription(auditLog.getDescription()); + dto.setOperator(auditLog.getOperator()); + dto.setHappenedTime(auditLog.getDataChangeCreatedTime()); + dto.setSpanId(auditLog.getSpanId()); + dto.setTraceId(auditLog.getTraceId()); + dto.setFollowsFromSpanId(auditLog.getFollowsFromSpanId()); + dto.setParentSpanId(auditLog.getParentSpanId()); + return dto; + } + + public static ApolloAuditLogDataInfluenceDTO dataInfluenceToDTO( + ApolloAuditLogDataInfluence dataInfluence) { + ApolloAuditLogDataInfluenceDTO dto = new ApolloAuditLogDataInfluenceDTO(); + dto.setId(dataInfluence.getId()); + dto.setInfluenceEntityName(dataInfluence.getInfluenceEntityName()); + dto.setInfluenceEntityId(dataInfluence.getInfluenceEntityId()); + dto.setFieldName(dataInfluence.getFieldName()); + dto.setFieldOldValue(dataInfluence.getFieldOldValue()); + dto.setFieldNewValue(dataInfluence.getFieldNewValue()); + dto.setHappenedTime(dataInfluence.getDataChangeCreatedTime()); + dto.setSpanId(dataInfluence.getSpanId()); + return dto; + } + + public static List logListToDTOList(List logList) { + List logDTOList = new ArrayList<>(); + logList.forEach(log -> { + logDTOList.add(logToDTO(log)); + }); + return logDTOList; + } + + public static List dataInfluenceListToDTOList( + List dataInfluenceList) { + List dataInfluenceDTOList = new ArrayList<>(); + dataInfluenceList.forEach(dataInfluence -> { + dataInfluenceDTOList.add(dataInfluenceToDTO(dataInfluence)); + }); + return dataInfluenceDTOList; + } + +} diff --git a/apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/MockBeanFactory.java b/apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/MockBeanFactory.java new file mode 100644 index 00000000000..ca3b7da0e9a --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/MockBeanFactory.java @@ -0,0 +1,101 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit; + +import com.ctrip.framework.apollo.audit.dto.ApolloAuditLogDTO; +import com.ctrip.framework.apollo.audit.dto.ApolloAuditLogDataInfluenceDTO; +import com.ctrip.framework.apollo.audit.dto.ApolloAuditLogDetailsDTO; +import com.ctrip.framework.apollo.audit.entity.ApolloAuditLog; +import com.ctrip.framework.apollo.audit.entity.ApolloAuditLogDataInfluence; +import java.util.ArrayList; +import java.util.List; + +public class MockBeanFactory { + + public static ApolloAuditLogDTO mockAuditLogDTO() { + return new ApolloAuditLogDTO(); + } + + public static List mockAuditLogDTOListByLength(int length) { + List mockList = new ArrayList<>(); + for (int i = 0; i < length; i++) { + mockList.add(mockAuditLogDTO()); + } + return mockList; + } + + public static ApolloAuditLog mockAuditLog() { + return new ApolloAuditLog(); + } + + public static List mockAuditLogListByLength(int length) { + List mockList = new ArrayList<>(); + for (int i = 0; i < length; i++) { + mockList.add(mockAuditLog()); + } + return mockList; + } + + public static List mockTraceDetailsDTOListByLength(int length) { + List mockList = new ArrayList<>(); + for (int i = 0; i < length; i++) { + ApolloAuditLogDetailsDTO dto = new ApolloAuditLogDetailsDTO(); + dto.setLogDTO(mockAuditLogDTO()); + mockList.add(dto); + } + return mockList; + } + + public static ApolloAuditLogDataInfluenceDTO mockDataInfluenceDTO() { + return new ApolloAuditLogDataInfluenceDTO(); + } + + public static List mockDataInfluenceDTOListByLength(int length) { + List mockList = new ArrayList<>(); + for (int i = 0; i < length; i++) { + mockList.add(mockDataInfluenceDTO()); + } + return mockList; + } + + public static ApolloAuditLogDataInfluence mockDataInfluence() { + return new ApolloAuditLogDataInfluence(); + } + + public static List mockDataInfluenceListByLength(int length) { + List mockList = new ArrayList<>(); + for (int i = 0; i < length; i++) { + mockList.add(mockDataInfluence()); + } + return mockList; + } + + public static MockDataInfluenceEntity mockDataInfluenceEntity() { + return new MockDataInfluenceEntity(); + } + + public static List mockDataInfluenceEntityListByLength(int length) { + List mockList = new ArrayList<>(); + for (int i = 0; i < length; i++) { + MockDataInfluenceEntity e = mockDataInfluenceEntity(); + e.setId(i+1); + mockList.add(e); + } + return mockList; + } + +} diff --git a/apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/MockDataInfluenceEntity.java b/apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/MockDataInfluenceEntity.java new file mode 100644 index 00000000000..58ec8c97459 --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/MockDataInfluenceEntity.java @@ -0,0 +1,65 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit; + +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLogDataInfluenceTable; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLogDataInfluenceTableField; +import javax.persistence.Id; + +@ApolloAuditLogDataInfluenceTable(tableName = "MockTableName") +public class MockDataInfluenceEntity { + + @Id + private long id; + + @ApolloAuditLogDataInfluenceTableField(fieldName = "MarkedAttribute") + private String markedAttribute; + private String unMarkedAttribute; + private boolean isDeleted; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getMarkedAttribute() { + return markedAttribute; + } + + public void setMarkedAttribute(String markedAttribute) { + this.markedAttribute = markedAttribute; + } + + public String getUnMarkedAttribute() { + return unMarkedAttribute; + } + + public void setUnMarkedAttribute(String unMarkedAttribute) { + this.unMarkedAttribute = unMarkedAttribute; + } + + public boolean isDeleted() { + return isDeleted; + } + + public void setDeleted(boolean deleted) { + isDeleted = deleted; + } +} diff --git a/apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/aop/ApolloAuditSpanAspectTest.java b/apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/aop/ApolloAuditSpanAspectTest.java new file mode 100644 index 00000000000..310e95129e0 --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/aop/ApolloAuditSpanAspectTest.java @@ -0,0 +1,181 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.aop; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLog; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLogDataInfluence; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLogDataInfluenceTable; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLogDataInfluenceTableField; +import com.ctrip.framework.apollo.audit.annotation.OpType; +import com.ctrip.framework.apollo.audit.api.ApolloAuditLogApi; +import com.ctrip.framework.apollo.audit.constants.ApolloAuditConstants; +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.List; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.reflect.MethodSignature; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.boot.test.mock.mockito.SpyBean; +import org.springframework.test.context.ContextConfiguration; + +@SpringBootTest +@ContextConfiguration(classes = ApolloAuditSpanAspect.class) +public class ApolloAuditSpanAspectTest { + + @SpyBean + ApolloAuditSpanAspect aspect; + + @MockBean + ApolloAuditLogApi api; + + @Test + public void testAround() throws Throwable { + final OpType opType = OpType.CREATE; + final String opName = "App.create"; + final String description = "no description"; + + ProceedingJoinPoint mockPJP = mock(ProceedingJoinPoint.class); + ApolloAuditLog mockAnnotation = mock(ApolloAuditLog.class); + AutoCloseable mockScope = mock(AutoCloseable.class); + { + when(mockAnnotation.type()).thenReturn(opType); + when(mockAnnotation.name()).thenReturn(opName); + when(mockAnnotation.description()).thenReturn(description); + when(api.appendAuditLog(eq(opType), eq(opName), eq(description))) + .thenReturn(mockScope); + doNothing().when(aspect).auditDataInfluenceArg(mockPJP); + } + + aspect.around(mockPJP, mockAnnotation); + verify(api, times(1)) + .appendAuditLog(eq(opType), eq(opName), eq(description)); + verify(mockScope, times(1)) + .close(); + verify(aspect, times(1)) + .auditDataInfluenceArg(eq(mockPJP)); + } + + @Test + public void testAuditDataInfluenceArg() throws NoSuchMethodException { + ProceedingJoinPoint mockPJP = mock(ProceedingJoinPoint.class); + Object[] args = new Object[]{new Object(), new Object()}; + Method method = MockAuditClass.class.getMethod("mockAuditMethod", Object.class, Object.class); + { + doReturn(method).when(aspect).findMethod(any()); + when(mockPJP.getArgs()).thenReturn(args); + } + aspect.auditDataInfluenceArg(mockPJP); + verify(aspect, times(1)) + .parseArgAndAppend(eq("App"), eq("Name"), eq(args[0])); + } + + @Test + public void testAuditDataInfluenceArgCaseFindMethodReturnNull() throws NoSuchMethodException { + ProceedingJoinPoint mockPJP = mock(ProceedingJoinPoint.class); + Object[] args = new Object[]{new Object(), new Object()}; + { + doReturn(null).when(aspect).findMethod(any()); + when(mockPJP.getArgs()).thenReturn(args); + } + aspect.auditDataInfluenceArg(mockPJP); + verify(aspect, times(0)) + .parseArgAndAppend(eq("App"), eq("Name"), eq(args[0])); + } + + @Test + public void testFindMethod() throws NoSuchMethodException { + ProceedingJoinPoint mockPJP = mock(ProceedingJoinPoint.class); + MockAuditClass mockAuditClass = new MockAuditClass(); + MethodSignature signature = mock(MethodSignature.class); + Method method = MockAuditClass.class.getMethod("mockAuditMethod", Object.class, Object.class); + Method sameNameMethod = MockAuditClass.class.getMethod("mockAuditMethod", Object.class); + { + when(mockPJP.getTarget()).thenReturn(mockAuditClass); + when(mockPJP.getSignature()).thenReturn(signature); + when(signature.getName()).thenReturn("mockAuditMethod"); + when(signature.getParameterTypes()).thenReturn(new Class[]{Object.class, Object.class}); + } + Method methodFounded = aspect.findMethod(mockPJP); + + assertEquals(method, methodFounded); + assertNotEquals(sameNameMethod, methodFounded); + } + + @Test + public void testParseArgAndAppendCaseNullName() { + Object somewhat = new Object(); + aspect.parseArgAndAppend(null, null, somewhat); + verify(api, times(0)) + .appendDataInfluence(any(), any(), any(), any()); + } + + @Test + public void testParseArgAndAppendCaseCollectionTypeArg() { + final String entityName = "App"; + final String fieldName = "Name"; + List list = Arrays.asList(new Object(), new Object(), new Object()); + + { + doNothing().when(api).appendDataInfluence(any(), any(), any(), any()); + } + aspect.parseArgAndAppend(entityName, fieldName, list); + verify(api, times(list.size())).appendDataInfluence(eq(entityName), + eq(ApolloAuditConstants.ANY_MATCHED_ID), eq(fieldName), any()); + } + + @Test + public void testParseArgAndAppendCaseNormalTypeArg() { + final String entityName = "App"; + final String fieldName = "Name"; + Object arg = new Object(); + + { + doNothing().when(api).appendDataInfluence(any(), any(), any(), any()); + } + aspect.parseArgAndAppend(entityName, fieldName, arg); + verify(api, times(1)).appendDataInfluence(eq(entityName), + eq(ApolloAuditConstants.ANY_MATCHED_ID), eq(fieldName), any()); + } + + public class MockAuditClass { + + public void mockAuditMethod( + @ApolloAuditLogDataInfluence + @ApolloAuditLogDataInfluenceTable(tableName = "App") + @ApolloAuditLogDataInfluenceTableField(fieldName = "Name") Object val1, + Object val2) { + } + + // same name method test + public void mockAuditMethod( + Object val2) { + } + } +} diff --git a/apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/component/ApolloAuditHttpInterceptorTest.java b/apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/component/ApolloAuditHttpInterceptorTest.java new file mode 100644 index 00000000000..bcfce181cc3 --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/component/ApolloAuditHttpInterceptorTest.java @@ -0,0 +1,76 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.component; + +import com.ctrip.framework.apollo.audit.context.ApolloAuditTraceContext; +import com.ctrip.framework.apollo.audit.context.ApolloAuditTracer; +import com.ctrip.framework.apollo.audit.entity.ApolloAuditLogDataInfluence; +import java.io.IOException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.Mockito; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.boot.test.mock.mockito.SpyBean; +import org.springframework.http.HttpRequest; +import org.springframework.http.client.ClientHttpRequestExecution; +import org.springframework.test.context.ContextConfiguration; + +@SpringBootTest +@ContextConfiguration(classes = ApolloAuditHttpInterceptor.class) +public class ApolloAuditHttpInterceptorTest { + + @SpyBean + ApolloAuditHttpInterceptor interceptor; + + @MockBean + ApolloAuditTraceContext traceContext; + + @Test + public void testInterceptor() throws IOException { + ClientHttpRequestExecution execution = Mockito.mock(ClientHttpRequestExecution.class); + HttpRequest request = Mockito.mock(HttpRequest.class); + byte[] body = new byte[]{}; + ApolloAuditTracer tracer = Mockito.mock(ApolloAuditTracer.class); + HttpRequest mockInjected = Mockito.mock(HttpRequest.class); + + Mockito.when(traceContext.tracer()).thenReturn(tracer); + Mockito.when(tracer.inject(Mockito.eq(request))) + .thenReturn(mockInjected); + + interceptor.intercept(request, body, execution); + + Mockito.verify(execution, Mockito.times(1)) + .execute(Mockito.eq(mockInjected), Mockito.eq(body)); + } + + @Test + public void testInterceptorCaseNoTracer() throws IOException { + ClientHttpRequestExecution execution = Mockito.mock(ClientHttpRequestExecution.class); + HttpRequest request = Mockito.mock(HttpRequest.class); + byte[] body = new byte[]{}; + Mockito.when(traceContext.tracer()).thenReturn(null); + + interceptor.intercept(request, body, execution); + + Mockito.verify(execution, Mockito.times(1)) + .execute(Mockito.eq(request), Mockito.eq(body)); + } + +} diff --git a/apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/component/ApolloAuditLogApiJpaImplTest.java b/apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/component/ApolloAuditLogApiJpaImplTest.java new file mode 100644 index 00000000000..a3c8ac71cdb --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/component/ApolloAuditLogApiJpaImplTest.java @@ -0,0 +1,309 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.component; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import com.ctrip.framework.apollo.audit.MockBeanFactory; +import com.ctrip.framework.apollo.audit.MockDataInfluenceEntity; +import com.ctrip.framework.apollo.audit.annotation.OpType; +import com.ctrip.framework.apollo.audit.context.ApolloAuditScope; +import com.ctrip.framework.apollo.audit.context.ApolloAuditScopeManager; +import com.ctrip.framework.apollo.audit.context.ApolloAuditSpan; +import com.ctrip.framework.apollo.audit.context.ApolloAuditSpanContext; +import com.ctrip.framework.apollo.audit.context.ApolloAuditTraceContext; +import com.ctrip.framework.apollo.audit.context.ApolloAuditTracer; +import com.ctrip.framework.apollo.audit.dto.ApolloAuditLogDTO; +import com.ctrip.framework.apollo.audit.dto.ApolloAuditLogDataInfluenceDTO; +import com.ctrip.framework.apollo.audit.dto.ApolloAuditLogDetailsDTO; +import com.ctrip.framework.apollo.audit.entity.ApolloAuditLog; +import com.ctrip.framework.apollo.audit.entity.ApolloAuditLogDataInfluence; +import com.ctrip.framework.apollo.audit.service.ApolloAuditLogDataInfluenceService; +import com.ctrip.framework.apollo.audit.service.ApolloAuditLogService; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.Mockito; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.boot.test.mock.mockito.SpyBean; +import org.springframework.test.context.ContextConfiguration; + +@SpringBootTest +@ContextConfiguration(classes = ApolloAuditLogApiJpaImpl.class) +public class ApolloAuditLogApiJpaImplTest { + + // record api + + final OpType create = OpType.CREATE; + final OpType delete = OpType.DELETE; + final String opName = "test.create"; + final String traceId = "test-trace-id"; + final String spanId = "test-span-id"; + + final String entityId = "1"; + final String entityName = "App"; + final String fieldName = "name"; + final String fieldCurrentValue = "xxx"; + + final int entityNum = 3; + + // query api + + final int page = 0; + final int size = 10; + + @SpyBean + ApolloAuditLogApiJpaImpl api; + + @MockBean + ApolloAuditLogService logService; + @MockBean + ApolloAuditLogDataInfluenceService dataInfluenceService; + @MockBean + ApolloAuditTraceContext traceContext; + @MockBean + ApolloAuditTracer tracer; + + @Captor + private ArgumentCaptor influenceCaptor; + + @BeforeEach + void beforeEach() { + Mockito.reset(traceContext, tracer); + Mockito.when(traceContext.tracer()).thenReturn(tracer); + } + + @Test + public void testAppendAuditLog() { + final String description = "no description"; + { + ApolloAuditSpan activeSpan = new ApolloAuditSpan(); + activeSpan.setOpType(create); + activeSpan.setOpName(opName); + activeSpan.setContext(new ApolloAuditSpanContext(traceId, spanId)); + ApolloAuditScopeManager manager = new ApolloAuditScopeManager(); + ApolloAuditScope scope = new ApolloAuditScope(activeSpan, manager); + + Mockito.when(tracer.startActiveSpan(Mockito.eq(create), Mockito.eq(opName), Mockito.eq(description))) + .thenReturn(scope); + } + ApolloAuditScope scope = (ApolloAuditScope) api.appendAuditLog(create, opName); + + Mockito.verify(traceContext, Mockito.times(1)).tracer(); + Mockito.verify(tracer, Mockito.times(1)) + .startActiveSpan(Mockito.eq(create), Mockito.eq(opName), Mockito.eq(description)); + + assertEquals(create, scope.activeSpan().getOpType()); + assertEquals(opName, scope.activeSpan().getOpName()); + assertEquals(traceId, scope.activeSpan().traceId()); + assertEquals(spanId, scope.activeSpan().spanId()); + } + + @Test + public void testAppendDataInfluenceCaseCreateOrUpdate() { + { + ApolloAuditSpan span = Mockito.mock(ApolloAuditSpan.class); + Mockito.when(tracer.getActiveSpan()).thenReturn(span); + Mockito.when(span.spanId()).thenReturn(spanId); + Mockito.when(span.getOpType()).thenReturn(create); + } + + api.appendDataInfluence(entityName, entityId, fieldName, fieldCurrentValue); + + Mockito.verify(dataInfluenceService, Mockito.times(1)).save(influenceCaptor.capture()); + + ApolloAuditLogDataInfluence capturedInfluence = influenceCaptor.getValue(); + assertEquals(entityId, capturedInfluence.getInfluenceEntityId()); + assertEquals(entityName, capturedInfluence.getInfluenceEntityName()); + assertEquals(fieldName, capturedInfluence.getFieldName()); + assertNull(capturedInfluence.getFieldOldValue()); + assertEquals(fieldCurrentValue, capturedInfluence.getFieldNewValue()); + assertEquals(spanId, capturedInfluence.getSpanId()); + } + + @Test + public void testAppendDataInfluenceCaseDelete() { + { + ApolloAuditSpan span = Mockito.mock(ApolloAuditSpan.class); + Mockito.when(tracer.getActiveSpan()).thenReturn(span); + Mockito.when(span.spanId()).thenReturn(spanId); + Mockito.when(span.getOpType()).thenReturn(delete); + } + + api.appendDataInfluence(entityName, entityId, fieldName, fieldCurrentValue); + + Mockito.verify(dataInfluenceService, Mockito.times(1)).save(influenceCaptor.capture()); + + ApolloAuditLogDataInfluence capturedInfluence = influenceCaptor.getValue(); + assertEquals(entityId, capturedInfluence.getInfluenceEntityId()); + assertEquals(entityName, capturedInfluence.getInfluenceEntityName()); + assertEquals(fieldName, capturedInfluence.getFieldName()); + assertEquals(fieldCurrentValue, capturedInfluence.getFieldOldValue()); + assertNull(capturedInfluence.getFieldNewValue()); + assertEquals(spanId, capturedInfluence.getSpanId()); + } + + @Test + public void testAppendDataInfluenceCaseTracerIsNull() { + Mockito.when(traceContext.tracer()).thenReturn(null); + api.appendDataInfluence(entityName, entityId, fieldName, fieldCurrentValue); + Mockito.verify(traceContext, Mockito.times(1)).tracer(); + } + + @Test + public void testAppendDataInfluenceCaseActiveSpanIsNull() { + Mockito.when(tracer.getActiveSpan()).thenReturn(null); + api.appendDataInfluence(entityName, entityId, fieldName, fieldCurrentValue); + Mockito.verify(traceContext, Mockito.times(2)).tracer(); + Mockito.verify(tracer, Mockito.times(1)).getActiveSpan(); + } + + @Test + public void testAppendDataInfluences() { + List entities = MockBeanFactory.mockDataInfluenceEntityListByLength(entityNum); + api.appendDataInfluences(entities, MockDataInfluenceEntity.class); + + Mockito.verify(api, Mockito.times(entityNum)) + .appendDataInfluence(Mockito.eq("MockTableName"), Mockito.any(), Mockito.eq("MarkedAttribute"), + Mockito.any()); + } + + @Test + public void testAppendDataInfluencesCaseWrongBeanDefinition() { + List entities = new ArrayList<>(); + entities.add(new Object()); + assertThrows(IllegalArgumentException.class, () -> { + api.appendDataInfluences(entities, MockDataInfluenceEntity.class); + }); + + } + + @Test + public void testAppendDataInfluencesCaseIncompleteConditions() { + List entities = new ArrayList<>(entityNum); + + api.appendDataInfluences(entities, Object.class); + + Mockito.verify(api, Mockito.times(0)) + .appendDataInfluence(Mockito.any(), Mockito.any(), + Mockito.any(), Mockito.any()); + } + + + + @Test + public void testQueryLogs() { + { + List logList = MockBeanFactory.mockAuditLogListByLength(size); + Mockito.when(logService.findAll(Mockito.eq(page), Mockito.eq(size))) + .thenReturn(logList); + } + + List dtoList = api.queryLogs(page, size); + Mockito.verify(logService, Mockito.times(1)) + .findAll(Mockito.eq(page), Mockito.eq(size)); + assertEquals(size, dtoList.size()); + } + + @Test + public void testQueryLogsByOpNameCaseDateIsNull() { + final String opName = "query-op-name"; + final Date startDate = null; + final Date endDate = null; + { + List logList = MockBeanFactory.mockAuditLogListByLength(size); + Mockito.when(logService.findByOpName(Mockito.eq(opName), Mockito.eq(page), Mockito.eq(size))) + .thenReturn(logList); + } + + List dtoList = api.queryLogsByOpName(opName, startDate, endDate, page, size); + Mockito.verify(logService, Mockito.times(1)) + .findByOpName(Mockito.eq(opName), Mockito.eq(page), Mockito.eq(size)); + assertEquals(size, dtoList.size()); + } + + @Test + public void testQueryLogsByOpName() { + final String opName = "query-op-name"; + final Date startDate = new Date(); + final Date endDate = new Date(); + { + List logList = MockBeanFactory.mockAuditLogListByLength(size); + Mockito.when(logService.findByOpNameAndTime(Mockito.eq(opName), + Mockito.eq(startDate), Mockito.eq(endDate), Mockito.eq(page), Mockito.eq(size))) + .thenReturn(logList); + } + + List dtoList = api.queryLogsByOpName(opName, startDate, endDate, page, size); + Mockito.verify(logService, Mockito.times(1)) + .findByOpNameAndTime(Mockito.eq(opName), + Mockito.eq(startDate), Mockito.eq(endDate), Mockito.eq(page), Mockito.eq(size)); + assertEquals(size, dtoList.size()); + } + + @Test + public void testQueryTraceDetails() { + final String traceId = "query-trace-id"; + final int traceDetailsLength = 3; + final int dataInfluenceOfEachLog = 3; + { + List logList = MockBeanFactory.mockAuditLogListByLength(traceDetailsLength); + Mockito.when(logService.findByTraceId(Mockito.eq(traceId))) + .thenReturn(logList); + List dataInfluenceList = + MockBeanFactory.mockDataInfluenceListByLength(dataInfluenceOfEachLog); + Mockito.when(dataInfluenceService.findBySpanId(Mockito.any())) + .thenReturn(dataInfluenceList); + } + + List detailsDTOList = api.queryTraceDetails(traceId); + + Mockito.verify(logService, Mockito.times(1)) + .findByTraceId(Mockito.eq(traceId)); + Mockito.verify(dataInfluenceService, Mockito.times(3)) + .findBySpanId(Mockito.any()); + + assertEquals(traceDetailsLength, detailsDTOList.size()); + assertEquals(dataInfluenceOfEachLog, detailsDTOList.get(0).getDataInfluenceDTOList().size()); + } + + @Test + public void testQueryDataInfluencesByField() { + final String entityName = "App"; + final String entityId = "1"; + final String fieldName = "xxx"; + { + List dataInfluenceList = MockBeanFactory.mockDataInfluenceListByLength(size); + Mockito.when(dataInfluenceService.findByEntityNameAndEntityIdAndFieldName(Mockito.eq(entityName), + Mockito.eq(entityId), Mockito.eq(fieldName), Mockito.eq(page), Mockito.eq(size))) + .thenReturn(dataInfluenceList); + } + + List dtoList = api.queryDataInfluencesByField(entityName, entityId, fieldName, page, size); + Mockito.verify(dataInfluenceService, Mockito.times(1)) + .findByEntityNameAndEntityIdAndFieldName(Mockito.eq(entityName), + Mockito.eq(entityId), Mockito.eq(fieldName), Mockito.eq(page), Mockito.eq(size)); + assertEquals(size, dtoList.size()); + } +} diff --git a/apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/component/ApolloAuditScopeManagerTest.java b/apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/component/ApolloAuditScopeManagerTest.java new file mode 100644 index 00000000000..a8f04096291 --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/component/ApolloAuditScopeManagerTest.java @@ -0,0 +1,48 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.component; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + +import com.ctrip.framework.apollo.audit.context.ApolloAuditScope; +import com.ctrip.framework.apollo.audit.context.ApolloAuditScopeManager; +import com.ctrip.framework.apollo.audit.context.ApolloAuditSpan; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.SpyBean; +import org.springframework.test.context.ContextConfiguration; + +@SpringBootTest +@ContextConfiguration(classes = ApolloAuditScopeManager.class) +public class ApolloAuditScopeManagerTest { + + @SpyBean + ApolloAuditScopeManager manager; + + @Test + public void testActivate() { + ApolloAuditSpan mockSpan = mock(ApolloAuditSpan.class); + ApolloAuditScope activeScope = manager.activate(mockSpan); + + verify(manager).setScope(eq(activeScope)); + assertEquals(mockSpan, activeScope.activeSpan()); + } + +} diff --git a/apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/context/ApolloAuditTraceContextTest.java b/apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/context/ApolloAuditTraceContextTest.java new file mode 100644 index 00000000000..791a32cd433 --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/context/ApolloAuditTraceContextTest.java @@ -0,0 +1,120 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.context; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; + +import com.ctrip.framework.apollo.audit.constants.ApolloAuditConstants; +import com.ctrip.framework.apollo.audit.spi.ApolloAuditOperatorSupplier; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.Executors; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.boot.test.mock.mockito.SpyBean; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; + +@SpringBootTest +@ContextConfiguration(classes = ApolloAuditTraceContext.class) +public class ApolloAuditTraceContextTest { + + @SpyBean + ApolloAuditTraceContext traceContext; + + @MockBean + ApolloAuditOperatorSupplier supplier; + + @BeforeEach + public void beforeEach() { + // will be null of each unit-test begin + RequestContextHolder.resetRequestAttributes(); + Mockito.reset( + traceContext + ); + } + + @Test + public void testGetTracerNotInRequestThread() { + ApolloAuditTracer get = traceContext.tracer(); + assertNull(get); + } + + @Test + public void testGetTracerCaseNoTracerExistsInRequestThreads() { + RequestAttributes mockRequestAttributes = Mockito.mock(RequestAttributes.class); + RequestContextHolder.setRequestAttributes(mockRequestAttributes); + + ApolloAuditTracer get = traceContext.tracer(); + assertNotNull(get); + Mockito.verify(traceContext, Mockito.times(1)) + .setTracer(Mockito.any(ApolloAuditTracer.class)); + } + + @Test + public void testGetTracerInRequestThreads() { + ApolloAuditTracer mockTracer = new ApolloAuditTracer(Mockito.mock(ApolloAuditScopeManager.class), supplier); + RequestAttributes mockRequestAttributes = Mockito.mock(RequestAttributes.class); + RequestContextHolder.setRequestAttributes(mockRequestAttributes); + Mockito.when(mockRequestAttributes.getAttribute(Mockito.eq(ApolloAuditConstants.TRACER), Mockito.eq(RequestAttributes.SCOPE_REQUEST))) + .thenReturn(mockTracer); + ApolloAuditTracer get = traceContext.tracer(); + assertNotNull(get); + Mockito.verify(traceContext, Mockito.times(0)) + .setTracer(Mockito.any(ApolloAuditTracer.class)); + } + + @Test + public void testGetTracerInAnotherThreadButSameRequest() { + ApolloAuditTracer mockTracer = Mockito.mock(ApolloAuditTracer.class); + { + Mockito.when(traceContext.tracer()).thenReturn(mockTracer); + } + CountDownLatch latch = new CountDownLatch(1); + Executors.newSingleThreadExecutor().submit(() -> { + ApolloAuditTracer tracer = traceContext.tracer(); + + assertEquals(mockTracer, tracer); + + latch.countDown(); + }); + } + + @Test + public void testGetTracerInAnotherRequest() { + ApolloAuditTracer mockTracer = Mockito.mock(ApolloAuditTracer.class); + { + Mockito.when(traceContext.tracer()).thenReturn(mockTracer); + } + CountDownLatch latch = new CountDownLatch(1); + Executors.newSingleThreadExecutor().submit(() -> { + RequestContextHolder.resetRequestAttributes(); + ApolloAuditTracer tracer = traceContext.tracer(); + + assertNotEquals(mockTracer, tracer); + + latch.countDown(); + }); + } + +} diff --git a/apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/context/ApolloAuditTracerTest.java b/apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/context/ApolloAuditTracerTest.java new file mode 100644 index 00000000000..6742fddb094 --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/context/ApolloAuditTracerTest.java @@ -0,0 +1,251 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.context; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.times; + +import com.ctrip.framework.apollo.audit.annotation.OpType; +import com.ctrip.framework.apollo.audit.constants.ApolloAuditConstants; +import com.ctrip.framework.apollo.audit.spi.ApolloAuditOperatorSupplier; +import javax.servlet.http.HttpServletRequest; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.boot.test.mock.mockito.SpyBean; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpRequest; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +@SpringBootTest +@ContextConfiguration(classes = ApolloAuditTracer.class) +public class ApolloAuditTracerTest { + + final OpType opType = OpType.CREATE; + final String opName = "create"; + final String description = "description"; + + final String activeTraceId = "10001"; + final String activeSpanId = "100010001"; + final String operator = "luke"; + + @SpyBean + ApolloAuditTracer tracer; + + @MockBean + ApolloAuditScopeManager manager; + @MockBean + ApolloAuditOperatorSupplier supplier; + + @BeforeEach + public void beforeEach() { + RequestContextHolder.resetRequestAttributes(); + Mockito.reset( + tracer, + manager, + supplier + ); + } + + @Test + public void testInject() { + + HttpRequest mockRequest = Mockito.mock(HttpRequest.class); + { + ApolloAuditSpan activeSpan = Mockito.mock(ApolloAuditSpan.class); + Mockito.when(manager.activeSpan()).thenReturn(activeSpan); + Mockito.when(mockRequest.getHeaders()).thenReturn(new HttpHeaders()); + } + HttpRequest injected = tracer.inject(mockRequest); + + HttpHeaders headers = injected.getHeaders(); + assertNotNull(headers.get(ApolloAuditConstants.TRACE_ID)); + assertNotNull(headers.get(ApolloAuditConstants.SPAN_ID)); + assertNotNull(headers.get(ApolloAuditConstants.OPERATOR)); + assertNotNull(headers.get(ApolloAuditConstants.PARENT_ID)); + assertNotNull(headers.get(ApolloAuditConstants.FOLLOWS_FROM_ID)); + } + + @Test + public void testInjectCaseActiveSpanIsNull() { + HttpRequest mockRequest = Mockito.mock(HttpRequest.class); + { + Mockito.when(manager.activeSpan()).thenReturn(null); + Mockito.when(mockRequest.getHeaders()).thenReturn(new HttpHeaders()); + } + HttpRequest injected = tracer.inject(mockRequest); + + HttpHeaders headers = injected.getHeaders(); + assertNull(headers.get(ApolloAuditConstants.TRACE_ID)); + assertNull(headers.get(ApolloAuditConstants.SPAN_ID)); + assertNull(headers.get(ApolloAuditConstants.OPERATOR)); + assertNull(headers.get(ApolloAuditConstants.PARENT_ID)); + assertNull(headers.get(ApolloAuditConstants.FOLLOWS_FROM_ID)); + } + + @Test + public void testStartSpanCaseActiveSpanExistsAndNoFollowsFrom() { + { + // has parent span + ApolloAuditSpan activeSpan = Mockito.mock(ApolloAuditSpan.class); + Mockito.when(tracer.getActiveSpan()).thenReturn(activeSpan); + Mockito.when(activeSpan.traceId()).thenReturn(activeTraceId); + Mockito.when(activeSpan.spanId()).thenReturn(activeSpanId); + Mockito.when(activeSpan.operator()).thenReturn(operator); + // not follows from any span + ApolloAuditScope mockScope = Mockito.mock(ApolloAuditScope.class); + Mockito.when(manager.getScope()).thenReturn(mockScope); + Mockito.when(mockScope.getLastSpanId()).thenReturn(null); + } + + ApolloAuditSpan build = tracer.startSpan(opType, opName, description); + + assertEquals(opType, build.getOpType()); + assertEquals(opName, build.getOpName()); + assertEquals(description, build.getDescription()); + assertEquals(activeTraceId, build.traceId()); + assertEquals(activeSpanId, build.parentId()); + assertEquals(operator, build.operator()); + assertNotNull(build.spanId()); + assertNull(build.followsFromId()); + } + + @Test + public void testStartSpanCaseActiveSpanExistsAndHasFollowsFrom() { + final String followsFromSpanId = "100010000"; + { + // has parent span + ApolloAuditSpan activeSpan = Mockito.mock(ApolloAuditSpan.class); + Mockito.when(tracer.getActiveSpan()).thenReturn(activeSpan); + Mockito.when(activeSpan.traceId()).thenReturn(activeTraceId); + Mockito.when(activeSpan.spanId()).thenReturn(activeSpanId); + Mockito.when(activeSpan.operator()).thenReturn(operator); + // has follows from span + ApolloAuditScope mockScope = Mockito.mock(ApolloAuditScope.class); + Mockito.when(manager.getScope()).thenReturn(mockScope); + Mockito.when(mockScope.getLastSpanId()).thenReturn(followsFromSpanId); + } + + ApolloAuditSpan build = tracer.startSpan(opType, opName, description); + + assertEquals(opType, build.getOpType()); + assertEquals(opName, build.getOpName()); + assertEquals(description, build.getDescription()); + assertEquals(activeTraceId, build.traceId()); + assertEquals(activeSpanId, build.parentId()); + assertEquals(operator, build.operator()); + assertNotNull(build.spanId()); + assertEquals(followsFromSpanId, build.followsFromId()); + } + + @Test + public void testStartSpanCaseNoActiveSpanExists() { + { + // no parent span + Mockito.when(tracer.getActiveSpan()).thenReturn(null); + // is the origin of a trace, need to get operator + Mockito.when(supplier.getOperator()).thenReturn(operator); + // of course no scope at this time + Mockito.when(manager.getScope()).thenReturn(null); + } + + ApolloAuditSpan build = tracer.startSpan(opType, opName, description); + + assertEquals(opType, build.getOpType()); + assertEquals(opName, build.getOpName()); + assertEquals(description, build.getDescription()); + assertNotNull(build.traceId()); + assertNotNull(build.spanId()); + assertNull(build.parentId()); + assertEquals(operator, build.operator()); + assertNull(build.followsFromId()); + } + + @Test + public void testStartActiveSpan() { + ApolloAuditSpan activeSpan = Mockito.mock(ApolloAuditSpan.class); + { + doReturn(activeSpan).when(tracer).startSpan(Mockito.eq(opType), Mockito.eq(opName), Mockito.eq(description)); + } + tracer.startActiveSpan(opType, opName, description); + Mockito.verify(tracer, Mockito.times(1)) + .startSpan(Mockito.eq(opType), Mockito.eq(opName), Mockito.eq(description)); + Mockito.verify(manager, times(1)) + .activate(Mockito.eq(activeSpan)); + } + + @Test + public void testGetActiveSpanFromContext() { + ApolloAuditSpan activeSpan = Mockito.mock(ApolloAuditSpan.class); + { + Mockito.when(manager.activeSpan()).thenReturn(activeSpan); + } + ApolloAuditSpan get = tracer.getActiveSpan(); + assertEquals(activeSpan, get); + } + + @Test + public void testGetActiveSpanFromHttpRequestCaseNotInRequestThread() { + { + // no span would be in context + Mockito.when(manager.activeSpan()).thenReturn(null); + // not in request thread + } + ApolloAuditSpan get = tracer.getActiveSpan(); + assertNull(get); + } + + @Test + public void testGetActiveSpanFromHttpRequestCaseInRequestThread() { + final String httpParentId = "100010002"; + final String httpFollowsFromId = "100010003"; + { + // no span would be in context + Mockito.when(manager.activeSpan()).thenReturn(null); + // in request thread + HttpServletRequest request = Mockito.mock(HttpServletRequest.class); + RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request)); + Mockito.when(request.getHeader(Mockito.eq(ApolloAuditConstants.TRACE_ID))) + .thenReturn(activeTraceId); + Mockito.when(request.getHeader(Mockito.eq(ApolloAuditConstants.SPAN_ID))) + .thenReturn(activeSpanId); + Mockito.when(request.getHeader(Mockito.eq(ApolloAuditConstants.OPERATOR))) + .thenReturn(operator); + Mockito.when(request.getHeader(Mockito.eq(ApolloAuditConstants.PARENT_ID))) + .thenReturn(httpParentId); + Mockito.when(request.getHeader(Mockito.eq(ApolloAuditConstants.FOLLOWS_FROM_ID))) + .thenReturn(httpFollowsFromId); + } + ApolloAuditSpan get = tracer.getActiveSpan(); + assertEquals(activeTraceId, get.traceId()); + assertEquals(activeSpanId, get.spanId()); + assertEquals(operator, get.operator()); + assertEquals(httpParentId, get.parentId()); + assertEquals(httpFollowsFromId, get.followsFromId()); + + assertNull(get.getOpType()); + assertNull(get.getOpName()); + } + +} diff --git a/apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/controller/ApolloAuditControllerTest.java b/apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/controller/ApolloAuditControllerTest.java new file mode 100644 index 00000000000..dd21bbe9728 --- /dev/null +++ b/apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/controller/ApolloAuditControllerTest.java @@ -0,0 +1,159 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.controller; + +import com.ctrip.framework.apollo.audit.ApolloAuditProperties; +import com.ctrip.framework.apollo.audit.MockBeanFactory; +import com.ctrip.framework.apollo.audit.api.ApolloAuditLogApi; +import com.ctrip.framework.apollo.audit.dto.ApolloAuditLogDTO; +import com.ctrip.framework.apollo.audit.dto.ApolloAuditLogDataInfluenceDTO; +import com.ctrip.framework.apollo.audit.dto.ApolloAuditLogDetailsDTO; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.List; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.test.web.servlet.result.MockMvcResultMatchers; + +@WebMvcTest +@ContextConfiguration(classes = ApolloAuditController.class) +public class ApolloAuditControllerTest { + + final int page = 0; + final int size = 10; + @Autowired + ApolloAuditController apolloAuditController; + @Autowired + private MockMvc mockMvc; + @MockBean + private ApolloAuditLogApi api; + @MockBean + private ApolloAuditProperties properties; + + @Test + public void testFindAllAuditLogs() throws Exception { + + { + List mockLogDTOList = MockBeanFactory.mockAuditLogDTOListByLength(size); + Mockito.when(api.queryLogs(Mockito.eq(page), Mockito.eq(size))).thenReturn(mockLogDTOList); + } + + mockMvc.perform(MockMvcRequestBuilders.get("/apollo/audit/logs") + .param("page", String.valueOf(page)) + .param("size", String.valueOf(size))) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andExpect(MockMvcResultMatchers.jsonPath("$").isArray()) + .andExpect(MockMvcResultMatchers.jsonPath("$.length()").value(size)); + + Mockito.verify(api, Mockito.times(1)).queryLogs(Mockito.eq(page), Mockito.eq(size)); + } + + @Test + public void testFindTraceDetails() throws Exception { + final String traceId = "query-trace-id"; + final int traceDetailsListLength = 3; + { + List mockDetailsDTOList = MockBeanFactory.mockTraceDetailsDTOListByLength( + traceDetailsListLength); + mockDetailsDTOList.forEach(e -> e.getLogDTO().setTraceId(traceId)); + Mockito.when(api.queryTraceDetails(Mockito.eq(traceId))).thenReturn(mockDetailsDTOList); + } + + mockMvc.perform(MockMvcRequestBuilders.get("/apollo/audit/trace") + .param("traceId", traceId)) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andExpect(MockMvcResultMatchers.jsonPath("$").isArray()) + .andExpect(MockMvcResultMatchers.jsonPath("$.length()").value(traceDetailsListLength)) + .andExpect(MockMvcResultMatchers.jsonPath("$[0].logDTO.traceId").value(traceId)); + + Mockito.verify(api, Mockito.times(1)).queryTraceDetails(Mockito.eq(traceId)); + } + + @Test + public void testFindAllAuditLogsByOpNameAndTime() throws Exception { + final String opName = "query-op-name"; + final Date startDate = new Date(2023, Calendar.OCTOBER, 15); + final Date endDate = new Date(2023, Calendar.OCTOBER, 16); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); + + { + List mockLogDTOList = MockBeanFactory.mockAuditLogDTOListByLength(size); + mockLogDTOList.forEach(e -> { + e.setOpName(opName); + }); + Mockito.when( + api.queryLogsByOpName(Mockito.eq(opName), Mockito.eq(startDate), Mockito.eq(endDate), + Mockito.eq(page), Mockito.eq(size))).thenReturn(mockLogDTOList); + } + + mockMvc.perform(MockMvcRequestBuilders.get("/apollo/audit/logs/opName").param("opName", opName) + .param("startDate", sdf.format(startDate)) + .param("endDate", sdf.format(endDate)) + .param("page", String.valueOf(page)) + .param("size", String.valueOf(size))) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andExpect(MockMvcResultMatchers.jsonPath("$").isArray()) + .andExpect(MockMvcResultMatchers.jsonPath("$.length()").value(size)) + .andExpect(MockMvcResultMatchers.jsonPath("$.[0].opName").value(opName)); + + Mockito.verify(api, Mockito.times(1)) + .queryLogsByOpName(Mockito.eq(opName), Mockito.eq(startDate), Mockito.eq(endDate), + Mockito.eq(page), Mockito.eq(size)); + } + + @Test + public void testFindDataInfluencesByField() throws Exception { + final String entityName = "query-entity-name"; + final String entityId = "query-entity-id"; + final String fieldName = "query-field-name"; + { + List mockDataInfluenceDTOList = MockBeanFactory.mockDataInfluenceDTOListByLength( + size); + mockDataInfluenceDTOList.forEach(e -> { + e.setInfluenceEntityName(entityName); + e.setInfluenceEntityId(entityId); + e.setFieldName(fieldName); + }); + Mockito.when(api.queryDataInfluencesByField(Mockito.eq(entityName), Mockito.eq(entityId), + Mockito.eq(fieldName), Mockito.eq(page), Mockito.eq(size))) + .thenReturn(mockDataInfluenceDTOList); + } + + mockMvc.perform(MockMvcRequestBuilders.get("/apollo/audit/logs/dataInfluences/field") + .param("entityName", entityName) + .param("entityId", entityId) + .param("fieldName", fieldName) + .param("page", String.valueOf(page)) + .param("size", String.valueOf(size))) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andExpect(MockMvcResultMatchers.jsonPath("$").isArray()) + .andExpect(MockMvcResultMatchers.jsonPath("$.length()").value(size)); + + Mockito.verify(api, Mockito.times(1)) + .queryDataInfluencesByField(Mockito.eq(entityName), Mockito.eq(entityId), + Mockito.eq(fieldName), Mockito.eq(page), Mockito.eq(size)); + } + + +} diff --git a/apollo-audit/apollo-audit-spring-boot-starter/pom.xml b/apollo-audit/apollo-audit-spring-boot-starter/pom.xml new file mode 100644 index 00000000000..e6729d37a08 --- /dev/null +++ b/apollo-audit/apollo-audit-spring-boot-starter/pom.xml @@ -0,0 +1,43 @@ + + + + + apollo-audit + com.ctrip.framework.apollo + ${revision} + + 4.0.0 + + apollo-audit-spring-boot-starter + ${revision} + + + + com.ctrip.framework.apollo + apollo-audit-impl + + third party<--> + + org.springframework.boot + spring-boot-autoconfigure + + + + \ No newline at end of file diff --git a/apollo-audit/apollo-audit-spring-boot-starter/src/main/java/com/ctrip/framework/apollo/audit/configuration/ApolloAuditAutoConfiguration.java b/apollo-audit/apollo-audit-spring-boot-starter/src/main/java/com/ctrip/framework/apollo/audit/configuration/ApolloAuditAutoConfiguration.java new file mode 100644 index 00000000000..4770b1c6c67 --- /dev/null +++ b/apollo-audit/apollo-audit-spring-boot-starter/src/main/java/com/ctrip/framework/apollo/audit/configuration/ApolloAuditAutoConfiguration.java @@ -0,0 +1,117 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.configuration; + +import com.ctrip.framework.apollo.audit.ApolloAuditProperties; +import com.ctrip.framework.apollo.audit.ApolloAuditRegistrar; +import com.ctrip.framework.apollo.audit.aop.ApolloAuditSpanAspect; +import com.ctrip.framework.apollo.audit.api.ApolloAuditLogApi; +import com.ctrip.framework.apollo.audit.component.ApolloAuditHttpInterceptor; +import com.ctrip.framework.apollo.audit.component.ApolloAuditLogApiJpaImpl; +import com.ctrip.framework.apollo.audit.context.ApolloAuditTraceContext; +import com.ctrip.framework.apollo.audit.controller.ApolloAuditController; +import com.ctrip.framework.apollo.audit.listener.ApolloAuditLogDataInfluenceEventListener; +import com.ctrip.framework.apollo.audit.repository.ApolloAuditLogDataInfluenceRepository; +import com.ctrip.framework.apollo.audit.repository.ApolloAuditLogRepository; +import com.ctrip.framework.apollo.audit.service.ApolloAuditLogDataInfluenceService; +import com.ctrip.framework.apollo.audit.service.ApolloAuditLogService; +import com.ctrip.framework.apollo.audit.spi.ApolloAuditLogQueryApiPreAuthorizer; +import com.ctrip.framework.apollo.audit.spi.ApolloAuditOperatorSupplier; +import com.ctrip.framework.apollo.audit.spi.defaultimpl.ApolloAuditLogQueryApiDefaultPreAuthorizer; +import com.ctrip.framework.apollo.audit.spi.defaultimpl.ApolloAuditOperatorDefaultSupplier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; + +@Configuration +@EnableConfigurationProperties(ApolloAuditProperties.class) +@Import(ApolloAuditRegistrar.class) +@ConditionalOnProperty(prefix = "apollo.audit.log", name = "enabled", havingValue = "true") +public class ApolloAuditAutoConfiguration { + + private static final Logger logger = LoggerFactory.getLogger(ApolloAuditAutoConfiguration.class); + + private final ApolloAuditProperties apolloAuditProperties; + + public ApolloAuditAutoConfiguration(ApolloAuditProperties apolloAuditProperties) { + this.apolloAuditProperties = apolloAuditProperties; + logger.info("ApolloAuditAutoConfigure initializing..."); + } + + @Bean + public ApolloAuditLogDataInfluenceService apolloAuditLogDataInfluenceService( + ApolloAuditLogDataInfluenceRepository dataInfluenceRepository) { + return new ApolloAuditLogDataInfluenceService(dataInfluenceRepository); + } + + @Bean + public ApolloAuditLogService apolloAuditLogService(ApolloAuditLogRepository logRepository) { + return new ApolloAuditLogService(logRepository); + } + + @Bean + @ConditionalOnMissingBean(ApolloAuditOperatorSupplier.class) + public ApolloAuditOperatorSupplier apolloAuditLogOperatorSupplier() { + return new ApolloAuditOperatorDefaultSupplier(); + } + + @Bean + public ApolloAuditTraceContext apolloAuditTraceContext( + ApolloAuditOperatorSupplier apolloAuditLogOperatorSupplier) { + return new ApolloAuditTraceContext(apolloAuditLogOperatorSupplier); + } + + @Bean + public ApolloAuditLogApi apolloAuditLogApi(ApolloAuditLogService logService, + ApolloAuditLogDataInfluenceService dataInfluenceService, + ApolloAuditTraceContext apolloAuditTraceContext) { + return new ApolloAuditLogApiJpaImpl(logService, dataInfluenceService, apolloAuditTraceContext); + } + + @Bean + public ApolloAuditSpanAspect apolloAuditSpanAspect(ApolloAuditLogApi apolloAuditLogApi) { + return new ApolloAuditSpanAspect(apolloAuditLogApi); + } + + @Bean + public ApolloAuditHttpInterceptor apolloAuditHttpInterceptor( + ApolloAuditTraceContext traceContext) { + return new ApolloAuditHttpInterceptor(traceContext); + } + + @Bean(name = "apolloAuditLogQueryApiPreAuthorizer") + @ConditionalOnMissingBean(ApolloAuditLogQueryApiPreAuthorizer.class) + public ApolloAuditLogQueryApiPreAuthorizer apolloAuditLogQueryApiPreAuthorizer() { + return new ApolloAuditLogQueryApiDefaultPreAuthorizer(); + } + + @Bean + public ApolloAuditController apolloAuditController(ApolloAuditLogApi api, ApolloAuditProperties apolloAuditProperties) { + return new ApolloAuditController(api, apolloAuditProperties); + } + + @Bean + public ApolloAuditLogDataInfluenceEventListener apolloAuditLogDataInfluenceEventListener( + ApolloAuditLogApi api) { + return new ApolloAuditLogDataInfluenceEventListener(api); + } +} diff --git a/apollo-audit/apollo-audit-spring-boot-starter/src/main/java/com/ctrip/framework/apollo/audit/configuration/ApolloAuditNoOpAutoConfiguration.java b/apollo-audit/apollo-audit-spring-boot-starter/src/main/java/com/ctrip/framework/apollo/audit/configuration/ApolloAuditNoOpAutoConfiguration.java new file mode 100644 index 00000000000..6b158304ba4 --- /dev/null +++ b/apollo-audit/apollo-audit-spring-boot-starter/src/main/java/com/ctrip/framework/apollo/audit/configuration/ApolloAuditNoOpAutoConfiguration.java @@ -0,0 +1,82 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.audit.configuration; + +import com.ctrip.framework.apollo.audit.ApolloAuditProperties; +import com.ctrip.framework.apollo.audit.api.ApolloAuditLogApi; +import com.ctrip.framework.apollo.audit.component.ApolloAuditHttpInterceptor; +import com.ctrip.framework.apollo.audit.component.ApolloAuditLogApiNoOpImpl; +import com.ctrip.framework.apollo.audit.context.ApolloAuditTraceContext; +import com.ctrip.framework.apollo.audit.controller.ApolloAuditController; +import com.ctrip.framework.apollo.audit.spi.ApolloAuditLogQueryApiPreAuthorizer; +import com.ctrip.framework.apollo.audit.spi.ApolloAuditOperatorSupplier; +import com.ctrip.framework.apollo.audit.spi.defaultimpl.ApolloAuditLogQueryApiDefaultPreAuthorizer; +import com.ctrip.framework.apollo.audit.spi.defaultimpl.ApolloAuditOperatorDefaultSupplier; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +@EnableConfigurationProperties(ApolloAuditProperties.class) +@ConditionalOnProperty(prefix = "apollo.audit.log", name = "enabled", havingValue = "false", matchIfMissing = true) +public class ApolloAuditNoOpAutoConfiguration { + + private final ApolloAuditProperties apolloAuditProperties; + + public ApolloAuditNoOpAutoConfiguration(ApolloAuditProperties apolloAuditProperties) { + this.apolloAuditProperties = apolloAuditProperties; + } + + @Bean + @ConditionalOnMissingBean(ApolloAuditLogApi.class) + public ApolloAuditLogApi apolloAuditLogApi() { + return new ApolloAuditLogApiNoOpImpl(); + } + + @Bean + @ConditionalOnMissingBean(ApolloAuditOperatorSupplier.class) + public ApolloAuditOperatorSupplier apolloAuditLogOperatorSupplier() { + return new ApolloAuditOperatorDefaultSupplier(); + } + + @Bean + @ConditionalOnMissingBean(ApolloAuditTraceContext.class) + public ApolloAuditTraceContext apolloAuditTraceContext(ApolloAuditOperatorSupplier supplier) { + return new ApolloAuditTraceContext(supplier); + } + + @Bean + @ConditionalOnMissingBean(ApolloAuditHttpInterceptor.class) + public ApolloAuditHttpInterceptor apolloAuditLogHttpInterceptor( + ApolloAuditTraceContext traceContext) { + return new ApolloAuditHttpInterceptor(traceContext); + } + + @Bean(name = "apolloAuditLogQueryApiPreAuthorizer") + @ConditionalOnMissingBean(ApolloAuditLogQueryApiPreAuthorizer.class) + public ApolloAuditLogQueryApiPreAuthorizer apolloAuditLogQueryApiPreAuthorizer() { + return new ApolloAuditLogQueryApiDefaultPreAuthorizer(); + } + + @Bean + public ApolloAuditController apolloAuditController(ApolloAuditLogApi api, ApolloAuditProperties apolloAuditProperties) { + return new ApolloAuditController(api, apolloAuditProperties); + } + +} diff --git a/apollo-audit/apollo-audit-spring-boot-starter/src/main/resources/META-INF/spring.factories b/apollo-audit/apollo-audit-spring-boot-starter/src/main/resources/META-INF/spring.factories new file mode 100644 index 00000000000..d442dd2cfb7 --- /dev/null +++ b/apollo-audit/apollo-audit-spring-boot-starter/src/main/resources/META-INF/spring.factories @@ -0,0 +1,3 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ + com.ctrip.framework.apollo.audit.configuration.ApolloAuditAutoConfiguration,\ + com.ctrip.framework.apollo.audit.configuration.ApolloAuditNoOpAutoConfiguration \ No newline at end of file diff --git a/apollo-audit/pom.xml b/apollo-audit/pom.xml new file mode 100644 index 00000000000..c83322cfac9 --- /dev/null +++ b/apollo-audit/pom.xml @@ -0,0 +1,42 @@ + + + + + apollo + com.ctrip.framework.apollo + ${revision} + + 4.0.0 + + apollo-audit + pom + Apollo Audit + + apollo-audit-annotation + apollo-audit-impl + apollo-audit-api + apollo-audit-spring-boot-starter + + + + ${project.artifactId} + + + \ No newline at end of file diff --git a/apollo-biz/pom.xml b/apollo-biz/pom.xml index 737e82707d2..68a70356ad9 100644 --- a/apollo-biz/pom.xml +++ b/apollo-biz/pom.xml @@ -1,6 +1,6 @@ org.springframework.cloud diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/ApolloBizConfig.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/ApolloBizConfig.java index b537d24362b..54e936d2715 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/ApolloBizConfig.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/ApolloBizConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/auth/WebSecurityConfig.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/auth/WebSecurityConfig.java index 67f42f2fcf2..81f1af034d7 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/auth/WebSecurityConfig.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/auth/WebSecurityConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/config/BizConfig.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/config/BizConfig.java index a43218870eb..2652995f582 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/config/BizConfig.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/config/BizConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/AccessKey.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/AccessKey.java index 346cbdd3f14..dcd78d04228 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/AccessKey.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/AccessKey.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Audit.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Audit.java index fa851bf11d4..3f0886de1d3 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Audit.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Audit.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java index d632fbc57ec..e69b8019e66 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,6 +43,9 @@ public class Cluster extends BaseEntity implements Comparable { @Column(name = "`ParentClusterId`", nullable = false) private long parentClusterId; + @Column(name = "`Comment`") + private String comment; + public String getAppId() { return appId; } @@ -67,9 +70,17 @@ public void setParentClusterId(long parentClusterId) { this.parentClusterId = parentClusterId; } + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + public String toString() { return toStringHelper().add("name", name).add("appId", appId) - .add("parentClusterId", parentClusterId).toString(); + .add("parentClusterId", parentClusterId).add("comment", comment).toString(); } @Override diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Commit.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Commit.java index 96430e6bdbb..cc03f375c07 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Commit.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Commit.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/GrayReleaseRule.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/GrayReleaseRule.java index 9311f0363f2..355adeb19ef 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/GrayReleaseRule.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/GrayReleaseRule.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Instance.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Instance.java index b2b35424d09..f75e16aefbf 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Instance.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Instance.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/InstanceConfig.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/InstanceConfig.java index 08dd5b21543..a9fe5f70f6e 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/InstanceConfig.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/InstanceConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Item.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Item.java index 2c6752cdc58..641f8cc8bdd 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Item.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Item.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/JpaMapFieldJsonConverter.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/JpaMapFieldJsonConverter.java index 99b54f2c58e..dc243124c64 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/JpaMapFieldJsonConverter.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/JpaMapFieldJsonConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Namespace.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Namespace.java index b365eb91c66..d03368f72ca 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Namespace.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Namespace.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/NamespaceLock.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/NamespaceLock.java index 9c1312451b0..66e0693f08e 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/NamespaceLock.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/NamespaceLock.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Privilege.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Privilege.java index d1f346844f4..e33be80a8a0 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Privilege.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Privilege.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Release.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Release.java index e7d65743a3c..950962d57fb 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Release.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Release.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ReleaseHistory.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ReleaseHistory.java index 9aa594d8741..5d6ebc84706 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ReleaseHistory.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ReleaseHistory.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ReleaseMessage.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ReleaseMessage.java index 8cd021dfa45..5ff7e8ede7c 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ReleaseMessage.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ReleaseMessage.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ServerConfig.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ServerConfig.java index 0d188d0667d..bb82f2ea191 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ServerConfig.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ServerConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ServiceRegistry.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ServiceRegistry.java index 3927e42027c..6297a60daa8 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ServiceRegistry.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ServiceRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/eureka/ApolloEurekaClientConfig.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/eureka/ApolloEurekaClientConfig.java index ebd8b7662b5..b664cdd8757 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/eureka/ApolloEurekaClientConfig.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/eureka/ApolloEurekaClientConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/grayReleaseRule/GrayReleaseRuleCache.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/grayReleaseRule/GrayReleaseRuleCache.java index d82ef38d745..2fcbdee90b3 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/grayReleaseRule/GrayReleaseRuleCache.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/grayReleaseRule/GrayReleaseRuleCache.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/grayReleaseRule/GrayReleaseRulesHolder.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/grayReleaseRule/GrayReleaseRulesHolder.java index 5c2d18cd961..e7f3b904301 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/grayReleaseRule/GrayReleaseRulesHolder.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/grayReleaseRule/GrayReleaseRulesHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/DatabaseMessageSender.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/DatabaseMessageSender.java index 8fce13a0c56..300375a492f 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/DatabaseMessageSender.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/DatabaseMessageSender.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/MessageSender.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/MessageSender.java index 949a0521eb3..dd213bb0376 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/MessageSender.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/MessageSender.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/ReleaseMessageListener.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/ReleaseMessageListener.java index 401cb3ea398..ce35fe36a9f 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/ReleaseMessageListener.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/ReleaseMessageListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/ReleaseMessageScanner.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/ReleaseMessageScanner.java index 182b8fa5371..2953ac8b05c 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/ReleaseMessageScanner.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/ReleaseMessageScanner.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/Topics.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/Topics.java index e2aaeca96d8..a7c7c589cf5 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/Topics.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/message/Topics.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClient.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClient.java index 228720248d1..0d1382a2357 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClient.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientAlwaysAddSelfInstanceDecoratorImpl.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientAlwaysAddSelfInstanceDecoratorImpl.java index 8edf0685309..1a85c448797 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientAlwaysAddSelfInstanceDecoratorImpl.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientAlwaysAddSelfInstanceDecoratorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientImpl.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientImpl.java index e2ed335dff4..5811d6609e2 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientImpl.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientMemoryCacheDecoratorImpl.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientMemoryCacheDecoratorImpl.java index d057608abab..7940d40ecde 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientMemoryCacheDecoratorImpl.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientMemoryCacheDecoratorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseServiceRegistry.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseServiceRegistry.java index 2d2d6941c7d..1ba96e75c9c 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseServiceRegistry.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseServiceRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseServiceRegistryImpl.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseServiceRegistryImpl.java index 2dd6fbff3d0..454f779174e 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseServiceRegistryImpl.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/DatabaseServiceRegistryImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/ServiceInstance.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/ServiceInstance.java index c68edf6e3b0..d4b78f630c9 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/ServiceInstance.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/ServiceInstance.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/ApolloServiceDiscoveryAutoConfiguration.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/ApolloServiceDiscoveryAutoConfiguration.java index 347d029cb46..e64cabd1395 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/ApolloServiceDiscoveryAutoConfiguration.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/ApolloServiceDiscoveryAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/ApolloServiceRegistryAutoConfiguration.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/ApolloServiceRegistryAutoConfiguration.java index a8922adcb4a..30f80d52ba9 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/ApolloServiceRegistryAutoConfiguration.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/ApolloServiceRegistryAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/support/ApolloServiceDiscoveryProperties.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/support/ApolloServiceDiscoveryProperties.java index 8cae644972e..424b5a9828d 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/support/ApolloServiceDiscoveryProperties.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/support/ApolloServiceDiscoveryProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/support/ApolloServiceRegistryClearApplicationRunner.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/support/ApolloServiceRegistryClearApplicationRunner.java index 9cd31d8b959..325ad141781 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/support/ApolloServiceRegistryClearApplicationRunner.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/support/ApolloServiceRegistryClearApplicationRunner.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/support/ApolloServiceRegistryDeregisterApplicationListener.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/support/ApolloServiceRegistryDeregisterApplicationListener.java index 78652805d69..60ab9890f71 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/support/ApolloServiceRegistryDeregisterApplicationListener.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/support/ApolloServiceRegistryDeregisterApplicationListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/support/ApolloServiceRegistryHeartbeatApplicationRunner.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/support/ApolloServiceRegistryHeartbeatApplicationRunner.java index 795884ebd90..50a137ef831 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/support/ApolloServiceRegistryHeartbeatApplicationRunner.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/support/ApolloServiceRegistryHeartbeatApplicationRunner.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/support/ApolloServiceRegistryProperties.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/support/ApolloServiceRegistryProperties.java index 96843fb31d3..10e285e238f 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/support/ApolloServiceRegistryProperties.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/configuration/support/ApolloServiceRegistryProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/package-info.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/package-info.java index 737af84b963..cbc83b86f45 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/package-info.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/registry/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AccessKeyRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AccessKeyRepository.java index 35a8612c7a6..25f9356ccaa 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AccessKeyRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AccessKeyRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppNamespaceRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppNamespaceRepository.java index fb751b6d7c6..8f9ceabde78 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppNamespaceRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppNamespaceRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppRepository.java index 47987c848ab..f49484d0d7b 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AuditRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AuditRepository.java index e47d97bec7e..5cfe8763b84 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AuditRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AuditRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ClusterRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ClusterRepository.java index f6af92c78f2..b30f75e17f2 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ClusterRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ClusterRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/CommitRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/CommitRepository.java index a6bd936763f..6c8daaac193 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/CommitRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/CommitRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/GrayReleaseRuleRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/GrayReleaseRuleRepository.java index fa3e812880e..b214cf88ab8 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/GrayReleaseRuleRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/GrayReleaseRuleRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/InstanceConfigRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/InstanceConfigRepository.java index b51edfffcb3..c8cb7fadcb2 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/InstanceConfigRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/InstanceConfigRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/InstanceRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/InstanceRepository.java index 5274ffb55df..b4552831736 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/InstanceRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/InstanceRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ItemRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ItemRepository.java index 7c6d330876b..d482ce63e97 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ItemRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ItemRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceLockRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceLockRepository.java index 869b05f9bac..3b1551fd5b4 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceLockRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceLockRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceRepository.java index ab36506d178..fc36a10524b 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/PrivilegeRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/PrivilegeRepository.java index c7267ba09b3..87b19efd362 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/PrivilegeRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/PrivilegeRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseHistoryRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseHistoryRepository.java index 626e51d892a..3115e66a1fb 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseHistoryRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseHistoryRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseMessageRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseMessageRepository.java index 78c0f0db432..79769a97633 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseMessageRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseMessageRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseRepository.java index 3af5c24ccc0..992c8c93283 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ServerConfigRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ServerConfigRepository.java index 360a3d8728b..400f62581c8 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ServerConfigRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ServerConfigRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ServiceRegistryRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ServiceRegistryRepository.java index abffd87334f..53a2b2774da 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ServiceRegistryRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ServiceRegistryRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AccessKeyService.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AccessKeyService.java index 2306e0de3b0..f70f8be6822 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AccessKeyService.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AccessKeyService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AdminService.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AdminService.java index 34415a5384e..ce0f596c9b6 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AdminService.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AdminService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AppNamespaceService.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AppNamespaceService.java index 66d7bb63b08..e2b031b2c0a 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AppNamespaceService.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AppNamespaceService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ */ package com.ctrip.framework.apollo.biz.service; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLog; +import com.ctrip.framework.apollo.audit.annotation.OpType; import com.ctrip.framework.apollo.biz.entity.Audit; import com.ctrip.framework.apollo.biz.entity.Cluster; import com.ctrip.framework.apollo.biz.entity.Namespace; @@ -102,6 +104,7 @@ public List findByAppIdAndNamespaces(String appId, Set nam } @Transactional + @ApolloAuditLog(type = OpType.CREATE, name = "AppNamespace.createDefault") public void createDefaultAppNamespace(String appId, String createBy) { if (!isAppNamespaceNameUnique(appId, ConfigConsts.NAMESPACE_APPLICATION)) { throw new ServiceException("appnamespace not unique"); diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AppService.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AppService.java index 14fa621cb5b..541aad42ca1 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AppService.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AppService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ */ package com.ctrip.framework.apollo.biz.service; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLog; +import com.ctrip.framework.apollo.audit.annotation.OpType; import com.ctrip.framework.apollo.biz.entity.Audit; import com.ctrip.framework.apollo.biz.repository.AppRepository; import com.ctrip.framework.apollo.common.entity.App; @@ -46,16 +48,16 @@ public boolean isAppIdUnique(String appId) { } @Transactional + @ApolloAuditLog(type = OpType.DELETE, name = "App.delete") public void delete(long id, String operator) { + App app = appRepository.findById(id).orElse(null); if (app == null) { return; } - app.setDeleted(true); app.setDataChangeLastModifiedBy(operator); appRepository.save(app); - auditService.audit(App.class.getSimpleName(), id, Audit.OP.DELETE, operator); } @@ -73,6 +75,7 @@ public App findOne(String appId) { } @Transactional + @ApolloAuditLog(type = OpType.CREATE, name = "App.create") public App save(App entity) { if (!isAppIdUnique(entity.getAppId())) { throw new ServiceException("appId not unique"); @@ -87,6 +90,7 @@ public App save(App entity) { } @Transactional + @ApolloAuditLog(type = OpType.UPDATE, name = "App.update") public void update(App app) { String appId = app.getAppId(); @@ -103,7 +107,6 @@ public void update(App app) { managedApp.setDataChangeLastModifiedBy(app.getDataChangeLastModifiedBy()); managedApp = appRepository.save(managedApp); - auditService.audit(App.class.getSimpleName(), managedApp.getId(), Audit.OP.UPDATE, managedApp.getDataChangeLastModifiedBy()); diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AuditService.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AuditService.java index 23891ee5de8..0f60c571b34 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AuditService.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AuditService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/BizDBPropertySource.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/BizDBPropertySource.java index 17128cd51bf..714a3417962 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/BizDBPropertySource.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/BizDBPropertySource.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,7 +67,7 @@ public BizDBPropertySource(final ServerConfigRepository serverConfigRepository, @PostConstruct public void runSqlScript() throws Exception { if (env.acceptsProfiles(Profiles.of("h2"))) { - Resource resource = new ClassPathResource("jpa/init.h2.sql"); + Resource resource = new ClassPathResource("jpa/configdb.init.h2.sql"); if (resource.exists()) { DatabasePopulatorUtils.execute(new ResourceDatabasePopulator(resource), dataSource); } diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ClusterService.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ClusterService.java index b1744724674..40965a93c4a 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ClusterService.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ClusterService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/CommitService.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/CommitService.java index 31e1e577fdc..926b6a3dc68 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/CommitService.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/CommitService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/InstanceService.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/InstanceService.java index df21306ae57..5100764ec3a 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/InstanceService.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/InstanceService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemService.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemService.java index a6bba2afc0b..7dffa366c5e 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemService.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemSetService.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemSetService.java index 1734dbef346..f1559d2643d 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemSetService.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemSetService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceBranchService.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceBranchService.java index 03acbb2a5a2..d33d5c82307 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceBranchService.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceBranchService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceLockService.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceLockService.java index a5d4acedd82..b0e9bb936af 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceLockService.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceLockService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceService.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceService.java index 2c098566ae6..f95bd2e0a1e 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceService.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseHistoryService.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseHistoryService.java index 9bc55577bab..804f1f77550 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseHistoryService.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseHistoryService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseMessageService.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseMessageService.java index 45f92c13c55..718dbd7cccf 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseMessageService.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseMessageService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseService.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseService.java index b62afb20f1e..95b099e8fc4 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseService.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ServerConfigService.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ServerConfigService.java index ad43457c80f..045dea1d173 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ServerConfigService.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ServerConfigService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ServiceRegistryService.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ServiceRegistryService.java index 80df2c8ccbf..c5a6b142d0f 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ServiceRegistryService.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ServiceRegistryService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/utils/ConfigChangeContentBuilder.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/utils/ConfigChangeContentBuilder.java index 00a646aeafd..acbc7d700aa 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/utils/ConfigChangeContentBuilder.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/utils/ConfigChangeContentBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/utils/EntityManagerUtil.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/utils/EntityManagerUtil.java index 936d4383599..0c9bca1855b 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/utils/EntityManagerUtil.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/utils/EntityManagerUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/utils/ReleaseKeyGenerator.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/utils/ReleaseKeyGenerator.java index 43ca5f63a8d..b38717736b9 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/utils/ReleaseKeyGenerator.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/utils/ReleaseKeyGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/utils/ReleaseMessageKeyGenerator.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/utils/ReleaseMessageKeyGenerator.java index 1b333e8ba22..b3f7cc22ca6 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/utils/ReleaseMessageKeyGenerator.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/utils/ReleaseMessageKeyGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/AbstractIntegrationTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/AbstractIntegrationTest.java index 612a6ea8edd..fbfa139b37c 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/AbstractIntegrationTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/AbstractIntegrationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/AbstractUnitTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/AbstractUnitTest.java index adcb4bec8a5..908fb72b7be 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/AbstractUnitTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/AbstractUnitTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/BizTestConfiguration.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/BizTestConfiguration.java index 6715204f735..f510af1d2ce 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/BizTestConfiguration.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/BizTestConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/MockBeanFactory.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/MockBeanFactory.java index e1cb1c29fdd..1ff3539d709 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/MockBeanFactory.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/MockBeanFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/config/BizConfigTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/config/BizConfigTest.java index 2922ef27610..7c7b1ea484a 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/config/BizConfigTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/config/BizConfigTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/entity/JpaMapFieldJsonConverterTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/entity/JpaMapFieldJsonConverterTest.java index 7d1d86d5d4e..4f1ff657dbb 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/entity/JpaMapFieldJsonConverterTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/entity/JpaMapFieldJsonConverterTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/grayReleaseRule/GrayReleaseRulesHolderTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/grayReleaseRule/GrayReleaseRulesHolderTest.java index 8a17f15e1bd..503f36ae3d6 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/grayReleaseRule/GrayReleaseRulesHolderTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/grayReleaseRule/GrayReleaseRulesHolderTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/message/DatabaseMessageSenderTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/message/DatabaseMessageSenderTest.java index 7d6eac6e248..efaa421b005 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/message/DatabaseMessageSenderTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/message/DatabaseMessageSenderTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/message/ReleaseMessageScannerTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/message/ReleaseMessageScannerTest.java index 0b247f2e236..707eb2ce72b 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/message/ReleaseMessageScannerTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/message/ReleaseMessageScannerTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientAlwaysAddSelfInstanceDecoratorImplTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientAlwaysAddSelfInstanceDecoratorImplTest.java index cb8d44f96a8..68942717018 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientAlwaysAddSelfInstanceDecoratorImplTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientAlwaysAddSelfInstanceDecoratorImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientImplTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientImplTest.java index 7707a300b31..5d9e3200cdb 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientImplTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientMemoryCacheDecoratorImplTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientMemoryCacheDecoratorImplTest.java index 56a24b850c3..ae7e511712a 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientMemoryCacheDecoratorImplTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryClientMemoryCacheDecoratorImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryIntegrationTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryIntegrationTest.java index 39cdb04bbcb..edbf5611374 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryIntegrationTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryIntegrationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,14 +22,11 @@ import com.ctrip.framework.apollo.biz.AbstractIntegrationTest; import com.ctrip.framework.apollo.biz.registry.configuration.ApolloServiceDiscoveryAutoConfiguration; import com.ctrip.framework.apollo.biz.registry.configuration.ApolloServiceRegistryAutoConfiguration; -import com.ctrip.framework.apollo.biz.repository.ServiceRegistryRepository; - import java.util.List; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; @@ -49,7 +46,6 @@ ApolloServiceRegistryAutoConfiguration.class, ApolloServiceDiscoveryAutoConfiguration.class, }) -@EnableJpaRepositories(basePackageClasses = ServiceRegistryRepository.class) public class DatabaseDiscoveryIntegrationTest extends AbstractIntegrationTest { private final Logger log = LoggerFactory.getLogger(this.getClass()); diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryWithoutDecoratorIntegrationTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryWithoutDecoratorIntegrationTest.java index 8d60a414d7c..27208e2ec7c 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryWithoutDecoratorIntegrationTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/DatabaseDiscoveryWithoutDecoratorIntegrationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,6 @@ import com.ctrip.framework.apollo.biz.registry.configuration.ApolloServiceDiscoveryAutoConfiguration; import com.ctrip.framework.apollo.biz.registry.configuration.ApolloServiceRegistryAutoConfiguration; import com.ctrip.framework.apollo.biz.registry.configuration.support.ApolloServiceDiscoveryProperties; -import com.ctrip.framework.apollo.biz.repository.ServiceRegistryRepository; import com.ctrip.framework.apollo.biz.service.ServiceRegistryService; import java.util.List; import org.junit.Test; @@ -37,7 +36,6 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; @@ -62,7 +60,6 @@ ApolloServiceDiscoveryWithoutDecoratorAutoConfiguration.class, ApolloServiceDiscoveryAutoConfiguration.class, }) -@EnableJpaRepositories(basePackageClasses = ServiceRegistryRepository.class) public class DatabaseDiscoveryWithoutDecoratorIntegrationTest extends AbstractIntegrationTest { private final Logger log = LoggerFactory.getLogger(this.getClass()); diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/ServiceInstanceFactory.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/ServiceInstanceFactory.java index 7b7f0c923e6..088e052c7de 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/ServiceInstanceFactory.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/ServiceInstanceFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/configuration/ApolloServiceRegistryAutoConfigurationNotEnabledTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/configuration/ApolloServiceRegistryAutoConfigurationNotEnabledTest.java index b2e6f1a3682..8175c32b24a 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/configuration/ApolloServiceRegistryAutoConfigurationNotEnabledTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/configuration/ApolloServiceRegistryAutoConfigurationNotEnabledTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/configuration/support/ApolloServiceRegistryClearApplicationRunnerIntegrationTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/configuration/support/ApolloServiceRegistryClearApplicationRunnerIntegrationTest.java index d57469b3cdc..b786457ac28 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/configuration/support/ApolloServiceRegistryClearApplicationRunnerIntegrationTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/registry/configuration/support/ApolloServiceRegistryClearApplicationRunnerIntegrationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,6 @@ import java.util.List; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; @@ -44,7 +43,6 @@ ApolloServiceRegistryAutoConfiguration.class, ApolloServiceDiscoveryAutoConfiguration.class, }) -@EnableJpaRepositories(basePackageClasses = ServiceRegistryRepository.class) public class ApolloServiceRegistryClearApplicationRunnerIntegrationTest extends AbstractIntegrationTest { diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/AccessKeyRepositoryTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/AccessKeyRepositoryTest.java index 3ce3428f88e..1938d3b0eec 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/AccessKeyRepositoryTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/AccessKeyRepositoryTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/AppNamespaceRepositoryTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/AppNamespaceRepositoryTest.java index 8b4ce48c70e..0e59c444ade 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/AppNamespaceRepositoryTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/AppNamespaceRepositoryTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/AppRepositoryTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/AppRepositoryTest.java index ae8540f493b..6d70d059ee7 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/AppRepositoryTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/AppRepositoryTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/InstanceConfigRepositoryTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/InstanceConfigRepositoryTest.java index 698925c28f1..6fe04c2858e 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/InstanceConfigRepositoryTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/InstanceConfigRepositoryTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/ReleaseHistoryRepositoryTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/ReleaseHistoryRepositoryTest.java index 58f95f80bda..fd7bf2bb0af 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/ReleaseHistoryRepositoryTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/ReleaseHistoryRepositoryTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/AccessKeyServiceTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/AccessKeyServiceTest.java index 00c2fe902bf..d02c27554f8 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/AccessKeyServiceTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/AccessKeyServiceTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/AdminServiceTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/AdminServiceTest.java index 3776cacaa14..3519db52f28 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/AdminServiceTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/AdminServiceTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/AdminServiceTransactionTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/AdminServiceTransactionTest.java index d04a512f1ae..79701ea7bbd 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/AdminServiceTransactionTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/AdminServiceTransactionTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/BizDBPropertySourceTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/BizDBPropertySourceTest.java index e42fcab3a12..86e6c2c3eec 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/BizDBPropertySourceTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/BizDBPropertySourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ClusterServiceTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ClusterServiceTest.java index 3f9d9aff4a0..62e92693dbd 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ClusterServiceTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ClusterServiceTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/InstanceServiceTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/InstanceServiceTest.java index 0aedfcc6949..50ad5123d6e 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/InstanceServiceTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/InstanceServiceTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ItemServiceTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ItemServiceTest.java index a58eb22adb2..3b0ed5f6a4b 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ItemServiceTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ItemServiceTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespaceBranchServiceTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespaceBranchServiceTest.java index 93cc0ea0b25..ed077c08b5a 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespaceBranchServiceTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespaceBranchServiceTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespacePublishInfoTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespacePublishInfoTest.java index 416e5592c3e..d1dd7e6b2c1 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespacePublishInfoTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespacePublishInfoTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespaceServiceIntegrationTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespaceServiceIntegrationTest.java index 6269507f12b..3bc57305138 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespaceServiceIntegrationTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespaceServiceIntegrationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespaceServiceTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespaceServiceTest.java index 75429823334..551b5dc497a 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespaceServiceTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespaceServiceTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ReleaseCreationTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ReleaseCreationTest.java index 0751610c6b9..d25a2f0d87e 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ReleaseCreationTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ReleaseCreationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ReleaseHistoryServiceTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ReleaseHistoryServiceTest.java index e66da46c3cc..ab23f40379f 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ReleaseHistoryServiceTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ReleaseHistoryServiceTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ReleaseServiceTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ReleaseServiceTest.java index 480203f37fb..c50471f8812 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ReleaseServiceTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ReleaseServiceTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ServerConfigServiceTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ServerConfigServiceTest.java index 0bde2f5c011..a9f3e727dbb 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ServerConfigServiceTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ServerConfigServiceTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/utils/ConfigChangeContentBuilderTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/utils/ConfigChangeContentBuilderTest.java index e092c5e7335..c61026f9df2 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/utils/ConfigChangeContentBuilderTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/utils/ConfigChangeContentBuilderTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/utils/ReleaseKeyGeneratorTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/utils/ReleaseKeyGeneratorTest.java index a12efc03841..a36a75a2013 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/utils/ReleaseKeyGeneratorTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/utils/ReleaseKeyGeneratorTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/resources/application.properties b/apollo-biz/src/test/resources/application.properties index cc42ed85e24..375ac9d1da6 100644 --- a/apollo-biz/src/test/resources/application.properties +++ b/apollo-biz/src/test/resources/application.properties @@ -1,5 +1,5 @@ # -# Copyright 2023 Apollo Authors +# Copyright 2024 Apollo Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/resources/data.sql b/apollo-biz/src/test/resources/data.sql index 001a9dc6f7f..d522254d89d 100644 --- a/apollo-biz/src/test/resources/data.sql +++ b/apollo-biz/src/test/resources/data.sql @@ -1,5 +1,5 @@ -- --- Copyright 2023 Apollo Authors +-- Copyright 2024 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/resources/import.sql b/apollo-biz/src/test/resources/import.sql index 4baf6771fb1..3efd3b62006 100644 --- a/apollo-biz/src/test/resources/import.sql +++ b/apollo-biz/src/test/resources/import.sql @@ -1,5 +1,5 @@ -- --- Copyright 2023 Apollo Authors +-- Copyright 2024 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/resources/logback-test.xml b/apollo-biz/src/test/resources/logback-test.xml index 8d6c3a5e674..c295e0b4f03 100644 --- a/apollo-biz/src/test/resources/logback-test.xml +++ b/apollo-biz/src/test/resources/logback-test.xml @@ -1,6 +1,6 @@ diff --git a/apollo-portal/src/main/docker/Dockerfile b/apollo-portal/src/main/docker/Dockerfile index b7ce2a6ba58..6213091c6d6 100755 --- a/apollo-portal/src/main/docker/Dockerfile +++ b/apollo-portal/src/main/docker/Dockerfile @@ -1,5 +1,5 @@ # -# Copyright 2023 Apollo Authors +# Copyright 2024 Apollo Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/PortalOpenApiConfig.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/PortalOpenApiConfig.java index 0926a18bf75..ece1147e44f 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/PortalOpenApiConfig.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/PortalOpenApiConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/auth/ConsumerPermissionValidator.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/auth/ConsumerPermissionValidator.java index d7952eb55ee..7480b77c5eb 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/auth/ConsumerPermissionValidator.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/auth/ConsumerPermissionValidator.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/Consumer.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/Consumer.java index fd24d750373..4b06b9e1657 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/Consumer.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/Consumer.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerAudit.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerAudit.java index 6efe84510a5..fb0f89966af 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerAudit.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerAudit.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerRole.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerRole.java index 6c5f9b7e32c..d9ce70739d2 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerRole.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerRole.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerToken.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerToken.java index 0d36a09ceff..631ffabfedc 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerToken.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerToken.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/filter/ConsumerAuthenticationFilter.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/filter/ConsumerAuthenticationFilter.java index ec4d2a9a96d..c08de6dd505 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/filter/ConsumerAuthenticationFilter.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/filter/ConsumerAuthenticationFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerAuditRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerAuditRepository.java index 104ebb64086..94bc003a0df 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerAuditRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerAuditRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerRepository.java index 59385aed71a..49a7e1314d1 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerRoleRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerRoleRepository.java index 3cd7afda9e1..d369f810037 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerRoleRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerRoleRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerTokenRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerTokenRepository.java index da863d8a8f9..456dee7717b 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerTokenRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerTokenRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/server/service/ServerAppOpenApiService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/server/service/ServerAppOpenApiService.java index 533bc0af74c..d3d772fd28d 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/server/service/ServerAppOpenApiService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/server/service/ServerAppOpenApiService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/server/service/ServerClusterOpenApiService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/server/service/ServerClusterOpenApiService.java index 394b472132e..a5719b672bf 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/server/service/ServerClusterOpenApiService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/server/service/ServerClusterOpenApiService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/server/service/ServerItemOpenApiService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/server/service/ServerItemOpenApiService.java index 43e03f44284..3ae1e66fd00 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/server/service/ServerItemOpenApiService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/server/service/ServerItemOpenApiService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/server/service/ServerNamespaceOpenApiService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/server/service/ServerNamespaceOpenApiService.java index f67f448f2f7..cc2cf13f829 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/server/service/ServerNamespaceOpenApiService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/server/service/ServerNamespaceOpenApiService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/server/service/ServerReleaseOpenApiService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/server/service/ServerReleaseOpenApiService.java index db32c1c67a6..6213c3256dd 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/server/service/ServerReleaseOpenApiService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/server/service/ServerReleaseOpenApiService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/service/ConsumerRolePermissionService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/service/ConsumerRolePermissionService.java index e60e64db7c3..e39321230e2 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/service/ConsumerRolePermissionService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/service/ConsumerRolePermissionService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/service/ConsumerService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/service/ConsumerService.java index 7c235d8abf6..90164feea7f 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/service/ConsumerService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/service/ConsumerService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/util/ConsumerAuditUtil.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/util/ConsumerAuditUtil.java index 6049b821b29..5c5237bc0f9 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/util/ConsumerAuditUtil.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/util/ConsumerAuditUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/util/ConsumerAuthUtil.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/util/ConsumerAuthUtil.java index a82ebd5e8db..83d5e02ab4e 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/util/ConsumerAuthUtil.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/util/ConsumerAuthUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/util/OpenApiBeanUtils.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/util/OpenApiBeanUtils.java index e1b82d2e509..a1a82e30adb 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/util/OpenApiBeanUtils.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/util/OpenApiBeanUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/AppController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/AppController.java index 7b84c00c926..c9bf44b6871 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/AppController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/AppController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/ClusterController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/ClusterController.java index 235d8927f2e..1b9dbdb3673 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/ClusterController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/ClusterController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/ItemController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/ItemController.java index c9afb429e4b..fdc9f0e18e8 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/ItemController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/ItemController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/NamespaceBranchController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/NamespaceBranchController.java index 4a0d940e8d3..73873b30d20 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/NamespaceBranchController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/NamespaceBranchController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/NamespaceController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/NamespaceController.java index 822db491fbc..bbe3ba8e422 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/NamespaceController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/NamespaceController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/ReleaseController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/ReleaseController.java index 1b0067d102b..cb0d0ef9e14 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/ReleaseController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/ReleaseController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/PortalApplication.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/PortalApplication.java index 2a3afc5f593..15cfb2e3594 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/PortalApplication.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/PortalApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/ServletInitializer.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/ServletInitializer.java index 1f6771df4eb..d15cdbb840b 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/ServletInitializer.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/ServletInitializer.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/API.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/API.java index e995bae75b0..c6c2e364d69 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/API.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/API.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/AdminServiceAPI.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/AdminServiceAPI.java index 5224237d803..3d3f23bff4a 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/AdminServiceAPI.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/AdminServiceAPI.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ */ package com.ctrip.framework.apollo.portal.api; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLog; +import com.ctrip.framework.apollo.audit.annotation.OpType; import com.ctrip.framework.apollo.common.dto.*; import com.ctrip.framework.apollo.openapi.dto.OpenItemDTO; import com.ctrip.framework.apollo.portal.entity.po.ServerConfig; @@ -58,14 +60,17 @@ public AppDTO loadApp(Env env, String appId) { return restTemplate.get(env, "apps/{appId}", AppDTO.class, appId); } + @ApolloAuditLog(type = OpType.RPC, name = "App.createInRemote") public AppDTO createApp(Env env, AppDTO app) { return restTemplate.post(env, "apps", app, AppDTO.class); } + @ApolloAuditLog(type = OpType.RPC, name = "App.updateInRemote") public void updateApp(Env env, AppDTO app) { restTemplate.put(env, "apps/{appId}", app, app.getAppId()); } + @ApolloAuditLog(type = OpType.RPC, name = "App.deleteInRemote") public void deleteApp(Env env, String appId, String operator) { restTemplate.delete(env, "/apps/{appId}?operator={operator}", appId, operator); } @@ -113,17 +118,20 @@ public NamespaceDTO findPublicNamespaceForAssociatedNamespace(Env env, String ap NamespaceDTO.class, appId, clusterName, namespaceName); } + @ApolloAuditLog(type = OpType.RPC, name = "Namespace.createInRemote") public NamespaceDTO createNamespace(Env env, NamespaceDTO namespace) { return restTemplate .post(env, "apps/{appId}/clusters/{clusterName}/namespaces", namespace, NamespaceDTO.class, namespace.getAppId(), namespace.getClusterName()); } + @ApolloAuditLog(type = OpType.RPC, name = "AppNamespace.createInRemote") public AppNamespaceDTO createAppNamespace(Env env, AppNamespaceDTO appNamespace) { return restTemplate .post(env, "apps/{appId}/appnamespaces", appNamespace, AppNamespaceDTO.class, appNamespace.getAppId()); } + @ApolloAuditLog(type = OpType.RPC, name = "AppNamespace.createMissingAppNamespaceInRemote") public AppNamespaceDTO createMissingAppNamespace(Env env, AppNamespaceDTO appNamespace) { return restTemplate .post(env, "apps/{appId}/appnamespaces?silentCreation=true", appNamespace, AppNamespaceDTO.class, @@ -135,6 +143,7 @@ public List getAppNamespaces(String appId, Env env) { return Arrays.asList(appNamespaceDTOs); } + @ApolloAuditLog(type = OpType.RPC, name = "Namespace.deleteInRemote") public void deleteNamespace(Env env, String appId, String clusterName, String namespaceName, String operator) { restTemplate .delete(env, "apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}?operator={operator}", appId, @@ -162,6 +171,7 @@ public int countPublicAppNamespaceAssociatedNamespaces(Env env, String publicNam return count == null ? 0 : count; } + @ApolloAuditLog(type = OpType.RPC, name = "AppNamespace.deleteInRemote") public void deleteAppNamespace(Env env, String appId, String namespaceName, String operator) { restTemplate.delete(env, "/apps/{appId}/appnamespaces/{namespaceName}?operator={operator}", appId, namespaceName, operator); @@ -261,12 +271,13 @@ public boolean isClusterUnique(String appId, Env env, String clusterName) { } + @ApolloAuditLog(type = OpType.RPC, name = "Cluster.createInRemote") public ClusterDTO create(Env env, ClusterDTO cluster) { return restTemplate.post(env, "apps/{appId}/clusters", cluster, ClusterDTO.class, cluster.getAppId()); } - + @ApolloAuditLog(type = OpType.RPC, name = "Cluster.deleteInRemote") public void delete(Env env, String appId, String clusterName, String operator) { restTemplate.delete(env, "apps/{appId}/clusters/{clusterName}?operator={operator}", appId, clusterName, operator); } @@ -275,6 +286,7 @@ public void delete(Env env, String appId, String clusterName, String operator) { @Service public static class AccessKeyAPI extends API { + @ApolloAuditLog(type = OpType.RPC, name = "AccessKey.createInRemote") public AccessKeyDTO create(Env env, AccessKeyDTO accessKey) { return restTemplate.post(env, "apps/{appId}/accesskeys", accessKey, AccessKeyDTO.class, accessKey.getAppId()); @@ -286,16 +298,19 @@ public List findByAppId(Env env, String appId) { return Arrays.asList(accessKeys); } + @ApolloAuditLog(type = OpType.RPC, name = "AccessKey.deleteInRemote") public void delete(Env env, String appId, long id, String operator) { restTemplate.delete(env, "apps/{appId}/accesskeys/{id}?operator={operator}", appId, id, operator); } + @ApolloAuditLog(type = OpType.RPC, name = "AccessKey.enableInRemote") public void enable(Env env, String appId, long id, String operator) { restTemplate.put(env, "apps/{appId}/accesskeys/{id}/enable?operator={operator}", null, appId, id, operator); } + @ApolloAuditLog(type = OpType.RPC, name = "AccessKey.disableInRemote") public void disable(Env env, String appId, long id, String operator) { restTemplate.put(env, "apps/{appId}/accesskeys/{id}/disable?operator={operator}", null, appId, id, operator); @@ -508,6 +523,7 @@ public int getInstanceCountByNamespace(String appId, Env env, String clusterName @Service public static class NamespaceBranchAPI extends API { + @ApolloAuditLog(type = OpType.RPC, name = "NamespaceBranch.createInRemote") public NamespaceDTO createBranch(String appId, Env env, String clusterName, String namespaceName, String operator) { return restTemplate @@ -529,6 +545,7 @@ public GrayReleaseRuleDTO findBranchGrayRules(String appId, Env env, String clus } + @ApolloAuditLog(type = OpType.RPC, name = "NamespaceBranch.updateInRemote") public void updateBranchGrayRules(String appId, Env env, String clusterName, String namespaceName, String branchName, GrayReleaseRuleDTO rules) { restTemplate @@ -537,6 +554,7 @@ public void updateBranchGrayRules(String appId, Env env, String clusterName, } + @ApolloAuditLog(type = OpType.RPC, name = "NamespaceBranch.deleteInRemote") public void deleteBranch(String appId, Env env, String clusterName, String namespaceName, String branchName, String operator) { restTemplate.delete(env, @@ -582,6 +600,7 @@ public List findAllConfigDBConfig(Env env){ }).getBody(); } + @ApolloAuditLog(type = OpType.RPC, name = "ServerConfig.createOrUpdateConfigDBConfigInRemote") public ServerConfig createOrUpdateConfigDBConfig(Env env, ServerConfig serverConfig){ return restTemplate.post(env, "/server/config", serverConfig, ServerConfig.class); } diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/audit/ApolloAuditLogQueryApiPortalPreAuthorizer.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/audit/ApolloAuditLogQueryApiPortalPreAuthorizer.java new file mode 100644 index 00000000000..445dbd60b75 --- /dev/null +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/audit/ApolloAuditLogQueryApiPortalPreAuthorizer.java @@ -0,0 +1,38 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.portal.audit; + +import com.ctrip.framework.apollo.audit.spi.ApolloAuditLogQueryApiPreAuthorizer; +import com.ctrip.framework.apollo.portal.component.PermissionValidator; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.stereotype.Component; + +@Component("apolloAuditLogQueryApiPreAuthorizer") +@ConditionalOnProperty(prefix = "apollo.audit.log", name = "enabled", havingValue = "true") +public class ApolloAuditLogQueryApiPortalPreAuthorizer implements + ApolloAuditLogQueryApiPreAuthorizer { + private final PermissionValidator permissionValidator; + + public ApolloAuditLogQueryApiPortalPreAuthorizer(PermissionValidator permissionValidator) { + this.permissionValidator = permissionValidator; + } + + @Override + public boolean hasQueryPermission() { + return permissionValidator.isSuperAdmin(); + } +} diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/audit/ApolloAuditOperatorPortalSupplier.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/audit/ApolloAuditOperatorPortalSupplier.java new file mode 100644 index 00000000000..9a165f9c1d2 --- /dev/null +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/audit/ApolloAuditOperatorPortalSupplier.java @@ -0,0 +1,38 @@ +/* + * Copyright 2024 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.ctrip.framework.apollo.portal.audit; + +import com.ctrip.framework.apollo.audit.spi.ApolloAuditOperatorSupplier; +import com.ctrip.framework.apollo.portal.spi.UserInfoHolder; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.stereotype.Component; + +@Component +@ConditionalOnProperty(prefix = "apollo.audit.log", name = "enabled", havingValue = "true") +public class ApolloAuditOperatorPortalSupplier implements ApolloAuditOperatorSupplier { + + private final UserInfoHolder userInfoHolder; + + public ApolloAuditOperatorPortalSupplier(UserInfoHolder userInfoHolder) { + this.userInfoHolder = userInfoHolder; + } + + @Override + public String getOperator() { + return userInfoHolder.getUser().getName(); + } +} diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/AdminServiceAddressLocator.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/AdminServiceAddressLocator.java index 8f5971661cc..c8d4e72b22b 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/AdminServiceAddressLocator.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/AdminServiceAddressLocator.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/ConfigReleaseWebhookNotifier.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/ConfigReleaseWebhookNotifier.java index f98fcb63c20..891fe26bb77 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/ConfigReleaseWebhookNotifier.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/ConfigReleaseWebhookNotifier.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/ItemsComparator.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/ItemsComparator.java index a7027170d3c..a0221fb1786 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/ItemsComparator.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/ItemsComparator.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/PermissionValidator.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/PermissionValidator.java index ecda7166ada..494dba648e7 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/PermissionValidator.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/PermissionValidator.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/PortalSettings.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/PortalSettings.java index f5441ab3690..230be5275a6 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/PortalSettings.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/PortalSettings.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/RestTemplateFactory.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/RestTemplateFactory.java index 4d4c73e1d68..55c27d5b19a 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/RestTemplateFactory.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/RestTemplateFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ */ package com.ctrip.framework.apollo.portal.component; +import com.ctrip.framework.apollo.audit.component.ApolloAuditHttpInterceptor; import com.ctrip.framework.apollo.portal.component.config.PortalConfig; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; @@ -33,13 +34,15 @@ public class RestTemplateFactory implements FactoryBean, Initializ private final HttpMessageConverters httpMessageConverters; private final PortalConfig portalConfig; + private final ApolloAuditHttpInterceptor apolloAuditHttpInterceptor; private RestTemplate restTemplate; public RestTemplateFactory(final HttpMessageConverters httpMessageConverters, - final PortalConfig portalConfig) { + final PortalConfig portalConfig, final ApolloAuditHttpInterceptor apolloAuditHttpInterceptor) { this.httpMessageConverters = httpMessageConverters; this.portalConfig = portalConfig; + this.apolloAuditHttpInterceptor = apolloAuditHttpInterceptor; } public RestTemplate getObject() { @@ -64,6 +67,7 @@ public void afterPropertiesSet() throws UnsupportedEncodingException { requestFactory.setReadTimeout(portalConfig.readTimeout()); restTemplate.setRequestFactory(requestFactory); + restTemplate.getInterceptors().add(apolloAuditHttpInterceptor); } diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/RetryableRestTemplate.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/RetryableRestTemplate.java index 922af859ca4..bc1d35bc4cf 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/RetryableRestTemplate.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/RetryableRestTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/config/PortalConfig.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/config/PortalConfig.java index a6a4ab82358..9a677eea9a5 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/config/PortalConfig.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/config/PortalConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/config/SpringSessionConfig.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/config/SpringSessionConfig.java index e8466800dcc..c347e671719 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/config/SpringSessionConfig.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/config/SpringSessionConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/emailbuilder/ConfigPublishEmailBuilder.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/emailbuilder/ConfigPublishEmailBuilder.java index 6efc371136d..c5f155a97c1 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/emailbuilder/ConfigPublishEmailBuilder.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/emailbuilder/ConfigPublishEmailBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/emailbuilder/GrayPublishEmailBuilder.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/emailbuilder/GrayPublishEmailBuilder.java index 0f5ed0f8c1a..6312028ced2 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/emailbuilder/GrayPublishEmailBuilder.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/emailbuilder/GrayPublishEmailBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/emailbuilder/MergeEmailBuilder.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/emailbuilder/MergeEmailBuilder.java index 4939f750f00..926517dcc66 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/emailbuilder/MergeEmailBuilder.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/emailbuilder/MergeEmailBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/emailbuilder/NormalPublishEmailBuilder.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/emailbuilder/NormalPublishEmailBuilder.java index 1d070dbdb89..418624141f8 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/emailbuilder/NormalPublishEmailBuilder.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/emailbuilder/NormalPublishEmailBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/emailbuilder/RollbackEmailBuilder.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/emailbuilder/RollbackEmailBuilder.java index dc641cdacd4..f6e5fc1afa8 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/emailbuilder/RollbackEmailBuilder.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/emailbuilder/RollbackEmailBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/txtresolver/ConfigTextResolver.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/txtresolver/ConfigTextResolver.java index 46f313f1af1..6916466d1a3 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/txtresolver/ConfigTextResolver.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/txtresolver/ConfigTextResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/txtresolver/FileTextResolver.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/txtresolver/FileTextResolver.java index a826674616b..1e8d28c004a 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/txtresolver/FileTextResolver.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/txtresolver/FileTextResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/txtresolver/PropertyResolver.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/txtresolver/PropertyResolver.java index 16f1cb0b3ce..44080d7520d 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/txtresolver/PropertyResolver.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/txtresolver/PropertyResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/constant/PermissionType.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/constant/PermissionType.java index 3fcec84e1c2..85aa1d75806 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/constant/PermissionType.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/constant/PermissionType.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/constant/RoleType.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/constant/RoleType.java index c27eb96f521..802eafe5185 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/constant/RoleType.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/constant/RoleType.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/constant/TracerEventType.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/constant/TracerEventType.java index adf3ecdd50f..3f1611bb40a 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/constant/TracerEventType.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/constant/TracerEventType.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/AccessKeyController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/AccessKeyController.java index 127cd063f82..fb8518d7dec 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/AccessKeyController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/AccessKeyController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ */ package com.ctrip.framework.apollo.portal.controller; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLog; +import com.ctrip.framework.apollo.audit.annotation.OpType; import com.ctrip.framework.apollo.common.dto.AccessKeyDTO; import com.ctrip.framework.apollo.portal.environment.Env; import com.ctrip.framework.apollo.portal.service.AccessKeyService; @@ -44,6 +46,7 @@ public AccessKeyController( @PreAuthorize(value = "@permissionValidator.isAppAdmin(#appId)") @PostMapping(value = "/apps/{appId}/envs/{env}/accesskeys") + @ApolloAuditLog(type = OpType.CREATE, name = "AccessKey.create") public AccessKeyDTO save(@PathVariable String appId, @PathVariable String env, @RequestBody AccessKeyDTO accessKeyDTO) { String secret = UUID.randomUUID().toString().replaceAll("-", ""); @@ -61,6 +64,7 @@ public List findByAppId(@PathVariable String appId, @PreAuthorize(value = "@permissionValidator.isAppAdmin(#appId)") @DeleteMapping(value = "/apps/{appId}/envs/{env}/accesskeys/{id}") + @ApolloAuditLog(type = OpType.DELETE, name = "AccessKey.delete") public void delete(@PathVariable String appId, @PathVariable String env, @PathVariable long id) { @@ -70,6 +74,7 @@ public void delete(@PathVariable String appId, @PreAuthorize(value = "@permissionValidator.isAppAdmin(#appId)") @PutMapping(value = "/apps/{appId}/envs/{env}/accesskeys/{id}/enable") + @ApolloAuditLog(type = OpType.UPDATE, name = "AccessKey.enable") public void enable(@PathVariable String appId, @PathVariable String env, @PathVariable long id) { @@ -79,6 +84,7 @@ public void enable(@PathVariable String appId, @PreAuthorize(value = "@permissionValidator.isAppAdmin(#appId)") @PutMapping(value = "/apps/{appId}/envs/{env}/accesskeys/{id}/disable") + @ApolloAuditLog(type = OpType.UPDATE, name = "AccessKey.disable") public void disable(@PathVariable String appId, @PathVariable String env, @PathVariable long id) { diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/AppController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/AppController.java index a20393fc317..97503ac77ad 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/AppController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/AppController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,8 @@ package com.ctrip.framework.apollo.portal.controller; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLog; +import com.ctrip.framework.apollo.audit.annotation.OpType; import com.ctrip.framework.apollo.common.dto.AppDTO; import com.ctrip.framework.apollo.common.entity.App; import com.ctrip.framework.apollo.common.exception.BadRequestException; @@ -119,6 +121,7 @@ public List findAppsByOwner(@RequestParam("owner") String owner, Pageable p @PreAuthorize(value = "@permissionValidator.hasCreateApplicationPermission()") @PostMapping + @ApolloAuditLog(type = OpType.CREATE, name = "App.create") public App create(@Valid @RequestBody AppModel appModel) { App app = transformToApp(appModel); @@ -127,6 +130,7 @@ public App create(@Valid @RequestBody AppModel appModel) { @PreAuthorize(value = "@permissionValidator.isAppAdmin(#appId)") @PutMapping("/{appId:.+}") + @ApolloAuditLog(type = OpType.UPDATE, name = "App.update") public void update(@PathVariable String appId, @Valid @RequestBody AppModel appModel) { if (!Objects.equals(appId, appModel.getAppId())) { throw new BadRequestException("The App Id of path variable and request body is different"); @@ -157,6 +161,7 @@ public MultiResponseEntity nav(@PathVariable String appId) { } @PostMapping(value = "/envs/{env}", consumes = {"application/json"}) + @ApolloAuditLog(type = OpType.CREATE, name = "App.create.forEnv") public ResponseEntity create(@PathVariable String env, @Valid @RequestBody App app) { appService.createAppInRemote(Env.valueOf(env), app); @@ -178,6 +183,7 @@ public AppDTO load(@PathVariable String appId) { @PreAuthorize(value = "@permissionValidator.isSuperAdmin()") @DeleteMapping("/{appId:.+}") + @ApolloAuditLog(type = OpType.RPC, name = "App.delete") public void deleteApp(@PathVariable String appId) { App app = appService.deleteAppInLocal(appId); diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ClusterController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ClusterController.java index 27c2306509b..2831f150876 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ClusterController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ClusterController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ */ package com.ctrip.framework.apollo.portal.controller; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLog; +import com.ctrip.framework.apollo.audit.annotation.OpType; import com.ctrip.framework.apollo.common.dto.ClusterDTO; import com.ctrip.framework.apollo.portal.environment.Env; import com.ctrip.framework.apollo.portal.service.ClusterService; @@ -44,6 +46,7 @@ public ClusterController(final ClusterService clusterService, final UserInfoHold @PreAuthorize(value = "@permissionValidator.hasCreateClusterPermission(#appId)") @PostMapping(value = "apps/{appId}/envs/{env}/clusters") + @ApolloAuditLog(type = OpType.CREATE, name = "Cluster.create") public ClusterDTO createCluster(@PathVariable String appId, @PathVariable String env, @Valid @RequestBody ClusterDTO cluster) { String operator = userInfoHolder.getUser().getUserId(); @@ -55,6 +58,7 @@ public ClusterDTO createCluster(@PathVariable String appId, @PathVariable String @PreAuthorize(value = "@permissionValidator.isSuperAdmin()") @DeleteMapping(value = "apps/{appId}/envs/{env}/clusters/{clusterName:.+}") + @ApolloAuditLog(type = OpType.DELETE, name = "Cluster.delete") public ResponseEntity deleteCluster(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName){ clusterService.deleteCluster(Env.valueOf(env), appId, clusterName); diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/CommitController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/CommitController.java index 0aa57ceaeb7..f1e030536e3 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/CommitController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/CommitController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ConfigsExportController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ConfigsExportController.java index 9c4ff608182..1d3c7d79c2d 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ConfigsExportController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ConfigsExportController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ConfigsImportController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ConfigsImportController.java index 35f4ebf6ee9..88ecfba5a69 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ConfigsImportController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ConfigsImportController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ConsumerController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ConsumerController.java index 6be442492eb..0c7a5141731 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ConsumerController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ConsumerController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/EnvController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/EnvController.java index 90138825aa1..5d512806dcc 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/EnvController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/EnvController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/FavoriteController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/FavoriteController.java index 02df7f053b0..c134322848a 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/FavoriteController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/FavoriteController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/InstanceController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/InstanceController.java index 51b3b3c6f41..56c1b856153 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/InstanceController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/InstanceController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ItemController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ItemController.java index 73ab100e355..afc15d89cff 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ItemController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ItemController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceBranchController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceBranchController.java index 75adb257466..8daa6b68a87 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceBranchController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceBranchController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ */ package com.ctrip.framework.apollo.portal.controller; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLog; +import com.ctrip.framework.apollo.audit.annotation.OpType; import com.ctrip.framework.apollo.common.dto.GrayReleaseRuleDTO; import com.ctrip.framework.apollo.common.dto.NamespaceDTO; import com.ctrip.framework.apollo.common.dto.ReleaseDTO; @@ -78,6 +80,7 @@ public NamespaceBO findBranch(@PathVariable String appId, @PreAuthorize(value = "@permissionValidator.hasModifyNamespacePermission(#appId, #namespaceName, #env)") @PostMapping(value = "/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches") + @ApolloAuditLog(type = OpType.CREATE, name = "NamespaceBranch.create") public NamespaceDTO createBranch(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @@ -87,6 +90,7 @@ public NamespaceDTO createBranch(@PathVariable String appId, } @DeleteMapping(value = "/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}") + @ApolloAuditLog(type = OpType.DELETE, name = "NamespaceBranch.delete") public void deleteBranch(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @@ -113,6 +117,7 @@ public void deleteBranch(@PathVariable String appId, @PreAuthorize(value = "@permissionValidator.hasReleaseNamespacePermission(#appId, #namespaceName, #env)") @PostMapping(value = "/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/merge") + @ApolloAuditLog(type = OpType.UPDATE, name = "NamespaceBranch.merge") public ReleaseDTO merge(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName, @PathVariable String branchName, @RequestParam(value = "deleteBranch", defaultValue = "true") boolean deleteBranch, @@ -152,6 +157,7 @@ public GrayReleaseRuleDTO getBranchGrayRules(@PathVariable String appId, @PathVa @PreAuthorize(value = "@permissionValidator.hasOperateNamespacePermission(#appId, #namespaceName, #env)") @PutMapping(value = "/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/rules") + @ApolloAuditLog(type = OpType.UPDATE, name = "NamespaceBranch.updateBranchRules") public void updateBranchRules(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName, @PathVariable String branchName, @RequestBody GrayReleaseRuleDTO rules) { diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceController.java index c3bbbcadad8..ee2515d99ff 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ */ package com.ctrip.framework.apollo.portal.controller; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLog; +import com.ctrip.framework.apollo.audit.annotation.OpType; import com.ctrip.framework.apollo.common.dto.AppNamespaceDTO; import com.ctrip.framework.apollo.common.dto.NamespaceDTO; import com.ctrip.framework.apollo.common.entity.AppNamespace; @@ -141,6 +143,7 @@ public NamespaceBO findPublicNamespaceForAssociatedNamespace(@PathVariable Strin @PreAuthorize(value = "@permissionValidator.hasCreateNamespacePermission(#appId)") @PostMapping("/apps/{appId}/namespaces") + @ApolloAuditLog(type = OpType.CREATE, name = "Namespace.create") public ResponseEntity createNamespace(@PathVariable String appId, @RequestBody List models) { @@ -171,6 +174,7 @@ public ResponseEntity createNamespace(@PathVariable String appId, @PreAuthorize(value = "@permissionValidator.hasDeleteNamespacePermission(#appId)") @DeleteMapping("/apps/{appId}/envs/{env}/clusters/{clusterName}/linked-namespaces/{namespaceName:.+}") + @ApolloAuditLog(type = OpType.DELETE, name = "Namespace.deleteLinkedNamespace") public ResponseEntity deleteLinkedNamespace(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName) { @@ -193,6 +197,7 @@ public List findNamespaceUsage(@PathVariable String appId, @Path @PreAuthorize(value = "@permissionValidator.hasDeleteNamespacePermission(#appId)") @DeleteMapping("/apps/{appId}/appnamespaces/{namespaceName:.+}") + @ApolloAuditLog(type = OpType.DELETE, name = "AppNamespace.delete") public ResponseEntity deleteAppNamespace(@PathVariable String appId, @PathVariable String namespaceName) { AppNamespace appNamespace = appNamespaceService.deleteAppNamespace(appId, namespaceName); @@ -215,6 +220,7 @@ public AppNamespaceDTO findAppNamespace(@PathVariable String appId, @PathVariabl @PreAuthorize(value = "@permissionValidator.hasCreateAppNamespacePermission(#appId, #appNamespace)") @PostMapping("/apps/{appId}/appnamespaces") + @ApolloAuditLog(type = OpType.CREATE, name = "AppNamespace.create") public AppNamespace createAppNamespace(@PathVariable String appId, @RequestParam(defaultValue = "true") boolean appendNamespacePrefix, @Valid @RequestBody AppNamespace appNamespace) { @@ -272,6 +278,7 @@ public MultiResponseEntity findMissingNamespaces(@PathVariable String ap } @PostMapping("/apps/{appId}/envs/{env}/clusters/{clusterName}/missing-namespaces") + @ApolloAuditLog(type = OpType.CREATE, name = "Namespace.createMissingNamespaces") public ResponseEntity createMissingNamespaces(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName) { Set missingNamespaces = findMissingNamespaceNames(appId, env, clusterName); diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceLockController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceLockController.java index cdcdb7f52bf..045c41329fa 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceLockController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceLockController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/OrganizationController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/OrganizationController.java index 7c715194ecf..0acb0783abe 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/OrganizationController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/OrganizationController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PageSettingController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PageSettingController.java index 30367c1c832..10598a81a58 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PageSettingController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PageSettingController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PermissionController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PermissionController.java index 9cb4eb54ca8..8cc166ce26d 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PermissionController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PermissionController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ */ package com.ctrip.framework.apollo.portal.controller; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLog; +import com.ctrip.framework.apollo.audit.annotation.OpType; import com.ctrip.framework.apollo.common.exception.BadRequestException; import com.ctrip.framework.apollo.common.utils.RequestPrecondition; import com.ctrip.framework.apollo.portal.component.PermissionValidator; @@ -148,6 +150,7 @@ public NamespaceEnvRolesAssignedUsers getNamespaceEnvRoles(@PathVariable String @PreAuthorize(value = "@permissionValidator.hasAssignRolePermission(#appId)") @PostMapping("/apps/{appId}/envs/{env}/namespaces/{namespaceName}/roles/{roleType}") + @ApolloAuditLog(type = OpType.CREATE, name = "Auth.assignNamespaceEnvRoleToUser") public ResponseEntity assignNamespaceEnvRoleToUser(@PathVariable String appId, @PathVariable String env, @PathVariable String namespaceName, @PathVariable String roleType, @RequestBody String user) { checkUserExists(user); @@ -172,6 +175,7 @@ public ResponseEntity assignNamespaceEnvRoleToUser(@PathVariable String ap @PreAuthorize(value = "@permissionValidator.hasAssignRolePermission(#appId)") @DeleteMapping("/apps/{appId}/envs/{env}/namespaces/{namespaceName}/roles/{roleType}") + @ApolloAuditLog(type = OpType.DELETE, name = "Auth.removeNamespaceEnvRoleFromUser") public ResponseEntity removeNamespaceEnvRoleFromUser(@PathVariable String appId, @PathVariable String env, @PathVariable String namespaceName, @PathVariable String roleType, @RequestParam String user) { RequestPrecondition.checkArgumentsNotEmpty(user); @@ -208,6 +212,7 @@ public NamespaceRolesAssignedUsers getNamespaceRoles(@PathVariable String appId, @PreAuthorize(value = "@permissionValidator.hasAssignRolePermission(#appId)") @PostMapping("/apps/{appId}/namespaces/{namespaceName}/roles/{roleType}") + @ApolloAuditLog(type = OpType.CREATE, name = "Auth.assignNamespaceRoleToUser") public ResponseEntity assignNamespaceRoleToUser(@PathVariable String appId, @PathVariable String namespaceName, @PathVariable String roleType, @RequestBody String user) { checkUserExists(user); @@ -227,6 +232,7 @@ public ResponseEntity assignNamespaceRoleToUser(@PathVariable String appId @PreAuthorize(value = "@permissionValidator.hasAssignRolePermission(#appId)") @DeleteMapping("/apps/{appId}/namespaces/{namespaceName}/roles/{roleType}") + @ApolloAuditLog(type = OpType.DELETE, name = "Auth.removeNamespaceRoleFromUser") public ResponseEntity removeNamespaceRoleFromUser(@PathVariable String appId, @PathVariable String namespaceName, @PathVariable String roleType, @RequestParam String user) { RequestPrecondition.checkArgumentsNotEmpty(user); @@ -252,6 +258,7 @@ public AppRolesAssignedUsers getAppRoles(@PathVariable String appId) { @PreAuthorize(value = "@permissionValidator.hasManageAppMasterPermission(#appId)") @PostMapping("/apps/{appId}/roles/{roleType}") + @ApolloAuditLog(type = OpType.CREATE, name = "Auth.assignAppRoleToUser") public ResponseEntity assignAppRoleToUser(@PathVariable String appId, @PathVariable String roleType, @RequestBody String user) { checkUserExists(user); @@ -271,6 +278,7 @@ public ResponseEntity assignAppRoleToUser(@PathVariable String appId, @Pat @PreAuthorize(value = "@permissionValidator.hasManageAppMasterPermission(#appId)") @DeleteMapping("/apps/{appId}/roles/{roleType}") + @ApolloAuditLog(type = OpType.DELETE, name = "Auth.removeAppRoleFromUser") public ResponseEntity removeAppRoleFromUser(@PathVariable String appId, @PathVariable String roleType, @RequestParam String user) { RequestPrecondition.checkArgumentsNotEmpty(user); @@ -291,6 +299,7 @@ private void checkUserExists(String userId) { @PreAuthorize(value = "@permissionValidator.isSuperAdmin()") @PostMapping("/system/role/createApplication") + @ApolloAuditLog(type = OpType.CREATE, name = "Auth.addCreateApplicationRoleToUser") public ResponseEntity addCreateApplicationRoleToUser(@RequestBody List userIds) { userIds.forEach(this::checkUserExists); @@ -302,6 +311,7 @@ public ResponseEntity addCreateApplicationRoleToUser(@RequestBody List deleteCreateApplicationRoleFromUser(@PathVariable("userId") String userId) { checkUserExists(userId); Set userIds = new HashSet<>(); @@ -327,6 +337,7 @@ public JsonObject hasCreateApplicationPermission(@PathVariable String userId) { @PreAuthorize(value = "@permissionValidator.isSuperAdmin()") @PostMapping("/apps/{appId}/system/master/{userId}") + @ApolloAuditLog(type = OpType.CREATE, name = "Auth.addManageAppMasterRoleToUser") public ResponseEntity addManageAppMasterRoleToUser(@PathVariable String appId, @PathVariable String userId) { checkUserExists(userId); roleInitializationService.initManageAppMasterRole(appId, userInfoHolder.getUser().getUserId()); @@ -339,6 +350,7 @@ public ResponseEntity addManageAppMasterRoleToUser(@PathVariable String ap @PreAuthorize(value = "@permissionValidator.isSuperAdmin()") @DeleteMapping("/apps/{appId}/system/master/{userId}") + @ApolloAuditLog(type = OpType.DELETE, name = "Auth.forbidManageAppMaster") public ResponseEntity forbidManageAppMaster(@PathVariable String appId, @PathVariable String userId) { checkUserExists(userId); roleInitializationService.initManageAppMasterRole(appId, userInfoHolder.getUser().getUserId()); diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PrefixPathController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PrefixPathController.java index 3207e6c105d..9f7e30a2b67 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PrefixPathController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PrefixPathController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ReleaseController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ReleaseController.java index ca1292317bd..06e303f18fe 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ReleaseController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ReleaseController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ReleaseHistoryController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ReleaseHistoryController.java index 7db422cf26b..da391666836 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ReleaseHistoryController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ReleaseHistoryController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/SearchController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/SearchController.java index b1ab2d2cf05..a27ef3588d2 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/SearchController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/SearchController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ServerConfigController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ServerConfigController.java index bf2a65857f4..bfa2810321b 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ServerConfigController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ServerConfigController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,8 @@ package com.ctrip.framework.apollo.portal.controller; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLog; +import com.ctrip.framework.apollo.audit.annotation.OpType; import com.ctrip.framework.apollo.portal.entity.po.ServerConfig; import com.ctrip.framework.apollo.portal.environment.Env; import com.ctrip.framework.apollo.portal.service.ServerConfigService; @@ -42,12 +44,14 @@ public ServerConfigController(final ServerConfigService serverConfigService) { @PreAuthorize(value = "@permissionValidator.isSuperAdmin()") @PostMapping("/server/portal-db/config") + @ApolloAuditLog(type = OpType.CREATE, name = "ServerConfig.createOrUpdatePortalDBConfig") public ServerConfig createOrUpdatePortalDBConfig(@Valid @RequestBody ServerConfig serverConfig) { return serverConfigService.createOrUpdatePortalDBConfig(serverConfig); } @PreAuthorize(value = "@permissionValidator.isSuperAdmin()") @PostMapping("/server/envs/{env}/config-db/config") + @ApolloAuditLog(type = OpType.CREATE, name = "ServerConfig.createOrUpdateConfigDBConfig") public ServerConfig createOrUpdateConfigDBConfig(@Valid @RequestBody ServerConfig serverConfig, @PathVariable String env) { return serverConfigService.createOrUpdateConfigDBConfig(Env.transformEnv(env), serverConfig); } diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/SignInController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/SignInController.java index 69437cba027..39f734ebbad 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/SignInController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/SignInController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/SsoHeartbeatController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/SsoHeartbeatController.java index 1c9e39fa441..85668883409 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/SsoHeartbeatController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/SsoHeartbeatController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/SystemInfoController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/SystemInfoController.java index 71c5642f283..a10c7a3dcac 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/SystemInfoController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/SystemInfoController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/UserInfoController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/UserInfoController.java index 5bec4eef2eb..86be1feffb3 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/UserInfoController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/UserInfoController.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enricher/AdditionalUserInfoEnricher.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enricher/AdditionalUserInfoEnricher.java index 9f2b40c4564..fac28a4d7bd 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enricher/AdditionalUserInfoEnricher.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enricher/AdditionalUserInfoEnricher.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enricher/adapter/AppDtoUserInfoEnrichedAdapter.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enricher/adapter/AppDtoUserInfoEnrichedAdapter.java index 1fdf68efd06..69412037c19 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enricher/adapter/AppDtoUserInfoEnrichedAdapter.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enricher/adapter/AppDtoUserInfoEnrichedAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enricher/adapter/BaseDtoUserInfoEnrichedAdapter.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enricher/adapter/BaseDtoUserInfoEnrichedAdapter.java index 6c959eb642e..20125c82e8e 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enricher/adapter/BaseDtoUserInfoEnrichedAdapter.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enricher/adapter/BaseDtoUserInfoEnrichedAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enricher/adapter/UserInfoEnrichedAdapter.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enricher/adapter/UserInfoEnrichedAdapter.java index fd533118fc1..59c725dcdba 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enricher/adapter/UserInfoEnrichedAdapter.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enricher/adapter/UserInfoEnrichedAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enricher/impl/UserDisplayNameEnricher.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enricher/impl/UserDisplayNameEnricher.java index df2c64fbe35..c5dc99c244a 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enricher/impl/UserDisplayNameEnricher.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enricher/impl/UserDisplayNameEnricher.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/ConfigBO.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/ConfigBO.java index e6e57aa939b..4a74ce2c873 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/ConfigBO.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/ConfigBO.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/Email.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/Email.java index cedd86cbfcb..0a12e527054 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/Email.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/Email.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/ItemBO.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/ItemBO.java index 3486b758884..2609999a6db 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/ItemBO.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/ItemBO.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/KVEntity.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/KVEntity.java index 671a14917e9..48e6af30c80 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/KVEntity.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/KVEntity.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/NamespaceBO.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/NamespaceBO.java index e8c442332e1..d132ecbcaea 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/NamespaceBO.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/NamespaceBO.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/ReleaseBO.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/ReleaseBO.java index 0abe657f621..523ad84aded 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/ReleaseBO.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/ReleaseBO.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/ReleaseHistoryBO.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/ReleaseHistoryBO.java index 01dbddec2ef..cd98238e43f 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/ReleaseHistoryBO.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/ReleaseHistoryBO.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/UserInfo.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/UserInfo.java index 3236ab99e59..dec06cb61ae 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/UserInfo.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/UserInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/AppModel.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/AppModel.java index 31a18802724..ad8cfccbbc8 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/AppModel.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/AppModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/NamespaceCreationModel.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/NamespaceCreationModel.java index aa92f08f80a..79a1019e85f 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/NamespaceCreationModel.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/NamespaceCreationModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/NamespaceGrayDelReleaseModel.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/NamespaceGrayDelReleaseModel.java index 3fac40c475d..b78e0f88b10 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/NamespaceGrayDelReleaseModel.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/NamespaceGrayDelReleaseModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/NamespaceReleaseModel.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/NamespaceReleaseModel.java index ad09d04b9f2..31b1ce7e52d 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/NamespaceReleaseModel.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/NamespaceReleaseModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/NamespaceSyncModel.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/NamespaceSyncModel.java index 2595aa91159..85edd139feb 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/NamespaceSyncModel.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/NamespaceSyncModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/NamespaceTextModel.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/NamespaceTextModel.java index 757937b1def..3af1dfe7757 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/NamespaceTextModel.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/NamespaceTextModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/Verifiable.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/Verifiable.java index ffaf5c81dd2..7efb85d7eee 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/Verifiable.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/Verifiable.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Authority.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Authority.java index 2d42a1ed395..854c876b1f6 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Authority.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Authority.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Favorite.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Favorite.java index f9471d96328..2b759f741d2 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Favorite.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Favorite.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Permission.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Permission.java index 6c28d5323ba..b78e5025886 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Permission.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Permission.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Role.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Role.java index 6c2bb2cd687..700372692ae 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Role.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Role.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ */ package com.ctrip.framework.apollo.portal.entity.po; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLogDataInfluenceTable; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLogDataInfluenceTableField; import com.ctrip.framework.apollo.common.entity.BaseEntity; import org.hibernate.annotations.SQLDelete; @@ -32,7 +34,9 @@ @Table(name = "`Role`") @SQLDelete(sql = "Update Role set IsDeleted = true, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000) where Id = ?") @Where(clause = "`IsDeleted` = false") +@ApolloAuditLogDataInfluenceTable(tableName = "Role") public class Role extends BaseEntity { + @ApolloAuditLogDataInfluenceTableField(fieldName = "RoleName") @Column(name = "`RoleName`", nullable = false) private String roleName; diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/RolePermission.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/RolePermission.java index c624aa8011a..6291bfad7ee 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/RolePermission.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/RolePermission.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/ServerConfig.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/ServerConfig.java index 3363a2a9683..f3991afd0bc 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/ServerConfig.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/ServerConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ */ package com.ctrip.framework.apollo.portal.entity.po; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLogDataInfluenceTable; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLogDataInfluenceTableField; import com.ctrip.framework.apollo.common.entity.BaseEntity; import javax.validation.constraints.NotBlank; @@ -33,13 +35,16 @@ @Table(name = "`ServerConfig`") @SQLDelete(sql = "Update ServerConfig set IsDeleted = true, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000) where Id = ?") @Where(clause = "`IsDeleted` = false") +@ApolloAuditLogDataInfluenceTable(tableName = "ServerConfig") public class ServerConfig extends BaseEntity { @NotBlank(message = "ServerConfig.Key cannot be blank") @Column(name = "`Key`", nullable = false) + @ApolloAuditLogDataInfluenceTableField(fieldName = "Key") private String key; @NotBlank(message = "ServerConfig.Value cannot be blank") @Column(name = "`Value`", nullable = false) + @ApolloAuditLogDataInfluenceTableField(fieldName = "Value") private String value; @Column(name = "`Comment`", nullable = false) diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserPO.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserPO.java index 46d1f548717..a5467f23609 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserPO.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserPO.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserRole.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserRole.java index aa6ab8b28cb..8007ce4a0a2 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserRole.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserRole.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ */ package com.ctrip.framework.apollo.portal.entity.po; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLogDataInfluenceTable; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLogDataInfluenceTableField; import com.ctrip.framework.apollo.common.entity.BaseEntity; import org.hibernate.annotations.SQLDelete; @@ -32,10 +34,13 @@ @Table(name = "`UserRole`") @SQLDelete(sql = "Update UserRole set IsDeleted = true, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000) where Id = ?") @Where(clause = "`IsDeleted` = false") +@ApolloAuditLogDataInfluenceTable(tableName = "UserRole") public class UserRole extends BaseEntity { + @ApolloAuditLogDataInfluenceTableField(fieldName = "UserId") @Column(name = "`UserId`", nullable = false) private String userId; + @ApolloAuditLogDataInfluenceTableField(fieldName = "RoleId") @Column(name = "`RoleId`", nullable = false) private long roleId; diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/AppRolesAssignedUsers.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/AppRolesAssignedUsers.java index 5cbcfa8165a..9e0d903401f 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/AppRolesAssignedUsers.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/AppRolesAssignedUsers.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/Change.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/Change.java index 2b67855c495..4df310250a5 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/Change.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/Change.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/EnvClusterInfo.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/EnvClusterInfo.java index 9ff82d88c6d..fe474284358 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/EnvClusterInfo.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/EnvClusterInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/EnvironmentInfo.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/EnvironmentInfo.java index 7056f03dc6a..80a8880cbbc 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/EnvironmentInfo.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/EnvironmentInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/ItemDiffs.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/ItemDiffs.java index 994093f0a19..3a249856106 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/ItemDiffs.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/ItemDiffs.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/LockInfo.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/LockInfo.java index 82f938ef1c8..17ed138fb7d 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/LockInfo.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/LockInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/NamespaceEnvRolesAssignedUsers.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/NamespaceEnvRolesAssignedUsers.java index ec942dd0b6a..1d5f3a075ca 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/NamespaceEnvRolesAssignedUsers.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/NamespaceEnvRolesAssignedUsers.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/NamespaceIdentifier.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/NamespaceIdentifier.java index 0817d2d01af..8216ebecd3e 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/NamespaceIdentifier.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/NamespaceIdentifier.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/NamespaceRolesAssignedUsers.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/NamespaceRolesAssignedUsers.java index c89bb14e33a..f5686230f03 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/NamespaceRolesAssignedUsers.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/NamespaceRolesAssignedUsers.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/NamespaceUsage.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/NamespaceUsage.java index a5525cf4ed5..d19476d0fb6 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/NamespaceUsage.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/NamespaceUsage.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/Number.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/Number.java index c7132063af1..e7566f62a91 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/Number.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/Number.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/Organization.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/Organization.java index caeddf50d18..22785453802 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/Organization.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/Organization.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/PageSetting.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/PageSetting.java index 92492c24c82..7fe8b4d27bf 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/PageSetting.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/PageSetting.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/PermissionCondition.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/PermissionCondition.java index 62064d35c35..5a4e4e69c0c 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/PermissionCondition.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/PermissionCondition.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/ReleaseCompareResult.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/ReleaseCompareResult.java index 1ed70c249ec..446d2e0d821 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/ReleaseCompareResult.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/ReleaseCompareResult.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/SystemInfo.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/SystemInfo.java index 00cc2cb13a5..703566b27f0 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/SystemInfo.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/SystemInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/consumer/ConsumerCreateRequestVO.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/consumer/ConsumerCreateRequestVO.java index a114fbc9e75..62bd2406fd2 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/consumer/ConsumerCreateRequestVO.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/consumer/ConsumerCreateRequestVO.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/consumer/ConsumerInfo.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/consumer/ConsumerInfo.java index 6f5259546b8..f6779da140c 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/consumer/ConsumerInfo.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/consumer/ConsumerInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enums/ChangeType.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enums/ChangeType.java index 525c7f03514..0fe8ecd9863 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enums/ChangeType.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/enums/ChangeType.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/environment/DatabasePortalMetaServerProvider.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/environment/DatabasePortalMetaServerProvider.java index 436ac13d62f..a0afd48909a 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/environment/DatabasePortalMetaServerProvider.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/environment/DatabasePortalMetaServerProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/environment/DefaultPortalMetaServerProvider.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/environment/DefaultPortalMetaServerProvider.java index 0cc915a2dd8..0c591e0bc72 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/environment/DefaultPortalMetaServerProvider.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/environment/DefaultPortalMetaServerProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/environment/Env.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/environment/Env.java index 17c4a30f46d..52200c07f7a 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/environment/Env.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/environment/Env.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/environment/PortalMetaDomainService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/environment/PortalMetaDomainService.java index 86dc3b69880..d18841102d8 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/environment/PortalMetaDomainService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/environment/PortalMetaDomainService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/environment/PortalMetaServerProvider.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/environment/PortalMetaServerProvider.java index dbea9cea70c..9a9002a3835 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/environment/PortalMetaServerProvider.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/environment/PortalMetaServerProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppCreationEvent.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppCreationEvent.java index 2ae4fd813ca..7fb9b67bd4f 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppCreationEvent.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppCreationEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppDeletionEvent.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppDeletionEvent.java index dd7a165ee07..7717f92be97 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppDeletionEvent.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppDeletionEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppInfoChangedEvent.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppInfoChangedEvent.java index f01d86fd5b8..c4ce2a34ee5 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppInfoChangedEvent.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppInfoChangedEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppInfoChangedListener.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppInfoChangedListener.java index dff635f366d..a0e1a34172b 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppInfoChangedListener.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppInfoChangedListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppNamespaceCreationEvent.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppNamespaceCreationEvent.java index a4166438060..ff05773f445 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppNamespaceCreationEvent.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppNamespaceCreationEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppNamespaceDeletionEvent.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppNamespaceDeletionEvent.java index 3c58ac4d7e8..56c7b74fade 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppNamespaceDeletionEvent.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/AppNamespaceDeletionEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/ConfigPublishEvent.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/ConfigPublishEvent.java index 588d1dd5344..22fed7fded3 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/ConfigPublishEvent.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/ConfigPublishEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/ConfigPublishListener.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/ConfigPublishListener.java index f64aff38b39..1c2f2a14a72 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/ConfigPublishListener.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/ConfigPublishListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/CreationListener.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/CreationListener.java index 783b347eb12..550b9f64f5b 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/CreationListener.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/CreationListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/DeletionListener.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/DeletionListener.java index fb70f4aaace..a5c6aa7e3e4 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/DeletionListener.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/DeletionListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppNamespaceRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppNamespaceRepository.java index 716ea938ff2..26ec35943be 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppNamespaceRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppNamespaceRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppRepository.java index d966df0d019..5d8ccc51e8b 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AuthorityRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AuthorityRepository.java index 79522d4b841..4b14bd111f3 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AuthorityRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AuthorityRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/FavoriteRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/FavoriteRepository.java index c559b10f733..1242ca79335 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/FavoriteRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/FavoriteRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/PermissionRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/PermissionRepository.java index 111d49329a2..5655317108e 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/PermissionRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/PermissionRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RolePermissionRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RolePermissionRepository.java index 1d3c50f1481..df816f7d3ff 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RolePermissionRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RolePermissionRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RoleRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RoleRepository.java index e22e9477658..e870b933297 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RoleRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RoleRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/ServerConfigRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/ServerConfigRepository.java index ece75d24520..53897b56964 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/ServerConfigRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/ServerConfigRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/UserRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/UserRepository.java index 4a5aab94733..488de700e40 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/UserRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/UserRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/UserRoleRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/UserRoleRepository.java index 6134fe18af1..c5ee1e06845 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/UserRoleRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/UserRoleRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AccessKeyService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AccessKeyService.java index 49d8f5586da..26ba0ff92c0 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AccessKeyService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AccessKeyService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AdditionalUserInfoEnrichService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AdditionalUserInfoEnrichService.java index 69a94f0ec29..52e48a0ae0c 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AdditionalUserInfoEnrichService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AdditionalUserInfoEnrichService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AdditionalUserInfoEnrichServiceImpl.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AdditionalUserInfoEnrichServiceImpl.java index 92d7a53e722..76710125a85 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AdditionalUserInfoEnrichServiceImpl.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AdditionalUserInfoEnrichServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AppNamespaceService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AppNamespaceService.java index 3a2b840baa1..c5a125a5e0e 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AppNamespaceService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AppNamespaceService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,11 @@ */ package com.ctrip.framework.apollo.portal.service; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLog; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLogDataInfluence; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLogDataInfluenceTable; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLogDataInfluenceTableField; +import com.ctrip.framework.apollo.audit.annotation.OpType; import com.ctrip.framework.apollo.common.entity.App; import com.ctrip.framework.apollo.common.entity.AppNamespace; import com.ctrip.framework.apollo.common.exception.BadRequestException; @@ -94,6 +99,7 @@ public List findAll() { return Lists.newArrayList(appNamespaces); } + @ApolloAuditLog(type = OpType.CREATE, name = "AppNamespace.create", description = "createDefaultAppNamespace") @Transactional public void createDefaultAppNamespace(String appId) { if (!isAppNamespaceNameUnique(appId, ConfigConsts.NAMESPACE_APPLICATION)) { @@ -124,6 +130,7 @@ public AppNamespace createAppNamespaceInLocal(AppNamespace appNamespace) { } @Transactional + @ApolloAuditLog(type = OpType.CREATE, name = "AppNamespace.create", description = "createAppNamespaceInLocal") public AppNamespace createAppNamespaceInLocal(AppNamespace appNamespace, boolean appendNamespacePrefix) { String appId = appNamespace.getAppId(); @@ -228,7 +235,7 @@ private void checkPublicAppNamespaceGlobalUniqueness(AppNamespace appNamespace) } } - + @ApolloAuditLog(type = OpType.DELETE, name = "AppNamespace.delete", description = "deleteAppNamespace") @Transactional public AppNamespace deleteAppNamespace(String appId, String namespaceName) { AppNamespace appNamespace = appNamespaceRepository.findByAppIdAndName(appId, namespaceName); @@ -250,7 +257,12 @@ public AppNamespace deleteAppNamespace(String appId, String namespaceName) { return appNamespace; } - public void batchDeleteByAppId(String appId, String operator) { + @ApolloAuditLog(type = OpType.DELETE, name = "AppNamespace.batchDeleteByAppId", description = "batchDeleteByAppId") + public void batchDeleteByAppId( + @ApolloAuditLogDataInfluence + @ApolloAuditLogDataInfluenceTable(tableName = "AppNamespace") + @ApolloAuditLogDataInfluenceTableField(fieldName = "AppId") String appId, + String operator) { appNamespaceRepository.batchDeleteByAppId(appId, operator); } diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AppService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AppService.java index 9184d90a1a0..df68039f292 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AppService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AppService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,10 @@ */ package com.ctrip.framework.apollo.portal.service; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLog; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLogDataInfluence; +import com.ctrip.framework.apollo.audit.annotation.OpType; +import com.ctrip.framework.apollo.audit.api.ApolloAuditLogApi; import com.ctrip.framework.apollo.common.dto.AppDTO; import com.ctrip.framework.apollo.common.dto.PageDTO; import com.ctrip.framework.apollo.common.entity.App; @@ -35,6 +39,7 @@ import com.ctrip.framework.apollo.portal.util.RoleUtils; import com.ctrip.framework.apollo.tracer.Tracer; import com.google.common.collect.Lists; +import java.util.Collections; import org.springframework.context.ApplicationEventPublisher; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -57,6 +62,7 @@ public class AppService { private final RolePermissionService rolePermissionService; private final FavoriteService favoriteService; private final UserService userService; + private final ApolloAuditLogApi apolloAuditLogApi; private final ApplicationEventPublisher publisher; @@ -69,7 +75,8 @@ public AppService( final RoleInitializationService roleInitializationService, final RolePermissionService rolePermissionService, final FavoriteService favoriteService, - final UserService userService, ApplicationEventPublisher publisher) { + final UserService userService, ApplicationEventPublisher publisher, + final ApolloAuditLogApi apolloAuditLogApi) { this.userInfoHolder = userInfoHolder; this.appAPI = appAPI; this.appRepository = appRepository; @@ -79,6 +86,7 @@ public AppService( this.rolePermissionService = rolePermissionService; this.favoriteService = favoriteService; this.userService = userService; + this.apolloAuditLogApi = apolloAuditLogApi; this.publisher = publisher; } @@ -161,6 +169,7 @@ private App createAppInLocal(App app) { } @Transactional + @ApolloAuditLog(type = OpType.CREATE, name = "App.create") public App createAppAndAddRolePermission( App app, Set admins ) { @@ -197,6 +206,7 @@ public App importAppInLocal(App app) { } @Transactional + @ApolloAuditLog(type = OpType.UPDATE, name = "App.update") public App updateAppInLocal(App app) { String appId = app.getAppId(); @@ -230,6 +240,7 @@ public EnvClusterInfo createEnvNavNode(Env env, String appId) { } @Transactional + @ApolloAuditLog(type = OpType.DELETE, name = "App.delete") public App deleteAppInLocal(String appId) { App managedApp = appRepository.findByAppId(appId); if (managedApp == null) { @@ -243,6 +254,9 @@ public App deleteAppInLocal(String appId) { //删除portal数据库中的app appRepository.deleteApp(appId, operator); + // append a deleted data influence should be bounded + apolloAuditLogApi.appendDataInfluences(Collections.singletonList(managedApp), App.class); + //删除portal数据库中的appNamespace appNamespaceService.batchDeleteByAppId(appId, operator); diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ClusterService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ClusterService.java index 9790eed86b9..b0ee27f2e86 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ClusterService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ClusterService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/CommitService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/CommitService.java index 3e48a743412..4610e04f3b8 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/CommitService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/CommitService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ConfigsExportService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ConfigsExportService.java index 79348057af6..aa524105169 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ConfigsExportService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ConfigsExportService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ConfigsImportService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ConfigsImportService.java index 63e59a27d42..cc086f63ef4 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ConfigsImportService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ConfigsImportService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/FavoriteService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/FavoriteService.java index b60c46e079c..f422625838c 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/FavoriteService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/FavoriteService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/InstanceService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/InstanceService.java index dd613da9785..7cc35e62acc 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/InstanceService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/InstanceService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ItemService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ItemService.java index 81970c9c38c..b1677e18858 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ItemService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ItemService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceBranchService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceBranchService.java index 30940bcfb33..272a53fa366 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceBranchService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceBranchService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceLockService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceLockService.java index f46882651e1..d9dff7813a5 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceLockService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceLockService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceService.java index 735ad2a4609..43f05e4de94 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/PortalDBPropertySource.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/PortalDBPropertySource.java index b5431bcb1e6..603eb38e745 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/PortalDBPropertySource.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/PortalDBPropertySource.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,7 +63,7 @@ public PortalDBPropertySource(final ServerConfigRepository serverConfigRepositor @PostConstruct public void runSqlScript() throws Exception { if (env.acceptsProfiles(Profiles.of("h2"))) { - Resource resource = new ClassPathResource("jpa/init.h2.sql"); + Resource resource = new ClassPathResource("jpa/portaldb.init.h2.sql"); if (resource.exists()) { DatabasePopulatorUtils.execute(new ResourceDatabasePopulator(resource), dataSource); } diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ReleaseHistoryService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ReleaseHistoryService.java index 111eaeef158..323164f2537 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ReleaseHistoryService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ReleaseHistoryService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ReleaseService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ReleaseService.java index e65335ab71c..a21761dc19c 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ReleaseService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ReleaseService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/RoleInitializationService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/RoleInitializationService.java index d442ab18e95..1ccb5f9081d 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/RoleInitializationService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/RoleInitializationService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/RolePermissionService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/RolePermissionService.java index 12da3d04fff..538baea2aa9 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/RolePermissionService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/RolePermissionService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ServerConfigService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ServerConfigService.java index 0e9a202b395..416eecdb99b 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ServerConfigService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ServerConfigService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/SystemRoleManagerService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/SystemRoleManagerService.java index ad696c62fe5..94e7a3b4ca9 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/SystemRoleManagerService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/SystemRoleManagerService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/EmailService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/EmailService.java index b9c145cf3e9..dc069c7a684 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/EmailService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/EmailService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/LogoutHandler.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/LogoutHandler.java index fbddedbe38c..31bc1dd34b6 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/LogoutHandler.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/LogoutHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/MQService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/MQService.java index c5e2025fd5e..c5d57e16693 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/MQService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/MQService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/SsoHeartbeatHandler.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/SsoHeartbeatHandler.java index 19a2a96c332..f6a3ce63ca4 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/SsoHeartbeatHandler.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/SsoHeartbeatHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/UserInfoHolder.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/UserInfoHolder.java index 5281baf1c63..6ed9985093a 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/UserInfoHolder.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/UserInfoHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/UserService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/UserService.java index 32f2a2a17d4..a58983fba9b 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/UserService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/UserService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/AuthConfiguration.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/AuthConfiguration.java index d7bfcd078fb..9ba1f6eef06 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/AuthConfiguration.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/AuthConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -195,14 +195,11 @@ static class SpringSecurityLDAPAuthAutoConfiguration { private final LdapProperties properties; private final Environment environment; - private final LdapTemplate ldapTemplate; public SpringSecurityLDAPAuthAutoConfiguration(final LdapProperties properties, - final Environment environment, - final LdapTemplate ldapTemplate) { + final Environment environment) { this.properties = properties; this.environment = environment; - this.ldapTemplate = ldapTemplate; } @Bean @@ -225,7 +222,7 @@ public LogoutHandler logoutHandler() { @Bean @ConditionalOnMissingBean(UserService.class) - public UserService springSecurityUserService() { + public UserService springSecurityUserService(LdapTemplate ldapTemplate) { return new LdapUserService(ldapTemplate); } diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/AuthFilterConfiguration.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/AuthFilterConfiguration.java index bec5e8a310d..66414b3eef2 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/AuthFilterConfiguration.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/AuthFilterConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/EmailConfiguration.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/EmailConfiguration.java index bc57443ed83..d3862f18c33 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/EmailConfiguration.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/EmailConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/LdapExtendProperties.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/LdapExtendProperties.java index 0b7cd483e86..a609d9562cd 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/LdapExtendProperties.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/LdapExtendProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/LdapGroupProperties.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/LdapGroupProperties.java index 9c977585e7c..bb1814de33e 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/LdapGroupProperties.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/LdapGroupProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/LdapMappingProperties.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/LdapMappingProperties.java index d43a848ed46..5453486fb47 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/LdapMappingProperties.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/LdapMappingProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/LdapProperties.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/LdapProperties.java index 3e44f614e64..5f15b591eb6 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/LdapProperties.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/LdapProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/MQConfiguration.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/MQConfiguration.java index 84f07082190..15395d4f54a 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/MQConfiguration.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/MQConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/OidcExtendProperties.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/OidcExtendProperties.java index 70c6c8405bd..a890984ca38 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/OidcExtendProperties.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/OidcExtendProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/RoleConfiguration.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/RoleConfiguration.java index 4c9294e8e6b..6010d696b91 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/RoleConfiguration.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/RoleConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultEmailService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultEmailService.java index ad26700c4dd..3770230c600 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultEmailService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultEmailService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultLogoutHandler.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultLogoutHandler.java index d40d1e530c3..d5288e82a55 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultLogoutHandler.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultLogoutHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultMQService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultMQService.java index cd319573c1d..b8dfd9ca088 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultMQService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultMQService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultRoleInitializationService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultRoleInitializationService.java index ddb78400741..950406f0968 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultRoleInitializationService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultRoleInitializationService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultRolePermissionService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultRolePermissionService.java index ef48d436fc0..61fa627b42f 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultRolePermissionService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultRolePermissionService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,11 @@ */ package com.ctrip.framework.apollo.portal.spi.defaultimpl; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLog; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLogDataInfluence; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLogDataInfluenceTable; +import com.ctrip.framework.apollo.audit.annotation.ApolloAuditLogDataInfluenceTableField; +import com.ctrip.framework.apollo.audit.annotation.OpType; import com.ctrip.framework.apollo.openapi.repository.ConsumerRoleRepository; import com.ctrip.framework.apollo.portal.component.config.PortalConfig; import com.ctrip.framework.apollo.portal.entity.bo.UserInfo; @@ -107,6 +112,7 @@ public Role createRoleWithPermissions(Role role, Set permissionIds) { * @return the users assigned roles */ @Transactional + @ApolloAuditLog(type = OpType.CREATE, name = "Auth.assignRoleToUsers") public Set assignRoleToUsers(String roleName, Set userIds, String operatorUserId) { Role role = findRoleByRoleName(roleName); @@ -136,7 +142,14 @@ public Set assignRoleToUsers(String roleName, Set userIds, * Remove role from users */ @Transactional - public void removeRoleFromUsers(String roleName, Set userIds, String operatorUserId) { + @ApolloAuditLog(type = OpType.DELETE, name = "Auth.removeRoleFromUsers") + public void removeRoleFromUsers( + @ApolloAuditLogDataInfluence + @ApolloAuditLogDataInfluenceTable(tableName = "UserRole") + @ApolloAuditLogDataInfluenceTableField(fieldName = "RoleName") String roleName, + @ApolloAuditLogDataInfluence + @ApolloAuditLogDataInfluenceTable(tableName = "UserRole") + @ApolloAuditLogDataInfluenceTableField(fieldName = "UserId") Set userIds, String operatorUserId) { Role role = findRoleByRoleName(roleName); Preconditions.checkState(role != null, "Role %s doesn't exist!", roleName); diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultSsoHeartbeatHandler.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultSsoHeartbeatHandler.java index 79bae2e995f..3b23e695265 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultSsoHeartbeatHandler.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultSsoHeartbeatHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultUserInfoHolder.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultUserInfoHolder.java index 82a85ac99fc..2af882c669b 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultUserInfoHolder.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultUserInfoHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultUserService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultUserService.java index bf7c489f17f..47bcb7a2a18 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultUserService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/defaultimpl/DefaultUserService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ldap/ApolloLdapAuthenticationProvider.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ldap/ApolloLdapAuthenticationProvider.java index ebc69b27792..7ab4beccc59 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ldap/ApolloLdapAuthenticationProvider.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ldap/ApolloLdapAuthenticationProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ldap/FilterLdapByGroupUserSearch.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ldap/FilterLdapByGroupUserSearch.java index 389c2db3ef1..aa015fcea6e 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ldap/FilterLdapByGroupUserSearch.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ldap/FilterLdapByGroupUserSearch.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ldap/LdapUserService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ldap/LdapUserService.java index adb2fb0a7ab..e59a6cf5e8c 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ldap/LdapUserService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ldap/LdapUserService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/ExcludeClientCredentialsClientRegistrationRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/ExcludeClientCredentialsClientRegistrationRepository.java index f5360740fa4..8e9a2b95764 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/ExcludeClientCredentialsClientRegistrationRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/ExcludeClientCredentialsClientRegistrationRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcAuthenticationSuccessEventListener.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcAuthenticationSuccessEventListener.java index a97aed650b2..f9460d43215 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcAuthenticationSuccessEventListener.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcAuthenticationSuccessEventListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcLocalUserService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcLocalUserService.java index 483a10f5383..409c01d8806 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcLocalUserService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcLocalUserService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcLocalUserServiceImpl.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcLocalUserServiceImpl.java index 1d2abdb72c5..1f94274a123 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcLocalUserServiceImpl.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcLocalUserServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcLogoutHandler.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcLogoutHandler.java index ca826e08e01..887d6d8c9b6 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcLogoutHandler.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcLogoutHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcUserInfoHolder.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcUserInfoHolder.java index cf029ae472a..f65827c8a1d 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcUserInfoHolder.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcUserInfoHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcUserInfoUtil.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcUserInfoUtil.java index 2a7675da74b..ee9d84c6137 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcUserInfoUtil.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcUserInfoUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/PlaceholderPasswordEncoder.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/PlaceholderPasswordEncoder.java index 6470a552e67..2d2fe7ebb73 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/PlaceholderPasswordEncoder.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/PlaceholderPasswordEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/package-info.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/package-info.java index 69df5c35926..6fb5fdfaf54 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/package-info.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/springsecurity/ApolloPasswordEncoderFactory.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/springsecurity/ApolloPasswordEncoderFactory.java index 716408477a1..dbf021ba3d7 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/springsecurity/ApolloPasswordEncoderFactory.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/springsecurity/ApolloPasswordEncoderFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/springsecurity/PasswordEncoderAdapter.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/springsecurity/PasswordEncoderAdapter.java index 430f1572d83..bf9243d8e7a 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/springsecurity/PasswordEncoderAdapter.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/springsecurity/PasswordEncoderAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/springsecurity/SpringSecurityUserInfoHolder.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/springsecurity/SpringSecurityUserInfoHolder.java index 2c72672c618..00885214795 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/springsecurity/SpringSecurityUserInfoHolder.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/springsecurity/SpringSecurityUserInfoHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/springsecurity/SpringSecurityUserService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/springsecurity/SpringSecurityUserService.java index ab0e183d254..6eb1a2446ad 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/springsecurity/SpringSecurityUserService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/springsecurity/SpringSecurityUserService.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/ConfigFileUtils.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/ConfigFileUtils.java index e5f8af840ae..1bf5bf9a14f 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/ConfigFileUtils.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/ConfigFileUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/ConfigToFileUtils.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/ConfigToFileUtils.java index 7d900631e66..fcb155bbc2e 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/ConfigToFileUtils.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/ConfigToFileUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/KeyValueUtils.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/KeyValueUtils.java index 241cc3cc0e5..1acf5778e39 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/KeyValueUtils.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/KeyValueUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/NamespaceBOUtils.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/NamespaceBOUtils.java index a944c2938b1..a520c2da837 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/NamespaceBOUtils.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/NamespaceBOUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/RelativeDateFormat.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/RelativeDateFormat.java index 678d9945791..8668b55235a 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/RelativeDateFormat.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/RelativeDateFormat.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/RoleUtils.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/RoleUtils.java index ebf8c73d5cc..a02473fbe99 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/RoleUtils.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/RoleUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/checker/AuthUserPasswordChecker.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/checker/AuthUserPasswordChecker.java index 64812b2fd47..99200a83ec8 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/checker/AuthUserPasswordChecker.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/checker/AuthUserPasswordChecker.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/checker/CheckResult.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/checker/CheckResult.java index e32c2074d82..57a41125495 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/checker/CheckResult.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/checker/CheckResult.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/checker/UserPasswordChecker.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/checker/UserPasswordChecker.java index 60223487a46..f7546516f78 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/checker/UserPasswordChecker.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/checker/UserPasswordChecker.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Apollo Authors + * Copyright 2024 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/resources/apollo-env.properties b/apollo-portal/src/main/resources/apollo-env.properties index f2cdd22568e..b09ff7562de 100644 --- a/apollo-portal/src/main/resources/apollo-env.properties +++ b/apollo-portal/src/main/resources/apollo-env.properties @@ -1,5 +1,5 @@ # -# Copyright 2023 Apollo Authors +# Copyright 2024 Apollo Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/resources/apollo-portal.conf b/apollo-portal/src/main/resources/apollo-portal.conf index 19d4b8ea0be..2a2dd96e564 100644 --- a/apollo-portal/src/main/resources/apollo-portal.conf +++ b/apollo-portal/src/main/resources/apollo-portal.conf @@ -1,8 +1,8 @@ MODE=service PID_FOLDER=. # console appender log file folder -LOG_FOLDER=/opt/logs/100003173/ +LOG_FOLDER=/opt/logs/ # console appender log file name -LOG_FILENAME=console.log +LOG_FILENAME=apollo-portal.console.log # write application logs only to file appender export LOG_APPENDERS=FILE \ No newline at end of file diff --git a/apollo-portal/src/main/resources/application-github.properties b/apollo-portal/src/main/resources/application-github.properties index 3312cef3cb0..d4e117c63ca 100644 --- a/apollo-portal/src/main/resources/application-github.properties +++ b/apollo-portal/src/main/resources/application-github.properties @@ -1,5 +1,5 @@ # -# Copyright 2023 Apollo Authors +# Copyright 2024 Apollo Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/resources/application-ldap-activedirectory-sample.yml b/apollo-portal/src/main/resources/application-ldap-activedirectory-sample.yml index ed55a72a1b5..797366b7315 100644 --- a/apollo-portal/src/main/resources/application-ldap-activedirectory-sample.yml +++ b/apollo-portal/src/main/resources/application-ldap-activedirectory-sample.yml @@ -1,5 +1,5 @@ # -# Copyright 2023 Apollo Authors +# Copyright 2024 Apollo Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/resources/application-ldap-apacheds-sample.yml b/apollo-portal/src/main/resources/application-ldap-apacheds-sample.yml index 01b026a23b8..6d92be468f3 100644 --- a/apollo-portal/src/main/resources/application-ldap-apacheds-sample.yml +++ b/apollo-portal/src/main/resources/application-ldap-apacheds-sample.yml @@ -1,5 +1,5 @@ # -# Copyright 2023 Apollo Authors +# Copyright 2024 Apollo Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/resources/application-ldap-openldap-sample.yml b/apollo-portal/src/main/resources/application-ldap-openldap-sample.yml index 80aeda5b19d..cfb3e32bde6 100644 --- a/apollo-portal/src/main/resources/application-ldap-openldap-sample.yml +++ b/apollo-portal/src/main/resources/application-ldap-openldap-sample.yml @@ -1,5 +1,5 @@ # -# Copyright 2023 Apollo Authors +# Copyright 2024 Apollo Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/resources/application-oidc-sample.yml b/apollo-portal/src/main/resources/application-oidc-sample.yml index a1f53d45211..f06d455d621 100644 --- a/apollo-portal/src/main/resources/application-oidc-sample.yml +++ b/apollo-portal/src/main/resources/application-oidc-sample.yml @@ -1,5 +1,5 @@ # -# Copyright 2023 Apollo Authors +# Copyright 2024 Apollo Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/resources/application.properties b/apollo-portal/src/main/resources/application.properties index 5ede28e5782..e2f0302515c 100644 --- a/apollo-portal/src/main/resources/application.properties +++ b/apollo-portal/src/main/resources/application.properties @@ -1,5 +1,5 @@ # -# Copyright 2023 Apollo Authors +# Copyright 2024 Apollo Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,3 +22,7 @@ # You may change the following config to activate different database profiles like h2/postgres spring.profiles.group.github = mysql + +# true: enabled the new feature of audit log +# false/missing: disable it +apollo.audit.log.enabled = true diff --git a/apollo-portal/src/main/resources/application.yml b/apollo-portal/src/main/resources/application.yml index 475980fb37c..20f126490ac 100644 --- a/apollo-portal/src/main/resources/application.yml +++ b/apollo-portal/src/main/resources/application.yml @@ -1,5 +1,5 @@ # -# Copyright 2023 Apollo Authors +# Copyright 2024 Apollo Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/resources/jpa/init.h2.sql b/apollo-portal/src/main/resources/jpa/portaldb.init.h2.sql similarity index 98% rename from apollo-portal/src/main/resources/jpa/init.h2.sql rename to apollo-portal/src/main/resources/jpa/portaldb.init.h2.sql index 5e22d656906..7fdad852a2a 100644 --- a/apollo-portal/src/main/resources/jpa/init.h2.sql +++ b/apollo-portal/src/main/resources/jpa/portaldb.init.h2.sql @@ -1,5 +1,5 @@ -- --- Copyright 2023 Apollo Authors +-- Copyright 2024 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/main/resources/logback.xml b/apollo-portal/src/main/resources/logback.xml index 18c144d2a15..fc19cf9d1b7 100644 --- a/apollo-portal/src/main/resources/logback.xml +++ b/apollo-portal/src/main/resources/logback.xml @@ -1,6 +1,6 @@ + + + + + + + + + + + + + + + + + + {{'ApolloAuditLog.Title' | translate}} + + + + +
+
+
+
+

{{'ApolloAuditLog.Disabled' | translate}}

+
+

{{'ApolloAuditLog.DisabledTips' | translate}}

+

{{'ApolloAuditLog.MoreDetails' | translate}}

+
+
+
+
+
+
+
+ + +
+
+ + + + + + + + + + + + + + + +
{{'ApolloAuditLog.OpName' | translate }}{{'ApolloAuditLog.OpType' | translate }}{{'ApolloAuditLog.Operator' | translate }}{{'ApolloAuditLog.HappenedTime' | translate }}{{'ApolloAuditLog.Description' | translate }}
{{ alog.opName }}{{ alog.opType }}{{ alog.operator }}{{ alog.happenedTime | date: 'yyyy-MM-dd HH:mm:ss' }}{{ alog.description }}
+
+
+
+
+
+
{{'ApolloAuditLog.LoadMore' | translate }}
+
+
+
+
+
+
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/apollo-portal/src/main/resources/static/audit_log_trace_detail.html b/apollo-portal/src/main/resources/static/audit_log_trace_detail.html new file mode 100644 index 00000000000..e3363e39813 --- /dev/null +++ b/apollo-portal/src/main/resources/static/audit_log_trace_detail.html @@ -0,0 +1,241 @@ + + + + + + + + + + + + + + + + + + + {{ 'ApolloAuditLog.TraceDetailTips' | translate }} + + + + +
+
+
+ +
+

{{ 'ApolloAuditLog.TraceDetailTips' | translate }}

+ {{'ApolloAuditLog.TraceIdTips' | translate }}:{{traceId}} + +
+ +
+ +
+
+ +
+ + {{'ApolloAuditLog.TraceAuditLogTips' | translate }} +
+
+
+

+ {{detail.logDTO.opName}} + +

+
+
{{'ApolloAuditLog.SpanIdTips' | translate }}:{{detail.logDTO.spanId.substr(0,5)+'...'}}
+
{{'ApolloAuditLog.ParentSpan' | translate }}:{{findOpNameBySpanId(detail.logDTO.parentSpanId)}}
+
{{'ApolloAuditLog.FollowsFromSpan' | translate }}:{{findOpNameBySpanId(detail.logDTO.followsFromSpanId)}}
+
+
+
+
+ +
+
+ {{'ApolloAuditLog.RelatedDataInfluenceTips' | translate }} +
+
+
+
+

{{'ApolloAuditLog.OpType' | translate}}:{{showingDetail.logDTO.opType}}

+
+ {{'ApolloAuditLog.Operator' | translate}}:{{showingDetail.logDTO.operator}} +
+
+ {{'ApolloAuditLog.OpName' | translate}}:{{showingDetail.logDTO.opName}} +
+
+ {{'ApolloAuditLog.Description' | translate}}:{{showingDetail.logDTO.description}} +
+
+

+ {{'ApolloAuditLog.InfluenceEntity' | translate}}: +

+
+
+
+
+
+ {{'ApolloAuditLog.DataInfluence.EntityName' | translate}}: {{dataInfluenceEntity[1].name}} +
+
+ {{'ApolloAuditLog.DataInfluence.EntityId' | translate}}: {{dataInfluenceEntity[1].id}} +
+
+ {{'ApolloAuditLog.DataInfluence.AnyMatchedEntityId' | translate}} +
+
+
+
+ {{'ApolloAuditLog.DataInfluence.Fields' | translate}}: +
+
+ {{'ApolloAuditLog.DataInfluence.MatchedFields' | translate}}: +
+
+
+ {{dataInfluence.fieldName}} ==> {{dataInfluence.fieldNewValue}} +
+
+ {{dataInfluence.fieldName}} : {{dataInfluence.fieldOldValue}} ==> (deleted) +
+
+ {{dataInfluence.fieldName}} <== + {{showingDetail.logDTO.opType == 'DELETE' ? dataInfluence.fieldOldValue : dataInfluence.fieldNewValue}} +
+
+
+
+
+
{{'ApolloAuditLog.NoDataInfluence' | translate }}
+
+
+
+
+
+
+ {{'ApolloAuditLog.FieldChangeHistory' | translate }} +
+
+
+

+ {{entityNameOfFindRelated + ':' + entityIdOfFindRelated + ':' + fieldNameOfFindRelated}} +

+
+ + + + + + + + + + + + + +
{{'ApolloAuditLog.DataInfluence.FieldNewValue' | translate }}{{'ApolloAuditLog.DataInfluence.HappenedTime' | translate }}
{{ di.fieldNewValue ? di.fieldNewValue : '(deleted)' }}{{ di.happenedTime | date: 'yyyy-MM-dd HH:mm:ss' }}
+
+
+ {{'ApolloAuditLog.DataInfluence.LoadMore' | translate }} +
+
+
{{'ApolloAuditLog.NoDataInfluence' | translate }}
+
+
+
+
+
+ +
+

+ {{'ApolloAuditLog.NoTraceDetail' | translate }}

+
+
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/apollo-portal/src/main/resources/static/cluster.html b/apollo-portal/src/main/resources/static/cluster.html index d14eb79327f..ed1a01a5a60 100644 --- a/apollo-portal/src/main/resources/static/cluster.html +++ b/apollo-portal/src/main/resources/static/cluster.html @@ -1,5 +1,5 @@ 4.2.0 3.12.0 2.10.1 - 31.1-jre + 32.0.0-jre 3.23.1-GA 1.1.1 1.6.2 @@ -102,7 +102,8 @@ apollo-adminservice apollo-portal apollo-assembly - + apollo-audit + @@ -146,6 +147,27 @@ apollo-openapi ${apollo-java.version}
+ + + com.ctrip.framework.apollo + apollo-audit-annotation + ${project.version} + + + com.ctrip.framework.apollo + apollo-audit-impl + ${project.version} + + + com.ctrip.framework.apollo + apollo-audit-api + ${project.version} + + + com.ctrip.framework.apollo + apollo-audit-spring-boot-starter + ${project.version} + com.google.guava @@ -424,7 +446,7 @@ ch.qos.logback logback-classic - 1.2.0 + 1.3.12 diff --git a/scripts/build.bat b/scripts/build.bat index b4cda177b53..938c968a523 100644 --- a/scripts/build.bat +++ b/scripts/build.bat @@ -1,5 +1,5 @@ rem -rem Copyright 2023 Apollo Authors +rem Copyright 2024 Apollo Authors rem rem Licensed under the Apache License, Version 2.0 (the "License"); rem you may not use this file except in compliance with the License. diff --git a/scripts/build.sh b/scripts/build.sh index abe30a22e30..51485c33176 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright 2023 Apollo Authors +# Copyright 2024 Apollo Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/scripts/openapi/bash/openapi-usage-example.sh b/scripts/openapi/bash/openapi-usage-example.sh index 5c31830aa2b..620b5491331 100644 --- a/scripts/openapi/bash/openapi-usage-example.sh +++ b/scripts/openapi/bash/openapi-usage-example.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright 2023 Apollo Authors +# Copyright 2024 Apollo Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/scripts/openapi/bash/openapi.sh b/scripts/openapi/bash/openapi.sh index 6a7303ee972..2b55412c3d2 100644 --- a/scripts/openapi/bash/openapi.sh +++ b/scripts/openapi/bash/openapi.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright 2023 Apollo Authors +# Copyright 2024 Apollo Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/scripts/sql/apolloconfigdb.sql b/scripts/sql/apolloconfigdb.sql index 40f6c81a54f..301f1ebe838 100644 --- a/scripts/sql/apolloconfigdb.sql +++ b/scripts/sql/apolloconfigdb.sql @@ -1,5 +1,5 @@ -- --- Copyright 2023 Apollo Authors +-- Copyright 2024 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. @@ -113,6 +113,7 @@ CREATE TABLE `Cluster` ( `Name` varchar(32) NOT NULL DEFAULT '' COMMENT '集群名字', `AppId` varchar(64) NOT NULL DEFAULT '' COMMENT 'App id', `ParentClusterId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '父cluster', + `Comment` varchar(64) DEFAULT NULL COMMENT '备注', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', @@ -429,6 +430,58 @@ CREATE TABLE `ServiceRegistry` ( INDEX `IX_DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='注册中心'; +# Dump of table AuditLog +# ------------------------------------------------------------ + +DROP TABLE IF EXISTS `AuditLog`; + +CREATE TABLE `AuditLog` ( + `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `TraceId` varchar(32) NOT NULL DEFAULT '' COMMENT '链路全局唯一ID', + `SpanId` varchar(32) NOT NULL DEFAULT '' COMMENT '跨度ID', + `ParentSpanId` varchar(32) DEFAULT NULL COMMENT '父跨度ID', + `FollowsFromSpanId` varchar(32) DEFAULT NULL COMMENT '上一个兄弟跨度ID', + `Operator` varchar(64) NOT NULL DEFAULT 'anonymous' COMMENT '操作人', + `OpType` varchar(50) NOT NULL DEFAULT 'default' COMMENT '操作类型', + `OpName` varchar(150) NOT NULL DEFAULT 'default' COMMENT '操作名称', + `Description` varchar(200) DEFAULT NULL COMMENT '备注', + `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_CreatedBy` varchar(64) DEFAULT NULL COMMENT '创建人邮箱前缀', + `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', + `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', + PRIMARY KEY (`Id`), + KEY `IX_TraceId` (`TraceId`), + KEY `IX_OpName` (`OpName`), + KEY `IX_DataChange_CreatedTime` (`DataChange_CreatedTime`), + KEY `IX_Operator` (`Operator`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='审计日志表'; + +# Dump of table AuditLogDataInfluence +# ------------------------------------------------------------ + +DROP TABLE IF EXISTS `AuditLogDataInfluence`; + +CREATE TABLE `AuditLogDataInfluence` ( + `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `SpanId` char(32) NOT NULL DEFAULT '' COMMENT '跨度ID', + `InfluenceEntityId` varchar(50) NOT NULL DEFAULT '0' COMMENT '记录ID', + `InfluenceEntityName` varchar(50) NOT NULL DEFAULT 'default' COMMENT '表名', + `FieldName` varchar(50) DEFAULT NULL COMMENT '字段名称', + `FieldOldValue` varchar(500) DEFAULT NULL COMMENT '字段旧值', + `FieldNewValue` varchar(500) DEFAULT NULL COMMENT '字段新值', + `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_CreatedBy` varchar(64) DEFAULT NULL COMMENT '创建人邮箱前缀', + `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', + `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', + PRIMARY KEY (`Id`), + KEY `IX_SpanId` (`SpanId`), + KEY `IX_DataChange_CreatedTime` (`DataChange_CreatedTime`), + KEY `IX_EntityId` (`InfluenceEntityId`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='审计日志数据变动表'; # Config # ------------------------------------------------------------ diff --git a/scripts/sql/apolloportaldb.sql b/scripts/sql/apolloportaldb.sql index a006b5362df..8af0c276f0d 100644 --- a/scripts/sql/apolloportaldb.sql +++ b/scripts/sql/apolloportaldb.sql @@ -1,5 +1,5 @@ -- --- Copyright 2023 Apollo Authors +-- Copyright 2024 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. @@ -330,6 +330,91 @@ CREATE TABLE `Authorities` ( PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +-- spring session (https://github.com/spring-projects/spring-session/blob/faee8f1bdb8822a5653a81eba838dddf224d92d6/spring-session-jdbc/src/main/resources/org/springframework/session/jdbc/schema-mysql.sql) +# Dump of table SPRING_SESSION +# ------------------------------------------------------------ + +DROP TABLE IF EXISTS `SPRING_SESSION`; + +CREATE TABLE `SPRING_SESSION` ( + `PRIMARY_ID` char(36) NOT NULL, + `SESSION_ID` char(36) NOT NULL, + `CREATION_TIME` bigint NOT NULL, + `LAST_ACCESS_TIME` bigint NOT NULL, + `MAX_INACTIVE_INTERVAL` int NOT NULL, + `EXPIRY_TIME` bigint NOT NULL, + `PRINCIPAL_NAME` varchar(100) DEFAULT NULL, + PRIMARY KEY (`PRIMARY_ID`), + UNIQUE KEY `SPRING_SESSION_IX1` (`SESSION_ID`), + KEY `SPRING_SESSION_IX2` (`EXPIRY_TIME`), + KEY `SPRING_SESSION_IX3` (`PRINCIPAL_NAME`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC; + +# Dump of table SPRING_SESSION_ATTRIBUTES +# ------------------------------------------------------------ + +DROP TABLE IF EXISTS `SPRING_SESSION_ATTRIBUTES`; + +CREATE TABLE `SPRING_SESSION_ATTRIBUTES` ( + `SESSION_PRIMARY_ID` char(36) NOT NULL, + `ATTRIBUTE_NAME` varchar(200) NOT NULL, + `ATTRIBUTE_BYTES` blob NOT NULL, + PRIMARY KEY (`SESSION_PRIMARY_ID`,`ATTRIBUTE_NAME`), + CONSTRAINT `SPRING_SESSION_ATTRIBUTES_FK` FOREIGN KEY (`SESSION_PRIMARY_ID`) REFERENCES `SPRING_SESSION` (`PRIMARY_ID`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC; + +# Dump of table AuditLog +# ------------------------------------------------------------ + +DROP TABLE IF EXISTS `AuditLog`; + +CREATE TABLE `AuditLog` ( + `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `TraceId` varchar(32) NOT NULL DEFAULT '' COMMENT '链路全局唯一ID', + `SpanId` varchar(32) NOT NULL DEFAULT '' COMMENT '跨度ID', + `ParentSpanId` varchar(32) DEFAULT NULL COMMENT '父跨度ID', + `FollowsFromSpanId` varchar(32) DEFAULT NULL COMMENT '上一个兄弟跨度ID', + `Operator` varchar(64) NOT NULL DEFAULT 'anonymous' COMMENT '操作人', + `OpType` varchar(50) NOT NULL DEFAULT 'default' COMMENT '操作类型', + `OpName` varchar(150) NOT NULL DEFAULT 'default' COMMENT '操作名称', + `Description` varchar(200) DEFAULT NULL COMMENT '备注', + `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_CreatedBy` varchar(64) DEFAULT NULL COMMENT '创建人邮箱前缀', + `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', + `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', + PRIMARY KEY (`Id`), + KEY `IX_TraceId` (`TraceId`), + KEY `IX_OpName` (`OpName`), + KEY `IX_DataChange_CreatedTime` (`DataChange_CreatedTime`), + KEY `IX_Operator` (`Operator`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='审计日志表'; + +# Dump of table AuditLogDataInfluence +# ------------------------------------------------------------ + +DROP TABLE IF EXISTS `AuditLogDataInfluence`; + +CREATE TABLE `AuditLogDataInfluence` ( + `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `SpanId` char(32) NOT NULL DEFAULT '' COMMENT '跨度ID', + `InfluenceEntityId` varchar(50) NOT NULL DEFAULT '0' COMMENT '记录ID', + `InfluenceEntityName` varchar(50) NOT NULL DEFAULT 'default' COMMENT '表名', + `FieldName` varchar(50) DEFAULT NULL COMMENT '字段名称', + `FieldOldValue` varchar(500) DEFAULT NULL COMMENT '字段旧值', + `FieldNewValue` varchar(500) DEFAULT NULL COMMENT '字段新值', + `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_CreatedBy` varchar(64) DEFAULT NULL COMMENT '创建人邮箱前缀', + `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', + `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', + PRIMARY KEY (`Id`), + KEY `IX_SpanId` (`SpanId`), + KEY `IX_DataChange_CreatedTime` (`DataChange_CreatedTime`), + KEY `IX_EntityId` (`InfluenceEntityId`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='审计日志数据变动表'; # Config # ------------------------------------------------------------ @@ -351,33 +436,9 @@ VALUES INSERT INTO `Authorities` (`Username`, `Authority`) VALUES ('apollo', 'ROLE_user'); --- spring session (https://github.com/spring-projects/spring-session/blob/faee8f1bdb8822a5653a81eba838dddf224d92d6/spring-session-jdbc/src/main/resources/org/springframework/session/jdbc/schema-mysql.sql) -CREATE TABLE SPRING_SESSION ( - PRIMARY_ID CHAR(36) NOT NULL, - SESSION_ID CHAR(36) NOT NULL, - CREATION_TIME BIGINT NOT NULL, - LAST_ACCESS_TIME BIGINT NOT NULL, - MAX_INACTIVE_INTERVAL INT NOT NULL, - EXPIRY_TIME BIGINT NOT NULL, - PRINCIPAL_NAME VARCHAR(100), - CONSTRAINT SPRING_SESSION_PK PRIMARY KEY (PRIMARY_ID) -) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; - -CREATE UNIQUE INDEX SPRING_SESSION_IX1 ON SPRING_SESSION (SESSION_ID); -CREATE INDEX SPRING_SESSION_IX2 ON SPRING_SESSION (EXPIRY_TIME); -CREATE INDEX SPRING_SESSION_IX3 ON SPRING_SESSION (PRINCIPAL_NAME); - -CREATE TABLE SPRING_SESSION_ATTRIBUTES ( - SESSION_PRIMARY_ID CHAR(36) NOT NULL, - ATTRIBUTE_NAME VARCHAR(200) NOT NULL, - ATTRIBUTE_BYTES BLOB NOT NULL, - CONSTRAINT SPRING_SESSION_ATTRIBUTES_PK PRIMARY KEY (SESSION_PRIMARY_ID, ATTRIBUTE_NAME), - CONSTRAINT SPRING_SESSION_ATTRIBUTES_FK FOREIGN KEY (SESSION_PRIMARY_ID) REFERENCES SPRING_SESSION(PRIMARY_ID) ON DELETE CASCADE -) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; - /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; \ No newline at end of file diff --git a/scripts/sql/delta/v040-v050/apolloconfigdb-v040-v050.sql b/scripts/sql/delta/v040-v050/apolloconfigdb-v040-v050.sql index 094cd542211..a2c1b518e44 100644 --- a/scripts/sql/delta/v040-v050/apolloconfigdb-v040-v050.sql +++ b/scripts/sql/delta/v040-v050/apolloconfigdb-v040-v050.sql @@ -1,5 +1,5 @@ -- --- Copyright 2023 Apollo Authors +-- Copyright 2024 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. diff --git a/scripts/sql/delta/v040-v050/apolloportaldb-v040-v050.sql b/scripts/sql/delta/v040-v050/apolloportaldb-v040-v050.sql index 24f64e5af87..2f379b5c011 100644 --- a/scripts/sql/delta/v040-v050/apolloportaldb-v040-v050.sql +++ b/scripts/sql/delta/v040-v050/apolloportaldb-v040-v050.sql @@ -1,5 +1,5 @@ -- --- Copyright 2023 Apollo Authors +-- Copyright 2024 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. diff --git a/scripts/sql/delta/v060-v062/apolloconfigdb-v060-v062.sql b/scripts/sql/delta/v060-v062/apolloconfigdb-v060-v062.sql index 8e56b163ad9..7ceb815eacf 100644 --- a/scripts/sql/delta/v060-v062/apolloconfigdb-v060-v062.sql +++ b/scripts/sql/delta/v060-v062/apolloconfigdb-v060-v062.sql @@ -1,5 +1,5 @@ -- --- Copyright 2023 Apollo Authors +-- Copyright 2024 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. diff --git a/scripts/sql/delta/v060-v062/apolloportaldb-v060-v062.sql b/scripts/sql/delta/v060-v062/apolloportaldb-v060-v062.sql index 48a2b60b419..39e14a6f64e 100644 --- a/scripts/sql/delta/v060-v062/apolloportaldb-v060-v062.sql +++ b/scripts/sql/delta/v060-v062/apolloportaldb-v060-v062.sql @@ -1,5 +1,5 @@ -- --- Copyright 2023 Apollo Authors +-- Copyright 2024 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. diff --git a/scripts/sql/delta/v080-v090/apolloportaldb-v080-v090.sql b/scripts/sql/delta/v080-v090/apolloportaldb-v080-v090.sql index 9904bbc1ada..5b92094f8fb 100644 --- a/scripts/sql/delta/v080-v090/apolloportaldb-v080-v090.sql +++ b/scripts/sql/delta/v080-v090/apolloportaldb-v080-v090.sql @@ -1,5 +1,5 @@ -- --- Copyright 2023 Apollo Authors +-- Copyright 2024 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. diff --git a/scripts/sql/delta/v151-v160/apolloconfigdb-v151-v160.sql b/scripts/sql/delta/v151-v160/apolloconfigdb-v151-v160.sql index 7c28d69b2bc..7adf6340c6c 100644 --- a/scripts/sql/delta/v151-v160/apolloconfigdb-v151-v160.sql +++ b/scripts/sql/delta/v151-v160/apolloconfigdb-v151-v160.sql @@ -1,5 +1,5 @@ -- --- Copyright 2023 Apollo Authors +-- Copyright 2024 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. diff --git a/scripts/sql/delta/v170-v180/apolloconfigdb-v170-v180.sql b/scripts/sql/delta/v170-v180/apolloconfigdb-v170-v180.sql index 9ffa526032c..ad2fb5eab9e 100644 --- a/scripts/sql/delta/v170-v180/apolloconfigdb-v170-v180.sql +++ b/scripts/sql/delta/v170-v180/apolloconfigdb-v170-v180.sql @@ -1,5 +1,5 @@ -- --- Copyright 2023 Apollo Authors +-- Copyright 2024 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. diff --git a/scripts/sql/delta/v170-v180/apolloportaldb-v170-v180.sql b/scripts/sql/delta/v170-v180/apolloportaldb-v170-v180.sql index eaf406e97da..89eec98d1fc 100644 --- a/scripts/sql/delta/v170-v180/apolloportaldb-v170-v180.sql +++ b/scripts/sql/delta/v170-v180/apolloportaldb-v170-v180.sql @@ -1,5 +1,5 @@ -- --- Copyright 2023 Apollo Authors +-- Copyright 2024 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. diff --git a/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190.sql b/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190.sql index 2671edb8304..7038cb5af44 100644 --- a/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190.sql +++ b/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190.sql @@ -1,5 +1,5 @@ -- --- Copyright 2023 Apollo Authors +-- Copyright 2024 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. diff --git a/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190.sql b/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190.sql index 0c09401c2cb..0edeac99808 100644 --- a/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190.sql +++ b/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190.sql @@ -1,5 +1,5 @@ -- --- Copyright 2023 Apollo Authors +-- Copyright 2024 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. diff --git a/scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200-after.sql b/scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200-after.sql index dc46a635787..3ed6d2bf593 100644 --- a/scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200-after.sql +++ b/scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200-after.sql @@ -1,5 +1,5 @@ -- --- Copyright 2023 Apollo Authors +-- Copyright 2024 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. diff --git a/scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200.sql b/scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200.sql index 0dd06b432b9..f39c40ad2b3 100644 --- a/scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200.sql +++ b/scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200.sql @@ -1,5 +1,5 @@ -- --- Copyright 2023 Apollo Authors +-- Copyright 2024 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. diff --git a/scripts/sql/delta/v190-v200/apolloportaldb-v190-v200-after.sql b/scripts/sql/delta/v190-v200/apolloportaldb-v190-v200-after.sql index 204aef8d220..6bbb3bda324 100644 --- a/scripts/sql/delta/v190-v200/apolloportaldb-v190-v200-after.sql +++ b/scripts/sql/delta/v190-v200/apolloportaldb-v190-v200-after.sql @@ -1,5 +1,5 @@ -- --- Copyright 2023 Apollo Authors +-- Copyright 2024 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. diff --git a/scripts/sql/delta/v190-v200/apolloportaldb-v190-v200.sql b/scripts/sql/delta/v190-v200/apolloportaldb-v190-v200.sql index 1582a1a0374..0f287f88fc8 100644 --- a/scripts/sql/delta/v190-v200/apolloportaldb-v190-v200.sql +++ b/scripts/sql/delta/v190-v200/apolloportaldb-v190-v200.sql @@ -1,5 +1,5 @@ -- --- Copyright 2023 Apollo Authors +-- Copyright 2024 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. diff --git a/scripts/sql/delta/v200-v210/apolloconfigdb-v200-v210.sql b/scripts/sql/delta/v200-v210/apolloconfigdb-v200-v210.sql index 8ce329fb7a6..ad84a9e78f7 100644 --- a/scripts/sql/delta/v200-v210/apolloconfigdb-v200-v210.sql +++ b/scripts/sql/delta/v200-v210/apolloconfigdb-v200-v210.sql @@ -1,5 +1,5 @@ -- --- Copyright 2023 Apollo Authors +-- Copyright 2024 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. diff --git a/scripts/sql/delta/v210-v220/apolloconfigdb-v210-v220.sql b/scripts/sql/delta/v210-v220/apolloconfigdb-v210-v220.sql index 3021a270f26..81183f62c5e 100644 --- a/scripts/sql/delta/v210-v220/apolloconfigdb-v210-v220.sql +++ b/scripts/sql/delta/v210-v220/apolloconfigdb-v210-v220.sql @@ -1,5 +1,5 @@ -- --- Copyright 2023 Apollo Authors +-- Copyright 2024 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. @@ -42,4 +42,52 @@ ALTER TABLE `Namespace` ALTER TABLE `Release` DROP INDEX `AppId_ClusterName_GroupName`, - ADD INDEX `AppId_ClusterName_GroupName` (`AppId`,`ClusterName`(191),`NamespaceName`(191),`DeletedAt`); \ No newline at end of file + ADD INDEX `AppId_ClusterName_GroupName` (`AppId`,`ClusterName`(191),`NamespaceName`(191),`DeletedAt`); + +DROP TABLE IF EXISTS `AuditLog`; + +CREATE TABLE `AuditLog` ( + `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `TraceId` varchar(32) NOT NULL DEFAULT '' COMMENT '链路全局唯一ID', + `SpanId` varchar(32) NOT NULL DEFAULT '' COMMENT '跨度ID', + `ParentSpanId` varchar(32) DEFAULT NULL COMMENT '父跨度ID', + `FollowsFromSpanId` varchar(32) DEFAULT NULL COMMENT '上一个兄弟跨度ID', + `Operator` varchar(64) NOT NULL DEFAULT 'anonymous' COMMENT '操作人', + `OpType` varchar(50) NOT NULL DEFAULT 'default' COMMENT '操作类型', + `OpName` varchar(150) NOT NULL DEFAULT 'default' COMMENT '操作名称', + `Description` varchar(200) DEFAULT NULL COMMENT '备注', + `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_CreatedBy` varchar(64) DEFAULT NULL COMMENT '创建人邮箱前缀', + `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', + `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', + PRIMARY KEY (`Id`), + KEY `IX_TraceId` (`TraceId`), + KEY `IX_OpName` (`OpName`), + KEY `IX_DataChange_CreatedTime` (`DataChange_CreatedTime`), + KEY `IX_Operator` (`Operator`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='审计日志表'; + + +DROP TABLE IF EXISTS `AuditLogDataInfluence`; + +CREATE TABLE `AuditLogDataInfluence` ( + `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `SpanId` char(32) NOT NULL DEFAULT '' COMMENT '跨度ID', + `InfluenceEntityId` varchar(50) NOT NULL DEFAULT '0' COMMENT '记录ID', + `InfluenceEntityName` varchar(50) NOT NULL DEFAULT 'default' COMMENT '表名', + `FieldName` varchar(50) DEFAULT NULL COMMENT '字段名称', + `FieldOldValue` varchar(500) DEFAULT NULL COMMENT '字段旧值', + `FieldNewValue` varchar(500) DEFAULT NULL COMMENT '字段新值', + `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_CreatedBy` varchar(64) DEFAULT NULL COMMENT '创建人邮箱前缀', + `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', + `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', + PRIMARY KEY (`Id`), + KEY `IX_SpanId` (`SpanId`), + KEY `IX_DataChange_CreatedTime` (`DataChange_CreatedTime`), + KEY `IX_EntityId` (`InfluenceEntityId`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='审计日志数据变动表'; \ No newline at end of file diff --git a/scripts/sql/delta/v210-v220/apolloportaldb-v210-v220.sql b/scripts/sql/delta/v210-v220/apolloportaldb-v210-v220.sql index 086769c357e..c2c0ab7083c 100644 --- a/scripts/sql/delta/v210-v220/apolloportaldb-v210-v220.sql +++ b/scripts/sql/delta/v210-v220/apolloportaldb-v210-v220.sql @@ -1,5 +1,5 @@ -- --- Copyright 2023 Apollo Authors +-- Copyright 2024 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. @@ -28,4 +28,52 @@ ALTER TABLE `Favorite` ALTER TABLE `Favorite` DROP INDEX `AppId`, - ADD INDEX `AppId` (`AppId`); \ No newline at end of file + ADD INDEX `AppId` (`AppId`); + +DROP TABLE IF EXISTS `AuditLog`; + +CREATE TABLE `AuditLog` ( + `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `TraceId` varchar(32) NOT NULL DEFAULT '' COMMENT '链路全局唯一ID', + `SpanId` varchar(32) NOT NULL DEFAULT '' COMMENT '跨度ID', + `ParentSpanId` varchar(32) DEFAULT NULL COMMENT '父跨度ID', + `FollowsFromSpanId` varchar(32) DEFAULT NULL COMMENT '上一个兄弟跨度ID', + `Operator` varchar(64) NOT NULL DEFAULT 'anonymous' COMMENT '操作人', + `OpType` varchar(50) NOT NULL DEFAULT 'default' COMMENT '操作类型', + `OpName` varchar(150) NOT NULL DEFAULT 'default' COMMENT '操作名称', + `Description` varchar(200) DEFAULT NULL COMMENT '备注', + `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_CreatedBy` varchar(64) DEFAULT NULL COMMENT '创建人邮箱前缀', + `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', + `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', + PRIMARY KEY (`Id`), + KEY `IX_TraceId` (`TraceId`), + KEY `IX_OpName` (`OpName`), + KEY `IX_DataChange_CreatedTime` (`DataChange_CreatedTime`), + KEY `IX_Operator` (`Operator`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='审计日志表'; + + +DROP TABLE IF EXISTS `AuditLogDataInfluence`; + +CREATE TABLE `AuditLogDataInfluence` ( + `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `SpanId` char(32) NOT NULL DEFAULT '' COMMENT '跨度ID', + `InfluenceEntityId` varchar(50) NOT NULL DEFAULT '0' COMMENT '记录ID', + `InfluenceEntityName` varchar(50) NOT NULL DEFAULT 'default' COMMENT '表名', + `FieldName` varchar(50) DEFAULT NULL COMMENT '字段名称', + `FieldOldValue` varchar(500) DEFAULT NULL COMMENT '字段旧值', + `FieldNewValue` varchar(500) DEFAULT NULL COMMENT '字段新值', + `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_CreatedBy` varchar(64) DEFAULT NULL COMMENT '创建人邮箱前缀', + `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', + `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', + PRIMARY KEY (`Id`), + KEY `IX_SpanId` (`SpanId`), + KEY `IX_DataChange_CreatedTime` (`DataChange_CreatedTime`), + KEY `IX_EntityId` (`InfluenceEntityId`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='审计日志数据变动表'; \ No newline at end of file diff --git a/scripts/sql/delta/v220-v230/apolloconfigdb-v220-v230.sql b/scripts/sql/delta/v220-v230/apolloconfigdb-v220-v230.sql new file mode 100644 index 00000000000..412b67f5fd2 --- /dev/null +++ b/scripts/sql/delta/v220-v230/apolloconfigdb-v220-v230.sql @@ -0,0 +1,21 @@ +-- +-- Copyright 2024 Apollo Authors +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +# delta schema to upgrade apollo config db from v2.2.0 to v2.3.0 + +Use ApolloConfigDB; + +ALTER TABLE `Cluster` + ADD COLUMN `Comment` varchar(64) DEFAULT NULL COMMENT '备注'; \ No newline at end of file