Merge "Not logged or rethrow this exception."
[aai/data-router.git] / src / main / java / org / openecomp / datarouter / search / filters / config / UiFiltersSchemaUtility.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017 Amdocs
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  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  */
23 package org.openecomp.datarouter.search.filters.config;
24
25 import java.io.File;
26 import java.io.IOException;
27
28 import org.onap.aai.cl.api.Logger;
29 import org.onap.aai.cl.eelf.LoggerFactory;
30 import org.openecomp.datarouter.logging.DataRouterMsgs;
31 import org.openecomp.datarouter.util.DataRouterConstants;
32
33 import com.fasterxml.jackson.databind.ObjectMapper;
34
35 /**
36  * Utility methods for interacting with the UI filters schema file
37  */
38 public class UiFiltersSchemaUtility {
39   private static final Logger LOG =
40       LoggerFactory.getInstance().getLogger(UiFiltersSchemaUtility.class);
41
42   private ObjectMapper mapper = new ObjectMapper();
43
44   /**
45    * Reads in the file and populates an object with that data
46    * 
47    * @throws Exception
48    */
49   public UiFiltersConfig loadUiFiltersConfig() {
50     UiFiltersConfig filtersConfig = new UiFiltersConfig();
51
52     try {
53       filtersConfig = mapper.readValue(new File(DataRouterConstants.UI_FILTER_LIST_FILE), UiFiltersConfig.class);
54     } catch (IOException e) {
55       LOG.error(DataRouterMsgs.JSON_CONVERSION_ERROR, "Could not convert filters config file " +
56           DataRouterConstants.UI_FILTER_LIST_FILE + " to " + filtersConfig.getClass());
57     }
58
59     return filtersConfig;
60   }
61 }