Commit 270ed026 authored by Aman Verma's avatar Aman Verma
Browse files

adding new factory class and interface

parent f907a3e0
Pipeline #6424 passed with stages
in 1 minute and 50 seconds
......@@ -21,7 +21,7 @@
<groupId>org.opengroup.osdu</groupId>
<artifactId>core-lib-azure</artifactId>
<packaging>jar</packaging>
<version>0.0.19</version>
<version>0.0.20</version>
<name>core-lib-azure</name>
<properties>
......
// 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.
package org.opengroup.osdu.azure.blobstorage;
import com.azure.identity.DefaultAzureCredential;
import com.azure.storage.blob.BlobServiceClient;
import com.azure.storage.blob.BlobServiceClientBuilder;
import org.opengroup.osdu.common.Validators;
import org.springframework.beans.factory.annotation.Autowired;
import javax.inject.Named;
/**
* Implementation for IBlobServiceClientFactory.
*/
public class BlobServiceClientFactoryImpl implements IBlobServiceClientFactory {
@Autowired
private DefaultAzureCredential defaultAzureCredential;
@Autowired
@Named("STORAGE_ACCOUNT_NAME")
private String storageAccount;
private BlobServiceClient blobServiceClient;
/**
* Parameter-less constructor.
* This initializes the blobServiceClient.
*/
public BlobServiceClientFactoryImpl() {
Validators.checkNotNull(defaultAzureCredential, "Credential cannot be null");
Validators.checkNotNullAndNotEmpty(storageAccount, "KV URL");
String endpoint = String.format("https://%s.blob.core.windows.net", storageAccount);
blobServiceClient = new BlobServiceClientBuilder()
.endpoint(endpoint)
.credential(defaultAzureCredential)
.buildClient();
}
/**
* @param dataPartitionId data partition id.
* @return BlobServiceClient corresponding to the given data partition id.
*/
@Override
public BlobServiceClient getBlobServiceClient(final String dataPartitionId) {
return blobServiceClient;
}
}
// 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.
package org.opengroup.osdu.azure.blobstorage;
import com.azure.storage.blob.BlobServiceClient;
/**
* Interface for Blob service client factory to return appropriate
* blobServiceClient based on the data partition id and container name.
*/
public interface IBlobServiceClientFactory {
/**
*
* @param dataPartitionId data partition id.
* @return BlobServiceClient corresponding to the given data partition id.
*/
BlobServiceClient getBlobServiceClient(String dataPartitionId);
}
Supports Markdown
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