a59022c3f08900da643eb55007a80716eeed5544
[ccsdk/cds.git] / ms / sdclistener / application / src / main / java / org / onap / ccsdk / cds / sdclistener / dto / SdcListenerDto.java
1 /*
2  * Copyright © 2019 Bell Canada
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.onap.ccsdk.cds.sdclistener.dto;
17
18 import io.grpc.ManagedChannel;
19 import io.grpc.ManagedChannelBuilder;
20 import org.onap.ccsdk.cds.sdclistener.client.SdcListenerAuthClientInterceptor;
21 import org.onap.sdc.api.IDistributionClient;
22 import org.springframework.beans.factory.annotation.Autowired;
23 import org.springframework.beans.factory.annotation.Value;
24 import org.springframework.boot.context.properties.ConfigurationProperties;
25 import org.springframework.stereotype.Component;
26
27 @Component
28 @ConfigurationProperties("listenerservice")
29 public class SdcListenerDto {
30
31     @Value("${listenerservice.config.grpcAddress}")
32     private String grpcAddress;
33
34     @Value("${listenerservice.config.grpcPort}")
35     private int grpcPort;
36
37     private String artifactUrl;
38
39     @Autowired
40     private SdcListenerAuthClientInterceptor sdcListenerAuthClientInterceptor;
41
42     private IDistributionClient distributionClient;
43     private ManagedChannel managedChannel;
44     private String distributionId;
45
46     public IDistributionClient getDistributionClient() {
47         return distributionClient;
48     }
49
50     public void setDistributionClient(IDistributionClient distributionClient) {
51         this.distributionClient = distributionClient;
52     }
53
54     public void setDistributionId(String id) {
55         this.distributionId = id;
56     }
57
58     public String getDistributionId() {
59         return distributionId;
60     }
61
62     public void setManagedChannelForGrpc() {
63         managedChannel = ManagedChannelBuilder.forAddress(grpcAddress, grpcPort)
64             .usePlaintext()
65             .intercept(sdcListenerAuthClientInterceptor)
66             .build();
67     }
68
69     public ManagedChannel getManagedChannelForGrpc() {
70         return managedChannel;
71     }
72
73     public String getArtifactUrl() {
74         return artifactUrl;
75     }
76
77     public void setArtifactUrl(String artifactUrl) {
78         this.artifactUrl = artifactUrl;
79     }
80 }