Replaced all tabs with spaces in java and pom.xml
[so.git] / cloudify-client / src / main / java / org / onap / so / cloudify / connector / http / HttpClientRedirectStrategy.java
index a7575ff..b8b4a5b 100644 (file)
@@ -21,7 +21,6 @@
 package org.onap.so.cloudify.connector.http;
 
 import java.net.URI;
-
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
@@ -36,15 +35,12 @@ import org.apache.http.impl.client.DefaultRedirectStrategy;
 import org.apache.http.protocol.HttpContext;
 
 /**
- * Custom {@link org.apache.http.client.RedirectStrategy} implementation
- * that automatically redirects all HEAD, GET and DELETE requests.
- * The {@link org.apache.http.client.DefaultRedirectStrategy} only
- * redirects GET and HEAD automatically, per the HTTP specification
- * (POST and PUT typically have bodies and thus cannot be redirected).
+ * Custom {@link org.apache.http.client.RedirectStrategy} implementation that automatically redirects all HEAD, GET and
+ * DELETE requests. The {@link org.apache.http.client.DefaultRedirectStrategy} only redirects GET and HEAD
+ * automatically, per the HTTP specification (POST and PUT typically have bodies and thus cannot be redirected).
  * 
- * A custom strategy is needed for the Openstack API, which can also send
- * 302 on a DELETE (by name) request, expecting the client to follow the
- * redirect to perform the actual deletion. 
+ * A custom strategy is needed for the Openstack API, which can also send 302 on a DELETE (by name) request, expecting
+ * the client to follow the redirect to perform the actual deletion.
  */
 @Immutable
 public class HttpClientRedirectStrategy extends DefaultRedirectStrategy {
@@ -52,20 +48,16 @@ public class HttpClientRedirectStrategy extends DefaultRedirectStrategy {
     /**
      * Redirectable methods.
      */
-    private static final String[] REDIRECT_METHODS = new String[] {
-        HttpGet.METHOD_NAME,
-        HttpDelete.METHOD_NAME,
-        HttpHead.METHOD_NAME
-    };
+    private static final String[] REDIRECT_METHODS =
+            new String[] {HttpGet.METHOD_NAME, HttpDelete.METHOD_NAME, HttpHead.METHOD_NAME};
 
     /**
-     * Determine if the request should be redirected.
-     * This may not actually be needed, since the REDIRECT_METHODS
-     * array has been updated with the DELETE.
+     * Determine if the request should be redirected. This may not actually be needed, since the REDIRECT_METHODS array
+     * has been updated with the DELETE.
      */
     @Override
     protected boolean isRedirectable(final String method) {
-        for (final String m: REDIRECT_METHODS) {
+        for (final String m : REDIRECT_METHODS) {
             if (m.equalsIgnoreCase(method)) {
                 return true;
             }
@@ -74,16 +66,13 @@ public class HttpClientRedirectStrategy extends DefaultRedirectStrategy {
     }
 
     /**
-     * Override the default redirect handling method.  As implemented
-     * in HttpClient, it does not preserve the method on 301 or 302
-     * responses, always redirecting to a GET.
+     * Override the default redirect handling method. As implemented in HttpClient, it does not preserve the method on
+     * 301 or 302 responses, always redirecting to a GET.
      */
     @Override
-    public HttpUriRequest getRedirect(
-            final HttpRequest request,
-            final HttpResponse response,
-            final HttpContext context) throws ProtocolException {
-       
+    public HttpUriRequest getRedirect(final HttpRequest request, final HttpResponse response, final HttpContext context)
+            throws ProtocolException {
+
         final URI uri = getLocationURI(request, response, context);
         final String method = request.getRequestLine().getMethod();
         if (method.equalsIgnoreCase(HttpHead.METHOD_NAME)) {
@@ -93,14 +82,14 @@ public class HttpClientRedirectStrategy extends DefaultRedirectStrategy {
         } else {
 
             final int status = response.getStatusLine().getStatusCode();
-            
-               HttpUriRequest newRequest = null;
-               if (status == HttpStatus.SC_TEMPORARY_REDIRECT || status == HttpStatus.SC_MOVED_TEMPORARILY) {
+
+            HttpUriRequest newRequest = null;
+            if (status == HttpStatus.SC_TEMPORARY_REDIRECT || status == HttpStatus.SC_MOVED_TEMPORARILY) {
                 newRequest = RequestBuilder.copy(request).setUri(uri).build();
             } else {
-                newRequest =  new HttpGet(uri);
+                newRequest = new HttpGet(uri);
             }
-               return newRequest;
+            return newRequest;
         }
     }
 }