From dd4e31cbf0384a1114344602967dfc225b450ddb Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Sun, 6 Mar 2011 01:34:12 +0300 Subject: SONAR-2204,SONAR-2259 Fix URL encoding * For correct URL encoding we must encode parameters on lower level - in Query itself, but not in concrete implementation of Connector, because in Query we can distinguish concrete parts of URL. * Moreover in this case any additional encoding routines in Connector are useless, so were removed. --- .../wsclient/connectors/HttpClient3Connector.java | 94 ++++++++++------------ .../wsclient/connectors/HttpClient4Connector.java | 47 +++++++---- .../org/sonar/wsclient/services/AbstractQuery.java | 23 +++++- .../sonar/wsclient/services/DependencyQuery.java | 22 ++--- .../wsclient/services/DependencyTreeQuery.java | 20 +---- .../wsclient/services/FavouriteCreateQuery.java | 4 +- .../wsclient/services/FavouriteDeleteQuery.java | 2 +- .../org/sonar/wsclient/services/MetricQuery.java | 2 +- .../java/org/sonar/wsclient/services/Plugin.java | 1 - .../wsclient/services/PropertyCreateQuery.java | 2 +- .../wsclient/services/PropertyDeleteQuery.java | 2 +- .../org/sonar/wsclient/services/PropertyQuery.java | 2 +- .../wsclient/services/PropertyUpdateQuery.java | 2 +- .../org/sonar/wsclient/services/SourceQuery.java | 9 +-- .../sonar/wsclient/services/UpdateCenterQuery.java | 1 - .../wsclient/services/UserPropertyDeleteQuery.java | 2 +- .../sonar/wsclient/services/UserPropertyQuery.java | 4 +- .../wsclient/unmarshallers/PluginUnmarshaller.java | 1 - 18 files changed, 117 insertions(+), 123 deletions(-) (limited to 'sonar-ws-client/src/main') diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient3Connector.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient3Connector.java index 94cf646b6c9..25545be4446 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient3Connector.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient3Connector.java @@ -19,27 +19,35 @@ */ package org.sonar.wsclient.connectors; -import org.apache.commons.httpclient.*; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.UnsupportedEncodingException; + +import org.apache.commons.httpclient.Credentials; +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.HttpException; +import org.apache.commons.httpclient.HttpMethod; +import org.apache.commons.httpclient.HttpMethodBase; +import org.apache.commons.httpclient.HttpStatus; +import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; +import org.apache.commons.httpclient.UsernamePasswordCredentials; import org.apache.commons.httpclient.auth.AuthScope; import org.apache.commons.httpclient.methods.DeleteMethod; +import org.apache.commons.httpclient.methods.EntityEnclosingMethod; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.methods.PostMethod; import org.apache.commons.httpclient.methods.PutMethod; import org.apache.commons.httpclient.methods.StringRequestEntity; import org.apache.commons.httpclient.params.HttpConnectionManagerParams; -import org.apache.commons.httpclient.util.URIUtil; import org.sonar.wsclient.Host; +import org.sonar.wsclient.services.AbstractQuery; import org.sonar.wsclient.services.CreateQuery; import org.sonar.wsclient.services.DeleteQuery; import org.sonar.wsclient.services.Query; import org.sonar.wsclient.services.UpdateQuery; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.UnsupportedEncodingException; - /** * @since 2.1 */ @@ -123,61 +131,43 @@ public class HttpClient3Connector extends Connector { } private HttpMethodBase newGetRequest(Query query) { - try { - String url = server.getHost() + URIUtil.encodeQuery(query.getUrl()); - HttpMethodBase method = new GetMethod(url); - method.setRequestHeader("Accept", "application/json"); - return method; + HttpMethodBase method = new GetMethod(server.getHost() + query.getUrl()); + setJsonHeader(method); + return method; + } - } catch (URIException e) { - throw new ConnectionException("Query: " + query, e); - } + private HttpMethodBase newDeleteRequest(DeleteQuery query) { + HttpMethodBase method = new DeleteMethod(server.getHost() + query.getUrl()); + setJsonHeader(method); + return method; } private HttpMethodBase newPostRequest(CreateQuery query) { - try { - String url = server.getHost() + URIUtil.encodeQuery(query.getUrl()); - PostMethod method = new PostMethod(url); - method.setRequestHeader("Accept", "application/json"); - if (query.getBody() != null) { - method.setRequestEntity(new StringRequestEntity(query.getBody(), "text/plain; charset=UTF-8", "UTF-8")); - } - return method; - - } catch (URIException e) { - throw new ConnectionException("Query: " + query, e); - } catch (UnsupportedEncodingException e) { - throw new ConnectionException("Unsupported encoding", e); - } + PostMethod method = new PostMethod(server.getHost() + query.getUrl()); + setJsonHeader(method); + setRequestEntity(method, query); + return method; } private HttpMethodBase newPutRequest(UpdateQuery query) { - try { - String url = server.getHost() + URIUtil.encodeQuery(query.getUrl()); - PutMethod method = new PutMethod(url); - method.setRequestHeader("Accept", "application/json"); - if (query.getBody() != null) { - method.setRequestEntity(new StringRequestEntity(query.getBody(), "text/plain; charset=UTF-8", "UTF-8")); - } - return method; + PutMethod method = new PutMethod(server.getHost() + query.getUrl()); + setJsonHeader(method); + setRequestEntity(method, query); + return method; + } - } catch (URIException e) { - throw new ConnectionException("Query: " + query, e); - } catch (UnsupportedEncodingException e) { - throw new ConnectionException("Unsupported encoding", e); + private void setRequestEntity(EntityEnclosingMethod request, AbstractQuery query) { + if (query.getBody() != null) { + try { + request.setRequestEntity(new StringRequestEntity(query.getBody(), "text/plain; charset=UTF-8", "UTF-8")); + } catch (UnsupportedEncodingException e) { + throw new ConnectionException("Unsupported encoding", e); + } } } - private HttpMethodBase newDeleteRequest(DeleteQuery query) { - try { - String url = server.getHost() + URIUtil.encodeQuery(query.getUrl()); - HttpMethodBase method = new DeleteMethod(url); - method.setRequestHeader("Accept", "application/json"); - return method; - - } catch (URIException e) { - throw new ConnectionException("Query: " + query, e); - } + private void setJsonHeader(HttpMethodBase request) { + request.setRequestHeader("Accept", "application/json"); } private String getResponseBodyAsString(HttpMethod method) { diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient4Connector.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient4Connector.java index d85796ebc55..382f5bd3614 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient4Connector.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient4Connector.java @@ -19,10 +19,24 @@ */ package org.sonar.wsclient.connectors; -import org.apache.http.*; -import org.apache.http.auth.*; +import java.io.IOException; +import java.io.UnsupportedEncodingException; + +import org.apache.http.HttpEntity; +import org.apache.http.HttpException; +import org.apache.http.HttpHost; +import org.apache.http.HttpRequest; +import org.apache.http.HttpRequestInterceptor; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.auth.AuthScheme; +import org.apache.http.auth.AuthScope; +import org.apache.http.auth.AuthState; +import org.apache.http.auth.Credentials; +import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.CredentialsProvider; import org.apache.http.client.methods.HttpDelete; +import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPut; @@ -38,14 +52,12 @@ import org.apache.http.protocol.ExecutionContext; import org.apache.http.protocol.HttpContext; import org.apache.http.util.EntityUtils; import org.sonar.wsclient.Host; +import org.sonar.wsclient.services.AbstractQuery; import org.sonar.wsclient.services.CreateQuery; import org.sonar.wsclient.services.DeleteQuery; import org.sonar.wsclient.services.Query; import org.sonar.wsclient.services.UpdateQuery; -import java.io.IOException; -import java.io.UnsupportedEncodingException; - /** * @since 2.1 */ @@ -85,7 +97,9 @@ public class HttpClient4Connector extends Connector { json = EntityUtils.toString(entity); } else if (response.getStatusLine().getStatusCode() != HttpStatus.SC_NOT_FOUND) { - throw new ConnectionException("HTTP error: " + response.getStatusLine().getStatusCode() + ", msg: " + response.getStatusLine().getReasonPhrase() + ", query: " + request.toString()); + throw new ConnectionException("HTTP error: " + response.getStatusLine().getStatusCode() + + ", msg: " + response.getStatusLine().getReasonPhrase() + + ", query: " + request.toString()); } } @@ -104,7 +118,8 @@ public class HttpClient4Connector extends Connector { HttpConnectionParams.setConnectionTimeout(params, TIMEOUT_MS); HttpConnectionParams.setSoTimeout(params, TIMEOUT_MS); if (server.getUsername() != null) { - client.getCredentialsProvider().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(server.getUsername(), server.getPassword())); + client.getCredentialsProvider() + .setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(server.getUsername(), server.getPassword())); } return client; } @@ -138,28 +153,26 @@ public class HttpClient4Connector extends Connector { private HttpPost newPostMethod(CreateQuery query) { HttpPost post = new HttpPost(server.getHost() + query.getUrl()); - if (query.getBody() != null) { - try { - post.setEntity(new StringEntity(query.getBody(), "UTF-8")); - } catch (UnsupportedEncodingException e) { - throw new ConnectionException("Encoding is not supported", e); - } - } setJsonHeader(post); + setRequestEntity(post, query); return post; } private HttpPut newPutMethod(UpdateQuery query) { HttpPut put = new HttpPut(server.getHost() + query.getUrl()); + setJsonHeader(put); + setRequestEntity(put, query); + return put; + } + + private void setRequestEntity(HttpEntityEnclosingRequestBase request, AbstractQuery query) { if (query.getBody() != null) { try { - put.setEntity(new StringEntity(query.getBody(), "UTF-8")); + request.setEntity(new StringEntity(query.getBody(), "UTF-8")); } catch (UnsupportedEncodingException e) { throw new ConnectionException("Encoding is not supported", e); } } - setJsonHeader(put); - return put; } private void setJsonHeader(HttpRequestBase request) { diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/AbstractQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/AbstractQuery.java index 923830480e4..288dfba7ee2 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/AbstractQuery.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/AbstractQuery.java @@ -28,21 +28,36 @@ public abstract class AbstractQuery { /** * Must start with a slash, for example: /api/metrics + *

+ * IMPORTANT: In implementations of this method we must use helper methods to construct URL. + *

+ * + * @see #encode(String) + * @see #appendUrlParameter(StringBuilder, String, Object) + * @see #appendUrlParameter(StringBuilder, String, Object[]) + * @see #appendUrlParameter(StringBuilder, String, Date, boolean) */ public abstract String getUrl(); /** - * Request body. By defaut it is empty but it can be overriden. + * Request body. By default it is empty but it can be overridden. */ public String getBody() { return null; } + /** + * Encodes single parameter value. + */ + protected static String encode(String value) { + return WSUtils.getINSTANCE().encodeUrl(value); + } + protected static void appendUrlParameter(StringBuilder url, String paramKey, Object paramValue) { if (paramValue != null) { url.append(paramKey) .append('=') - .append(paramValue) + .append(encode(paramValue.toString())) .append('&'); } } @@ -55,7 +70,7 @@ public abstract class AbstractQuery { url.append(','); } if (paramValues[index] != null) { - url.append(paramValues[index]); + url.append(encode(paramValues[index].toString())); } } url.append('&'); @@ -67,7 +82,7 @@ public abstract class AbstractQuery { String format = (includeTime ? "yyyy-MM-dd'T'HH:mm:ssZ" : "yyyy-MM-dd"); url.append(paramKey) .append('=') - .append(WSUtils.getINSTANCE().encodeUrl(WSUtils.getINSTANCE().format(paramValue, format))) + .append(encode(WSUtils.getINSTANCE().format(paramValue, format))) .append('&'); } } diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/DependencyQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/DependencyQuery.java index 65e4447c7f2..5c20923c731 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/DependencyQuery.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/DependencyQuery.java @@ -59,18 +59,10 @@ public class DependencyQuery extends Query { public String getUrl() { StringBuilder url = new StringBuilder(BASE_URL); url.append('?'); - if (resourceIdOrKey != null) { - url.append("resource=").append(resourceIdOrKey).append('&'); - } - if (direction != null) { - url.append("dir=").append(direction).append('&'); - } - if (parentId !=null) { - url.append("parent=").append(parentId).append('&'); - } - if (id !=null) { - url.append("id=").append(id).append('&'); - } + appendUrlParameter(url, "resource", resourceIdOrKey); + appendUrlParameter(url, "dir", direction); + appendUrlParameter(url, "parent", parentId); + appendUrlParameter(url, "id", id); return url.toString(); } @@ -99,7 +91,7 @@ public class DependencyQuery extends Query { /** * Resources that depend upon a resource - * + * * @param resourceIdOrKey the target resource. Can be the primary key (a number) or the logical key (String) */ public static DependencyQuery createForIncomingDependencies(String resourceIdOrKey) { @@ -111,7 +103,7 @@ public class DependencyQuery extends Query { /** * Resources that are depended upon a resource = all the resources that a resource depends upon - * + * * @param resourceIdOrKey the target resource. Can be the primary key (an integer) or the logical key (String) */ public static DependencyQuery createForOutgoingDependencies(String resourceIdOrKey) { @@ -124,7 +116,7 @@ public class DependencyQuery extends Query { /** * Resources that depend upon or are depended upon a resource. It equals the merge of createForIncomingDependencies(resourceIdOrKey) * and createForOutgoingDependencies(resourceIdOrKey) - * + * * @param resourceIdOrKey the target resource. Can be the primary key (an integer) or the logical key (String) */ public static DependencyQuery createForResource(String resourceIdOrKey) { diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/DependencyTreeQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/DependencyTreeQuery.java index 27e25081a52..552de333a4e 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/DependencyTreeQuery.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/DependencyTreeQuery.java @@ -53,23 +53,9 @@ public class DependencyTreeQuery extends Query { @Override public String getUrl() { StringBuilder url = new StringBuilder(BASE_URL); - url.append("?resource=") - .append(resourceId) - .append("&"); - if (scopes != null) { - url.append("scopes="); - if (scopes != null) { - for (int index = 0; index < scopes.length; index++) { - if (index > 0) { - url.append(','); - } - if (scopes[index] != null) { - url.append(scopes[index]); - } - } - url.append('&'); - } - } + url.append('?'); + appendUrlParameter(url, "resource", resourceId); + appendUrlParameter(url, "scopes", scopes); return url.toString(); } diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/FavouriteCreateQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/FavouriteCreateQuery.java index 9ec9958e3ec..a22b11bfc78 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/FavouriteCreateQuery.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/FavouriteCreateQuery.java @@ -29,7 +29,9 @@ public class FavouriteCreateQuery extends CreateQuery { @Override public String getUrl() { - return new StringBuilder().append(FavouriteQuery.BASE_URL).append("?key=").append(idOrKey).toString(); + StringBuilder url = new StringBuilder(FavouriteQuery.BASE_URL).append('?'); + appendUrlParameter(url, "key", idOrKey); + return url.toString(); } @Override diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/FavouriteDeleteQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/FavouriteDeleteQuery.java index b1d64eaca7b..40ac6d21e79 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/FavouriteDeleteQuery.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/FavouriteDeleteQuery.java @@ -33,6 +33,6 @@ public class FavouriteDeleteQuery extends DeleteQuery { @Override public String getUrl() { - return new StringBuilder().append(FavouriteQuery.BASE_URL).append('/').append(idOrKey).toString(); + return new StringBuilder().append(FavouriteQuery.BASE_URL).append('/').append(encode(idOrKey)).toString(); } } diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/MetricQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/MetricQuery.java index 708d4836639..b0647b2f7b0 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/MetricQuery.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/MetricQuery.java @@ -36,7 +36,7 @@ public final class MetricQuery extends Query { StringBuilder sb = new StringBuilder(BASE_URL); if (key != null && !"".equals(key)) { sb.append("/"); - sb.append(key); + sb.append(encode(key)); } sb.append("?"); return sb.toString(); diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Plugin.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Plugin.java index 5c945ce6205..f2159494d3b 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Plugin.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Plugin.java @@ -17,7 +17,6 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ - package org.sonar.wsclient.services; /** diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyCreateQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyCreateQuery.java index 2a1f9d46514..bc26094bdfa 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyCreateQuery.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyCreateQuery.java @@ -78,7 +78,7 @@ public class PropertyCreateQuery extends CreateQuery { public String getUrl() { StringBuilder url = new StringBuilder(); url.append(PropertyQuery.BASE_URL); - url.append("/").append(key); + url.append("/").append(encode(key)); url.append('?'); appendUrlParameter(url, "value", value); appendUrlParameter(url, "resource", resourceKeyOrId); diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyDeleteQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyDeleteQuery.java index 316059671c4..8e6b7b119dd 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyDeleteQuery.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyDeleteQuery.java @@ -62,7 +62,7 @@ public class PropertyDeleteQuery extends DeleteQuery { public String getUrl() { StringBuilder url = new StringBuilder(); url.append(PropertyQuery.BASE_URL); - url.append("/").append(key); + url.append("/").append(encode(key)); url.append('?'); appendUrlParameter(url, "resource", resourceKeyOrId); return url.toString(); diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyQuery.java index d4dbbfd2d54..21715c96be8 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyQuery.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyQuery.java @@ -47,7 +47,7 @@ public class PropertyQuery extends Query { public String getUrl() { StringBuilder url = new StringBuilder(BASE_URL); if (key != null) { - url.append("/").append(key); + url.append("/").append(encode(key)); } url.append('?'); appendUrlParameter(url, "resource", resourceKeyOrId); diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyUpdateQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyUpdateQuery.java index 749870393ce..35964e16d39 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyUpdateQuery.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyUpdateQuery.java @@ -78,7 +78,7 @@ public class PropertyUpdateQuery extends UpdateQuery { public String getUrl() { StringBuilder url = new StringBuilder(); url.append(PropertyQuery.BASE_URL); - url.append("/").append(key); + url.append("/").append(encode(key)); url.append('?'); appendUrlParameter(url, "resource", resourceKeyOrId); return url.toString(); diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/SourceQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/SourceQuery.java index d4c9070fa34..64cde183f34 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/SourceQuery.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/SourceQuery.java @@ -46,8 +46,8 @@ public class SourceQuery extends Query { /** * Get only a few lines - * - * @param from Index of the first line, starts to 1 + * + * @param from Index of the first line, starts to 1 * @param excludedTo Index of the last line (excluded). */ public SourceQuery setFromLineToLine(int from, int excludedTo) { @@ -78,9 +78,8 @@ public class SourceQuery extends Query { @Override public String getUrl() { StringBuilder url = new StringBuilder(BASE_URL); - url.append("?resource=") - .append(resourceKeyOrId) - .append("&"); + url.append('?'); + appendUrlParameter(url, "resource", resourceKeyOrId); if (from > 0 && to > 0) { url.append("from=").append(from).append("&to=").append(to).append("&"); } diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UpdateCenterQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UpdateCenterQuery.java index daef570e499..19a3b989cb4 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UpdateCenterQuery.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UpdateCenterQuery.java @@ -17,7 +17,6 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ - package org.sonar.wsclient.services; /** diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UserPropertyDeleteQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UserPropertyDeleteQuery.java index 972cc8d4e34..81f1e182134 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UserPropertyDeleteQuery.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UserPropertyDeleteQuery.java @@ -45,6 +45,6 @@ public class UserPropertyDeleteQuery extends DeleteQuery { @Override public String getUrl() { - return new StringBuilder().append(UserPropertyQuery.BASE_URL).append('/').append(key).toString(); + return new StringBuilder().append(UserPropertyQuery.BASE_URL).append('/').append(encode(key)).toString(); } } diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UserPropertyQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UserPropertyQuery.java index 999375228d4..6307b596b07 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UserPropertyQuery.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UserPropertyQuery.java @@ -21,7 +21,7 @@ package org.sonar.wsclient.services; /** * Get properties of the authenticated user. - * + * * @since 2.2 */ public class UserPropertyQuery extends Query { @@ -55,7 +55,7 @@ public class UserPropertyQuery extends Query { public String getUrl() { String url = BASE_URL; if (key != null) { - url += "/" + key; + url += "/" + encode(key); } return url + "?"; } diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/PluginUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/PluginUnmarshaller.java index d3b0917de24..3c5f9b69dc1 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/PluginUnmarshaller.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/PluginUnmarshaller.java @@ -17,7 +17,6 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ - package org.sonar.wsclient.unmarshallers; import org.sonar.wsclient.services.Plugin; -- cgit v1.2.3