Adding UI extensibility
[aai/sparky-be.git] / src / main / java / org / onap / aai / sparky / dal / sas / config / SearchServiceConfig.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017 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  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  */
23 package org.onap.aai.sparky.dal.sas.config;
24
25 import java.util.Properties;
26
27 import org.onap.aai.sparky.util.ConfigHelper;
28 import org.onap.aai.sparky.viewandinspect.config.TierSupportUiConstants;
29
30 /**
31  * The Class ElasticSearchConfig.
32  */
33 public class SearchServiceConfig {
34
35   public static final String CONFIG_FILE =
36       TierSupportUiConstants.DYNAMIC_CONFIG_APP_LOCATION + "search-service.properties";
37
38   private static SearchServiceConfig instance;
39
40   private String ipAddress;
41
42   private String httpPort;
43
44   private String indexName;
45
46   private String auditIndexName;
47
48   private String topographicalSearchIndex;
49
50   private String entityCountHistoryIndex;
51
52   private String version;
53
54   private String type;
55
56   private String certName;
57
58   private String keystorePassword;
59
60   private String keystore;
61
62   private static final String IP_ADDRESS_DEFAULT = "localhost";
63
64   private static final String HTTP_PORT_DEFAULT = "9509";
65
66   private static final String INDEX_NAME_DEFAULT = "entitySearchIndex-localhost";
67
68   private static final String AUDIT_INDEX_NAME_DEFAULT = "di-violations";
69
70   private static final String TOPOGRAPHICAL_INDEX_NAME_DEFAULT =
71       "topographicalsearchindex-localhost";
72
73   private static final String ENTITY_COUNT_HISTORY_INDEX_NAME_DEFAULT =
74       "entitycounthistoryindex-localhost";
75
76   private static final String VERSION_DEFAULT = "v1";
77
78   public static SearchServiceConfig getConfig() throws Exception {
79
80     if (instance == null) {
81       instance = new SearchServiceConfig();
82       instance.initializeProperties();
83     }
84
85     return instance;
86   }
87
88   public static void setConfig(SearchServiceConfig config) {
89     SearchServiceConfig.instance = config;
90   }
91
92   /**
93    * Instantiates a new search service config.
94    */
95   public SearchServiceConfig() {
96     // test method
97   }
98
99   /**
100    * Initialize properties.
101    */
102   private void initializeProperties() {
103     Properties props = ConfigHelper.loadConfigFromExplicitPath(CONFIG_FILE);
104
105     Properties sasProps = ConfigHelper.getConfigWithPrefix("search-service", props);
106
107     ipAddress = sasProps.getProperty("ipAddress", IP_ADDRESS_DEFAULT);
108     httpPort = sasProps.getProperty("httpPort", "" + HTTP_PORT_DEFAULT);
109     version = sasProps.getProperty("version", "" + VERSION_DEFAULT);
110     indexName = sasProps.getProperty("indexName", INDEX_NAME_DEFAULT);
111     auditIndexName = sasProps.getProperty("auditIndexName", AUDIT_INDEX_NAME_DEFAULT);
112     topographicalSearchIndex =
113         sasProps.getProperty("topographicalIndexName", TOPOGRAPHICAL_INDEX_NAME_DEFAULT);
114     entityCountHistoryIndex = sasProps.getProperty("entityCountHistoryIndexName",
115         ENTITY_COUNT_HISTORY_INDEX_NAME_DEFAULT);
116     certName = sasProps.getProperty("ssl.cert-name", "aai-client-cert.p12");
117     keystorePassword = sasProps.getProperty("ssl.keystore-password",
118         "OBF:1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o");
119     keystore = sasProps.getProperty("ssl.keystore", "tomcat_keystore");
120   }
121
122   public String getIpAddress() {
123     return ipAddress;
124   }
125
126   public void setIpAddress(String ipAddress) {
127     this.ipAddress = ipAddress;
128   }
129
130   public String getHttpPort() {
131     return httpPort;
132   }
133
134   public void setHttpPort(String httpPort) {
135     this.httpPort = httpPort;
136   }
137
138   public String getIndexName() {
139     return indexName;
140   }
141
142   public void setIndexName(String indexName) {
143     this.indexName = indexName;
144   }
145
146   public String getVersion() {
147     return version;
148   }
149
150   public void setVersion(String version) {
151     this.version = version;
152   }
153
154   public String getAuditIndexName() {
155     return auditIndexName;
156   }
157
158   public void setAuditIndexName(String auditIndexName) {
159     this.auditIndexName = auditIndexName;
160   }
161
162   public String getTopographicalSearchIndex() {
163     return topographicalSearchIndex;
164   }
165
166   public void setTopographicalSearchIndex(String topographicalSearchIndex) {
167     this.topographicalSearchIndex = topographicalSearchIndex;
168   }
169
170   public String getEntityCountHistoryIndex() {
171     return entityCountHistoryIndex;
172   }
173
174   public void setEntityCountHistoryIndex(String entityCountHistoryIndex) {
175     this.entityCountHistoryIndex = entityCountHistoryIndex;
176   }
177
178   public String getType() {
179     return type;
180   }
181
182   public void setType(String type) {
183     this.type = type;
184   }
185
186
187   public String getCertName() {
188     return certName;
189   }
190
191   public void setCertName(String certName) {
192     this.certName = certName;
193   }
194
195   public String getKeystorePassword() {
196     return keystorePassword;
197   }
198
199   public void setKeystorePassword(String keystorePassword) {
200     this.keystorePassword = keystorePassword;
201   }
202
203   public String getKeystore() {
204     return keystore;
205   }
206
207   public void setKeystore(String keystore) {
208     this.keystore = keystore;
209   }
210
211   @Override
212   public String toString() {
213     return "SearchServiceConfig [ipAddress=" + ipAddress + ", httpPort=" + httpPort + ", indexName="
214         + indexName + ", auditIndexName=" + auditIndexName + ", topographicalSearchIndex="
215         + topographicalSearchIndex + ", entityCountHistoryIndex=" + entityCountHistoryIndex
216         + ", version=" + version + ", type=" + type + "]";
217   }
218
219
220 }