Commit a8d3caab authored by Abhishek Patil's avatar Abhishek Patil Committed by Kishore Battula
Browse files

Dependency Management & Azure SDK Upgrade

parent 630292fe
......@@ -9,6 +9,13 @@ The following software have components provided under the terms of this license:
- Android SDK (from https://www.android.com/)
========================================================================
Apache-1.1
========================================================================
The following software have components provided under the terms of this license:
- StAX (from http://stax.codehaus.org/)
========================================================================
Apache-2.0
========================================================================
......@@ -203,16 +210,13 @@ The following software have components provided under the terms of this license:
- AWS SDK for Java - Core (from https://aws.amazon.com/sdkforjava)
- AWS SDK for Java - Models (from https://aws.amazon.com/sdkforjava)
- Adapter: RxJava (from )
- Apache Commons BeanUtils (from http://commons.apache.org/proper/commons-beanutils/)
- Apache Commons Codec (from http://commons.apache.org/proper/commons-codec/)
- Apache Commons Collections (from http://commons.apache.org/proper/commons-collections/)
- Apache Commons Lang (from http://commons.apache.org/proper/commons-lang/)
- Apache Commons Logging (from http://commons.apache.org/proper/commons-logging/)
- Apache Commons Logging (from http://commons.apache.org/proper/commons-logging/)
- Apache Commons Text (from http://commons.apache.org/proper/commons-text/)
- Apache Commons Validator (from http://commons.apache.org/proper/commons-validator/)
- Apache HttpAsyncClient (from http://hc.apache.org/httpcomponents-asyncclient)
- Apache HttpClient (from http://hc.apache.org/httpcomponents-client)
- Apache HttpClient Cache (from http://hc.apache.org/httpcomponents-client)
- Apache HttpCore (from http://hc.apache.org/httpcomponents-core-ga)
- Apache HttpCore NIO (from http://hc.apache.org/httpcomponents-core-ga)
- Apache Log4j API (from )
......@@ -224,14 +228,14 @@ The following software have components provided under the terms of this license:
- Asynchronous Http Client (from )
- Asynchronous Http Client Netty Utils (from )
- AutoValue Annotations (from )
- Azure AD Spring Security Integration Spring Boot Starter (from https://github.com/Microsoft/azure-spring-boot)
- Azure Metrics Spring Boot Starter (from https://github.com/Microsoft/azure-spring-boot)
- Bean Validation API (from http://beanvalidation.org)
- Byte Buddy (without dependencies) (from )
- Byte Buddy Java agent (from )
- ClassMate (from http://github.com/cowtowncoder/java-classmate)
- Cloud Storage JSON API v1-rev58-1.21.0 (from )
- CloudWatch Metrics for AWS Java SDK (from https://aws.amazon.com/sdkforjava)
- Commons Digester (from http://commons.apache.org/digester/)
- Commons IO (from http://commons.apache.org/io/)
- Converter: Jackson (from )
- Elastic JNA Distribution (from https://github.com/java-native-access/jna)
- Elasticsearch: 5.0.0-alpha5 (from https://github.com/elastic/elasticsearch)
......@@ -258,6 +262,7 @@ The following software have components provided under the terms of this license:
- Hibernate Validator Engine (from )
- Hibernate Validator Engine (from )
- Identity and Access Management (IAM) API v1-rev247-1.23.0 (from )
- IntelliJ IDEA Annotations (from http://www.jetbrains.org)
- J2ObjC Annotations (from https://github.com/google/j2objc/)
- JBoss Logging 3 (from http://www.jboss.org)
- JCIP Annotations under Apache License (from http://stephenc.github.com/jcip-annotations)
......@@ -268,24 +273,37 @@ The following software have components provided under the terms of this license:
- JSONassert (from https://github.com/skyscreamer/JSONassert)
- Jackson 2 extensions to the Google HTTP Client Library for Java. (from https://github.com/google/google-http-java-client.git/google-http-client-jackson2)
- Jackson dataformat: CBOR (from http://github.com/FasterXML/jackson-dataformats-binary)
- Jackson dataformat: CBOR (from http://github.com/FasterXML/jackson-dataformats-binary)
- Jackson datatype: JSR310 (from http://wiki.fasterxml.com/JacksonModuleJSR310)
- Jackson datatype: JSR310 (from http://wiki.fasterxml.com/JacksonModuleJSR310)
- Jackson-annotations (from http://github.com/FasterXML/jackson)
- Jackson-annotations (from http://github.com/FasterXML/jackson)
- Jackson-core (from https://github.com/FasterXML/jackson-core)
- Jackson-core (from https://github.com/FasterXML/jackson-core)
- Jackson-dataformat-Smile (from http://github.com/FasterXML/jackson-dataformat-smile)
- Jackson-dataformat-XML (from http://wiki.fasterxml.com/JacksonExtensionXmlDataBinding)
- Jackson-dataformat-YAML (from https://github.com/FasterXML/jackson)
- Jackson-dataformat-YAML (from https://github.com/FasterXML/jackson)
- Jackson-datatype-Joda (from http://wiki.fasterxml.com/JacksonModuleJoda)
- Jackson-datatype-jdk8 (from )
- Jackson-datatype-jdk8 (from )
- Jackson-module-Afterburner (from http://wiki.fasterxml.com/JacksonHome)
- Jackson-module-JAXB-annotations (from http://wiki.fasterxml.com/JacksonJAXBAnnotations)
- Jackson-module-parameter-names (from )
- Jackson-module-parameter-names (from )
- Jakarta Bean Validation API (from https://beanvalidation.org)
- 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)
- Java UUID Generator (from http://wiki.fasterxml.com/JugHome)
- Javassist (from http://www.javassist.org/)
- Joda-Time (from http://www.joda.org/joda-time/)
- Json Path (from https://github.com/jayway/JsonPath)
- KeePassJava2 :: All (from https://repo1.maven.org/maven2/org/linguafranca/pwdb/KeePassJava2)
- KeePassJava2 :: DOM (from https://repo1.maven.org/maven2/org/linguafranca/pwdb/KeePassJava2-dom)
- KeePassJava2 :: JAXB (from https://repo1.maven.org/maven2/org/linguafranca/pwdb/KeePassJava2-jaxb)
- 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)
- Lucene Common Analyzers (from )
- Lucene Core (from )
- Lucene Grouping (from )
......@@ -308,23 +326,30 @@ 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)
- Microsoft Azure Netty HTTP Client Library (from https://github.com/Azure/azure-sdk-for-java)
- Mockito (from http://www.mockito.org)
- Microsoft Azure SDK for SQL API of Azure Cosmos DB Service (from https://github.com/Azure/azure-sdk-for-java)
- Mockito (from http://mockito.org)
- Mockito (from http://www.mockito.org)
- Netty Reactive Streams Implementation (from )
- Netty/Buffer (from http://netty.io/)
- Netty/Buffer (from http://netty.io/)
- Netty/Codec (from )
- Netty/Codec (from )
- Netty/Codec/DNS (from )
- Netty/Codec/HTTP (from )
- Netty/Codec/HTTP (from )
- Netty/Codec/HTTP2 (from )
- Netty/Codec/Socks (from )
- Netty/Common (from )
- Netty/Common (from )
- Netty/Handler (from )
- Netty/Handler (from )
- Netty/Handler/Proxy (from )
- Netty/Resolver (from )
- Netty/Resolver/DNS (from )
- Netty/Resolver (from )
- Netty/TomcatNative [BoringSSL - Static] (from )
- Netty/Transport (from http://netty.io/)
- Netty/Transport (from http://netty.io/)
- Netty/Transport/Native/Unix/Common (from )
- Nimbus Content Type (from https://bitbucket.org/connect2id/nimbus-content-type)
- Nimbus JOSE+JWT (from https://bitbucket.org/connect2id/nimbus-jose-jwt)
- Nimbus LangTag (from https://bitbucket.org/connect2id/nimbus-language-tags)
- Non-Blocking Reactive Foundation for the JVM (from https://github.com/reactor/reactor)
......@@ -339,9 +364,11 @@ The following software have components provided under the terms of this license:
- 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)
- PWDB :: Database (from https://repo1.maven.org/maven2/org/linguafranca/pwdb/database)
- Protocol Buffer extensions to the Google HTTP Client Library for Java. (from )
- Reactive Streams Netty driver (from https://github.com/reactor/reactor-netty)
- Retrofit (from )
- Simple XML (from http://simple.sourceforge.net)
- 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)
......@@ -366,15 +393,20 @@ The following software have components provided under the terms of this license:
- Spring Commons Logging Bridge (from https://github.com/spring-projects/spring-framework)
- Spring Context (from https://github.com/spring-projects/spring-framework)
- Spring Core (from https://github.com/spring-projects/spring-framework)
- Spring Data Core (from )
- Spring Expression Language (SpEL) (from https://github.com/spring-projects/spring-framework)
- Spring Plugin - Core (from )
- Spring Plugin - Metadata Extension (from )
- Spring TestContext Framework (from https://github.com/spring-projects/spring-framework)
- Spring Transaction (from https://github.com/spring-projects/spring-framework)
- Spring Web (from https://github.com/spring-projects/spring-framework)
- Spring Web MVC (from https://github.com/spring-projects/spring-framework)
- StAX (from http://stax.codehaus.org/)
- StAX API (from http://stax.codehaus.org/)
- T-Digest (from https://github.com/tdunning/t-digest)
- TypeTools (from http://github.com/jhalterman/typetools/)
- Woodstox (from https://github.com/FasterXML/woodstox)
- aalto-xml (from )
- aggs-matrix-stats (from https://github.com/elastic/elasticsearch)
- cli (from https://github.com/elastic/elasticsearch)
- com.google.api.grpc:grpc-google-cloud-pubsub-v1 (from https://github.com/googleapis/googleapis)
......@@ -382,7 +414,6 @@ The following software have components provided under the terms of this license:
- com.google.api.grpc:proto-google-cloud-pubsub-v1 (from https://github.com/googleapis/googleapis)
- com.google.api.grpc:proto-google-common-protos (from https://github.com/googleapis/googleapis)
- com.google.api.grpc:proto-google-iam-v1 (from https://github.com/googleapis/googleapis)
- commons-collections (from )
- compiler (from http://github.com/spullara/mustache.java)
- datastore-v1-proto-client (from )
- elasticsearch-core (from https://github.com/elastic/elasticsearch)
......@@ -400,6 +431,8 @@ The following software have components provided under the terms of this license:
- io.grpc:grpc-stub (from https://github.com/grpc/grpc-java)
- ion-java (from https://github.com/amznlabs/ion-java/)
- jackson-databind (from http://github.com/FasterXML/jackson)
- jackson-databind (from http://github.com/FasterXML/jackson)
- javatuples (from http://www.javatuples.org)
- javax.inject (from http://code.google.com/p/atinject/)
- jose4j (from https://bitbucket.org/b_c/jose4j/)
- lang-mustache (from https://github.com/elastic/elasticsearch)
......@@ -416,7 +449,6 @@ The following software have components provided under the terms of this license:
- rest (from https://github.com/elastic/elasticsearch)
- rest-high-level (from https://github.com/elastic/elasticsearch)
- rxjava (from https://github.com/ReactiveX/RxJava)
- rxjava (from https://github.com/ReactiveX/RxJava)
- secure-sm (from https://github.com/elastic/elasticsearch)
- spring-security-config (from http://spring.io/spring-security)
- spring-security-core (from http://spring.io/spring-security)
......@@ -449,6 +481,7 @@ The following software have components provided under the terms of this license:
- Hamcrest Core (from http://hamcrest.org/)
- HdrHistogram (from http://hdrhistogram.github.io/HdrHistogram/)
- Lucene Common Analyzers (from )
- StAX (from http://stax.codehaus.org/)
- Stax2 API (from http://github.com/FasterXML/stax2-api)
- ThreeTen backport (from https://www.threeten.org/threetenbp)
......@@ -480,6 +513,7 @@ The following software have components provided under the terms of this license:
- Mockito (from http://www.mockito.org)
- NanoHttpd-Core (from )
- Netty/Codec/HTTP (from )
- Netty/Codec/HTTP (from )
- Protocol Buffer Java API (from https://developers.google.com/protocol-buffers/)
- Protocol Buffers [Util] (from )
- Reflections (from http://github.com/ronmamo/reflections)
......@@ -600,6 +634,7 @@ GPL-3.0-only
========================================================================
The following software have components provided under the terms of this license:
- Project Lombok (from https://projectlombok.org)
- Project Lombok (from https://projectlombok.org)
- jakarta.annotation-api (from https://projects.eclipse.org/projects/ee4j.ca)
......@@ -657,7 +692,6 @@ The following software have components provided under the terms of this license:
- Azure Java Client Runtime for AutoRest (from https://github.com/Azure/autorest-clientruntime-for-java)
- Azure Metrics Spring Boot Starter (from https://github.com/Microsoft/azure-spring-boot)
- Azure Spring Boot AutoConfigure (from https://github.com/Microsoft/azure-spring-boot)
- Azure Spring Boot Starter (from https://github.com/Microsoft/azure-spring-boot)
- Checker Qual (from https://checkerframework.org)
- Checker Qual (from https://checkerframework.org)
- Cucumber Expressions (from https://github.com/cucumber/cucumber-expressions-java)
......@@ -691,17 +725,24 @@ The following software have components provided under the terms of this license:
- Microsoft Azure client library for Identity (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)
- Microsoft Azure internal Avro module for Storage (from https://github.com/Azure/azure-sdk-for-java)
- Mockito (from http://www.mockito.org)
- Mockito (from http://mockito.org)
- Netty/Codec/HTTP (from )
- Netty/Codec/HTTP (from )
- Netty/Common (from )
- Netty/Common (from )
- Project Lombok (from https://projectlombok.org)
- Project Lombok (from https://projectlombok.org)
- SLF4J API Module (from http://www.slf4j.org)
- Spongy Castle (from http://rtyley.github.io/spongycastle/)
- 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)
- micrometer-core (from https://github.com/micrometer-metrics/micrometer)
- mockito-inline (from https://github.com/mockito/mockito)
- 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)
- spring-security-core (from http://spring.io/spring-security)
========================================================================
......@@ -735,6 +776,7 @@ The following software have components provided under the terms of this license:
- AOP alliance (from http://aopalliance.sourceforge.net)
- HdrHistogram (from http://hdrhistogram.github.io/HdrHistogram/)
- LatencyUtils (from http://latencyutils.github.io/LatencyUtils/)
- Spongy Castle (from http://rtyley.github.io/spongycastle/)
========================================================================
SPL-1.0
......@@ -767,7 +809,9 @@ The following software have components provided under the terms of this license:
- Microsoft Azure SDK for SQL API of Azure Cosmos DB Service (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)
- Project Lombok (from https://projectlombok.org)
- Project Lombok (from https://projectlombok.org)
- Spring Web (from https://github.com/spring-projects/spring-framework)
- msal4j (from https://github.com/AzureAD/microsoft-authentication-library-for-java)
- reactive-streams (from http://www.reactive-streams.org/)
========================================================================
......@@ -780,6 +824,7 @@ The following software have components provided under the terms of this license:
- JUnit Jupiter (Aggregator) (from https://junit.org/junit5/)
- JavaBeans Activation Framework API jar (from )
- JavaMail API (from )
- Spongy Castle (from http://rtyley.github.io/spongycastle/)
- jakarta.xml.bind-api (from )
- org.junit.jupiter:junit-jupiter-api (from http://junit.org/junit5/)
- org.junit.jupiter:junit-jupiter-engine (from http://junit.org/junit5/)
......
......@@ -30,23 +30,55 @@
<description>Azure related implementation staff.</description>
<packaging>jar</packaging>
<properties>
<osdu.corelibazure.version>0.0.40</osdu.corelibazure.version>
<osdu.oscorecommon.version>0.3.12</osdu.oscorecommon.version>
<osdu.os-schema-core.version>0.0.1</osdu.os-schema-core.version>
<mockito.version>1.10.19</mockito.version>
<cucumber.version>5.4.0</cucumber.version>
</properties>
<dependencyManagement>
<dependencies>
<!-- Inherit managed dependencies from core-lib-azure -->
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>core-lib-azure</artifactId>
<version>${osdu.corelibazure.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-active-directory-spring-boot-starter</artifactId>
<version>2.1.7</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>core-lib-azure</artifactId>
<version>0.0.23</version>
<version>${osdu.corelibazure.version}</version>
</dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>${osdu.oscorecommon.version}</version>
</dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-schema-core</artifactId>
<version>0.0.1</version>
<version>${osdu.os-schema-core.version}</version>
</dependency>
<dependency>
......@@ -64,28 +96,28 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java8</artifactId>
<version>5.4.0</version>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>5.4.0</version>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-guice</artifactId>
<version>5.4.0</version>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
......@@ -95,7 +127,6 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.2.3.RELEASE</version>
</dependency>
</dependencies>
......
......@@ -14,6 +14,12 @@
package org.opengroup.osdu.schema.azure.di;
import com.azure.cosmos.CosmosClient;
import com.azure.cosmos.CosmosClientBuilder;
import com.azure.identity.DefaultAzureCredential;
import com.azure.storage.blob.BlobServiceClient;
import com.azure.storage.blob.BlobServiceClientBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
......@@ -87,4 +93,21 @@ public class AzureBootstrapConfig {
return secretValue;
}
@Bean
public CosmosClient buildCosmosClient(SecretClient kv)
{
return new CosmosClientBuilder().endpoint(cosmosEndpoint(kv)).key(cosmosKey(kv)).buildClient();
}
@Autowired
private DefaultAzureCredential defaultAzureCredential;
@Bean
public BlobServiceClient buildBlobServiceClient()
{
String blobEndpoint = String.format("https://%s.blob.core.windows.net", storageAccount);
return new BlobServiceClientBuilder().endpoint(blobEndpoint).credential(defaultAzureCredential).buildClient();
}
}
\ No newline at end of file
package org.opengroup.osdu.schema.azure.di;
import com.azure.storage.blob.BlobServiceClient;
import org.opengroup.osdu.azure.blobstorage.IBlobServiceClientFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
@Component
@Primary
public class SinglePartitionBlobServiceClientFactory implements IBlobServiceClientFactory {
@Autowired
BlobServiceClient blobServiceClient;
@Override
public BlobServiceClient getBlobServiceClient(String s) {
return blobServiceClient;
}
}
package org.opengroup.osdu.schema.azure.di;
import com.azure.cosmos.CosmosClient;
import org.opengroup.osdu.azure.cosmosdb.ICosmosClientFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
@Component
@Primary
public class SinglePartitionCosmosClientFactory implements ICosmosClientFactory {
@Autowired
CosmosClient cosmosClient;
@Override
public CosmosClient getClient(final String s) {
return cosmosClient;
}
}
......@@ -18,7 +18,7 @@ import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.schema.constants.SchemaConstants;
import org.opengroup.osdu.azure.CosmosStore;
import org.opengroup.osdu.azure.cosmosdb.CosmosStore;
import org.opengroup.osdu.schema.azure.definitions.AuthorityDoc;
import org.opengroup.osdu.schema.exceptions.ApplicationException;
import org.opengroup.osdu.schema.exceptions.BadRequestException;
......@@ -84,7 +84,7 @@ public class AzureAuthorityStore implements IAuthorityStore {
try {
AuthorityDoc authorityDoc = new AuthorityDoc(id, headers.getPartitionId(), authority);
cosmosStore.createItem(headers.getPartitionId(), cosmosDBName, authorityContainer, authorityDoc);
cosmosStore.createItem(headers.getPartitionId(), cosmosDBName, authorityContainer, headers.getPartitionId(), authorityDoc);
} catch (AppException ex) {
if (ex.getError().getCode() == 409) {
log.warning(SchemaConstants.AUTHORITY_EXISTS_ALREADY_REGISTERED);
......
......@@ -15,7 +15,7 @@
package org.opengroup.osdu.schema.azure.impl.schemainfostore;
import java.text.MessageFormat;
import org.opengroup.osdu.azure.CosmosStore;
import org.opengroup.osdu.azure.cosmosdb.CosmosStore;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
......@@ -86,7 +86,7 @@ public class AzureEntityTypeStore implements IEntityTypeStore {
try {
EntityTypeDoc entityTypeDoc = new EntityTypeDoc(id, headers.getPartitionId(), entityType);
cosmosStore.createItem(headers.getPartitionId(), cosmosDBName, entityTypeContainer, entityTypeDoc);
cosmosStore.createItem(headers.getPartitionId(), cosmosDBName, entityTypeContainer, headers.getPartitionId(), entityTypeDoc);
} catch (AppException ex) {
if (ex.getError().getCode() == 409) {
log.warning(SchemaConstants.ENTITY_TYPE_EXISTS);
......
......@@ -19,9 +19,11 @@ import java.util.*;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import com.azure.cosmos.*;
import com.azure.cosmos.models.SqlQuerySpec;
import com.azure.cosmos.models.SqlParameter;
import com.azure.cosmos.models.CosmosQueryRequestOptions;
import com.google.gson.Gson;
import org.opengroup.osdu.azure.CosmosStore;
import org.opengroup.osdu.azure.cosmosdb.CosmosStore;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
......@@ -104,7 +106,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore {
FlattenedSchemaInfo flattenedSchemaInfo = populateSchemaInfo(schema);
SchemaInfoDoc schemaInfoDoc = new SchemaInfoDoc(id, headers.getPartitionId(), flattenedSchemaInfo);
try {
cosmosStore.createItem(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, schemaInfoDoc);
cosmosStore.createItem(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, headers.getPartitionId(), schemaInfoDoc);
} catch (AppException ex) {
if (ex.getError().getCode() == 409) {
log.warning(SchemaConstants.SCHEMA_ID_EXISTS);
......@@ -133,7 +135,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore {
FlattenedSchemaInfo flattenedSchemaInfo = populateSchemaInfo(schema);
SchemaInfoDoc schemaInfoDoc = new SchemaInfoDoc(id, headers.getPartitionId(), flattenedSchemaInfo);
try {
cosmosStore.upsertItem(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, schemaInfoDoc);
cosmosStore.upsertItem(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, headers.getPartitionId(), schemaInfoDoc);
} catch (Exception ex) {
log.error(MessageFormat.format(SchemaConstants.OBJECT_INVALID, ex.getMessage()));
throw new ApplicationException(SchemaConstants.SCHEMA_CREATION_FAILED_INVALID_OBJECT);
......@@ -173,15 +175,14 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore {
" AND c.flattenedSchemaInfo.source = @source" +
" AND c.flattenedSchemaInfo.entityType = @entityType" +
" AND c.flattenedSchemaInfo.majorVersion = @majorVersion");
SqlParameterList pars = query.getParameters();
pars.add(new SqlParameter("@partitionId", headers.getPartitionId()));
pars.add(new SqlParameter("@authority", schemaInfo.getSchemaIdentity().getAuthority()));
pars.add(new SqlParameter("@source", schemaInfo.getSchemaIdentity().getSource()));
pars.add(new SqlParameter("@entityType", schemaInfo.getSchemaIdentity().getEntityType()));
pars.add(new SqlParameter("@majorVersion", schemaInfo.getSchemaIdentity().getSchemaVersionMajor()));
FeedOptions options = new FeedOptions();
options.setEnableCrossPartitionQuery(false);
List<SqlParameter> sqlParameterList = query.getParameters();
sqlParameterList.add(new SqlParameter("@partitionId", headers.getPartitionId()));
sqlParameterList.add(new SqlParameter("@authority", schemaInfo.getSchemaIdentity().getAuthority()));
sqlParameterList.add(new SqlParameter("@source", schemaInfo.getSchemaIdentity().getSource()));
sqlParameterList.add(new SqlParameter("@entityType", schemaInfo.getSchemaIdentity().getEntityType()));
sqlParameterList.add(new SqlParameter("@majorVersion", schemaInfo.getSchemaIdentity().getSchemaVersionMajor()));
CosmosQueryRequestOptions options = new CosmosQueryRequestOptions();
List<SchemaInfoDoc> schemaInfoList = cosmosStore.queryItems(headers.getPartitionId(), cosmosDBName,schemaInfoContainer, query, options, SchemaInfoDoc.class);
TreeMap<Long, String> sortedMap = new TreeMap<>(Collections.reverseOrder());
......@@ -301,14 +302,12 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore {
}
SqlQuerySpec query = new SqlQuerySpec(queryText);
SqlParameterList pars = query.getParameters();
for (String param : parameterMap.keySet())
{
pars.add(new SqlParameter(param, parameterMap.get(param)));
query.getParameters().add(new SqlParameter(param, parameterMap.get(param)));
}
FeedOptions options = new FeedOptions();
options.setEnableCrossPartitionQuery(false);
CosmosQueryRequestOptions options = new CosmosQueryRequestOptions();
List<SchemaInfoDoc> schemaInfoList = cosmosStore.queryItems(headers.getPartitionId(), cosmosDBName,schemaInfoContainer, query, options, SchemaInfoDoc.class);
List<SchemaInfo> schemaList = new LinkedList<>();
......@@ -330,6 +329,9 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore {
tenantList.add(SchemaConstants.ACCOUNT_ID_COMMON_PROJECT);
tenantList.add(tenantId);
/* TODO : Below code enables uniqueness check across tenants and is redundant now. This will be handled/updated as part
of data partition changes.
*/
if (tenantId.equalsIgnoreCase(SchemaConstants.ACCOUNT_ID_COMMON_PROJECT)) {
List<String> privateTenantList = tenantFactory.listTenantInfo().stream().map(TenantInfo::getName)
.collect(Collectors.toList());
......
......@@ -15,7 +15,7 @@
package org.opengroup.osdu.schema.azure.impl.schemainfostore;
import java.text.MessageFormat;
import org.opengroup.osdu.azure.CosmosStore;
import org.opengroup.osdu.azure.cosmosdb.CosmosStore;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.http.AppException;
......@@ -83,7 +83,7 @@ public class AzureSourceStore implements ISourceStore {
try {
SourceDoc sourceDoc = new SourceDoc(id, headers.getPartitionId(), source);
cosmosStore.createItem(headers.getPartitionId(), cosmosDBName, sourceContainer, sourceDoc);
cosmosStore.createItem(headers.getPartitionId(), cosmosDBName, sourceContainer, headers.getPartitionId(), sourceDoc);
} catch (AppException ex) {
if (ex.getError().getCode() == 409) {
log.warning(SchemaConstants.SOURCE_EXISTS);
......
......@@ -18,6 +18,8 @@ server.servlet.context-path=/api/schema-service/v1
AUTHORIZE_API=${entitlements_service_endpoint}
AUTHORIZE_API_KEY=${entitlements_service_api_key}
azure.activedirectory.app-resource-id=${aad_client_id}
# Azure AD configuration
azure.activedirectory.client-id=${aad_client_id}
azure.activedirectory.AppIdUri=api://${azure.activedirectory.client-id}
......@@ -47,3 +49,8 @@ server.port=${server.port}
#logging configuration
logging.transaction.enabled=true
logging.slf4jlogger.enabled=true
#TenantFactory Configuration
tenantFactoryImpl.required=true
azure.blobStore.required=true
......@@ -31,7 +31,7 @@ import org.opengroup.osdu.schema.exceptions.ApplicationException;
import org.opengroup.osdu.schema.exceptions.BadRequestException;
import org.opengroup.osdu.schema.exceptions.NotFoundException;
import org.opengroup.osdu.schema.model.Authority;
import org.opengroup.osdu.azure.CosmosStore;
import org.opengroup.osdu.azure.cosmosdb.CosmosStore;
import java.io.IOException;
import java.util.Optional;
......@@ -112,7 +112,7 @@ public class AzureAuthorityStoreTest {
@Test
public void testCreateAuthority() throws ApplicationException, BadRequestException {
doNothing().when(cosmosStore).createItem(eq(dataPartitionId), any(), any(), any());
doNothing().when(cosmosStore).createItem(eq(dataPartitionId), any(), any(), any(), any());