From 3be1089538c3be71e8454cc2599c40b94753dfee Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sat, 22 Dec 2012 17:45:31 -0800 Subject: [PATCH] removed explicit matrix param support as their use is edge case in rest --- ...GroupsAsNeededAndReturnRunOptionsTest.java | 2 - .../http/options/BaseHttpRequestOptions.java | 24 +--- .../org/jclouds/http/options/GetOptions.java | 5 +- .../http/options/HttpRequestOptions.java | 7 - .../rest/annotations/MatrixParams.java | 43 ------ .../internal/RestAnnotationProcessor.java | 70 ---------- .../rest/internal/SeedAnnotationCache.java | 2 - .../internal/RestAnnotationProcessorTest.java | 124 ------------------ .../jclouds/abiquo/binders/BindToPath.java | 13 +- .../abiquo/binders/BindToPathTest.java | 12 -- .../cdmi/v1/options/GetCDMIObjectOptions.java | 2 +- ...GroupsAsNeededAndReturnRunOptionsTest.java | 5 - .../miro/RimuHostingAsyncClient.java | 7 +- 13 files changed, 10 insertions(+), 306 deletions(-) delete mode 100644 core/src/main/java/org/jclouds/rest/annotations/MatrixParams.java diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java index 0c26af735c..9e5b491cff 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java @@ -145,7 +145,6 @@ public class CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest { customize.buildFormParameters().entries(), ImmutableMultimap. of("InstanceType", size.getProviderId(), "SecurityGroup.1", generatedGroup, "KeyName", systemGeneratedKeyPairName).entries()); - assertEquals(customize.buildMatrixParameters(), ImmutableMultimap. of()); assertEquals(customize.buildRequestHeaders(), ImmutableMultimap. of()); assertEquals(customize.buildStringPayload(), null); @@ -201,7 +200,6 @@ public class CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest { customize.buildFormParameters().entries(), ImmutableMultimap. of("InstanceType", size.getProviderId(), "SecurityGroup.1", "group", "KeyName", systemGeneratedKeyPairName, "UserData", CryptoStreams.base64("hello".getBytes())).entries()); - assertEquals(customize.buildMatrixParameters(), ImmutableMultimap. of()); assertEquals(customize.buildRequestHeaders(), ImmutableMultimap. of()); assertEquals(customize.buildStringPayload(), null); diff --git a/core/src/main/java/org/jclouds/http/options/BaseHttpRequestOptions.java b/core/src/main/java/org/jclouds/http/options/BaseHttpRequestOptions.java index 693b9cc987..80d7dbdf28 100644 --- a/core/src/main/java/org/jclouds/http/options/BaseHttpRequestOptions.java +++ b/core/src/main/java/org/jclouds/http/options/BaseHttpRequestOptions.java @@ -31,7 +31,6 @@ import com.google.common.collect.Multimap; */ public class BaseHttpRequestOptions implements HttpRequestOptions { - protected final Multimap matrixParameters = LinkedHashMultimap.create(); protected final Multimap formParameters = LinkedHashMultimap.create(); protected final Multimap queryParameters = LinkedHashMultimap.create(); protected final Multimap headers = LinkedHashMultimap.create(); @@ -42,11 +41,6 @@ public class BaseHttpRequestOptions implements HttpRequestOptions { return payload; } - protected String getFirstMatrixOrNull(String string) { - Collection values = matrixParameters.get(string); - return (values != null && values.size() >= 1) ? values.iterator().next() : null; - } - protected String getFirstQueryOrNull(String string) { Collection values = queryParameters.get(string); return (values != null && values.size() >= 1) ? values.iterator().next() : null; @@ -81,13 +75,6 @@ public class BaseHttpRequestOptions implements HttpRequestOptions { return queryParameters; } - /** - * {@inheritDoc} - */ - public Multimap buildMatrixParameters() { - return matrixParameters; - } - public String buildPathSuffix() { return pathSuffix; } @@ -102,7 +89,6 @@ public class BaseHttpRequestOptions implements HttpRequestOptions { int result = 1; result = prime * result + ((formParameters == null) ? 0 : formParameters.hashCode()); result = prime * result + ((headers == null) ? 0 : headers.hashCode()); - result = prime * result + ((matrixParameters == null) ? 0 : matrixParameters.hashCode()); result = prime * result + ((pathSuffix == null) ? 0 : pathSuffix.hashCode()); result = prime * result + ((payload == null) ? 0 : payload.hashCode()); result = prime * result + ((queryParameters == null) ? 0 : queryParameters.hashCode()); @@ -128,11 +114,6 @@ public class BaseHttpRequestOptions implements HttpRequestOptions { return false; } else if (!headers.equals(other.headers)) return false; - if (matrixParameters == null) { - if (other.matrixParameters != null) - return false; - } else if (!matrixParameters.equals(other.matrixParameters)) - return false; if (pathSuffix == null) { if (other.pathSuffix != null) return false; @@ -153,9 +134,8 @@ public class BaseHttpRequestOptions implements HttpRequestOptions { @Override public String toString() { - return "[formParameters=" + formParameters + ", headers=" + headers + ", matrixParameters=" - + matrixParameters + ", pathSuffix=" + pathSuffix + ", payload=" + payload - + ", queryParameters=" + queryParameters + "]"; + return "[formParameters=" + formParameters + ", headers=" + headers + ", pathSuffix=" + pathSuffix + ", payload=" + + payload + ", queryParameters=" + queryParameters + "]"; } } diff --git a/core/src/main/java/org/jclouds/http/options/GetOptions.java b/core/src/main/java/org/jclouds/http/options/GetOptions.java index 7c43557518..02ca5943c5 100644 --- a/core/src/main/java/org/jclouds/http/options/GetOptions.java +++ b/core/src/main/java/org/jclouds/http/options/GetOptions.java @@ -298,9 +298,8 @@ public class GetOptions extends BaseHttpRequestOptions { @Override public String toString() { - return "[matrixParameters=" + matrixParameters + ", formParameters=" + formParameters + ", queryParameters=" - + queryParameters + ", headers=" + headers + ", payload=" + payload + ", pathSuffix=" + pathSuffix - + ", ranges=" + ranges + "]"; + return "[formParameters=" + formParameters + ", queryParameters=" + queryParameters + ", headers=" + headers + + ", payload=" + payload + ", pathSuffix=" + pathSuffix + ", ranges=" + ranges + "]"; } } diff --git a/core/src/main/java/org/jclouds/http/options/HttpRequestOptions.java b/core/src/main/java/org/jclouds/http/options/HttpRequestOptions.java index 9cd58ad342..5945c6bc5f 100644 --- a/core/src/main/java/org/jclouds/http/options/HttpRequestOptions.java +++ b/core/src/main/java/org/jclouds/http/options/HttpRequestOptions.java @@ -49,13 +49,6 @@ public interface HttpRequestOptions { */ Multimap buildFormParameters(); - /** - * Builds matrix parameters representing options. - * - * @return multimap that may contain matrix parameters. - */ - Multimap buildMatrixParameters(); - String buildStringPayload(); String buildPathSuffix(); diff --git a/core/src/main/java/org/jclouds/rest/annotations/MatrixParams.java b/core/src/main/java/org/jclouds/rest/annotations/MatrixParams.java deleted file mode 100644 index 068d4fe760..0000000000 --- a/core/src/main/java/org/jclouds/rest/annotations/MatrixParams.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -/** - * Designates that a matrix param will be added to the request. - * - * @see MatrixParam - * @author Adrian Cole - */ -@Target( { TYPE, METHOD }) -@Retention(RUNTIME) -public @interface MatrixParams { - - public static final String NULL = "MATRIX_NULL"; - - String[] keys(); - - String[] values() default NULL; -} diff --git a/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java b/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java index a98badd49a..494c8ae88f 100644 --- a/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java +++ b/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java @@ -57,7 +57,6 @@ import javax.ws.rs.Consumes; import javax.ws.rs.FormParam; import javax.ws.rs.HeaderParam; import javax.ws.rs.HttpMethod; -import javax.ws.rs.MatrixParam; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; @@ -111,7 +110,6 @@ import org.jclouds.rest.annotations.FormParams; import org.jclouds.rest.annotations.Headers; import org.jclouds.rest.annotations.JAXBResponseParser; import org.jclouds.rest.annotations.MapBinder; -import org.jclouds.rest.annotations.MatrixParams; import org.jclouds.rest.annotations.OnlyElement; import org.jclouds.rest.annotations.OverrideRequestFilters; import org.jclouds.rest.annotations.ParamParser; @@ -182,7 +180,6 @@ public class RestAnnotationProcessor { static final LoadingCache>> methodToIndexOfParamToHeaderParamAnnotations = createMethodToIndexOfParamToAnnotation(HeaderParam.class); static final LoadingCache>> methodToIndexOfParamToEndpointAnnotations = createMethodToIndexOfParamToAnnotation(Endpoint.class); static final LoadingCache>> methodToIndexOfParamToEndpointParamAnnotations = createMethodToIndexOfParamToAnnotation(EndpointParam.class); - static final LoadingCache>> methodToIndexOfParamToMatrixParamAnnotations = createMethodToIndexOfParamToAnnotation(MatrixParam.class); static final LoadingCache>> methodToIndexOfParamToFormParamAnnotations = createMethodToIndexOfParamToAnnotation(FormParam.class); static final LoadingCache>> methodToIndexOfParamToQueryParamAnnotations = createMethodToIndexOfParamToAnnotation(QueryParam.class); static final LoadingCache>> methodToIndexOfParamToPathParamAnnotations = createMethodToIndexOfParamToAnnotation(PathParam.class); @@ -429,7 +426,6 @@ public class RestAnnotationProcessor { Multimap formParams = addFormParams(tokenValues.entries(), method, args); Multimap queryParams = addQueryParams(tokenValues.entries(), method, args); - Multimap matrixParams = addMatrixParams(tokenValues.entries(), method, args); Multimap headers = buildHeaders(tokenValues.entries(), method, args); if (r != null) headers.putAll(r.getHeaders()); @@ -447,9 +443,6 @@ public class RestAnnotationProcessor { for (Entry header : options.buildRequestHeaders().entries()) { headers.put(header.getKey(), Strings2.replaceTokens(header.getValue(), tokenValues.entries())); } - for (Entry matrix : options.buildMatrixParameters().entries()) { - matrixParams.put(matrix.getKey(), Strings2.replaceTokens(matrix.getValue(), tokenValues.entries())); - } for (Entry query : options.buildQueryParameters().entries()) { queryParams.put(query.getKey(), Strings2.replaceTokens(query.getValue(), tokenValues.entries())); } @@ -466,11 +459,6 @@ public class RestAnnotationProcessor { payload = Payloads.newStringPayload(stringPayload); } - if (matrixParams.size() > 0) { - for (String key : matrixParams.keySet()) - builder.matrixParam(key, Lists.newArrayList(matrixParams.get(key)).toArray()); - } - if (queryParams.size() > 0) { builder.replaceQuery(Queries.makeQueryLine(queryParams, null, skips)); } @@ -587,25 +575,6 @@ public class RestAnnotationProcessor { return builder.build(); } - private Multimap addMatrixParams(Collection> tokenValues, Method method, - Object... args) { - Multimap matrixMap = LinkedListMultimap.create(); - if (declaring.isAnnotationPresent(MatrixParams.class)) { - MatrixParams matrix = declaring.getAnnotation(MatrixParams.class); - addMatrix(matrixMap, matrix, tokenValues); - } - - if (method.isAnnotationPresent(MatrixParams.class)) { - MatrixParams matrix = method.getAnnotation(MatrixParams.class); - addMatrix(matrixMap, matrix, tokenValues); - } - - for (Entry matrix : getMatrixParamKeyValues(method, args).entries()) { - matrixMap.put(matrix.getKey(), Strings2.replaceTokens(matrix.getValue(), tokenValues)); - } - return matrixMap; - } - private Multimap addFormParams(Collection> tokenValues, Method method, Object... args) { Multimap formMap = LinkedListMultimap.create(); @@ -668,18 +637,6 @@ public class RestAnnotationProcessor { } } - private void addMatrix(Multimap matrixParams, MatrixParams matrix, - Collection> tokenValues) { - for (int i = 0; i < matrix.keys().length; i++) { - if (matrix.values()[i].equals(MatrixParams.NULL)) { - matrixParams.removeAll(matrix.keys()[i]); - matrixParams.put(matrix.keys()[i], null); - } else { - matrixParams.put(matrix.keys()[i], Strings2.replaceTokens(matrix.values()[i], tokenValues)); - } - } - } - private void addMapPayload(Map postParams, PayloadParams mapDefaults, Collection> tokenValues) { for (int i = 0; i < mapDefaults.keys().length; i++) { @@ -1249,33 +1206,6 @@ public class RestAnnotationProcessor { return encoded; } - //TODO: change to LoadingCache and move this logic to the CacheLoader. - private Multimap getMatrixParamKeyValues(Method method, Object... args) { - Multimap matrixParamValues = LinkedHashMultimap.create(); - LoadingCache> indexToMatrixParam = methodToIndexOfParamToMatrixParamAnnotations - .getUnchecked(method); - - LoadingCache> indexToParamExtractor = methodToIndexOfParamToParamParserAnnotations - .getUnchecked(method); - for (Entry> entry : indexToMatrixParam.asMap().entrySet()) { - for (Annotation key : entry.getValue()) { - Set extractors = indexToParamExtractor.getUnchecked(entry.getKey()); - String paramKey = ((MatrixParam) key).value(); - Optional paramValue = getParamValue(method, args, extractors, entry, paramKey); - if (paramValue.isPresent()) - matrixParamValues.put(paramKey, paramValue.get().toString()); - } - } - - if (method.isAnnotationPresent(MatrixParam.class) && method.isAnnotationPresent(ParamParser.class)) { - String paramKey = method.getAnnotation(MatrixParam.class).value(); - String paramValue = injector.getInstance(method.getAnnotation(ParamParser.class).value()).apply(args); - matrixParamValues.put(paramKey, paramValue); - - } - return matrixParamValues; - } - //TODO: change to LoadingCache and move this logic to the CacheLoader. //take care to manage size of this cache private Multimap getFormParamKeyValues(Method method, Object... args) { diff --git a/core/src/main/java/org/jclouds/rest/internal/SeedAnnotationCache.java b/core/src/main/java/org/jclouds/rest/internal/SeedAnnotationCache.java index 13e15ed6c9..2dbc3ad642 100644 --- a/core/src/main/java/org/jclouds/rest/internal/SeedAnnotationCache.java +++ b/core/src/main/java/org/jclouds/rest/internal/SeedAnnotationCache.java @@ -25,7 +25,6 @@ import static org.jclouds.rest.internal.RestAnnotationProcessor.methodToIndexOfP import static org.jclouds.rest.internal.RestAnnotationProcessor.methodToIndexOfParamToEndpointParamAnnotations; import static org.jclouds.rest.internal.RestAnnotationProcessor.methodToIndexOfParamToFormParamAnnotations; import static org.jclouds.rest.internal.RestAnnotationProcessor.methodToIndexOfParamToHeaderParamAnnotations; -import static org.jclouds.rest.internal.RestAnnotationProcessor.methodToIndexOfParamToMatrixParamAnnotations; import static org.jclouds.rest.internal.RestAnnotationProcessor.methodToIndexOfParamToParamParserAnnotations; import static org.jclouds.rest.internal.RestAnnotationProcessor.methodToIndexOfParamToPartParamAnnotations; import static org.jclouds.rest.internal.RestAnnotationProcessor.methodToIndexOfParamToPathParamAnnotations; @@ -84,7 +83,6 @@ public class SeedAnnotationCache extends CacheLoader, Boolean> { methodToIndexOfParamToBinderParamAnnotation.get(method).get(index); methodToIndexOfParamToWrapWithAnnotation.get(method).get(index); methodToIndexOfParamToHeaderParamAnnotations.get(method).get(index); - methodToIndexOfParamToMatrixParamAnnotations.get(method).get(index); methodToIndexOfParamToFormParamAnnotations.get(method).get(index); methodToIndexOfParamToQueryParamAnnotations.get(method).get(index); methodToIndexOfParamToEndpointAnnotations.get(method).get(index); diff --git a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java index d6b057b79d..1ece298a94 100644 --- a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java @@ -58,7 +58,6 @@ import javax.ws.rs.FormParam; import javax.ws.rs.GET; import javax.ws.rs.HeaderParam; import javax.ws.rs.HttpMethod; -import javax.ws.rs.MatrixParam; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; @@ -114,7 +113,6 @@ import org.jclouds.rest.annotations.FormParams; import org.jclouds.rest.annotations.Headers; import org.jclouds.rest.annotations.JAXBResponseParser; import org.jclouds.rest.annotations.MapBinder; -import org.jclouds.rest.annotations.MatrixParams; import org.jclouds.rest.annotations.OnlyElement; import org.jclouds.rest.annotations.OverrideRequestFilters; import org.jclouds.rest.annotations.ParamParser; @@ -1455,11 +1453,6 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void oneFormParamExtractor(@FormParam("one") @ParamParser(FirstCharacter.class) String one) { } - @GET - @Path("/") - public void oneMatrixParamExtractor(@MatrixParam("one") @ParamParser(FirstCharacter.class) String one) { - } - @GET @Path("/{path}") @PathParam("path") @@ -1495,25 +1488,6 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { assertNonPayloadHeadersEqual(request, ""); assertPayloadEquals(request, null, null, false); } - - @Test - public void testMatrixParamExtractor() throws SecurityException, NoSuchMethodException, IOException { - Method method = TestPath.class.getMethod("oneMatrixParamExtractor", String.class); - HttpRequest request = factory(TestPath.class).createRequest(method, new Object[] { "localhost" }); - assertRequestLineEquals(request, "GET http://localhost:9999/;one=l HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - } - - @Test - public void testNiceNPEMatrixParam() throws SecurityException, NoSuchMethodException, IOException { - Method method = TestPath.class.getMethod("oneMatrixParamExtractor", String.class); - try { - factory(TestPath.class).createRequest(method, (String) null); - } catch (NullPointerException e) { - assertEquals(e.getMessage(), "param{one} for method TestPath.oneMatrixParamExtractor"); - } - } @Test public void testFormParamExtractor() throws SecurityException, NoSuchMethodException, IOException { @@ -1730,104 +1704,6 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { assertEquals(query, "x-amz-copy-source=/eggs/robot"); } - public class TestReplaceMatrixOptions extends BaseHttpRequestOptions { - public TestReplaceMatrixOptions() { - this.matrixParameters.put("x-amz-copy-source", "/{bucket}"); - } - } - - @Test - public void testMatrixInOptions() throws SecurityException, NoSuchMethodException { - Method oneMatrix = TestMatrixReplace.class.getMethod("matrixInOptions", String.class, - TestReplaceMatrixOptions.class); - String path = factory(TestMatrixReplace.class) - .createRequest(oneMatrix, new Object[] { "robot", new TestReplaceMatrixOptions() }).getEndpoint().getPath(); - assertEquals(path, "/;x-amz-copy-source=/robot"); - } - - @Path("/") - public class TestMatrixReplace { - - @GET - @Path("/") - public void matrixInOptions(@PathParam("bucket") String path, TestReplaceMatrixOptions options) { - } - - @GET - @Path("/") - @MatrixParams(keys = "x-amz-copy-source", values = "/{bucket}") - public void oneMatrix(@PathParam("bucket") String path) { - } - - @GET - @Path("/") - @MatrixParams(keys = { "slash", "hyphen" }, values = { "/{bucket}", "-{bucket}" }) - public void twoMatrix(@PathParam("bucket") String path) { - } - - @GET - @Path("/") - @MatrixParams(keys = "x-amz-copy-source", values = "/{bucket}/{key}") - public void twoMatrixs(@PathParam("bucket") String path, @PathParam("key") String path2) { - } - - @GET - @Path("/") - @MatrixParams(keys = "x-amz-copy-source", values = "/{bucket}/{key}") - public void twoMatrixsOutOfOrder(@PathParam("key") String path, @PathParam("bucket") String path2) { - } - } - - @Test - public void testBuildTwoMatrix() throws SecurityException, NoSuchMethodException { - Method oneMatrix = TestMatrixReplace.class.getMethod("twoMatrix", String.class); - String path = factory(TestMatrixReplace.class).createRequest(oneMatrix, new Object[] { "robot" }).getEndpoint() - .getPath(); - assertEquals(path, "/;slash=/robot;hyphen=-robot"); - } - - @MatrixParams(keys = "x-amz-copy-source", values = "/{bucket}") - @Path("/") - public class TestClassMatrix { - @GET - @Path("/") - public void oneMatrix(@PathParam("bucket") String path) { - } - } - - @Test - public void testBuildOneClassMatrix() throws SecurityException, NoSuchMethodException { - Method oneMatrix = TestClassMatrix.class.getMethod("oneMatrix", String.class); - String path = factory(TestClassMatrix.class).createRequest(oneMatrix, new Object[] { "robot" }).getEndpoint() - .getPath(); - assertEquals(path, "/;x-amz-copy-source=/robot"); - } - - @Test - public void testBuildOneMatrix() throws SecurityException, NoSuchMethodException { - Method oneMatrix = TestMatrixReplace.class.getMethod("oneMatrix", String.class); - String path = factory(TestMatrixReplace.class).createRequest(oneMatrix, new Object[] { "robot" }).getEndpoint() - .getPath(); - assertEquals(path, "/;x-amz-copy-source=/robot"); - } - - @Test - public void testBuildTwoMatrixs() throws SecurityException, NoSuchMethodException { - Method twoMatrixs = TestMatrixReplace.class.getMethod("twoMatrixs", String.class, String.class); - String path = factory(TestMatrixReplace.class).createRequest(twoMatrixs, new Object[] { "robot", "eggs" }) - .getEndpoint().getPath(); - assertEquals(path, "/;x-amz-copy-source=/robot/eggs"); - } - - @Test - public void testBuildTwoMatrixsOutOfOrder() throws SecurityException, NoSuchMethodException { - Method twoMatrixsOutOfOrder = TestMatrixReplace.class.getMethod("twoMatrixsOutOfOrder", String.class, - String.class); - String path = factory(TestMatrixReplace.class) - .createRequest(twoMatrixsOutOfOrder, new Object[] { "robot", "eggs" }).getEndpoint().getPath(); - assertEquals(path, "/;x-amz-copy-source=/eggs/robot"); - } - public interface TestTransformers { @GET int noTransformer(); diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindToPath.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindToPath.java index a8da04c4f0..527873cb78 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindToPath.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindToPath.java @@ -107,7 +107,7 @@ public class BindToPath implements Binder { */ @SuppressWarnings("unchecked") static R bindToPath(final R request, final String endpoint) { - // Preserve current query and matrix parameters + // Preserve current query parameters String newEndpoint = endpoint + getParameterString(request); // Replace the URI with the edit link in the DTO @@ -126,20 +126,13 @@ public class BindToPath implements Binder { String endpoint = request.getEndpoint().toString(); int query = endpoint.indexOf('?'); - int matrix = endpoint.indexOf(';'); - if (query == -1 && matrix == -1) { + if (query == -1) { // No parameters return ""; - } else if (query != -1 && matrix != -1) { - // Both parameter types - return endpoint.substring(query < matrix ? query : matrix); - } else if (query != -1) { + } else { // Only request parameters return endpoint.substring(query); - } else { - // Only matrix parameters - return endpoint.substring(matrix); } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/BindToPathTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/BindToPathTest.java index 0e9c10534a..ec8e3a1daa 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/BindToPathTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/BindToPathTest.java @@ -127,18 +127,6 @@ public class BindToPathTest { assertEquals(newRequest.getRequestLine(), "GET http://linkuri?param=value HTTP/1.1"); } - public void testBindWithQueryAndMatrixParameters() throws SecurityException, NoSuchMethodException { - TestDto dto = new TestDto(); - Method withEndpointLink = TestEndpointLink.class.getMethod("withEndpointLink", TestDto.class); - GeneratedHttpRequest request = GeneratedHttpRequest.builder().declaring(TestEndpointLink.class) - .javaMethod(withEndpointLink).args(ImmutableList. of(dto)).method(HttpMethod.GET) - .endpoint(URI.create("http://localhost?param=value;matrix=value2")).build(); - - BindToPath binder = new BindToPath(); - GeneratedHttpRequest newRequest = binder.bindToRequest(request, dto); - assertEquals(newRequest.getRequestLine(), "GET http://linkuri?param=value;matrix=value2 HTTP/1.1"); - } - static interface TestEndpointLink { @GET void withEndpointLink(@EndpointLink("edit") TestDto dto); diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/GetCDMIObjectOptions.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/GetCDMIObjectOptions.java index 01d5f68b26..5cc4519570 100644 --- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/GetCDMIObjectOptions.java +++ b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/GetCDMIObjectOptions.java @@ -4,7 +4,7 @@ import org.jclouds.http.options.BaseHttpRequestOptions; /** * Optional get CDMI object options Note: We use BaseHttpRequestOptions.pathSuffix to include the - * CDMI query parameters rather than queryParam or MatrixParam because the CDMI specification is not + * CDMI query parameters rather than queryParam because the CDMI specification is not * following the standard usage. This is the summary of the CDMI specification: To read one or more * requested fields from an existing CDMI container object, one of the following requests shall be * performed: GET ///?;;... GET diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java index 7efa88908e..693de282b0 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java @@ -129,7 +129,6 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT customize.buildFormParameters().entries(), ImmutableMultimap. of("InstanceType", size.getProviderId(), "SecurityGroup.1", generatedGroup, "KeyName", systemGeneratedKeyPairName).entries()); - assertEquals(customize.buildMatrixParameters(), ImmutableMultimap. of()); assertEquals(customize.buildRequestHeaders(), ImmutableMultimap. of()); assertEquals(customize.buildStringPayload(), null); @@ -195,7 +194,6 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT ImmutableMultimap. of("InstanceType", size.getProviderId(), "SecurityGroup.1", generatedGroup, "KeyName", systemGeneratedKeyPairName, "Placement.GroupName", generatedGroup) .entries()); - assertEquals(customize.buildMatrixParameters(), ImmutableMultimap. of()); assertEquals(customize.buildRequestHeaders(), ImmutableMultimap. of()); assertEquals(customize.buildStringPayload(), null); @@ -261,7 +259,6 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT ImmutableMultimap. of("InstanceType", size.getProviderId(), "SecurityGroup.1", generatedGroup, "KeyName", systemGeneratedKeyPairName, "Placement.GroupName", generatedGroup) .entries()); - assertEquals(customize.buildMatrixParameters(), ImmutableMultimap. of()); assertEquals(customize.buildRequestHeaders(), ImmutableMultimap. of()); assertEquals(customize.buildStringPayload(), null); @@ -321,7 +318,6 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT customize.buildFormParameters().entries(), ImmutableMultimap. of("InstanceType", size.getProviderId(), "SubnetId", "1", "KeyName", systemGeneratedKeyPairName).entries()); - assertEquals(customize.buildMatrixParameters(), ImmutableMultimap. of()); assertEquals(customize.buildRequestHeaders(), ImmutableMultimap. of()); assertEquals(customize.buildStringPayload(), null); @@ -384,7 +380,6 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT customize.buildFormParameters().entries(), ImmutableMultimap. of("InstanceType", size.getProviderId(), "SecurityGroup.1", "group", "KeyName", systemGeneratedKeyPairName, "UserData", CryptoStreams.base64("hello".getBytes())).entries()); - assertEquals(customize.buildMatrixParameters(), ImmutableMultimap. of()); assertEquals(customize.buildRequestHeaders(), ImmutableMultimap. of()); assertEquals(customize.buildStringPayload(), null); diff --git a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClient.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClient.java index 9cc4ed3068..38f0e1eeb0 100644 --- a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClient.java +++ b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClient.java @@ -33,7 +33,6 @@ import javax.ws.rs.core.MediaType; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.MapBinder; -import org.jclouds.rest.annotations.MatrixParams; import org.jclouds.rest.annotations.PayloadParam; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.ResponseParser; @@ -83,9 +82,8 @@ public interface RimuHostingAsyncClient { * @see RimuHostingClient#getServerList */ @GET - @Path("/orders") + @Path("/orders;include_inactive=N") @ResponseParser(ParseServersFromJsonResponse.class) - @MatrixParams(keys = "include_inactive", values = "N") @Consumes(MediaType.APPLICATION_JSON) @ExceptionParser(ParseRimuHostingException.class) ListenableFuture> getServerList(); @@ -94,8 +92,7 @@ public interface RimuHostingAsyncClient { * @see RimuHostingClient#getPricingPlanList */ @GET - @Path("/pricing-plans") - @MatrixParams(keys = "server-type", values = "VPS") + @Path("/pricing-plans;server-type=VPS") @Consumes(MediaType.APPLICATION_JSON) @ExceptionParser(ParseRimuHostingException.class) @ResponseParser(ParsePricingPlansFromJsonResponse.class)