2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * ================================================================================
9 * Modifications Copyright (C) 2019 Ericsson
10 * =============================================================================
11 * Licensed under the Apache License, Version 2.0 (the "License");
12 * you may not use this file except in compliance with the License.
13 * You may obtain a copy of the License at
15 * http://www.apache.org/licenses/LICENSE-2.0
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
23 * ============LICENSE_END=========================================================
25 package org.onap.appc.encryptiontool.wrapper;
27 import java.util.ArrayList;
28 import java.util.HashMap;
31 import javax.sql.rowset.CachedRowSet;
33 import org.apache.commons.configuration.PropertiesConfiguration;
34 import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
37 public class LoadFromDB {
39 private static final Logger log = LoggerFactory
40 .getLogger(WrapperEncryptionTool.class);
41 public static void main(String[] args) {
43 ArrayList argList=null;
45 String getselectData = " DA.VNF_TYPE, PR.PROTOCOL, PR.ACTION ,DA.USER_NAME,DA.PASSWORD,DA.PORT_NUMBER ";
47 String clause = " DA.VNF_TYPE=PR.VNF_TYPE group by PR.ACTION ";
48 String tableName ="DEVICE_AUTHENTICATION DA , PROTOCOL_REFERENCE PR";
49 DBResourceManager dbResourceManager = null;
52 dbResourceManager = DbServiceUtil.initDbLibService();
53 CachedRowSet data = DbServiceUtil.getData(tableName, argList, Constants.SCHEMA_SDNCTL, getselectData, clause );
55 Map <String, String> mp = new HashMap<>();
58 mp.put(data.getString(1) + "." + data.getString(2) + "."+data.getString(3) + "."+"user", data.getString(4));
59 mp.put(data.getString(1) + "." + data.getString(2) + "."+data.getString(3) + "."+"password", data.getString(5));
60 mp.put(data.getString(1) + "." + data.getString(2) + "."+data.getString(3) + "."+"port", data.getString(6));
61 mp.put(data.getString(1) + "." + data.getString(2) + "."+data.getString(3) + "."+"url", "");
66 log.info("Size of Map data:"+mp.size());
67 File file = new File(Constants.APPC_CONFIG_DIR );
69 file = new File(Constants.APPC_CONFIG_DIR + "/appc_southbound.properties");
72 log.info("APPC-MESSAGE:" + " File already Exists");
77 log.info("APPC-MESSAGE:" + " New File is created");
80 log.info("APPC-MESSAGE: ERROR - No record Found ");
84 log.info("Size of Map file:"+mp.size());
85 PropertiesConfiguration conf = new PropertiesConfiguration(
86 Constants.APPC_CONFIG_DIR + "/appc_southbound.properties");
89 for (Map.Entry<String, String> key : mp.entrySet()) {
90 log.debug(key.getKey() + ":" + key.getValue());
91 if(key.getValue()==null)
95 conf.setProperty(key.getKey(), key.getValue());
100 log.info("APPC-MESSAGE:" + "properties updated successfully");
103 } catch (Exception e) {
104 log.info("Caught exception", e);
105 log.info("APPC-MESSAGE:" + e.getMessage());
107 if (dbResourceManager != null) {
108 dbResourceManager.cleanUp();