Formatting Code base with ktlint
[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
17 package org.onap.ccsdk.cds.sdclistener.dto;
18
19 import io.grpc.ManagedChannel;
20 import io.grpc.ManagedChannelBuilder;
21 import org.onap.ccsdk.cds.sdclistener.client.SdcListenerAuthClientInterceptor;
22 import org.onap.sdc.api.IDistributionClient;
23 import org.springframework.beans.factory.annotation.Autowired;
24 import org.springframework.beans.factory.annotation.Value;
25 import org.springframework.boot.context.properties.ConfigurationProperties;
26 import org.springframework.stereotype.Component;
27
28 @Component
29 @ConfigurationProperties("listenerservice")
30 public class SdcListenerDto {
31
32     @Value("${listenerservice.config.grpcAddress}")
33     private String grpcAddress;
34
35     @Value("${listenerservice.config.grpcPort}")
36     private int grpcPort;
37
38     private String artifactUrl;
39
40     @Autowired
41     private SdcListenerAuthClientInterceptor sdcListenerAuthClientInterceptor;
42
43     private IDistributionClient distributionClient;
44     private ManagedChannel managedChannel;
45     private String distributionId;
46
47     public IDistributionClient getDistributionClient() {
48         return distributionClient;
49     }
50
51     public void setDistributionClient(IDistributionClient distributionClient) {
52         this.distributionClient = distributionClient;
53     }
54
55     public void setDistributionId(String id) {
56         this.distributionId = id;
57     }
58
59     public String getDistributionId() {
60         return distributionId;
61     }
62
63     public void setManagedChannelForGrpc() {
64         managedChannel = ManagedChannelBuilder.forAddress(grpcAddress, grpcPort)
65                 .usePlaintext()
66                 .intercept(sdcListenerAuthClientInterceptor)
67                 .build();
68     }
69
70     public ManagedChannel getManagedChannelForGrpc() {
71         return managedChannel;
72     }
73
74     public String getArtifactUrl() {
75         return artifactUrl;
76     }
77
78     public void setArtifactUrl(String artifactUrl) {
79         this.artifactUrl = artifactUrl;
80     }
81
82 }