2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.sli.northbound.daeximoffsitebackup;
25 import java.io.FileInputStream;
26 import java.io.IOException;
27 import java.io.InputStream;
28 import java.util.Properties;
30 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.daeximoffsitebackup.rev180926.BackupDataOutputBuilder;
32 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.daeximoffsitebackup.rev180926.RetrieveDataInputBuilder;
33 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.daeximoffsitebackup.rev180926.RetrieveDataOutputBuilder;
35 import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper;
37 import org.slf4j.Logger;
38 import org.slf4j.LoggerFactory;
40 public class DaeximOffsiteBackupUtil extends MdsalHelper {
41 private static final Logger LOG = LoggerFactory.getLogger(DaeximOffsiteBackupUtil.class);
42 private static String PROPERTIES_FILE;
44 public static void loadProperties() {
45 File file = new File(PROPERTIES_FILE);
46 Properties properties = new Properties();
47 InputStream input = null;
48 if(file.isFile() && file.canRead()) {
50 input = new FileInputStream(file);
51 properties.load(input);
52 LOG.info("Loaded properties from " + PROPERTIES_FILE);
53 setProperties(properties);
54 } catch (Exception e) {
55 LOG.error("Failed to load properties " + PROPERTIES_FILE + "\n", e);
60 } catch (IOException e) {
61 LOG.error("Failed to close properties file " + PROPERTIES_FILE + "\n", e);
69 // Trick class loader into loading builders. Some of
70 // these will be needed later by Reflection classes, but need
71 // to explicitly "new" them here to get class loader to load them.
73 BackupDataOutputBuilder b1 = new BackupDataOutputBuilder();
75 RetrieveDataOutputBuilder b2 = new RetrieveDataOutputBuilder();
76 RetrieveDataInputBuilder b3 = new RetrieveDataInputBuilder();