You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2018/07/17 14:35:24 UTC

[camel] 02/05: CAMEL-12658 - Fixed CS

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 26481fd4f1f4d95a464d02d590fce170e8d0d44d
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Jul 17 16:28:43 2018 +0200

    CAMEL-12658 - Fixed CS
---
 .../camel/component/weather/WeatherComponent.java  | 53 ++++++--------
 .../component/weather/WeatherConfiguration.java    | 84 ++++++++++++----------
 .../geolocation/FreeGeoIpGeoLocationProvider.java  |  7 +-
 3 files changed, 69 insertions(+), 75 deletions(-)

diff --git a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherComponent.java b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherComponent.java
index a49cd3a..14f4a23 100644
--- a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherComponent.java
+++ b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherComponent.java
@@ -42,7 +42,6 @@ public class WeatherComponent extends UriEndpointComponent {
     private String geolocationAccessKey;
     private String geolocationRequestHostIP;
 
-
     public WeatherComponent() {
         super(WeatherEndpoint.class);
     }
@@ -53,7 +52,7 @@ public class WeatherComponent extends UriEndpointComponent {
 
     @Override
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
-    	WeatherConfiguration configuration = new WeatherConfiguration(this);
+        WeatherConfiguration configuration = new WeatherConfiguration(this);
 
         // and then override from parameters
         setProperties(configuration, parameters);
@@ -73,8 +72,7 @@ public class WeatherComponent extends UriEndpointComponent {
         HttpClient httpClient = new HttpClient(connectionManager);
 
         if (configuration.getProxyHost() != null && configuration.getProxyPort() != null) {
-            httpClient.getHostConfiguration().setProxy(configuration.getProxyHost(),
-                    configuration.getProxyPort());
+            httpClient.getHostConfiguration().setProxy(configuration.getProxyHost(), configuration.getProxyPort());
         }
 
         if (configuration.getProxyAuthUsername() != null && configuration.getProxyAuthMethod() == null) {
@@ -83,12 +81,8 @@ public class WeatherComponent extends UriEndpointComponent {
 
         CompositeHttpConfigurer configurer = new CompositeHttpConfigurer();
         if (configuration.getProxyAuthMethod() != null) {
-            configureProxyAuth(configurer,
-                    configuration.getProxyAuthMethod(),
-                    configuration.getProxyAuthUsername(),
-                    configuration.getProxyAuthPassword(),
-                    configuration.getProxyAuthDomain(),
-                    configuration.getProxyAuthHost());
+            configureProxyAuth(configurer, configuration.getProxyAuthMethod(), configuration.getProxyAuthUsername(), configuration.getProxyAuthPassword(),
+                               configuration.getProxyAuthDomain(), configuration.getProxyAuthHost());
         }
 
         configurer.configureHttpClient(httpClient);
@@ -96,12 +90,7 @@ public class WeatherComponent extends UriEndpointComponent {
         return httpClient;
     }
 
-    private HttpClientConfigurer configureProxyAuth(CompositeHttpConfigurer configurer,
-                                    String authMethod,
-                                    String username,
-                                    String password,
-                                    String domain,
-                                    String host) {
+    private HttpClientConfigurer configureProxyAuth(CompositeHttpConfigurer configurer, String authMethod, String username, String password, String domain, String host) {
         // no proxy auth is in use
         if (username == null && authMethod == null) {
             return configurer;
@@ -136,27 +125,27 @@ public class WeatherComponent extends UriEndpointComponent {
         return httpClient;
     }
 
-	public String getGeolocationAccessKey() {
-		return geolocationAccessKey;
-	}
-	
+    public String getGeolocationAccessKey() {
+        return geolocationAccessKey;
+    }
+
     /**
      * The geolocation service now needs an accessKey to be used
      */
-	public void setGeolocationAccessKey(String geolocationAccessKey) {
-		this.geolocationAccessKey = geolocationAccessKey;
-	}
+    public void setGeolocationAccessKey(String geolocationAccessKey) {
+        this.geolocationAccessKey = geolocationAccessKey;
+    }
 
-	public String getGeolocationRequestHostIP() {
-		return geolocationRequestHostIP;
-	}
+    public String getGeolocationRequestHostIP() {
+        return geolocationRequestHostIP;
+    }
 
     /**
-     * The geolocation service now needs to specify the IP associated to the accessKey you're using
+     * The geolocation service now needs to specify the IP associated to the
+     * accessKey you're using
      */
-	public void setGeolocationRequestHostIP(String geolocationRequestHostIP) {
-		this.geolocationRequestHostIP = geolocationRequestHostIP;
-	}
-	
+    public void setGeolocationRequestHostIP(String geolocationRequestHostIP) {
+        this.geolocationRequestHostIP = geolocationRequestHostIP;
+    }
 
-}
\ No newline at end of file
+}
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 92e90c6..5c372a0 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
@@ -40,9 +40,11 @@ public class WeatherConfiguration {
     private final WeatherComponent component;
     private final WeatherQuery weatherQuery;
 
-    @UriPath(description = "The name value is not used.") @Metadata(required = "true")
+    @UriPath(description = "The name value is not used.")
+    @Metadata(required = "true")
     private String name;
-    @UriParam @Metadata(required = "true")
+    @UriParam
+    @Metadata(required = "true")
     private String appid;
     @UriParam
     private WeatherApi weatherApi;
@@ -108,8 +110,10 @@ public class WeatherConfiguration {
     }
 
     /**
-     * If null, the current weather will be returned, else use values of 5, 7, 14 days.
-     * Only the numeric value for the forecast period is actually parsed, so spelling, capitalisation of the time period is up to you (its ignored)
+     * If null, the current weather will be returned, else use values of 5, 7,
+     * 14 days. Only the numeric value for the forecast period is actually
+     * parsed, so spelling, capitalisation of the time period is up to you (its
+     * ignored)
      */
     public void setPeriod(String period) {
         notNull(period, "period");
@@ -159,11 +163,14 @@ public class WeatherConfiguration {
     }
 
     /**
-     * If null Camel will try and determine your current location using the geolocation of your ip address,
-     * else specify the city,country. For well known city names, Open Weather Map will determine the best fit,
-     * but multiple results may be returned. Hence specifying and country as well will return more accurate data.
-     * If you specify "current" as the location then the component will try to get the current latitude and longitude
-     * and use that to get the weather details. You can use lat and lon options instead of location.
+     * If null Camel will try and determine your current location using the
+     * geolocation of your ip address, else specify the city,country. For well
+     * known city names, Open Weather Map will determine the best fit, but
+     * multiple results may be returned. Hence specifying and country as well
+     * will return more accurate data. If you specify "current" as the location
+     * then the component will try to get the current latitude and longitude and
+     * use that to get the weather details. You can use lat and lon options
+     * instead of location.
      */
     public void setLocation(String location) {
         this.location = location;
@@ -174,7 +181,8 @@ public class WeatherConfiguration {
     }
 
     /**
-     * To store the weather result in this header instead of the message body. This is useable if you want to keep current message body as-is.
+     * To store the weather result in this header instead of the message body.
+     * This is useable if you want to keep current message body as-is.
      */
     public void setHeaderName(String headerName) {
         this.headerName = headerName;
@@ -185,8 +193,8 @@ public class WeatherConfiguration {
     }
 
     /**
-     * Latitude of location. You can use lat and lon options instead of location.
-     * For boxed queries this is the bottom latitude.
+     * Latitude of location. You can use lat and lon options instead of
+     * location. For boxed queries this is the bottom latitude.
      */
     public void setLat(String lat) {
         this.lat = lat;
@@ -197,13 +205,13 @@ public class WeatherConfiguration {
     }
 
     /**
-     * Longitude of location. You can use lat and lon options instead of location.
-     * For boxed queries this is the left longtitude.
+     * Longitude of location. You can use lat and lon options instead of
+     * location. For boxed queries this is the left longtitude.
      */
     public void setLon(String lon) {
         this.lon = lon;
     }
-    
+
     /**
      * APPID ID used to authenticate the user connected to the API Server
      */
@@ -239,8 +247,8 @@ public class WeatherConfiguration {
     }
 
     /**
-     * For boxed queries this is the right longtitude. Needs to be used
-     * in combination with topLat and zoom.
+     * For boxed queries this is the right longtitude. Needs to be used in
+     * combination with topLat and zoom.
      */
     public void setRightLon(String rightLon) {
         this.rightLon = rightLon;
@@ -251,8 +259,8 @@ public class WeatherConfiguration {
     }
 
     /**
-     * For boxed queries this is the top latitude. Needs to be used
-     * in combination with rightLon and zoom.
+     * For boxed queries this is the top latitude. Needs to be used in
+     * combination with rightLon and zoom.
      */
     public void setTopLat(String topLat) {
         this.topLat = topLat;
@@ -263,8 +271,8 @@ public class WeatherConfiguration {
     }
 
     /**
-     * For boxed queries this is the zoom. Needs to be used
-     * in combination with rightLon and topLat.
+     * For boxed queries this is the zoom. Needs to be used in combination with
+     * rightLon and topLat.
      */
     public void setZoom(Integer zoom) {
         this.zoom = zoom;
@@ -382,7 +390,7 @@ public class WeatherConfiguration {
         }
         Iterator<?> it = ObjectHelper.createIterator(id);
         while (it.hasNext()) {
-            String myId = (String) it.next();
+            String myId = (String)it.next();
             ids.add(myId);
         }
     }
@@ -413,26 +421,26 @@ public class WeatherConfiguration {
         this.weatherApi = weatherApi;
     }
 
-	public String getGeolocationAccessKey() {
-		return geolocationAccessKey;
-	}
-
+    public String getGeolocationAccessKey() {
+        return geolocationAccessKey;
+    }
 
     /**
      * The geolocation service now needs an accessKey to be used
      */
-	public void setGeolocationAccessKey(String geolocationAccessKey) {
-		this.geolocationAccessKey = geolocationAccessKey;
-	}
-
-	public String getGeolocationRequestHostIP() {
-		return geolocationRequestHostIP;
-	}
-	
+    public void setGeolocationAccessKey(String geolocationAccessKey) {
+        this.geolocationAccessKey = geolocationAccessKey;
+    }
+
+    public String getGeolocationRequestHostIP() {
+        return geolocationRequestHostIP;
+    }
+
     /**
-     * The geolocation service now needs to specify the IP associated to the accessKey you're using
+     * The geolocation service now needs to specify the IP associated to the
+     * accessKey you're using
      */
-	public void setGeolocationRequestHostIP(String geolocationRequestHostIP) {
-		this.geolocationRequestHostIP = geolocationRequestHostIP;
-	}
+    public void setGeolocationRequestHostIP(String geolocationRequestHostIP) {
+        this.geolocationRequestHostIP = geolocationRequestHostIP;
+    }
 }
diff --git a/components/camel-weather/src/main/java/org/apache/camel/component/weather/geolocation/FreeGeoIpGeoLocationProvider.java b/components/camel-weather/src/main/java/org/apache/camel/component/weather/geolocation/FreeGeoIpGeoLocationProvider.java
index e0ae56b..a896107 100644
--- a/components/camel-weather/src/main/java/org/apache/camel/component/weather/geolocation/FreeGeoIpGeoLocationProvider.java
+++ b/components/camel-weather/src/main/java/org/apache/camel/component/weather/geolocation/FreeGeoIpGeoLocationProvider.java
@@ -45,11 +45,8 @@ public class FreeGeoIpGeoLocationProvider implements GeoLocationProvider {
             throw new IllegalStateException("The geolocation service requires a mandatory geolocationRequestHostIP");
         }
         GetMethod getMethod = new GetMethod("http://api.ipstack.com/" + component.getGeolocationRequestHostIP());
-        getMethod.setQueryString(new NameValuePair[] { 
-        	    new NameValuePair("access_key", component.getGeolocationAccessKey()),
-        	    new NameValuePair("legacy", "1"),
-        	    new NameValuePair("output", "json")
-        	}); 
+        getMethod.setQueryString(new NameValuePair[] {new NameValuePair("access_key", component.getGeolocationAccessKey()), new NameValuePair("legacy", "1"),
+                                                      new NameValuePair("output", "json")});
         try {
             int statusCode = httpClient.executeMethod(getMethod);
             if (statusCode != HttpStatus.SC_OK) {