diff --git a/NOTICE b/NOTICE index 2cb329a473abd805dcc4681d720c22f7f7ce5f54..dbcc3b72ffca366ca73482a991671dc77da1cf48 100644 --- a/NOTICE +++ b/NOTICE @@ -14,7 +14,7 @@ Apache-1.1 ======================================================================== The following software have components provided under the terms of this license: -- Apache Commons CLI (from http://commons.apache.org/proper/commons-cli/) +- Apache Commons CLI (from https://commons.apache.org/proper/commons-cli/) - Cobertura (from http://cobertura.sourceforge.net) - Plexus :: Default Container (from https://repo1.maven.org/maven2/org/codehaus/plexus/plexus-container-default) - Plexus Common Utilities (from http://plexus.codehaus.org/plexus-utils) @@ -292,12 +292,10 @@ The following software have components provided under the terms of this license: - Apache Ant Core (from http://ant.apache.org/) - Apache Ant Launcher (from http://ant.apache.org/) - Apache Commons BeanUtils (from http://commons.apache.org/proper/commons-beanutils/) -- Apache Commons CLI (from http://commons.apache.org/proper/commons-cli/) +- Apache Commons CLI (from https://commons.apache.org/proper/commons-cli/) - Apache Commons Codec (from https://commons.apache.org/proper/commons-codec/) - Apache Commons Collections (from http://commons.apache.org/proper/commons-collections/) -- Apache Commons IO (from https://commons.apache.org/proper/commons-io/) - Apache Commons Lang (from http://commons.apache.org/proper/commons-lang/) -- Apache Commons Logging (from http://commons.apache.org/proper/commons-logging/) - Apache Geronimo JMS Spec 2.0 (from http://geronimo.apache.org/maven/${siteId}/${version}) - Apache HttpClient Cache (from http://hc.apache.org/httpcomponents-client) - Apache HttpCore (from http://hc.apache.org/httpcomponents-core-ga) @@ -306,9 +304,11 @@ The following software have components provided under the terms of this license: - Apache Log4j JUL Adapter (from https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-jul) - Apache Log4j SLF4J Binding (from https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-slf4j-impl) - Apache Log4j to SLF4J Adapter (from https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-to-slf4j) +- Apache Maven Invoker (from https://repo1.maven.org/maven2/org/apache/maven/shared/maven-invoker) - Apache Maven Wagon :: API (from https://repo1.maven.org/maven2/org/apache/maven/wagon/wagon-provider-api) - Apache Maven Wagon :: Providers :: File Provider (from https://repo1.maven.org/maven2/org/apache/maven/wagon/wagon-file) - Apache Maven Wagon :: Providers :: HTTP Shared Library (from https://repo1.maven.org/maven2/org/apache/maven/wagon/wagon-http-shared) +- Apache Maven Wagon :: Providers :: Lightweight HTTP Provider (from https://repo1.maven.org/maven2/org/apache/maven/wagon/wagon-http-lightweight) - Apache Maven Wagon :: Providers :: SSH Common Library (from https://repo1.maven.org/maven2/org/apache/maven/wagon/wagon-ssh-common) - Apache Maven Wagon :: Providers :: SSH External Provider (from https://repo1.maven.org/maven2/org/apache/maven/wagon/wagon-ssh-external) - Apache Maven Wagon :: Providers :: SSH Provider (from https://repo1.maven.org/maven2/org/apache/maven/wagon/wagon-ssh) @@ -328,11 +328,13 @@ The following software have components provided under the terms of this license: - Byte Buddy Java agent (from https://repo1.maven.org/maven2/net/bytebuddy/byte-buddy-agent) - ClassMate (from http://github.com/cowtowncoder/java-classmate) - Cloud Key Management Service (KMS) API v1-rev20210820-1.32.1 (from https://repo1.maven.org/maven2/com/google/apis/google-api-services-cloudkms) -- Cloud Storage JSON API v1-rev20200814-1.30.10 (from https://repo1.maven.org/maven2/com/google/apis/google-api-services-storage) +- Cloud Storage JSON API v1-rev20210918-1.32.1 (from https://repo1.maven.org/maven2/com/google/apis/google-api-services-storage) - CloudWatch Metrics for AWS Java SDK (from https://aws.amazon.com/sdkforjava) - Cobertura (from http://cobertura.sourceforge.net) - Collections (from https://repo1.maven.org/maven2/commons-collections/commons-collections) +- Commons IO (from http://commons.apache.org/io/) - Commons Lang (from http://commons.apache.org/lang/) +- Commons Logging (from http://commons.apache.org/logging/) - Commons Validator (from http://commons.apache.org/validator/) - Converter: Jackson (from https://repo1.maven.org/maven2/com/squareup/retrofit2/converter-jackson) - Core functionality for the Reactor Netty library (from https://github.com/reactor/reactor-netty) @@ -345,7 +347,6 @@ The following software have components provided under the terms of this license: - Doxia :: XHTML Module (from https://repo1.maven.org/maven2/org/apache/maven/doxia/doxia-module-xhtml) - Doxia Sitetools :: Decoration Model (from https://repo1.maven.org/maven2/org/apache/maven/doxia/doxia-decoration-model) - Doxia Sitetools :: Site Renderer Component (from https://repo1.maven.org/maven2/org/apache/maven/doxia/doxia-site-renderer) -- Expression Language 3.0 (from https://projects.eclipse.org/projects/ee4j.el) - FindBugs-jsr305 (from http://findbugs.sourceforge.net/) - GSON extensions to the Google HTTP Client Library for Java. (from https://repo1.maven.org/maven2/com/google/http-client/google-http-client-gson) - Google APIs Client Library for Java (from https://repo1.maven.org/maven2/com/google/api-client/google-api-client) @@ -356,14 +357,14 @@ The following software have components provided under the terms of this license: - Google Cloud Datastore (from https://github.com/googleapis/java-datastore) - Google Cloud IAM Service Account Credentials (from https://github.com/googleapis/java-iamcredentials) - Google Cloud Logging (from https://github.com/googleapis/java-logging) -- Google Cloud Pub/Sub (from https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-pubsub) -- Google Cloud Storage (from https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-storage) +- Google Cloud Pub/Sub (from https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-clients/google-cloud-pubsub) +- Google Cloud Storage (from https://github.com/googleapis/java-storage) - Google HTTP Client Library for Java (from https://repo1.maven.org/maven2/com/google/http-client/google-http-client) - Google OAuth Client Library for Java (from https://repo1.maven.org/maven2/com/google/oauth-client/google-oauth-client) -- Gson (from http://code.google.com/p/google-gson/) +- Gson (from https://repo1.maven.org/maven2/com/google/code/gson/gson) - Guava InternalFutureFailureAccess and InternalFutures (from https://repo1.maven.org/maven2/com/google/guava/failureaccess) -- Guava: Google Core Libraries for Java (from https://repo1.maven.org/maven2/com/google/guava/guava) -- Guava: Google Core Libraries for Java (from https://repo1.maven.org/maven2/com/google/guava/guava) +- Guava: Google Core Libraries for Java (from https://github.com/google/guava) +- Guava: Google Core Libraries for Java (from https://github.com/google/guava) - HTTP functionality for the Reactor Netty library (from https://github.com/reactor/reactor-netty) - Hibernate Validator Engine (from https://repo1.maven.org/maven2/org/hibernate/validator/hibernate-validator) - HttpClient (from http://hc.apache.org/httpcomponents-client) @@ -390,17 +391,18 @@ The following software have components provided under the terms of this license: - Jackson datatype: JSR310 (from https://repo1.maven.org/maven2/com/fasterxml/jackson/datatype/jackson-datatype-jsr310) - Jackson datatype: jdk8 (from https://repo1.maven.org/maven2/com/fasterxml/jackson/datatype/jackson-datatype-jdk8) - Jackson extensions to the Google HTTP Client Library for Java. (from https://repo1.maven.org/maven2/com/google/http-client/google-http-client-jackson) -- Jackson module: Afterburner (from https://github.com/FasterXML/jackson-modules-base) - Jackson-annotations (from http://github.com/FasterXML/jackson) - Jackson-annotations (from http://github.com/FasterXML/jackson) - Jackson-core (from https://github.com/FasterXML/jackson) - Jackson-core (from https://github.com/FasterXML/jackson) -- Jackson-dataformat-XML (from https://github.com/FasterXML/jackson-dataformat-xml) -- Jackson-dataformat-YAML (from https://github.com/FasterXML/jackson-dataformats-text) +- Jackson-dataformat-XML (from http://wiki.fasterxml.com/JacksonExtensionXmlDataBinding) +- Jackson-dataformat-YAML (from http://wiki.fasterxml.com/JacksonExtensionYAML) - Jackson-datatype-Joda (from http://wiki.fasterxml.com/JacksonModuleJoda) +- Jackson-module-Afterburner (from http://wiki.fasterxml.com/JacksonHome) - Jackson-module-JAXB-annotations (from http://wiki.fasterxml.com/JacksonJAXBAnnotations) - Jackson-module-parameter-names (from https://repo1.maven.org/maven2/com/fasterxml/jackson/module/jackson-module-parameter-names) - Jakarta Bean Validation API (from https://beanvalidation.org) +- Jakarta Expression Language Implementation (from https://projects.eclipse.org/projects/ee4j.el) - Java Libraries for Amazon Simple WorkFlow (from https://aws.amazon.com/sdkforjava) - Java Native Access (from https://github.com/java-native-access/jna) - Java Native Access Platform (from https://github.com/java-native-access/jna) @@ -420,8 +422,6 @@ The following software have components provided under the terms of this license: - KeePassJava2 :: KDB (from https://repo1.maven.org/maven2/org/linguafranca/pwdb/KeePassJava2-kdb) - KeePassJava2 :: KDBX (from https://repo1.maven.org/maven2/org/linguafranca/pwdb/KeePassJava2-kdbx) - KeePassJava2 :: Simple (from https://repo1.maven.org/maven2/org/linguafranca/pwdb/KeePassJava2-simple) -- Kotlin Stdlib (from https://kotlinlang.org/) -- Kotlin Stdlib Common (from https://kotlinlang.org/) - Logback Contrib :: JSON :: Classic (from https://repo1.maven.org/maven2/ch/qos/logback/contrib/logback-json-classic) - Logback Contrib :: JSON :: Core (from https://repo1.maven.org/maven2/ch/qos/logback/contrib/logback-json-core) - Logback Contrib :: Jackson (from https://repo1.maven.org/maven2/ch/qos/logback/contrib/logback-jackson) @@ -430,8 +430,6 @@ The following software have components provided under the terms of this license: - Maven Artifact Manager (from https://repo1.maven.org/maven2/org/apache/maven/maven-artifact-manager) - Maven Core (from https://repo1.maven.org/maven2/org/apache/maven/maven-core) - Maven Error Diagnostics (from https://repo1.maven.org/maven2/org/apache/maven/maven-error-diagnostics) -- Maven Invoker (from https://repo1.maven.org/maven2/org/apache/maven/shared/maven-invoker) -- Maven Local Settings Model (from https://repo1.maven.org/maven2/org/apache/maven/maven-settings) - Maven Model (from https://repo1.maven.org/maven2/org/apache/maven/maven-model) - Maven Monitor (from https://repo1.maven.org/maven2/org/apache/maven/maven-monitor) - Maven Plugin API (from https://repo1.maven.org/maven2/org/apache/maven/maven-plugin-api) @@ -443,7 +441,7 @@ The following software have components provided under the terms of this license: - Maven Reporting API (from https://repo1.maven.org/maven2/org/apache/maven/reporting/maven-reporting-api) - Maven Reporting Implementation (from https://repo1.maven.org/maven2/org/apache/maven/reporting/maven-reporting-impl) - Maven Repository Metadata Model (from https://repo1.maven.org/maven2/org/apache/maven/maven-repository-metadata) -- Maven Wagon Lightweight HTTP Provider (from https://repo1.maven.org/maven2/org/apache/maven/wagon/wagon-http-lightweight) +- Maven Settings (from https://repo1.maven.org/maven2/org/apache/maven/maven-settings) - Metrics Core (from https://repo1.maven.org/maven2/io/dropwizard/metrics/metrics-core) - Microsoft Application Insights Java SDK Core (from https://github.com/Microsoft/ApplicationInsights-Java) - Microsoft Application Insights Java SDK Spring Boot starter (from https://github.com/Microsoft/ApplicationInsights-Java) @@ -477,6 +475,10 @@ The following software have components provided under the terms of this license: - Non-Blocking Reactive Foundation for the JVM (from https://github.com/reactor/reactor-core) - OAuth 2.0 SDK with OpenID Connect extensions (from https://bitbucket.org/connect2id/oauth-2.0-sdk-with-openid-connect-extensions) - Objenesis (from http://objenesis.org) +- OkHttp (from https://repo1.maven.org/maven2/com/squareup/okhttp3/okhttp) +- OkHttp Logging Interceptor (from https://repo1.maven.org/maven2/com/squareup/okhttp3/logging-interceptor) +- OkHttp URLConnection (from https://repo1.maven.org/maven2/com/squareup/okhttp3/okhttp-urlconnection) +- Okio (from https://repo1.maven.org/maven2/com/squareup/okio/okio) - OpenCensus (from https://github.com/census-instrumentation/opencensus-java) - OpenCensus (from https://github.com/census-instrumentation/opencensus-java) - OpenCensus (from https://github.com/census-instrumentation/opencensus-java) @@ -499,6 +501,7 @@ The following software have components provided under the terms of this license: - PowerMock (from http://www.powermock.org) - PowerMock (from http://www.powermock.org) - Protocol Buffer extensions to the Google HTTP Client Library for Java. (from https://repo1.maven.org/maven2/com/google/http-client/google-http-client-protobuf) +- Proton-J (from https://repo1.maven.org/maven2/org/apache/qpid/proton-j) - QpidJMS Client (from https://repo1.maven.org/maven2/org/apache/qpid/qpid-jms-client) - Reactive Streams Netty driver (from https://github.com/reactor/reactor-netty) - Retrofit (from https://repo1.maven.org/maven2/com/squareup/retrofit2/retrofit) @@ -506,8 +509,19 @@ The following software have components provided under the terms of this license: - SnakeYAML (from http://www.snakeyaml.org) - Spring AOP (from https://github.com/spring-projects/spring-framework) - Spring Beans (from https://github.com/spring-projects/spring-framework) -- Spring Boot Reactor Netty Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-reactor-netty) -- Spring Boot WebFlux Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-webflux) +- Spring Boot (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot) +- Spring Boot AOP Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-aop) +- Spring Boot Actuator (from http://projects.spring.io/spring-boot/) +- Spring Boot AutoConfigure (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-autoconfigure) +- Spring Boot Json Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-json) +- Spring Boot Logging Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-logging) +- Spring Boot Security Starter (from http://projects.spring.io/spring-boot/) +- Spring Boot Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter) +- Spring Boot Test (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-test) +- Spring Boot Test Auto-Configure (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-test-autoconfigure) +- Spring Boot Test Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-test) +- Spring Boot Tomcat Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-tomcat) +- Spring Boot Web Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-web) - Spring Cloud GCP Autoconfigure Module (from https://repo1.maven.org/maven2/org/springframework/cloud/spring-cloud-gcp-autoconfigure) - Spring Cloud GCP Core Module (from https://repo1.maven.org/maven2/org/springframework/cloud/spring-cloud-gcp-core) - Spring Cloud GCP Datastore Module (from https://repo1.maven.org/maven2/org/springframework/cloud/spring-cloud-gcp-data-datastore) @@ -536,7 +550,7 @@ The following software have components provided under the terms of this license: - Zipkin Core Library (from https://repo1.maven.org/maven2/io/zipkin/zipkin2/zipkin) - Zipkin Reporter Brave (from https://repo1.maven.org/maven2/io/zipkin/reporter2/zipkin-reporter-brave) - Zipkin Reporter: Core (from https://repo1.maven.org/maven2/io/zipkin/reporter2/zipkin-reporter) -- aalto-xml (from ) +- aalto-xml (from https://repo1.maven.org/maven2/com/fasterxml/aalto-xml) - datastore-v1-proto-client (from https://repo1.maven.org/maven2/com/google/cloud/datastore/datastore-v1-proto-client) - error-prone annotations (from https://repo1.maven.org/maven2/com/google/errorprone/error_prone_annotations) - error-prone annotations (from https://repo1.maven.org/maven2/com/google/errorprone/error_prone_annotations) @@ -568,18 +582,16 @@ The following software have components provided under the terms of this license: - javatuples (from http://www.javatuples.org) - javax.inject (from http://code.google.com/p/atinject/) - jose4j (from https://bitbucket.org/b_c/jose4j/) +- kotlin-stdlib (from https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib) - lettuce (from http://github.com/mp911de/lettuce/wiki) - micrometer-core (from https://github.com/micrometer-metrics/micrometer) - micrometer-registry-azure-monitor (from https://github.com/micrometer-metrics/micrometer) -- mockito-core (from https://github.com/mockito/mockito) -- mockito-core (from https://github.com/mockito/mockito) -- mockito-core (from https://github.com/mockito/mockito) -- okhttp (from https://square.github.io/okhttp/) -- okhttp-logging-interceptor (from https://square.github.io/okhttp/) -- okhttp-urlconnection (from https://square.github.io/okhttp/) -- okio (from https://github.com/square/okio/) +- mockito-core (from http://mockito.org) +- mockito-core (from http://mockito.org) +- mockito-core (from http://mockito.org) - org.apiguardian:apiguardian-api (from https://github.com/apiguardian-team/apiguardian) - org.conscrypt:conscrypt-openjdk-uber (from https://conscrypt.org/) +- org.jetbrains.kotlin:kotlin-stdlib-common (from https://kotlinlang.org/) - org.opentest4j:opentest4j (from https://github.com/ota4j-team/opentest4j) - org.xmlunit:xmlunit-core (from https://www.xmlunit.org/) - perfmark:perfmark-api (from https://github.com/perfmark/perfmark) @@ -591,43 +603,31 @@ The following software have components provided under the terms of this license: - proto-google-common-protos (from https://github.com/googleapis/java-iam/proto-google-common-protos) - proto-google-common-protos (from https://github.com/googleapis/java-iam/proto-google-common-protos) - proto-google-iam-v1 (from https://github.com/googleapis/java-iam/proto-google-iam-v1) -- proton-j (from https://repo1.maven.org/maven2/org/apache/qpid/proton-j) -- resilience4j (from https://github.com/resilience4j/resilience4j) - resilience4j (from https://resilience4j.readme.io) - resilience4j (from https://github.com/resilience4j/resilience4j) -- resilience4j (from https://resilience4j.readme.io) +- resilience4j (from https://github.com/resilience4j/resilience4j) +- resilience4j (from https://github.com/resilience4j/resilience4j) - resilience4j (from https://github.com/resilience4j/resilience4j) - resilience4j (from https://github.com/resilience4j/resilience4j) - resilience4j (from https://resilience4j.readme.io) - resilience4j (from https://github.com/resilience4j/resilience4j) - rxjava (from https://github.com/ReactiveX/RxJava) -- spring-boot (from https://spring.io/projects/spring-boot) -- spring-boot-actuator (from https://spring.io/projects/spring-boot) - spring-boot-actuator-autoconfigure (from https://spring.io/projects/spring-boot) -- spring-boot-autoconfigure (from https://spring.io/projects/spring-boot) - spring-boot-dependencies (from https://spring.io/projects/spring-boot) -- spring-boot-starter (from https://spring.io/projects/spring-boot) - spring-boot-starter-actuator (from https://spring.io/projects/spring-boot) -- spring-boot-starter-aop (from https://spring.io/projects/spring-boot) - spring-boot-starter-data-mongodb (from https://spring.io/projects/spring-boot) -- spring-boot-starter-json (from https://spring.io/projects/spring-boot) - spring-boot-starter-log4j2 (from https://spring.io/projects/spring-boot) -- spring-boot-starter-logging (from https://spring.io/projects/spring-boot) -- spring-boot-starter-security (from https://spring.io/projects/spring-boot) -- spring-boot-starter-test (from https://spring.io/projects/spring-boot) -- spring-boot-starter-tomcat (from https://spring.io/projects/spring-boot) +- spring-boot-starter-reactor-netty (from https://spring.io/projects/spring-boot) - spring-boot-starter-validation (from https://spring.io/projects/spring-boot) -- spring-boot-starter-web (from https://spring.io/projects/spring-boot) -- spring-boot-test (from https://spring.io/projects/spring-boot) -- spring-boot-test-autoconfigure (from https://spring.io/projects/spring-boot) -- spring-security-config (from https://spring.io/spring-security) -- spring-security-core (from https://spring.io/spring-security) -- spring-security-oauth2-client (from https://spring.io/spring-security) -- spring-security-oauth2-core (from https://spring.io/spring-security) -- spring-security-oauth2-jose (from https://spring.io/spring-security) +- spring-boot-starter-webflux (from https://spring.io/projects/spring-boot) +- spring-security-config (from http://spring.io/spring-security) +- spring-security-core (from http://spring.io/spring-security) +- spring-security-oauth2-client (from http://spring.io/spring-security) +- spring-security-oauth2-core (from http://spring.io/spring-security) +- spring-security-oauth2-jose (from http://spring.io/spring-security) - spring-security-oauth2-resource-server (from https://spring.io/spring-security) -- spring-security-test (from https://spring.io/spring-security) -- spring-security-web (from https://spring.io/spring-security) +- spring-security-test (from http://spring.io/spring-security) +- spring-security-web (from http://spring.io/spring-security) - springfox-core (from https://github.com/springfox/springfox) - springfox-schema (from https://github.com/springfox/springfox) - springfox-spi (from https://github.com/springfox/springfox) @@ -649,7 +649,7 @@ The following software have components provided under the terms of this license: - API Common (from https://github.com/googleapis/api-common-java) - API Common (from https://github.com/googleapis/api-common-java) -- Apache Commons CLI (from http://commons.apache.org/proper/commons-cli/) +- Apache Commons CLI (from https://commons.apache.org/proper/commons-cli/) - GAX (Google Api eXtensions) for Java (from https://github.com/googleapis/gax-java) - GAX (Google Api eXtensions) for Java (from https://github.com/googleapis/gax-java) - GAX (Google Api eXtensions) for Java (from https://github.com/googleapis/gax-java) @@ -719,7 +719,6 @@ CC-BY-2.5 ======================================================================== The following software have components provided under the terms of this license: -- Checker Qual (from https://checkerframework.org) - FindBugs-jsr305 (from http://findbugs.sourceforge.net/) - MongoDB Java Driver Core (from http://www.mongodb.org) @@ -770,14 +769,10 @@ EPL-1.0 The following software have components provided under the terms of this license: - AspectJ weaver (from http://www.aspectj.org) -- Expression Language 3.0 (from https://projects.eclipse.org/projects/ee4j.el) - JUnit Jupiter (Aggregator) (from https://junit.org/junit5/) -- JUnit Jupiter API (from https://junit.org/junit5/) -- JUnit Jupiter Engine (from https://junit.org/junit5/) - JUnit Jupiter Params (from https://junit.org/junit5/) -- JUnit Platform Commons (from https://junit.org/junit5/) -- JUnit Platform Engine API (from https://junit.org/junit5/) - Jakarta Annotations API (from https://projects.eclipse.org/projects/ee4j.ca) +- Jakarta Expression Language Implementation (from https://projects.eclipse.org/projects/ee4j.el) - Logback Classic Module (from http://logback.qos.ch) - Logback Contrib :: JSON :: Classic (from https://repo1.maven.org/maven2/ch/qos/logback/contrib/logback-json-classic) - Logback Contrib :: JSON :: Core (from https://repo1.maven.org/maven2/ch/qos/logback/contrib/logback-json-core) @@ -788,20 +783,24 @@ The following software have components provided under the terms of this license: - Microsoft Application Insights Java SDK Web Module (from https://github.com/Microsoft/ApplicationInsights-Java) - Microsoft Application Insights Log4j 2 Appender (from https://github.com/Microsoft/ApplicationInsights-Java) - SnakeYAML (from http://www.snakeyaml.org) +- org.junit.jupiter:junit-jupiter-api (from http://junit.org/junit5/) +- org.junit.jupiter:junit-jupiter-engine (from http://junit.org/junit5/) +- org.junit.platform:junit-platform-commons (from http://junit.org/junit5/) +- org.junit.platform:junit-platform-engine (from http://junit.org/junit5/) ======================================================================== EPL-2.0 ======================================================================== The following software have components provided under the terms of this license: -- Expression Language 3.0 (from https://projects.eclipse.org/projects/ee4j.el) - JUnit Jupiter (Aggregator) (from https://junit.org/junit5/) -- JUnit Jupiter API (from https://junit.org/junit5/) -- JUnit Jupiter Engine (from https://junit.org/junit5/) - JUnit Jupiter Params (from https://junit.org/junit5/) -- JUnit Platform Commons (from https://junit.org/junit5/) -- JUnit Platform Engine API (from https://junit.org/junit5/) - Jakarta Annotations API (from https://projects.eclipse.org/projects/ee4j.ca) +- Jakarta Expression Language Implementation (from https://projects.eclipse.org/projects/ee4j.el) +- org.junit.jupiter:junit-jupiter-api (from http://junit.org/junit5/) +- org.junit.jupiter:junit-jupiter-engine (from http://junit.org/junit5/) +- org.junit.platform:junit-platform-commons (from http://junit.org/junit5/) +- org.junit.platform:junit-platform-engine (from http://junit.org/junit5/) ======================================================================== GPL-2.0-only @@ -830,8 +829,8 @@ The following software have components provided under the terms of this license: - Checker Qual (from https://checkerframework.org) - Cobertura (from http://cobertura.sourceforge.net) -- Expression Language 3.0 (from https://projects.eclipse.org/projects/ee4j.el) - Jakarta Annotations API (from https://projects.eclipse.org/projects/ee4j.ca) +- Jakarta Expression Language Implementation (from https://projects.eclipse.org/projects/ee4j.el) - JavaBeans Activation Framework (from ) - javax.annotation-api (from http://jcp.org/en/jsr/detail?id=250) - tomcat-embed-core (from http://tomcat.apache.org/) @@ -841,8 +840,8 @@ GPL-3.0-only ======================================================================== The following software have components provided under the terms of this license: -- Expression Language 3.0 (from https://projects.eclipse.org/projects/ee4j.el) - Jakarta Annotations API (from https://projects.eclipse.org/projects/ee4j.ca) +- Jakarta Expression Language Implementation (from https://projects.eclipse.org/projects/ee4j.el) - Project Lombok (from http://projectlombok.org) - Project Lombok (from http://projectlombok.org) - Project Lombok (from http://projectlombok.org) @@ -908,6 +907,7 @@ The following software have components provided under the terms of this license: - Checker Qual (from https://checkerframework.org) - Checker Qual (from https://checkerframework.org) - Checker Qual (from https://checkerframework.org) +- Extensions on Apache Proton-J library (from https://github.com/Azure/qpid-proton-j-extensions) - JUL to SLF4J bridge (from http://www.slf4j.org) - Java Client Runtime for AutoRest (from https://github.com/Azure/autorest-clientruntime-for-java) - Microsoft Application Insights Java SDK Core (from https://github.com/Microsoft/ApplicationInsights-Java) @@ -923,6 +923,7 @@ The following software have components provided under the terms of this license: - Microsoft Azure SDK for Service Bus (from https://github.com/Azure/azure-sdk-for-java) - Microsoft Azure SDK for eventgrid (from https://github.com/Azure/azure-sdk-for-java) - Microsoft Azure client library for Blob Storage (from https://github.com/Azure/azure-sdk-for-java) +- Microsoft Azure client library for Identity (from https://github.com/Azure/azure-sdk-for-java) - Microsoft Azure client library for KeyVault Keys (from https://github.com/Azure/azure-sdk-for-java) - Microsoft Azure client library for KeyVault Secrets (from https://github.com/Azure/azure-sdk-for-java) - Microsoft Azure common module for Storage (from https://github.com/Azure/azure-sdk-for-java) @@ -940,18 +941,16 @@ The following software have components provided under the terms of this license: - Spring Data for Azure Cosmos DB SQL API (from https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/cosmos/azure-spring-data-cosmos) - adal4j (from https://github.com/AzureAD/azure-activedirectory-library-for-java) - azure-documentdb (from http://azure.microsoft.com/en-us/services/documentdb/) -- azure-identity (from https://repo1.maven.org/maven2/com/azure/azure-identity) - documentdb-bulkexecutor (from http://azure.microsoft.com/en-us/services/documentdb/) - java jwt (from http://www.jwt.io) - micrometer-core (from https://github.com/micrometer-metrics/micrometer) -- mockito-core (from https://github.com/mockito/mockito) -- mockito-core (from https://github.com/mockito/mockito) -- mockito-core (from https://github.com/mockito/mockito) +- mockito-core (from http://mockito.org) +- mockito-core (from http://mockito.org) +- mockito-core (from http://mockito.org) - mockito-junit-jupiter (from https://github.com/mockito/mockito) - msal4j (from https://github.com/AzureAD/microsoft-authentication-library-for-java) - msal4j-persistence-extension (from https://github.com/AzureAD/microsoft-authentication-extensions-for-java) -- qpid-proton-j-extensions (from https://github.com/Azure/qpid-proton-j-extensions) -- spring-security-core (from https://spring.io/spring-security) +- spring-security-core (from http://spring.io/spring-security) ======================================================================== MPL-1.1 @@ -969,7 +968,7 @@ The following software have components provided under the terms of this license: - Javassist (from http://www.javassist.org/) - Javassist (from http://www.javassist.org/) -- okhttp (from https://square.github.io/okhttp/) +- OkHttp (from https://repo1.maven.org/maven2/com/squareup/okhttp3/okhttp) ======================================================================== PHP-3.01 @@ -999,8 +998,6 @@ SPL-1.0 ======================================================================== The following software have components provided under the terms of this license: -- Checker Qual (from https://checkerframework.org) -- Checker Qual (from https://checkerframework.org) - Servlet Specification 2.5 API (from http://jetty.mortbay.org) ======================================================================== @@ -1027,8 +1024,8 @@ The following software have components provided under the terms of this license: - AWS SDK for Java - Models (from https://aws.amazon.com/sdkforjava) - Asynchronous Http Client (from https://repo1.maven.org/maven2/org/asynchttpclient/async-http-client) -- Guava: Google Core Libraries for Java (from https://repo1.maven.org/maven2/com/google/guava/guava) -- Guava: Google Core Libraries for Java (from https://repo1.maven.org/maven2/com/google/guava/guava) +- Guava: Google Core Libraries for Java (from https://github.com/google/guava) +- Guava: Google Core Libraries for Java (from https://github.com/google/guava) - HdrHistogram (from http://hdrhistogram.github.io/HdrHistogram/) - JTidy (from http://jtidy.sourceforge.net) - Joda-Time (from https://www.joda.org/joda-time/) @@ -1055,17 +1052,18 @@ The following software have components provided under the terms of this license: - Byte Buddy (without dependencies) (from https://repo1.maven.org/maven2/net/bytebuddy/byte-buddy) - Checker Qual (from https://checkerframework.org) +- Checker Qual (from https://checkerframework.org) - JSON in Java (from https://github.com/douglascrockford/JSON-java) - JTidy (from http://jtidy.sourceforge.net) - JUnit Jupiter (Aggregator) (from https://junit.org/junit5/) -- JUnit Jupiter API (from https://junit.org/junit5/) -- JUnit Jupiter Engine (from https://junit.org/junit5/) - JUnit Jupiter Params (from https://junit.org/junit5/) -- JUnit Platform Commons (from https://junit.org/junit5/) -- JUnit Platform Engine API (from https://junit.org/junit5/) - Jakarta Activation API jar (from https://repo1.maven.org/maven2/jakarta/activation/jakarta.activation-api) - Jakarta XML Binding API (from https://repo1.maven.org/maven2/jakarta/xml/bind/jakarta.xml.bind-api) - Spongy Castle (from http://rtyley.github.io/spongycastle/) +- org.junit.jupiter:junit-jupiter-api (from http://junit.org/junit5/) +- org.junit.jupiter:junit-jupiter-engine (from http://junit.org/junit5/) +- org.junit.platform:junit-platform-commons (from http://junit.org/junit5/) +- org.junit.platform:junit-platform-engine (from http://junit.org/junit5/) - xml-apis (from ) diff --git a/devops/azure/chart/helm-config.yaml b/devops/azure/chart/helm-config.yaml index 2be1682717f591beab15bcaab8ab7d365fa5feaf..cfcfdb375897fd6285e0196bcc93a13ff056dbbb 100644 --- a/devops/azure/chart/helm-config.yaml +++ b/devops/azure/chart/helm-config.yaml @@ -3,6 +3,8 @@ global: # Service(s) Replica Count replicaCount: 2 + maxReplicaCount: 20 + minReplicaCount: 4 nodepool: services isAutoscalingEnabled: false @@ -23,3 +25,5 @@ featureFlag: resourceLimits: enabledEnvs: - demo + hpa: + enabledEnvs: [] diff --git a/devops/azure/chart/templates/deployment.yaml b/devops/azure/chart/templates/deployment.yaml index 9d69bc4b8487c7d7c4050e800c380bcc76556d00..62c0be7e4a980d4affbf2ca44138f5b6401e99a1 100644 --- a/devops/azure/chart/templates/deployment.yaml +++ b/devops/azure/chart/templates/deployment.yaml @@ -18,7 +18,10 @@ metadata: name: {{ .Release.Name }} namespace: osdu spec: + {{- if has .Values.env .Values.featureFlag.hpa.enabledEnvs }} + {{- else }} replicas: {{ .Values.global.replicaCount }} + {{- end }} selector: matchLabels: app: {{ .Chart.Name }} diff --git a/devops/azure/chart/templates/hpa.yaml b/devops/azure/chart/templates/hpa.yaml new file mode 100644 index 0000000000000000000000000000000000000000..29591611b8db6055ff6c36342e4be239f4dc8656 --- /dev/null +++ b/devops/azure/chart/templates/hpa.yaml @@ -0,0 +1,51 @@ +# Copyright © Microsoft Corporation +# +# 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. +{{- if has .Values.env .Values.featureFlag.hpa.enabledEnvs }} +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Chart.Name }} + namespace: osdu +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Chart.Name }} + minReplicas: {{ .Values.global.minReplicaCount }} + maxReplicas: {{ .Values.global.maxReplicaCount }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 50 + behavior: + scaleDown: + stabilizationWindowSeconds: 150 + policies: + - type: Pods + value: 2 + periodSeconds: 30 + scaleUp: + stabilizationWindowSeconds: 10 + selectPolicy: Max + policies: + - type: Pods + value: 6 + periodSeconds: 10 + - type: Percent + value: 50 + periodSeconds: 10 +{{- end }} \ No newline at end of file diff --git a/devops/azure/chart/values.yaml b/devops/azure/chart/values.yaml index 9c987e7e65b5187ddf59a93ec4ba947223173f41..8bce3bedb1abb97fcd6c04ed31d9abdce31c32b3 100644 --- a/devops/azure/chart/values.yaml +++ b/devops/azure/chart/values.yaml @@ -14,6 +14,8 @@ global: replicaCount: 1 + maxReplicaCount: 1 + minReplicaCount: 1 nodepool: services isAutoscalingEnabled: false @@ -22,7 +24,7 @@ image: branch: master tag: latest -istioDnsHost: "" +istioDnsHost: "contoso.com" env: demo @@ -30,3 +32,5 @@ featureFlag: resourceLimits: enabledEnvs: - demo + hpa: + enabledEnvs: [] diff --git a/docs/api/partition_openapi.yaml b/docs/api/partition_openapi.yaml index e540fcbc34ea5acf88494c8682e5539b6ab83914..12a749e8bb317121fe3bb43efd6ca4c870910d22 100644 --- a/docs/api/partition_openapi.yaml +++ b/docs/api/partition_openapi.yaml @@ -22,32 +22,8 @@ paths: get: tags: - health-check - summary: livenessCheck - operationId: livenessCheckUsingGET - consumes: - - application/json - produces: - - application/json - responses: - '200': - description: OK - schema: - type: string - '401': - description: Unauthorized - '403': - description: Forbidden - '404': - description: Not Found - security: - - JWT: - - global - /actuator/health: - get: - tags: - - health-check - summary: readinessCheck - operationId: readinessCheckUsingGET + summary: "Health check: liveness, readiness." + operationId: healthCheckUsingGET consumes: - application/json produces: diff --git a/partition-core/pom.xml b/partition-core/pom.xml index 6269b08f8a70cf555d4c942ed5242ccb83596764..b6a69e1d3d0373bfb75e77fd0ee0f1e66c109e6f 100644 --- a/partition-core/pom.xml +++ b/partition-core/pom.xml @@ -23,7 +23,7 @@ <parent> <groupId>org.opengroup.osdu</groupId> <artifactId>partition</artifactId> - <version>0.12.0</version> + <version>0.13.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> diff --git a/partition-core/src/main/java/org/opengroup/osdu/partition/api/PartitionApi.java b/partition-core/src/main/java/org/opengroup/osdu/partition/api/PartitionApi.java index 860086cf902a557715cd74807f776fdcec66a4ad..886d4da0a4e2e9bb85459a426453b4a9b0b34d5f 100644 --- a/partition-core/src/main/java/org/opengroup/osdu/partition/api/PartitionApi.java +++ b/partition-core/src/main/java/org/opengroup/osdu/partition/api/PartitionApi.java @@ -14,7 +14,6 @@ package org.opengroup.osdu.partition.api; -import java.util.Collections; import org.opengroup.osdu.partition.logging.AuditLogger; import org.opengroup.osdu.partition.model.PartitionInfo; import org.opengroup.osdu.partition.model.Property; @@ -24,12 +23,21 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; import org.springframework.web.context.annotation.RequestScope; import org.springframework.web.servlet.support.ServletUriComponentsBuilder; import javax.validation.Valid; import java.net.URI; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -39,7 +47,7 @@ import java.util.Map; public class PartitionApi { @Autowired - @Qualifier("cachedPartitionServiceImpl") + @Qualifier("partitionServiceImpl") private IPartitionService partitionService; @Autowired diff --git a/partition-core/src/main/java/org/opengroup/osdu/partition/provider/interfaces/IPartitionServiceCache.java b/partition-core/src/main/java/org/opengroup/osdu/partition/provider/interfaces/IPartitionServiceCache.java deleted file mode 100644 index 593d67c65bc08c127d0586ed709667f277a54d4f..0000000000000000000000000000000000000000 --- a/partition-core/src/main/java/org/opengroup/osdu/partition/provider/interfaces/IPartitionServiceCache.java +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2017-2020, Schlumberger -// -// 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 org.opengroup.osdu.partition.provider.interfaces; - -import org.opengroup.osdu.core.common.cache.ICache; - -public interface IPartitionServiceCache<String, V> extends ICache<String, V> { -} diff --git a/partition-core/src/main/java/org/opengroup/osdu/partition/service/CachedPartitionServiceImpl.java b/partition-core/src/main/java/org/opengroup/osdu/partition/service/CachedPartitionServiceImpl.java deleted file mode 100644 index a060902382b29112fed96fd9356377ef054aca61..0000000000000000000000000000000000000000 --- a/partition-core/src/main/java/org/opengroup/osdu/partition/service/CachedPartitionServiceImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright 2017-2020, Schlumberger -// -// 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 org.opengroup.osdu.partition.service; - -import org.apache.http.HttpStatus; -import org.opengroup.osdu.core.common.model.http.AppException; -import org.opengroup.osdu.partition.model.PartitionInfo; -import org.opengroup.osdu.partition.provider.interfaces.IPartitionService; -import org.opengroup.osdu.partition.provider.interfaces.IPartitionServiceCache; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; - -import javax.inject.Inject; -import java.util.List; - -@Service -public class CachedPartitionServiceImpl implements IPartitionService { - - private static final String PARTITION_LIST_KEY = "getAllPartitions"; - - @Inject - @Qualifier("partitionServiceImpl") - private IPartitionService partitionService; - - @Inject - @Qualifier("partitionServiceCache") - private IPartitionServiceCache<String, PartitionInfo> partitionServiceCache; - - @Inject - @Qualifier("partitionListCache") - private IPartitionServiceCache<String, List<String>> partitionListCache; - - @Override - public PartitionInfo createPartition(String partitionId, PartitionInfo partitionInfo) { - if (partitionServiceCache.get(partitionId) != null) - throw new AppException(HttpStatus.SC_CONFLICT, "partition exist", "Partition with same id exist"); - PartitionInfo pi = partitionService.createPartition(partitionId, partitionInfo); - - if (pi != null) { - partitionServiceCache.put(partitionId, pi); - partitionListCache.clearAll(); - } - - return pi; - } - - @Override - public PartitionInfo updatePartition(String partitionId, PartitionInfo partitionInfo) { - PartitionInfo pi = partitionService.updatePartition(partitionId, partitionInfo); - - if(pi != null) { - partitionServiceCache.put(partitionId, pi); - } - - return pi; - } - - @Override - public PartitionInfo getPartition(String partitionId) { - PartitionInfo pi = (PartitionInfo) partitionServiceCache.get(partitionId); - - if (pi == null) { - pi = partitionService.getPartition(partitionId); - - if (pi != null) { - partitionServiceCache.put(partitionId, pi); - } - } - - return pi; - } - - @Override - public boolean deletePartition(String partitionId) { - if (partitionService.deletePartition(partitionId)) { - if (partitionServiceCache.get(partitionId) != null) { - partitionServiceCache.delete(partitionId); - } - partitionListCache.clearAll(); - return true; - } - - return false; - } - - @Override - public List<String> getAllPartitions() { - List<String> partitions = (List<String>)partitionListCache.get(PARTITION_LIST_KEY); - - if (partitions == null) { - partitions = partitionService.getAllPartitions(); - - if (partitions != null) { - partitionListCache.put(PARTITION_LIST_KEY, partitions); - } - } - return partitions; - } -} diff --git a/partition-core/src/test/java/org/opengroup/osdu/partition/service/CachedPartitionServiceImplTest.java b/partition-core/src/test/java/org/opengroup/osdu/partition/service/CachedPartitionServiceImplTest.java deleted file mode 100644 index 7d2680573eaa08e0e471c186603052320e042400..0000000000000000000000000000000000000000 --- a/partition-core/src/test/java/org/opengroup/osdu/partition/service/CachedPartitionServiceImplTest.java +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright 2017-2020, Schlumberger -// -// 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 org.opengroup.osdu.partition.service; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import org.opengroup.osdu.partition.model.PartitionInfo; -import org.opengroup.osdu.partition.provider.interfaces.IPartitionService; -import org.opengroup.osdu.partition.provider.interfaces.IPartitionServiceCache; - -import java.util.ArrayList; -import java.util.List; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.*; - -@RunWith(MockitoJUnitRunner.class) -public class CachedPartitionServiceImplTest { - - @Mock - private IPartitionService partitionServiceImpl; - - @Mock - private IPartitionServiceCache<String, PartitionInfo> partitionServiceCache; - - @Mock - private IPartitionServiceCache<String, List<String>> partitionListCache; - - @InjectMocks - private CachedPartitionServiceImpl cachedPartitionServiceImpl; - - @Test - public void createPartitionSucceed() { - String partId = "key"; - - PartitionInfo newPi = PartitionInfo.builder().build(); - PartitionInfo retPi = PartitionInfo.builder().build(); - - when(partitionServiceImpl.createPartition(partId, newPi)).thenReturn(retPi); - cachedPartitionServiceImpl.createPartition(partId, newPi); - - verify(partitionServiceImpl, times(1)).createPartition(partId, newPi); - verify(partitionServiceCache, times(1)).put(partId, retPi); - verify(partitionListCache, times(1)).clearAll(); - } - - @Test - public void createPartitionFailed() { - String partId = "key"; - PartitionInfo newPi = PartitionInfo.builder().build(); - - when(partitionServiceCache.get(partId)).thenReturn(null); - when(partitionServiceImpl.createPartition(partId, newPi)).thenReturn(null); - - cachedPartitionServiceImpl.createPartition(partId, newPi); - - verify(partitionServiceImpl, times(1)).createPartition(partId, newPi); - verify(partitionServiceCache, times(0)).put(any(), any()); - verify(partitionListCache, times(0)).clearAll(); - verify(partitionServiceCache, times(1)).get(any()); - } - - @Test - public void updatePartitionSucceed() { - String partId = "key"; - - PartitionInfo newPi = PartitionInfo.builder().build(); - PartitionInfo retPi = PartitionInfo.builder().build(); - - when(partitionServiceImpl.updatePartition(partId, newPi)).thenReturn(retPi); - - cachedPartitionServiceImpl.updatePartition(partId, newPi); - - verify(partitionServiceImpl, times(1)).updatePartition(partId, newPi); - verify(partitionServiceCache, times(1)).put(partId, retPi); - } - - @Test - public void updatePartitionFailed() { - String partId = "key"; - PartitionInfo newPi = PartitionInfo.builder().build(); - - when(partitionServiceImpl.updatePartition(partId, newPi)).thenReturn(null); - - cachedPartitionServiceImpl.updatePartition(partId, newPi); - - verify(partitionServiceImpl, times(1)).updatePartition(partId, newPi); - verify(partitionServiceCache, times(0)).put(any(), any()); - verify(partitionServiceCache, times(0)).get(any()); - } - - @Test - public void getPartition() { - String partId = "key"; - - PartitionInfo retPi = PartitionInfo.builder().build(); - - when(partitionServiceImpl.getPartition(partId)).thenReturn(retPi); - - cachedPartitionServiceImpl.getPartition(partId); - - verify(partitionServiceCache, times(1)).get(partId); - verify(partitionServiceImpl, times(1)).getPartition(partId); - verify(partitionServiceCache, times(1)).put(partId, retPi); - } - - @Test - public void deletePartition() { - String partId = "key"; - PartitionInfo retPi = PartitionInfo.builder().build(); - - when(partitionServiceImpl.deletePartition(partId)).thenReturn(true); - when(partitionServiceCache.get(partId)).thenReturn(retPi); - - cachedPartitionServiceImpl.deletePartition(partId); - - verify(partitionServiceImpl, times(1)).deletePartition(partId); - verify(partitionServiceCache, times(1)).delete(partId); - verify(partitionServiceCache, times(1)).get(partId); - verify(partitionListCache, times(1)).clearAll(); - } - - @Test - public void getAllPartitions() { - List<String> partitions = new ArrayList<>(); - - when(partitionServiceImpl.getAllPartitions()).thenReturn(partitions); - cachedPartitionServiceImpl.getAllPartitions(); - String partKey = "getAllPartitions"; - verify(partitionListCache, times(1)).get(partKey); - verify(partitionServiceImpl, times(1)).getAllPartitions(); - verify(partitionListCache, times(1)).put(partKey, partitions); - } - -} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 44e6451c7324c2c6430a96eadfcdc8b102f48dbb..1a4c022ab3acd4f08156bbb290793761bf014748 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.opengroup.osdu</groupId> <artifactId>partition</artifactId> - <version>0.12.0</version> + <version>0.13.0-SNAPSHOT</version> <description>Partition Service</description> <properties> diff --git a/provider/partition-aws/pom.xml b/provider/partition-aws/pom.xml index 466ec16928b5eef79189888bbcd6a70700ab5238..00883ec60432eaf8fd44275d0337f7ea48f4ecd6 100644 --- a/provider/partition-aws/pom.xml +++ b/provider/partition-aws/pom.xml @@ -21,7 +21,7 @@ <parent> <artifactId>partition</artifactId> <groupId>org.opengroup.osdu</groupId> - <version>0.12.0</version> + <version>0.13.0-SNAPSHOT</version> <relativePath>../../pom.xml</relativePath> </parent> diff --git a/provider/partition-aws/src/main/java/org/opengroup/osdu/partition/provider/aws/service/PartitionServiceDummyListCacheImpl.java b/provider/partition-aws/src/main/java/org/opengroup/osdu/partition/provider/aws/service/PartitionServiceDummyListCacheImpl.java deleted file mode 100644 index 6065c902714871f0611491478b832087bd557c03..0000000000000000000000000000000000000000 --- a/provider/partition-aws/src/main/java/org/opengroup/osdu/partition/provider/aws/service/PartitionServiceDummyListCacheImpl.java +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright © 2020 Amazon Web Services -// -// 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 org.opengroup.osdu.partition.provider.aws.service; - -import org.opengroup.osdu.partition.model.PartitionInfo; -import org.opengroup.osdu.partition.provider.interfaces.IPartitionServiceCache; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; -import java.util.List; - -/*** - * We don't want to use cache. Implement a dummy service to always return a cache miss. - */ -@Service -@Qualifier("partitionListCache") -public class PartitionServiceDummyListCacheImpl implements IPartitionServiceCache<String, List<String>> { - public PartitionServiceDummyListCacheImpl() { - - } - - @Override - public void clearAll() { - return; - } - - @Override - public void delete(String arg0) { - return; - } - - @Override - public List<String> get(String arg0) { - return null; - } - - @Override - public void put(String arg0, List<String> arg1) { - return; - } -} diff --git a/provider/partition-aws/src/main/java/org/opengroup/osdu/partition/provider/aws/service/PartitionServiceDummyPartitionInfoCacheImpl.java b/provider/partition-aws/src/main/java/org/opengroup/osdu/partition/provider/aws/service/PartitionServiceDummyPartitionInfoCacheImpl.java deleted file mode 100644 index 615ddef175865f4dfa389e754cf28f9c8f4d8ee9..0000000000000000000000000000000000000000 --- a/provider/partition-aws/src/main/java/org/opengroup/osdu/partition/provider/aws/service/PartitionServiceDummyPartitionInfoCacheImpl.java +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright © 2020 Amazon Web Services -// -// 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 org.opengroup.osdu.partition.provider.aws.service; - -import org.opengroup.osdu.partition.model.PartitionInfo; -import org.opengroup.osdu.partition.provider.interfaces.IPartitionServiceCache; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; - -/*** - * We don't want to use cache. Implement a dummy service to always return a cache miss. - */ -@Service -@Qualifier("partitionServiceCache") -public class PartitionServiceDummyPartitionInfoCacheImpl implements IPartitionServiceCache<String, PartitionInfo> { - public PartitionServiceDummyPartitionInfoCacheImpl() { - - } - - @Override - public void clearAll() { - return; - } - - @Override - public void delete(String arg0) { - return; - } - - @Override - public PartitionInfo get(String arg0) { - return null; - } - - @Override - public void put(String arg0, PartitionInfo arg1) { - return; - } -} diff --git a/provider/partition-aws/src/main/java/org/opengroup/osdu/partition/provider/aws/service/PartitionServiceImpl.java b/provider/partition-aws/src/main/java/org/opengroup/osdu/partition/provider/aws/service/PartitionServiceImpl.java index ce1433df3184b49282524b02cf6a2295a5fe10c5..ad69c012f8c112aa29f8c94d65ede3e7f827125c 100644 --- a/provider/partition-aws/src/main/java/org/opengroup/osdu/partition/provider/aws/service/PartitionServiceImpl.java +++ b/provider/partition-aws/src/main/java/org/opengroup/osdu/partition/provider/aws/service/PartitionServiceImpl.java @@ -14,9 +14,6 @@ package org.opengroup.osdu.partition.provider.aws.service; -import java.util.List; -import java.util.Map; - import org.apache.http.HttpStatus; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; import org.opengroup.osdu.core.common.model.http.AppException; @@ -27,6 +24,12 @@ import org.opengroup.osdu.partition.provider.interfaces.IPartitionService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; +import java.util.Map; + +/** + * AWS implementation doesn't use cache. + */ @Service public class PartitionServiceImpl implements IPartitionService { diff --git a/provider/partition-azure/pom.xml b/provider/partition-azure/pom.xml index 7b0194a3e2fa4c8e823dc4e67e6523edfd724bf0..d25ec10adcc352e98a3ad19b99191c44cb869aed 100644 --- a/provider/partition-azure/pom.xml +++ b/provider/partition-azure/pom.xml @@ -4,7 +4,7 @@ <parent> <artifactId>partition</artifactId> <groupId>org.opengroup.osdu</groupId> - <version>0.12.0</version> + <version>0.13.0-SNAPSHOT</version> <relativePath>../../pom.xml</relativePath> </parent> diff --git a/provider/partition-azure/src/main/java/org/opengroup/osdu/partition/provider/azure/cache/PartitionListCacheImpl.java b/provider/partition-azure/src/main/java/org/opengroup/osdu/partition/provider/azure/cache/PartitionListCacheImpl.java deleted file mode 100644 index 11a6a706100ba0245bd97049e543998a4e8e9ce4..0000000000000000000000000000000000000000 --- a/provider/partition-azure/src/main/java/org/opengroup/osdu/partition/provider/azure/cache/PartitionListCacheImpl.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.opengroup.osdu.partition.provider.azure.cache; - -import org.opengroup.osdu.core.common.cache.ICache; -import org.opengroup.osdu.partition.provider.interfaces.IPartitionServiceCache; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.util.List; - -@Service -@Qualifier("partitionListCache") -public class PartitionListCacheImpl implements IPartitionServiceCache<String, List<String>> { - - @Resource(name="partitionListCache") - private ICache<String, List<String>> cache; - - @Override - public void put(String s, List<String> o) { - this.cache.put(s, o); - } - - @Override - public List<String> get(String s) { - return this.cache.get(s); - } - - @Override - public void delete(String s) { - this.cache.delete(s); - } - - @Override - public void clearAll() { - this.cache.clearAll(); - } - -} diff --git a/provider/partition-azure/src/main/java/org/opengroup/osdu/partition/provider/azure/cache/PartitionServiceCacheImpl.java b/provider/partition-azure/src/main/java/org/opengroup/osdu/partition/provider/azure/cache/PartitionServiceCacheImpl.java deleted file mode 100644 index 372432c05f7a9d41eb815058061afa65f0972e7b..0000000000000000000000000000000000000000 --- a/provider/partition-azure/src/main/java/org/opengroup/osdu/partition/provider/azure/cache/PartitionServiceCacheImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.opengroup.osdu.partition.provider.azure.cache; - -import org.opengroup.osdu.core.common.cache.ICache; -import org.opengroup.osdu.partition.model.PartitionInfo; -import org.opengroup.osdu.partition.provider.interfaces.IPartitionServiceCache; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; - -@Service -@Qualifier("partitionServiceCache") -public class PartitionServiceCacheImpl implements IPartitionServiceCache<String, PartitionInfo> { - - @Resource(name="partitionServiceCache") - private ICache<String, PartitionInfo> cache; - - @Override - public void put(String s, PartitionInfo o) { - this.cache.put(s, o); - } - - @Override - public PartitionInfo get(String s) { - return this.cache.get(s); - } - - @Override - public void delete(String s) { - this.cache.delete(s); - } - - @Override - public void clearAll() { - this.cache.clearAll(); - } -} diff --git a/provider/partition-azure/src/main/java/org/opengroup/osdu/partition/provider/azure/service/PartitionServiceImpl.java b/provider/partition-azure/src/main/java/org/opengroup/osdu/partition/provider/azure/service/PartitionServiceImpl.java index ec96e47aac01391c54eb13c33194ad2b29633903..b1ae9b1c1eec9f61ad3d997fa437e9eefb1727e6 100644 --- a/provider/partition-azure/src/main/java/org/opengroup/osdu/partition/provider/azure/service/PartitionServiceImpl.java +++ b/provider/partition-azure/src/main/java/org/opengroup/osdu/partition/provider/azure/service/PartitionServiceImpl.java @@ -15,41 +15,56 @@ package org.opengroup.osdu.partition.provider.azure.service; import org.apache.http.HttpStatus; +import org.opengroup.osdu.core.common.cache.ICache; import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.partition.model.PartitionInfo; import org.opengroup.osdu.partition.model.Property; import org.opengroup.osdu.partition.provider.azure.persistence.PartitionTableStore; import org.opengroup.osdu.partition.provider.interfaces.IPartitionService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; -import java.util.ArrayList; +import javax.inject.Inject; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; @Service public class PartitionServiceImpl implements IPartitionService { - private final String PARTITION_NOT_FOUND = "partition not found"; + static final String PARTITION_LIST_KEY = "getAllPartitions"; + static final String PARTITION_NOT_FOUND = "partition not found"; @Autowired private PartitionTableStore tableStore; + @Inject + @Qualifier("partitionServiceCache") + private ICache<String, PartitionInfo> partitionServiceCache; + + @Inject + @Qualifier("partitionListCache") + private ICache<String, List<String>> partitionListCache; + @Override public PartitionInfo createPartition(String partitionId, PartitionInfo partitionInfo) { - if (this.tableStore.partitionExists(partitionId)) { + if (partitionServiceCache.get(partitionId) != null || tableStore.partitionExists(partitionId)) { throw new AppException(HttpStatus.SC_CONFLICT, "partition exist", "Partition with same id exist"); } - this.tableStore.addPartition(partitionId, partitionInfo); + tableStore.addPartition(partitionId, partitionInfo); + + partitionServiceCache.put(partitionId, partitionInfo); + partitionListCache.clearAll(); return partitionInfo; } @Override public PartitionInfo updatePartition(String partitionId, PartitionInfo partitionInfo) { - if (!this.tableStore.partitionExists(partitionId)) { + if (!tableStore.partitionExists(partitionId)) { throw new AppException(HttpStatus.SC_NOT_FOUND, PARTITION_NOT_FOUND, String.format("%s partition not found", partitionId)); } @@ -57,35 +72,65 @@ public class PartitionServiceImpl implements IPartitionService { throw new AppException(HttpStatus.SC_BAD_REQUEST, "can not update id", "the field id can not be updated"); } - this.tableStore.addPartition(partitionId, partitionInfo); - return PartitionInfo.builder().properties(this.tableStore.getPartition(partitionId)).build(); + tableStore.addPartition(partitionId, partitionInfo); + PartitionInfo pi = Optional.ofNullable(tableStore.getPartition(partitionId)) + .map(map -> PartitionInfo.builder().properties(map).build()) + .orElse(null); + + if(pi != null) { + partitionServiceCache.put(partitionId, pi); + } + + return pi; } @Override public PartitionInfo getPartition(String partitionId) { - Map<String, Property> out = new HashMap<>(); - out.putAll(this.tableStore.getPartition(partitionId)); + PartitionInfo pi = partitionServiceCache.get(partitionId); - if (out.isEmpty()) { - throw new AppException(HttpStatus.SC_NOT_FOUND, PARTITION_NOT_FOUND, String.format("%s partition not found", partitionId)); + if (pi == null) { + Map<String, Property> out = new HashMap<>(tableStore.getPartition(partitionId)); + + if (out.isEmpty()) { + throw new AppException(HttpStatus.SC_NOT_FOUND, PARTITION_NOT_FOUND, String.format("%s partition not found", partitionId)); + } + + pi = PartitionInfo.builder().properties(out).build(); + + if (pi != null) { + partitionServiceCache.put(partitionId, pi); + } } - return PartitionInfo.builder().properties(out).build(); + return pi; } @Override public boolean deletePartition(String partitionId) { - if (!this.tableStore.partitionExists(partitionId)) { + if (!tableStore.partitionExists(partitionId)) { throw new AppException(HttpStatus.SC_NOT_FOUND, PARTITION_NOT_FOUND, String.format("%s partition not found", partitionId)); } - this.tableStore.deletePartition(partitionId); + tableStore.deletePartition(partitionId); + if (partitionServiceCache.get(partitionId) != null) { + partitionServiceCache.delete(partitionId); + } + partitionListCache.clearAll(); return true; } @Override public List<String> getAllPartitions() { - return this.tableStore.getAllPartitions(); + List<String> partitions = partitionListCache.get(PARTITION_LIST_KEY); + + if (partitions == null) { + partitions = tableStore.getAllPartitions(); + + if (partitions != null) { + partitionListCache.put(PARTITION_LIST_KEY, partitions); + } + } + return partitions; } } \ No newline at end of file diff --git a/provider/partition-azure/src/test/java/org/opengroup/osdu/partition/provider/azure/service/PartitionServiceImplCacheTest.java b/provider/partition-azure/src/test/java/org/opengroup/osdu/partition/provider/azure/service/PartitionServiceImplCacheTest.java new file mode 100644 index 0000000000000000000000000000000000000000..6c5b7800e91d7b3dbcba0dbcc49aa9481789cac0 --- /dev/null +++ b/provider/partition-azure/src/test/java/org/opengroup/osdu/partition/provider/azure/service/PartitionServiceImplCacheTest.java @@ -0,0 +1,146 @@ +// Copyright 2017-2020, Schlumberger +// +// 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 org.opengroup.osdu.partition.provider.azure.service; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.opengroup.osdu.core.common.cache.ICache; +import org.opengroup.osdu.partition.model.PartitionInfo; +import org.opengroup.osdu.partition.model.Property; +import org.opengroup.osdu.partition.provider.azure.persistence.PartitionTableStore; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +@ExtendWith(MockitoExtension.class) +public class PartitionServiceImplCacheTest { + + @Mock + private PartitionTableStore tableStore; + + @Mock + private ICache<String, PartitionInfo> partitionServiceCache; + + @Mock + private ICache<String, List<String>> partitionListCache; + + @InjectMocks + private PartitionServiceImpl partitionService; + + @Test + public void createPartitionSucceed() { + String partId = "key"; + + PartitionInfo newPi = PartitionInfo.builder().build(); + PartitionInfo retPi = PartitionInfo.builder().build(); + + PartitionInfo partition = partitionService.createPartition(partId, newPi); + + assertEquals(newPi, partition); + verify(tableStore, times(1)).addPartition(partId, newPi); + verify(partitionServiceCache, times(1)).put(partId, retPi); + verify(partitionListCache, times(1)).clearAll(); + } + + @Test + public void updatePartitionSucceed() { + String partId = "key"; + + PartitionInfo newPi = PartitionInfo.builder().build(); + Map<String, Property> retPiProps = new HashMap<>(); + PartitionInfo retPi = PartitionInfo.builder().properties(retPiProps).build(); + + when(tableStore.partitionExists(partId)).thenReturn(true); + when(tableStore.getPartition(partId)).thenReturn(retPiProps); + + partitionService.updatePartition(partId, newPi); + + verify(tableStore, times(1)).addPartition(partId, newPi); + verify(partitionServiceCache, times(1)).put(partId, retPi); + } + + @Test + public void updatePartitionFailed() { + String partId = "key"; + PartitionInfo newPi = PartitionInfo.builder().build(); + + when(tableStore.partitionExists(partId)).thenReturn(true); + when(tableStore.getPartition(partId)).thenReturn(null); + + partitionService.updatePartition(partId, newPi); + + verify(tableStore, times(1)).addPartition(partId, newPi); + verify(partitionServiceCache, times(0)).put(any(), any()); + verify(partitionServiceCache, times(0)).get(any()); + } + + @Test + public void getPartition() { + String partId = "key"; + + Map<String, Property> retPiProps = new HashMap<String, Property>() {{ + put("1", mock(Property.class)); + }}; + PartitionInfo retPi = PartitionInfo.builder().properties(retPiProps).build(); + + when(tableStore.getPartition(partId)).thenReturn(retPiProps); + + partitionService.getPartition(partId); + + verify(partitionServiceCache, times(1)).get(partId); + verify(tableStore, times(1)).getPartition(partId); + verify(partitionServiceCache, times(1)).put(partId, retPi); + } + + @Test + public void deletePartition() { + String partId = "key"; + PartitionInfo retPi = PartitionInfo.builder().build(); + + when(tableStore.partitionExists(partId)).thenReturn(true); + when(partitionServiceCache.get(partId)).thenReturn(retPi); + + partitionService.deletePartition(partId); + + verify(tableStore, times(1)).deletePartition(partId); + verify(partitionServiceCache, times(1)).delete(partId); + verify(partitionServiceCache, times(1)).get(partId); + verify(partitionListCache, times(1)).clearAll(); + } + + @Test + public void getAllPartitions() { + List<String> partitions = new ArrayList<>(); + + when(tableStore.getAllPartitions()).thenReturn(partitions); + partitionService.getAllPartitions(); + String partKey = "getAllPartitions"; + verify(partitionListCache, times(1)).get(partKey); + verify(tableStore, times(1)).getAllPartitions(); + verify(partitionListCache, times(1)).put(partKey, partitions); + } +} \ No newline at end of file diff --git a/provider/partition-azure/src/test/java/org/opengroup/osdu/partition/provider/azure/service/PartitionServiceImplTest.java b/provider/partition-azure/src/test/java/org/opengroup/osdu/partition/provider/azure/service/PartitionServiceImplTest.java index 8643ebee2299e24487d5f22df43dbd8a4b05c25f..2521a6a6f65c481f5a122be73729162866d3c688 100644 --- a/provider/partition-azure/src/test/java/org/opengroup/osdu/partition/provider/azure/service/PartitionServiceImplTest.java +++ b/provider/partition-azure/src/test/java/org/opengroup/osdu/partition/provider/azure/service/PartitionServiceImplTest.java @@ -14,28 +14,38 @@ package org.opengroup.osdu.partition.provider.azure.service; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.opengroup.osdu.core.common.cache.ICache; import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.partition.model.PartitionInfo; import org.opengroup.osdu.partition.model.Property; import org.opengroup.osdu.partition.provider.azure.persistence.PartitionTableStore; -import org.powermock.modules.junit4.PowerMockRunner; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.when; -@RunWith(PowerMockRunner.class) +@ExtendWith(MockitoExtension.class) public class PartitionServiceImplTest { + @Mock + private ICache<String, PartitionInfo> partitionServiceCache; + + @Mock + private ICache<String, List<String>> partitionListCache; + @Mock private PartitionTableStore tableStore; @InjectMocks @@ -46,7 +56,7 @@ public class PartitionServiceImplTest { private final static String PARTITION_ID = "my-tenant"; private final Map<String, Property> properties = new HashMap<>(); - @Before + @BeforeEach public void setup() { properties.put("id", Property.builder().value(PARTITION_ID).build()); properties.put("storageAccount", Property.builder().value("storage-account").sensitive(true).build()); @@ -136,8 +146,6 @@ public class PartitionServiceImplTest { @Test public void should_throwException_when_deletingNonExistentPartition() { - when(this.tableStore.partitionExists(PARTITION_ID)).thenReturn(false); - try { this.sut.deletePartition("test-partition"); } catch (AppException ae) { @@ -146,10 +154,9 @@ public class PartitionServiceImplTest { } } - @Test(expected = AppException.class) + @Test public void should_throwException_when_deletingInvalidPartition() { - - this.sut.deletePartition(null); + assertThrows(AppException.class, () -> sut.deletePartition(null)); } @Test diff --git a/provider/partition-gcp/pom.xml b/provider/partition-gcp/pom.xml index 78fdba84d04f9a2b3181e6cd98b1f0950b6c5fa8..85c9fd26b627520eba3dfba0ca3bc17ffc5fa8a8 100644 --- a/provider/partition-gcp/pom.xml +++ b/provider/partition-gcp/pom.xml @@ -5,7 +5,7 @@ <parent> <artifactId>partition</artifactId> <groupId>org.opengroup.osdu</groupId> - <version>0.12.0</version> + <version>0.13.0-SNAPSHOT</version> <relativePath>../../pom.xml</relativePath> </parent> diff --git a/provider/partition-gcp/src/main/java/org/opengroup/osdu/partition/provider/gcp/cache/PartitionListCacheImpl.java b/provider/partition-gcp/src/main/java/org/opengroup/osdu/partition/provider/gcp/cache/PartitionListCacheImpl.java deleted file mode 100644 index 366bb47ab386d439d07ac41f945966fb59e52b94..0000000000000000000000000000000000000000 --- a/provider/partition-gcp/src/main/java/org/opengroup/osdu/partition/provider/gcp/cache/PartitionListCacheImpl.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - Copyright 2002-2021 Google LLC - Copyright 2002-2021 EPAM Systems, 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. - */ - -package org.opengroup.osdu.partition.provider.gcp.cache; - -import java.util.List; -import lombok.RequiredArgsConstructor; -import org.opengroup.osdu.core.common.cache.ICache; -import org.opengroup.osdu.partition.provider.interfaces.IPartitionServiceCache; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; - -@Service -@Qualifier("partitionListCache") -@RequiredArgsConstructor -public class PartitionListCacheImpl implements IPartitionServiceCache<String, List<String>> { - - private final ICache<String, List<String>> cache; - - @Override - public void put(String s, List<String> o) { - this.cache.put(s, o); - } - - @Override - public List<String> get(String s) { - return this.cache.get(s); - } - - @Override - public void delete(String s) { - this.cache.delete(s); - } - - @Override - public void clearAll() { - this.cache.clearAll(); - } -} diff --git a/provider/partition-gcp/src/main/java/org/opengroup/osdu/partition/provider/gcp/cache/PartitionServiceCacheImpl.java b/provider/partition-gcp/src/main/java/org/opengroup/osdu/partition/provider/gcp/cache/PartitionServiceCacheImpl.java deleted file mode 100644 index af35fb9431bc5c34932b5ee66b9cdf9be7e99dc0..0000000000000000000000000000000000000000 --- a/provider/partition-gcp/src/main/java/org/opengroup/osdu/partition/provider/gcp/cache/PartitionServiceCacheImpl.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - Copyright 2002-2021 Google LLC - Copyright 2002-2021 EPAM Systems, 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. - */ -package org.opengroup.osdu.partition.provider.gcp.cache; - -import lombok.RequiredArgsConstructor; -import org.opengroup.osdu.core.common.cache.ICache; -import org.opengroup.osdu.partition.model.PartitionInfo; -import org.opengroup.osdu.partition.provider.interfaces.IPartitionServiceCache; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; - -@Service -@Qualifier("partitionServiceCache") -@RequiredArgsConstructor -public class PartitionServiceCacheImpl implements IPartitionServiceCache<String, PartitionInfo> { - - private final ICache<String, PartitionInfo> cache; - - @Override - public void put(String s, PartitionInfo o) { - this.cache.put(s, o); - } - - @Override - public PartitionInfo get(String s) { - return this.cache.get(s); - } - - @Override - public void delete(String s) { - this.cache.delete(s); - } - - @Override - public void clearAll() { - this.cache.clearAll(); - } -} diff --git a/provider/partition-gcp/src/main/java/org/opengroup/osdu/partition/provider/gcp/service/PartitionServiceImpl.java b/provider/partition-gcp/src/main/java/org/opengroup/osdu/partition/provider/gcp/service/PartitionServiceImpl.java index 1c82f49c73cd74d18b13611aabd5dac09f0580f8..226e294905fc691af8cfa9425ca560c7948c48fc 100644 --- a/provider/partition-gcp/src/main/java/org/opengroup/osdu/partition/provider/gcp/service/PartitionServiceImpl.java +++ b/provider/partition-gcp/src/main/java/org/opengroup/osdu/partition/provider/gcp/service/PartitionServiceImpl.java @@ -17,15 +17,9 @@ package org.opengroup.osdu.partition.provider.gcp.service; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; import lombok.RequiredArgsConstructor; import org.apache.http.HttpStatus; +import org.opengroup.osdu.core.common.cache.ICache; import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.core.common.provider.interfaces.IKmsClient; import org.opengroup.osdu.partition.logging.AuditLogger; @@ -37,12 +31,21 @@ import org.opengroup.osdu.partition.provider.interfaces.IPartitionService; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + @Service @RequiredArgsConstructor public class PartitionServiceImpl implements IPartitionService { - private static final String UNKNOWN_ERROR_REASON = "unknown error"; - + static final String UNKNOWN_ERROR_REASON = "unknown error"; + static final String PARTITION_LIST_KEY = "getAllPartitions"; private final PartitionPropertyEntityRepository partitionPropertyEntityRepository; @@ -50,17 +53,24 @@ public class PartitionServiceImpl implements IPartitionService { private final AuditLogger auditLogger; + private final ICache<String, PartitionInfo> partitionServiceCache; + + private final ICache<String, List<String>> partitionListCache; + @Override public PartitionInfo createPartition(String partitionId, PartitionInfo partitionInfo) { + if (partitionServiceCache.get(partitionId) != null) + throw new AppException(HttpStatus.SC_CONFLICT, "partition exist", "Partition with same id exist"); + if (this.partitionPropertyEntityRepository.findByPartitionId(partitionId).isPresent()) { this.auditLogger.createPartitionFailure(Collections.singletonList(partitionId)); throw new AppException(HttpStatus.SC_CONFLICT, UNKNOWN_ERROR_REASON, - "Partition already exists."); + "Partition already exists."); } List<PartitionPropertyEntity> partitionProperties = new ArrayList<>(); for (Map.Entry<String, Property> entry : partitionInfo.getProperties().entrySet()) { PartitionPropertyEntity entity = new PartitionPropertyEntity(partitionId, - entry.getKey(), entry.getValue()); + entry.getKey(), entry.getValue()); encryptPartitionPropertyEntityIfNeeded(entity); partitionProperties.add(entity); } @@ -68,7 +78,13 @@ public class PartitionServiceImpl implements IPartitionService { repository.saveAll(partitionProperties); return true; }); - return getPartition(partitionId); + PartitionInfo pi = getPartition(partitionId); + + if (pi != null) { + partitionListCache.clearAll(); + } + + return pi; } private void encryptPartitionPropertyEntityIfNeeded(PartitionPropertyEntity entity) { @@ -88,19 +104,19 @@ public class PartitionServiceImpl implements IPartitionService { if (partitionInfo.getProperties().containsKey("id")) { this.auditLogger.updatePartitionSecretFailure(Collections.singletonList(partitionId)); throw new AppException(HttpStatus.SC_BAD_REQUEST, "can not update id", - "the field id can not be updated"); + "the field id can not be updated"); } if (!this.partitionPropertyEntityRepository.findByPartitionId(partitionId).isPresent()) { this.auditLogger.updatePartitionSecretFailure(Collections.singletonList(partitionId)); throw new AppException(HttpStatus.SC_NOT_FOUND, UNKNOWN_ERROR_REASON, - "An attempt to update not existing partition."); + "An attempt to update not existing partition."); } List<PartitionPropertyEntity> partitionProperties = new ArrayList<>(); for (Map.Entry<String, Property> entry : partitionInfo.getProperties().entrySet()) { PartitionPropertyEntity entity = this.partitionPropertyEntityRepository - .findByPartitionIdAndName(partitionId, entry.getKey()); + .findByPartitionIdAndName(partitionId, entry.getKey()); if (Objects.nonNull(entity)) { entity.setSensitive(entry.getValue().isSensitive()); entity.setValue(entry.getValue().getValue()); @@ -114,26 +130,37 @@ public class PartitionServiceImpl implements IPartitionService { repository.saveAll(partitionProperties); return true; }); + return getPartition(partitionId); } @Override public PartitionInfo getPartition(String partitionId) { - PartitionInfo partitionInfo = getEncryptedPartition(partitionId); - for (Property property : partitionInfo.getProperties().values()) { - decryptPartitionPropertyIfNeeded(property); + PartitionInfo pi = partitionServiceCache.get(partitionId); + + if (pi == null) { + pi = getEncryptedPartition(partitionId); + for (Property property : pi.getProperties().values()) { + decryptPartitionPropertyIfNeeded(property); + } + + if (pi != null) { + partitionServiceCache.put(partitionId, pi); + } } - return partitionInfo; + + return pi; } private PartitionInfo getEncryptedPartition(String partitionId) { - if (!this.partitionPropertyEntityRepository.findByPartitionId(partitionId).isPresent()) { + Optional<List<PartitionPropertyEntity>> partitionPropertyEntitiesOptional = partitionPropertyEntityRepository + .findByPartitionId(partitionId); + if (!partitionPropertyEntitiesOptional.isPresent()) { this.auditLogger.readPartitionFailure(Collections.singletonList(partitionId)); throw new AppException(HttpStatus.SC_NOT_FOUND, UNKNOWN_ERROR_REASON, "Partition does not exist."); } - List<PartitionPropertyEntity> partitionPropertiesList = this.partitionPropertyEntityRepository - .findByPartitionId(partitionId).get(); + List<PartitionPropertyEntity> partitionPropertiesList = partitionPropertyEntitiesOptional.get(); PartitionInfo partitionInfo = new PartitionInfo(); Map<String, Property> partitionInfoProperties = new HashMap<>(); for (PartitionPropertyEntity entity : partitionPropertiesList) { @@ -163,16 +190,30 @@ public class PartitionServiceImpl implements IPartitionService { if (!this.partitionPropertyEntityRepository.findByPartitionId(partitionId).isPresent()) { this.auditLogger.deletePartitionFailure(Collections.singletonList(partitionId)); throw new AppException(HttpStatus.SC_NOT_FOUND, UNKNOWN_ERROR_REASON, - "An attempt to delete not existing partition."); + "An attempt to delete not existing partition."); } this.partitionPropertyEntityRepository.deleteByPartitionId(partitionId); + + if (partitionServiceCache.get(partitionId) != null) { + partitionServiceCache.delete(partitionId); + } + partitionListCache.clearAll(); return true; } @Transactional @Override public List<String> getAllPartitions() { - List<String> allPartitions = this.partitionPropertyEntityRepository.getAllPartitions(); - return (allPartitions.isEmpty() ? null : allPartitions); + List<String> partitions = partitionListCache.get(PARTITION_LIST_KEY); + + if (partitions == null) { + List<String> allPartitions = this.partitionPropertyEntityRepository.getAllPartitions(); + partitions = (allPartitions.isEmpty() ? null : allPartitions); + + if (partitions != null) { + partitionListCache.put(PARTITION_LIST_KEY, partitions); + } + } + return partitions; } } diff --git a/provider/partition-gcp/src/test/java/org/opengroup/osdu/partition/provider/gcp/service/PartitionServiceImplCacheTest.java b/provider/partition-gcp/src/test/java/org/opengroup/osdu/partition/provider/gcp/service/PartitionServiceImplCacheTest.java new file mode 100644 index 0000000000000000000000000000000000000000..388f56f2836d9bc4d891c728efd25e8d2b1ab82b --- /dev/null +++ b/provider/partition-gcp/src/test/java/org/opengroup/osdu/partition/provider/gcp/service/PartitionServiceImplCacheTest.java @@ -0,0 +1,200 @@ +/* + Copyright 2002-2021 Google LLC + Copyright 2002-2021 EPAM Systems, 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. + */ + +package org.opengroup.osdu.partition.provider.gcp.service; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.opengroup.osdu.core.common.cache.ICache; +import org.opengroup.osdu.core.common.model.http.AppException; +import org.opengroup.osdu.core.common.provider.interfaces.IKmsClient; +import org.opengroup.osdu.partition.logging.AuditLogger; +import org.opengroup.osdu.partition.model.PartitionInfo; +import org.opengroup.osdu.partition.model.Property; +import org.opengroup.osdu.partition.provider.gcp.model.PartitionPropertyEntity; +import org.opengroup.osdu.partition.provider.gcp.repository.PartitionPropertyEntityRepository; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.argThat; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +@ExtendWith(MockitoExtension.class) +public class PartitionServiceImplCacheTest { + + @Mock + private ICache<String, PartitionInfo> partitionServiceCache; + + @Mock + private ICache<String, List<String>> partitionListCache; + + @Mock + private PartitionPropertyEntityRepository partitionPropertyEntityRepository; + + @Mock + private AuditLogger auditLogger; + + private PartitionServiceImpl partitionServiceImpl; + + @BeforeEach + public void setup() { + partitionServiceImpl = new PartitionServiceImpl( + partitionPropertyEntityRepository, + mock(IKmsClient.class), + auditLogger, + partitionServiceCache, + partitionListCache + ); + } + + private List<PartitionPropertyEntity> partitionInfoToEntity(String partitionId, PartitionInfo partitionInfo) { + return partitionInfo.getProperties().entrySet().stream() + .map(entry -> new PartitionPropertyEntity(partitionId, entry.getKey(), entry.getValue())) + .collect(Collectors.toList()); + } + + @Test + public void createPartitionSucceed() { + String partId = "key"; + + PartitionInfo newPi = PartitionInfo.builder().build(); + PartitionInfo retPi = PartitionInfo.builder().build(); + String propKey = "123987123498"; + retPi.getProperties().put(propKey, new Property()); + + doReturn(Optional.empty(), Optional.of(partitionInfoToEntity(partId, retPi))) + .when(partitionPropertyEntityRepository).findByPartitionId(partId); + partitionServiceImpl.createPartition(partId, newPi); + + verify(partitionPropertyEntityRepository, times(1)).performTransaction(any()); + verify(partitionServiceCache, times(1)) + .put(any(), argThat(argument -> argument.getProperties().containsKey(propKey))); + verify(partitionListCache).clearAll(); + } + + @Test + public void createPartitionFailed() { + String partId = "key"; + PartitionInfo newPi = PartitionInfo.builder().build(); + + when(partitionServiceCache.get(partId)).thenReturn(null); + doReturn(Optional.empty()) + .when(partitionPropertyEntityRepository).findByPartitionId(partId); + + assertThrows(AppException.class, () -> partitionServiceImpl.createPartition(partId, newPi)); + + verify(partitionServiceCache, times(0)).put(any(), any()); + verify(partitionListCache, times(0)).clearAll(); + verify(partitionServiceCache, times(2)).get(any()); + } + + @Test + public void updatePartitionSucceed() { + String partId = "key"; + + PartitionInfo newPi = PartitionInfo.builder().build(); + PartitionInfo retPi = PartitionInfo.builder().build(); + String propKey = "123987123498"; + retPi.getProperties().put(propKey, new Property()); + + doReturn(Optional.of(partitionInfoToEntity(partId, retPi))) + .when(partitionPropertyEntityRepository).findByPartitionId(partId); + + partitionServiceImpl.updatePartition(partId, newPi); + + verify(partitionPropertyEntityRepository, times(1)).performTransaction(any()); + verify(partitionServiceCache, times(1)) + .put(any(), argThat(argument -> argument.getProperties().containsKey(propKey))); + } + + @Test + public void updatePartitionFailed() { + String partId = "key"; + PartitionInfo newPi = PartitionInfo.builder().build(); + + doReturn(Optional.empty()) + .when(partitionPropertyEntityRepository).findByPartitionId(partId); + + assertThrows(AppException.class, () -> partitionServiceImpl.updatePartition(partId, newPi)); + + verify(partitionServiceCache, times(0)).put(any(), any()); + verify(partitionServiceCache, times(0)).get(any()); + } + + + @Test + public void getPartition() { + String partId = "key"; + + PartitionInfo retPi = PartitionInfo.builder().build(); + String propKey = "123987123498"; + retPi.getProperties().put(propKey, new Property()); + + doReturn(Optional.of(partitionInfoToEntity(partId, retPi))) + .when(partitionPropertyEntityRepository).findByPartitionId(partId); + + partitionServiceImpl.getPartition(partId); + + verify(partitionServiceCache, times(1)).get(partId); + verify(partitionPropertyEntityRepository, times(1)).findByPartitionId(partId); + verify(partitionServiceCache, times(1)).put(partId, retPi); + } + + @Test + public void deletePartition() { + String partId = "key"; + PartitionInfo retPi = PartitionInfo.builder().build(); + + doReturn(Optional.of(partitionInfoToEntity(partId, retPi))) + .when(partitionPropertyEntityRepository).findByPartitionId(partId); + when(partitionServiceCache.get(partId)).thenReturn(retPi); + + partitionServiceImpl.deletePartition(partId); + + verify(partitionPropertyEntityRepository, times(1)).deleteByPartitionId(partId); + verify(partitionServiceCache, times(1)).delete(partId); + verify(partitionServiceCache, times(1)).get(partId); + verify(partitionListCache, times(1)).clearAll(); + } + + @Test + public void getAllPartitions() { + List<String> partitions = new ArrayList<>(); + partitions.add("1"); + + doReturn(partitions) + .when(partitionPropertyEntityRepository).getAllPartitions(); + + partitionServiceImpl.getAllPartitions(); + + verify(partitionListCache, times(1)).get(PartitionServiceImpl.PARTITION_LIST_KEY); + verify(partitionPropertyEntityRepository, times(1)).getAllPartitions(); + verify(partitionListCache, times(1)).put(PartitionServiceImpl.PARTITION_LIST_KEY, partitions); + } +} \ No newline at end of file diff --git a/provider/partition-gcp/src/test/java/org/opengroup/osdu/partition/provider/gcp/service/PartitionServiceImplTest.java b/provider/partition-gcp/src/test/java/org/opengroup/osdu/partition/provider/gcp/service/PartitionServiceImplTest.java index fadb1f153c422417e64e32d9728d8a089d65e431..a583242da6716f9675ae4fc068b583878f3b700f 100644 --- a/provider/partition-gcp/src/test/java/org/opengroup/osdu/partition/provider/gcp/service/PartitionServiceImplTest.java +++ b/provider/partition-gcp/src/test/java/org/opengroup/osdu/partition/provider/gcp/service/PartitionServiceImplTest.java @@ -17,161 +17,185 @@ package org.opengroup.osdu.partition.provider.gcp.service; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; +import org.opengroup.osdu.core.common.cache.ICache; import org.opengroup.osdu.core.common.model.http.AppException; +import org.opengroup.osdu.core.common.provider.interfaces.IKmsClient; import org.opengroup.osdu.partition.logging.AuditLogger; import org.opengroup.osdu.partition.model.PartitionInfo; import org.opengroup.osdu.partition.model.Property; import org.opengroup.osdu.partition.provider.gcp.model.PartitionPropertyEntity; import org.opengroup.osdu.partition.provider.gcp.repository.PartitionPropertyEntityRepository; -@RunWith(MockitoJUnitRunner.class) -public class PartitionServiceImplTest { - - private static final String PARTITION_ID = "newPartition"; - private static final boolean SENSITIVE = false; - private static final String NAME = "new-key"; - private static final String VALUE = "new-value"; - - - @Mock - private PartitionPropertyEntityRepository partitionPropertyEntityRepository; - - @Mock - private AuditLogger auditLogger; - - @InjectMocks - private PartitionServiceImpl partitionServiceImpl; - - private PartitionInfo expectedPartitionInfo; - private PartitionPropertyEntity partitionPropertyEntity; - private Optional<List<PartitionPropertyEntity>> partitionPropertyEntityList; - private Optional<List<PartitionPropertyEntity>> emptyList; - - @Before - public void setup() { - this.expectedPartitionInfo = new PartitionInfo(); - - Property property = new Property(); - property.setSensitive(SENSITIVE); - property.setValue(VALUE); - - Map<String, Property> properties = new HashMap<>(); - properties.put(NAME, property); - - this.expectedPartitionInfo.setProperties(properties); - - partitionPropertyEntity = new PartitionPropertyEntity(); - partitionPropertyEntity.setPartitionId(PARTITION_ID); - partitionPropertyEntity.setName(NAME); - partitionPropertyEntity.setSensitive(SENSITIVE); - partitionPropertyEntity.setValue(VALUE); - - List<PartitionPropertyEntity> entities = new ArrayList<>(); - entities.add(partitionPropertyEntity); - this.partitionPropertyEntityList = Optional.of(entities); - - this.emptyList = Optional.empty(); - } - - @Test - public void should_createPartition_when_partitionDoesNotExist() { - when(this.partitionPropertyEntityRepository.findByPartitionId(PARTITION_ID)) - .thenReturn(this.emptyList, this.partitionPropertyEntityList); - - PartitionInfo actualPartitionInfo = this.partitionServiceImpl - .createPartition(PARTITION_ID, this.expectedPartitionInfo); - - assertEquals(this.expectedPartitionInfo, actualPartitionInfo); - } - - @Test(expected = AppException.class) - public void should_throwAnException_when_createPartitionWhichAlreadyExists() { - when(this.partitionPropertyEntityRepository.findByPartitionId(PARTITION_ID)) - .thenReturn(this.emptyList); - - this.partitionServiceImpl.createPartition(PARTITION_ID, new PartitionInfo()); - } - - @Test - public void should_updatePartition_when_partitionExists() { - when(this.partitionPropertyEntityRepository.findByPartitionId(PARTITION_ID)) - .thenReturn(this.partitionPropertyEntityList); - when(this.partitionPropertyEntityRepository.findByPartitionIdAndName(PARTITION_ID, NAME)) - .thenReturn(null); - - PartitionInfo actualPartitionInfo = this.partitionServiceImpl - .updatePartition(PARTITION_ID, this.expectedPartitionInfo); - - assertEquals(this.expectedPartitionInfo, actualPartitionInfo); - } - - @Test(expected = AppException.class) - public void should_throwAnException_when_updatePartitionWhichDoesNotExist() { - when(this.partitionPropertyEntityRepository.findByPartitionId(PARTITION_ID)) - .thenReturn(this.emptyList); - this.partitionServiceImpl.createPartition(PARTITION_ID, new PartitionInfo()); - } - - @Test - public void should_getPartition_when_partitionExists() { - when(this.partitionPropertyEntityRepository.findByPartitionId(PARTITION_ID)) - .thenReturn(this.partitionPropertyEntityList); - - PartitionInfo actualPartitionInfo = this.partitionServiceImpl.getPartition(PARTITION_ID); - - assertEquals(this.expectedPartitionInfo, actualPartitionInfo); - } - - @Test(expected = AppException.class) - public void should_throwAnException_when_getPartitionWhichDoesNotExist() { - when(this.partitionPropertyEntityRepository.findByPartitionId(PARTITION_ID)) - .thenReturn(this.emptyList); - this.partitionServiceImpl.getPartition(PARTITION_ID); - } - - @Test - public void should_deletePartition_when_partitionExists() { - when(this.partitionPropertyEntityRepository.findByPartitionId(PARTITION_ID)) - .thenReturn(this.partitionPropertyEntityList); - doNothing().when(this.partitionPropertyEntityRepository).deleteByPartitionId(PARTITION_ID); +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; - boolean expected = true; - boolean actual = partitionServiceImpl.deletePartition(PARTITION_ID); +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; - assertEquals(expected, actual); - } +@ExtendWith(MockitoExtension.class) +public class PartitionServiceImplTest { - @Test(expected = AppException.class) - public void should_throwAnException_when_deletePartitionWhichDoesNotExist() { - when(this.partitionPropertyEntityRepository.findByPartitionId(PARTITION_ID)) - .thenReturn(this.emptyList); - this.partitionServiceImpl.deletePartition(PARTITION_ID); - } - - @Test - public void should_getAllPartitions() { - List<String> expectedPartitions = new ArrayList<>(); - expectedPartitions.add(PARTITION_ID); + private static final String PARTITION_ID = "newPartition"; + private static final boolean SENSITIVE = false; + private static final String NAME = "new-key"; + private static final String VALUE = "new-value"; + + @Mock + private ICache<String, PartitionInfo> partitionServiceCache; - when(this.partitionPropertyEntityRepository.getAllPartitions()).thenReturn(expectedPartitions); + @Mock + private ICache<String, List<String>> partitionListCache; - List<String> actualPartitions = this.partitionServiceImpl.getAllPartitions(); + @Mock + private PartitionPropertyEntityRepository partitionPropertyEntityRepository; - assertEquals(expectedPartitions, actualPartitions); - } + @Mock + private AuditLogger auditLogger; + + private PartitionServiceImpl partitionServiceImpl; + + private PartitionInfo expectedPartitionInfo; + private PartitionPropertyEntity partitionPropertyEntity; + private Optional<List<PartitionPropertyEntity>> partitionPropertyEntityList; + private Optional<List<PartitionPropertyEntity>> emptyList; + + @BeforeEach + public void setup() { + partitionServiceImpl = new PartitionServiceImpl( + partitionPropertyEntityRepository, + mock(IKmsClient.class), + auditLogger, + partitionServiceCache, + partitionListCache + ); + + expectedPartitionInfo = new PartitionInfo(); + + Property property = new Property(); + property.setSensitive(SENSITIVE); + property.setValue(VALUE); + + Map<String, Property> properties = new HashMap<>(); + properties.put(NAME, property); + + expectedPartitionInfo.setProperties(properties); + + partitionPropertyEntity = new PartitionPropertyEntity(); + partitionPropertyEntity.setPartitionId(PARTITION_ID); + partitionPropertyEntity.setName(NAME); + partitionPropertyEntity.setSensitive(SENSITIVE); + partitionPropertyEntity.setValue(VALUE); + + List<PartitionPropertyEntity> entities = new ArrayList<>(); + entities.add(partitionPropertyEntity); + partitionPropertyEntityList = Optional.of(entities); + + emptyList = Optional.empty(); + } + + @Test + public void should_createPartition_when_partitionDoesNotExist() { + when(partitionPropertyEntityRepository.findByPartitionId(PARTITION_ID)) + .thenReturn(emptyList, partitionPropertyEntityList); + + PartitionInfo actualPartitionInfo = partitionServiceImpl + .createPartition(PARTITION_ID, expectedPartitionInfo); + + assertEquals(expectedPartitionInfo, actualPartitionInfo); + } + + @Test + public void should_throwAnException_when_createPartitionWhichAlreadyExists() { + assertThrows(AppException.class, () -> { + when(partitionPropertyEntityRepository.findByPartitionId(PARTITION_ID)) + .thenReturn(emptyList); + + partitionServiceImpl.createPartition(PARTITION_ID, new PartitionInfo()); + }); + } + + @Test + public void should_updatePartition_when_partitionExists() { + when(partitionPropertyEntityRepository.findByPartitionId(PARTITION_ID)) + .thenReturn(partitionPropertyEntityList); + when(partitionPropertyEntityRepository.findByPartitionIdAndName(PARTITION_ID, NAME)) + .thenReturn(null); + + PartitionInfo actualPartitionInfo = partitionServiceImpl + .updatePartition(PARTITION_ID, expectedPartitionInfo); + + assertEquals(expectedPartitionInfo, actualPartitionInfo); + } + + @Test + public void should_throwAnException_when_updatePartitionWhichDoesNotExist() { + assertThrows(AppException.class, () -> { + when(partitionPropertyEntityRepository.findByPartitionId(PARTITION_ID)) + .thenReturn(emptyList); + partitionServiceImpl.createPartition(PARTITION_ID, new PartitionInfo()); + }); + } + + @Test + public void should_getPartition_when_partitionExists() { + when(partitionPropertyEntityRepository.findByPartitionId(PARTITION_ID)) + .thenReturn(partitionPropertyEntityList); + + PartitionInfo actualPartitionInfo = partitionServiceImpl.getPartition(PARTITION_ID); + + assertEquals(expectedPartitionInfo, actualPartitionInfo); + } + + @Test + public void should_throwAnException_when_getPartitionWhichDoesNotExist() { + assertThrows(AppException.class, () -> { + when(partitionPropertyEntityRepository.findByPartitionId(PARTITION_ID)) + .thenReturn(emptyList); + partitionServiceImpl.getPartition(PARTITION_ID); + }); + } + + @Test + public void should_deletePartition_when_partitionExists() { + when(partitionPropertyEntityRepository.findByPartitionId(PARTITION_ID)) + .thenReturn(partitionPropertyEntityList); + doNothing().when(partitionPropertyEntityRepository).deleteByPartitionId(PARTITION_ID); + + boolean expected = true; + boolean actual = partitionServiceImpl.deletePartition(PARTITION_ID); + + assertEquals(expected, actual); + } + + @Test + public void should_throwAnException_when_deletePartitionWhichDoesNotExist() { + assertThrows(AppException.class, () -> { + when(partitionPropertyEntityRepository.findByPartitionId(PARTITION_ID)) + .thenReturn(emptyList); + partitionServiceImpl.deletePartition(PARTITION_ID); + }); + } + + @Test + public void should_getAllPartitions() { + List<String> expectedPartitions = new ArrayList<>(); + expectedPartitions.add(PARTITION_ID); + + when(partitionPropertyEntityRepository.getAllPartitions()).thenReturn(expectedPartitions); + + List<String> actualPartitions = partitionServiceImpl.getAllPartitions(); + + assertEquals(expectedPartitions, actualPartitions); + } } \ No newline at end of file diff --git a/provider/partition-ibm/pom.xml b/provider/partition-ibm/pom.xml index a87c998bb8202cb796670ff2dd6a48d3563e8015..08d207fc42619990872e8780525ed5da4437a2d9 100644 --- a/provider/partition-ibm/pom.xml +++ b/provider/partition-ibm/pom.xml @@ -9,7 +9,7 @@ <parent> <artifactId>partition</artifactId> <groupId>org.opengroup.osdu</groupId> - <version>0.12.0</version> + <version>0.13.0-SNAPSHOT</version> <relativePath>../../pom.xml</relativePath> </parent> diff --git a/provider/partition-ibm/src/main/java/org/opengroup/osdu/partition/provider/ibm/cache/PartitionListCacheImpl.java b/provider/partition-ibm/src/main/java/org/opengroup/osdu/partition/provider/ibm/cache/PartitionListCacheImpl.java deleted file mode 100644 index a1dc123275a4dbc9799979fe8a6a559d8c70e721..0000000000000000000000000000000000000000 --- a/provider/partition-ibm/src/main/java/org/opengroup/osdu/partition/provider/ibm/cache/PartitionListCacheImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -/* Licensed Materials - Property of IBM */ -/* (c) Copyright IBM Corp. 2020. All Rights Reserved.*/ - -package org.opengroup.osdu.partition.provider.ibm.cache; - -import java.util.List; - -import javax.annotation.Resource; - -import org.opengroup.osdu.core.common.cache.ICache; -import org.opengroup.osdu.partition.provider.interfaces.IPartitionServiceCache; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; - -@Service -@Qualifier("partitionListCache") -public class PartitionListCacheImpl implements IPartitionServiceCache<String, List<String>> { - - - @Autowired - @Qualifier("partitionListCache") - private ICache<String, List<String>> cache; - - @Override - public void put(String s, List<String> o) { - this.cache.put(s, o); - } - - @Override - public List<String> get(String s) { - return this.cache.get(s); - } - - @Override - public void delete(String s) { - this.cache.delete(s); - } - - @Override - public void clearAll() { - this.cache.clearAll(); - } - -} diff --git a/provider/partition-ibm/src/main/java/org/opengroup/osdu/partition/provider/ibm/cache/PartitionServiceCacheImpl.java b/provider/partition-ibm/src/main/java/org/opengroup/osdu/partition/provider/ibm/cache/PartitionServiceCacheImpl.java deleted file mode 100644 index 4afd7cd1f50890924930fb762b179603ec017274..0000000000000000000000000000000000000000 --- a/provider/partition-ibm/src/main/java/org/opengroup/osdu/partition/provider/ibm/cache/PartitionServiceCacheImpl.java +++ /dev/null @@ -1,42 +0,0 @@ -/* Licensed Materials - Property of IBM */ -/* (c) Copyright IBM Corp. 2020. All Rights Reserved.*/ - -package org.opengroup.osdu.partition.provider.ibm.cache; - -import org.opengroup.osdu.core.common.cache.ICache; -import org.opengroup.osdu.partition.model.PartitionInfo; -import org.opengroup.osdu.partition.provider.interfaces.IPartitionServiceCache; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; - -@Service -@Qualifier("partitionServiceCache") -public class PartitionServiceCacheImpl implements IPartitionServiceCache<String, PartitionInfo> { - - @Autowired - @Qualifier("partitionServiceCache") - private ICache<String, PartitionInfo> cache; - - @Override - public void put(String s, PartitionInfo o) { - this.cache.put(s, o); - } - - @Override - public PartitionInfo get(String s) { - return this.cache.get(s); - } - - @Override - public void delete(String s) { - this.cache.delete(s); - } - - @Override - public void clearAll() { - this.cache.clearAll(); - } -} diff --git a/provider/partition-ibm/src/main/java/org/opengroup/osdu/partition/provider/ibm/security/AuthorizationService.java b/provider/partition-ibm/src/main/java/org/opengroup/osdu/partition/provider/ibm/security/AuthorizationService.java index bf7676e5c993ab512a30c204b10690d0a1084981..e25b142ffb5059ed1ccbdf278b78ab35dc98939f 100644 --- a/provider/partition-ibm/src/main/java/org/opengroup/osdu/partition/provider/ibm/security/AuthorizationService.java +++ b/provider/partition-ibm/src/main/java/org/opengroup/osdu/partition/provider/ibm/security/AuthorizationService.java @@ -4,7 +4,9 @@ package org.opengroup.osdu.partition.provider.ibm.security; import org.opengroup.osdu.core.common.model.http.AppException; +import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.partition.provider.interfaces.IAuthorizationService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.security.core.Authentication; @@ -20,6 +22,9 @@ import lombok.extern.slf4j.Slf4j; @Slf4j public class AuthorizationService implements IAuthorizationService { + @Autowired + DpsHeaders dpsheaders; + @Value("${service.partition.admin.user}") String partitionAdminUser; @@ -27,20 +32,15 @@ public class AuthorizationService implements IAuthorizationService { @Override public boolean isDomainAdminServiceAccount() { try { - final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); - Jwt principal = (Jwt) authentication.getPrincipal(); - String memberEmail = principal.getClaimAsString("email"); -// @SuppressWarnings("unchecked") -// KeycloakPrincipal<KeycloakSecurityContext> principal = (KeycloakPrincipal<KeycloakSecurityContext>) auth.getPrincipal(); -// String upn = principal.getName(); - log.debug("email : "+memberEmail); - if(memberEmail.equals(partitionAdminUser)) { + + String userId = dpsheaders.getUserId(); + log.debug("logged in email : " + userId); + if(userId != null && partitionAdminUser != null && userId.equals(partitionAdminUser)) { return true; - } - else { + } else { throw AppException.createUnauthorized("Unauthorized. The user is not Service Principal"); } - + } catch (AppException e) { throw e; diff --git a/provider/partition-ibm/src/main/java/org/opengroup/osdu/partition/provider/ibm/security/SecurityConfig.java b/provider/partition-ibm/src/main/java/org/opengroup/osdu/partition/provider/ibm/security/SecurityConfig.java index 0c899dfb1fe95325ce2c9669b2f3e9cec17165f5..54218f3ce3acf56c3432ef517c4b5816c234b17e 100644 --- a/provider/partition-ibm/src/main/java/org/opengroup/osdu/partition/provider/ibm/security/SecurityConfig.java +++ b/provider/partition-ibm/src/main/java/org/opengroup/osdu/partition/provider/ibm/security/SecurityConfig.java @@ -15,8 +15,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http.httpBasic().disable() - .csrf().disable().authorizeRequests().anyRequest() - .authenticated().and().oauth2ResourceServer().jwt(); + .csrf().disable(); + //.authorizeRequests().anyRequest() + //.authenticated().and().oauth2ResourceServer().jwt(); } } diff --git a/provider/partition-ibm/src/main/java/org/opengroup/osdu/partition/provider/ibm/service/PartitionServiceImpl.java b/provider/partition-ibm/src/main/java/org/opengroup/osdu/partition/provider/ibm/service/PartitionServiceImpl.java index 247f48402ae97a50d6e1c5379e0541d0c848d7bf..5545607a0024126c444548fcc4bb4cffd394f23a 100644 --- a/provider/partition-ibm/src/main/java/org/opengroup/osdu/partition/provider/ibm/service/PartitionServiceImpl.java +++ b/provider/partition-ibm/src/main/java/org/opengroup/osdu/partition/provider/ibm/service/PartitionServiceImpl.java @@ -3,13 +3,13 @@ package org.opengroup.osdu.partition.provider.ibm.service; -import java.io.IOException; -import java.net.MalformedURLException; -import java.util.List; - -import javax.annotation.PostConstruct; - +import com.cloudant.client.api.Database; +import com.cloudant.client.api.model.Response; +import com.cloudant.client.org.lightcouch.DocumentConflictException; +import com.cloudant.client.org.lightcouch.NoDocumentException; +import lombok.extern.slf4j.Slf4j; import org.apache.http.HttpStatus; +import org.opengroup.osdu.core.common.cache.ICache; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.core.ibm.auth.ServiceCredentials; @@ -18,25 +18,33 @@ import org.opengroup.osdu.partition.model.PartitionInfo; import org.opengroup.osdu.partition.provider.ibm.model.PartitionDoc; import org.opengroup.osdu.partition.provider.interfaces.IPartitionService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; -import com.cloudant.client.api.Database; -import com.cloudant.client.api.model.Response; -import com.cloudant.client.org.lightcouch.DocumentConflictException; -import com.cloudant.client.org.lightcouch.NoDocumentException; - -import lombok.extern.slf4j.Slf4j; +import javax.annotation.PostConstruct; +import java.io.IOException; +import java.net.MalformedURLException; +import java.util.List; @Service @Slf4j public class PartitionServiceImpl implements IPartitionService { private static final String PARTITION_DATABASE = "partition"; + private static final String PARTITION_LIST_KEY = "getAllPartitions"; @Autowired private JaxRsDpsLog logger; + @Autowired + @Qualifier("partitionServiceCache") + private ICache<String, PartitionInfo> partitionServiceCache; + + @Autowired + @Qualifier("partitionListCache") + private ICache<String, List<String>> partitionListCache; + Database db; private IBMCloudantClientFactory cloudantFactory; @@ -69,10 +77,15 @@ public class PartitionServiceImpl implements IPartitionService { @Override public PartitionInfo createPartition(String partitionId, PartitionInfo partitionInfo) { + if (partitionServiceCache.get(partitionId) != null) { + throw new AppException(HttpStatus.SC_CONFLICT, "partition exist", "Partition with same id exist"); + } + + PartitionInfo pi; PartitionDoc partitionDoc = new PartitionDoc(partitionId, partitionInfo); try { db.save(partitionDoc); - return partitionInfo; + pi = partitionInfo; } catch (DocumentConflictException e) { log.error("Partition already exists"); throw new AppException(e.getStatusCode(), "Conflict", "partition already exists", e); @@ -81,11 +94,18 @@ public class PartitionServiceImpl implements IPartitionService { e.printStackTrace(); throw new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR, e.getMessage(), "Partition creation failed", e); } - + + if (pi != null) { + partitionServiceCache.put(partitionId, pi); + partitionListCache.clearAll(); + } + + return pi; } @Override public PartitionInfo updatePartition(String partitionId, PartitionInfo partitionInfo) { + PartitionInfo pi; if (partitionInfo.getProperties().containsKey("id")) { throw new AppException(HttpStatus.SC_BAD_REQUEST, "can not update id", "the field id can not be updated"); } @@ -93,7 +113,7 @@ public class PartitionServiceImpl implements IPartitionService { PartitionDoc partitionDoc = db.find(PartitionDoc.class, partitionId); partitionDoc.getPartitionInfo().getProperties().putAll(partitionInfo.getProperties()); Response update = db.update(partitionDoc); - return partitionDoc.getPartitionInfo(); + pi = partitionDoc.getPartitionInfo(); } catch (NoDocumentException e) { log.error(String.format("%s partition does not exists", partitionId)); e.printStackTrace(); @@ -110,23 +130,38 @@ public class PartitionServiceImpl implements IPartitionService { throw new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR, "Partition update failed", e.getMessage(), e); } + if(pi != null) { + partitionServiceCache.put(partitionId, pi); + } + + return pi; } @Override public PartitionInfo getPartition(String partitionId) { - PartitionDoc partitionDoc = null; - try { - partitionDoc = db.find(PartitionDoc.class, partitionId); - } catch (NoDocumentException e) { - log.error(String.format("%s partition does not exists", partitionId)); - e.printStackTrace(); - throw new AppException(e.getStatusCode(), e.getReason(), String.format("%s partition does not exists", partitionId), e); - } catch (Exception e) { - log.error("Partition could not found"); - e.printStackTrace(); - throw new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR, "unknown error", "Partition could not found", e ); + PartitionInfo pi = partitionServiceCache.get(partitionId); + + if (pi == null) { + PartitionDoc partitionDoc = null; + try { + partitionDoc = db.find(PartitionDoc.class, partitionId); + } catch (NoDocumentException e) { + log.error(String.format("%s partition does not exists", partitionId)); + e.printStackTrace(); + throw new AppException(e.getStatusCode(), e.getReason(), String.format("%s partition does not exists", partitionId), e); + } catch (Exception e) { + log.error("Partition could not found"); + e.printStackTrace(); + throw new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR, "unknown error", "Partition could not found", e ); + } + pi = partitionDoc.getPartitionInfo(); + + if (pi != null) { + partitionServiceCache.put(partitionId, pi); + } } - return partitionDoc.getPartitionInfo(); + + return pi; } @Override @@ -143,26 +178,38 @@ public class PartitionServiceImpl implements IPartitionService { log.error("Deletion Failed. Unexpected error"); e.printStackTrace(); } + if(deleteStatus.getStatusCode() == 200) { + if (partitionServiceCache.get(partitionId) != null) { + partitionServiceCache.delete(partitionId); + } + partitionListCache.clearAll(); return true; - } + } + return false; - } @Override public List<String> getAllPartitions() { - List<String> partitionList = null; - try { - partitionList = db.getAllDocsRequestBuilder().includeDocs(true).build().getResponse().getDocIds(); - } catch (IOException e) { - log.error("Partitions could not found. IOException occurred", e); - e.printStackTrace(); - } catch (Exception e) { - log.error("Partition could not found.", e); - e.printStackTrace(); + List<String> partitions = partitionListCache.get(PARTITION_LIST_KEY); + + if (partitions == null) { + try { + partitions = db.getAllDocsRequestBuilder().includeDocs(true).build().getResponse().getDocIds(); + } catch (IOException e) { + log.error("Partitions could not found. IOException occurred", e); + e.printStackTrace(); + } catch (Exception e) { + log.error("Partition could not found.", e); + e.printStackTrace(); + } + + if (partitions != null) { + partitionListCache.put(PARTITION_LIST_KEY, partitions); + } } - return partitionList; + return partitions; } } diff --git a/provider/partition-reference/README.md b/provider/partition-reference/README.md index 262136fc0217dfbd176ce7b190695c3ea1e57549..0342cbde4d1bad595e691df66338c9c00424bf98 100644 --- a/provider/partition-reference/README.md +++ b/provider/partition-reference/README.md @@ -26,9 +26,9 @@ In order to run the service locally or remotely, you will need to have the follo | `GOOGLE_APPLICATION_CREDENTIALS` | ex `/path/to/directory/service-key.json` | Service account credentials, you only need this if running locally | yes | https://console.cloud.google.com/iam-admin/serviceaccounts | | `KEY_RING` | ex `csqp` | A key ring holds keys in a specific Google Cloud location and permit us to manage access control on groups of keys | yes | https://cloud.google.com/kms/docs/resource-hierarchy#key_rings | | `KMS_KEY` | ex `partitionService` | A key exists on one key ring linked to a specific location. | yes | https://cloud.google.com/kms/docs/resource-hierarchy#key_rings | -| `MONGO_DB_URL` | ex `mongodb://localhost:27017` | Mongo DB Url| yes | output of infrastructure deployment | +| `MONGO_DB_URL` | ex `localhost:27017` | Mongo DB Url| yes | output of infrastructure deployment | | `MONGO_DB_USER` | ex `mongouser` | Mongo DB userName| yes | output of infrastructure deployment | -| `MONGO_DB_PASSWORD` | ex `mongopassword` | Mongo DB userPassword| yes | output of infrastructure deployment | +| `MONGO_DB_PASSWORD` | ex `mongopassword` | Mongo DB userPassword. If password contains `@` symbols, it must be encoded to URL-encoded format. | yes | output of infrastructure deployment | | `MONGO_DB_NAME` | ex `mongoDBName` | Mongo DB DbName| yes | output of infrastructure deployment | ### Run Locally diff --git a/provider/partition-reference/pom.xml b/provider/partition-reference/pom.xml index 4196bc14b9024f0db36c31374c5b432eff3f6602..4688b95e5828afeaac8f196108108122d2f56b05 100644 --- a/provider/partition-reference/pom.xml +++ b/provider/partition-reference/pom.xml @@ -1,20 +1,18 @@ <?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.opengroup.osdu</groupId> <artifactId>partition</artifactId> - <version>0.12.0</version> + <version>0.13.0-SNAPSHOT</version> <relativePath>../../pom.xml</relativePath> </parent> <groupId>org.opengroup.osdu</groupId> <artifactId>partition-reference</artifactId> <description>Partition service on Hybrid Cloud</description> - <version>0.12.0</version> + <version>0.13.0-SNAPSHOT</version> <packaging>jar</packaging> <dependencies> diff --git a/provider/partition-reference/src/main/java/org/opengroup/osdu/partition/provider/reference/cache/PartitionListCacheImpl.java b/provider/partition-reference/src/main/java/org/opengroup/osdu/partition/provider/reference/cache/PartitionListCacheImpl.java deleted file mode 100644 index 83853f6c938857db57bdd0881e623e05be0f6259..0000000000000000000000000000000000000000 --- a/provider/partition-reference/src/main/java/org/opengroup/osdu/partition/provider/reference/cache/PartitionListCacheImpl.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - Copyright 2002-2021 Google LLC - Copyright 2002-2021 EPAM Systems, 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. - */ - -package org.opengroup.osdu.partition.provider.reference.cache; - -import java.util.List; -import lombok.RequiredArgsConstructor; -import org.opengroup.osdu.core.common.cache.ICache; -import org.opengroup.osdu.partition.provider.interfaces.IPartitionServiceCache; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; - -@Service -@Qualifier("partitionListCache") -@RequiredArgsConstructor -public class PartitionListCacheImpl implements IPartitionServiceCache<String, List<String>> { - - private final ICache<String, List<String>> cache; - - @Override - public void put(String s, List<String> o) { - this.cache.put(s, o); - } - - @Override - public List<String> get(String s) { - return this.cache.get(s); - } - - @Override - public void delete(String s) { - this.cache.delete(s); - } - - @Override - public void clearAll() { - this.cache.clearAll(); - } -} diff --git a/provider/partition-reference/src/main/java/org/opengroup/osdu/partition/provider/reference/cache/PartitionServiceCacheImpl.java b/provider/partition-reference/src/main/java/org/opengroup/osdu/partition/provider/reference/cache/PartitionServiceCacheImpl.java deleted file mode 100644 index 55a0c33ead57b2f6668c23b45790025932937b22..0000000000000000000000000000000000000000 --- a/provider/partition-reference/src/main/java/org/opengroup/osdu/partition/provider/reference/cache/PartitionServiceCacheImpl.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - Copyright 2002-2021 Google LLC - Copyright 2002-2021 EPAM Systems, 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. - */ -package org.opengroup.osdu.partition.provider.reference.cache; - -import lombok.RequiredArgsConstructor; -import org.opengroup.osdu.core.common.cache.ICache; -import org.opengroup.osdu.partition.model.PartitionInfo; -import org.opengroup.osdu.partition.provider.interfaces.IPartitionServiceCache; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; - -@Service -@Qualifier("partitionServiceCache") -@RequiredArgsConstructor -public class PartitionServiceCacheImpl implements IPartitionServiceCache<String, PartitionInfo> { - - private final ICache<String, PartitionInfo> cache; - - @Override - public void put(String s, PartitionInfo o) { - this.cache.put(s, o); - } - - @Override - public PartitionInfo get(String s) { - return this.cache.get(s); - } - - @Override - public void delete(String s) { - this.cache.delete(s); - } - - @Override - public void clearAll() { - this.cache.clearAll(); - } -} diff --git a/provider/partition-reference/src/main/java/org/opengroup/osdu/partition/provider/reference/service/PartitionServiceImpl.java b/provider/partition-reference/src/main/java/org/opengroup/osdu/partition/provider/reference/service/PartitionServiceImpl.java index 32bf72832d9d711e5e1ada19bb4432c070fc79d1..0757dae4d0402531ad1e5a8f0dcb9d082a8a32bc 100644 --- a/provider/partition-reference/src/main/java/org/opengroup/osdu/partition/provider/reference/service/PartitionServiceImpl.java +++ b/provider/partition-reference/src/main/java/org/opengroup/osdu/partition/provider/reference/service/PartitionServiceImpl.java @@ -17,11 +17,9 @@ package org.opengroup.osdu.partition.provider.reference.service; -import java.util.Collections; -import java.util.List; -import java.util.Optional; import lombok.RequiredArgsConstructor; import org.apache.http.HttpStatus; +import org.opengroup.osdu.core.common.cache.ICache; import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.core.common.provider.interfaces.IKmsClient; import org.opengroup.osdu.partition.logging.AuditLogger; @@ -31,28 +29,48 @@ import org.opengroup.osdu.partition.provider.interfaces.IPartitionService; import org.opengroup.osdu.partition.provider.reference.repository.PartitionPropertyEntityRepository; import org.springframework.stereotype.Service; +import java.util.Collections; +import java.util.List; +import java.util.Optional; + @Service @RequiredArgsConstructor public class PartitionServiceImpl implements IPartitionService { private static final String UNKNOWN_ERROR_REASON = "unknown error"; + private static final String PARTITION_LIST_KEY = "getAllPartitions"; + private final PartitionPropertyEntityRepository partitionPropertyEntityRepository; private final IKmsClient kmsClient; private final AuditLogger auditLogger; + private final ICache<String, PartitionInfo> partitionServiceCache; + + private final ICache<String, List<String>> partitionListCache; + @Override public PartitionInfo createPartition(String partitionId, PartitionInfo partitionInfo) { + if (partitionServiceCache.get(partitionId) != null) + throw new AppException(HttpStatus.SC_CONFLICT, "partition exist", "Partition with same id exist"); + if (partitionPropertyEntityRepository.findByPartitionId(partitionId).isPresent()) { throw new AppException(HttpStatus.SC_CONFLICT, UNKNOWN_ERROR_REASON, - "Partition already exists."); + "Partition already exists."); } partitionInfo.getProperties() - .forEach((key, property) -> encryptPartitionPropertyEntityIfNeeded(property)); + .forEach((key, property) -> encryptPartitionPropertyEntityIfNeeded(property)); partitionPropertyEntityRepository.createPartition(partitionId, partitionInfo); - return getPartition(partitionId); + PartitionInfo pi = getPartition(partitionId); + + if (pi != null) { + partitionServiceCache.put(partitionId, pi); + partitionListCache.clearAll(); + } + + return pi; } @Override @@ -60,16 +78,16 @@ public class PartitionServiceImpl implements IPartitionService { if (partitionInfo.getProperties().containsKey("id")) { this.auditLogger.updatePartitionSecretFailure(Collections.singletonList(partitionId)); throw new AppException(HttpStatus.SC_BAD_REQUEST, "can not update id", - "the field id can not be updated"); + "the field id can not be updated"); } if (!partitionPropertyEntityRepository.findByPartitionId(partitionId).isPresent()) { this.auditLogger.updatePartitionSecretFailure(Collections.singletonList(partitionId)); throw new AppException(HttpStatus.SC_NOT_FOUND, UNKNOWN_ERROR_REASON, - "An attempt to update not existing partition."); + "An attempt to update not existing partition."); } partitionInfo.getProperties().forEach((key, value) -> { Optional<Property> property = this.partitionPropertyEntityRepository - .findByPartitionIdAndName(partitionId, key); + .findByPartitionIdAndName(partitionId, key); if (property.isPresent()) { property.get().setSensitive(value.isSensitive()); property.get().setValue(value.getValue()); @@ -78,19 +96,31 @@ public class PartitionServiceImpl implements IPartitionService { encryptPartitionPropertyEntityIfNeeded(value); }); partitionPropertyEntityRepository.updatePartition(partitionId, partitionInfo); - return getPartition(partitionId); + PartitionInfo pi = getPartition(partitionId); + + if(pi != null) { + partitionServiceCache.put(partitionId, pi); + } + + return pi; } @Override public PartitionInfo getPartition(String partitionId) { - Optional<PartitionInfo> result = partitionPropertyEntityRepository.findByPartitionId( - partitionId); - if (result.isPresent()) { + PartitionInfo pi = (PartitionInfo) partitionServiceCache.get(partitionId); + + if (pi == null) { + Optional<PartitionInfo> result = partitionPropertyEntityRepository.findByPartitionId( + partitionId); + if (!result.isPresent()) { + throw new AppException(HttpStatus.SC_NOT_FOUND, UNKNOWN_ERROR_REASON, "Partition does not exist."); + } result.get().getProperties() .forEach((key, property) -> decryptPartitionPropertyIfNeeded(property)); - return result.get(); + pi = result.get(); + partitionServiceCache.put(partitionId, pi); } - return new PartitionInfo(); + return pi; } @Override @@ -98,14 +128,31 @@ public class PartitionServiceImpl implements IPartitionService { if (!partitionPropertyEntityRepository.findByPartitionId(partitionId).isPresent()) { this.auditLogger.deletePartitionFailure(Collections.singletonList(partitionId)); throw new AppException(HttpStatus.SC_NOT_FOUND, UNKNOWN_ERROR_REASON, - "An attempt to delete not existing partition."); + "An attempt to delete not existing partition."); } - return partitionPropertyEntityRepository.isDeletedPartitionInfoByPartitionId(partitionId); + if (partitionPropertyEntityRepository.isDeletedPartitionInfoByPartitionId(partitionId)) { + if (partitionServiceCache.get(partitionId) != null) { + partitionServiceCache.delete(partitionId); + } + partitionListCache.clearAll(); + return true; + } + + return false; } @Override public List<String> getAllPartitions() { - return partitionPropertyEntityRepository.getAllPartitions(); + List<String> partitions = (List<String>)partitionListCache.get(PARTITION_LIST_KEY); + + if (partitions == null) { + partitions = partitionPropertyEntityRepository.getAllPartitions(); + + if (partitions != null) { + partitionListCache.put(PARTITION_LIST_KEY, partitions); + } + } + return partitions; } private void encryptPartitionPropertyEntityIfNeeded(Property property) { diff --git a/testing/partition-test-aws/pom.xml b/testing/partition-test-aws/pom.xml index 53980b674bbe118059aa89fe86e1c4d26fbe1e63..0518140eaae2bd10052d5944414db47dcf9b5691 100644 --- a/testing/partition-test-aws/pom.xml +++ b/testing/partition-test-aws/pom.xml @@ -19,14 +19,14 @@ <parent> <groupId>org.opengroup.osdu</groupId> <artifactId>os-partition-testing</artifactId> - <version>0.12.0</version> + <version>0.13.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> <modelVersion>4.0.0</modelVersion> <groupId>org.opengroup.osdu.partition</groupId> <artifactId>partition-test-aws</artifactId> - <version>0.12.0</version> + <version>0.13.0-SNAPSHOT</version> <packaging>jar</packaging> <properties> @@ -65,7 +65,7 @@ <dependency> <groupId>org.opengroup.osdu.partition</groupId> <artifactId>partition-test-core</artifactId> - <version>0.12.0</version> + <version>0.13.0-SNAPSHOT</version> </dependency> <dependency> diff --git a/testing/partition-test-azure/pom.xml b/testing/partition-test-azure/pom.xml index 14e3b6a0502d7c020dd7eb11805d67ae373844c6..b3ba3ba5558f837853c73b9fb4e1e788b2704e68 100644 --- a/testing/partition-test-azure/pom.xml +++ b/testing/partition-test-azure/pom.xml @@ -20,13 +20,13 @@ <parent> <groupId>org.opengroup.osdu</groupId> <artifactId>os-partition-testing</artifactId> - <version>0.12.0</version> + <version>0.13.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> <groupId>org.opengroup.osdu.partition</groupId> <artifactId>partition-test-azure</artifactId> - <version>0.12.0</version> + <version>0.13.0-SNAPSHOT</version> <packaging>jar</packaging> <properties> @@ -65,7 +65,7 @@ <dependency> <groupId>org.opengroup.osdu.partition</groupId> <artifactId>partition-test-core</artifactId> - <version>0.12.0</version> + <version>0.13.0-SNAPSHOT</version> </dependency> <dependency> diff --git a/testing/partition-test-core/pom.xml b/testing/partition-test-core/pom.xml index 8dd907e001b9fc0814505bc93635e95b27c54b1b..bf641599bd58159e73e78849b3d322a3d51c8c60 100644 --- a/testing/partition-test-core/pom.xml +++ b/testing/partition-test-core/pom.xml @@ -20,13 +20,13 @@ <parent> <groupId>org.opengroup.osdu</groupId> <artifactId>os-partition-testing</artifactId> - <version>0.12.0</version> + <version>0.13.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> <groupId>org.opengroup.osdu.partition</groupId> <artifactId>partition-test-core</artifactId> - <version>0.12.0</version> + <version>0.13.0-SNAPSHOT</version> <packaging>jar</packaging> <properties> diff --git a/testing/partition-test-gcp/pom.xml b/testing/partition-test-gcp/pom.xml index 710604c4a30957f4ece87e3a29a0170a1b004402..988d947b2e42b939244f20f002911b6f524afad6 100644 --- a/testing/partition-test-gcp/pom.xml +++ b/testing/partition-test-gcp/pom.xml @@ -6,13 +6,13 @@ <parent> <groupId>org.opengroup.osdu</groupId> <artifactId>os-partition-testing</artifactId> - <version>0.12.0</version> + <version>0.13.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> <groupId>org.opengroup.osdu.partition</groupId> <artifactId>partition-test-gcp</artifactId> - <version>0.12.0</version> + <version>0.13.0-SNAPSHOT</version> <packaging>jar</packaging> <properties> @@ -57,7 +57,7 @@ <dependency> <groupId>org.opengroup.osdu.partition</groupId> <artifactId>partition-test-core</artifactId> - <version>0.12.0</version> + <version>0.13.0-SNAPSHOT</version> </dependency> <dependency> diff --git a/testing/partition-test-ibm/pom.xml b/testing/partition-test-ibm/pom.xml index 7c25abec400537e85bafccdf8e402c918b08625a..6dd9b8cd8884d3b44fd663382b16784f83f86aa1 100644 --- a/testing/partition-test-ibm/pom.xml +++ b/testing/partition-test-ibm/pom.xml @@ -6,13 +6,13 @@ <parent> <groupId>org.opengroup.osdu</groupId> <artifactId>os-partition-testing</artifactId> - <version>0.12.0</version> + <version>0.13.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> <groupId>org.opengroup.osdu.partition</groupId> <artifactId>partition-test-ibm</artifactId> - <version>0.12.0</version> + <version>0.13.0-SNAPSHOT</version> <packaging>jar</packaging> <properties> @@ -58,7 +58,7 @@ <dependency> <groupId>org.opengroup.osdu.partition</groupId> <artifactId>partition-test-core</artifactId> - <version>0.12.0</version> + <version>0.13.0-SNAPSHOT</version> </dependency> <dependency> diff --git a/testing/partition-test-ibm/src/test/java/org/opengroup/osdu/partition/api/TestCreatePartition.java b/testing/partition-test-ibm/src/test/java/org/opengroup/osdu/partition/api/TestCreatePartition.java index 38292e7425ba84e9d228a990449b4226627f9a88..9f4b9f109f8047261c31659d57b31caef99ec150 100644 --- a/testing/partition-test-ibm/src/test/java/org/opengroup/osdu/partition/api/TestCreatePartition.java +++ b/testing/partition-test-ibm/src/test/java/org/opengroup/osdu/partition/api/TestCreatePartition.java @@ -3,10 +3,14 @@ package org.opengroup.osdu.partition.api; +import static org.junit.Assert.assertEquals; + import org.junit.After; import org.junit.Before; import org.opengroup.osdu.partition.util.IBMTestUtils; +import com.sun.jersey.api.client.ClientResponse; + public class TestCreatePartition extends CreatePartitionTest { @Before @@ -20,6 +24,14 @@ public class TestCreatePartition extends CreatePartitionTest { public void tearDown() { this.testUtils = null; } - + //servicemesh changes response code - 403 + @Override + public void should_return401_when_makingHttpRequestWithoutToken() throws Exception { + ClientResponse response = descriptor.run(getId(), ""); + assertEquals(error(response.getEntity(String.class)), 403, response.getStatus()); + } + + + } diff --git a/testing/partition-test-ibm/src/test/java/org/opengroup/osdu/partition/api/TestDeletePartition.java b/testing/partition-test-ibm/src/test/java/org/opengroup/osdu/partition/api/TestDeletePartition.java index 3edcc15fda767afe3868569aac23cc1f56655471..26ce98ab6936589f2ad9cbc7c845f2c6fd306dab 100644 --- a/testing/partition-test-ibm/src/test/java/org/opengroup/osdu/partition/api/TestDeletePartition.java +++ b/testing/partition-test-ibm/src/test/java/org/opengroup/osdu/partition/api/TestDeletePartition.java @@ -3,10 +3,14 @@ package org.opengroup.osdu.partition.api; +import static org.junit.Assert.assertEquals; + import org.junit.After; import org.junit.Before; import org.opengroup.osdu.partition.util.IBMTestUtils; +import com.sun.jersey.api.client.ClientResponse; + public class TestDeletePartition extends DeletePartitionTest { @Before @@ -20,5 +24,12 @@ public class TestDeletePartition extends DeletePartitionTest { public void tearDown() { this.testUtils = null; } + + //servicemesh changes response code - 403 + @Override + public void should_return401_when_makingHttpRequestWithoutToken() throws Exception { + ClientResponse response = descriptor.run(getId(), ""); + assertEquals(error(response.getEntity(String.class)), 403, response.getStatus()); + } } diff --git a/testing/partition-test-ibm/src/test/java/org/opengroup/osdu/partition/api/TestGetPartitionById.java b/testing/partition-test-ibm/src/test/java/org/opengroup/osdu/partition/api/TestGetPartitionById.java index dd9247dcf7e06cae89911fee0cfea91660fea2e7..3faed4d5a76df67796d683358fa4696b219a5021 100644 --- a/testing/partition-test-ibm/src/test/java/org/opengroup/osdu/partition/api/TestGetPartitionById.java +++ b/testing/partition-test-ibm/src/test/java/org/opengroup/osdu/partition/api/TestGetPartitionById.java @@ -25,5 +25,12 @@ public class TestGetPartitionById extends GetPartitionByIdApitTest { public void tearDown() { this.testUtils = null; } + + //servicemesh changes response code - 403 + @Override + public void should_return401_when_makingHttpRequestWithoutToken() throws Exception { + ClientResponse response = descriptor.run(getId(), ""); + assertEquals(error(response.getEntity(String.class)), 403, response.getStatus()); + } } diff --git a/testing/partition-test-ibm/src/test/java/org/opengroup/osdu/partition/api/TestListPartitions.java b/testing/partition-test-ibm/src/test/java/org/opengroup/osdu/partition/api/TestListPartitions.java index 7f325d538abefa7ab4ad3286306a2ab265f11d8b..826354c7ad8a5c0c4d0069ddd3cd0634329bd855 100644 --- a/testing/partition-test-ibm/src/test/java/org/opengroup/osdu/partition/api/TestListPartitions.java +++ b/testing/partition-test-ibm/src/test/java/org/opengroup/osdu/partition/api/TestListPartitions.java @@ -3,10 +3,14 @@ package org.opengroup.osdu.partition.api; +import static org.junit.Assert.assertEquals; + import org.junit.After; import org.junit.Before; import org.opengroup.osdu.partition.util.IBMTestUtils; +import com.sun.jersey.api.client.ClientResponse; + public class TestListPartitions extends ListPartitionsApitTest { @Before @@ -20,5 +24,13 @@ public class TestListPartitions extends ListPartitionsApitTest { public void tearDown() { this.testUtils = null; } + + //servicemesh changes response code - 403 + @Override + public void should_return401_when_makingHttpRequestWithoutToken() throws Exception { + ClientResponse response = descriptor.run(getId(), ""); + assertEquals(error(response.getEntity(String.class)), 403, response.getStatus()); + } + } diff --git a/testing/partition-test-ibm/src/test/java/org/opengroup/osdu/partition/api/TestUpdatePartition.java b/testing/partition-test-ibm/src/test/java/org/opengroup/osdu/partition/api/TestUpdatePartition.java index 62bc2289bea5153a55384479787c005859ff90b6..159e17965384d734fa3de7695b29c224c5efdde9 100644 --- a/testing/partition-test-ibm/src/test/java/org/opengroup/osdu/partition/api/TestUpdatePartition.java +++ b/testing/partition-test-ibm/src/test/java/org/opengroup/osdu/partition/api/TestUpdatePartition.java @@ -25,5 +25,13 @@ public class TestUpdatePartition extends UpdatePartitionTest { public void tearDown() { this.testUtils = null; } + + //servicemesh changes response code - 403 + @Override + public void should_return401_when_makingHttpRequestWithoutToken() throws Exception { + ClientResponse response = descriptor.run(getId(), ""); + assertEquals(error(response.getEntity(String.class)), 403, response.getStatus()); + } + } diff --git a/testing/pom.xml b/testing/pom.xml index 024e64fc3a6e3b67ce27dc3d87c52351b0b775d7..c9e882298e072041063f5737fe4a2fbbcbdcb12a 100644 --- a/testing/pom.xml +++ b/testing/pom.xml @@ -18,7 +18,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.opengroup.osdu</groupId> <artifactId>os-partition-testing</artifactId> - <version>0.12.0</version> + <version>0.13.0-SNAPSHOT</version> <description>Root partition test project</description> <packaging>pom</packaging>