Changing the license and trademark
[aai/sparky-be.git] / src / main / java / org / openecomp / 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.openecomp.sparky.dal.sas.config;
24
25 import java.util.Properties;
26
27 import org.openecomp.sparky.util.ConfigHelper;
28 import org.openecomp.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 = sasProps.getProperty("topographicalIndexName",
113         TOPOGRAPHICAL_INDEX_NAME_DEFAULT);
114     entityCountHistoryIndex = sasProps.getProperty("entityCountHistoryIndexName",
115         ENTITY_COUNT_HISTORY_INDEX_NAME_DEFAULT);
116     certName =
117         sasProps.getProperty("ssl.cert-name", "aai-client-cert.p12");
118     keystorePassword = sasProps.getProperty("ssl.keystore-password",
119         "OBF:1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o");
120     keystore = sasProps.getProperty("ssl.keystore", "tomcat_keystore");
121   }
122
123   public String getIpAddress() {
124     return ipAddress;
125   }
126
127   public void setIpAddress(String ipAddress) {
128     this.ipAddress = ipAddress;
129   }
130
131   public String getHttpPort() {
132     return httpPort;
133   }
134
135   public void setHttpPort(String httpPort) {
136     this.httpPort = httpPort;
137   }
138
139   public String getIndexName() {
140     return indexName;
141   }
142
143   public void setIndexName(String indexName) {
144     this.indexName = indexName;
145   }
146
147   public String getVersion() {
148     return version;
149   }
150
151   public void setVersion(String version) {
152     this.version = version;
153   }
154
155   public String getAuditIndexName() {
156     return auditIndexName;
157   }
158
159   public void setAuditIndexName(String auditIndexName) {
160     this.auditIndexName = auditIndexName;
161   }
162
163   public String getTopographicalSearchIndex() {
164     return topographicalSearchIndex;
165   }
166
167   public void setTopographicalSearchIndex(String topographicalSearchIndex) {
168     this.topographicalSearchIndex = topographicalSearchIndex;
169   }
170
171   public String getEntityCountHistoryIndex() {
172     return entityCountHistoryIndex;
173   }
174
175   public void setEntityCountHistoryIndex(String entityCountHistoryIndex) {
176     this.entityCountHistoryIndex = entityCountHistoryIndex;
177   }
178
179   public String getType() {
180     return type;
181   }
182
183   public void setType(String type) {
184     this.type = type;
185   }
186   
187   
188   public String getCertName() {
189     return certName;
190   }
191
192   public void setCertName(String certName) {
193     this.certName = certName;
194   }
195
196   public String getKeystorePassword() {
197     return keystorePassword;
198   }
199
200   public void setKeystorePassword(String keystorePassword) {
201     this.keystorePassword = keystorePassword;
202   }
203
204   public String getKeystore() {
205     return keystore;
206   }
207
208   public void setKeystore(String keystore) {
209     this.keystore = keystore;
210   }
211
212   @Override
213   public String toString() {
214     return "SearchServiceConfig [ipAddress=" + ipAddress + ", httpPort=" + httpPort + ", indexName="
215         + indexName + ", auditIndexName=" + auditIndexName + ", topographicalSearchIndex="
216         + topographicalSearchIndex + ", entityCountHistoryIndex=" + entityCountHistoryIndex
217         + ", version=" + version + ", type=" + type + "]";
218   }
219
220
221 }