Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
System
Lib
cloud
azure
OS Core Lib Azure
Commits
270ed026
Commit
270ed026
authored
Aug 24, 2020
by
Aman Verma
Browse files
adding new factory class and interface
parent
f907a3e0
Pipeline
#6424
passed with stages
in 1 minute and 50 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
270ed026
...
...
@@ -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>
...
...
src/main/java/org/opengroup/osdu/azure/blobstorage/BlobServiceClientFactoryImpl.java
0 → 100644
View file @
270ed026
// 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
;
}
}
src/main/java/org/opengroup/osdu/azure/blobstorage/IBlobServiceClientFactory.java
0 → 100644
View file @
270ed026
// 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
);
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment