From c780c081666e2119905996246c1e54611c4eb6e4 Mon Sep 17 00:00:00 2001
From: Bill Wang <wanzhiji@amazon.com>
Date: Wed, 5 May 2021 15:54:47 +0000
Subject: [PATCH] Add (Storage) Partition Support

commit 72ce2b9b
Author: zhijie wang <wanzhiji@amazon.com>
Date: Tue May 04 2021 13:47:08 GMT-0500 (Central Daylight Time)

    proper path


commit 9deece71
Author: zhijie wang <wanzhiji@amazon.com>
Date: Tue May 04 2021 13:17:23 GMT-0500 (Central Daylight Time)

    add more properties


commit 11d678f3
Author: zhijie wang <wanzhiji@amazon.com>
Date: Tue May 04 2021 13:12:47 GMT-0500 (Central Daylight Time)

    add more properties


commit 4ad4cd50
Author: zhijie wang <wanzhiji@amazon.com>
Date: Tue May 04 2021 12:49:43 GMT-0500 (Central Daylight Time)

    resolve conflicting beans


commit 991d6d3f
Author: zhijie wang <wanzhiji@amazon.com>
Date: Mon May 03 2021 12:30:44 GMT-0500 (Central Daylight Time)

    update pom


commit ea0280de
Author: zhijie wang <wanzhiji@amazon.com>
Date: Mon May 03 2021 11:38:59 GMT-0500 (Central Daylight Time)

    supress maven transport progress in test


commit 3c5f6fe9
Author: zhijie wang <wanzhiji@amazon.com>
Date: Sat May 01 2021 13:06:50 GMT-0500 (Central Daylight Time)

    update tests


commit 7e86f5f5
Author: zhijie wang <wanzhiji@amazon.com>
Date: Thu Apr 29 2021 12:28:05 GMT-0500 (Central Daylight Time)

    Merge branch 'dev' of codecommit::us-east-1://osdu-dev@os-notification into dev


commit 9538c071
Author: Bill Wang <wanzhiji@amazon.com>
Date: Mon Jan 04 2021 16:27:35 GMT-0600 (Central Standard Time)

    Squashed commit of the following

commit 04e49a0d
Author: zhijie wang <wanzhiji@amazon.com>
Date: Mon Dec 28 2020 19:10:30 GMT-0800 (Pacific Standard Time)

    fix Cognito region services


commit fca15a32
Author: zhijie wang <wanzhiji@amazon.com>
Date: Mon Dec 28 2020 13:56:14 GMT-0800 (Pacific Standard Time)

commit eaf5dcc4
Author: zhijie wang <wanzhiji@amazon.com>
Date: Mon Dec 28 2020 13:35:25 GMT-0800 (Pacific Standard Time)

    fix cognito client


commit 9ceee335
Author: zhijie wang <wanzhiji@amazon.com>
Date: Mon Dec 28 2020 13:20:15 GMT-0800 (Pacific Standard Time)

    bump core service version


commit 30d44fe4
Author: zhijie wang <wanzhiji@amazon.com>
Date: Mon Dec 21 2020 15:03:10 GMT-0800 (Pacific Standard Time)

    fix pom version



commit d5afc1b8
Author: wanzhiji <wanzhiji@amazon.com>
Date: Tue Dec 22 2020 10:29:39 GMT-0600 (Central Standard Time)

    Squashed commit of the following

commit 30d44fe4
Author: zhijie wang <wanzhiji@amazon.com>
Date: Mon Dec 21 2020 15:03:10 GMT-0800 (Pacific Standard Time)

    fix pom version
---
 provider/notification-aws/pom.xml             |   2 +-
 .../impl/AwsPubsubRequestBodyExtractor.java   |   2 +-
 .../impl/ServiceAccountJwtAwsClientImpl.java  | 113 ------------------
 .../provider/aws/utils/AwsCognitoClient.java  |   2 -
 .../src/main/resources/application.properties |  12 +-
 .../AwsPubsubRequestBodyExtractorTest.java    |   3 -
 .../build-aws/prepare-dist.sh                 |   6 +-
 7 files changed, 10 insertions(+), 130 deletions(-)
 delete mode 100644 provider/notification-aws/src/main/java/org/opengroup/osdu/notification/provider/aws/impl/ServiceAccountJwtAwsClientImpl.java

