877103f49a5e276d3a8663eef75bc4ce2d3cc996
[sdc.git] /
1 /*
2  * Copyright © 2018 European Support Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15 */
16
17 package org.openecomp.sdc.applicationconfig.impl;
18
19 import java.util.Collection;
20 import org.openecomp.core.utilities.applicationconfig.ApplicationConfig;
21 import org.openecomp.core.utilities.applicationconfig.dao.type.ApplicationConfigEntity;
22 import org.openecomp.core.utilities.applicationconfig.impl.ApplicationConfigImpl;
23 import org.openecomp.core.utilities.applicationconfig.type.ConfigurationData;
24 import org.openecomp.sdc.applicationconfig.ApplicationConfigManager;
25 import org.openecomp.sdc.common.errors.CoreException;
26 import org.openecomp.sdc.common.errors.ErrorCategory;
27 import org.openecomp.sdc.common.errors.ErrorCode;
28
29 /**
30  * Created by Talio on 8/8/2016.
31  */
32 public class ApplicationConfigManagerImpl implements ApplicationConfigManager {
33
34   private static final String SCHEMA_GENERATOR_INITIALIZATION_ERROR =
35       "SCHEMA_GENERATOR_INITIALIZATION_ERROR";
36   private static final String SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG =
37       "Error occurred while loading questionnaire schema templates";
38   private ApplicationConfig applicationConfig = new ApplicationConfigImpl();
39
40   @Override
41   public void insertIntoTable(String namespace, String key, String value) {
42     try {
43       applicationConfig.insertValue(namespace, key, value);
44     } catch (Exception exception) {
45       throw new CoreException(new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory
46           .APPLICATION).withId(SCHEMA_GENERATOR_INITIALIZATION_ERROR).withMessage(
47           SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG).build(), exception);
48     }
49   }
50
51   @Override
52   public ConfigurationData getFromTable(String namespace, String key) {
53     return applicationConfig.getConfigurationData(namespace, key);
54   }
55
56   @Override
57   public Collection<ApplicationConfigEntity> getListOfConfigurationByNamespace(String namespace) {
58     return applicationConfig.getListOfConfigurationByNamespace(namespace);
59   }
60 }