From e88b41aabd600627164b1e040deb4739c9431f6a Mon Sep 17 00:00:00 2001 From: Stanislav Riabokon <stanislav_riabokon@epam.com> Date: Mon, 28 Sep 2020 14:42:09 +0400 Subject: [PATCH] Default value for 'enable.full.bucket.name' = false. Added debug logs. --- .../countries/StorageReaderFactoryImpl.java | 2 +- .../src/main/resources/application.properties | 4 +-- .../osdu/legal/util/GCPLegalTagUtils.java | 28 ++++++++++++------- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/provider/legal-gcp/src/main/java/org/opengroup/osdu/legal/countries/StorageReaderFactoryImpl.java b/provider/legal-gcp/src/main/java/org/opengroup/osdu/legal/countries/StorageReaderFactoryImpl.java index 8c0147e18..040d92900 100644 --- a/provider/legal-gcp/src/main/java/org/opengroup/osdu/legal/countries/StorageReaderFactoryImpl.java +++ b/provider/legal-gcp/src/main/java/org/opengroup/osdu/legal/countries/StorageReaderFactoryImpl.java @@ -10,7 +10,7 @@ import org.springframework.stereotype.Component; @Component public class StorageReaderFactoryImpl implements IStorageReaderFactory { - @Value("#{new Boolean('${enable.full.bucket.name}')}") + @Value("#{new Boolean('${enable.full.bucket.name:false}')}") private Boolean isFullBucketName; @Override diff --git a/provider/legal-gcp/src/main/resources/application.properties b/provider/legal-gcp/src/main/resources/application.properties index 17e15708f..bf07a4576 100644 --- a/provider/legal-gcp/src/main/resources/application.properties +++ b/provider/legal-gcp/src/main/resources/application.properties @@ -8,6 +8,4 @@ server.port=8080 JAVA_HEAP_OPTS=-Xms4096M -Xmx4096M JAVA_GC_OPTS=-XX:+UseG1GC -XX:+UseStringDeduplication -XX:InitiatingHeapOccupancyPercent=45 -enable.full.bucket.name=${ENABLE_FULL_BUCKET_NAME} - - +enable.full.bucket.name=false \ No newline at end of file diff --git a/testing/legal-test-gcp/src/test/java/org/opengroup/osdu/legal/util/GCPLegalTagUtils.java b/testing/legal-test-gcp/src/test/java/org/opengroup/osdu/legal/util/GCPLegalTagUtils.java index c2b7d9be9..0752f278c 100644 --- a/testing/legal-test-gcp/src/test/java/org/opengroup/osdu/legal/util/GCPLegalTagUtils.java +++ b/testing/legal-test-gcp/src/test/java/org/opengroup/osdu/legal/util/GCPLegalTagUtils.java @@ -1,10 +1,5 @@ package org.opengroup.osdu.legal.util; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Base64; - import com.google.api.client.util.Strings; import com.google.auth.oauth2.GoogleCredentials; import com.google.cloud.storage.BlobId; @@ -12,7 +7,10 @@ import com.google.cloud.storage.BlobInfo; import com.google.cloud.storage.Storage; import com.google.cloud.storage.StorageOptions; import com.google.common.collect.Lists; -import java.util.Objects; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Base64; import lombok.extern.java.Log; @Log @@ -47,12 +45,22 @@ public class GCPLegalTagUtils extends LegalTagUtils { String projectName = System.getProperty("GCLOUD_PROJECT", System.getenv("GCLOUD_PROJECT")) .toLowerCase(); String enableFullBucketName = System.getProperty("ENABLE_FULL_BUCKET_NAME", - System.getenv("ENABLE_FULL_BUCKET_NAME")).toLowerCase(); + System.getenv("ENABLE_FULL_BUCKET_NAME")); + + enableFullBucketName = (Strings.isNullOrEmpty(enableFullBucketName) ? "false" + : enableFullBucketName).toLowerCase(); + log.info("ENABLE_FULL_BUCKET_NAME = " + enableFullBucketName); - if (Objects.nonNull(enableFullBucketName) && Boolean.valueOf(enableFullBucketName)) { - return projectName + "-" + tenantName + "-" + BUCKET_NAME; + + String bucketName; + if (Boolean.parseBoolean(enableFullBucketName)) { + bucketName = projectName + "-" + tenantName + "-" + BUCKET_NAME; + } else { + bucketName = tenantName + "-" + BUCKET_NAME; } - return tenantName + "-" + BUCKET_NAME; + + log.info("bucketName = " + bucketName); + return bucketName; } @Override -- GitLab