diff --git a/scm-core/src/main/java/sonia/scm/net/HttpClient.java b/scm-core/src/main/java/sonia/scm/net/HttpClient.java index 590f682e14..b9b891f557 100644 --- a/scm-core/src/main/java/sonia/scm/net/HttpClient.java +++ b/scm-core/src/main/java/sonia/scm/net/HttpClient.java @@ -41,31 +41,37 @@ import java.util.List; import java.util.Map; /** + * Simple client for http operations. * * @author Sebastian Sdorra + * + * @apiviz.landmark + * @apiviz.uses sonia.scm.net.HttpRequest + * @apiviz.uses sonia.scm.net.HttpResponse */ public interface HttpClient { /** - * Method description + * Send a post request to the given url. * * - * @param url + * @param url url for post request * - * @return + * @return the response of the http request * * @throws IOException */ public HttpResponse post(String url) throws IOException; /** - * Method description + * Sends a post request with the parameter specified in the + * {@link HttpRequest} object. * * - * @param request + * @param request request object * - * @return + * @return the response of the http request * @since 1.9 * * @throws IOException @@ -73,13 +79,13 @@ public interface HttpClient public HttpResponse post(HttpRequest request) throws IOException; /** - * Method description + * Send a post request to the given url with the specified post parameters. * * - * @param url - * @param parameters + * @param url url for post request + * @param parameters parameters for the post request * - * @return + * @return the response of the http request * * @throws IOException */ @@ -89,24 +95,25 @@ public interface HttpClient //~--- get methods ---------------------------------------------------------- /** - * Method description + * Send a get request to the given url. * * - * @param url + * @param url url for get request * - * @return + * @return the response of the http request * * @throws IOException */ public HttpResponse get(String url) throws IOException; /** - * Method description + * Sends a get request with the parameter specified in the + * {@link HttpRequest} object. * * - * @param request + * @param request request object * - * @return + * @return the response of the http request * @since 1.9 * * @throws IOException @@ -114,13 +121,13 @@ public interface HttpClient public HttpResponse get(HttpRequest request) throws IOException; /** - * Method description + * Send a get request to the given url with the specified post parameters. * * - * @param url - * @param parameters + * @param url url for get request + * @param parameters parameters for the get request * - * @return + * @return the response of the http request * * @throws IOException */ diff --git a/scm-core/src/main/java/sonia/scm/net/HttpRequest.java b/scm-core/src/main/java/sonia/scm/net/HttpRequest.java index 68c391c646..87bac859ed 100644 --- a/scm-core/src/main/java/sonia/scm/net/HttpRequest.java +++ b/scm-core/src/main/java/sonia/scm/net/HttpRequest.java @@ -35,17 +35,19 @@ package sonia.scm.net; //~--- non-JDK imports -------------------------------------------------------- +import com.google.common.collect.Lists; + import sonia.scm.util.AssertUtil; //~--- JDK imports ------------------------------------------------------------ -import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; /** + * Http request which can be executed by the {@link HttpClient}. * * @author Sebastian Sdorra * @since 1.9 @@ -54,10 +56,10 @@ public class HttpRequest { /** - * Constructs ... + * Constructs a new HttpRequest. * * - * @param url + * @param url url for the request */ public HttpRequest(String url) { @@ -67,13 +69,13 @@ public class HttpRequest //~--- methods -------------------------------------------------------------- /** - * Method description + * Add a http header for the request. * * - * @param name - * @param values + * @param name name of the request header + * @param values values of the request header * - * @return + * @return {@code this} */ public HttpRequest addHeader(String name, String... values) { @@ -90,13 +92,13 @@ public class HttpRequest } /** - * Method description + * Add a parameter to the request. * * - * @param name - * @param values + * @param name name of the parameter + * @param values values of the parameter * - * @return + * @return {@code this} */ public HttpRequest addParameters(String name, String... values) { @@ -115,10 +117,10 @@ public class HttpRequest //~--- get methods ---------------------------------------------------------- /** - * Method description + * Return a map with http headers used for the request. * * - * @return + * @return map with http headers */ public Map> getHeaders() { @@ -126,10 +128,10 @@ public class HttpRequest } /** - * Method description + * Return a map with http parameters for the request. * * - * @return + * @return map with http parameters */ public Map> getParameters() { @@ -137,10 +139,10 @@ public class HttpRequest } /** - * Method description + * Returns the password for http basic authentication. * * - * @return + * @return password for http basic authentication */ public String getPassword() { @@ -148,10 +150,10 @@ public class HttpRequest } /** - * Method description + * Returns the url for the request. * * - * @return + * @return url of the request */ public String getUrl() { @@ -159,10 +161,10 @@ public class HttpRequest } /** - * Method description + * Returns the username for http basic authentication. * * - * @return + * @return username for http basic authentication */ public String getUsername() { @@ -170,10 +172,10 @@ public class HttpRequest } /** - * Method description + * Returns true if the request decodes gzip compression. * * - * @return + * @return true if the request decodes gzip compression * * @since 1.14 */ @@ -183,10 +185,10 @@ public class HttpRequest } /** - * Method description + * Returns true if the verification of ssl certificates is disabled. * * - * @return + * @return true if certificate verification is disabled * @since 1.17 */ public boolean isDisableCertificateValidation() @@ -195,10 +197,10 @@ public class HttpRequest } /** - * Method description + * Returns true if the ssl hostname validation is disabled. * * - * @return + * @return true if the ssl hostname validation is disabled * @since 1.17 */ public boolean isDisableHostnameValidation() @@ -207,10 +209,10 @@ public class HttpRequest } /** - * Method description + * Returns true if the proxy settings are ignored. * * - * @return + * @return true if the proxy settings are ignored * @since 1.17 */ public boolean isIgnoreProxySettings() @@ -221,13 +223,13 @@ public class HttpRequest //~--- set methods ---------------------------------------------------------- /** - * Method description + * Enabled http basic authentication. * * - * @param username - * @param password + * @param username username for http basic authentication + * @param password password for http basic authentication * - * @return + * @return {@code this} */ public HttpRequest setBasicAuthentication(String username, String password) { @@ -238,12 +240,12 @@ public class HttpRequest } /** - * Method description + * Enable or disabled gzip decoding. The default value is false. * * - * @param decodeGZip + * @param decodeGZip true to enable gzip decoding * - * @return + * @return {@code this} * * @since 1.14 */ @@ -255,23 +257,25 @@ public class HttpRequest } /** - * Method description + * Enable or disable certificate validation of ssl certificates. The default + * value is false. * * - * @param disableCertificateValidation + * @param disableCertificateValidation true to disable certificate validation * @since 1.17 */ public void setDisableCertificateValidation( - boolean disableCertificateValidation) + boolean disableCertificateValidation) { this.disableCertificateValidation = disableCertificateValidation; } /** - * Method description + * Enable or disable the validation of ssl hostnames. The default value is + * false. * * - * @param disableHostnameValidation + * @param disableHostnameValidation true to disable ssl hostname validation * @since 1.17 */ public void setDisableHostnameValidation(boolean disableHostnameValidation) @@ -280,12 +284,12 @@ public class HttpRequest } /** - * Method description + * Set http headers for the request. * * - * @param headers + * @param headers headers for the request * - * @return + * @return {@code this} */ public HttpRequest setHeaders(Map> headers) { @@ -295,10 +299,10 @@ public class HttpRequest } /** - * Method description + * Ignore proxy settings. The default value is false. * * - * @param ignoreProxySettings + * @param ignoreProxySettings true to ignore proxy settings. * @since 1.17 */ public void setIgnoreProxySettings(boolean ignoreProxySettings) @@ -307,12 +311,12 @@ public class HttpRequest } /** - * Method description + * Set http parameters for the request. * * - * @param parameters + * @param parameters parameters for the request * - * @return + * @return {@code this} */ public HttpRequest setParameters(Map> parameters) { @@ -324,21 +328,21 @@ public class HttpRequest //~--- methods -------------------------------------------------------------- /** - * Method description + * Append values to map. * * - * @param map - * @param name - * @param values + * @param map map to append values + * @param name name of the key + * @param values values to append */ private void appendValues(Map> map, String name, - String[] values) + String[] values) { List valueList = map.get(name); if (valueList == null) { - valueList = new ArrayList(); + valueList = Lists.newArrayList(values); map.put(name, valueList); } @@ -350,30 +354,30 @@ public class HttpRequest //~--- fields --------------------------------------------------------------- - /** Field description */ + /** map of request headers */ private Map> headers; - /** Field description */ + /** ignore proxy settings */ private boolean ignoreProxySettings = false; - /** Field description */ + /** disable ssl hostname validation */ private boolean disableHostnameValidation = false; - /** Field description */ + /** disable ssl certificate validation */ private boolean disableCertificateValidation = false; - /** Field description */ + /** decode gzip */ private boolean decodeGZip = false; - /** Field description */ + /** map of parameters */ private Map> parameters; - /** Field description */ + /** password for http basic authentication */ private String password; - /** Field description */ + /** url for the request */ private String url; - /** Field description */ + /** username for http basic authentication */ private String username; } diff --git a/scm-core/src/main/java/sonia/scm/net/HttpResponse.java b/scm-core/src/main/java/sonia/scm/net/HttpResponse.java index 00745615c1..83cdf9ee61 100644 --- a/scm-core/src/main/java/sonia/scm/net/HttpResponse.java +++ b/scm-core/src/main/java/sonia/scm/net/HttpResponse.java @@ -43,6 +43,7 @@ import java.util.List; import java.util.Map; /** + * Response of a {@link HttpRequest} execute by the {@link HttpClient}. * * @author Sebastian Sdorra */ @@ -50,48 +51,48 @@ public interface HttpResponse extends Closeable { /** - * Method description + * Returns the response body as stream. * * - * @return + * @return response body as stream * * @throws IOException */ public InputStream getContent() throws IOException; /** - * Method description + * Returns the response body as string. * * - * @return + * @return response body as string * * @throws IOException */ public String getContentAsString() throws IOException; /** - * Method description + * Returns the value of the first response header with the given name. * * - * @param name + * @param name name of the response header * - * @return + * @return value of the first response header with the given name */ public String getHeader(String name); /** - * Method description + * Returns a map with all response headers. * * - * @return + * @return map with all response headers */ public Map> getHeaderMap(); /** - * Method description + * Returns the status code of the response. * * - * @return + * @return status code * * @throws IOException */