1 /*******************************************************************************
2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 Wipro Limited.
6 * Copyright (C) 2022 CTC, Inc.
7 * ==============================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 *******************************************************************************/
23 package org.onap.slice.analysis.ms.dmaap;
25 import java.io.IOException;
28 import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.api.MessageRouterPublisher;
29 import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.MessageRouterPublishRequest;
30 import org.onap.slice.analysis.ms.models.Configuration;
31 import org.onap.slice.analysis.ms.utils.DcaeDmaapUtil;
34 * Client class to handle Policy interactions
36 public class PolicyDmaapClient {
38 private Configuration configuration;
40 public PolicyDmaapClient(Configuration configuration) {
41 this.configuration = configuration;
45 * Method stub for sending notification to policy.
47 @SuppressWarnings("unchecked")
48 public boolean sendNotificationToPolicy(String msg) {
49 Map<String, Object> streamsPublishes = configuration.getStreamsPublishes();
50 String policyTopicUrl = ((Map<String, String>) ((Map<String, Object>) streamsPublishes.get("CL_topic"))
51 .get("dmaap_info")).get("topic_url");
53 MessageRouterPublisher publisher = DcaeDmaapUtil.buildPublisher();
54 MessageRouterPublishRequest request = DcaeDmaapUtil.buildPublisherRequest("CL_topic", policyTopicUrl);
56 NotificationProducer notificationProducer = new NotificationProducer(publisher, request);
57 notificationProducer.sendNotification(msg);
58 } catch (IOException e) {