summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIsaac Manuel Raj <isaac.manuelraj@huawei.com>2019-04-12 11:50:33 +0530
committerIsaac Manuel Raj <isaac.manuelraj@huawei.com>2019-04-12 11:50:33 +0530
commite32315ad60357eeca4a00fa12f9108442fe11bb8 (patch)
tree06e379198d2c598cb386abdcf907ca03653dc578
parent3309730ba1c81602bc17baee30484fa8b2a06200 (diff)
Code Enhancement (Sonar Fixes)
Sonar Issues Fixes Issue-ID: SO-1490 Change-Id: I1cba16fafce421c2b3589f86ffd696dc8d8ca3d7 Signed-off-by: Isaac Manuel Raj <isaac.manuelraj@huawei.com>
-rw-r--r--openstack-client-connectors/http-connector/src/main/java/com/woorea/openstack/connector/HttpClientRedirectStrategy.java38
-rw-r--r--openstack-client-connectors/http-connector/src/main/java/com/woorea/openstack/connector/HttpClientResponse.java34
2 files changed, 14 insertions, 58 deletions
diff --git a/openstack-client-connectors/http-connector/src/main/java/com/woorea/openstack/connector/HttpClientRedirectStrategy.java b/openstack-client-connectors/http-connector/src/main/java/com/woorea/openstack/connector/HttpClientRedirectStrategy.java
index f9aedf5..c611e13 100644
--- a/openstack-client-connectors/http-connector/src/main/java/com/woorea/openstack/connector/HttpClientRedirectStrategy.java
+++ b/openstack-client-connectors/http-connector/src/main/java/com/woorea/openstack/connector/HttpClientRedirectStrategy.java
@@ -14,28 +14,6 @@
* ============LICENSE_END=========================================================
*/
-/*
- * ============LICENSE_START==========================================
- * ===================================================================
- * Copyright © 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;
@@ -60,10 +38,10 @@ import org.apache.http.protocol.HttpContext;
* 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.
+ * redirect to perform the actual deletion.
*/
@Immutable
public class HttpClientRedirectStrategy extends DefaultRedirectStrategy {
@@ -72,9 +50,9 @@ public class HttpClientRedirectStrategy extends DefaultRedirectStrategy {
* Redirectable methods.
*/
private static final String[] REDIRECT_METHODS = new String[] {
- HttpGet.METHOD_NAME,
- HttpDelete.METHOD_NAME,
- HttpHead.METHOD_NAME
+ HttpGet.METHOD_NAME,
+ HttpDelete.METHOD_NAME,
+ HttpHead.METHOD_NAME
};
/**
@@ -102,7 +80,7 @@ public class HttpClientRedirectStrategy extends DefaultRedirectStrategy {
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)) {
@@ -112,7 +90,7 @@ public class HttpClientRedirectStrategy extends DefaultRedirectStrategy {
} else {
final int status = response.getStatusLine().getStatusCode();
-
+
HttpUriRequest newRequest;
if (status == HttpStatus.SC_TEMPORARY_REDIRECT || status == HttpStatus.SC_MOVED_TEMPORARILY) {
newRequest = RequestBuilder.copy(request).setUri(uri).build();
@@ -122,4 +100,4 @@ public class HttpClientRedirectStrategy extends DefaultRedirectStrategy {
return newRequest;
}
}
-}
+} \ No newline at end of file
diff --git a/openstack-client-connectors/http-connector/src/main/java/com/woorea/openstack/connector/HttpClientResponse.java b/openstack-client-connectors/http-connector/src/main/java/com/woorea/openstack/connector/HttpClientResponse.java
index 41466a6..468e859 100644
--- a/openstack-client-connectors/http-connector/src/main/java/com/woorea/openstack/connector/HttpClientResponse.java
+++ b/openstack-client-connectors/http-connector/src/main/java/com/woorea/openstack/connector/HttpClientResponse.java
@@ -14,28 +14,6 @@
* ============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