This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit 9b3ec9891102be43c2b113cbef0e2eaa81e0d808 Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Tue May 12 16:11:29 2020 +0200 Camel-geocoder: Fixed CS --- .../component/geocoder/GeoCoderComponent.java | 3 +- .../camel/component/geocoder/GeoCoderEndpoint.java | 64 +++++++++------------ .../component/geocoder/GeoCoderGoogleProducer.java | 11 ++-- .../geocoder/GeoCoderNominatimProducer.java | 45 +++++---------- .../camel/component/geocoder/GeoCoderType.java | 7 +-- .../camel/component/geocoder/GeocoderStatus.java | 12 +--- .../geocoder/GeoCoderComponentAddressTest.java | 7 +-- .../geocoder/GeoCoderCurrentAddressTest.java | 11 ++-- .../geocoder/GeoCoderEmptyAddressTest.java | 9 +-- .../geocoder/GeoCoderLatLngComponentTest.java | 8 +-- .../geocoder/GeoCoderNominatimAddressTest.java | 6 +- .../component/geocoder/GeoCoderNominatimTest.java | 6 +- .../component/geocoder/GeoCoderProxyTest.java | 13 ++--- .../dsl/GeoCoderEndpointBuilderFactory.java | 66 ++++++++++++++++++---- 14 files changed, 130 insertions(+), 138 deletions(-) diff --git a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderComponent.java b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderComponent.java index eebc6f6..614a4ae 100644 --- a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderComponent.java +++ b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderComponent.java @@ -32,8 +32,7 @@ public class GeoCoderComponent extends DefaultComponent { } @Override - protected Endpoint createEndpoint(String uri, String remaining, - Map<String, Object> parameters) throws Exception { + protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { GeoCoderEndpoint endpoint = new GeoCoderEndpoint(uri, this); // remaining can either be address or latlng diff --git a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderEndpoint.java b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderEndpoint.java index 2c3babc..010fc7f 100644 --- a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderEndpoint.java +++ b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderEndpoint.java @@ -30,7 +30,8 @@ import org.apache.camel.spi.UriPath; import org.apache.camel.support.DefaultEndpoint; /** - * Find geocodes (latitude and longitude) for a given address or the other way round. + * Find geocodes (latitude and longitude) for a given address or the other way + * round. */ @UriEndpoint(firstVersion = "2.12.0", scheme = "geocoder", title = "Geocoder", syntax = "geocoder:address:latlng", producerOnly = true, label = "api,location") public class GeoCoderEndpoint extends DefaultEndpoint { @@ -41,43 +42,31 @@ public class GeoCoderEndpoint extends DefaultEndpoint { private String latlng; @UriParam(defaultValue = "en") private String language = "en"; - @UriParam(label = "security", secret = true, - description="Client ID to access Google GeoCoding server.") + @UriParam(label = "security", secret = true, description = "Client ID to access Google GeoCoding server.") private String clientId; - @UriParam(label = "security", secret = true, - description="Client Key to access Google GeoCoding server.") + @UriParam(label = "security", secret = true, description = "Client Key to access Google GeoCoding server.") private String clientKey; - @UriParam(label = "security", secret = true, - description="API Key to access Google. Mandatory for Google GeoCoding server.") + @UriParam(label = "security", secret = true, description = "API Key to access Google. Mandatory for Google GeoCoding server.") private String apiKey; - @UriParam(description = "URL to the geocoder server. Mandatory for Nominatim server.", - displayName = "Server URL") + @UriParam(description = "URL to the geocoder server. Mandatory for Nominatim server.", displayName = "Server URL") private String serverUrl; @UriParam private boolean headersOnly; - @UriParam(label = "proxy", - description="Proxy Host to access GeoCoding server.") + @UriParam(label = "proxy", description = "Proxy Host to access GeoCoding server.") private String proxyHost; - @UriParam(label = "proxy", - description="Proxy Port to access GeoCoding server.") + @UriParam(label = "proxy", description = "Proxy Port to access GeoCoding server.") private Integer proxyPort; - @UriParam(label = "proxy", - description="Authentication Method to Google GeoCoding server.") + @UriParam(label = "proxy", description = "Authentication Method to Google GeoCoding server.") private String proxyAuthMethod; - @UriParam(label = "proxy", - description="Proxy Username to access GeoCoding server.") + @UriParam(label = "proxy", description = "Proxy Username to access GeoCoding server.") private String proxyAuthUsername; - @UriParam(label = "proxy", - description="Proxy Password to access GeoCoding server.") + @UriParam(label = "proxy", description = "Proxy Password to access GeoCoding server.") private String proxyAuthPassword; - @UriParam(label = "proxy", - description="Proxy Authentication Domain to access Google GeoCoding server.") + @UriParam(label = "proxy", description = "Proxy Authentication Domain to access Google GeoCoding server.") private String proxyAuthDomain; - @UriParam(label = "proxy", - description="Proxy Authentication Host to access Google GeoCoding server.") + @UriParam(label = "proxy", description = "Proxy Authentication Host to access Google GeoCoding server.") private String proxyAuthHost; - @UriParam(displayName = "GeoCoding Type", - description = "Type of GeoCoding server. Supported Nominatim and Google.") + @UriParam(displayName = "GeoCoding Type", description = "Type of GeoCoding server. Supported Nominatim and Google.") private GeoCoderType type; public GeoCoderEndpoint() { @@ -89,14 +78,13 @@ public class GeoCoderEndpoint extends DefaultEndpoint { @Override public Producer createProducer() throws Exception { - switch (getType()) - { - case NOMINATIM: - return new GeoCoderNominatimProducer(this); - case GOOGLE: - default: - // default to Google for backwards compatibility - return new GeoCoderGoogleProducer(this); + switch (getType()) { + case NOMINATIM: + return new GeoCoderNominatimProducer(this); + case GOOGLE: + default: + // default to Google for backwards compatibility + return new GeoCoderGoogleProducer(this); } } @@ -132,7 +120,8 @@ public class GeoCoderEndpoint extends DefaultEndpoint { } /** - * The geo latitude and longitude which should be prefixed with <tt>latlng:</tt> + * The geo latitude and longitude which should be prefixed with + * <tt>latlng:</tt> */ public void setLatlng(String latlng) { this.latlng = latlng; @@ -143,7 +132,8 @@ public class GeoCoderEndpoint extends DefaultEndpoint { } /** - * Whether to only enrich the Exchange with headers, and leave the body as-is. + * Whether to only enrich the Exchange with headers, and leave the body + * as-is. */ public void setHeadersOnly(boolean headersOnly) { this.headersOnly = headersOnly; @@ -204,7 +194,6 @@ public class GeoCoderEndpoint extends DefaultEndpoint { this.proxyPort = proxyPort; } - public String getProxyAuthMethod() { return proxyAuthMethod; } @@ -261,7 +250,7 @@ public class GeoCoderEndpoint extends DefaultEndpoint { } public GeoCoderType getType() { - if(type == null) { + if (type == null) { type = GeoCoderType.GOOGLE; } return type; @@ -285,6 +274,7 @@ public class GeoCoderEndpoint extends DefaultEndpoint { /** * Specific Google required + * * @return */ protected GeoApiContext createGeoApiContext() { diff --git a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderGoogleProducer.java b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderGoogleProducer.java index 19dff2e..331535b 100644 --- a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderGoogleProducer.java +++ b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderGoogleProducer.java @@ -17,6 +17,7 @@ package org.apache.camel.component.geocoder; import java.util.Locale; + import com.google.maps.GeoApiContext; import com.google.maps.GeocodingApi; import com.google.maps.GeolocationApi; @@ -118,14 +119,14 @@ public class GeoCoderGoogleProducer extends DefaultProducer { GeolocationResult result = GeolocationApi.geolocate(context, payload).await(); LOG.debug("Geolocation response {}", result); - //status + // status exchange.getIn().setHeader(GeoCoderConstants.STATUS, GeocoderStatus.OK); - //latlng + // latlng String resLatlng = result.location.toString(); exchange.getIn().setHeader(GeoCoderConstants.LATLNG, resLatlng); - //address - reverse geocode + // address - reverse geocode LOG.debug("Geocode - reverse geocode for location {}", resLatlng); GeocodingResult[] results = GeocodingApi.reverseGeocode(context, result.location).await(); @@ -150,7 +151,7 @@ public class GeoCoderGoogleProducer extends DefaultProducer { if (!endpoint.isHeadersOnly()) { exchange.getIn().setBody(res); } - //no results + // no results if (res.length == 0) { exchange.getIn().setHeader(GeoCoderConstants.STATUS, GeocoderStatus.ZERO_RESULTS); return; @@ -163,7 +164,7 @@ public class GeoCoderGoogleProducer extends DefaultProducer { // just grab the first element and its lat and lon setLatLngToExchangeHeader(first.geometry.location, exchange); - //additional details + // additional details AddressComponent country = getCountry(res); if (country != null) { exchange.getIn().setHeader(GeoCoderConstants.COUNTRY_SHORT, country.shortName); diff --git a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderNominatimProducer.java b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderNominatimProducer.java index 0ed8a4c..bcbcd73 100644 --- a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderNominatimProducer.java +++ b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderNominatimProducer.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.util.HashMap; import java.util.Locale; import java.util.Map; + import com.jayway.jsonpath.Configuration; import com.jayway.jsonpath.DocumentContext; import com.jayway.jsonpath.JsonPath; @@ -107,8 +108,7 @@ public class GeoCoderNominatimProducer extends DefaultProducer { } url += operation; - final RequestBuilder builder = - RequestBuilder.get().setUri(url); + final RequestBuilder builder = RequestBuilder.get().setUri(url); for (Map.Entry<String, String> entry : params.entrySet()) { builder.addParameter(entry.getKey(), entry.getValue()); @@ -127,31 +127,23 @@ public class GeoCoderNominatimProducer extends DefaultProducer { } if (place == null || place.isEmpty()) { - exchange.getIn().setHeader(GeoCoderConstants.STATUS, - GeocoderStatus.ZERO_RESULTS); + exchange.getIn().setHeader(GeoCoderConstants.STATUS, GeocoderStatus.ZERO_RESULTS); return; } exchange.getIn().setHeader(GeoCoderConstants.STATUS, GeocoderStatus.OK); - if(place.startsWith("[") && place.endsWith("]")) { + if (place.startsWith("[") && place.endsWith("]")) { place = place.substring(1, place.length() - 1); } - //additional details - final Configuration conf = - Configuration.defaultConfiguration() - .addOptions(Option.SUPPRESS_EXCEPTIONS); + // additional details + final Configuration conf = Configuration.defaultConfiguration().addOptions(Option.SUPPRESS_EXCEPTIONS); final DocumentContext doc = JsonPath.using(conf).parse(place); - - exchange.getIn().setHeader(GeoCoderConstants.ADDRESS, - doc.read("$['display_name']")); + exchange.getIn().setHeader(GeoCoderConstants.ADDRESS, doc.read("$['display_name']")); // just grab the first element and its lat and lon - setLatLngToExchangeHeader( - doc.read("$['lat']"), - doc.read("$['lon']"), - exchange); + setLatLngToExchangeHeader(doc.read("$['lat']"), doc.read("$['lon']"), exchange); extractCountry(doc, exchange.getIn()); extractCity(doc, exchange.getIn()); @@ -167,39 +159,32 @@ public class GeoCoderNominatimProducer extends DefaultProducer { } private void extractCountry(DocumentContext doc, Message in) { - String code = - doc.read("$['address']['country_code']"); + String code = doc.read("$['address']['country_code']"); if (code != null) { code = code.toUpperCase(); } in.setHeader(GeoCoderConstants.COUNTRY_SHORT, code); - in.setHeader(GeoCoderConstants.COUNTRY_LONG, - doc.read("$['address']['country']")); + in.setHeader(GeoCoderConstants.COUNTRY_LONG, doc.read("$['address']['country']")); } private void extractCity(DocumentContext doc, Message in) { - in.setHeader(GeoCoderConstants.CITY, - doc.read("$['address']['city']")); + in.setHeader(GeoCoderConstants.CITY, doc.read("$['address']['city']")); } private void extractPostalCode(DocumentContext doc, Message in) { - in.setHeader(GeoCoderConstants.POSTAL_CODE, - doc.read("$['address']['postcode']")); + in.setHeader(GeoCoderConstants.POSTAL_CODE, doc.read("$['address']['postcode']")); } private void extractRegion(DocumentContext doc, Message in) { - String code = - doc.read("$['address']['state_code']"); + String code = doc.read("$['address']['state_code']"); if (code != null) { code = code.toUpperCase(); } in.setHeader(GeoCoderConstants.REGION_CODE, code); - in.setHeader(GeoCoderConstants.REGION_NAME, - doc.read("$['address']['state']")); + in.setHeader(GeoCoderConstants.REGION_NAME, doc.read("$['address']['state']")); } private String formatLatOrLon(String value) { - return String.format(Locale.ENGLISH, "%.8f", - Double.parseDouble(value)); + return String.format(Locale.ENGLISH, "%.8f", Double.parseDouble(value)); } } diff --git a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderType.java b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderType.java index 3a822ec..6407421 100644 --- a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderType.java +++ b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderType.java @@ -17,8 +17,7 @@ package org.apache.camel.component.geocoder; public enum GeoCoderType { - NOMINATIM, - GOOGLE; + NOMINATIM, GOOGLE; public String value() { return name(); @@ -26,10 +25,10 @@ public enum GeoCoderType { public static GeoCoderType fromValue(String v) { if (v == null || v.isEmpty()) { - //Default to Google for backwards compatibility + // Default to Google for backwards compatibility return GOOGLE; } return valueOf(v); } -} \ No newline at end of file +} diff --git a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeocoderStatus.java b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeocoderStatus.java index 56b39d6..ecb1689 100644 --- a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeocoderStatus.java +++ b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeocoderStatus.java @@ -17,15 +17,7 @@ package org.apache.camel.component.geocoder; public enum GeocoderStatus { - ERROR, - INVALID_REQUEST, - ACCESS_NOT_CONFIGURED, - OK, - OVER_QUERY_LIMIT, - OVER_DAILY_LIMIT, - REQUEST_DENIED, - UNKNOWN_ERROR, - ZERO_RESULTS; + ERROR, INVALID_REQUEST, ACCESS_NOT_CONFIGURED, OK, OVER_QUERY_LIMIT, OVER_DAILY_LIMIT, REQUEST_DENIED, UNKNOWN_ERROR, ZERO_RESULTS; public String value() { return name(); @@ -34,4 +26,4 @@ public enum GeocoderStatus { public static GeocoderStatus fromValue(String v) { return valueOf(v); } -} \ No newline at end of file +} diff --git a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderComponentAddressTest.java b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderComponentAddressTest.java index b9bb6af..cbdd945 100644 --- a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderComponentAddressTest.java +++ b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderComponentAddressTest.java @@ -38,11 +38,8 @@ public class GeoCoderComponentAddressTest extends GeoCoderApiKeyTestBase { protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() { - from("direct:start") - .to("geocoder:address: empty?apiKey=" + getApiKey()) - .to("log:result") - .log("Location ${header.CamelGeocoderAddress} is at lat/lng: ${header.CamelGeocoderLatlng} in city ${header.CamelGeocoderCity}") - .to("mock:result"); + from("direct:start").to("geocoder:address: empty?apiKey=" + getApiKey()).to("log:result") + .log("Location ${header.CamelGeocoderAddress} is at lat/lng: ${header.CamelGeocoderLatlng} in city ${header.CamelGeocoderCity}").to("mock:result"); } }; } diff --git a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderCurrentAddressTest.java b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderCurrentAddressTest.java index f9d95ee..3a7a9fd 100644 --- a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderCurrentAddressTest.java +++ b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderCurrentAddressTest.java @@ -20,7 +20,7 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.junit.Test; -public class GeoCoderCurrentAddressTest extends GeoCoderApiKeyTestBase { +public class GeoCoderCurrentAddressTest extends GeoCoderApiKeyTestBase { @Test public void testGeoCoder() throws Exception { @@ -30,7 +30,7 @@ public class GeoCoderCurrentAddressTest extends GeoCoderApiKeyTestBase { mock.message(0).header(GeoCoderConstants.LATLNG).isNotNull(); template.sendBody("direct:start", "Hello"); - + assertMockEndpointsSatisfied(); } @@ -38,11 +38,8 @@ public class GeoCoderCurrentAddressTest extends GeoCoderApiKeyTestBase { protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() { - from("direct:start") - .to("geocoder:address:current?headersOnly=true&apiKey=" + getApiKey()) - .to("log:result") - .log("You are at ${header.CamelGeoCoderLatlng} in city ${header.CamelGeoCoderCity} in country ${header.CamelGeoCoderCountryLong}") - .to("mock:result"); + from("direct:start").to("geocoder:address:current?headersOnly=true&apiKey=" + getApiKey()).to("log:result") + .log("You are at ${header.CamelGeoCoderLatlng} in city ${header.CamelGeoCoderCity} in country ${header.CamelGeoCoderCountryLong}").to("mock:result"); } }; } diff --git a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderEmptyAddressTest.java b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderEmptyAddressTest.java index 298b670..55ac515 100644 --- a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderEmptyAddressTest.java +++ b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderEmptyAddressTest.java @@ -30,7 +30,7 @@ public class GeoCoderEmptyAddressTest extends GeoCoderApiKeyTestBase { mock.expectedHeaderReceived(GeoCoderConstants.STATUS, GeocoderStatus.ZERO_RESULTS); // the address header overrides the endpoint configuration template.sendBodyAndHeader("direct:start", "Hello", GeoCoderConstants.ADDRESS, " "); - + assertMockEndpointsSatisfied(); } @@ -38,11 +38,8 @@ public class GeoCoderEmptyAddressTest extends GeoCoderApiKeyTestBase { protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() { - from("direct:start") - .to("geocoder:address: ?apiKey=" + getApiKey()) - .to("log:result") - .log("Location ${header.CamelGeocoderAddress} is at lat/lng: ${header.CamelGeocoderLatlng} in city ${header.CamelGeocoderCity}") - .to("mock:result"); + from("direct:start").to("geocoder:address: ?apiKey=" + getApiKey()).to("log:result") + .log("Location ${header.CamelGeocoderAddress} is at lat/lng: ${header.CamelGeocoderLatlng} in city ${header.CamelGeocoderCity}").to("mock:result"); } }; } diff --git a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderLatLngComponentTest.java b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderLatLngComponentTest.java index 4ca097a..f945a9c 100644 --- a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderLatLngComponentTest.java +++ b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderLatLngComponentTest.java @@ -31,7 +31,7 @@ public class GeoCoderLatLngComponentTest extends GeoCoderApiKeyTestBase { // the address header overrides the endpoint configuration template.sendBody("direct:start", "Hello"); - + assertMockEndpointsSatisfied(); } @@ -39,11 +39,9 @@ public class GeoCoderLatLngComponentTest extends GeoCoderApiKeyTestBase { protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() { - from("direct:start") - .to("geocoder:latlng:40.714224,-73.961452?apiKey=" + getApiKey()) - .to("log:result") + from("direct:start").to("geocoder:latlng:40.714224,-73.961452?apiKey=" + getApiKey()).to("log:result") .log("Location ${header.CamelGeocoderAddress} is at lat/lng: ${header.CamelGeocoderLatlng}" - + " and in city ${header.CamelGeoCoderCity} in country ${header.CamelGeoCoderCountryLong}") + + " and in city ${header.CamelGeoCoderCity} in country ${header.CamelGeoCoderCountryLong}") .to("mock:result"); } }; diff --git a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderNominatimAddressTest.java b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderNominatimAddressTest.java index 5705edb..304a12a 100644 --- a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderNominatimAddressTest.java +++ b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderNominatimAddressTest.java @@ -40,11 +40,9 @@ public class GeoCoderNominatimAddressTest extends CamelTestSupport { protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() { - from("direct:start") - .to("geocoder:address:calle marie curie, sevilla, sevilla?type=NOMINATIM&serverUrl=RAW(https://nominatim.openstreetmap.org)") - .to("log:result") + from("direct:start").to("geocoder:address:calle marie curie, sevilla, sevilla?type=NOMINATIM&serverUrl=RAW(https://nominatim.openstreetmap.org)").to("log:result") .log("Location ${header.CamelGeocoderAddress} is at lat/lng: ${header.CamelGeocoderLatlng}" - + " and in city ${header.CamelGeoCoderCity} in country ${header.CamelGeoCoderCountryLong}") + + " and in city ${header.CamelGeoCoderCity} in country ${header.CamelGeoCoderCountryLong}") .to("mock:result"); } }; diff --git a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderNominatimTest.java b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderNominatimTest.java index 3dd90b9..6419db5 100644 --- a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderNominatimTest.java +++ b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderNominatimTest.java @@ -40,11 +40,9 @@ public class GeoCoderNominatimTest extends CamelTestSupport { protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() { - from("direct:start") - .to("geocoder:latlng:37.38619,-5.99255?type=NOMINATIM&serverUrl=RAW(https://nominatim.openstreetmap.org)") - .to("log:result") + from("direct:start").to("geocoder:latlng:37.38619,-5.99255?type=NOMINATIM&serverUrl=RAW(https://nominatim.openstreetmap.org)").to("log:result") .log("Location ${header.CamelGeocoderAddress} is at lat/lng: ${header.CamelGeocoderLatlng}" - + " and in city ${header.CamelGeoCoderCity} in country ${header.CamelGeoCoderCountryLong}") + + " and in city ${header.CamelGeoCoderCity} in country ${header.CamelGeoCoderCountryLong}") .to("mock:result"); } }; diff --git a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderProxyTest.java b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderProxyTest.java index 25808c8..31f6fa4 100644 --- a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderProxyTest.java +++ b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderProxyTest.java @@ -29,10 +29,8 @@ public class GeoCoderProxyTest extends GeoCoderApiKeyTestBase { @Test public void testGeoCoderProxyNoAuth() throws Exception { - GeoCoderEndpoint endpoint = context. - getEndpoint("geocoder:address:current?headersOnly=true&proxyHost=localhost" - + "&proxyPort=8888&apiKey=" + getApiKey(), - GeoCoderEndpoint.class); + GeoCoderEndpoint endpoint = context.getEndpoint("geocoder:address:current?headersOnly=true&proxyHost=localhost" + "&proxyPort=8888&apiKey=" + getApiKey(), + GeoCoderEndpoint.class); GeoApiContext context = endpoint.createGeoApiContext(); GeocodingApiRequest geocodingApiRequest = GeocodingApi.reverseGeocode(context, new LatLng(45.4643, 9.1895)); @@ -43,10 +41,9 @@ public class GeoCoderProxyTest extends GeoCoderApiKeyTestBase { @Test public void testGeoCoderWithAuth() throws Exception { - GeoCoderEndpoint endpoint = context. - getEndpoint("geocoder:address:current?headersOnly=true&proxyHost=localhost" - + "&proxyPort=8888&proxyAuthMethod=Basic&proxyAuthUsername=proxy&proxyAuthPassword=proxy&apiKey=" + getApiKey(), - GeoCoderEndpoint.class); + GeoCoderEndpoint endpoint = context.getEndpoint("geocoder:address:current?headersOnly=true&proxyHost=localhost" + + "&proxyPort=8888&proxyAuthMethod=Basic&proxyAuthUsername=proxy&proxyAuthPassword=proxy&apiKey=" + getApiKey(), + GeoCoderEndpoint.class); GeoApiContext context = endpoint.createGeoApiContext(); GeocodingApiRequest geocodingApiRequest = GeocodingApi.reverseGeocode(context, new LatLng(45.4643, 9.1895)); diff --git a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/GeoCoderEndpointBuilderFactory.java b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/GeoCoderEndpointBuilderFactory.java index ee4642d..487d1f4 100644 --- a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/GeoCoderEndpointBuilderFactory.java +++ b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/GeoCoderEndpointBuilderFactory.java @@ -119,7 +119,42 @@ public interface GeoCoderEndpointBuilderFactory { return this; } /** - * Domain for proxy NTML authentication. + * URL to the geocoder server. Mandatory for Nominatim server. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: producer + */ + default GeoCoderEndpointBuilder serverUrl(String serverUrl) { + doSetProperty("serverUrl", serverUrl); + return this; + } + /** + * Type of GeoCoding server. Supported Nominatim and Google. + * + * The option is a: + * <code>org.apache.camel.component.geocoder.GeoCoderType</code> type. + * + * Group: producer + */ + default GeoCoderEndpointBuilder type(GeoCoderType type) { + doSetProperty("type", type); + return this; + } + /** + * Type of GeoCoding server. Supported Nominatim and Google. + * + * The option will be converted to a + * <code>org.apache.camel.component.geocoder.GeoCoderType</code> type. + * + * Group: producer + */ + default GeoCoderEndpointBuilder type(String type) { + doSetProperty("type", type); + return this; + } + /** + * Proxy Authentication Domain to access Google GeoCoding server. * * The option is a: <code>java.lang.String</code> type. * @@ -130,7 +165,7 @@ public interface GeoCoderEndpointBuilderFactory { return this; } /** - * Optional host for proxy NTML authentication. + * Proxy Authentication Host to access Google GeoCoding server. * * The option is a: <code>java.lang.String</code> type. * @@ -141,7 +176,7 @@ public interface GeoCoderEndpointBuilderFactory { return this; } /** - * Authentication method for proxy, either as Basic, Digest or NTLM. + * Authentication Method to Google GeoCoding server. * * The option is a: <code>java.lang.String</code> type. * @@ -152,7 +187,7 @@ public interface GeoCoderEndpointBuilderFactory { return this; } /** - * Password for proxy authentication. + * Proxy Password to access GeoCoding server. * * The option is a: <code>java.lang.String</code> type. * @@ -164,7 +199,7 @@ public interface GeoCoderEndpointBuilderFactory { return this; } /** - * Username for proxy authentication. + * Proxy Username to access GeoCoding server. * * The option is a: <code>java.lang.String</code> type. * @@ -176,7 +211,7 @@ public interface GeoCoderEndpointBuilderFactory { return this; } /** - * The proxy host name. + * Proxy Host to access GeoCoding server. * * The option is a: <code>java.lang.String</code> type. * @@ -187,7 +222,7 @@ public interface GeoCoderEndpointBuilderFactory { return this; } /** - * The proxy port number. + * Proxy Port to access GeoCoding server. * * The option is a: <code>java.lang.Integer</code> type. * @@ -198,7 +233,7 @@ public interface GeoCoderEndpointBuilderFactory { return this; } /** - * The proxy port number. + * Proxy Port to access GeoCoding server. * * The option will be converted to a <code>java.lang.Integer</code> * type. @@ -210,7 +245,7 @@ public interface GeoCoderEndpointBuilderFactory { return this; } /** - * To use google apiKey. + * API Key to access Google. Mandatory for Google GeoCoding server. * * The option is a: <code>java.lang.String</code> type. * @@ -221,7 +256,7 @@ public interface GeoCoderEndpointBuilderFactory { return this; } /** - * To use google premium with this client id. + * Client ID to access Google GeoCoding server. * * The option is a: <code>java.lang.String</code> type. * @@ -232,7 +267,7 @@ public interface GeoCoderEndpointBuilderFactory { return this; } /** - * To use google premium with this client key. + * Client Key to access Google GeoCoding server. * * The option is a: <code>java.lang.String</code> type. * @@ -309,6 +344,15 @@ public interface GeoCoderEndpointBuilderFactory { } } + /** + * Proxy enum for + * <code>org.apache.camel.component.geocoder.GeoCoderType</code> enum. + */ + enum GeoCoderType { + NOMINATIM, + GOOGLE; + } + public interface GeoCoderBuilders { /** * Geocoder (camel-geocoder)