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.util.HashMap;
29 public class CassandraUtils {
32 private static final String CASSANDRA_STATEMENT_DEFINITION_FILE = "cassandraStatements.json";
33 private static Map<String, String> statementMap = new HashMap<>();
35 public static String[] getAddresses() {
36 return ConfigurationManager.getInstance().getAddresses();
40 public static String getKeySpace() {
41 return ConfigurationManager.getInstance().getKeySpace();
47 * @param statementName the statement name
48 * @return the statement
50 public static String getStatement(String statementName) {
52 if (statementMap.size() == 0) {
53 statementMap = FileUtils.readViaInputStream(CASSANDRA_STATEMENT_DEFINITION_FILE,
54 stream -> JsonUtil.json2Object(stream, Map.class));
57 return statementMap.get(statementName);
60 public static String getUser() {
62 return ConfigurationManager.getInstance().getUsername();
65 public static String getPassword() {
66 return ConfigurationManager.getInstance().getPassword();
70 public static String getTruststore() {
71 return ConfigurationManager.getInstance().getTruststorePath();
75 public static String getTruststorePassword() {
76 return ConfigurationManager.getInstance().getTruststorePassword();
80 public static int getCassandraPort() {
81 return ConfigurationManager.getInstance().getSslPort();
85 public static boolean isSsl() {
86 return ConfigurationManager.getInstance().isSsl();
90 public static boolean isAuthenticate() {
91 return ConfigurationManager.getInstance().isAuthenticate();