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;
|
||||
|
||||
/**
|
||||
* The DELETE request operation deletes the bucket named in the URI. All objects
|
||||
* in the bucket must be deleted before the bucket itself can be deleted.
|
||||
* The DELETE request operation deletes the bucket named in the URI. All objects in the bucket must
|
||||
* be deleted before the bucket itself can be deleted.
|
||||
* <p />
|
||||
* Only the owner of a bucket can delete it, regardless of the bucket's access
|
||||
* control policy.
|
||||
* Only the owner of a bucket can delete it, regardless of the bucket's access 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
|
||||
*/
|
||||
public class DeleteBucket extends S3FutureCommand<Boolean> {
|
||||
|
||||
@Inject
|
||||
public DeleteBucket(@Named("jclouds.http.address") String amazonHost,
|
||||
ReturnTrueIf2xx callable, @Assisted String s3Bucket) {
|
||||
public DeleteBucket(@Named("jclouds.http.address") String amazonHost, ReturnTrueIf2xx callable,
|
||||
@Assisted String s3Bucket) {
|
||||
super("DELETE", "/", callable, amazonHost, s3Bucket);
|
||||
}
|
||||
|
||||
|
@ -66,14 +66,11 @@ public class DeleteBucket extends S3FutureCommand<Boolean> {
|
|||
|
||||
@VisibleForTesting
|
||||
Boolean attemptNotFound(ExecutionException e) throws ExecutionException {
|
||||
if (e.getCause() != null
|
||||
&& e.getCause() instanceof HttpResponseException) {
|
||||
AWSResponseException responseException = (AWSResponseException) e
|
||||
.getCause();
|
||||
if (e.getCause() != null && e.getCause() instanceof AWSResponseException) {
|
||||
AWSResponseException responseException = (AWSResponseException) e.getCause();
|
||||
if (responseException.getResponse().getStatusCode() == 404) {
|
||||
return true;
|
||||
} else if ("BucketNotEmpty".equals(responseException.getError()
|
||||
.getCode())) {
|
||||
} else if ("BucketNotEmpty".equals(responseException.getError().getCode())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -81,8 +78,8 @@ public class DeleteBucket extends S3FutureCommand<Boolean> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Boolean get(long l, TimeUnit timeUnit) throws InterruptedException,
|
||||
ExecutionException, TimeoutException {
|
||||
public Boolean get(long l, TimeUnit timeUnit) throws InterruptedException, ExecutionException,
|
||||
TimeoutException {
|
||||
try {
|
||||
return super.get(l, timeUnit);
|
||||
} catch (ExecutionException e) {
|
||||
|
|
|
@ -51,17 +51,14 @@ public class GetAccessControlList extends S3FutureCommand<AccessControlList> {
|
|||
@Inject
|
||||
public GetAccessControlList(@Named("jclouds.http.address") String amazonHost,
|
||||
ParseSax<AccessControlList> accessControlListParser,
|
||||
@Assisted("bucketName") String bucket)
|
||||
{
|
||||
@Assisted("bucketName") String bucket) {
|
||||
super("GET", "/?acl", accessControlListParser, amazonHost, bucket);
|
||||
}
|
||||
|
||||
@Inject
|
||||
public GetAccessControlList(@Named("jclouds.http.address") String amazonHost,
|
||||
ParseSax<AccessControlList> accessControlListParser,
|
||||
@Assisted("bucketName") String bucket,
|
||||
@Assisted("objectKey") String objectKey)
|
||||
{
|
||||
@Assisted("bucketName") String bucket, @Assisted("objectKey") String objectKey) {
|
||||
super("GET", "/" + objectKey + "?acl", accessControlListParser, amazonHost, bucket);
|
||||
}
|
||||
|
||||
|
@ -76,11 +73,10 @@ public class GetAccessControlList extends S3FutureCommand<AccessControlList> {
|
|||
|
||||
@VisibleForTesting
|
||||
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();
|
||||
if ("NoSuchBucket".equals(responseException.getError().getCode())
|
||||
|| "NoSuchObject".equals(responseException.getError().getCode()))
|
||||
{
|
||||
|| "NoSuchObject".equals(responseException.getError().getCode())) {
|
||||
return AccessControlList.NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
@ -88,8 +84,8 @@ public class GetAccessControlList extends S3FutureCommand<AccessControlList> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AccessControlList get(long l, TimeUnit timeUnit) throws InterruptedException, ExecutionException,
|
||||
TimeoutException {
|
||||
public AccessControlList get(long l, TimeUnit timeUnit) throws InterruptedException,
|
||||
ExecutionException, TimeoutException {
|
||||
try {
|
||||
return super.get(l, timeUnit);
|
||||
} 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.domain.S3Bucket;
|
||||
import org.jclouds.aws.s3.xml.ListBucketHandler;
|
||||
import org.jclouds.http.HttpResponseException;
|
||||
import org.jclouds.http.commands.callables.xml.ParseSax;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
|
@ -75,7 +74,7 @@ public class ListBucket extends S3FutureCommand<S3Bucket> {
|
|||
|
||||
@VisibleForTesting
|
||||
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();
|
||||
if ("NoSuchBucket".equals(responseException.getError().getCode())) {
|
||||
return S3Bucket.NOT_FOUND;
|
||||
|
|
Loading…
Reference in New Issue