summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openecomp/sparky/dal/sas/config/SearchServiceConfig.java
blob: 1ff2001d2c47a1776ec52e2f669e326605776e96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/**
 * ============LICENSE_START===================================================
 * SPARKY (AAI UI service)
 * ============================================================================
 * Copyright © 2017 AT&T Intellectual Property.
 * Copyright © 2017 Amdocs
 * All rights reserved.
 * ============================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=====================================================
 *
 * ECOMP and OpenECOMP are trademarks
 * and service marks of AT&T Intellectual Property.
 */

package org.openecomp.sparky.dal.sas.config;

import java.util.Properties;

import org.openecomp.sparky.util.ConfigHelper;
import org.openecomp.sparky.viewandinspect.config.TierSupportUiConstants;

/**
 * The Class ElasticSearchConfig.
 */
public class SearchServiceConfig {

  public static final String CONFIG_FILE =
      TierSupportUiConstants.DYNAMIC_CONFIG_APP_LOCATION + "search-service.properties";

  private static SearchServiceConfig instance;

  private String ipAddress;

  private String httpPort;

  private String indexName;

  private String auditIndexName;

  private String topographicalSearchIndex;

  private String entityCountHistoryIndex;

  private String version;

  private String type;
  
  private String certName;
  
  private String keystorePassword;
  
  private String keystore;

  private static final String IP_ADDRESS_DEFAULT = "localhost";

  private static final String HTTP_PORT_DEFAULT = "9509";

  private static final String INDEX_NAME_DEFAULT = "entitySearchIndex-localhost";

  private static final String AUDIT_INDEX_NAME_DEFAULT = "di-violations";

  private static final String TOPOGRAPHICAL_INDEX_NAME_DEFAULT =
      "topographicalsearchindex-localhost";

  private static final String ENTITY_COUNT_HISTORY_INDEX_NAME_DEFAULT =
      "entitycounthistoryindex-localhost";

  private static final String VERSION_DEFAULT = "v1";

  public static SearchServiceConfig getConfig() throws Exception {

    if (instance == null) {
      instance = new SearchServiceConfig();
      instance.initializeProperties();
    }

    return instance;
  }

  public static void setConfig(SearchServiceConfig config) {
    SearchServiceConfig.instance = config;
  }

  /**
   * Instantiates a new search service config.
   */
  public SearchServiceConfig() {
    // test method
  }

  /**
   * Initialize properties.
   */
  private void initializeProperties() {
    Properties props = ConfigHelper.loadConfigFromExplicitPath(CONFIG_FILE);
    
    Properties sasProps = ConfigHelper.getConfigWithPrefix("search-service", props);
    
    ipAddress = sasProps.getProperty("ipAddress", IP_ADDRESS_DEFAULT);
    httpPort = sasProps.getProperty("httpPort", "" + HTTP_PORT_DEFAULT);
    version = sasProps.getProperty("version", "" + VERSION_DEFAULT);
    indexName = sasProps.getProperty("indexName", INDEX_NAME_DEFAULT);
    auditIndexName = sasProps.getProperty("auditIndexName", AUDIT_INDEX_NAME_DEFAULT);
    topographicalSearchIndex = sasProps.getProperty("topographicalIndexName",
        TOPOGRAPHICAL_INDEX_NAME_DEFAULT);
    entityCountHistoryIndex = sasProps.getProperty("entityCountHistoryIndexName",
        ENTITY_COUNT_HISTORY_INDEX_NAME_DEFAULT);
    certName =
        sasProps.getProperty("ssl.cert-name", "aai-client-cert.p12");
    keystorePassword = sasProps.getProperty("ssl.keystore-password",
        "OBF:1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o");
    keystore = sasProps.getProperty("ssl.keystore", "tomcat_keystore");
  }

  public String getIpAddress() {
    return ipAddress;
  }

  public void setIpAddress(String ipAddress) {
    this.ipAddress = ipAddress;
  }

  public String getHttpPort() {
    return httpPort;
  }

  public void setHttpPort(String httpPort) {
    this.httpPort = httpPort;
  }

  public String getIndexName() {
    return indexName;
  }

  public void setIndexName(String indexName) {
    this.indexName = indexName;
  }

  public String getVersion() {
    return version;
  }

  public void setVersion(String version) {
    this.version = version;
  }

  public String getAuditIndexName() {
    return auditIndexName;
  }

  public void setAuditIndexName(String auditIndexName) {
    this.auditIndexName = auditIndexName;
  }

  public String getTopographicalSearchIndex() {
    return topographicalSearchIndex;
  }

  public void setTopographicalSearchIndex(String topographicalSearchIndex) {
    this.topographicalSearchIndex = topographicalSearchIndex;
  }

  public String getEntityCountHistoryIndex() {
    return entityCountHistoryIndex;
  }

  public void setEntityCountHistoryIndex(String entityCountHistoryIndex) {
    this.entityCountHistoryIndex = entityCountHistoryIndex;
  }

  public String getType() {
    return type;
  }

  public void setType(String type) {
    this.type = type;
  }
  
  
  public String getCertName() {
    return certName;
  }

  public void setCertName(String certName) {
    this.certName = certName;
  }

  public String getKeystorePassword() {
    return keystorePassword;
  }

  public void setKeystorePassword(String keystorePassword) {
    this.keystorePassword = keystorePassword;
  }

  public String getKeystore() {
    return keystore;
  }

  public void setKeystore(String keystore) {
    this.keystore = keystore;
  }

  @Override
  public String toString() {
    return "SearchServiceConfig [ipAddress=" + ipAddress + ", httpPort=" + httpPort + ", indexName="
        + indexName + ", auditIndexName=" + auditIndexName + ", topographicalSearchIndex="
        + topographicalSearchIndex + ", entityCountHistoryIndex=" + entityCountHistoryIndex
        + ", version=" + version + ", type=" + type + "]";
  }


}