diff --git a/provider/notification-aws/pom.xml b/provider/notification-aws/pom.xml
index 51d7957a1..55eb27000 100644
--- a/provider/notification-aws/pom.xml
+++ b/provider/notification-aws/pom.xml
@@ -48,7 +48,7 @@
         <dependency>
             <groupId>org.opengroup.osdu.core.aws</groupId>
             <artifactId>os-core-lib-aws</artifactId>
-            <version>0.3.17</version>
+            <version>0.9.1-SNAPSHOT</version>
         </dependency>
 
         <!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-secretsmanager -->
diff --git a/provider/notification-aws/src/main/java/org/opengroup/osdu/notification/provider/aws/impl/AwsPubsubRequestBodyExtractor.java b/provider/notification-aws/src/main/java/org/opengroup/osdu/notification/provider/aws/impl/AwsPubsubRequestBodyExtractor.java
index eeaba9297..bc731b0ff 100644
--- a/provider/notification-aws/src/main/java/org/opengroup/osdu/notification/provider/aws/impl/AwsPubsubRequestBodyExtractor.java
+++ b/provider/notification-aws/src/main/java/org/opengroup/osdu/notification/provider/aws/impl/AwsPubsubRequestBodyExtractor.java
@@ -99,7 +99,7 @@ public class AwsPubsubRequestBodyExtractor implements IPubsubRequestBodyExtracto
 
         Map<String, String> attributes = content.getAttributes();
         if (attributes == null || attributes.isEmpty()) {
-            log.error("Incorrect Message: " + message.toString() );
+            log.error("Incorrect Message: " + message );
             throw new AppException(HttpStatus.BAD_REQUEST.value(), INVALID_PUBSUB_MESSAGE, "Attribute map not found");
         }
         String data = content.getData();
