Skip to content

Commit

Permalink
Merge pull request #178 from Backblaze/mergePrivateChanges09152022
Browse files Browse the repository at this point in the history
This PR merges recent private updates to the public repo.

Testing: unit tests
  • Loading branch information
fmbz authored Sep 19, 2022
2 parents e8d85c0 + 676d005 commit ea81b02
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 9 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [6.1.0] - 2022-09-19
### Added
* Added support for Java 8's `-parameters` option so constructor parameters do not need to be reiterated in `B2Json.constructor#params`
* Added `fileLockEnabled` to `B2UpdateBucketRequest` to support enabling file lock on existing buckets

## [6.0.0] - 2022-06-03
### Changed `[Incompatible]`
* Updated `includeExistingFiles` to be required on B2ReplicationRule
Expand Down Expand Up @@ -166,7 +171,9 @@
* These changes were driven by switching our internal b2-sdk uses to use the http client from the sdk instead of a
different, custom interface.

[Unreleased]: https://github.com/Backblaze/b2-sdk-java/compare/v5.0.0...HEAD
[Unreleased]: https://github.com/Backblaze/b2-sdk-java/compare/v6.1.0...HEAD
[6.1.0]: https://github.com/Backblaze/b2-sdk-java/releases/tag/v6.1.0
[6.0.0]: https://github.com/Backblaze/b2-sdk-java/releases/tag/v6.0.0
[5.0.0]: https://github.com/Backblaze/b2-sdk-java/releases/tag/v5.0.0
[4.0.0]: https://github.com/Backblaze/b2-sdk-java/releases/tag/v4.0.0
[3.1.0]: https://github.com/Backblaze/b2-sdk-java/releases/tag/v3.1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021, Backblaze Inc. All Rights Reserved.
* Copyright 2022, Backblaze Inc. All Rights Reserved.
* License https://www.backblaze.com/using_b2_code.html
*/
package com.backblaze.b2.client.structures;
Expand Down Expand Up @@ -38,11 +38,14 @@ public class B2UpdateBucketRequest {
@B2Json.optional
private final B2BucketReplicationConfiguration replicationConfiguration;

@B2Json.optional
private final Boolean fileLockEnabled;

@B2Json.optional
private final Integer ifRevisionIs;

@B2Json.constructor(params = "accountId,bucketId,bucketType,bucketInfo,corsRules,lifecycleRules," +
"defaultRetention,defaultServerSideEncryption,replicationConfiguration,ifRevisionIs")
"defaultRetention,defaultServerSideEncryption,replicationConfiguration,fileLockEnabled,ifRevisionIs")
private B2UpdateBucketRequest(String accountId,
String bucketId,
String bucketType,
Expand All @@ -52,6 +55,7 @@ private B2UpdateBucketRequest(String accountId,
B2BucketDefaultRetention defaultRetention,
B2BucketServerSideEncryption defaultServerSideEncryption,
B2BucketReplicationConfiguration replicationConfiguration,
Boolean fileLockEnabled,
Integer ifRevisionIs) {
this.accountId = accountId;
this.bucketId = bucketId;
Expand All @@ -62,6 +66,7 @@ private B2UpdateBucketRequest(String accountId,
this.defaultRetention = defaultRetention;
this.defaultServerSideEncryption = defaultServerSideEncryption;
this.replicationConfiguration = replicationConfiguration;
this.fileLockEnabled = fileLockEnabled;
this.ifRevisionIs = ifRevisionIs;
}

Expand Down Expand Up @@ -100,6 +105,10 @@ public B2BucketReplicationConfiguration getReplicationConfiguration() {
return replicationConfiguration;
}

public Boolean getFileLockEnabled() {
return fileLockEnabled;
}

public Integer getIfRevisionIs() {
return ifRevisionIs;
}
Expand All @@ -118,6 +127,7 @@ public boolean equals(Object o) {
Objects.equals(getDefaultRetention(), that.getDefaultRetention()) &&
Objects.equals(getDefaultServerSideEncryption(), that.getDefaultServerSideEncryption()) &&
Objects.equals(getReplicationConfiguration(), that.getReplicationConfiguration()) &&
Objects.equals(getFileLockEnabled() , that.getFileLockEnabled()) &&
Objects.equals(getIfRevisionIs(), that.getIfRevisionIs());
}

Expand All @@ -133,6 +143,7 @@ public int hashCode() {
getDefaultRetention(),
getDefaultServerSideEncryption(),
getReplicationConfiguration(),
getFileLockEnabled(),
getIfRevisionIs()
);
}
Expand All @@ -156,6 +167,7 @@ public static class Builder {
private B2BucketDefaultRetention defaultRetention;
private B2BucketServerSideEncryption defaultServerSideEncryption;
private B2BucketReplicationConfiguration replicationConfiguration;
private Boolean fileLockEnabled;

private Builder(B2Bucket bucket) {
this.accountId = bucket.getAccountId();
Expand Down Expand Up @@ -198,6 +210,11 @@ public Builder setReplicationConfiguration(B2BucketReplicationConfiguration repl
return this;
}

public Builder setFileLockEnabled(Boolean fileLockEnabled) {
this.fileLockEnabled = fileLockEnabled;
return this;
}

public B2UpdateBucketRequest build() {
return new B2UpdateBucketRequest(
accountId,
Expand All @@ -209,6 +226,7 @@ public B2UpdateBucketRequest build() {
defaultRetention,
defaultServerSideEncryption,
replicationConfiguration,
fileLockEnabled,
ifRevisionIs
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021, Backblaze Inc. All Rights Reserved.
* Copyright 2022, Backblaze Inc. All Rights Reserved.
* License https://www.backblaze.com/using_b2_code.html
*/
package com.backblaze.b2.client;
Expand Down Expand Up @@ -136,18 +136,18 @@ public class B2StorageClientWebifierImplTest extends B2BaseTest {



private RecordingWebApiClient webApiClient = new RecordingWebApiClient();
private final RecordingWebApiClient webApiClient = new RecordingWebApiClient();

// i'm doing most tests with the a test mode to ensure it's set on all request type.
// there's a separate test it can be disabled; that test only checks one request type.
private B2StorageClientWebifierImpl webifier = new B2StorageClientWebifierImpl(
private final B2StorageClientWebifierImpl webifier = new B2StorageClientWebifierImpl(
webApiClient,
USER_AGENT,
MASTER_URL,
B2TestMode.FORCE_CAP_EXCEEDED
);

private B2ContentSink noopContentHandler = (r, i) -> {};
private final B2ContentSink noopContentHandler = (r, i) -> {};


@Rule
Expand Down Expand Up @@ -1139,6 +1139,7 @@ public void testUpdateBucket() throws B2Exception {
" ],\n" +
" \"defaultRetention\": null,\n" +
" \"defaultServerSideEncryption\": null,\n" +
" \"fileLockEnabled\": null,\n" +
" \"ifRevisionIs\": 1,\n" +
" \"lifecycleRules\": null,\n" +
" \"replicationConfiguration\": null\n" +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021, Backblaze Inc. All Rights Reserved.
* Copyright 2022, Backblaze Inc. All Rights Reserved.
* License https://www.backblaze.com/using_b2_code.html
*/
package com.backblaze.b2.client.structures;
Expand Down Expand Up @@ -133,6 +133,7 @@ public void testFullUpdateBucketRequest() {
.setDefaultRetention(defaultRetention)
.setDefaultServerSideEncryption(defaultServerSideEncryption)
.setReplicationConfiguration(replicationConfiguration)
.setFileLockEnabled(Boolean.TRUE)
.build();

// Convert from B2UpdateBucketRequest -> json
Expand Down Expand Up @@ -171,6 +172,7 @@ public void testFullUpdateBucketRequest() {
" \"algorithm\": \"AES256\",\n" +
" \"mode\": \"SSE-B2\"\n" +
" },\n" +
" \"fileLockEnabled\": true,\n" +
" \"ifRevisionIs\": 1,\n" +
" \"lifecycleRules\": [\n" +
" {\n" +
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright 2022, Backblaze Inc. All Rights Reserved.
# License https://www.backblaze.com/using_b2_code.html

version=6.0.0
version=6.1.0
group=com.backblaze.b2

0 comments on commit ea81b02

Please sign in to comment.