X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=models-sim%2Fmodels-sim-dmaap%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fmodels%2Fsim%2Fdmaap%2Fprovider%2FDmaapSimProvider.java;h=afbe10f5145efcfe4aa2e36e9acc920cd9de6ac9;hb=71be21fd5b9b52c613bb855f00a79a51e81906dd;hp=d11d1b397d7fef67c199bd73697df67898dac595;hpb=3b44a9887ab7ba8d0ba4f1159e2fc0a93c0247d0;p=policy%2Fmodels.git diff --git a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/DmaapSimProvider.java b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/DmaapSimProvider.java index d11d1b397..afbe10f51 100644 --- a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/DmaapSimProvider.java +++ b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/DmaapSimProvider.java @@ -1,7 +1,8 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019, 2023 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Bell Canada. 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. @@ -21,6 +22,8 @@ package org.onap.policy.models.sim.dmaap.provider; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; @@ -29,8 +32,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; import lombok.Getter; import lombok.Setter; import org.onap.policy.common.utils.services.ServiceManagerContainer; @@ -129,15 +130,9 @@ public class DmaapSimProvider extends ServiceManagerContainer { List lst = topic2data.computeIfAbsent(topicName, this::makeTopicData).read(consumerGroup, limit, timeoutMs); - if (lst.isEmpty() && timeoutMs > 0) { - LOGGER.debug("Topic: {}, Timed out waiting for messages: {}: {}", topicName, consumerGroup, consumerId); - return Response.status(Status.REQUEST_TIMEOUT).entity(lst).build(); - - } else { - LOGGER.debug("Topic: {}, Retrieved {} messages for: {}: {}", topicName, consumerGroup, lst.size(), - consumerId); - return Response.status(Status.OK).entity(lst).build(); - } + LOGGER.debug("Topic: {}, Retrieved {} messages for: {}: {}", topicName, lst.size(), consumerGroup, + consumerId); + return Response.status(Status.OK).entity(lst).build(); } catch (InterruptedException e) { LOGGER.warn("Topic: {}, Request for DMaaP message interrupted: {}: {}", topicName, consumerGroup, @@ -147,6 +142,20 @@ public class DmaapSimProvider extends ServiceManagerContainer { } } + /** + * Returns the list of default topics. + * + * @return the topic list + */ + public Response processDmaapTopicsGet() { + + LOGGER.debug("Request for listing DMaaP topics"); + var response = new DmaapGetTopicResponse(); + response.setTopics(List.of("POLICY-PDP-PAP", "POLICY-NOTIFICATION", "unauthenticated.DCAE_CL_OUTPUT", + "POLICY-CL-MGT")); + return Response.status(Status.OK).entity(response).build(); + } + /** * Task to remove idle consumers from each topic. */