diff --git a/provider/notification-aws/src/main/java/org/opengroup/osdu/notification/provider/aws/impl/ServiceAccountJwtAwsClientImpl.java b/provider/notification-aws/src/main/java/org/opengroup/osdu/notification/provider/aws/impl/ServiceAccountJwtAwsClientImpl.java
deleted file mode 100644
index 325b629c5..000000000
--- a/provider/notification-aws/src/main/java/org/opengroup/osdu/notification/provider/aws/impl/ServiceAccountJwtAwsClientImpl.java
+++ /dev/null
@@ -1,113 +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.notification.provider.aws.impl;
-
-
-import com.amazonaws.auth.AWSCredentialsProvider;
-import com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagement;
-import com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagementClientBuilder;
-import com.amazonaws.services.simplesystemsmanagement.model.GetParameterRequest;
-import com.amazonaws.services.simplesystemsmanagement.model.GetParameterResult;
-import com.amazonaws.services.simplesystemsmanagement.model.Parameter;
-import lombok.AccessLevel;
-import lombok.Getter;
-import lombok.Setter;
-
-import org.opengroup.osdu.core.aws.entitlements.ServicePrincipal;
-import org.opengroup.osdu.core.aws.iam.IAMConfig;
-import org.opengroup.osdu.core.aws.secrets.SecretsManager;
-import org.opengroup.osdu.core.common.util.IServiceAccountJwtClient;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.PostConstruct;
-
-
-@Component
-public class ServiceAccountJwtAwsClientImpl implements IServiceAccountJwtClient {
-
-
-    @Value("${aws.region}")
-    @Getter()
-    @Setter(AccessLevel.PROTECTED)
-    public String amazonRegion;
-
-
-
-    @Value("${aws.ssm}")
-    @Getter()
-    @Setter(AccessLevel.PROTECTED)
-    public Boolean ssmEnabled;
-
-
-    @Value("${aws.environment}")
-    @Getter()
-    @Setter(AccessLevel.PROTECTED)
-    public String environment;
-
-    private String awsOauthCustomScope;
-
-    String client_credentials_secret;
-    String client_credentials_clientid;
-    ServicePrincipal sp;
-
-
-    private AWSCredentialsProvider amazonAWSCredentials;
-    private AWSSimpleSystemsManagement ssmManager;
-
-    @PostConstruct
-    public void init() {
-        if (ssmEnabled) {
-
-            SecretsManager sm = new SecretsManager();
-
-            String oauth_token_url = "/osdu/" + environment + "/oauth-token-uri";
-            String oauth_custom_scope = "/osdu/" + environment + "/oauth-custom-scope";
-
-            String client_credentials_client_id = "/osdu/" + environment + "/client-credentials-client-id";
-            String client_secret_key = "client_credentials_client_secret";
-            String client_secret_secretName = "/osdu/" + environment + "/client_credentials_secret";
-
-            amazonAWSCredentials = IAMConfig.amazonAWSCredentials();
-            ssmManager = AWSSimpleSystemsManagementClientBuilder.standard()
-                    .withCredentials(amazonAWSCredentials)
-                    .withRegion(amazonRegion)
-                    .build();
-
-            client_credentials_clientid = getSsmParameter(client_credentials_client_id);
-
-            client_credentials_secret = sm.getSecret(client_secret_secretName,amazonRegion,client_secret_key);
-
-            String tokenUrl = getSsmParameter(oauth_token_url);
-
-            awsOauthCustomScope = getSsmParameter(oauth_custom_scope);
-
-            sp = new ServicePrincipal(amazonRegion,environment,tokenUrl,awsOauthCustomScope);
-
-        }
-    }
-
-    @Override
-    public String getIdToken(String s) {
-        String token=  sp.getServicePrincipalAccessToken(client_credentials_clientid,client_credentials_secret);
-        return token;
-    }
-
-    private String getSsmParameter(String parameterKey) {
-        GetParameterRequest paramRequest = (new GetParameterRequest()).withName(parameterKey).withWithDecryption(true);
-        GetParameterResult paramResult = ssmManager.getParameter(paramRequest);
-        return paramResult.getParameter().getValue();
-    }
-
-
-}
diff --git a/provider/notification-aws/src/main/java/org/opengroup/osdu/notification/provider/aws/utils/AwsCognitoClient.java b/provider/notification-aws/src/main/java/org/opengroup/osdu/notification/provider/aws/utils/AwsCognitoClient.java
index ea906d1ee..a5975d3c9 100644
--- a/provider/notification-aws/src/main/java/org/opengroup/osdu/notification/provider/aws/utils/AwsCognitoClient.java
+++ b/provider/notification-aws/src/main/java/org/opengroup/osdu/notification/provider/aws/utils/AwsCognitoClient.java
@@ -50,8 +50,6 @@ public class AwsCognitoClient {
         this.awsCognitoAuthParamsUser = awsCognitoAuthParamsUser;
         this.awsCognitoAuthParamsPassword = awsCognitoAuthParamsPassword;
        this.provider = generateCognitoClient(region);
-
-
     }
 
     public String getToken(String username, String password,String tokenType){
diff --git a/provider/notification-aws/src/main/resources/application.properties b/provider/notification-aws/src/main/resources/application.properties
index 8c09e85af..7baa534c8 100644
--- a/provider/notification-aws/src/main/resources/application.properties
+++ b/provider/notification-aws/src/main/resources/application.properties
@@ -18,15 +18,13 @@ server.servlet.contextPath=/api/notification/v1
 server.port=${APPLICATION_PORT:8080}
 
 AUTHORIZE_API=${ENTITLEMENTS_BASE_URL}/api/entitlements/v1
-
-REGISTER_SERVICE_URL=${REGISTER_BASE_URL}/api/register/v1
+PARTITION_API=${ENTITLEMENTS_BASE_URL}/api/partition/v1
+REGISTER_SERVICE_URL=${ENTITLEMENTS_BASE_URL}/api/register/v1
 
 aws.ssm=${SSM_ENABLED:True}
 aws.environment=${RESOURCE_PREFIX}
-## AWS DynamoDB configuration
-aws.region=${AWS_REGION}
-aws.dynamodb.table.prefix=${RESOURCE_PREFIX}-
-aws.dynamodb.endpoint=dynamodb.${AWS_REGION}.amazonaws.com
+aws.parameter.prefix=/osdu/${RESOURCE_PREFIX}
+aws.primary.region=${aws.parameter.prefix}/primary-region
 
 app.expireTime=300
 app.maxCacheSize=10
@@ -49,4 +47,4 @@ server.ssl.key-store-type=PKCS12
 server.ssl.key-store=${SSL_KEY_STORE_PATH:/certs/osduonaws.p12}
 server.ssl.key-alias=${SSL_KEY_ALIAS:osduonaws}
 server.ssl.key-password=${SSL_KEY_PASSWORD:}
-server.ssl.key-store-password=${SSL_KEY_STORE_PASSWORD:}
\ No newline at end of file
+server.ssl.key-store-password=${SSL_KEY_STORE_PASSWORD:}
diff --git a/provider/notification-aws/src/test/java/org/opengroup/osdu/notification/provider/aws/AwsPubsubRequestBodyExtractorTest.java b/provider/notification-aws/src/test/java/org/opengroup/osdu/notification/provider/aws/AwsPubsubRequestBodyExtractorTest.java
index 76d62972a..d3bfe13ff 100644
--- a/provider/notification-aws/src/test/java/org/opengroup/osdu/notification/provider/aws/AwsPubsubRequestBodyExtractorTest.java
+++ b/provider/notification-aws/src/test/java/org/opengroup/osdu/notification/provider/aws/AwsPubsubRequestBodyExtractorTest.java
@@ -15,13 +15,10 @@
 package org.opengroup.osdu.notification.provider.aws;
 
 
-import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBDeleteExpression;
-import com.amazonaws.services.dynamodbv2.model.ConditionalCheckFailedException;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
 import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
diff --git a/testing/notification-test-aws/build-aws/prepare-dist.sh b/testing/notification-test-aws/build-aws/prepare-dist.sh
index 7d5a51809..3aaf33a95 100755
--- a/testing/notification-test-aws/build-aws/prepare-dist.sh
+++ b/testing/notification-test-aws/build-aws/prepare-dist.sh
@@ -38,10 +38,10 @@ echo $INTEGRATION_TEST_OUTPUT_BIN_DIR
 rm -rf "$INTEGRATION_TEST_OUTPUT_DIR"
 mkdir -p "$INTEGRATION_TEST_OUTPUT_DIR" && mkdir -p "$INTEGRATION_TEST_OUTPUT_BIN_DIR"
 echo "Building integration testing assemblies and gathering artifacts..."
-mvn install -f "$INTEGRATION_TEST_SOURCE_DIR_CORE"/pom.xml
-mvn install dependency:copy-dependencies -DskipTests -f "$INTEGRATION_TEST_SOURCE_DIR_AWS"/pom.xml -DincludeGroupIds=org.opengroup.osdu -Dmdep.copyPom
+mvn -ntp -B install -f "$INTEGRATION_TEST_SOURCE_DIR_CORE"/pom.xml
+mvn -ntp -B install dependency:copy-dependencies -DskipTests -f "$INTEGRATION_TEST_SOURCE_DIR_AWS"/pom.xml -DincludeGroupIds=org.opengroup.osdu -Dmdep.copyPom
 cp "$INTEGRATION_TEST_SOURCE_DIR_AWS"/target/dependency/* "${INTEGRATION_TEST_OUTPUT_BIN_DIR}"
-(cd "${INTEGRATION_TEST_OUTPUT_BIN_DIR}" && ls *.jar | sed -e 's/\.jar$//' | xargs -I {} echo mvn install:install-file -Dfile={}.jar -DpomFile={}.pom >> install-deps.sh)
+(cd "${INTEGRATION_TEST_OUTPUT_BIN_DIR}" && ls *.jar | sed -e 's/\.jar$//' | xargs -I {} echo mvn -ntp -B install:install-file -Dfile={}.jar -DpomFile={}.pom >> install-deps.sh)
 chmod +x "${INTEGRATION_TEST_OUTPUT_BIN_DIR}"/install-deps.sh
 mvn clean -f "$INTEGRATION_TEST_SOURCE_DIR_AWS"/pom.xml
 cp -R "$INTEGRATION_TEST_SOURCE_DIR_AWS"/* "${INTEGRATION_TEST_OUTPUT_DIR}"/
-- 
GitLab