Commit d820cf34 authored by harshit aggarwal's avatar harshit aggarwal
Browse files

Addressing PR comments

parent 8a689b6f
Pipeline #4430 passed with stages
in 12 minutes and 30 seconds
......@@ -34,12 +34,6 @@ This project uses [Lombok](https://projectlombok.org/) for code generation. You
- [Intellij configuration](https://projectlombok.org/setup/intellij)
- [VSCode configuration](https://projectlombok.org/setup/vscode)
### Environment Variables
In order to run the service locally, you will need to have the following environment variables defined.
**System Environment required to run service**
Refer to [application.properties](./src/main/resources/application.properties)
### Configure Maven
......@@ -70,6 +64,39 @@ $ cat ~/.m2/settings.xml
</settings>
```
### Environment Variables
In order to run the service locally, you will need to have the following environment variables defined.
**System Environment required to run service**
Refer to [application.properties](./src/main/resources/application.properties)
Definitions for some variables used
| name | value | description | sensitive? | source |
| --- | --- | --- | --- | --- |
| `LOG_PREFIX` | `storage` | Logging prefix | no | - |
| `server.servlet.contextPath` | `/api/storage/v2/` | Servlet context path | no | - |
| `AUTHORIZE_API` | ex `https://foo-entitlements.azurewebsites.net` | Entitlements API endpoint | no | output of infrastructure deployment |
| `AUTHORIZE_API_KEY` | `********` | The API key clients will need to use when calling the entitlements | yes | -- |
| `azure.application-insights.instrumentation-key` | `********` | API Key for App Insights | yes | output of infrastructure deployment |
| `azure.activedirectory.client-id` | `********` | AAD client application ID | yes | output of infrastructure deployment |
| `azure.activedirectory.AppIdUri` | `api://${azure.activedirectory.client-id}` | URI for AAD Application | no | -- |
| `azure.activedirectory.session-stateless` | `true` | Flag run in stateless mode (needed by AAD dependency) | no | -- |
| `cosmosdb_account` | ex `devintosdur2cosmosacct` | Cosmos account name | no | output of infrastructure deployment |
| `cosmosdb_key` | `********` | Key for CosmosDB | yes | output of infrastructure deployments |
| `cosmosdb_database` | ex `dev-osdu-r2-db` | Cosmos database for storage documents | no | output of infrastructure deployment |
| `azure.storage.account-name` | ex `foo-storage-account` | Storage account for storing documents | no | output of infrastructure deployment |
| `azure.storage.enable-https` | `true` | Used by spring boot starter library | no | - |
| `servicebus_topic_name` | `recordstopic` | Topic for async messaging | no | output of infrastructure deployment |
| `servicebus_namespace_name` | ex `foo-sb-namespace` | Namespace for async messaging | no | output of infrastructure deployment |
| `KEYVAULT_URI` | ex `https://foo-keyvault.vault.azure.net/` | URI of KeyVault that holds application secrets | no | output of infrastructure deployment |
| `AZURE_CLIENT_ID` | `********` | Identity to run the service locally. This enables access to Azure resources. You only need this if running locally | yes | keyvault secret: `$KEYVAULT_URI/secrets/app-dev-sp-username` |
| `AZURE_TENANT_ID` | `********` | AD tenant to authenticate users from | yes | keyvault secret: `$KEYVAULT_URI/secrets/app-dev-sp-tenant-id` |
| `AZURE_CLIENT_SECRET` | `********` | Secret for `$AZURE_CLIENT_ID` | yes | keyvault secret: `$KEYVAULT_URI/secrets/app-dev-sp-password` |
### Build and run the application
After configuring your environment as specified above, you can follow these steps to build and run the application. These steps should be invoked from the *repository root*.
```bash
......
......@@ -43,11 +43,31 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-jose</artifactId>
......@@ -55,11 +75,12 @@
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>core-lib-azure</artifactId>
<version>0.0.11</version>
<version>0.0.12</version>
</dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>0.3.4</version>
</dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
......@@ -75,7 +96,6 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--
Override the spring-boot version of these dependencies to the ones
required by the azure-core library. This needs to be done for each
......@@ -143,37 +163,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-webapp-maven-plugin</artifactId>
<version>1.7.0</version>
<configuration>
<schemaVersion>V2</schemaVersion>
<authentication>
<serverId>azure-auth</serverId>
</authentication>
<subscriptionId>${azure.appservice.subscription}</subscriptionId>
<resourceGroup>${azure.appservice.resourcegroup}</resourceGroup>
<appServicePlanName>${azure.appservice.plan}</appServicePlanName>
<appName>${azure.appservice.appname}</appName>
<appSettings>
<property>
<name>JAVA_OPTS</name>
<value>-Dserver.port=80</value>
</property>
</appSettings>
<deployment>
<resources>
<resource>
<directory>${project.basedir}/target</directory>
<includes>
<include>*spring-boot.jar</include>
</includes>
</resource>
</resources>
</deployment>
</configuration>
</plugin>
</plugins>
</build>
</project>
......@@ -20,7 +20,7 @@ import com.azure.cosmos.SqlParameterList;
import com.azure.cosmos.SqlQuerySpec;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.register.action.model.Action;
import org.opengroup.osdu.register.action.persistence.IActionRepo;
import org.opengroup.osdu.register.provider.interfaces.action.IActionRepo;
import org.opengroup.osdu.azure.CosmosStore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
......
......@@ -23,7 +23,7 @@ import org.opengroup.osdu.azure.CosmosStore;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.register.ddms.model.Ddms;
import org.opengroup.osdu.register.ddms.model.RegisteredInterface;
import org.opengroup.osdu.register.ddms.persistence.IDdmsRepository;
import org.opengroup.osdu.register.provider.interfaces.ddms.IDdmsRepository;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
......
......@@ -9,7 +9,7 @@ import org.opengroup.osdu.azure.CosmosStore;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.register.subscriber.model.*;
import org.opengroup.osdu.register.subscriber.persistence.ISubscriptionRepository;
import org.opengroup.osdu.register.provider.interfaces.subscriber.ISubscriptionRepository;
import org.opengroup.osdu.register.utils.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
......@@ -37,24 +37,24 @@ public class SubscriptionRepository implements ISubscriptionRepository {
// TODO Validate if is there any upper limit required for maximum number of subscriptions for a tenant
if(exists(input.getId())){
throw new AppException(409, "Conflict", "A subscriber already exists with the same topic and endpoint combination");
}
if(exists(input.getId())){
throw new AppException(409, "Conflict", "A subscriber already exists with the same topic and endpoint combination");
}
// TODO Encryption required before storing the secret or Do we need Keyvault to know the secrets
// TODO Encryption required before storing the secret or Do we need Keyvault to know the secrets
SubscriptionDoc doc = new SubscriptionDoc(input, headers.getPartitionId());
cosmosStore.upsertItem(headers.getPartitionId(), cosmosDBName, subscriptionContainer, doc);
SubscriptionDoc doc = new SubscriptionDoc(input, headers.getPartitionId());
cosmosStore.upsertItem(headers.getPartitionId(), cosmosDBName, subscriptionContainer, doc);
try{
// TODO Add the flow to create subscription to the given topic
try{
// TODO Add the flow to create subscription to the given topic
return input;
}
catch (Exception e){
cosmosStore.deleteItem(headers.getPartitionId(), cosmosDBName, subscriptionContainer, input.getId(), headers.getPartitionId());
throw new AppException(500, "Server Error", "Unexpected error creating subscription", e);
}
return input;
}
catch (Exception e){
cosmosStore.deleteItem(headers.getPartitionId(), cosmosDBName, subscriptionContainer, input.getId(), headers.getPartitionId());
throw new AppException(500, "Server Error", "Unexpected error creating subscription", e);
}
}
@Override
......
......@@ -38,4 +38,8 @@ spring.application.name=register-azure
# Cosmosdb container name
registerAction.container.name=RegisterAction
registerDdms.container.name=RegisterDdms
registerSubscription.container.name=RegisterSubscription
\ No newline at end of file
registerSubscription.container.name=RegisterSubscription
#logging configuration
logging.transaction.enabled=true
logging.slf4jlogger.enabled=true
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment