--- /dev/null
+/*\r
+ * ============LICENSE_START========================================================================\r
+ * ONAP : tr-069-adapter\r
+ * =================================================================================================\r
+ * Copyright (C) 2020 CommScope Inc Intellectual Property.\r
+ * =================================================================================================\r
+ * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,\r
+ * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You\r
+ * may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\r
+ * either express or implied. See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ===============LICENSE_END=======================================================================\r
+ */\r
+\r
+\r
+package org.commscope.tr069adapter.acs.common.utils;\r
+\r
+import java.text.MessageFormat;\r
+import java.util.ResourceBundle;\r
+\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+public class Utility {\r
+\r
+ private Utility() {}\r
+\r
+ private static final Logger logger = LoggerFactory.getLogger(Utility.class);\r
+\r
+ private static final String ERROR_MESSAGE_PROPS = "config/ErrorMessages_tr069";\r
+\r
+ private static ResourceBundle resourceBundle = ResourceBundle.getBundle(ERROR_MESSAGE_PROPS);\r
+\r
+ /**\r
+ * Utility method for reading the error messages from the error message property file.\r
+ * \r
+ * @param key - The key of the message\r
+ * @param args - Arguments of the messages if any\r
+ * @return\r
+ * @throws ReplanExecutorFailedException\r
+ */\r
+ public static String getMessage(String key, String... args) {\r
+ try {\r
+ String result = resourceBundle.getString(key);\r
+ if (args != null && args.length > 0) {\r
+ MessageFormat messageForm = new MessageFormat(result);\r
+ result = messageForm.format(args);\r
+ }\r
+ return result;\r
+ } catch (Exception e) {\r
+ logger.error("Unable to get the message for the given key {}", key);\r
+ return "Unresolved key: " + key;\r
+ }\r
+ }\r
+\r
+}\r