Add unit test for vfc-nfvo-wfengine
[vfc/nfvo/wfengine.git] / activiti-extension / src / main / java / org / onap / workflow / activitiext / restservicetask / PropertyUtil.java
index 5391757..48e2ab6 100644 (file)
@@ -1,46 +1,47 @@
 /**\r
- * Copyright 2017 ZTE Corporation.\r
+ * Copyright 2017 [ZTE] and others.\r
  *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
  *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
  *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
  */\r
-\r
 package org.onap.workflow.activitiext.restservicetask;\r
 \r
 import java.util.ResourceBundle;\r
 \r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
 public class PropertyUtil {\r
        \r
+        private static final Logger logger = LoggerFactory.getLogger(PropertyUtil.class);\r
+       \r
        public static final String REST_PROPERTY_LOCATION = "config";\r
        \r
        public static final String BASE_URL = "baseurl";\r
        \r
-       private static ResourceBundle resource;\r
-       \r
-       static{\r
-               resource = ResourceBundle.getBundle(REST_PROPERTY_LOCATION);\r
-       }\r
-\r
        public static String findByKey(String key){\r
                \r
-               String value = resource.getString(key);\r
-               \r
-        return value;\r
+               try {\r
+                       ResourceBundle resource = ResourceBundle.getBundle(REST_PROPERTY_LOCATION);\r
+                       \r
+                       String value = resource.getString(key);\r
+                       \r
+                       return value;\r
+               } catch (Exception e) {\r
+                       logger.error("read resource failed!", e);\r
+                       throw e;\r
+               }\r
        }\r
        \r
        public static String getBasePath(){\r
                \r
-               String basepath = findByKey(BASE_URL);\r
-               \r
-               return basepath;\r
+               return findByKey(BASE_URL);\r
        }\r
 }\r