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