2 * ============LICENSE_START=======================================================
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.aai.sparky.dal.sas.config;
23 import java.util.Properties;
25 import org.onap.aai.sparky.util.ConfigHelper;
26 import org.onap.aai.sparky.viewandinspect.config.SparkyConstants;
29 * The Class ElasticSearchConfig.
31 public class SearchServiceConfig {
33 public static final String CONFIG_FILE =
34 SparkyConstants.DYNAMIC_CONFIG_APP_LOCATION + "search-service.properties";
36 private static SearchServiceConfig instance;
38 private String ipAddress;
40 private String httpPort;
42 private String indexName;
44 private String auditIndexName;
46 private String topographicalSearchIndex;
48 private String entityCountHistoryIndex;
50 private String version;
54 private String certName;
56 private String keystorePassword;
58 private String keystore;
60 private static final String IP_ADDRESS_DEFAULT = "localhost";
62 private static final String HTTP_PORT_DEFAULT = "9509";
64 private static final String INDEX_NAME_DEFAULT = "entitySearchIndex-localhost";
66 private static final String AUDIT_INDEX_NAME_DEFAULT = "di-violations";
68 private static final String TOPOGRAPHICAL_INDEX_NAME_DEFAULT =
69 "topographicalsearchindex-localhost";
71 private static final String ENTITY_COUNT_HISTORY_INDEX_NAME_DEFAULT =
72 "entitycounthistoryindex-localhost";
74 private static final String VERSION_DEFAULT = "v1";
76 public static SearchServiceConfig getConfig() throws Exception {
78 if (instance == null) {
79 instance = new SearchServiceConfig();
80 instance.initializeProperties();
86 public static void setConfig(SearchServiceConfig config) {
87 SearchServiceConfig.instance = config;
91 * Instantiates a new search service config.
93 public SearchServiceConfig() {
98 * Initialize properties.
100 private void initializeProperties() {
101 Properties props = ConfigHelper.loadConfigFromExplicitPath(CONFIG_FILE);
103 Properties sasProps = ConfigHelper.getConfigWithPrefix("search-service", props);
105 ipAddress = sasProps.getProperty("ipAddress", IP_ADDRESS_DEFAULT);
106 httpPort = sasProps.getProperty("httpPort", "" + HTTP_PORT_DEFAULT);
107 version = sasProps.getProperty("version", "" + VERSION_DEFAULT);
108 indexName = sasProps.getProperty("indexName", INDEX_NAME_DEFAULT);
109 auditIndexName = sasProps.getProperty("auditIndexName", AUDIT_INDEX_NAME_DEFAULT);
110 topographicalSearchIndex = sasProps.getProperty("topographicalIndexName",
111 TOPOGRAPHICAL_INDEX_NAME_DEFAULT);
112 entityCountHistoryIndex = sasProps.getProperty("entityCountHistoryIndexName",
113 ENTITY_COUNT_HISTORY_INDEX_NAME_DEFAULT);
115 sasProps.getProperty("ssl.cert-name", "aai-client-cert.p12");
116 keystorePassword = sasProps.getProperty("ssl.keystore-password",
117 "OBF:1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o");
118 keystore = sasProps.getProperty("ssl.keystore", "tomcat_keystore");
121 public String getIpAddress() {
125 public void setIpAddress(String ipAddress) {
126 this.ipAddress = ipAddress;
129 public String getHttpPort() {
133 public void setHttpPort(String httpPort) {
134 this.httpPort = httpPort;
137 public String getIndexName() {
141 public void setIndexName(String indexName) {
142 this.indexName = indexName;
145 public String getVersion() {
149 public void setVersion(String version) {
150 this.version = version;
153 public String getAuditIndexName() {
154 return auditIndexName;
157 public void setAuditIndexName(String auditIndexName) {
158 this.auditIndexName = auditIndexName;
161 public String getTopographicalSearchIndex() {
162 return topographicalSearchIndex;
165 public void setTopographicalSearchIndex(String topographicalSearchIndex) {
166 this.topographicalSearchIndex = topographicalSearchIndex;
169 public String getEntityCountHistoryIndex() {
170 return entityCountHistoryIndex;
173 public void setEntityCountHistoryIndex(String entityCountHistoryIndex) {
174 this.entityCountHistoryIndex = entityCountHistoryIndex;
177 public String getType() {
181 public void setType(String type) {
186 public String getCertName() {
190 public void setCertName(String certName) {
191 this.certName = certName;
194 public String getKeystorePassword() {
195 return keystorePassword;
198 public void setKeystorePassword(String keystorePassword) {
199 this.keystorePassword = keystorePassword;
202 public String getKeystore() {
206 public void setKeystore(String keystore) {
207 this.keystore = keystore;
211 public String toString() {
212 return "SearchServiceConfig [ipAddress=" + ipAddress + ", httpPort=" + httpPort + ", indexName="
213 + indexName + ", auditIndexName=" + auditIndexName + ", topographicalSearchIndex="
214 + topographicalSearchIndex + ", entityCountHistoryIndex=" + entityCountHistoryIndex
215 + ", version=" + version + ", type=" + type + "]";