push addional code
[sdc.git] / openecomp-be / backend / openecomp-sdc-application-config-manager / src / main / java / org / openecomp / sdc / applicationconfig / impl / ApplicationConfigManagerImpl.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.applicationconfig.impl;
22
23 import org.openecomp.core.utilities.applicationconfig.ApplicationConfig;
24 import org.openecomp.core.utilities.applicationconfig.dao.type.ApplicationConfigEntity;
25 import org.openecomp.core.utilities.applicationconfig.impl.ApplicationConfigImpl;
26 import org.openecomp.core.utilities.applicationconfig.type.ConfigurationData;
27 import org.openecomp.sdc.applicationconfig.ApplicationConfigManager;
28 import org.openecomp.sdc.common.errors.CoreException;
29 import org.openecomp.sdc.common.errors.ErrorCategory;
30 import org.openecomp.sdc.common.errors.ErrorCode;
31
32 import java.util.Collection;
33
34 public class ApplicationConfigManagerImpl implements ApplicationConfigManager {
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()
47           .withCategory(ErrorCategory.APPLICATION)
48           .withId(SCHEMA_GENERATOR_INITIALIZATION_ERROR)
49           .withMessage(SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG)
50           .build());
51     }
52   }
53
54   @Override
55   public ConfigurationData getFromTable(String namespace, String key) {
56     return applicationConfig.getConfigurationData(namespace, key);
57   }
58
59   @Override
60   public Collection<ApplicationConfigEntity> getListOfConfigurationByNamespace(String namespace) {
61     return applicationConfig.getListOfConfigurationByNamespace(namespace);
62   }
63 }