Skip to content
Snippets Groups Projects
Commit 9d62875f authored by Auto GO3-NRG Ticket's avatar Auto GO3-NRG Ticket
Browse files

Auto commit when pipeline succeeds

parents bbdf3a02 260e8fb1
No related branches found
No related tags found
2 merge requests!98(GONRG-1768) GCP: logging impl,!92Cloud-agnostic module `legal-reference` for Anthos (GONRG-1423)
......@@ -16,6 +16,7 @@ package org.opengroup.osdu.legal.azure.countries;
import com.azure.storage.blob.BlobContainerClient;
import com.azure.storage.blob.specialized.BlockBlobClient;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.tenant.TenantInfo;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.legal.provider.interfaces.IStorageReader;
......@@ -43,20 +44,27 @@ public class StorageReaderImpl implements IStorageReader {
return readFromBlobStorage().getBytes(StandardCharsets.UTF_8); //should return a json format of an array of Country class
}
/**
* This function should be fail close. It reads the pre-configuration file for the partition. As a security requirement, we should
* fail the corresponding request instead of assuming the content is empty, but it should only fail close on the request level not
* service level meaning the service could still start and running probably for the APIs which do not need the pre-configuration file
*/
public String readFromBlobStorage() {
String content = "";
BlockBlobClient blockBlobClient = blobContainerClient.getBlobClient(fileName).getBlockBlobClient();
if (blockBlobClient.exists())
{
try (ByteArrayOutputStream downloadStream = new ByteArrayOutputStream()) {
blockBlobClient.download(downloadStream);
content = downloadStream.toString(StandardCharsets.UTF_8.name());
String content = downloadStream.toString(StandardCharsets.UTF_8.name());
return content;
} catch (Exception e) {
logger.error(String.format("read %s failed", fileName));
String message = String.format("read %s failed", fileName);
throw new AppException(500, "Server error", message);
}
} else {
String message = String.format("%s does not exist on partition %s", fileName, tenantInfo.getDataPartitionId());
throw new AppException(500, "Server error", message);
}
return content;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment