7a70900873cc81d8ea01bf0176cf6d90b21ceb36
[sdc.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.core.nosqldb.util;
22
23 import org.openecomp.core.utilities.file.FileUtils;
24 import org.openecomp.core.utilities.json.JsonUtil;
25
26 import java.util.HashMap;
27 import java.util.Map;
28
29 public class CassandraUtils {
30
31
32   private static final String CASSANDRA_STATEMENT_DEFINITION_FILE = "cassandraStatements.json";
33   private static Map<String, String> statementMap = new HashMap<>();
34
35   public static String[] getAddresses() {
36     return ConfigurationManager.getInstance().getAddresses();
37
38   }
39
40   public static String getKeySpace() {
41     return ConfigurationManager.getInstance().getKeySpace();
42   }
43
44   /**
45    * Gets statement.
46    *
47    * @param statementName the statement name
48    * @return the statement
49    */
50   public static String getStatement(String statementName) {
51
52     if (statementMap.size() == 0) {
53         statementMap = FileUtils.readViaInputStream(CASSANDRA_STATEMENT_DEFINITION_FILE,
54                 stream -> JsonUtil.json2Object(stream, Map.class));
55     }
56
57     return statementMap.get(statementName);
58   }
59
60   public static String getUser() {
61
62     return ConfigurationManager.getInstance().getUsername();
63   }
64
65   public static String getPassword() {
66     return ConfigurationManager.getInstance().getPassword();
67
68   }
69
70   public static String getTruststore() {
71     return ConfigurationManager.getInstance().getTruststorePath();
72
73   }
74
75   public static String getTruststorePassword() {
76     return ConfigurationManager.getInstance().getTruststorePassword();
77
78   }
79
80   public static int getCassandraPort() {
81     return ConfigurationManager.getInstance().getSslPort();
82
83   }
84
85   public static boolean isSsl() {
86     return ConfigurationManager.getInstance().isSsl();
87
88   }
89
90   public static boolean isAuthenticate() {
91     return ConfigurationManager.getInstance().isAuthenticate();
92   }
93 }