Handle permission errors during bucket creation

This commit requires jclouds 2.1.0.  References #122.
pull/257/head
Andrew Gaul 2018-01-09 12:48:04 -08:00
rodzic 1955644f89
commit 6658f964f2
2 zmienionych plików z 9 dodań i 0 usunięć

Wyświetl plik

@ -42,6 +42,10 @@ public final class S3Exception extends Exception {
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,
Map<String, String> elements) {
super(requireNonNull(message), cause);

Wyświetl plik

@ -28,6 +28,7 @@ import java.io.PushbackInputStream;
import java.io.Writer;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.AccessDeniedException;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@ -1231,6 +1232,10 @@ public class S3ProxyHandler {
created = blobStore.createContainerInLocation(location,
containerName, options);
} 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);
}
if (!created) {