2 * Copyright (C) 2019 Bell Canada. All rights reserved.
4 * NOTICE: All the intellectual and technical concepts contained herein are
5 * proprietary to Bell Canada and are protected by trade secret or copyright law.
6 * Unauthorized copying of this file, via any medium is strictly prohibited.
9 package org.onap.ccsdk.cds.cdssdclistener.handler;
11 import io.grpc.ManagedChannel;
12 import org.onap.ccsdk.cds.controllerblueprints.common.api.Status;
13 import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintManagementOutput;
14 import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintManagementServiceGrpc;
15 import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintManagementServiceGrpc.BluePrintManagementServiceBlockingStub;
16 import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintUploadInput;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
19 import org.springframework.boot.context.properties.ConfigurationProperties;
20 import org.springframework.stereotype.Component;
22 @ConfigurationProperties("listenerservice")
24 public class BluePrintProcesssorHandler implements AutoCloseable {
26 private static final Logger LOGGER = LoggerFactory.getLogger(BluePrintProcesssorHandler.class);
28 private ManagedChannel channel;
31 * Sending CBA archive to CDS backend to store into its Database.
33 * @param request BluePrintManagementInput object holds CBA archive, its version and blueprints.
34 * @param managedChannel - ManagedChannel object helps to access the server or application end point.
35 * @return A response object
37 public Status sendRequest(BluePrintUploadInput request, ManagedChannel managedChannel) {
38 LOGGER.info("Sending request to blueprint processor");
40 this.channel = managedChannel;
42 final BluePrintManagementServiceBlockingStub syncStub = BluePrintManagementServiceGrpc.newBlockingStub(channel);
44 // Send the request to CDS backend.
45 final BluePrintManagementOutput response = syncStub.uploadBlueprint(request);
47 return response.getStatus();
52 if (channel != null) {
55 LOGGER.info("Stopping GRPC connection to CDS backend");