Temporarily use a custom annotation instead of @SinceApiVersion.

The intention is to use @SinceApiVersion for this purpose, but that
would affect a number of APIs, and we would want to have good test
coverage before merging that change (in
FormSignerUtils#getAnnotatedApiVersion). However, there is some issue
wth certain tests at resent that means we cannot successfully test
all APIs that make use of @SinceApiVersion in order to assure
ourselves that FormSignerUtils will not introduce some problem.

See https://github.com/jclouds/jclouds/pull/1102#issuecomment-302682049
for details.

This annotation is introduced as a temporary measure in order to
decouple the functionality of FormSignerUtils#getAnnotatedApiVersion
from @SinceApiVersion and the tests in question. It can be removed and
replaced by @SinceApiVersion when those tests are fixed.

Designates that a method overrides the {@link ApiVersion} on the class
with a specific value.


Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/28c3c33b
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/28c3c33b
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/28c3c33b

Branch: refs/heads/master
Commit: 28c3c33bf07b4d4ddbd5516f952992088d09e76b
Parents: ce0a0ad
Author: Geoff Macartney <[email protected]>
Authored: Fri May 26 15:22:21 2017 +0100
Committer: Ignasi Barrera <[email protected]>
Committed: Mon May 29 10:24:52 2017 +0200

----------------------------------------------------------------------
 .../jclouds/aws/filters/FormSignerUtils.java    | 12 ++---
 .../rest/annotations/ApiVersionOverride.java    | 56 ++++++++++++++++++++
 .../jclouds/aws/ec2/features/AWSSubnetApi.java  |  3 +-
 3 files changed, 64 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/28c3c33b/apis/sts/src/main/java/org/jclouds/aws/filters/FormSignerUtils.java
----------------------------------------------------------------------
diff --git 
a/apis/sts/src/main/java/org/jclouds/aws/filters/FormSignerUtils.java 
b/apis/sts/src/main/java/org/jclouds/aws/filters/FormSignerUtils.java
index 84ff04b..4a5d6d6 100644
--- a/apis/sts/src/main/java/org/jclouds/aws/filters/FormSignerUtils.java
+++ b/apis/sts/src/main/java/org/jclouds/aws/filters/FormSignerUtils.java
@@ -18,7 +18,7 @@ package org.jclouds.aws.filters;
 
 import org.jclouds.http.HttpRequest;
 import org.jclouds.reflect.Invocation;
-import org.jclouds.rest.annotations.SinceApiVersion;
+import org.jclouds.rest.annotations.ApiVersionOverride;
 import org.jclouds.rest.internal.GeneratedHttpRequest;
 
 import com.google.common.base.Optional;
@@ -32,7 +32,7 @@ public final class FormSignerUtils {
    private FormSignerUtils() {}
 
    /**
-    * Get the version from a @SinceApiVersion() annotation on an API method or 
its owning class.
+    * Get the version from a @ApiVersionOverride() annotation on an API method 
or its owning class.
     * @param request The API request for the method.
     * @return An optional of the value of the annotation.
     */
@@ -47,12 +47,12 @@ public final class FormSignerUtils {
 
    private static Optional<String> getAnnotatedApiVersion(Invocation 
invocation) {
       final Invokable<?, ?> invokable = invocation.getInvokable();
-      if (invokable.isAnnotationPresent(SinceApiVersion.class)) {
-         return 
Optional.fromNullable(invokable.getAnnotation(SinceApiVersion.class).value());
+      if (invokable.isAnnotationPresent(ApiVersionOverride.class)) {
+         return 
Optional.fromNullable(invokable.getAnnotation(ApiVersionOverride.class).value());
       } else {
          final Class<?> owner = invokable.getOwnerType().getRawType();
-         if (owner.isAnnotationPresent(SinceApiVersion.class)) {
-            return 
Optional.fromNullable(owner.getAnnotation(SinceApiVersion.class).value());
+         if (owner.isAnnotationPresent(ApiVersionOverride.class)) {
+            return 
Optional.fromNullable(owner.getAnnotation(ApiVersionOverride.class).value());
          }
       }
       return Optional.absent();

http://git-wip-us.apache.org/repos/asf/jclouds/blob/28c3c33b/core/src/main/java/org/jclouds/rest/annotations/ApiVersionOverride.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/jclouds/rest/annotations/ApiVersionOverride.java 
b/core/src/main/java/org/jclouds/rest/annotations/ApiVersionOverride.java
new file mode 100644
index 0000000..0307806
--- /dev/null
+++ b/core/src/main/java/org/jclouds/rest/annotations/ApiVersionOverride.java
@@ -0,0 +1,56 @@
+/*
+ * 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.rest.annotations;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+
+/**
+ * @Deprecated The intention is to use @SinceApiVersion for this purpose, but 
that would affect
+ * a number of APIs, and we would want to have good test coverage before 
merging that change
+ * (in {@link FormSignerUtils#getAnnotatedApiVersion}). However, there is some 
issue with certain tests at
+ * present that means we cannot successfully test all APIs that make use of 
@SinceApiVersion in order
+ * to assure ourselves that FormSignerUtils will not introduce some problem. 
See
+ * <a 
href="https://github.com/jclouds/jclouds/pull/1102#issuecomment-302682049";>
+ *    comments on github</a> for details
+ * This annotation is introduced as a temporary measure in order to decouple 
the functionality of
+ * {@link FormSignerUtils#getAnnotatedApiVersion} from @SinceApiVersion and 
the tests in question.
+ * It can be removed and replaced by @SinceApiVersion when those tests are 
fixed.
+ *
+ * Designates that a method overrides the {@link ApiVersion} on the class with 
a specific value.
+ *
+ * @see ApiVersion
+ */
+@Deprecated
+@Target({ METHOD })
+@Retention(RUNTIME)
+@Qualifier
+public @interface ApiVersionOverride {
+
+   /**
+    * Value to override the default {@link ApiVersion}.
+    *
+    */
+   String value();
+
+}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/28c3c33b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSSubnetApi.java
----------------------------------------------------------------------
diff --git 
a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSSubnetApi.java
 
b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSSubnetApi.java
index b0f245a..f11699b 100644
--- 
a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSSubnetApi.java
+++ 
b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSSubnetApi.java
@@ -36,6 +36,7 @@ import org.jclouds.ec2.xml.DescribeSubnetsResponseHandler;
 import org.jclouds.ec2.xml.SubnetHandler;
 import org.jclouds.javax.annotation.Nullable;
 import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
+import org.jclouds.rest.annotations.ApiVersionOverride;
 import org.jclouds.rest.annotations.BinderParam;
 import org.jclouds.rest.annotations.EndpointParam;
 import org.jclouds.rest.annotations.Fallback;
@@ -141,7 +142,7 @@ public interface AWSSubnetApi extends SubnetApi {
     * @param options The options containing the attribute to modify. You can 
only modify one attribute at a time.
     * @return true if the modification was successful
     */
-   @SinceApiVersion("2014-06-15")
+   @ApiVersionOverride("2014-06-15")
    @Named("ModifySubnetAttribute")
    @POST
    @Path("/")

Reply via email to