CAMEL-9272. Add appid param as the user key is required since 9/10/2015 to access the openweathermap service
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/594e11a4 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/594e11a4 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/594e11a4 Branch: refs/heads/camel-2.15.x Commit: 594e11a490dc2e6beafbd4c0e8f16d2f19d5c243 Parents: 7b84f41 Author: Charles Moulliard <cmoulli...@apache.org> Authored: Thu Oct 29 17:52:28 2015 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Fri Oct 30 07:42:12 2015 +0100 ---------------------------------------------------------------------- .../component/weather/WeatherConfiguration.java | 20 +++++++++++++++++++- .../CurrentWeatherMadridProducerTest.java | 4 +++- 2 files changed, 22 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/594e11a4/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java index 2c9d3ef..14793eb 100644 --- a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java +++ b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java @@ -52,6 +52,8 @@ public class WeatherConfiguration { private WeatherUnits units = METRIC; @UriParam private String headerName; + @UriParam + private String appid; public WeatherConfiguration(WeatherComponent component) { this.component = notNull(component, "component"); @@ -129,6 +131,18 @@ public class WeatherConfiguration { public void setLon(String lon) { this.lon = lon; } + + /** + * APPID ID used to authenticate the user connected to the API Server + */ + public void setAppid(String appid) { + this.appid = appid; + } + + public String getAppid() { + return appid; + } + public String getQuery() throws Exception { return getQuery(getLocation()); @@ -145,7 +159,7 @@ public class WeatherConfiguration { // assuming the location is a town or country location = "q=" + location; } - + if (isEmpty(getPeriod())) { answer += "weather?" + location; } else { @@ -162,6 +176,10 @@ public class WeatherConfiguration { answer += "&mode=" + getMode().name().toLowerCase(); } + if (getAppid() != null) { + answer += "&APPID=" + getAppid(); + } + return answer; } http://git-wip-us.apache.org/repos/asf/camel/blob/594e11a4/components/camel-weather/src/test/java/org/apache/camel/component/weather/CurrentWeatherMadridProducerTest.java ---------------------------------------------------------------------- diff --git a/components/camel-weather/src/test/java/org/apache/camel/component/weather/CurrentWeatherMadridProducerTest.java b/components/camel-weather/src/test/java/org/apache/camel/component/weather/CurrentWeatherMadridProducerTest.java index 9592513..61b7dc6 100644 --- a/components/camel-weather/src/test/java/org/apache/camel/component/weather/CurrentWeatherMadridProducerTest.java +++ b/components/camel-weather/src/test/java/org/apache/camel/component/weather/CurrentWeatherMadridProducerTest.java @@ -86,8 +86,10 @@ public class CurrentWeatherMadridProducerTest extends BaseWeatherConsumerTest { return new RouteBuilder() { @Override public void configure() throws Exception { + + /* The Camel Route uses the apache-camel appid to access the openweathermap service */ from("direct:start") - .to("weather:foo?location=Madrid,Spain") + .to("weather:foo?location=Madrid,Spain&appid=9162755b2efa555823cfe0451d7fff38") .to("mock:result"); } };