Code Enhancement (Sonar Fixes) 52/85152/1
authorIsaac Manuel Raj <isaac.manuelraj@huawei.com>
Fri, 12 Apr 2019 06:20:33 +0000 (11:50 +0530)
committerIsaac Manuel Raj <isaac.manuelraj@huawei.com>
Fri, 12 Apr 2019 06:20:33 +0000 (11:50 +0530)
Sonar Issues Fixes

Issue-ID: SO-1490

Change-Id: I1cba16fafce421c2b3589f86ffd696dc8d8ca3d7
Signed-off-by: Isaac Manuel Raj <isaac.manuelraj@huawei.com>
openstack-client-connectors/http-connector/src/main/java/com/woorea/openstack/connector/HttpClientRedirectStrategy.java
openstack-client-connectors/http-connector/src/main/java/com/woorea/openstack/connector/HttpClientResponse.java

index f9aedf5..c611e13 100644 (file)
  * ============LICENSE_END=========================================================\r
  */\r
 \r
-/*\r
- * ============LICENSE_START==========================================\r
- * ===================================================================\r
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * ===================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *        http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END============================================\r
- *\r
- * ECOMP and OpenECOMP are trademarks\r
- * and service marks of AT&T Intellectual Property.\r
- *\r
- */\r
 \r
 package com.woorea.openstack.connector;\r
 \r
@@ -60,10 +38,10 @@ import org.apache.http.protocol.HttpContext;
  * The {@link org.apache.http.client.DefaultRedirectStrategy} only\r
  * redirects GET and HEAD automatically, per the HTTP specification\r
  * (POST and PUT typically have bodies and thus cannot be redirected).\r
- * \r
+ *\r
  * A custom strategy is needed for the Openstack API, which can also send\r
  * 302 on a DELETE (by name) request, expecting the client to follow the\r
- * redirect to perform the actual deletion. \r
+ * redirect to perform the actual deletion.\r
  */\r
 @Immutable\r
 public class HttpClientRedirectStrategy extends DefaultRedirectStrategy {\r
@@ -72,9 +50,9 @@ public class HttpClientRedirectStrategy extends DefaultRedirectStrategy {
      * Redirectable methods.\r
      */\r
     private static final String[] REDIRECT_METHODS = new String[] {\r
-        HttpGet.METHOD_NAME,\r
-        HttpDelete.METHOD_NAME,\r
-        HttpHead.METHOD_NAME\r
+            HttpGet.METHOD_NAME,\r
+            HttpDelete.METHOD_NAME,\r
+            HttpHead.METHOD_NAME\r
     };\r
 \r
     /**\r
@@ -102,7 +80,7 @@ public class HttpClientRedirectStrategy extends DefaultRedirectStrategy {
             final HttpRequest request,\r
             final HttpResponse response,\r
             final HttpContext context) throws ProtocolException {\r
-        \r
+\r
         final URI uri = getLocationURI(request, response, context);\r
         final String method = request.getRequestLine().getMethod();\r
         if (method.equalsIgnoreCase(HttpHead.METHOD_NAME)) {\r
@@ -112,7 +90,7 @@ public class HttpClientRedirectStrategy extends DefaultRedirectStrategy {
         } else {\r
 \r
             final int status = response.getStatusLine().getStatusCode();\r
-            \r
+\r
             HttpUriRequest newRequest;\r
             if (status == HttpStatus.SC_TEMPORARY_REDIRECT || status == HttpStatus.SC_MOVED_TEMPORARILY) {\r
                 newRequest = RequestBuilder.copy(request).setUri(uri).build();\r
@@ -122,4 +100,4 @@ public class HttpClientRedirectStrategy extends DefaultRedirectStrategy {
             return newRequest;\r
         }\r
     }\r
-}\r
+}
\ No newline at end of file
index 41466a6..468e859 100644 (file)
  * ============LICENSE_END=========================================================
  */
 
-/*
- * ============LICENSE_START==========================================
- * ===================================================================
- * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
- * ===================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- *
- * ECOMP and OpenECOMP are trademarks
- * and service marks of AT&T Intellectual Property.
- *
- */
 
 package com.woorea.openstack.connector;
 
@@ -57,21 +35,21 @@ import java.util.Map;
 public class HttpClientResponse implements OpenStackResponse {
 
     private static Logger LOGGER = LoggerFactory.getLogger(HttpClientConnector.class);
-    
+
     private HttpResponse response = null;
     private String entityBody = null;
 
     public HttpClientResponse(HttpResponse response)
     {
         this.response = response;
-        
+
         // Read the body so InputStream can be closed
         if (response.getEntity() == null) {
             // No body
             LOGGER.debug ("No Response Body");
             return;
         }
-        
+
         ByteArrayOutputStream responseBody = new ByteArrayOutputStream();
         try {
             response.getEntity().writeTo(responseBody);
@@ -82,7 +60,7 @@ public class HttpClientResponse implements OpenStackResponse {
         LOGGER.debug (entityBody);
     }
 
-    
+
     @Override
     public <T> T getEntity (Class<T> returnType) {
         // Get appropriate mapper, based on existence of a root element
@@ -104,7 +82,7 @@ public class HttpClientResponse implements OpenStackResponse {
 
     @Override
     public InputStream getInputStream() {
-           return new ByteArrayInputStream (entityBody.getBytes());
+        return new ByteArrayInputStream (entityBody.getBytes());
     }
 
     @Override
@@ -124,4 +102,4 @@ public class HttpClientResponse implements OpenStackResponse {
         return headers;
     }
 
-}
+}
\ No newline at end of file