Fix request handler class error
[appc.git] / appc-common / src / main / java / org / onap / appc / configuration / Configuration.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * =============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * 
21  * ============LICENSE_END=========================================================
22  */
23
24 package org.onap.appc.configuration;
25
26 import java.util.Properties;
27
28 import org.slf4j.Logger;
29
30
31
32 /**
33  * This interface defines the common configuration support that is available to the application.
34  * <p>
35  * Where properties are common to all CDP components (server, coordinator, and EPM), the property symbolic values are
36  * defined as part of this interface. Where they are unique to each component, they must be defined within that
37  * component.
38  * </p>
39  */
40 public interface Configuration {
41
42     String PROPERTY_BOOTSTRAP_FILE_NAME = "org_onap_appc_bootstrap_file"; //
43     String DEFAULT_BOOTSTRAP_FILE_NAME = "appc.properties"; 
44     String PROPERTY_BOOTSTRAP_FILE_PATH = "org_onap_appc_bootstrap_path"; //
45     String DEFAULT_BOOTSTRAP_FILE_PATH = "/opt/onap/appc/data/properties,${user.home},etc,../etc";
46     String PROPERTY_RESOURCE_BUNDLES = "org.onap.appc.resources"; 
47     String DEFAULT_RESOURCE_BUNDLES = "org/onap/appc/i18n/MessageResources";
48
49    /**
50      * This method is called to obtain a property expressed as a boolean value (true or false). The standard rules for
51      * {@link Boolean#valueOf(String)} are used.
52      * 
53      * @param key
54      *            The property key
55      * @return The value of the property expressed as a boolean, or false if it does not exist.
56      */
57     boolean getBooleanProperty(String key);
58
59     /**
60      * This method is called to obtain a property expressed as a boolean value (true or false). The standard rules for
61      * {@link Boolean#valueOf(String)} are used.
62      * 
63      * @param key
64      *            The property key
65      * @param defaultValue
66      *            The default value to be returned if the property does not exist
67      * @return The value of the property expressed as a boolean, or false if it does not exist.
68      */
69     boolean getBooleanProperty(String key, boolean defaultValue);
70
71     /**
72      * Returns the indicated property value expressed as a floating point double-precision value (double). The standard
73      * rules for {@link Double#valueOf(String)} are used.
74      * 
75      * @param key
76      *            The property to retrieve
77      * @return The value of the property, or 0.0 if not found or invalid
78      */
79     double getDoubleProperty(String key);
80
81     /**
82      * Returns the indicated property value expressed as a floating point double-precision value (double). The standard
83      * rules for {@link Double#valueOf(String)} are used.
84      * 
85      * @param key
86      *            The property to retrieve
87      * @param defaultValue
88      *            The default value to be returned if the property does not exist
89      * @return The value of the property, or 0.0 if not found or invalid
90      */
91     double getDoubleProperty(String key, double defaultValue);
92
93     /**
94      * Returns the property indicated expressed as an integer. The standard rules for
95      * {@link Integer#parseInt(String, int)} using a radix of 10 are used.
96      * 
97      * @param key
98      *            The property name to retrieve.
99      * @return The value of the property, or 0 if it does not exist or is invalid.
100      */
101     int getIntegerProperty(String key);
102
103     /**
104      * Returns the property indicated expressed as an integer. The standard rules for
105      * {@link Integer#parseInt(String, int)} using a radix of 10 are used.
106      * 
107      * @param key
108      *            The property name to retrieve.
109      * @param defaultValue
110      *            The default value to be returned if the property does not exist
111      * @return The value of the property, or 0 if it does not exist or is invalid.
112      */
113     int getIntegerProperty(String key, int defaultValue);
114
115     /**
116      * Returns the specified property as a long integer value, if it exists, or zero if it does not.
117      * 
118      * @param key
119      *            The key of the property desired.
120      * @return The value of the property expressed as an integer long value, or zero if the property does not exist or
121      *         is not a valid integer long.
122      */
123     long getLongProperty(String key);
124
125     /**
126      * Returns the specified property as a long integer value, if it exists, or the default value if it does not exist
127      * or is invalid.
128      * 
129      * @param key
130      *            The key of the property desired.
131      * @param defaultValue
132      *            the value to be returned if the property is not valid or does not exist.
133      * @return The value of the property expressed as an integer long value, or the default value if the property does
134      *         not exist or is not a valid integer long.
135      */
136     long getLongProperty(String key, long defaultValue);
137
138     /**
139      * This method can be called to retrieve a properties object that is immutable. Any attempt to modify the properties
140      * object returned will result in an exception. This allows a caller to view the current configuration as a set of
141      * properties.
142      * 
143      * @return An unmodifiable properties object.
144      */
145     Properties getProperties();
146
147     /**
148      * This method is called to obtain a property as a string value
149      * 
150      * @param key
151      *            The key of the property
152      * @return The string value, or null if it does not exist.
153      */
154     String getProperty(String key);
155
156     /**
157      * This method is called to obtain a property as a string value
158      * 
159      * @param key
160      *            The key of the property
161      * @param defaultValue
162      *            The default value to be returned if the property does not exist
163      * @return The string value, or null if it does not exist.
164      */
165     String getProperty(String key, String defaultValue);
166
167     /**
168      * Returns true if the named property is defined, false otherwise.
169      * 
170      * @param key
171      *            The key of the property we are interested in
172      * @return True if the property exists.
173      */
174     boolean isPropertyDefined(String key);
175
176     /**
177      * Returns an indication of the validity of the boolean property. A boolean property is considered to be valid only
178      * if it has the value "true" or "false" (ignoring case).
179      * 
180      * @param key
181      *            The property to be checked
182      * @return True if the value is a boolean constant, or false if it does not exist or is not a correct string
183      */
184     boolean isValidBoolean(String key);
185
186     /**
187      * Returns an indication if the indicated property represents a valid double-precision floating point number.
188      * 
189      * @param key
190      *            The property to be examined
191      * @return True if the property is a valid representation of a double, or false if it does not exist or contains
192      *         illegal characters.
193      */
194     boolean isValidDouble(String key);
195
196     /**
197      * Returns an indication if the property is a valid integer value or not.
198      * 
199      * @param key
200      *            The key of the property to check
201      * @return True if the value is a valid integer string, or false if it does not exist or contains illegal
202      *         characters.
203      */
204     boolean isValidInteger(String key);
205
206     /**
207      * Determines is the specified property exists and is a valid representation of an integer long value.
208      * 
209      * @param key
210      *            The property to be checked
211      * @return True if the property is a valid representation of an integer long value, and false if it either does not
212      *         exist or is not valid.
213      */
214     boolean isValidLong(String key);
215
216     /**
217      * This method allows the caller to set all properties from a provided properties object into the configuration
218      * property set.
219      * <p>
220      * The primary difference between this method and the factory method
221      * {@link ConfigurationFactory#getConfiguration(Properties)} is that this method does not clear and reload the
222      * configuration. Rather, this method merges the provided properties object contents into the existing properties,
223      * replacing any same-named keys with the values from this object.
224      * </p>
225      * 
226      * @param properties
227      *            The properties object to copy all properties from
228      */
229     void setProperties(Properties properties);
230
231     /**
232      * This method allows a caller to insert a new property definition into the configuration object. This allows the
233      * application to adjust or add to the current configuration. If the property already exists, it is replaced with
234      * the new value.
235      * 
236      * @param key
237      *            The key of the property to be defined
238      * @param value
239      *            The value of the property to be defined
240      */
241     void setProperty(String key, String value);
242 }