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