Commit be7c9317 authored by Kishore Battula's avatar Kishore Battula
Browse files

Merge branch 'blob-store-provider' into 'master'

Added BlobStore provider to create spring beans for BlobStore related classes

See merge request !49
parents 1736ae14 1a7b7d60
Pipeline #17187 passed with stages
in 9 minutes and 36 seconds
......@@ -20,7 +20,7 @@
<groupId>org.opengroup.osdu</groupId>
<artifactId>core-lib-azure</artifactId>
<packaging>jar</packaging>
<version>0.0.44</version>
<version>0.0.45</version>
<name>core-lib-azure</name>
<properties>
......
......@@ -21,28 +21,29 @@ import org.opengroup.osdu.azure.cache.BlobServiceClientCache;
import org.opengroup.osdu.azure.partition.PartitionInfoAzure;
import org.opengroup.osdu.azure.partition.PartitionServiceClient;
import org.opengroup.osdu.common.Validators;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
/**
* Implementation for IBlobServiceClientFactory.
*/
@Component
@Lazy
@ConditionalOnProperty(value = "azure.blobStore.required", havingValue = "true", matchIfMissing = false)
public class BlobServiceClientFactoryImpl implements IBlobServiceClientFactory {
@Autowired
private DefaultAzureCredential defaultAzureCredential;
@Autowired
private PartitionServiceClient partitionService;
@Autowired
private BlobServiceClientCache clientCache;
/**
* Constructor to initialize instance of {@link BlobServiceClientFactoryImpl}.
* @param credentials Azure Credentials to use
* @param partitionServiceClient Partition service client to use
* @param blobServiceClientCache Blob service client cache to use
*/
public BlobServiceClientFactoryImpl(final DefaultAzureCredential credentials,
final PartitionServiceClient partitionServiceClient,
final BlobServiceClientCache blobServiceClientCache) {
this.defaultAzureCredential = credentials;
this.partitionService = partitionServiceClient;
this.clientCache = blobServiceClientCache;
}
/**
* @param dataPartitionId data partition id.
* @return BlobServiceClient corresponding to the given data partition id.
......
......@@ -25,9 +25,6 @@ import com.azure.storage.blob.sas.BlobServiceSasSignatureValues;
import com.azure.storage.blob.specialized.BlockBlobClient;
import org.opengroup.osdu.core.common.logging.ILogger;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
......@@ -79,17 +76,20 @@ import java.util.Collections;
* }
* </pre>
*/
@Component
@ConditionalOnProperty(value = "azure.blobStore.required", havingValue = "true", matchIfMissing = false)
public class BlobStore {
@Autowired
private IBlobServiceClientFactory blobServiceClientFactory;
@Autowired
private ILogger logger;
/**
* Constructor to create BlobStore.
* @param factory Factory that provides blob client.
* @param loggerInstance logger instance to be used for logging.
*/
public BlobStore(final IBlobServiceClientFactory factory, final ILogger loggerInstance) {
this.blobServiceClientFactory = factory;
this.logger = loggerInstance;
}
private static final String LOG_PREFIX = "azure-core-lib";
/**
......
package org.opengroup.osdu.azure.blobstorage;
import com.azure.identity.DefaultAzureCredential;
import org.opengroup.osdu.azure.cache.BlobServiceClientCache;
import org.opengroup.osdu.azure.partition.PartitionServiceClient;
import org.opengroup.osdu.core.common.logging.ILogger;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* This is configuration bean to provide BlobStore component.
*/
@Configuration
@ConditionalOnProperty(value = "azure.blobStore.required", havingValue = "true", matchIfMissing = false)
public class BlobStoreProvider {
/**
* Creates instance of {@link IBlobServiceClientFactory}.
* @param defaultAzureCredential Azure credentials to use.
* @param partitionServiceClient Partition service client to use.
* @param blobServiceClientCache Blob service client cache to use.
* @return instance of {@link BlobServiceClientFactoryImpl}
*/
@Bean
public IBlobServiceClientFactory buildBlobClientFactory(final DefaultAzureCredential defaultAzureCredential,
final PartitionServiceClient partitionServiceClient,
final BlobServiceClientCache blobServiceClientCache) {
return new BlobServiceClientFactoryImpl(defaultAzureCredential, partitionServiceClient, blobServiceClientCache);
}
/**
* Create instance of {@link BlobStore}.
* @param blobServiceClientFactory Factory which provides a BlobClient.
* @param logger logger to use for logging.
* @return instance of {@link BlobStore}
*/
@Bean
public BlobStore buildBlobStore(final IBlobServiceClientFactory blobServiceClientFactory, final ILogger logger) {
return new BlobStore(blobServiceClientFactory, logger);
}
}
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