update link to upper-constraints.txt
[holmes/engine-management.git] / engine-d / src / main / java / org / onap / holmes / dsa / dmaappolling / Subscriber.java
index 2c9d88b..4fd52ef 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 ZTE Corporation.
+ * Copyright 2017-2022 ZTE Corporation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,11 +20,10 @@ import lombok.Getter;
 import lombok.Setter;
 import lombok.extern.slf4j.Slf4j;
 import org.onap.holmes.common.api.stat.VesAlarm;
-import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
 import org.onap.holmes.common.exception.CorrelationException;
 import org.onap.holmes.common.utils.JerseyClient;
+import org.onap.holmes.common.utils.SpringContextUtil;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.UUID;
@@ -34,8 +33,7 @@ import java.util.UUID;
 @Slf4j
 public class Subscriber {
 
-    private DMaaPResponseUtil dMaaPResponseUtil = ServiceLocatorHolder.getLocator()
-            .getService(DMaaPResponseUtil.class);
+    private DMaaPResponseUtil dMaaPResponseUtil = SpringContextUtil.getBean(DMaaPResponseUtil.class);
 
     /**
      * The number of milliseconds to wait for messages if none are immediately available. This
@@ -77,19 +75,24 @@ public class Subscriber {
         }
     }
 
-    private List<String> getDMaaPData() throws Exception {
-        return new JerseyClient()
+    private List<String> getDMaaPData() {
+        return JerseyClient.newInstance()
                 .path(consumerGroup)
                 .path(consumer)
                 .queryParam("timeout", period)
                 .get(url, List.class);
     }
 
-    private List<VesAlarm> extractVesAlarm(List<String> responseEntity) throws IOException {
+    private List<VesAlarm> extractVesAlarm(List<String> responseEntity) {
         List<VesAlarm> vesAlarmList = new ArrayList<>();
         for (String entity : responseEntity) {
-            vesAlarmList.add(dMaaPResponseUtil.convertJsonToVesAlarm(entity));
-        }
+            try {
+                       vesAlarmList.add(dMaaPResponseUtil.convertJsonToVesAlarm(entity));
+                   } catch (Exception e) {
+               log.error("Failed to convert the response data to VES alarm ", e);
+               //Continue with other events
+            }
+       }
         return vesAlarmList;
     }
 }