mirror of https://github.com/apache/jclouds.git
Issue 149: updated to latest resteasy release
git-svn-id: http://jclouds.googlecode.com/svn/trunk@2669 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
f9fec120a7
commit
4407490ff0
|
@ -56,7 +56,7 @@
|
|||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-jaxrs-client</artifactId>
|
||||
<version>1.1.GA-SNAPSHOT</version>
|
||||
<version>1.2.1.GA-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.guice</groupId>
|
||||
|
|
|
@ -47,6 +47,7 @@ import javax.ws.rs.Consumes;
|
|||
import javax.ws.rs.FormParam;
|
||||
import javax.ws.rs.HeaderParam;
|
||||
import javax.ws.rs.MatrixParam;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
|
@ -316,6 +317,7 @@ public class RestAnnotationProcessor<T> {
|
|||
String httpMethod = getHttpMethodOrConstantOrThrowException(method);
|
||||
|
||||
UriBuilder builder = addHostPrefixIfPresent(endpoint, method, args);
|
||||
if (declaring.isAnnotationPresent(Path.class))
|
||||
builder.path(declaring);
|
||||
builder.path(method);
|
||||
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
</parent>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-jaxrs-client</artifactId>
|
||||
<version>1.1.GA-SNAPSHOT</version>
|
||||
<version>1.2.1.GA-SNAPSHOT</version>
|
||||
<name>RESTEasy JAX-RS Client Implementation</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>jaxrs-api</artifactId>
|
||||
<version>1.1.GA</version>
|
||||
<version>1.2.1.GA</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -1,21 +1,3 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.jboss.resteasy.specimpl;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
|
|
|
@ -1,21 +1,3 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.jboss.resteasy.specimpl;
|
||||
|
||||
import org.jboss.resteasy.util.Encode;
|
||||
|
@ -69,6 +51,23 @@ public class UriBuilderImpl extends UriBuilder
|
|||
|
||||
private static final Pattern uriPattern = Pattern.compile("([^:]+)://([^/:]+)(:(\\d+))?(/[^?]*)?(\\?([^#]+))?(#(.*))?");
|
||||
|
||||
/**
|
||||
* Must follow the patter scheme://host:port/path?query#fragment
|
||||
* <p/>
|
||||
* port, path, query and fragment are optional. Scheme and host must be specified.
|
||||
* <p/>
|
||||
* You may put path parameters anywhere within the uriTemplate except port
|
||||
*
|
||||
* @param uriTemplate
|
||||
* @return
|
||||
*/
|
||||
public static UriBuilder fromTemplate(String uriTemplate)
|
||||
{
|
||||
UriBuilderImpl impl = new UriBuilderImpl();
|
||||
impl.uriTemplate(uriTemplate);
|
||||
return impl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Must follow the patter scheme://host:port/path?query#fragment
|
||||
* <p/>
|
||||
|
@ -213,6 +212,10 @@ public class UriBuilderImpl extends UriBuilder
|
|||
String[] segments = new String[]{ann.value()};
|
||||
path = paths(true, path, segments);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("Class must be annotated with @Path to invoke path(Class)");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -330,7 +333,7 @@ public class UriBuilderImpl extends UriBuilder
|
|||
if (query != null)
|
||||
{
|
||||
buffer.append("?");
|
||||
replaceParameter(paramMap, isEncoded, query, buffer);
|
||||
replaceQueryStringParameter(paramMap, isEncoded, query, buffer);
|
||||
}
|
||||
if (fragment != null)
|
||||
{
|
||||
|
@ -397,6 +400,29 @@ public class UriBuilderImpl extends UriBuilder
|
|||
return buffer;
|
||||
}
|
||||
|
||||
protected StringBuffer replaceQueryStringParameter(Map<String, ? extends Object> paramMap, boolean isEncoded, String string, StringBuffer buffer)
|
||||
{
|
||||
Matcher matcher = createUriParamMatcher(string);
|
||||
while (matcher.find())
|
||||
{
|
||||
String param = matcher.group(1);
|
||||
String value = paramMap.get(param).toString();
|
||||
if (value != null)
|
||||
{
|
||||
if (!isEncoded)
|
||||
{
|
||||
value = Encode.encodeQueryStringNameOrValue(value);
|
||||
}
|
||||
matcher.appendReplacement(buffer, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("path param " + param + " has not been provided by the parameter map");
|
||||
}
|
||||
}
|
||||
matcher.appendTail(buffer);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a unique order list of path params
|
||||
|
@ -554,7 +580,7 @@ public class UriBuilderImpl extends UriBuilder
|
|||
{
|
||||
if (query == null) query = "";
|
||||
else query += "&";
|
||||
query += Encode.encodeQueryString(name) + "=" + Encode.encodeQueryString(value.toString());
|
||||
query += Encode.encodeQueryStringNameOrValue(name) + "=" + Encode.encodeQueryStringNameOrValue(value.toString());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -1,21 +1,3 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.jboss.resteasy.spi;
|
||||
|
||||
import org.jboss.resteasy.util.HttpResponseCodes;
|
||||
|
|
|
@ -1,21 +1,3 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.jboss.resteasy.spi;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
|
|
|
@ -1,21 +1,3 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.jboss.resteasy.util;
|
||||
|
||||
import org.jboss.resteasy.specimpl.MultivaluedMapImpl;
|
||||
|
@ -83,7 +65,7 @@ public class Encode
|
|||
return result;
|
||||
}
|
||||
|
||||
private static final Pattern nonCodes = Pattern.compile("%([^a-fA-F0-7]|$)");
|
||||
private static final Pattern nonCodes = Pattern.compile("%([^a-fA-F0-9]|$)");
|
||||
|
||||
public static String encodeNonCodes(String string)
|
||||
{
|
||||
|
@ -97,17 +79,29 @@ public class Encode
|
|||
return buf.toString();
|
||||
}
|
||||
|
||||
public static String encodeQueryString(String string)
|
||||
public static String encodeQueryStringNameOrValue(String string)
|
||||
{
|
||||
StringBuffer buf = new StringBuffer();
|
||||
List<String> params = new ArrayList<String>();
|
||||
boolean foundParam = false;
|
||||
if (savePathParams(string, buf, params))
|
||||
{
|
||||
foundParam = true;
|
||||
string = buf.toString();
|
||||
}
|
||||
try
|
||||
{
|
||||
string = URLEncoder.encode(string, "UTF-8").replace("+", "%20").replace("%25", "%");
|
||||
string = encodeNonCodes(string);
|
||||
string = URLEncoder.encode(string, "UTF-8").replace("%25", "%");
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
string = encodeNonCodes(string);
|
||||
if (foundParam)
|
||||
{
|
||||
return pathParamReplacement(string, params);
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
|
@ -166,7 +160,7 @@ public class Encode
|
|||
return segment;
|
||||
}
|
||||
|
||||
private static String pathParamReplacement(String segment, ArrayList<String> params)
|
||||
private static String pathParamReplacement(String segment, List<String> params)
|
||||
{
|
||||
StringBuffer newSegment = new StringBuffer();
|
||||
Matcher matcher = PARAM_REPLACEMENT.matcher(segment);
|
||||
|
|
|
@ -1,21 +1,3 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.jboss.resteasy.util;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,21 +1,3 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.jboss.resteasy.util;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
|
|
|
@ -1,21 +1,3 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.jboss.resteasy.util;
|
||||
|
||||
import org.jboss.resteasy.spi.LoggableFailure;
|
||||
|
|
|
@ -1,21 +1,3 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.
|
||||
* ====================================================================
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue