Open Kilda Java Documentation
MessageUtil.java
Go to the documentation of this file.
1 package org.openkilda.utility;
2 
3 import org.slf4j.Logger;
4 import org.slf4j.LoggerFactory;
5 
6 import org.springframework.stereotype.Component;
7 
8 import java.util.Properties;
9 
13 @Component
14 public class MessageUtil {
15 
16  private static final Logger LOGGER = LoggerFactory.getLogger(MessageUtil.class);
17 
18  public static final String CODE = ".code";
19  public static final String MESSAGE = ".message";
20  public static final String AUXILARY = ".auxilary";
21 
22  private static Properties messages;
23 
24  static {
25  messages = loadPropertiesFile("error-messages.properties");
26  }
27 
33  public static Properties loadPropertiesFile(final String fileName) {
34  Properties localProperties = new Properties();
35  try {
36  localProperties.load(MessageUtil.class.getClassLoader().getResourceAsStream(
37  fileName));
38  } catch (Exception e) {
39  LOGGER.error("[loadPropertiesFile] Exception : ", e);
40  }
41  return localProperties;
42  }
43 
50  public static String getCode(final String msg) {
51  return messages.getProperty(msg + CODE);
52  }
53 
60  public static String getMessage(final String msg) {
61  return messages.getProperty(msg + MESSAGE);
62  }
63 
70  public static String getAuxilaryMessage(final String msg) {
71  return messages.getProperty(msg + AUXILARY);
72  }
73 
80  public static String getPropertyValue(final String msg) {
81  return messages.getProperty(msg);
82  }
83 }
static String getAuxilaryMessage(final String msg)
static String getMessage(final String msg)
static Properties loadPropertiesFile(final String fileName)
static String getCode(final String msg)
static String getPropertyValue(final String msg)