re base code
[sdc.git] / openecomp-be / backend / openecomp-sdc-application-config-manager / src / main / java / org / openecomp / sdc / applicationconfig / impl / ApplicationConfigManagerImpl.java
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 org.openecomp.core.utilities.applicationconfig.ApplicationConfig;
20 import org.openecomp.core.utilities.applicationconfig.dao.type.ApplicationConfigEntity;
21 import org.openecomp.core.utilities.applicationconfig.impl.ApplicationConfigImpl;
22 import org.openecomp.core.utilities.applicationconfig.type.ConfigurationData;
23 import org.openecomp.sdc.applicationconfig.ApplicationConfigManager;
24 import org.openecomp.sdc.common.errors.CoreException;
25 import org.openecomp.sdc.common.errors.ErrorCategory;
26 import org.openecomp.sdc.common.errors.ErrorCode;
27
28 import java.util.Collection;
29
30 /**
31  * Created by Talio on 8/8/2016.
32  */
33 public class ApplicationConfigManagerImpl implements ApplicationConfigManager {
34
35   private static final String SCHEMA_GENERATOR_INITIALIZATION_ERROR =
36       "SCHEMA_GENERATOR_INITIALIZATION_ERROR";
37   private static final String SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG =
38       "Error occurred while loading questionnaire schema templates";
39   private ApplicationConfig applicationConfig = new ApplicationConfigImpl();
40
41   @Override
42   public void insertIntoTable(String namespace, String key, String value) {
43     try {
44       applicationConfig.insertValue(namespace, key, value);
45     } catch (Exception exception) {
46       throw new CoreException(new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory
47           .APPLICATION).withId(SCHEMA_GENERATOR_INITIALIZATION_ERROR).withMessage(
48           SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG).build(), exception);
49     }
50   }
51
52   @Override
53   public ConfigurationData getFromTable(String namespace, String key) {
54     return applicationConfig.getConfigurationData(namespace, key);
55   }
56
57   @Override
58   public Collection<ApplicationConfigEntity> getListOfConfigurationByNamespace(String namespace) {
59     return applicationConfig.getListOfConfigurationByNamespace(namespace);
60   }
61 }