import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import javax.inject.Inject;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import lombok.Setter;
import org.glassfish.jersey.client.ClientConfig;
import org.onap.holmes.common.api.stat.VesAlarm;
+import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
import org.onap.holmes.common.exception.CorrelationException;
@Getter
@Setter
public class Subscriber {
- @Inject
- private DMaaPResponseUtil dMaaPResponseUtil;
+ private DMaaPResponseUtil dMaaPResponseUtil = ServiceLocatorHolder.getLocator()
+ .getService(DMaaPResponseUtil.class);
/**
* The number of milliseconds to wait for messages if none are immediately available. This
try {
response = getDMaaPData();
} catch (Exception e) {
- throw new CorrelationException("Failed to connect to DMapp.", e);
+ throw new CorrelationException("Failed to get DMapp data.", e);
}
try {
return extractVesAlarm(response);
private List<String> getDMaaPData() {
Client client = ClientBuilder.newClient(new ClientConfig());
- WebTarget webTarget = client.target(url);
- Response response = webTarget.path(topic).path(consumerGroup).path(consumer).request().get();
+ WebTarget webTarget = client.target(url + "/" + consumerGroup + "/" + consumer);
+ Response response = webTarget.request().get();
return response.readEntity(List.class);
}