Removing blueprints-processor
[ccsdk/features.git] / sdnr / wt / mountpoint-state-provider / provider / src / main / java / org / onap / ccsdk / features / sdnr / wt / mountpointstateprovider / impl / GeneralConfig.java
1 /*******************************************************************************
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt
4  * =================================================================================================
5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6  * =================================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software distributed under the License
13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing permissions and limitations under
15  * the License.
16  * ============LICENSE_END==========================================================================
17  ******************************************************************************/
18 package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl;
19
20 import org.onap.ccsdk.features.sdnr.wt.common.configuration.Configuration;
21 import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
22
23 /**
24  * Configuration of mountpoint-state-provider, general section<br>
25  * - dmaapEnabled : Boolean disable/enable service depending on whether DMaaP is running or not
26  * Generates default Configuration properties if none exist or exist partially
27  * Generates Publisher properties only for TransportType=HTTPNOAUTH. Other TransportTypes like HTTP, AUTH_KEY and DME2 have additional properties and are not 
28  * generated by default. For a list of applicable properties for the different TranportType values, please see - https://wiki.onap.org/display/DW/Feature+configuration+requirements  
29  */
30 public class GeneralConfig implements Configuration {
31
32     private static final String SECTION_MARKER = "general";
33
34     private static final String PROPERTY_KEY_ENABLED = "dmaapEnabled" ; //"disabled";
35    
36     public static final String PROPERTY_KEY_PUBLISHER_TRANSPORTTYPE = "TransportType";
37     private static final String DEFAULT_VALUE_PUBLISHER_TRANSPORTTYPE = "HTTPNOAUTH";
38     
39     public static final String PROPERTY_KEY_PUBLISHER_HOST_PORT = "host";
40     private static final String DEFAULT_VALUE_PUBLISHER_HOST_PORT = "onap-dmap:3904";
41     
42     public static final String PROPERTY_KEY_PUBLISHER_TOPIC = "topic";
43     private static final String DEFAULT_VALUE_PUBLISHER_TOPIC = "unauthenticated.SDNR_MOUNTPOINT_STATE_INFO";
44     
45     public static final String PROPERTY_KEY_PUBLISHER_CONTENTTYPE = "contenttype";
46     private static final String DEFAULT_VALUE_PUBLISHER_CONTENTTYPE = "application/json";
47     
48     public static final String PROPERTY_KEY_PUBLISHER_TIMEOUT = "timeout";
49     private static final String DEFAULT_VALUE_PUBLISHER_TIMEOUT = "20000";
50
51     public static final String PROPERTY_KEY_PUBLISHER_LIMIT = "limit";
52     private static final String DEFAULT_VALUE_PUBLISHER_LIMIT = "10000";
53     
54     public static final String PROPERTY_KEY_PUBLISHER_MAXBATCHSIZE = "maxBatchSize";
55     public static final String DEFAULT_VALUE_PUBLISHER_MAXBATCHSIZE = "100";
56     
57     public static final String PROPERTY_KEY_PUBLISHER_MAXAGEMS = "maxAgeMs";
58     public static final String DEFAULT_VALUE_PUBLISHER_MAXAGEMS = "250";
59     
60     public static final String PROPERTY_KEY_PUBLISHER_MESSAGESENTTHREADOCCURANCE = "MessageSentThreadOccurance";
61     public static final String DEFAULT_VALUE_PUBLISHER_MESSAGESENTTHREADOCCURANCE = "50";
62
63         private final ConfigurationFileRepresentation configuration;
64
65         public GeneralConfig(ConfigurationFileRepresentation configuration) {
66                 this.configuration = configuration;
67         this.configuration.addSection(SECTION_MARKER);
68                 defaults();
69         }
70
71         public Boolean getEnabled() {
72                 Boolean enabled = configuration.getPropertyBoolean(SECTION_MARKER, PROPERTY_KEY_ENABLED);
73                 return enabled;
74         }
75         
76         public String getHostPort() {
77                 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_PUBLISHER_HOST_PORT);
78         }
79         
80         public String getTransportType() {
81                 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_PUBLISHER_TRANSPORTTYPE);
82         }
83
84         public String getTopic() {
85                 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_PUBLISHER_TOPIC);
86         }
87         
88         public String getTimeout() {
89                 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_PUBLISHER_TIMEOUT);
90         }
91         
92         public String getLimit() {
93                 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_PUBLISHER_LIMIT);
94         }
95         
96         public String getContenttype() {
97                 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_PUBLISHER_CONTENTTYPE);
98         }
99         
100         public String getMaxBatchSize() {
101                 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_PUBLISHER_MAXBATCHSIZE);
102         }
103         
104         public String getMaxAgeMs() {
105                 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_PUBLISHER_MAXAGEMS);
106         }
107         
108         public String getMessageSentThreadOccurrence() {
109                 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_PUBLISHER_MESSAGESENTTHREADOCCURANCE);
110         }
111         
112         @Override
113         public String getSectionName() {
114                 return SECTION_MARKER;
115         }
116
117         @Override
118         public void defaults() {
119                 // The default value should be "false" given that SDNR can be run in environments where DMaaP is not used
120                 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_ENABLED, Boolean.FALSE);
121                 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_PUBLISHER_TRANSPORTTYPE, DEFAULT_VALUE_PUBLISHER_TRANSPORTTYPE);
122                 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_PUBLISHER_HOST_PORT, DEFAULT_VALUE_PUBLISHER_HOST_PORT);
123                 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_PUBLISHER_TOPIC, DEFAULT_VALUE_PUBLISHER_TOPIC);
124                 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_PUBLISHER_CONTENTTYPE, DEFAULT_VALUE_PUBLISHER_CONTENTTYPE);
125                 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_PUBLISHER_TIMEOUT, DEFAULT_VALUE_PUBLISHER_TIMEOUT);
126                 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_PUBLISHER_LIMIT, DEFAULT_VALUE_PUBLISHER_LIMIT);
127                 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_PUBLISHER_MAXBATCHSIZE, DEFAULT_VALUE_PUBLISHER_MAXBATCHSIZE);
128                 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_PUBLISHER_MAXAGEMS, DEFAULT_VALUE_PUBLISHER_MAXAGEMS);
129                 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_PUBLISHER_MESSAGESENTTHREADOCCURANCE, DEFAULT_VALUE_PUBLISHER_MESSAGESENTTHREADOCCURANCE);
130         }
131
132 }