Skip to content

Commit c2c27cc

Browse files
sandeepvinayakiamabhilaksh
authored andcommitted
chore: enforce the checkstyle (#330)
1 parent bdb1502 commit c2c27cc

File tree

461 files changed

+76043
-73231
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

461 files changed

+76043
-73231
lines changed

CLAUDE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ Conformance tests require valid cloud credentials:
9797
### Dependency management
9898
- Never add cloud specific dependency in cloud-agnostic package.
9999
- for example, `docstore-client` should never depend upon `multicloud-common-gcp`, `docstore-aws` etc
100+
- Never put any provider specific code, documentation, keywords in client, driver packages such as anything in `docstore-client` module.
100101

101102
### Adding New Functionality
102103

@@ -105,7 +106,7 @@ Conformance tests require valid cloud credentials:
105106
3. Implement functionality in each provider-specific module (aws, gcp, ali)
106107
4. Add unit tests to provider modules
107108
5. Add/update conformance tests in `-client` module
108-
6. Ensure checkstyle passes (Google Java Style Guide)
109+
6. Ensure checkstyle passes (Google Java Style Guide), the checkstyle.xml are in config/
109110

110111
### Working with Multiple Cloud Providers
111112

blob/blob-ali/src/main/java/com/salesforce/multicloudj/blob/ali/AliBlobClient.java

Lines changed: 96 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -15,115 +15,120 @@
1515
import com.salesforce.multicloudj.common.exceptions.SubstrateSdkException;
1616
import com.salesforce.multicloudj.common.exceptions.UnknownException;
1717
import com.salesforce.multicloudj.common.provider.Provider;
18-
1918
import java.util.stream.Collectors;
2019

2120
/**
22-
* An implementation of the {@link AbstractBlobClient} for Ali OSS
23-
* AliBlobClient is service client for interacting with Alibaba Cloud Blob Storage.
21+
* An implementation of the {@link AbstractBlobClient} for Ali OSS AliBlobClient is service client
22+
* for interacting with Alibaba Cloud Blob Storage.
2423
*
25-
* <p>This class provides methods to access Ali resources using Alibaba OSS JDK to interact
26-
* with the OSS service.
24+
* <p>This class provides methods to access Ali resources using Alibaba OSS JDK to interact with the
25+
* OSS service.
2726
*/
2827
public class AliBlobClient extends AbstractBlobClient<AliBlobClient> {
29-
private OSS ossClient;
28+
private OSS ossClient;
3029

31-
/**
32-
* Constructs an {@link AliBlobClient} using the provided builder.
33-
*
34-
* @param builder the builder to use to construct the AliBlobClient
35-
*/
36-
protected AliBlobClient(Builder builder) {
37-
super(builder);
30+
/**
31+
* Constructs an {@link AliBlobClient} using the provided builder.
32+
*
33+
* @param builder the builder to use to construct the AliBlobClient
34+
*/
35+
protected AliBlobClient(Builder builder) {
36+
super(builder);
3837

39-
String endpoint = "https://oss-" + region + ".aliyuncs.com";
40-
if (builder.getEndpoint() != null) {
41-
endpoint = builder.getEndpoint().getHost();
42-
}
43-
OSSClientBuilder.OSSClientBuilderImpl ossClientBuilderImpl = OSSClientBuilder.create().endpoint(endpoint);
44-
ClientBuilderConfiguration clientBuilderConfiguration = new ClientBuilderConfiguration();
45-
clientBuilderConfiguration.setSignatureVersion(SignVersion.V4);
46-
if (builder.getProxyEndpoint() != null) {
47-
clientBuilderConfiguration.setProxyHost(builder.getProxyEndpoint().getHost());
48-
clientBuilderConfiguration.setProxyPort(builder.getProxyEndpoint().getPort());
49-
}
50-
CredentialsProvider credentialsProvider = OSSCredentialsProvider.getCredentialsProvider(credentialsOverrider, region);
51-
if (credentialsProvider != null) {
52-
ossClientBuilderImpl.credentialsProvider(credentialsProvider);
53-
}
54-
ossClientBuilderImpl.clientConfiguration(clientBuilderConfiguration);
55-
ossClient = ossClientBuilderImpl.build();
38+
String endpoint = "https://oss-" + region + ".aliyuncs.com";
39+
if (builder.getEndpoint() != null) {
40+
endpoint = builder.getEndpoint().getHost();
5641
}
57-
58-
/**
59-
* Lists all buckets in the Alibaba Cloud Blob Storage account associated with this client.
60-
*
61-
* @return a {@link ListBucketsResponse} containing a list of all buckets int the current region for this account
62-
*/
63-
@Override
64-
protected ListBucketsResponse doListBuckets() {
65-
return ListBucketsResponse.builder().bucketInfoList(ossClient.listBuckets().stream().map(bucket -> BucketInfo.builder()
66-
.name(bucket.getName())
67-
.region(bucket.getRegion())
68-
.creationDate(bucket.getCreationDate().toInstant())
69-
.build()).collect(Collectors.toList())).build();
42+
OSSClientBuilder.OSSClientBuilderImpl ossClientBuilderImpl =
43+
OSSClientBuilder.create().endpoint(endpoint);
44+
ClientBuilderConfiguration clientBuilderConfiguration = new ClientBuilderConfiguration();
45+
clientBuilderConfiguration.setSignatureVersion(SignVersion.V4);
46+
if (builder.getProxyEndpoint() != null) {
47+
clientBuilderConfiguration.setProxyHost(builder.getProxyEndpoint().getHost());
48+
clientBuilderConfiguration.setProxyPort(builder.getProxyEndpoint().getPort());
7049
}
71-
72-
/**
73-
* Creates a new bucket with the specified name.
74-
*
75-
* @param bucketName The name of the bucket to create
76-
*/
77-
@Override
78-
protected void doCreateBucket(String bucketName) {
79-
ossClient.createBucket(bucketName);
50+
CredentialsProvider credentialsProvider =
51+
OSSCredentialsProvider.getCredentialsProvider(credentialsOverrider, region);
52+
if (credentialsProvider != null) {
53+
ossClientBuilderImpl.credentialsProvider(credentialsProvider);
8054
}
55+
ossClientBuilderImpl.clientConfiguration(clientBuilderConfiguration);
56+
ossClient = ossClientBuilderImpl.build();
57+
}
8158

82-
/**
83-
* Returns a {@link Provider.Builder} for creating a Provider for this class.
84-
*
85-
* @return a {@link Provider.Builder} for creating a Provider for this class
86-
*/
87-
@Override
88-
public Provider.Builder builder() {
89-
return new AliBlobStore.Builder();
90-
}
59+
/**
60+
* Lists all buckets in the Alibaba Cloud Blob Storage account associated with this client.
61+
*
62+
* @return a {@link ListBucketsResponse} containing a list of all buckets int the current region
63+
* for this account
64+
*/
65+
@Override
66+
protected ListBucketsResponse doListBuckets() {
67+
return ListBucketsResponse.builder()
68+
.bucketInfoList(
69+
ossClient.listBuckets().stream()
70+
.map(
71+
bucket ->
72+
BucketInfo.builder()
73+
.name(bucket.getName())
74+
.region(bucket.getRegion())
75+
.creationDate(bucket.getCreationDate().toInstant())
76+
.build())
77+
.collect(Collectors.toList()))
78+
.build();
79+
}
9180

92-
/**
93-
* Returns the appropriate SubstrateSdkException subclass for the given Throwable.
94-
*/
95-
@Override
96-
public Class<? extends SubstrateSdkException> getException(Throwable t) {
97-
if (t instanceof SubstrateSdkException) {
98-
return (Class<? extends SubstrateSdkException>) t.getClass();
99-
} else if (t instanceof ServiceException) {
100-
String errorCode = ((ServiceException) t).getErrorCode();
101-
return ErrorCodeMapping.getException(errorCode);
102-
} else if (t instanceof ClientException) {
103-
return InvalidArgumentException.class;
104-
}
105-
return UnknownException.class;
81+
/**
82+
* Creates a new bucket with the specified name.
83+
*
84+
* @param bucketName The name of the bucket to create
85+
*/
86+
@Override
87+
protected void doCreateBucket(String bucketName) {
88+
ossClient.createBucket(bucketName);
89+
}
90+
91+
/**
92+
* Returns a {@link Provider.Builder} for creating a Provider for this class.
93+
*
94+
* @return a {@link Provider.Builder} for creating a Provider for this class
95+
*/
96+
@Override
97+
public Provider.Builder builder() {
98+
return new AliBlobStore.Builder();
99+
}
100+
101+
/** Returns the appropriate SubstrateSdkException subclass for the given Throwable. */
102+
@Override
103+
public Class<? extends SubstrateSdkException> getException(Throwable t) {
104+
if (t instanceof SubstrateSdkException) {
105+
return (Class<? extends SubstrateSdkException>) t.getClass();
106+
} else if (t instanceof ServiceException) {
107+
String errorCode = ((ServiceException) t).getErrorCode();
108+
return ErrorCodeMapping.getException(errorCode);
109+
} else if (t instanceof ClientException) {
110+
return InvalidArgumentException.class;
106111
}
112+
return UnknownException.class;
113+
}
107114

108-
/**
109-
* Closes the underlying OSS client and releases any resources.
110-
*/
111-
@Override
112-
public void close() {
113-
if (ossClient != null) {
114-
ossClient.shutdown();
115-
}
115+
/** Closes the underlying OSS client and releases any resources. */
116+
@Override
117+
public void close() {
118+
if (ossClient != null) {
119+
ossClient.shutdown();
116120
}
121+
}
117122

118-
public static class Builder extends AbstractBlobClient.Builder<AliBlobClient> {
123+
public static class Builder extends AbstractBlobClient.Builder<AliBlobClient> {
119124

120-
public Builder() {
121-
providerId(AliConstants.PROVIDER_ID);
122-
}
125+
public Builder() {
126+
providerId(AliConstants.PROVIDER_ID);
127+
}
123128

124-
@Override
125-
public AliBlobClient build() {
126-
return new AliBlobClient(this);
127-
}
129+
@Override
130+
public AliBlobClient build() {
131+
return new AliBlobClient(this);
128132
}
133+
}
129134
}

0 commit comments

Comments
 (0)