From 150f5704733260b395aa218b939cf29eadebc559 Mon Sep 17 00:00:00 2001 From: Brett Morgan Date: Tue, 15 Aug 2017 13:58:33 +1000 Subject: [PATCH 1/9] Opening up development on v0.2.3 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 5e2edd420..36bc85cfa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=0.2.2 +version=0.2.3-SNAPSHOT # variables required to allow build.gradle to parse, # override in ~/.gradle/gradle.properties From ddb536333c515b6d9b909e60e1334587560c5cf6 Mon Sep 17 00:00:00 2001 From: Brett Morgan Date: Wed, 16 Aug 2017 13:15:59 +1000 Subject: [PATCH 2/9] Documenting new GAE usage Fix for https://github.com/googlemaps/google-maps-services-java/issues/334 --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 267e2a608..beda1ca1e 100644 --- a/README.md +++ b/README.md @@ -182,8 +182,7 @@ For more usage examples, check out [the tests](src/test/java/com/google/maps/). You can use this client library on Google App Engine with a single code change. ```java -GeoApiContext context = new GeoApiContext.Builder() - .requestHandlerBuilder(new GaeRequestHandler.Builder()) +new GeoApiContext.Builder(new GaeRequestHandler.Builder()) .apiKey("AIza...") .build(); ``` From 69fd2913acaec29ab8039c97e569777a8828ff6c Mon Sep 17 00:00:00 2001 From: Brett Morgan Date: Wed, 16 Aug 2017 13:38:12 +1000 Subject: [PATCH 3/9] Javadoc for v0.2.2 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 267e2a608..ac5256dcb 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ Maven Central](https://search.maven.org/#search%7Cga%7C1%7Ca%3A%22google-maps-se ## Developer Documentation -View the [javadoc](https://googlemaps.github.io/google-maps-services-java/v0.2.1/javadoc/). +View the [javadoc](https://googlemaps.github.io/google-maps-services-java/v0.2.2/javadoc/). Additional documentation for the included web services is available at https://developers.google.com/maps/. From 4c4a6cc02f27bfa521cba6101c6125c1f2aa65af Mon Sep 17 00:00:00 2001 From: lhomme-a Date: Thu, 17 Aug 2017 14:44:27 +0200 Subject: [PATCH 4/9] adding proxy authentication in GeoApiContext --- .../com/google/maps/GaeRequestHandler.java | 6 +++++ .../java/com/google/maps/GeoApiContext.java | 13 +++++++++++ .../com/google/maps/OkHttpRequestHandler.java | 22 +++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/src/main/java/com/google/maps/GaeRequestHandler.java b/src/main/java/com/google/maps/GaeRequestHandler.java index 226101378..f4f4aabbc 100644 --- a/src/main/java/com/google/maps/GaeRequestHandler.java +++ b/src/main/java/com/google/maps/GaeRequestHandler.java @@ -127,6 +127,12 @@ public void proxy(Proxy proxy) { } @Override + public void proxyAuthentication(String proxyUserName, String proxyUserPassword) { + // TODO: Investigate if GAE URL Fetch Service supports setting proxy authentication + throw new RuntimeException("setProxyAuthentication not implemented for Google App Engine"); + } + + @Override public RequestHandler build() { return new GaeRequestHandler(); } diff --git a/src/main/java/com/google/maps/GeoApiContext.java b/src/main/java/com/google/maps/GeoApiContext.java index 7058cf5bc..0be8cc8bb 100644 --- a/src/main/java/com/google/maps/GeoApiContext.java +++ b/src/main/java/com/google/maps/GeoApiContext.java @@ -117,6 +117,8 @@ interface Builder { void proxy(Proxy proxy); + void proxyAuthentication(String proxyUserName, String proxyUserPassword); + RequestHandler build(); } } @@ -482,6 +484,17 @@ public Builder proxy(Proxy proxy) { return this; } + /** + * set authentication for proxy + * @param proxyUserName username for proxy authentication + * @param proxyUserPassword username for proxy authentication + * @return Returns this builder for call chaining. + */ + public Builder proxyAuthentication(String proxyUserName, String proxyUserPassword) { + builder.proxyAuthentication(proxyUserName, proxyUserPassword); + return this; + } + /** * Converts this builder into a {@code GeoApiContext}. * diff --git a/src/main/java/com/google/maps/OkHttpRequestHandler.java b/src/main/java/com/google/maps/OkHttpRequestHandler.java index 65c0cfef5..844855637 100644 --- a/src/main/java/com/google/maps/OkHttpRequestHandler.java +++ b/src/main/java/com/google/maps/OkHttpRequestHandler.java @@ -21,13 +21,20 @@ import com.google.maps.internal.ExceptionsAllowedToRetry; import com.google.maps.internal.OkHttpPendingResult; import com.google.maps.internal.RateLimitExecutorService; + +import java.io.IOException; import java.net.Proxy; import java.util.concurrent.TimeUnit; + +import okhttp3.Authenticator; +import okhttp3.Credentials; import okhttp3.Dispatcher; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.Route; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -126,6 +133,21 @@ public void proxy(Proxy proxy) { } @Override + public void proxyAuthentication(String proxyUserName, String proxyUserPassword) { + final String userName = proxyUserName; + final String password = proxyUserPassword; + builder.proxyAuthenticator(new Authenticator() { + @Override + public Request authenticate(Route route, Response response) throws IOException { + String credential = Credentials.basic(userName, password); + return response.request().newBuilder() + .header("Proxy-Authorization", credential) + .build(); + } + }); + } + + @Override public RequestHandler build() { OkHttpClient client = builder.build(); return new OkHttpRequestHandler(client); From ffc2a43dad6eb87e2c5b73c41a40014ac99ee418 Mon Sep 17 00:00:00 2001 From: Dan van Kley Date: Fri, 18 Aug 2017 11:31:45 -0400 Subject: [PATCH 5/9] Add note about paging delay From discussion in https://github.com/googlemaps/google-maps-services-java/issues/338 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 04e2e52ac..847db7f4c 100644 --- a/README.md +++ b/README.md @@ -197,6 +197,7 @@ based strategy. Never sleep between requests again! By default, requests are sent at the expected rate limits for each web service, typically 10 queries per second for free users. If you want to speed up or slow down requests, you can do that too, using `new GeoApiContext.Builder().queryRateLimit(qps).build()`. +Note that you still need to manually handle the [delay between the initial request and successive pages](https://developers.google.com/places/web-service/search#PlaceSearchPaging) when you're paging through multiple result sets. ### Retry on Failure From bd5303d9f8ee1d6694030848bbd45aba77b89e00 Mon Sep 17 00:00:00 2001 From: lhomme-a Date: Mon, 21 Aug 2017 14:59:33 +0200 Subject: [PATCH 6/9] adding proxy authentication in GeoApiContext - googleJavaFormat --- .../java/com/google/maps/GeoApiContext.java | 21 +++++++++--------- .../com/google/maps/OkHttpRequestHandler.java | 22 +++++++++++-------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/google/maps/GeoApiContext.java b/src/main/java/com/google/maps/GeoApiContext.java index 0be8cc8bb..e6c7404c7 100644 --- a/src/main/java/com/google/maps/GeoApiContext.java +++ b/src/main/java/com/google/maps/GeoApiContext.java @@ -484,16 +484,17 @@ public Builder proxy(Proxy proxy) { return this; } - /** - * set authentication for proxy - * @param proxyUserName username for proxy authentication - * @param proxyUserPassword username for proxy authentication - * @return Returns this builder for call chaining. - */ - public Builder proxyAuthentication(String proxyUserName, String proxyUserPassword) { - builder.proxyAuthentication(proxyUserName, proxyUserPassword); - return this; - } + /** + * set authentication for proxy + * + * @param proxyUserName username for proxy authentication + * @param proxyUserPassword username for proxy authentication + * @return Returns this builder for call chaining. + */ + public Builder proxyAuthentication(String proxyUserName, String proxyUserPassword) { + builder.proxyAuthentication(proxyUserName, proxyUserPassword); + return this; + } /** * Converts this builder into a {@code GeoApiContext}. diff --git a/src/main/java/com/google/maps/OkHttpRequestHandler.java b/src/main/java/com/google/maps/OkHttpRequestHandler.java index 844855637..713a23a84 100644 --- a/src/main/java/com/google/maps/OkHttpRequestHandler.java +++ b/src/main/java/com/google/maps/OkHttpRequestHandler.java @@ -134,20 +134,24 @@ public void proxy(Proxy proxy) { @Override public void proxyAuthentication(String proxyUserName, String proxyUserPassword) { - final String userName = proxyUserName; - final String password = proxyUserPassword; - builder.proxyAuthenticator(new Authenticator() { + final String userName = proxyUserName; + final String password = proxyUserPassword; + + builder.proxyAuthenticator( + new Authenticator() { @Override public Request authenticate(Route route, Response response) throws IOException { - String credential = Credentials.basic(userName, password); - return response.request().newBuilder() - .header("Proxy-Authorization", credential) - .build(); + String credential = Credentials.basic(userName, password); + return response + .request() + .newBuilder() + .header("Proxy-Authorization", credential) + .build(); } - }); + }); } - @Override + @Override public RequestHandler build() { OkHttpClient client = builder.build(); return new OkHttpRequestHandler(client); From 3134cf7a2d0215211c36b33ffd4932241666ff88 Mon Sep 17 00:00:00 2001 From: Brett Morgan Date: Wed, 23 Aug 2017 21:49:41 +1000 Subject: [PATCH 7/9] ./gradlew googleJavaFormat --- src/main/java/com/google/maps/GaeRequestHandler.java | 10 +++++----- .../java/com/google/maps/OkHttpRequestHandler.java | 2 -- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/google/maps/GaeRequestHandler.java b/src/main/java/com/google/maps/GaeRequestHandler.java index f4f4aabbc..4c2cc0f50 100644 --- a/src/main/java/com/google/maps/GaeRequestHandler.java +++ b/src/main/java/com/google/maps/GaeRequestHandler.java @@ -127,12 +127,12 @@ public void proxy(Proxy proxy) { } @Override - public void proxyAuthentication(String proxyUserName, String proxyUserPassword) { - // TODO: Investigate if GAE URL Fetch Service supports setting proxy authentication - throw new RuntimeException("setProxyAuthentication not implemented for Google App Engine"); - } + public void proxyAuthentication(String proxyUserName, String proxyUserPassword) { + // TODO: Investigate if GAE URL Fetch Service supports setting proxy authentication + throw new RuntimeException("setProxyAuthentication not implemented for Google App Engine"); + } - @Override + @Override public RequestHandler build() { return new GaeRequestHandler(); } diff --git a/src/main/java/com/google/maps/OkHttpRequestHandler.java b/src/main/java/com/google/maps/OkHttpRequestHandler.java index 713a23a84..b75a4e43a 100644 --- a/src/main/java/com/google/maps/OkHttpRequestHandler.java +++ b/src/main/java/com/google/maps/OkHttpRequestHandler.java @@ -21,11 +21,9 @@ import com.google.maps.internal.ExceptionsAllowedToRetry; import com.google.maps.internal.OkHttpPendingResult; import com.google.maps.internal.RateLimitExecutorService; - import java.io.IOException; import java.net.Proxy; import java.util.concurrent.TimeUnit; - import okhttp3.Authenticator; import okhttp3.Credentials; import okhttp3.Dispatcher; From 921654a9aa1c14cefd3db72c025d2a780b13873f Mon Sep 17 00:00:00 2001 From: Brett Morgan Date: Wed, 13 Sep 2017 17:20:56 +1000 Subject: [PATCH 8/9] Cleaning up README.md's markdown --- README.md | 64 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 847db7f4c..3345c8000 100644 --- a/README.md +++ b/README.md @@ -15,13 +15,13 @@ Services] to your server-side Java application. The Java Client for Google Maps Services is a Java Client library for the following Google Maps APIs: - - [Directions API] - - [Distance Matrix API] - - [Elevation API] - - [Geocoding API] - - [Places API] - - [Roads API] - - [Time Zone API] +- [Directions API] +- [Distance Matrix API] +- [Elevation API] +- [Geocoding API] +- [Places API] +- [Roads API] +- [Time Zone API] Keep in mind that the same [terms and conditions](https://developers.google.com/maps/terms) apply to usage of the APIs when they're accessed through this library. @@ -46,30 +46,30 @@ contribute, please read [How to Contribute][contrib]. ## Requirements - - Java 1.7 or later. - - A Google Maps API key. +- Java 1.7 or later. +- A Google Maps API key. ### API keys Each Google Maps Web Service request requires an API key or client ID. API keys are freely available with a Google Account at -https://developers.google.com/console. The type of API key you need is a -**Server key**. +[developers.google.com/console](https://developers.google.com/console). The +type of API key you need is a **Server key**. To get an API key: - 1. Visit https://developers.google.com/console and log in with - a Google Account. + 1. Visit [developers.google.com/console](https://developers.google.com/console) + and log in with a Google Account. 1. Select one of your existing projects, or create a new project. 1. Enable the API(s) you want to use. The Java Client for Google Maps Services accesses the following APIs: - * Directions API - * Distance Matrix API - * Elevation API - * Geocoding API - * Places API - * Roads API - * Time Zone API + - Directions API + - Distance Matrix API + - Elevation API + - Geocoding API + - Places API + - Roads API + - Time Zone API 1. Create a new **Server key**. 1. If you'd like to restrict requests to a specific IP address, do so now. @@ -94,6 +94,7 @@ that will make more sense in other configurations. This will stop a warning mess when you start using `google-maps-services`. ### Maven + ```xml com.google.maps @@ -108,6 +109,7 @@ when you start using `google-maps-services`. ``` ### Gradle + ```groovy repositories { mavenCentral() @@ -129,13 +131,13 @@ View the [javadoc](https://googlemaps.github.io/google-maps-services-java/v0.2.2 Additional documentation for the included web services is available at https://developers.google.com/maps/. - - [Directions API] - - [Distance Matrix API] - - [Elevation API] - - [Geocoding API] - - [Places API] - - [Roads API] - - [Time Zone API] +- [Directions API] +- [Distance Matrix API] +- [Elevation API] +- [Geocoding API] +- [Places API] +- [Roads API] +- [Time Zone API] ## Usage @@ -206,10 +208,10 @@ are returned from the API. To alter or disable automatic retries, see these methods in `GeoApiContext`: -* `.disableRetries()` -* `.maxRetries()` -* `.retryTimeout()` -* `.setIfExceptionIsAllowedToRetry()` +- `.disableRetries()` +- `.maxRetries()` +- `.retryTimeout()` +- `.setIfExceptionIsAllowedToRetry()` ### Client IDs From e8a337e2f0cdc46c51a078f09df190008cd02888 Mon Sep 17 00:00:00 2001 From: Brett Morgan Date: Wed, 13 Sep 2017 17:56:24 +1000 Subject: [PATCH 9/9] Releasing version 0.2.3 (#346) --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 36bc85cfa..783275b46 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=0.2.3-SNAPSHOT +version=0.2.3 # variables required to allow build.gradle to parse, # override in ~/.gradle/gradle.properties