From 3fa283523c52bb07c45f37ef532e0cd31fde6602 Mon Sep 17 00:00:00 2001 From: Krishna Nikhil Vedurumudi Date: Thu, 15 Sep 2022 10:26:08 +0000 Subject: [PATCH] Merge branch 'storage' into 'master' Do not fail if Legal_COO.json does not exist See merge request osdu/platform/security-and-compliance/legal!297 (cherry picked from commit d17c70d1c756679f400183b7ad9a8c443f9b98cb) cf2578fb Do not fail if Legal_COO.json does not exist --- .../azure/countries/StorageReaderImpl.java | 15 ++++++++++-- .../resources/application-local.properties | 23 +++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 provider/legal-azure/src/main/resources/application-local.properties diff --git a/provider/legal-azure/src/main/java/org/opengroup/osdu/legal/azure/countries/StorageReaderImpl.java b/provider/legal-azure/src/main/java/org/opengroup/osdu/legal/azure/countries/StorageReaderImpl.java index 7f55be34..38dce230 100644 --- a/provider/legal-azure/src/main/java/org/opengroup/osdu/legal/azure/countries/StorageReaderImpl.java +++ b/provider/legal-azure/src/main/java/org/opengroup/osdu/legal/azure/countries/StorageReaderImpl.java @@ -14,7 +14,9 @@ package org.opengroup.osdu.legal.azure.countries; +import org.apache.http.HttpStatus; import org.opengroup.osdu.azure.blobstorage.BlobStore; +import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.legal.provider.interfaces.IStorageReader; import java.nio.charset.StandardCharsets; @@ -36,7 +38,16 @@ public class StorageReaderImpl implements IStorageReader { @Override public byte[] readAllBytes() { - return blobStore.readFromStorageContainer(dataPartitionId, fileName, containerName).getBytes(StandardCharsets.UTF_8); //should return a json format of an array of Country class + try { + //should return a json format of an array of Country class + return blobStore.readFromStorageContainer(dataPartitionId, fileName, containerName).getBytes(StandardCharsets.UTF_8); + } catch (AppException ae) { + if (ae.getError().getCode() == HttpStatus.SC_NOT_FOUND) { + // Storage File does not exist. No countries are being overwritten using Storage account. + // Continue using the DefaultCountryCode.json + return new byte[0]; + } + throw ae; + } } - } \ No newline at end of file diff --git a/provider/legal-azure/src/main/resources/application-local.properties b/provider/legal-azure/src/main/resources/application-local.properties new file mode 100644 index 00000000..66f1063e --- /dev/null +++ b/provider/legal-azure/src/main/resources/application-local.properties @@ -0,0 +1,23 @@ +# 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. + +runtime.env.local=true + +azure.activedirectory.client-id=${aad_client_id} +azure.activedirectory.AppIdUri=api://${azure.activedirectory.client-id} +azure.activedirectory.session-stateless=true + +# Istio Auth Enabled +azure.istio.auth.enabled=false + -- GitLab