Merge "fix oauth code"
[ccsdk/features.git] / sdnr / wt / mountpoint-registrar / provider / src / main / java / org / onap / ccsdk / features / sdnr / wt / mountpointregistrar / config / MessageConfig.java
1 /*
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt mountpoint-registrar
4  * =================================================================================================
5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6  * Copyright (C) 2021 Samsung Electronics Intellectual Property. All rights reserved.
7  * =================================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
9  * in compliance with the License. You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software distributed under the License
14  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
15  * or implied. See the License for the specific language governing permissions and limitations under
16  * the License.
17  * ============LICENSE_END==========================================================================
18  */
19
20 package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.config;
21
22 import org.onap.ccsdk.features.sdnr.wt.common.configuration.Configuration;
23 import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
24
25
26 public abstract class MessageConfig implements Configuration {
27     protected String sectionMarker;
28
29     public static final String PROPERTY_KEY_CONSUMER_TOPIC = "topic";
30
31     public static final String PROPERTY_KEY_CONSUMER_GROUP = "consumerGroup";
32     private static final String DEFAULT_VALUE_CONSUMER_GROUP = "myG";
33
34     public static final String PROPERTY_KEY_CONSUMER_ID = "consumerID";
35     private static final String DEFAULT_VALUE_CONSUMER_ID = "C1";
36
37     public static final String PROPERTY_KEY_CONSUMER_TIMEOUT = "timeout";
38     private static final String DEFAULT_VALUE_CONSUMER_TIMEOUT = "2000";
39
40     public static final String PROPERTY_KEY_CONSUMER_LIMIT = "limit";
41     private static final String DEFAULT_VALUE_CONSUMER_LIMIT = "1000";
42
43     public static final String PROPERTY_KEY_CONSUMER_FETCHPAUSE = "fetchPause";
44     private static final String DEFAULT_VALUE_CONSUMER_FETCHPAUSE = "5000";
45
46     protected ConfigurationFileRepresentation configuration;
47
48     public MessageConfig(ConfigurationFileRepresentation configuration) {
49         this.configuration = configuration;
50     }
51
52     @Override
53     public String getSectionName() {
54         return sectionMarker;
55     }
56
57     @Override
58     public void defaults() {
59         configuration.setPropertyIfNotAvailable(sectionMarker, PROPERTY_KEY_CONSUMER_GROUP,
60                 DEFAULT_VALUE_CONSUMER_GROUP);
61         configuration.setPropertyIfNotAvailable(sectionMarker, PROPERTY_KEY_CONSUMER_ID, DEFAULT_VALUE_CONSUMER_ID);
62         configuration.setPropertyIfNotAvailable(sectionMarker, PROPERTY_KEY_CONSUMER_TIMEOUT,
63                 DEFAULT_VALUE_CONSUMER_TIMEOUT);
64         configuration.setPropertyIfNotAvailable(sectionMarker, PROPERTY_KEY_CONSUMER_LIMIT,
65                 DEFAULT_VALUE_CONSUMER_LIMIT);
66         configuration.setPropertyIfNotAvailable(sectionMarker, PROPERTY_KEY_CONSUMER_FETCHPAUSE,
67                 DEFAULT_VALUE_CONSUMER_FETCHPAUSE);
68     }
69
70     public String getTopic() {
71         return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_TOPIC);
72     }
73
74     public String getConsumerGroup() {
75         return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_GROUP);
76     }
77
78     public String getConsumerId() {
79         return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_ID);
80     }
81
82     public String getTimeout() {
83         return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_TIMEOUT);
84     }
85
86     public String getLimit() {
87         return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_LIMIT);
88     }
89
90     public String getFetchPause() {
91         return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_FETCHPAUSE);
92     }
93
94 }