Improvements in RequestClientFactory 89/88889/1
authorr.bogacki <r.bogacki@samsung.com>
Thu, 30 May 2019 13:16:57 +0000 (15:16 +0200)
committerr.bogacki <r.bogacki@samsung.com>
Thu, 30 May 2019 13:19:15 +0000 (15:19 +0200)
Improvements in RequestClientFactory according to the Sonar analysis.
Fixed imports.
Removed unnecessary exceptions handling.
Replaced depreciated  DefaultHttpClient with a new one.

Issue-ID: SO-1947
Signed-off-by: Robert Bogacki <r.bogacki@samsung.com>
Change-Id: Id497bfb620775aac67ad4c5f6d57e0fccce4fd34

mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/RequestClientFactory.java

index 4149d5e..c2ffa7e 100644 (file)
@@ -4,6 +4,9 @@
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
+ *
  * 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
@@ -20,9 +23,7 @@
 
 package org.onap.so.apihandler.common;
 
-
-
-import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;
 import org.springframework.stereotype.Component;
@@ -34,7 +35,7 @@ public class RequestClientFactory {
     private Environment env;
 
     // based on URI, returns BPEL, CamundaTask or Camunda client
-    public RequestClient getRequestClient(String orchestrationURI) throws IllegalStateException {
+    public RequestClient getRequestClient(String orchestrationURI) {
         RequestClient retClient;
 
         String url;
@@ -45,7 +46,7 @@ public class RequestClientFactory {
             url = env.getProperty(CommonConstants.CAMUNDA_URL) + orchestrationURI;
             retClient = new CamundaClient();
         }
-        retClient.setClient(new DefaultHttpClient());
+        retClient.setClient(HttpClientBuilder.create().build());
         retClient.setProps(env);
         retClient.setUrl(url);
         return retClient;