Add new Maven module to manage NBI Notifications
[transportpce.git] / nbinotifications / src / main / java / org / opendaylight / transportpce / nbinotifications / utils / NbiNotificationsUtils.java
1 /*
2  * Copyright © 2020 Orange, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.transportpce.nbinotifications.utils;
9
10 import java.io.IOException;
11 import java.io.InputStream;
12 import java.util.Properties;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
15
16 public final class NbiNotificationsUtils {
17
18     private static final Logger LOG = LoggerFactory.getLogger(NbiNotificationsUtils.class);
19
20     private NbiNotificationsUtils() {
21     }
22
23     public static Properties loadProperties(String propertyFileName) {
24         Properties props = new Properties();
25         InputStream inputStream = NbiNotificationsUtils.class.getClassLoader()
26                 .getResourceAsStream(propertyFileName);
27         try {
28             if (inputStream != null) {
29                 props.load(inputStream);
30             } else {
31                 LOG.warn("Kafka property file '{}' is empty", propertyFileName);
32             }
33         } catch (IOException e) {
34             LOG.warn("Kafka property file '{}' was not found in the classpath", propertyFileName);
35         }
36         return props;
37     }
38 }