Remove sonar code smells from sdnc-a1-controller 17/2817/1
authorRehanRaza <muhammad.rehan.raza@est.tech>
Mon, 16 Mar 2020 15:26:25 +0000 (16:26 +0100)
committerRehanRaza <muhammad.rehan.raza@est.tech>
Tue, 17 Mar 2020 07:48:50 +0000 (08:48 +0100)
Change-Id: I85344bad6ac1a9205320d5b158040c5d94e56ea2
Issue-ID: NONRTRIC-142
Signed-off-by: RehanRaza <muhammad.rehan.raza@est.tech>
sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/main/java/org/onap/sdnc/northbound/provider/NonrtRicApiProvider.java
sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/main/java/org/onap/sdnc/northbound/restadapter/NearRicUrlProvider.java
sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/main/java/org/onap/sdnc/northbound/restadapter/RestAdapterImpl.java

index c0c46a7..95acacb 100644 (file)
@@ -23,11 +23,7 @@ package org.onap.sdnc.northbound.provider;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
 import java.util.List;
-import java.util.TimeZone;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -74,6 +70,7 @@ import org.springframework.http.ResponseEntity;
  *
  */
 
+@SuppressWarnings("squid:S1874") // "@Deprecated" code should not be used
 public class NonrtRicApiProvider implements AutoCloseable, A1ADAPTERAPIService {
 
   protected static final String APP_NAME = "nonrt-ric-api";
@@ -123,20 +120,6 @@ public class NonrtRicApiProvider implements AutoCloseable, A1ADAPTERAPIService {
     log.info("Successfully closed provider for {}", APP_NAME);
   }
 
-  private static class Iso8601Util {
-
-    private static TimeZone timeZone = TimeZone.getTimeZone("UTC");
-    private DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
-
-    private Iso8601Util() {
-      dateFormat.setTimeZone(timeZone);
-    }
-
-    private String now() {
-      return dateFormat.format(new Date());
-    }
-  }
-
   public void setDataBroker(DataBroker dataBroker) {
     this.dataBroker = dataBroker;
     if (log.isDebugEnabled()) {
@@ -249,7 +232,7 @@ public class NonrtRicApiProvider implements AutoCloseable, A1ADAPTERAPIService {
     DeletePolicyOutputBuilder responseBuilder = new DeletePolicyOutputBuilder();
     String uri = nearRicUrlProvider.deletePolicyUrl(String.valueOf(input.getNearRtRicUrl()),
             String.valueOf(input.getPolicyId()));
-    ResponseEntity<Void> response = restAdapter.delete(uri);
+    restAdapter.delete(uri);
     log.info("End of deletePolicy");
     RpcResult<DeletePolicyOutput> rpcResult = RpcResultBuilder
         .<DeletePolicyOutput>status(true).withResult(responseBuilder.build()).build();
index afa1d9f..9e9d28a 100644 (file)
@@ -20,8 +20,6 @@
 
 package org.onap.sdnc.northbound.restadapter;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpMethod;
@@ -38,8 +36,6 @@ import org.springframework.web.client.RestTemplate;
 
 public class RestAdapterImpl implements RestAdapter {
 
-  private final Logger log = LoggerFactory.getLogger(RestAdapterImpl.class);
-
   private RestTemplate restTemplate;
 
   public RestAdapterImpl() {
@@ -60,7 +56,7 @@ public class RestAdapterImpl implements RestAdapter {
   public <T> ResponseEntity<T> put(String uri, String body, Class<T> clazz) {
     HttpHeaders headers = new HttpHeaders();
     headers.setContentType(MediaType.APPLICATION_JSON);
-    HttpEntity<String> entity = new HttpEntity<String>(body, headers);
+    HttpEntity<String> entity = new HttpEntity<>(body, headers);
     return invokeHttpRequest(uri, HttpMethod.PUT, clazz, entity);
   }