Repository: jclouds-labs-aws Updated Branches: refs/heads/master b3180ce98 -> c781a1dfa
Renamed FalseIfVaultNotEmpty to be more generic. deleteVault should return false on any IllegalArgumentException. Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/commit/c781a1df Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/tree/c781a1df Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/diff/c781a1df Branch: refs/heads/master Commit: c781a1dfa26086b9ae109790a8867d745a9a17d5 Parents: b3180ce Author: Roman C. Coedo <[email protected]> Authored: Sat May 31 11:58:19 2014 +0200 Committer: Andrew Gaul <[email protected]> Committed: Tue Jun 10 14:37:02 2014 -0700 ---------------------------------------------------------------------- .../org/jclouds/glacier/GlacierAsyncClient.java | 6 +-- .../java/org/jclouds/glacier/GlacierClient.java | 4 +- .../glacier/fallbacks/FalseIfVaultNotEmpty.java | 45 -------------------- .../FalseOnIllegalArgumentException.java | 45 ++++++++++++++++++++ .../filters/RequestAuthorizeSignature.java | 8 ++-- .../glacier/util/AWSRequestSignerV4.java | 6 +-- .../jclouds/glacier/GlacierClientMockTest.java | 2 + 7 files changed, 59 insertions(+), 57 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/blob/c781a1df/glacier/src/main/java/org/jclouds/glacier/GlacierAsyncClient.java ---------------------------------------------------------------------- diff --git a/glacier/src/main/java/org/jclouds/glacier/GlacierAsyncClient.java b/glacier/src/main/java/org/jclouds/glacier/GlacierAsyncClient.java index 2e92a3c..90eeb5b 100644 --- a/glacier/src/main/java/org/jclouds/glacier/GlacierAsyncClient.java +++ b/glacier/src/main/java/org/jclouds/glacier/GlacierAsyncClient.java @@ -32,7 +32,7 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.blobstore.attr.BlobScope; import org.jclouds.glacier.domain.PaginatedVaultCollection; import org.jclouds.glacier.domain.VaultMetadata; -import org.jclouds.glacier.fallbacks.FalseIfVaultNotEmpty; +import org.jclouds.glacier.fallbacks.FalseOnIllegalArgumentException; import org.jclouds.glacier.filters.RequestAuthorizeSignature; import org.jclouds.glacier.functions.ParseVaultMetadataFromHttpContent; import org.jclouds.glacier.functions.ParseVaultMetadataListFromHttpContent; @@ -73,8 +73,8 @@ public interface GlacierAsyncClient extends Closeable { @Named("DeleteVault") @DELETE @Path("/-/vaults/{vault}") - @Fallback(FalseIfVaultNotEmpty.class) - ListenableFuture<Boolean> deleteVault(@PathParam("vault") @ParamValidators(VaultNameValidator.class) String vaultName); + @Fallback(FalseOnIllegalArgumentException.class) + ListenableFuture<Boolean> deleteVault(@PathParam("vault") String vaultName); /** * @see GlacierClient#describeVault http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/blob/c781a1df/glacier/src/main/java/org/jclouds/glacier/GlacierClient.java ---------------------------------------------------------------------- diff --git a/glacier/src/main/java/org/jclouds/glacier/GlacierClient.java b/glacier/src/main/java/org/jclouds/glacier/GlacierClient.java index 80070f7..aba9422 100644 --- a/glacier/src/main/java/org/jclouds/glacier/GlacierClient.java +++ b/glacier/src/main/java/org/jclouds/glacier/GlacierClient.java @@ -43,7 +43,7 @@ public interface GlacierClient extends Closeable { URI createVault(String vaultName); /** - * A DELETE request operation with a vault name to delete an existing vault. + * Deletes a vault. * * @param vaultName * Name of the Vault being deleted. @@ -73,7 +73,7 @@ public interface GlacierClient extends Closeable { PaginatedVaultCollection listVaults(PaginationOptions options); /** - * List vaults. + * Lists vaults. * * @see GlacierClient#listVaults(PaginationOptions) */ http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/blob/c781a1df/glacier/src/main/java/org/jclouds/glacier/fallbacks/FalseIfVaultNotEmpty.java ---------------------------------------------------------------------- diff --git a/glacier/src/main/java/org/jclouds/glacier/fallbacks/FalseIfVaultNotEmpty.java b/glacier/src/main/java/org/jclouds/glacier/fallbacks/FalseIfVaultNotEmpty.java deleted file mode 100644 index 0bbecb2..0000000 --- a/glacier/src/main/java/org/jclouds/glacier/fallbacks/FalseIfVaultNotEmpty.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.jclouds.glacier.fallbacks; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Throwables.propagate; -import static com.google.common.util.concurrent.Futures.immediateFuture; -import static org.jclouds.util.Throwables2.getFirstThrowableOfType; - -import org.jclouds.Fallback; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Fallback used when deleting a vault. - */ -public class FalseIfVaultNotEmpty implements Fallback<Boolean> { - - @Override - public ListenableFuture<Boolean> create(Throwable t) throws Exception { - return immediateFuture(createOrPropagate(t)); - } - - @Override - public Boolean createOrPropagate(Throwable t) throws Exception { - if (getFirstThrowableOfType(checkNotNull(t, "throwable"), IllegalArgumentException.class) != null) - return false; - throw propagate(t); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/blob/c781a1df/glacier/src/main/java/org/jclouds/glacier/fallbacks/FalseOnIllegalArgumentException.java ---------------------------------------------------------------------- diff --git a/glacier/src/main/java/org/jclouds/glacier/fallbacks/FalseOnIllegalArgumentException.java b/glacier/src/main/java/org/jclouds/glacier/fallbacks/FalseOnIllegalArgumentException.java new file mode 100644 index 0000000..08839a2 --- /dev/null +++ b/glacier/src/main/java/org/jclouds/glacier/fallbacks/FalseOnIllegalArgumentException.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.jclouds.glacier.fallbacks; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Throwables.propagate; +import static com.google.common.util.concurrent.Futures.immediateFuture; +import static org.jclouds.util.Throwables2.getFirstThrowableOfType; + +import org.jclouds.Fallback; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Returns false when encountering an IllegalArgumentException. + */ +public class FalseOnIllegalArgumentException implements Fallback<Boolean> { + + @Override + public ListenableFuture<Boolean> create(Throwable t) throws Exception { + return immediateFuture(createOrPropagate(t)); + } + + @Override + public Boolean createOrPropagate(Throwable t) throws Exception { + if (getFirstThrowableOfType(checkNotNull(t, "throwable"), IllegalArgumentException.class) != null) + return false; + throw propagate(t); + } + +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/blob/c781a1df/glacier/src/main/java/org/jclouds/glacier/filters/RequestAuthorizeSignature.java ---------------------------------------------------------------------- diff --git a/glacier/src/main/java/org/jclouds/glacier/filters/RequestAuthorizeSignature.java b/glacier/src/main/java/org/jclouds/glacier/filters/RequestAuthorizeSignature.java index 8b6133f..e530903 100644 --- a/glacier/src/main/java/org/jclouds/glacier/filters/RequestAuthorizeSignature.java +++ b/glacier/src/main/java/org/jclouds/glacier/filters/RequestAuthorizeSignature.java @@ -57,10 +57,10 @@ public class RequestAuthorizeSignature implements HttpRequestFilter { @Inject public RequestAuthorizeSignature(@TimeStamp Provider<String> timeStampProvider, @org.jclouds.location.Provider Supplier<Credentials> creds, Crypto crypto, HttpUtils utils) { - checkNotNull(creds); - this.signer = new AWSRequestSignerV4(creds.get().identity, creds.get().credential, checkNotNull(crypto)); - this.timeStampProvider = checkNotNull(timeStampProvider); - this.utils = checkNotNull(utils); + checkNotNull(creds, "creds"); + this.signer = new AWSRequestSignerV4(creds.get().identity, creds.get().credential, checkNotNull(crypto, "crypto")); + this.timeStampProvider = checkNotNull(timeStampProvider, "timeStampProvider"); + this.utils = checkNotNull(utils, "utils"); } @Override http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/blob/c781a1df/glacier/src/main/java/org/jclouds/glacier/util/AWSRequestSignerV4.java ---------------------------------------------------------------------- diff --git a/glacier/src/main/java/org/jclouds/glacier/util/AWSRequestSignerV4.java b/glacier/src/main/java/org/jclouds/glacier/util/AWSRequestSignerV4.java index 4c85ab0..8c85ae3 100644 --- a/glacier/src/main/java/org/jclouds/glacier/util/AWSRequestSignerV4.java +++ b/glacier/src/main/java/org/jclouds/glacier/util/AWSRequestSignerV4.java @@ -62,9 +62,9 @@ public class AWSRequestSignerV4 { private final String credential; public AWSRequestSignerV4(String identity, String credential, Crypto crypto) { - this.crypto = checkNotNull(crypto); - this.identity = checkNotNull(identity); - this.credential = checkNotNull(credential); + this.crypto = checkNotNull(crypto, "crypto"); + this.identity = checkNotNull(identity, "identity"); + this.credential = checkNotNull(credential, "credential"); } private static String buildHashedCanonicalRequest(String method, String endpoint, String hashedPayload, http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/blob/c781a1df/glacier/src/test/java/org/jclouds/glacier/GlacierClientMockTest.java ---------------------------------------------------------------------- diff --git a/glacier/src/test/java/org/jclouds/glacier/GlacierClientMockTest.java b/glacier/src/test/java/org/jclouds/glacier/GlacierClientMockTest.java index 63b5935..c7f1525 100644 --- a/glacier/src/test/java/org/jclouds/glacier/GlacierClientMockTest.java +++ b/glacier/src/test/java/org/jclouds/glacier/GlacierClientMockTest.java @@ -35,6 +35,7 @@ import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.glacier.domain.PaginatedVaultCollection; import org.jclouds.glacier.domain.VaultMetadata; import org.jclouds.glacier.options.PaginationOptions; +import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; import com.google.inject.Module; @@ -45,6 +46,7 @@ import com.google.mockwebserver.RecordedRequest; /** * Mock test for Glacier. */ +@Test public class GlacierClientMockTest { private static final String VAULT_NAME = "ConcreteVaultName";
