From 5e42e2f59456b43196f718668300ef86c0a13a20 Mon Sep 17 00:00:00 2001 From: alex-odysseus <75131044+alex-odysseus@users.noreply.github.com> Date: Thu, 10 Mar 2022 13:40:02 +0100 Subject: [PATCH] Merging the latest 'qa' into 'master' (#303) * Change version to 1.19.0-SNAPSHOT * 1.19.0-QA version (#297) * updated id and name * updated id and name * Added functionality for disabling modules (https://github.com/OHDSI/ArachneUI/issues/859) * fixed after review(https://github.com/OHDSI/ArachneUI/issues/859) * updated version to 1.19.1 * Bump commons-compress from 1.19 to 1.21 in /arachne-commons (#295) Bumps commons-compress from 1.19 to 1.21. --- updated-dependencies: - dependency-name: org.apache.commons:commons-compress dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump cron-utils from 9.1.3 to 9.1.6 in /arachne-scheduler (#299) Bumps [cron-utils](https://github.com/jmrozanec/cron-utils) from 9.1.3 to 9.1.6. - [Release notes](https://github.com/jmrozanec/cron-utils/releases) - [Commits](https://github.com/jmrozanec/cron-utils/compare/9.1.3...9.1.6) --- updated-dependencies: - dependency-name: com.cronutils:cron-utils dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Added Spark to DBMSType (#300) * 1.19.0-QA based on the latest origin/develop Co-authored-by: Sergey Suvorov Co-authored-by: Dmitry S <87665105+dmitrys-odysseus@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ajit Londhe --- arachne-common-types/pom.xml | 2 +- .../arachne/commons/types/DBMSType.java | 3 +- arachne-common-utils/pom.xml | 2 +- arachne-commons/pom.xml | 12 ++++- .../controller/ModuleSettingsController.java | 49 +++++++++++++++++++ .../modules/ModuleAccessException.java | 18 +++++++ .../conditions/modules/ModuleEnabled.java | 12 +++++ .../modules/ModuleEnabledAspect.java | 34 +++++++++++++ .../commons/config/ArachneConfiguration.java | 26 ++++++++++ .../pom.xml | 2 +- arachne-scheduler/pom.xml | 4 +- arachne-storage/pom.xml | 2 +- arachne-sys-settings/pom.xml | 2 +- data-source-manager/pom.xml | 2 +- execution-engine-commons/pom.xml | 2 +- logging/pom.xml | 2 +- pom.xml | 7 ++- 17 files changed, 167 insertions(+), 14 deletions(-) create mode 100644 arachne-commons/src/main/java/com/odysseusinc/arachne/commons/api/v1/controller/ModuleSettingsController.java create mode 100644 arachne-commons/src/main/java/com/odysseusinc/arachne/commons/conditions/modules/ModuleAccessException.java create mode 100644 arachne-commons/src/main/java/com/odysseusinc/arachne/commons/conditions/modules/ModuleEnabled.java create mode 100644 arachne-commons/src/main/java/com/odysseusinc/arachne/commons/conditions/modules/ModuleEnabledAspect.java create mode 100644 arachne-commons/src/main/java/com/odysseusinc/arachne/commons/config/ArachneConfiguration.java diff --git a/arachne-common-types/pom.xml b/arachne-common-types/pom.xml index 8f18993a..f5c02c7b 100644 --- a/arachne-common-types/pom.xml +++ b/arachne-common-types/pom.xml @@ -5,7 +5,7 @@ arachne-commons-bundle com.odysseusinc.arachne - 1.18.0 + 1.19.0 ../pom.xml 4.0.0 diff --git a/arachne-common-types/src/main/java/com/odysseusinc/arachne/commons/types/DBMSType.java b/arachne-common-types/src/main/java/com/odysseusinc/arachne/commons/types/DBMSType.java index a97c3541..90b2a979 100644 --- a/arachne-common-types/src/main/java/com/odysseusinc/arachne/commons/types/DBMSType.java +++ b/arachne-common-types/src/main/java/com/odysseusinc/arachne/commons/types/DBMSType.java @@ -32,7 +32,8 @@ public enum DBMSType { IMPALA("Impala", "impala"), BIGQUERY("Google BigQuery", "bigquery"), NETEZZA("Netezza", "netezza"), - HIVE("Apache Hive", "hive"); + HIVE("Apache Hive", "hive"), + SPARK("Spark", "spark"); private String label; // For further pass into SqlRender.translateSql as "targetDialect" and DatabaseConnector as "dbms" diff --git a/arachne-common-utils/pom.xml b/arachne-common-utils/pom.xml index 47f7dd86..d38e43f2 100644 --- a/arachne-common-utils/pom.xml +++ b/arachne-common-utils/pom.xml @@ -5,7 +5,7 @@ arachne-commons-bundle com.odysseusinc.arachne - 1.18.0 + 1.19.0 ../pom.xml 4.0.0 diff --git a/arachne-commons/pom.xml b/arachne-commons/pom.xml index a8c9f431..5558b255 100644 --- a/arachne-commons/pom.xml +++ b/arachne-commons/pom.xml @@ -7,7 +7,7 @@ com.odysseusinc.arachne arachne-commons-bundle - 1.18.0 + 1.19.0 ../pom.xml @@ -26,6 +26,14 @@ org.apache.commons commons-lang3 + + org.springframework + spring-aspects + + + org.springframework.boot + spring-boot-starter-web + org.springframework.boot spring-boot-starter-validation @@ -62,7 +70,7 @@ org.apache.commons commons-compress - 1.19 + 1.21 org.apache.tika diff --git a/arachne-commons/src/main/java/com/odysseusinc/arachne/commons/api/v1/controller/ModuleSettingsController.java b/arachne-commons/src/main/java/com/odysseusinc/arachne/commons/api/v1/controller/ModuleSettingsController.java new file mode 100644 index 00000000..466fd739 --- /dev/null +++ b/arachne-commons/src/main/java/com/odysseusinc/arachne/commons/api/v1/controller/ModuleSettingsController.java @@ -0,0 +1,49 @@ +/* + * + * Copyright 2018 Odysseus Data Services, inc. + * 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. + * + * Company: Odysseus Data Services, Inc. + * Product Owner/Architecture: Gregory Klebanov + * Authors: Sergey Suvorov + * Created: September 27, 2021 + * + */ + +package com.odysseusinc.arachne.commons.api.v1.controller; + +import com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult; +import com.odysseusinc.arachne.commons.config.ArachneConfiguration; +import io.swagger.annotations.Api; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@Api +@RestController +public class ModuleSettingsController { + private final ArachneConfiguration arachneConfiguration; + + public ModuleSettingsController(ArachneConfiguration arachneConfiguration) { + this.arachneConfiguration = arachneConfiguration; + } + + @RequestMapping(value = "/api/v1/modules/disabled-modules", method = RequestMethod.GET) + public JsonResult> getDisabledModules() { + JsonResult> result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR); + result.setResult(arachneConfiguration.getDisabledModules()); + return result; + } +} diff --git a/arachne-commons/src/main/java/com/odysseusinc/arachne/commons/conditions/modules/ModuleAccessException.java b/arachne-commons/src/main/java/com/odysseusinc/arachne/commons/conditions/modules/ModuleAccessException.java new file mode 100644 index 00000000..d21d1878 --- /dev/null +++ b/arachne-commons/src/main/java/com/odysseusinc/arachne/commons/conditions/modules/ModuleAccessException.java @@ -0,0 +1,18 @@ +package com.odysseusinc.arachne.commons.conditions.modules; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; + +@ResponseStatus(HttpStatus.NOT_FOUND) +public class ModuleAccessException extends RuntimeException { + private String module; + + public ModuleAccessException(String module) { + this.module = module; + } + + @Override + public String getMessage() { + return String.format("Module %s is disabled", this.module); + } +} diff --git a/arachne-commons/src/main/java/com/odysseusinc/arachne/commons/conditions/modules/ModuleEnabled.java b/arachne-commons/src/main/java/com/odysseusinc/arachne/commons/conditions/modules/ModuleEnabled.java new file mode 100644 index 00000000..97bfe905 --- /dev/null +++ b/arachne-commons/src/main/java/com/odysseusinc/arachne/commons/conditions/modules/ModuleEnabled.java @@ -0,0 +1,12 @@ +package com.odysseusinc.arachne.commons.conditions.modules; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.TYPE, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface ModuleEnabled { + String value(); +} diff --git a/arachne-commons/src/main/java/com/odysseusinc/arachne/commons/conditions/modules/ModuleEnabledAspect.java b/arachne-commons/src/main/java/com/odysseusinc/arachne/commons/conditions/modules/ModuleEnabledAspect.java new file mode 100644 index 00000000..3e123d4b --- /dev/null +++ b/arachne-commons/src/main/java/com/odysseusinc/arachne/commons/conditions/modules/ModuleEnabledAspect.java @@ -0,0 +1,34 @@ +package com.odysseusinc.arachne.commons.conditions.modules; + +import com.odysseusinc.arachne.commons.config.ArachneConfiguration; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.springframework.stereotype.Component; + +@Aspect +@Component +public class ModuleEnabledAspect { + private final ArachneConfiguration arachneConfiguration; + + public ModuleEnabledAspect(ArachneConfiguration arachneConfiguration) { + this.arachneConfiguration = arachneConfiguration; + } + + @Around("@within(moduleEnabled)") + public Object checkClassEnabled(ProceedingJoinPoint joinPoint, ModuleEnabled moduleEnabled) throws Throwable { + return checkModuleEnabled(joinPoint, moduleEnabled); + } + + @Around("@annotation(moduleEnabled)") + public Object checkMethodEnabled(ProceedingJoinPoint joinPoint, ModuleEnabled moduleEnabled) throws Throwable { + return checkModuleEnabled(joinPoint, moduleEnabled); + } + + private Object checkModuleEnabled(ProceedingJoinPoint joinPoint, ModuleEnabled moduleEnabled) throws Throwable { + if (arachneConfiguration.isModuleDisabled(moduleEnabled.value())) { + throw new ModuleAccessException(moduleEnabled.value()); + } + return joinPoint.proceed(); + } +} diff --git a/arachne-commons/src/main/java/com/odysseusinc/arachne/commons/config/ArachneConfiguration.java b/arachne-commons/src/main/java/com/odysseusinc/arachne/commons/config/ArachneConfiguration.java new file mode 100644 index 00000000..71358c1d --- /dev/null +++ b/arachne-commons/src/main/java/com/odysseusinc/arachne/commons/config/ArachneConfiguration.java @@ -0,0 +1,26 @@ +package com.odysseusinc.arachne.commons.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +import java.util.List; + +@Configuration +@ConfigurationProperties(prefix = "arachne") +public class ArachneConfiguration { + @Value("${disabledModules:}") + private List disabledModules; + + public List getDisabledModules() { + return disabledModules; + } + + public void setDisabledModules(List disabledModules) { + this.disabledModules = disabledModules; + } + + public boolean isModuleDisabled(String module) { + return this.disabledModules != null && this.disabledModules.contains(module); + } +} diff --git a/arachne-no-handler-found-exception-util/pom.xml b/arachne-no-handler-found-exception-util/pom.xml index 617b5aea..a1b7666e 100644 --- a/arachne-no-handler-found-exception-util/pom.xml +++ b/arachne-no-handler-found-exception-util/pom.xml @@ -7,7 +7,7 @@ com.odysseusinc.arachne arachne-commons-bundle - 1.18.0 + 1.19.0 ../pom.xml diff --git a/arachne-scheduler/pom.xml b/arachne-scheduler/pom.xml index 97e2042f..1daea40f 100644 --- a/arachne-scheduler/pom.xml +++ b/arachne-scheduler/pom.xml @@ -6,7 +6,7 @@ com.odysseusinc.arachne arachne-commons-bundle - 1.18.0 + 1.19.0 ../pom.xml @@ -43,7 +43,7 @@ com.cronutils cron-utils - 9.1.3 + 9.1.6 org.springframework diff --git a/arachne-storage/pom.xml b/arachne-storage/pom.xml index 1a3710b6..e57a5573 100644 --- a/arachne-storage/pom.xml +++ b/arachne-storage/pom.xml @@ -7,7 +7,7 @@ com.odysseusinc.arachne arachne-commons-bundle - 1.18.0 + 1.19.0 ../pom.xml diff --git a/arachne-sys-settings/pom.xml b/arachne-sys-settings/pom.xml index 6053c5b4..561e5f95 100644 --- a/arachne-sys-settings/pom.xml +++ b/arachne-sys-settings/pom.xml @@ -7,7 +7,7 @@ com.odysseusinc.arachne arachne-commons-bundle - 1.18.0 + 1.19.0 ../pom.xml diff --git a/data-source-manager/pom.xml b/data-source-manager/pom.xml index 600c08b4..f1646b84 100644 --- a/data-source-manager/pom.xml +++ b/data-source-manager/pom.xml @@ -29,7 +29,7 @@ com.odysseusinc.arachne arachne-commons-bundle - 1.18.0 + 1.19.0 ../pom.xml diff --git a/execution-engine-commons/pom.xml b/execution-engine-commons/pom.xml index 497d962f..ca647e90 100644 --- a/execution-engine-commons/pom.xml +++ b/execution-engine-commons/pom.xml @@ -7,7 +7,7 @@ com.odysseusinc.arachne arachne-commons-bundle - 1.18.0 + 1.19.0 ../pom.xml diff --git a/logging/pom.xml b/logging/pom.xml index 73b0237d..8f17c0e8 100644 --- a/logging/pom.xml +++ b/logging/pom.xml @@ -29,7 +29,7 @@ com.odysseusinc.arachne arachne-commons-bundle - 1.18.0 + 1.19.0 ../pom.xml diff --git a/pom.xml b/pom.xml index a087b292..4da2a21c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ arachne-commons-bundle com.odysseusinc.arachne - 1.18.0 + 1.19.0 pom @@ -61,6 +61,11 @@ spring-webmvc ${spring.version} + + org.springframework + spring-aspects + ${spring.version} + commons-io commons-io