summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-02-19 12:35:04 +0200
committerMichael Lando <ml636r@att.com>2017-02-19 12:35:04 +0200
commitf5f13c4f6b6fe3b4d98e349dfd7db59339803436 (patch)
tree72caffc93fab394ffa3b761505775331f1c559b9 /openecomp-be/lib/openecomp-core-lib/openecomp-config-lib
parent451a3400b76511393c62a444f588a4ed15f4a549 (diff)
push addional code
Change-Id: Ia427bb3460cda3a896f8faced2de69eaf3807b74 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-core-lib/openecomp-config-lib')
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/pom.xml48
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/ApplicationConfig.java35
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/ApplicationConfigFactory.java31
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/dao/ApplicationConfigDao.java33
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/dao/ApplicationConfigDaoFactory.java32
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/dao/impl/ApplicationConfigDaoCassandraImpl.java115
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/dao/impl/ApplicationConfigDaoFactoryImpl.java33
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/dao/type/ApplicationConfigEntity.java79
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/impl/ApplicationConfigFactoryImpl.java34
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/impl/ApplicationConfigImpl.java74
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/type/ConfigurationData.java48
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/resources/factoryConfiguration.json4
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/resources/logback.xml90
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/test/java/org/openecomp/sdc/applicationconfig/dao/ApplicationConfigImplDaoTest.java88
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/test/resources/questionnaire/testTemplate.txt12
15 files changed, 756 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/pom.xml b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/pom.xml
new file mode 100644
index 0000000000..a10e9cbd04
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/pom.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-core-lib</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>openecomp-config-lib</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.3.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.yaml</groupId>
+ <artifactId>snakeyaml</artifactId>
+ <version>1.14</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-nosqldb-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>6.9.10</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-vendor-software-product-api</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+
+</project> \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/ApplicationConfig.java b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/ApplicationConfig.java
new file mode 100644
index 0000000000..a68c6b614a
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/ApplicationConfig.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.utilities.applicationconfig;
+
+import org.openecomp.core.utilities.applicationconfig.dao.type.ApplicationConfigEntity;
+import org.openecomp.core.utilities.applicationconfig.type.ConfigurationData;
+
+import java.util.Collection;
+
+public interface ApplicationConfig {
+
+ ConfigurationData getConfigurationData(String namespace, String key);
+
+ void insertValue(String namespace, String key, String value);
+
+ Collection<ApplicationConfigEntity> getListOfConfigurationByNamespace(String namespace);
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/ApplicationConfigFactory.java b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/ApplicationConfigFactory.java
new file mode 100644
index 0000000000..e022294dfd
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/ApplicationConfigFactory.java
@@ -0,0 +1,31 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.utilities.applicationconfig;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+public abstract class ApplicationConfigFactory extends AbstractComponentFactory<ApplicationConfig> {
+
+ public static ApplicationConfigFactory getInstance() {
+ return AbstractFactory.getInstance(ApplicationConfigFactory.class);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/dao/ApplicationConfigDao.java b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/dao/ApplicationConfigDao.java
new file mode 100644
index 0000000000..a4c582744a
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/dao/ApplicationConfigDao.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.utilities.applicationconfig.dao;
+
+import org.openecomp.core.dao.BaseDao;
+import org.openecomp.core.utilities.applicationconfig.dao.type.ApplicationConfigEntity;
+import org.openecomp.core.utilities.applicationconfig.type.ConfigurationData;
+
+
+public interface ApplicationConfigDao extends BaseDao<ApplicationConfigEntity> {
+
+ long getValueTimestamp(String namespace, String key);
+
+ ConfigurationData getConfigurationData(String namespace, String key);
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/dao/ApplicationConfigDaoFactory.java b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/dao/ApplicationConfigDaoFactory.java
new file mode 100644
index 0000000000..f60e4a9010
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/dao/ApplicationConfigDaoFactory.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.utilities.applicationconfig.dao;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+public abstract class ApplicationConfigDaoFactory
+ extends AbstractComponentFactory<ApplicationConfigDao> {
+
+ public static ApplicationConfigDaoFactory getInstance() {
+ return AbstractFactory.getInstance(ApplicationConfigDaoFactory.class);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/dao/impl/ApplicationConfigDaoCassandraImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/dao/impl/ApplicationConfigDaoCassandraImpl.java
new file mode 100644
index 0000000000..7fb0e2f5ae
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/dao/impl/ApplicationConfigDaoCassandraImpl.java
@@ -0,0 +1,115 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.utilities.applicationconfig.dao.impl;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import com.datastax.driver.mapping.Mapper;
+import com.datastax.driver.mapping.Result;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Query;
+import org.openecomp.core.dao.impl.CassandraBaseDao;
+import org.openecomp.core.nosqldb.api.NoSqlDb;
+import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
+import org.openecomp.core.utilities.applicationconfig.dao.ApplicationConfigDao;
+import org.openecomp.core.utilities.applicationconfig.dao.type.ApplicationConfigEntity;
+import org.openecomp.core.utilities.applicationconfig.type.ConfigurationData;
+
+import java.util.Collection;
+import java.util.Objects;
+
+public class ApplicationConfigDaoCassandraImpl extends CassandraBaseDao<ApplicationConfigEntity>
+ implements ApplicationConfigDao {
+
+ private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
+ private static final Mapper<ApplicationConfigEntity> mapper =
+ noSqlDb.getMappingManager().mapper(ApplicationConfigEntity.class);
+ private static final ApplicationConfigAccessor accessor =
+ noSqlDb.getMappingManager().createAccessor(ApplicationConfigAccessor.class);
+
+ @Override
+ protected Mapper<ApplicationConfigEntity> getMapper() {
+ return mapper;
+ }
+
+ @Override
+ protected Object[] getKeys(ApplicationConfigEntity entity) {
+ return new Object[]{entity.getNamespace(), entity.getKey(), entity.getValue()};
+ }
+
+ @Override
+ public Collection<ApplicationConfigEntity> list(ApplicationConfigEntity entity) {
+ return accessor.list(entity.getNamespace()).all();
+ }
+
+ @Override
+ public void create(ApplicationConfigEntity entity) {
+ accessor.updateApplicationConfigData(entity.getNamespace(), entity.getKey(), entity.getValue());
+ }
+
+ @Override
+ public void update(ApplicationConfigEntity entity) {
+ accessor.updateApplicationConfigData(entity.getNamespace(), entity.getKey(), entity.getValue());
+ }
+
+ @Override
+ public ApplicationConfigEntity get(ApplicationConfigEntity entity) {
+ return accessor.get(entity.getNamespace(), entity.getKey());
+ }
+
+ @Override
+ public long getValueTimestamp(String namespace, String key) {
+ ResultSet resultSet = accessor.getValueAndTimestampOfConfigurationValue(namespace, key);
+
+ return resultSet.one().getLong("writetime(value)");
+ }
+
+ @Override
+ public ConfigurationData getConfigurationData(String namespace, String key) {
+ //String value = accessor.getValue(namespace, key).one().getString("value");
+ ResultSet resultSet = accessor.getValueAndTimestampOfConfigurationValue(namespace, key);
+ Row one = resultSet.one();
+
+ if (Objects.nonNull(one)) {
+ return new ConfigurationData(one.getString("value"), one.getLong("writetime(value)"));
+ }
+
+ return null;
+ }
+
+
+ @Accessor
+ interface ApplicationConfigAccessor {
+
+ @Query("select namespace, key, value from application_config where namespace=?")
+ Result<ApplicationConfigEntity> list(String namespace);
+
+ @Query("insert into application_config (namespace, key, value) values (?,?,?)")
+ ResultSet updateApplicationConfigData(String namespace, String key, String value);
+
+ @Query("select namespace, key, value from application_config where namespace=? and key=?")
+ ApplicationConfigEntity get(String namespace, String key);
+
+ @Query("select value, writetime(value) from application_config where namespace=? and key=?")
+ ResultSet getValueAndTimestampOfConfigurationValue(String namespace, String key);
+
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/dao/impl/ApplicationConfigDaoFactoryImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/dao/impl/ApplicationConfigDaoFactoryImpl.java
new file mode 100644
index 0000000000..cea49ea8d1
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/dao/impl/ApplicationConfigDaoFactoryImpl.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.utilities.applicationconfig.dao.impl;
+
+import org.openecomp.core.utilities.applicationconfig.dao.ApplicationConfigDao;
+import org.openecomp.core.utilities.applicationconfig.dao.ApplicationConfigDaoFactory;
+
+public class ApplicationConfigDaoFactoryImpl extends ApplicationConfigDaoFactory {
+ private static final ApplicationConfigDao INSTANCE = new ApplicationConfigDaoCassandraImpl();
+
+ @Override
+ public ApplicationConfigDao createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/dao/type/ApplicationConfigEntity.java b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/dao/type/ApplicationConfigEntity.java
new file mode 100644
index 0000000000..c73ce36744
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/dao/type/ApplicationConfigEntity.java
@@ -0,0 +1,79 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.utilities.applicationconfig.dao.type;
+
+
+import com.datastax.driver.mapping.annotations.ClusteringColumn;
+import com.datastax.driver.mapping.annotations.PartitionKey;
+import com.datastax.driver.mapping.annotations.Table;
+
+@Table(keyspace = "dox", name = "application_config")
+public class ApplicationConfigEntity {
+
+ @PartitionKey
+ private String namespace;
+ @ClusteringColumn
+ private String key;
+ private String value;
+
+ /**
+ * Instantiates a new Application config entity.
+ *
+ * @param namespace the namespace
+ * @param key the key
+ * @param value the value
+ */
+ public ApplicationConfigEntity(String namespace, String key, String value) {
+ this.namespace = namespace;
+ this.key = key;
+ this.value = value;
+ }
+
+
+ public ApplicationConfigEntity() {
+ }
+
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/impl/ApplicationConfigFactoryImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/impl/ApplicationConfigFactoryImpl.java
new file mode 100644
index 0000000000..cca07fc227
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/impl/ApplicationConfigFactoryImpl.java
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.utilities.applicationconfig.impl;
+
+import org.openecomp.core.utilities.applicationconfig.ApplicationConfig;
+import org.openecomp.core.utilities.applicationconfig.ApplicationConfigFactory;
+
+public class ApplicationConfigFactoryImpl extends ApplicationConfigFactory {
+
+ private static final ApplicationConfig INSTANCE = new ApplicationConfigImpl();
+
+ @Override
+ public ApplicationConfig createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/impl/ApplicationConfigImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/impl/ApplicationConfigImpl.java
new file mode 100644
index 0000000000..ff9c9aea87
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/impl/ApplicationConfigImpl.java
@@ -0,0 +1,74 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.utilities.applicationconfig.impl;
+
+import org.openecomp.core.utilities.applicationconfig.ApplicationConfig;
+import org.openecomp.core.utilities.applicationconfig.dao.ApplicationConfigDao;
+import org.openecomp.core.utilities.applicationconfig.dao.ApplicationConfigDaoFactory;
+import org.openecomp.core.utilities.applicationconfig.dao.type.ApplicationConfigEntity;
+import org.openecomp.core.utilities.applicationconfig.type.ConfigurationData;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+import java.util.Collection;
+import java.util.Objects;
+
+/**
+ * The type Application config.
+ */
+public class ApplicationConfigImpl implements ApplicationConfig {
+ private static final ApplicationConfigDao applicationConfigDao =
+ ApplicationConfigDaoFactory.getInstance().createInterface();
+
+ private static final String CONFIGURATION_SEARCH_ERROR = "CONFIGURATION_NOT_FOUND";
+ private static final String CONFIGURATION_SEARCH_ERROR_MSG =
+ "Configuration for namespace %s and key %s was not found";
+
+ @Override
+ public ConfigurationData getConfigurationData(String namespace, String key) {
+ ConfigurationData configurationData = applicationConfigDao.getConfigurationData(namespace, key);
+
+ if (Objects.isNull(configurationData)) {
+ throw new CoreException(new ErrorCode.ErrorCodeBuilder()
+ .withCategory(ErrorCategory.APPLICATION)
+ .withId(CONFIGURATION_SEARCH_ERROR)
+ .withMessage(String.format(CONFIGURATION_SEARCH_ERROR_MSG, namespace, key))
+ .build());
+ }
+
+ return configurationData;
+ }
+
+ @Override
+ public void insertValue(String namespace, String key, String value) {
+ ApplicationConfigEntity applicationConfigEntity =
+ new ApplicationConfigEntity(namespace, key, value);
+ applicationConfigDao.create(applicationConfigEntity);
+ }
+
+ @Override
+ public Collection<ApplicationConfigEntity> getListOfConfigurationByNamespace(String namespace) {
+ ApplicationConfigEntity applicationConfigEntity =
+ new ApplicationConfigEntity(namespace, null, null);
+ return applicationConfigDao.list(applicationConfigEntity);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/type/ConfigurationData.java b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/type/ConfigurationData.java
new file mode 100644
index 0000000000..53d3797e53
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/java/org/openecomp/core/utilities/applicationconfig/type/ConfigurationData.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.utilities.applicationconfig.type;
+
+public class ConfigurationData {
+
+ private String value;
+ private long timeStamp;
+
+ public ConfigurationData(String value, long timeStamp) {
+ this.value = value;
+ this.timeStamp = timeStamp;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public long getTimeStamp() {
+ return timeStamp;
+ }
+
+ public void setTimeStamp(long timeStamp) {
+ this.timeStamp = timeStamp;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/resources/factoryConfiguration.json
new file mode 100644
index 0000000000..19d2cafe8f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/resources/factoryConfiguration.json
@@ -0,0 +1,4 @@
+{
+ "org.openecomp.core.utilities.applicationconfig.ApplicationConfigFactory":"org.openecomp.core.utilities.applicationconfig.impl.ApplicationConfigFactoryImpl",
+ "org.openecomp.core.utilities.applicationconfig.dao.ApplicationConfigDaoFactory":"org.openecomp.core.utilities.applicationconfig.dao.impl.ApplicationConfigDaoFactoryImpl"
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/resources/logback.xml b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/resources/logback.xml
new file mode 100644
index 0000000000..e256e0b10a
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/main/resources/logback.xml
@@ -0,0 +1,90 @@
+<!--
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+
+
+ <appender name="DEBUG_ROLLING"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>DOX-BE.log
+ </file>
+
+ &lt;!&ndash; No need to deny audit messages - they are INFO only, will be denied
+ anyway &ndash;&gt;
+ &lt;!&ndash; Transaction messages filter - deny Transaction messages, there are
+ some DEBUG level messages among them &ndash;&gt;
+
+
+ &lt;!&ndash; accept DEBUG and TRACE level &ndash;&gt;
+
+ <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <fileNamePattern>/DOX-BE.log.%i
+ </fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>10</maxIndex>
+ </rollingPolicy>
+
+ <triggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>20MB</maxFileSize>
+ </triggeringPolicy>
+ <encoder>
+ <pattern>%level [%d{yyyy-MM-dd'T'HH:mm:ss}] - Method=%M, Desc=&lt;%msg&gt;%n</pattern>
+ </encoder>
+ </appender>
+
+
+ <root level="info">
+ <appender-ref ref="DEBUG_ROLLING" />
+ </root>
+</configuration>-->
+<configuration scan="true" scanPeriod="3 seconds">
+
+ <property name="logDir" value="logs"/>
+ <property name="componentName" value="ASDC"/>
+ <property name="ECOMP-subcomponent-name" value="ASDC-BE"/>
+
+ <property name="defaultPattern"
+ value="%msg%n"/>
+
+ <!--<property name="MetricsLogPattern" value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%X{CategoryLogLevel}|%X{Severity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{ClientIP}|%logger%n" />
+ <property name="AuditLogPattern" value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%X{CategoryLogLevel}|%X{Severity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{ClientIP}%n" />
+ <property name="ErrorLogPattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSS, GMT}|%X{RequestId}|%thread|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{ErrorCategory}|%X{ErrorCode}|%X{ErrorDescription}|%msg%n"/>
+ <property name="DebugLogPattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSS, GMT}|%X{RequestId}||%logger|%msg%n"/>-->
+
+ <!-- new pattern -->
+ <property name="default-log-pattern"
+ value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{BeginTimestamp}|%X{EndTimestamp}|%X{uuid}|%X{serviceInstanceID}|%thread|%X{ServerName}|%X{ServiceName}|${ECOMP-subcomponent-name}|%X{userId}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%X{ErrorCategory}|%X{ErrorCode}|%X{ErrorDescription}|%level|%X{alarmSeverity}|%X{localAddr}|%X{ElapsedTime}|%X{beFqdn}|%X{remoteAddr}|%logger{35}|%X{timer}|ActivityType=&lt;%M&gt;, Desc=&lt;%msg&gt;%n"/>
+
+ <property name="logDirectory" value="${logDir}/${componentName}"/>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>${defaultPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="DISPATCHER" class="ch.qos.logback.classic.sift.SiftingAppender">
+ <discriminator class="org.openecomp.core.logging.logback.EventTypeDiscriminator"/>
+ <sift>
+ <appender name="${eventType}" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDirectory}/${eventType}.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <fileNamePattern>${logDirectory}/${eventType}.%i.log.zip</fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>9</maxIndex>
+ </rollingPolicy>
+ <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>5MB</maxFileSize>
+ </triggeringPolicy>
+ <encoder>
+ <pattern>${default-log-pattern}</pattern>
+ </encoder>
+ </appender>
+ </sift>
+ </appender>
+
+ <root level="DEBUG">
+ <appender-ref ref="DISPATCHER"/>
+ </root>
+
+</configuration> \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/test/java/org/openecomp/sdc/applicationconfig/dao/ApplicationConfigImplDaoTest.java b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/test/java/org/openecomp/sdc/applicationconfig/dao/ApplicationConfigImplDaoTest.java
new file mode 100644
index 0000000000..40cde1ecb2
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/test/java/org/openecomp/sdc/applicationconfig/dao/ApplicationConfigImplDaoTest.java
@@ -0,0 +1,88 @@
+package org.openecomp.sdc.applicationconfig.dao;
+
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
+import org.openecomp.core.utilities.applicationconfig.ApplicationConfig;
+import org.openecomp.core.utilities.applicationconfig.ApplicationConfigFactory;
+import org.openecomp.core.utilities.applicationconfig.dao.ApplicationConfigDao;
+import org.openecomp.core.utilities.applicationconfig.dao.ApplicationConfigDaoFactory;
+import org.openecomp.core.utilities.applicationconfig.dao.type.ApplicationConfigEntity;
+import org.openecomp.core.utilities.applicationconfig.type.ConfigurationData;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+
+public class ApplicationConfigImplDaoTest {
+
+ private static final String SCHEMA_GENERATOR_INITIALIZATION_ERROR =
+ "SCHEMA_GENERATOR_INITIALIZATION_ERROR";
+ private static final String SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG =
+ "Error occurred while loading questionnaire schema templates";
+ private static ApplicationConfigDao applicationConfigDao =
+ ApplicationConfigDaoFactory.getInstance().createInterface();
+ private static ApplicationConfig applicationConfig =
+ ApplicationConfigFactory.getInstance().createInterface();
+
+// @BeforeClass
+ public static void init() {
+ try {
+
+ ApplicationConfigEntity applicationConfigEntity1 =
+ new ApplicationConfigEntity("test - namespace", "vsp", "vspTemplate");
+ ApplicationConfigEntity applicationConfigEntity2 =
+ new ApplicationConfigEntity("test - namespace", "nic", "nicTemplate");
+ ApplicationConfigEntity applicationConfigEntity3 =
+ new ApplicationConfigEntity("test - namespace", "component", "componentTemplate");
+
+ applicationConfigDao.create(applicationConfigEntity1);
+ applicationConfigDao.create(applicationConfigEntity2);
+ applicationConfigDao.create(applicationConfigEntity3);
+
+ } catch (Exception e) {
+ throw new CoreException(new ErrorCode.ErrorCodeBuilder().
+ withCategory(ErrorCategory.APPLICATION).
+ withId(SCHEMA_GENERATOR_INITIALIZATION_ERROR).
+ withMessage(SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG).
+ build());
+ }
+ }
+
+ private static String loadFileToString(String path) {
+ return new String(FileUtils.toByteArray(FileUtils.loadFileToInputStream(path)));
+ }
+
+// @Test
+ public void testApplicationConfigTimestampValue() {
+ ConfigurationData configurationData = applicationConfig
+ .getConfigurationData("test - namespace", CompositionEntityType.vsp.name());
+
+ Assert.assertNotNull(configurationData);
+ Assert.assertNotEquals(configurationData.getTimeStamp(), 0);
+
+ }
+
+// @Test(dependsOnMethods = "testApplicationConfigTimestampValue")
+ public void testNotExistingApplicationConfigTimestampValue() {
+ try {
+ applicationConfig.getConfigurationData("test - namespace", "aaa");
+ } catch (CoreException ce) {
+ Assert.assertEquals(ce.getMessage(),
+ "Configuration for namespace test - namespace and key aaa was not found");
+ }
+
+ }
+
+// @Test(dependsOnMethods = "testApplicationConfigTimestampValue")
+ public void testInsertApplicationConfiguration() {
+ String testTemplate = loadFileToString("questionnaire/testTemplate.txt");
+ applicationConfig.insertValue("test_namespace", "test_key", testTemplate);
+
+ Assert.assertEquals(testTemplate,
+ applicationConfig.getConfigurationData("test_namespace", "test_key").getValue());
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/test/resources/questionnaire/testTemplate.txt b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/test/resources/questionnaire/testTemplate.txt
new file mode 100644
index 0000000000..0bb19c5984
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/test/resources/questionnaire/testTemplate.txt
@@ -0,0 +1,12 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "general": {
+ "type": "object",
+ "properties": {
+ "testObject":{
+ "type": "string"
+ }
+ }
+} \ No newline at end of file