Moving Historical Queries to spring boot
[aai/data-router.git] / src / main / java / org / onap / aai / datarouter / query / RestClientConfig.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017-2018 Amdocs
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *       http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21 package org.onap.aai.datarouter.query;
22
23 public class RestClientConfig {
24
25   private String certPath;
26   private String certPassword;
27   private String trustStorePath;
28   private String connectionTimeout;
29   private String readTimeout;
30
31   public String getCertPath() {
32     return certPath;
33   }
34
35   public void setCertPath(String certPath) {
36     this.certPath = certPath;
37   }
38
39   public String getCertPassword() {
40     return certPassword;
41   }
42
43   public void setCertPassword(String certPassword) {
44     this.certPassword = certPassword;
45   }
46
47   public String getTrustStorePath() {
48     return trustStorePath;
49   }
50
51   public void setTrustStorePath(String trustStorePath) {
52     this.trustStorePath = trustStorePath;
53   }
54
55   public int getConnectionTimeout() {
56     return parseInt(connectionTimeout,10000);
57   }
58
59   public void setConnectionTimeout(String connectionTimeout) {
60     this.connectionTimeout = connectionTimeout;
61   }
62
63   public int getReadTimeout() {
64     return parseInt(connectionTimeout,10000);
65   }
66
67   public void setReadTimeout(String readTimeout) {
68     this.readTimeout = readTimeout;
69   }
70
71   
72   private int parseInt(String config, int defaultValue) {
73     int intVal = defaultValue; // Default delay of half a sec
74     try {
75       intVal = Integer.parseInt(config);
76     } catch (Exception e) {
77       // Ignore the parsing error and use the default
78     }
79     return intVal;
80   }
81   @Override
82   public String toString() {
83     return "RestClientConfig [certPath=" + certPath + ", certPassword=" + certPassword + ", trustStorePath="
84         + trustStorePath + ", connectionTimeout=" + connectionTimeout + ", readTimeout=" + readTimeout + "]";
85   }
86
87 }