2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.core.nosqldb.util;
23 import org.openecomp.core.utilities.file.FileUtils;
24 import org.openecomp.core.utilities.json.JsonUtil;
26 import java.io.InputStream;
27 import java.util.HashMap;
30 public class CassandraUtils {
33 private static final String CASSANDRA_STATEMENT_DEFINITION_FILE = "cassandraStatements.json";
34 private static Map<String, String> statementMap = new HashMap<>();
36 public static String[] getAddresses() {
37 return ConfigurationManager.getInstance().getAddresses();
41 public static String getKeySpace() {
42 return ConfigurationManager.getInstance().getKeySpace();
48 * @param statementName the statement name
49 * @return the statement
51 public static String getStatement(String statementName) {
52 if (statementMap.size() == 0) {
53 InputStream statementJson = FileUtils.getFileInputStream(CASSANDRA_STATEMENT_DEFINITION_FILE);
54 statementMap = JsonUtil.json2Object(statementJson, Map.class);
56 return statementMap.get(statementName);
59 public static String getUser() {
61 return ConfigurationManager.getInstance().getUsername();
64 public static String getPassword() {
65 return ConfigurationManager.getInstance().getPassword();
69 public static String getTruststore() {
70 return ConfigurationManager.getInstance().getTruststorePath();
74 public static String getTruststorePassword() {
75 return ConfigurationManager.getInstance().getTruststorePassword();
79 public static int getCassandraPort() {
80 return ConfigurationManager.getInstance().getSslPort();
84 public static boolean isSsl() {
85 return ConfigurationManager.getInstance().isSsl();
89 public static boolean isAuthenticate() {
90 return ConfigurationManager.getInstance().isAuthenticate();