-
Notifications
You must be signed in to change notification settings - Fork 484
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b67059
commit 199fb44
Showing
11 changed files
with
259 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* MinIO Java SDK for Amazon S3 Compatible Cloud Storage, (C) 2020 MinIO, Inc. | ||
* | ||
* 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 io.minio; | ||
|
||
public abstract class BucketArgs { | ||
private String name; | ||
private String region; | ||
|
||
BucketArgs(Builder<?> builder) { | ||
if (builder.name == null) { | ||
throw new IllegalArgumentException("null bucket name"); | ||
} | ||
|
||
// Bucket names cannot be no less than 3 and no more than 63 characters long. | ||
if (builder.name.length() < 3 || builder.name.length() > 63) { | ||
throw new IllegalArgumentException( | ||
builder.name | ||
+ " : " | ||
+ "bucket name must be at least 3 and no more than 63 characters long"); | ||
} | ||
// Successive periods in bucket names are not allowed. | ||
if (builder.name.contains("..")) { | ||
String msg = | ||
"bucket name cannot contain successive periods. For more information refer " | ||
+ "http://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html"; | ||
throw new IllegalArgumentException(builder.name + " : " + msg); | ||
} | ||
// Bucket names should be dns compatible. | ||
if (!builder.name.matches("^[a-z0-9][a-z0-9\\.\\-]+[a-z0-9]$")) { | ||
String msg = | ||
"bucket name does not follow Amazon S3 standards. For more information refer " | ||
+ "http://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html"; | ||
throw new IllegalArgumentException(builder.name + " : " + msg); | ||
} | ||
this.name = builder.name; | ||
this.region = builder.region; | ||
} | ||
|
||
public String bucketName() { | ||
return name; | ||
} | ||
|
||
public String region() { | ||
return region; | ||
} | ||
|
||
public abstract static class Builder<T extends Builder<T>> { | ||
public String name; | ||
public String region; | ||
|
||
@SuppressWarnings("unchecked") | ||
public T bucket(String name) { | ||
this.name = name; | ||
|
||
return (T) this; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public T region(String region) { | ||
this.region = region; | ||
return (T) this; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* MinIO Java SDK for Amazon S3 Compatible Cloud Storage, (C) 2020 MinIO, Inc. | ||
* | ||
* 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 io.minio; | ||
|
||
public class MakeBucketArgs extends BucketArgs { | ||
private final boolean objectLock; | ||
|
||
MakeBucketArgs(Builder builder) { | ||
super(builder); | ||
this.objectLock = builder.objectLock; | ||
} | ||
|
||
public boolean objectLock() { | ||
return objectLock; | ||
} | ||
|
||
public Builder build() { | ||
return new Builder(this); | ||
} | ||
|
||
public static final class Builder extends BucketArgs.Builder<Builder> { | ||
private boolean objectLock; | ||
|
||
public Builder() {} | ||
|
||
public Builder(MakeBucketArgs args) { | ||
this.name = args.bucketName(); | ||
this.region = args.region(); | ||
this.objectLock = args.objectLock(); | ||
} | ||
|
||
public Builder objectLock(boolean objectLock) { | ||
this.objectLock = objectLock; | ||
return this; | ||
} | ||
|
||
public MakeBucketArgs build() throws IllegalArgumentException { | ||
return new MakeBucketArgs(this); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.