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