You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2018/10/26 14:29:59 UTC

[camel] 03/03: Fixed CS

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit bd0f400e58da2fa0d4018161b1242a4ad2f3c0c4
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Oct 26 16:27:58 2018 +0200

    Fixed CS
---
 .../linkedin/api/LinkedInOAuthRequestFilter.java   | 31 +++++++++++-----------
 .../api/AbstractResourceIntegrationTest.java       | 10 ++++---
 .../internal/CachingOAuthSecureStorage.java        |  2 +-
 3 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/components/camel-linkedin/camel-linkedin-api/src/main/java/org/apache/camel/component/linkedin/api/LinkedInOAuthRequestFilter.java b/components/camel-linkedin/camel-linkedin-api/src/main/java/org/apache/camel/component/linkedin/api/LinkedInOAuthRequestFilter.java
index a82a26b..c060561 100644
--- a/components/camel-linkedin/camel-linkedin-api/src/main/java/org/apache/camel/component/linkedin/api/LinkedInOAuthRequestFilter.java
+++ b/components/camel-linkedin/camel-linkedin-api/src/main/java/org/apache/camel/component/linkedin/api/LinkedInOAuthRequestFilter.java
@@ -50,7 +50,6 @@ import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput;
 import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
 import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
 import com.gargoylesoftware.htmlunit.util.WebConnectionWrapper;
-
 import org.apache.http.HttpHeaders;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpStatus;
@@ -165,23 +164,23 @@ public final class LinkedInOAuthRequestFilter implements ClientRequestFilter {
                 // only handle errors returned with redirects
                 boolean done = false;
                 do {
-                        if (e.getStatusCode() == HttpStatus.SC_MOVED_TEMPORARILY || e.getStatusCode() == HttpStatus.SC_SEE_OTHER) {
-                            final URL location = new URL(e.getResponse().getResponseHeaderValue(HttpHeaders.LOCATION));
-                            final String locationQuery = location.getQuery();
-                            if (locationQuery != null && locationQuery.contains("error=")) {
-                                throw new IOException(URLDecoder.decode(locationQuery).replaceAll("&", ", "));
-                            } else {
-                                // follow the redirect to login form
-                                try {
-                                    authPage = webClient.getPage(location);
-                                    done = true;
-                                } catch (FailingHttpStatusCodeException e1) {
-                                    e = e1;
-                                }
-                            }
+                    if (e.getStatusCode() == HttpStatus.SC_MOVED_TEMPORARILY || e.getStatusCode() == HttpStatus.SC_SEE_OTHER) {
+                        final URL location = new URL(e.getResponse().getResponseHeaderValue(HttpHeaders.LOCATION));
+                        final String locationQuery = location.getQuery();
+                        if (locationQuery != null && locationQuery.contains("error=")) {
+                            throw new IOException(URLDecoder.decode(locationQuery).replaceAll("&", ", "));
                         } else {
-                            throw e;
+                            // follow the redirect to login form
+                            try {
+                                authPage = webClient.getPage(location);
+                                done = true;
+                            } catch (FailingHttpStatusCodeException e1) {
+                                e = e1;
+                            }
                         }
+                    } else {
+                        throw e;
+                    }
                 } while (!done);
             }
 
diff --git a/components/camel-linkedin/camel-linkedin-api/src/test/java/org/apache/camel/component/linkedin/api/AbstractResourceIntegrationTest.java b/components/camel-linkedin/camel-linkedin-api/src/test/java/org/apache/camel/component/linkedin/api/AbstractResourceIntegrationTest.java
index 8d3a03e..b0b5e02 100644
--- a/components/camel-linkedin/camel-linkedin-api/src/test/java/org/apache/camel/component/linkedin/api/AbstractResourceIntegrationTest.java
+++ b/components/camel-linkedin/camel-linkedin-api/src/test/java/org/apache/camel/component/linkedin/api/AbstractResourceIntegrationTest.java
@@ -15,11 +15,16 @@
  * limitations under the License.
  */
 package org.apache.camel.component.linkedin.api;
+
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Properties;
+
+import static java.util.concurrent.TimeUnit.DAYS;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+
 import javax.ws.rs.WebApplicationException;
 
 import org.apache.camel.component.linkedin.api.model.Error;
@@ -33,17 +38,16 @@ import org.junit.BeforeClass;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static java.util.concurrent.TimeUnit.DAYS;
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
 
 /**
  * Base class for resource tests.
  */
 public abstract class AbstractResourceIntegrationTest extends Assert {
 
+    public static final long DEFAULT_EXPIRY = MILLISECONDS.convert(60, DAYS) + System.currentTimeMillis();
+
     protected static final Logger LOG = LoggerFactory.getLogger(PeopleResourceIntegrationTest.class);
     protected static final String DEFAULT_FIELDS = "";
-    public static final long DEFAULT_EXPIRY = MILLISECONDS.convert(60, DAYS) + System.currentTimeMillis();
 
     protected static LinkedInOAuthRequestFilter requestFilter;
     protected static Properties properties;
diff --git a/components/camel-linkedin/camel-linkedin-component/src/main/java/org/apache/camel/component/linkedin/internal/CachingOAuthSecureStorage.java b/components/camel-linkedin/camel-linkedin-component/src/main/java/org/apache/camel/component/linkedin/internal/CachingOAuthSecureStorage.java
index a263fab..d20db3e 100644
--- a/components/camel-linkedin/camel-linkedin-component/src/main/java/org/apache/camel/component/linkedin/internal/CachingOAuthSecureStorage.java
+++ b/components/camel-linkedin/camel-linkedin-component/src/main/java/org/apache/camel/component/linkedin/internal/CachingOAuthSecureStorage.java
@@ -24,8 +24,8 @@ import org.apache.camel.component.linkedin.api.OAuthToken;
  */
 public class CachingOAuthSecureStorage implements OAuthSecureStorage {
 
-    private final OAuthSecureStorage secureStorage;
     protected OAuthToken token;
+    private final OAuthSecureStorage secureStorage;
 
     public CachingOAuthSecureStorage(OAuthSecureStorage secureStorage) {
         this.secureStorage = secureStorage;