7adb2fa1b2ef7ae009f6fcbe95c90bde3bf3806d
[ccsdk/sli.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : SDN-C
4  * ================================================================================
5  * Copyright (C) 2018 AT&T Intellectual Property. All rights
6  *                      reserved.
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
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
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=========================================================
20  */
21
22 package org.onap.ccsdk.sli.northbound.daeximoffsitebackup;
23
24 import java.io.File;
25 import java.io.FileInputStream;
26 import java.io.IOException;
27 import java.io.InputStream;
28 import java.util.Properties;
29
30 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.daeximoffsitebackup.rev180926.BackupDataOutputBuilder;
31
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;
34
35 import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper;
36
37 import org.slf4j.Logger;
38 import org.slf4j.LoggerFactory;
39
40 public class DaeximOffsiteBackupUtil extends MdsalHelper {
41     private static final Logger LOG = LoggerFactory.getLogger(DaeximOffsiteBackupUtil.class);
42     private static String PROPERTIES_FILE;
43
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()) {
49             try {
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);
56             } finally {
57                 if(input != null) {
58                     try {
59                         input.close();
60                     } catch (IOException e) {
61                         LOG.error("Failed to close properties file " + PROPERTIES_FILE + "\n", e);
62                     }
63                 }
64             }
65         }
66     }
67
68     static {
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.
72
73         BackupDataOutputBuilder b1 = new BackupDataOutputBuilder();
74
75         RetrieveDataOutputBuilder b2 = new RetrieveDataOutputBuilder();
76         RetrieveDataInputBuilder b3 = new RetrieveDataInputBuilder();
77     }
78 }