2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
24 package org.onap.appc.encryptiontool.wrapper;
26 import java.util.ArrayList;
27 import java.util.HashMap;
30 import javax.sql.rowset.CachedRowSet;
32 import org.apache.commons.configuration.PropertiesConfiguration;
33 import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
36 public class LoadFromDB {
38 private static final Logger log = LoggerFactory
39 .getLogger(WrapperEncryptionTool.class);
40 public static void main(String[] args) {
42 ArrayList argList=null;
44 String getselectData = " DA.VNF_TYPE, PR.PROTOCOL, PR.ACTION ,DA.USER_NAME,DA.PASSWORD,DA.PORT_NUMBER ";
46 String clause = " DA.VNF_TYPE=PR.VNF_TYPE group by PR.ACTION ";
47 String tableName ="DEVICE_AUTHENTICATION DA , PROTOCOL_REFERENCE PR";
48 DBResourceManager dbResourceManager = null;
51 dbResourceManager = DbServiceUtil.initDbLibService();
52 CachedRowSet data = DbServiceUtil.getData(tableName, argList, Constants.SCHEMA_SDNCTL, getselectData,clause );
54 Map <String,String> mp = new HashMap<String,String>();
57 mp.put(data.getString(1)+"."+data.getString(2)+"."+data.getString(3)+"."+"user",data.getString(4));
58 mp.put(data.getString(1)+"."+data.getString(2)+"."+data.getString(3)+"."+"password",data.getString(5));
59 mp.put(data.getString(1)+"."+data.getString(2)+"."+data.getString(3)+"."+"port",data.getString(6));
60 mp.put(data.getString(1)+"."+data.getString(2)+"."+data.getString(3)+"."+"url","");
65 log.info("Size of Map data:"+mp.size());
66 File file = new File(System.getenv("APPC_CONFIG_DIR"));
68 file = new File(System.getenv("APPC_CONFIG_DIR")+"/appc_southbound.properties");
71 log.info("APPC-MESSAGE:" + " File already Exists");
76 log.info("APPC-MESSAGE:" + " New File is created");
79 log.info("APPC-MESSAGE: ERROR - No record Found ");
83 log.info("Size of Map file:"+mp.size());
84 PropertiesConfiguration conf = new PropertiesConfiguration(
85 System.getenv("APPC_CONFIG_DIR")+"/appc_southbound.properties");
88 for (Map.Entry<String, String> key : mp.entrySet()) {
89 log.debug(key.getKey() + ":" + key.getValue());
90 if(key.getValue()==null)
94 conf.setProperty(key.getKey(), key.getValue());
99 log.info("APPC-MESSAGE:" + "properties updated successfully");
102 } catch (Exception e) {
103 log.info("Caught exception", e);
104 log.info("APPC-MESSAGE:" + e.getMessage());
106 if (dbResourceManager != null) {
107 dbResourceManager.cleanUp();