mirror of https://github.com/apache/jclouds.git
fixed bad cast
git-svn-id: http://jclouds.googlecode.com/svn/trunk@1090 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
9cec8159d4
commit
5cb5a3bb71
|
@ -37,21 +37,21 @@ import com.google.inject.assistedinject.Assisted;
|
||||||
import com.google.inject.name.Named;
|
import com.google.inject.name.Named;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The DELETE request operation deletes the bucket named in the URI. All objects
|
* The DELETE request operation deletes the bucket named in the URI. All objects in the bucket must
|
||||||
* in the bucket must be deleted before the bucket itself can be deleted.
|
* be deleted before the bucket itself can be deleted.
|
||||||
* <p />
|
* <p />
|
||||||
* Only the owner of a bucket can delete it, regardless of the bucket's access
|
* Only the owner of a bucket can delete it, regardless of the bucket's access control policy.
|
||||||
* control policy.
|
|
||||||
*
|
*
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AmazonS3/2006-03-01/index.html?RESTBucketDELETE.html"
|
* @see <a
|
||||||
|
* href="http://docs.amazonwebservices.com/AmazonS3/2006-03-01/index.html?RESTBucketDELETE.html"
|
||||||
* />
|
* />
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class DeleteBucket extends S3FutureCommand<Boolean> {
|
public class DeleteBucket extends S3FutureCommand<Boolean> {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public DeleteBucket(@Named("jclouds.http.address") String amazonHost,
|
public DeleteBucket(@Named("jclouds.http.address") String amazonHost, ReturnTrueIf2xx callable,
|
||||||
ReturnTrueIf2xx callable, @Assisted String s3Bucket) {
|
@Assisted String s3Bucket) {
|
||||||
super("DELETE", "/", callable, amazonHost, s3Bucket);
|
super("DELETE", "/", callable, amazonHost, s3Bucket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,14 +66,11 @@ public class DeleteBucket extends S3FutureCommand<Boolean> {
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
Boolean attemptNotFound(ExecutionException e) throws ExecutionException {
|
Boolean attemptNotFound(ExecutionException e) throws ExecutionException {
|
||||||
if (e.getCause() != null
|
if (e.getCause() != null && e.getCause() instanceof AWSResponseException) {
|
||||||
&& e.getCause() instanceof HttpResponseException) {
|
AWSResponseException responseException = (AWSResponseException) e.getCause();
|
||||||
AWSResponseException responseException = (AWSResponseException) e
|
|
||||||
.getCause();
|
|
||||||
if (responseException.getResponse().getStatusCode() == 404) {
|
if (responseException.getResponse().getStatusCode() == 404) {
|
||||||
return true;
|
return true;
|
||||||
} else if ("BucketNotEmpty".equals(responseException.getError()
|
} else if ("BucketNotEmpty".equals(responseException.getError().getCode())) {
|
||||||
.getCode())) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,8 +78,8 @@ public class DeleteBucket extends S3FutureCommand<Boolean> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean get(long l, TimeUnit timeUnit) throws InterruptedException,
|
public Boolean get(long l, TimeUnit timeUnit) throws InterruptedException, ExecutionException,
|
||||||
ExecutionException, TimeoutException {
|
TimeoutException {
|
||||||
try {
|
try {
|
||||||
return super.get(l, timeUnit);
|
return super.get(l, timeUnit);
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
|
|
|
@ -51,17 +51,14 @@ public class GetAccessControlList extends S3FutureCommand<AccessControlList> {
|
||||||
@Inject
|
@Inject
|
||||||
public GetAccessControlList(@Named("jclouds.http.address") String amazonHost,
|
public GetAccessControlList(@Named("jclouds.http.address") String amazonHost,
|
||||||
ParseSax<AccessControlList> accessControlListParser,
|
ParseSax<AccessControlList> accessControlListParser,
|
||||||
@Assisted("bucketName") String bucket)
|
@Assisted("bucketName") String bucket) {
|
||||||
{
|
|
||||||
super("GET", "/?acl", accessControlListParser, amazonHost, bucket);
|
super("GET", "/?acl", accessControlListParser, amazonHost, bucket);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public GetAccessControlList(@Named("jclouds.http.address") String amazonHost,
|
public GetAccessControlList(@Named("jclouds.http.address") String amazonHost,
|
||||||
ParseSax<AccessControlList> accessControlListParser,
|
ParseSax<AccessControlList> accessControlListParser,
|
||||||
@Assisted("bucketName") String bucket,
|
@Assisted("bucketName") String bucket, @Assisted("objectKey") String objectKey) {
|
||||||
@Assisted("objectKey") String objectKey)
|
|
||||||
{
|
|
||||||
super("GET", "/" + objectKey + "?acl", accessControlListParser, amazonHost, bucket);
|
super("GET", "/" + objectKey + "?acl", accessControlListParser, amazonHost, bucket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,11 +73,10 @@ public class GetAccessControlList extends S3FutureCommand<AccessControlList> {
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
AccessControlList attemptNotFound(ExecutionException e) throws ExecutionException {
|
AccessControlList attemptNotFound(ExecutionException e) throws ExecutionException {
|
||||||
if (e.getCause() != null && e.getCause() instanceof HttpResponseException) {
|
if (e.getCause() != null && e.getCause() instanceof AWSResponseException) {
|
||||||
AWSResponseException responseException = (AWSResponseException) e.getCause();
|
AWSResponseException responseException = (AWSResponseException) e.getCause();
|
||||||
if ("NoSuchBucket".equals(responseException.getError().getCode())
|
if ("NoSuchBucket".equals(responseException.getError().getCode())
|
||||||
|| "NoSuchObject".equals(responseException.getError().getCode()))
|
|| "NoSuchObject".equals(responseException.getError().getCode())) {
|
||||||
{
|
|
||||||
return AccessControlList.NOT_FOUND;
|
return AccessControlList.NOT_FOUND;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,8 +84,8 @@ public class GetAccessControlList extends S3FutureCommand<AccessControlList> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AccessControlList get(long l, TimeUnit timeUnit) throws InterruptedException, ExecutionException,
|
public AccessControlList get(long l, TimeUnit timeUnit) throws InterruptedException,
|
||||||
TimeoutException {
|
ExecutionException, TimeoutException {
|
||||||
try {
|
try {
|
||||||
return super.get(l, timeUnit);
|
return super.get(l, timeUnit);
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
|
|
|
@ -31,7 +31,6 @@ import org.jclouds.aws.AWSResponseException;
|
||||||
import org.jclouds.aws.s3.commands.options.ListBucketOptions;
|
import org.jclouds.aws.s3.commands.options.ListBucketOptions;
|
||||||
import org.jclouds.aws.s3.domain.S3Bucket;
|
import org.jclouds.aws.s3.domain.S3Bucket;
|
||||||
import org.jclouds.aws.s3.xml.ListBucketHandler;
|
import org.jclouds.aws.s3.xml.ListBucketHandler;
|
||||||
import org.jclouds.http.HttpResponseException;
|
|
||||||
import org.jclouds.http.commands.callables.xml.ParseSax;
|
import org.jclouds.http.commands.callables.xml.ParseSax;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
@ -75,7 +74,7 @@ public class ListBucket extends S3FutureCommand<S3Bucket> {
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
S3Bucket attemptNotFound(ExecutionException e) throws ExecutionException {
|
S3Bucket attemptNotFound(ExecutionException e) throws ExecutionException {
|
||||||
if (e.getCause() != null && e.getCause() instanceof HttpResponseException) {
|
if (e.getCause() != null && e.getCause() instanceof AWSResponseException) {
|
||||||
AWSResponseException responseException = (AWSResponseException) e.getCause();
|
AWSResponseException responseException = (AWSResponseException) e.getCause();
|
||||||
if ("NoSuchBucket".equals(responseException.getError().getCode())) {
|
if ("NoSuchBucket".equals(responseException.getError().getCode())) {
|
||||||
return S3Bucket.NOT_FOUND;
|
return S3Bucket.NOT_FOUND;
|
||||||
|
|
Loading…
Reference in New Issue