Merge "Reorder modifiers"
[so.git] / bpmn / MSORESTClient / src / main / java / org / openecomp / mso / rest / RESTClient.java
index cab3e50..3170e49 100644 (file)
@@ -1,8 +1,9 @@
 /*-
  * ============LICENSE_START=======================================================
- * OPENECOMP - MSO
+ * ONAP - SO
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
@@ -54,6 +55,7 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
 import org.apache.http.message.AbstractHttpMessage;
 import org.apache.http.util.EntityUtils;
 
+import org.openecomp.mso.logger.MsoLogger;
 /**
  * Client used to send RESTFul requests.
  * <p>
@@ -82,6 +84,8 @@ import org.apache.http.util.EntityUtils;
  * @since 1.0
  */
 public class RESTClient {
+       
+       private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
     private final String proxyHost;
     private final int proxyPort;
 
@@ -166,8 +170,7 @@ public class RESTClient {
                 }
             }
         } catch (UnsupportedEncodingException e) {
-            // should not occur
-            e.printStackTrace();
+            LOGGER.debug("Exception :", e);
         }
         return sb.toString();
     }
@@ -197,6 +200,7 @@ public class RESTClient {
                        clientBuilder = HttpClientBuilder.create().setConnectionManager(
                                        manager);
                } catch (Exception ex) {
+                       LOGGER.debug("Exception :", ex);
                        throw new RESTException(ex.getMessage());
                }
                clientBuilder.disableRedirectHandling();
@@ -238,16 +242,16 @@ public class RESTClient {
     /**
      * Creates a RESTClient with the RESTConfig object.
      *
-     * @param RESTConfig config to use for sending request
+     * @param restConfig config to use for sending request
      *
      * @throws RESTException if unable to create a RESTClient
      */
-    public RESTClient(RESTConfig cfg) throws RESTException {
-        this.headers = new LinkedHashMap<String, List<String>>();
-        this.parameters = new LinkedHashMap<String, List<String>>();
-        this.URL = cfg.getURL();
-        this.proxyHost = cfg.getProxyHost();
-        this.proxyPort = cfg.getProxyPort();
+    public RESTClient(RESTConfig restConfig) throws RESTException {
+        this.headers = new LinkedHashMap<>();
+        this.parameters = new LinkedHashMap<>();
+        this.URL = restConfig.getURL();
+        this.proxyHost = restConfig.getProxyHost();
+        this.proxyPort = restConfig.getProxyPort();
     }
 
     /**
@@ -262,7 +266,7 @@ public class RESTClient {
      */
     public RESTClient addParameter(String name, String value) {
         if (!parameters.containsKey(name)) {
-            parameters.put(name, new ArrayList<String>());
+            parameters.put(name, new ArrayList<>());
         }
 
         List<String> values = parameters.get(name);
@@ -302,7 +306,7 @@ public class RESTClient {
      */
     public RESTClient addHeader(String name, String value) {
         if (!headers.containsKey(name)) {
-            headers.put(name, new ArrayList<String>());
+            headers.put(name, new ArrayList<>());
         }
 
         List<String> values = headers.get(name);