kopia lustrzana https://github.com/gaul/s3proxy
Handle permission errors during bucket creation
This commit requires jclouds 2.1.0. References #122.pull/257/head
rodzic
1955644f89
commit
6658f964f2
|
@ -42,6 +42,10 @@ public final class S3Exception extends Exception {
|
||||||
ImmutableMap.<String, String>of());
|
ImmutableMap.<String, String>of());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
S3Exception(S3ErrorCode error, String message, Throwable cause) {
|
||||||
|
this(error, message, cause, ImmutableMap.<String, String>of());
|
||||||
|
}
|
||||||
|
|
||||||
S3Exception(S3ErrorCode error, String message, Throwable cause,
|
S3Exception(S3ErrorCode error, String message, Throwable cause,
|
||||||
Map<String, String> elements) {
|
Map<String, String> elements) {
|
||||||
super(requireNonNull(message), cause);
|
super(requireNonNull(message), cause);
|
||||||
|
|
|
@ -28,6 +28,7 @@ import java.io.PushbackInputStream;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.AccessDeniedException;
|
||||||
import java.security.InvalidKeyException;
|
import java.security.InvalidKeyException;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
@ -1231,6 +1232,10 @@ public class S3ProxyHandler {
|
||||||
created = blobStore.createContainerInLocation(location,
|
created = blobStore.createContainerInLocation(location,
|
||||||
containerName, options);
|
containerName, options);
|
||||||
} catch (AuthorizationException ae) {
|
} catch (AuthorizationException ae) {
|
||||||
|
if (ae.getCause() instanceof AccessDeniedException) {
|
||||||
|
throw new S3Exception(S3ErrorCode.ACCESS_DENIED,
|
||||||
|
"Could not create bucket", ae);
|
||||||
|
}
|
||||||
throw new S3Exception(S3ErrorCode.BUCKET_ALREADY_EXISTS, ae);
|
throw new S3Exception(S3ErrorCode.BUCKET_ALREADY_EXISTS, ae);
|
||||||
}
|
}
|
||||||
if (!created) {
|
if (!created) {
|
||||||
|
|
Ładowanie…
Reference in New Issue