aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSingal, Kapil (ks220y) <ks220y@att.com>2018-09-04 21:22:01 -0400
committerSingal, Kapil (ks220y) <ks220y@att.com>2018-09-04 21:22:01 -0400
commitd2cc0336c4dd9875e717e096d8f9bf815cb783b7 (patch)
tree244a71f6650645cd3177784ea07b502b8888773b
parenta43f31d01e92202e9bbb72ab0556c88790b3ce94 (diff)
SDN Controller Blueprints Data Adaptor
Formatting, Organizing Imports, Code Cleanup for SDN Controller Blueprints Data Adaptor Component Change-Id: I029da1d9660129ae3415429661d37b9ea13bcb8b Issue-ID: CCSDK-495 Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com>
-rw-r--r--blueprints-processor/.gitignore58
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/ConfigDataAdaptorException.java23
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/DataAdaptorConstants.java39
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigPropertyMapDao.java19
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigPropertyMapDaoImpl.java29
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigResourceDao.java23
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigResourceDaoImpl.java121
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/NamedQueryExecutorDao.java21
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/NamedQueryExecutorDaoImpl.java25
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/QueryExecutorDao.java21
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/QueryExecutorDaoImpl.java27
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/TransactionLogDao.java23
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/TransactionLogDaoImpl.java33
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/db/DataSourceWrap.java41
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/ConfigPropertyMapData.java29
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/ConfigResource.java79
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/ResourceAssignmentData.java75
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/TransactionLog.java49
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceNode.java33
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceService.java39
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceServiceImpl.java45
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml1
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigPropertyMapDaoTest.java25
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigResourceDaoTest.java43
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigTransactionLogDaoTest.java37
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/dao/QueryExecutorDaoTest.java35
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceNodeTest.java39
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceServiceTest.java59
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/log4j.properties26
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/test-context-h2db.xml1
-rw-r--r--blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/test-context.xml1
-rw-r--r--blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/ConfigRestAdaptorConstants.java31
-rw-r--r--blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/ConfigRestAdaptorException.java23
-rw-r--r--blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/data/RestResponse.java41
-rw-r--r--blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/AbstractConfigRestClientAdapter.java66
-rw-r--r--blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/ConfigRestAdaptorService.java29
-rw-r--r--blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/ConfigRestAdaptorServiceImpl.java49
-rw-r--r--blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/ConfigRestClientServiceAdapter.java29
-rw-r--r--blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/GenericRestClientAdapterImpl.java55
-rw-r--r--blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/SSLRestClientAdapterImpl.java55
-rw-r--r--blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/utils/BasicAuthorizationInterceptor.java25
-rw-r--r--blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/utils/LoggingRequestInterceptor.java25
-rw-r--r--blueprints-processor/adaptors/rest-adaptor-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml1
-rw-r--r--blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/config/rest/adaptor/service/AbstractConfigRestClientAdapterTest.java29
-rw-r--r--blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/config/rest/adaptor/service/GenericRestClientServiceTest.java56
-rw-r--r--blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/config/rest/adaptor/service/SSLClientServiceTest.java56
-rw-r--r--blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/config/rest/adaptor/utils/RestTemplateFactoryTest.java81
-rw-r--r--blueprints-processor/adaptors/rest-adaptor-provider/src/test/resources/config-rest-adaptor.properties74
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/ConfigAssignmentConstants.java21
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/data/ResourceAssignmentData.java77
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/processor/ProcessorFactory.java25
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/processor/ResourceAssignmentProcessor.java41
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentPersistService.java55
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentProcessService.java85
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentService.java23
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentServiceImpl.java31
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentUtils.java53
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigPreviewService.java33
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ResourceDictionaryService.java33
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ResourceModelService.java31
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml1
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ConfigPreviewServiceTest.java51
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ConfigResourceAssignmentTestUtils.java49
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ResourceAssignmentGenerationTest.java33
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ResourceAssignmentValidation.java37
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/TopologicalSortingTest.java23
66 files changed, 1383 insertions, 1163 deletions
diff --git a/blueprints-processor/.gitignore b/blueprints-processor/.gitignore
index 781272f59..dcf24b513 100644
--- a/blueprints-processor/.gitignore
+++ b/blueprints-processor/.gitignore
@@ -1,30 +1,30 @@
-# Target dir in all projects
-**/target/*
-**/target-ide/*
-
-# Logs dir in all projects
-**/logs/*
-**/debug-logs/*
-
-# Added for Intellij IDEA IDE
-**/.idea/*
-
-# Generated models and features
-**/bin/*
-
-# MANIFEST.MF is updated on every clean install
-**/src/main/resources/META-INF/
-**/src/main/yang-gen-sal
-**/src/main/yang-gen-config
-
-
-**/pom.xml.versionsBackup
-**/.flattened-pom.xml
-**/.pydevproject
-**/.settings
-**/.classpath
-**/.project
-
-**/*.class
-**/*.prefs
+# Target dir in all projects
+**/target/*
+**/target-ide/*
+
+# Logs dir in all projects
+**/logs/*
+**/debug-logs/*
+
+# Added for Intellij IDEA IDE
+**/.idea/*
+
+# Generated models and features
+**/bin/*
+
+# MANIFEST.MF is updated on every clean install
+**/src/main/resources/META-INF/
+**/src/main/yang-gen-sal
+**/src/main/yang-gen-config
+
+
+**/pom.xml.versionsBackup
+**/.flattened-pom.xml
+**/.pydevproject
+**/.settings
+**/.classpath
+**/.project
+
+**/*.class
+**/*.prefs
**/*.iml \ No newline at end of file
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/ConfigDataAdaptorException.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/ConfigDataAdaptorException.java
index c794b5d8a..cd4ac277a 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/ConfigDataAdaptorException.java
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/ConfigDataAdaptorException.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.data.adaptor;
@@ -20,12 +23,12 @@ package org.onap.ccsdk.config.data.adaptor;
* @version 1.0
*/
public class ConfigDataAdaptorException extends Exception {
-
+
/**
*
*/
private static final long serialVersionUID = 1L;
-
+
/**
* This is a ConfigDataAdaptorException constructor
*
@@ -34,7 +37,7 @@ public class ConfigDataAdaptorException extends Exception {
public ConfigDataAdaptorException(String message) {
super(message);
}
-
+
/**
* This is a ConfigDataAdaptorException constructor
*
@@ -43,5 +46,5 @@ public class ConfigDataAdaptorException extends Exception {
public ConfigDataAdaptorException(String message, Throwable cause) {
super(message, cause);
}
-
+
}
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/DataAdaptorConstants.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/DataAdaptorConstants.java
index c942ed6d8..6a61370ea 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/DataAdaptorConstants.java
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/DataAdaptorConstants.java
@@ -1,29 +1,32 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.data.adaptor;
@SuppressWarnings("squid:S1118")
public class DataAdaptorConstants {
-
+
public static final String OUTPUT_STATUS_SUCCESS = "success";
public static final String OUTPUT_STATUS_FAILURE = "failure";
-
+
public static final String PROPERTY_ENV_TYPE = "org.onap.ccsdk.config.rest.adaptors.envtype";
public static final String PROPERTY_ENV_PROD = "field";
public static final String PROPERTY_ENV_SOLO = "solo";
-
+
public static final String INPUT_PARAM_TAGS = "tags";
public static final String INPUT_PARAM_CAPABILITY_NAME = "capabilityName";
public static final String INPUT_PARAM_MESSAGE = "message";
@@ -35,39 +38,39 @@ public class DataAdaptorConstants {
public static final String INPUT_PARAM_ASDC_ARTIFACT_IND = "asdcArtifactInd";
public static final Object INPUT_PARAM_VNF_ID = "vnfId";
public static final Object INPUT_PARAM_VM_NAME = "vmName";
-
+
public static final Object INPUT_PARAM_CONFIG_CONTENT_TYPE = "configContentType";
-
+
public static final Object INPUT_PARAM_CONFIG_CONTENT = "configContent";
public static final Object INPUT_PARAM_CONFIG_INDICATOR = "configIndicator";
-
+
public static final Object CONFIG_CONTENT_TYPE_CONFIGURATION = "Configuration";
public static final Object CONFIG_CONTENT_TYPE_PARAMETERS = "Parameters";
public static final Object CONFIG_INDICATOR_PREPARE = "Prepare";
public static final Object CONFIG_INDICATOR_ACTIVE = "Active";
-
+
public static final String INPUT_PARAM_RESPONSE_PRIFIX = "response-prefix";
public static final String INPUT_PARAM_VNF_TYPE = "vnfType";
public static final String INPUT_PARAM_VNFC_TYPE = "vnfcType";
public static final String INPUT_PARAM_ACTION = "action";
public static final String INPUT_PARAM_API_VERSION = "apiVersion";
-
+
public static final String INPUT_PARAM_FILE_ID = "fileId";
public static final String INPUT_PARAM_UPLOAD_CONFIG_ID = "uploadConfigId";
public static final String FILE_CATEGORY_SERVICE_TEMPLATE = "service_template";
-
+
public static final String ARTIFACT_TYPE_SDNC_MODEL = "SDNC_MODEL";
-
+
public static final String LOG_MESSAGE_TYPE_LOG = "Log";
public static final String LOG_MESSAGE_TYPE_COMPONENT = "Component";
public static final String LOG_MESSAGE_TYPE_REQUEST = "Request";
public static final String LOG_MESSAGE_TYPE_MODEL = "Model";
public static final String LOG_MESSAGE_TYPE_DATA = "Data";
public static final String LOG_MESSAGE_TYPE_CONFIG = "Config";
-
+
public static final String SELF_SERVICE_STATUS_RECEIVED = "Received";
public static final String SELF_SERVICE_STATUS_ACKNOWLEDGED = "Acknowledged";
public static final String SELF_SERVICE_STATUS_REPLIED = "Replied";
public static final String SELF_SERVICE_STATUS_FAILED = "Failed";
-
+
}
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigPropertyMapDao.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigPropertyMapDao.java
index e1b25beda..2bf9682de 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigPropertyMapDao.java
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigPropertyMapDao.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.data.adaptor.dao;
@@ -17,7 +20,7 @@ package org.onap.ccsdk.config.data.adaptor.dao;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
public interface ConfigPropertyMapDao {
-
+
/**
* Query ConcurrentHashMap having CONFIG_PROPERTY_MAP table data for given key.
*
@@ -26,5 +29,5 @@ public interface ConfigPropertyMapDao {
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if fails
*/
public String getConfigPropertyByKey(String key) throws SvcLogicException;
-
+
}
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigPropertyMapDaoImpl.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigPropertyMapDaoImpl.java
index 84c96a84d..423e01451 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigPropertyMapDaoImpl.java
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigPropertyMapDaoImpl.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.data.adaptor.dao;
@@ -28,16 +31,16 @@ import com.att.eelf.configuration.EELFManager;
import com.google.common.base.Preconditions;
public class ConfigPropertyMapDaoImpl implements ConfigPropertyMapDao {
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigPropertyMapDaoImpl.class);
-
+
private JdbcTemplate jdbcTemplate;
private Map<String, String> configPropertyMap = new ConcurrentHashMap<>();
-
+
public ConfigPropertyMapDaoImpl(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
initializeMap();
-
+
String envType = configPropertyMap.get(DataAdaptorConstants.PROPERTY_ENV_TYPE);
if (!(DataAdaptorConstants.PROPERTY_ENV_PROD.equalsIgnoreCase(envType)
|| DataAdaptorConstants.PROPERTY_ENV_SOLO.equalsIgnoreCase(envType))) {
@@ -48,7 +51,7 @@ public class ConfigPropertyMapDaoImpl implements ConfigPropertyMapDao {
executor.scheduleWithFixedDelay(task, 60, 15, TimeUnit.MINUTES);
}
}
-
+
private void initializeMap() {
String getPropQuery = "SELECT * FROM CONFIG_PROPERTY_MAP";
jdbcTemplate.queryForList(getPropQuery).forEach(rows -> {
@@ -58,11 +61,11 @@ public class ConfigPropertyMapDaoImpl implements ConfigPropertyMapDao {
});
logger.trace("loaded configPropertyMap : ({})", configPropertyMap);
}
-
+
@Override
public String getConfigPropertyByKey(String key) throws SvcLogicException {
Preconditions.checkArgument(StringUtils.isNotBlank(key), "missing property key");
return configPropertyMap.get(key);
}
-
+
}
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigResourceDao.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigResourceDao.java
index 98f26473e..63628864c 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigResourceDao.java
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigResourceDao.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.data.adaptor.dao;
@@ -19,7 +22,7 @@ import org.onap.ccsdk.config.data.adaptor.domain.ConfigResource;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
public interface ConfigResourceDao {
-
+
/**
* Issue a single SQL Insert operation for CONFIG_RESOURCE table via a prepared statement, binding
* the given arguments.
@@ -29,7 +32,7 @@ public interface ConfigResourceDao {
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the insert
*/
public ConfigResource save(ConfigResource configResourceInput) throws SvcLogicException;
-
+
/**
* Issue a single SQL Delete operation for CONFIG_RESOURCE table via a prepared statement, binding
* the given arguments.
@@ -39,7 +42,7 @@ public interface ConfigResourceDao {
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the insert
*/
public void deleteByConfigResource(ConfigResource configResourceInput) throws SvcLogicException;
-
+
/**
* Query CONFIG_RESOURCE table for given input param to create a prepared statement to bind to the
* query, mapping each row to a Java object via a ConfigResource RowMapper.
@@ -50,6 +53,6 @@ public interface ConfigResourceDao {
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails
*/
public List<ConfigResource> findByConfigResource(ConfigResource configResourceInput) throws SvcLogicException;
-
+
public ConfigResource getConfigResource(ConfigResource configResource) throws SvcLogicException;
}
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigResourceDaoImpl.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigResourceDaoImpl.java
index 88cb78cb3..42cbbd1b0 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigResourceDaoImpl.java
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigResourceDaoImpl.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.data.adaptor.dao;
@@ -29,38 +32,38 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
public class ConfigResourceDaoImpl implements ConfigResourceDao {
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigResourceDaoImpl.class);
-
+
private JdbcTemplate jdbcTemplate;
-
+
public ConfigResourceDaoImpl(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
-
+
@Override
public ConfigResource save(ConfigResource configResource) throws SvcLogicException {
-
+
ConfigResource dbConfigResource = checkConfigResource(configResource);
-
+
if (dbConfigResource != null && StringUtils.isNotBlank(dbConfigResource.getConfigResourceId())) {
configResource.setConfigResourceId(dbConfigResource.getConfigResourceId());
-
+
validateConfigResource(configResource);
-
+
update(configResource);
-
+
saveConfigResourceAssignmentData(configResource);
} else {
String addQuery = "INSERT INTO CONFIG_RESOURCE "
+ "( config_resource_id, resource_id, resource_type, service_template_name, service_template_version,"
+ "template_name, recipe_name, request_id, resource_data, mask_data, status, created_date, updated_by ) "
+ "VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
-
+
configResource.setConfigResourceId(configResource.getUniqueId());
-
+
validateConfigResource(configResource);
-
+
logger.info("saving config resource ({}) ...", configResource);
jdbcTemplate.update(addQuery, configResource.getConfigResourceId(), configResource.getResourceId(),
configResource.getResourceType(), configResource.getServiceTemplateName(),
@@ -68,13 +71,13 @@ public class ConfigResourceDaoImpl implements ConfigResourceDao {
configResource.getRecipeName(), configResource.getRequestId(), configResource.getResourceData(),
configResource.getMaskData(), configResource.getStatus(), configResource.getCreatedDate(),
configResource.getUpdatedBy());
-
+
saveConfigResourceAssignmentData(configResource);
}
dbConfigResource = getConfigResource(configResource);
return dbConfigResource;
}
-
+
private void update(ConfigResource configResource) throws SvcLogicException {
if (StringUtils.isNotBlank(configResource.getConfigResourceId())) {
logger.info("updating config resource ({}) ...", configResource);
@@ -82,7 +85,7 @@ public class ConfigResourceDaoImpl implements ConfigResourceDao {
String updateQuery = "UPDATE CONFIG_RESOURCE SET "
+ "resource_data = ?, mask_data = ?, created_date = ?, updated_by = ? ,service_template_name = ?, service_template_version = ? "
+ "where config_resource_id = ?";
-
+
jdbcTemplate.update(updateQuery, configResource.getResourceData(), configResource.getMaskData(),
configResource.getCreatedDate(), configResource.getUpdatedBy(),
configResource.getServiceTemplateName(), configResource.getServiceTemplateVersion(),
@@ -91,7 +94,7 @@ public class ConfigResourceDaoImpl implements ConfigResourceDao {
throw new SvcLogicException("missing config resource id to update.");
}
}
-
+
private void saveConfigResourceAssignmentData(ConfigResource configResource) {
if (configResource != null && StringUtils.isNotBlank(configResource.getConfigResourceId())) {
List<Object> listOfArguments = new ArrayList<>();
@@ -100,7 +103,7 @@ public class ConfigResourceDaoImpl implements ConfigResourceDao {
this.jdbcTemplate.update(deleteQuery, listOfArguments.toArray());
logger.info("config resource assignment data deleted successfully for the config_resource_id ({})",
configResource.getConfigResourceId());
-
+
if (configResource.getResourceAssignments() != null) {
List<ResourceAssignmentData> resourceAssignments = configResource.getResourceAssignments();
for (ResourceAssignmentData resourceAssignmentData : resourceAssignments) {
@@ -112,13 +115,13 @@ public class ConfigResourceDaoImpl implements ConfigResourceDao {
}
}
}
-
+
private ResourceAssignmentData saveResourceAssignmentData(ResourceAssignmentData resourceAssignmentData) {
String addQuery = "INSERT INTO CONFIG_RESOURCE_ASSIGNMENT_DATA "
+ "( config_resource_assignment_data_id, config_resource_id, version, updated_by, template_key_name, "
+ "resource_name, data_type, entry_schema, resource_value, source, status, message ) "
+ "VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
-
+
logger.debug("saving config resource assignment data ({}) ... ", resourceAssignmentData);
jdbcTemplate.update(addQuery, resourceAssignmentData.getId(), resourceAssignmentData.getConfigResourceId(),
resourceAssignmentData.getVersion(), resourceAssignmentData.getUpdatedBy(),
@@ -126,33 +129,33 @@ public class ConfigResourceDaoImpl implements ConfigResourceDao {
resourceAssignmentData.getDataType(), resourceAssignmentData.getEntrySchema(),
resourceAssignmentData.getResourceValue(), resourceAssignmentData.getSource(),
resourceAssignmentData.getStatus(), resourceAssignmentData.getMessage());
-
+
return resourceAssignmentData;
}
-
+
@Override
public void deleteByConfigResource(ConfigResource configResourceInput) throws SvcLogicException {
StringBuilder selectArtifactBuffer = new StringBuilder();
List<Object> listOfArguments = new ArrayList<>();
-
+
selectArtifactBuffer.append("DELETE FROM CONFIG_RESOURCE WHERE config_resource_id = ? ");
listOfArguments.add(configResourceInput.getConfigResourceId());
-
+
String queryString = selectArtifactBuffer.toString();
this.jdbcTemplate.update(queryString, listOfArguments.toArray());
logger.info("config resource ({}) deleted successfully ", configResourceInput);
}
-
+
@SuppressWarnings("squid:S3776")
@Override
public List<ConfigResource> findByConfigResource(ConfigResource configResourceInput) throws SvcLogicException {
StringBuilder selectArtifactBuffer = new StringBuilder();
List<Object> listOfArguments = new ArrayList<>();
-
+
selectArtifactBuffer.append("SELECT * FROM CONFIG_RESOURCE WHERE ");
-
+
StringBuilder whereClauseRemaining = new StringBuilder();
-
+
if (configResourceInput.getServiceTemplateName() != null) {
if (whereClauseRemaining.length() != 0) {
whereClauseRemaining.append("AND ");
@@ -160,7 +163,7 @@ public class ConfigResourceDaoImpl implements ConfigResourceDao {
whereClauseRemaining.append("service_template_name = ? ");
listOfArguments.add(configResourceInput.getServiceTemplateName());
}
-
+
if (configResourceInput.getServiceTemplateVersion() != null) {
if (whereClauseRemaining.length() != 0) {
whereClauseRemaining.append("AND ");
@@ -168,7 +171,7 @@ public class ConfigResourceDaoImpl implements ConfigResourceDao {
whereClauseRemaining.append("service_template_version = ? ");
listOfArguments.add(configResourceInput.getServiceTemplateVersion());
}
-
+
if (configResourceInput.getResourceId() != null) {
if (whereClauseRemaining.length() != 0) {
whereClauseRemaining.append("AND ");
@@ -176,7 +179,7 @@ public class ConfigResourceDaoImpl implements ConfigResourceDao {
whereClauseRemaining.append("resource_id = ? ");
listOfArguments.add(configResourceInput.getResourceId());
}
-
+
if (configResourceInput.getResourceType() != null) {
if (whereClauseRemaining.length() != 0) {
whereClauseRemaining.append("AND ");
@@ -184,7 +187,7 @@ public class ConfigResourceDaoImpl implements ConfigResourceDao {
whereClauseRemaining.append("resource_type = ? ");
listOfArguments.add(configResourceInput.getResourceType());
}
-
+
if (configResourceInput.getRequestId() != null) {
if (whereClauseRemaining.length() != 0) {
whereClauseRemaining.append("AND ");
@@ -192,7 +195,7 @@ public class ConfigResourceDaoImpl implements ConfigResourceDao {
whereClauseRemaining.append("request_id = ? ");
listOfArguments.add(configResourceInput.getRequestId());
}
-
+
if (configResourceInput.getTemplateName() != null) {
if (whereClauseRemaining.length() != 0) {
whereClauseRemaining.append("AND ");
@@ -200,7 +203,7 @@ public class ConfigResourceDaoImpl implements ConfigResourceDao {
whereClauseRemaining.append("template_name = ? ");
listOfArguments.add(configResourceInput.getTemplateName());
}
-
+
if (configResourceInput.getRecipeName() != null) {
if (whereClauseRemaining.length() != 0) {
whereClauseRemaining.append("AND ");
@@ -208,14 +211,14 @@ public class ConfigResourceDaoImpl implements ConfigResourceDao {
whereClauseRemaining.append("recipe_name = ? ");
listOfArguments.add(configResourceInput.getRecipeName());
}
-
+
String queryString = selectArtifactBuffer.toString() + whereClauseRemaining.toString();
logger.info("config resource queryString ({})", queryString);
List<ConfigResource> configResources =
this.jdbcTemplate.query(queryString, listOfArguments.toArray(), new ConfigResourceMapper());
-
+
List<ConfigResource> returnConfigResources = new ArrayList<>();
-
+
if (configResources != null) {
for (ConfigResource configResource : configResources) {
if (configResource != null) {
@@ -225,11 +228,11 @@ public class ConfigResourceDaoImpl implements ConfigResourceDao {
}
return returnConfigResources;
}
-
+
public ConfigResource checkConfigResource(ConfigResource configResource) {
StringBuilder selectBuffer = new StringBuilder();
List<Object> listOfArguments = new ArrayList<>();
-
+
selectBuffer.append(
"SELECT * FROM CONFIG_RESOURCE WHERE resource_id = ? AND resource_type = ? AND template_name = ? ");
listOfArguments.add(configResource.getResourceId());
@@ -237,7 +240,7 @@ public class ConfigResourceDaoImpl implements ConfigResourceDao {
listOfArguments.add(configResource.getTemplateName());
return queryOneForObject(selectBuffer.toString(), listOfArguments.toArray(), new ConfigResourceMapper());
}
-
+
@Override
public ConfigResource getConfigResource(ConfigResource configResource) throws SvcLogicException {
ConfigResource dbConfigResource = checkConfigResource(configResource);
@@ -248,7 +251,7 @@ public class ConfigResourceDaoImpl implements ConfigResourceDao {
}
return configResource;
}
-
+
private List<ResourceAssignmentData> getResourceAssignmentdata(String configResourceId) {
List<Object> listOfArguments = new ArrayList<>();
String queryString = "SELECT * FROM CONFIG_RESOURCE_ASSIGNMENT_DATA WHERE config_resource_id = ? ";
@@ -256,32 +259,32 @@ public class ConfigResourceDaoImpl implements ConfigResourceDao {
listOfArguments.add(configResourceId);
return this.jdbcTemplate.query(queryString, listOfArguments.toArray(), new ResourceAssignmentDataMapper());
}
-
+
@SuppressWarnings("squid:S3776")
private boolean validateConfigResource(ConfigResource configResource) throws SvcLogicException {
if (configResource == null) {
throw new SvcLogicException("config resource information is missing.");
}
-
+
if (StringUtils.isBlank(configResource.getConfigResourceId())) {
throw new SvcLogicException("config resource id is missing.");
}
-
+
if (StringUtils.isBlank(configResource.getResourceType())) {
throw new SvcLogicException("config resource type is missing.");
}
if (StringUtils.isBlank(configResource.getResourceId())) {
throw new SvcLogicException("config resource resource id is missing.");
}
-
+
if (StringUtils.isBlank(configResource.getRecipeName())) {
throw new SvcLogicException("config resource action name is missing.");
}
-
+
if (StringUtils.isBlank(configResource.getTemplateName())) {
throw new SvcLogicException("config resource template name is missing.");
}
-
+
if (configResource.getResourceAssignments() != null) {
List<ResourceAssignmentData> resourceAssignments = configResource.getResourceAssignments();
for (ResourceAssignmentData resourceAssignmentData : resourceAssignments) {
@@ -306,15 +309,15 @@ public class ConfigResourceDaoImpl implements ConfigResourceDao {
if (resourceAssignmentData.getResourceValue() == null) {
resourceAssignmentData.setResourceValue("");
}
-
+
validateResourceAssignmentData(resourceAssignmentData);
}
}
}
-
+
return true;
}
-
+
private boolean validateResourceAssignmentData(ResourceAssignmentData resourceAssignmentData)
throws SvcLogicException {
if (resourceAssignmentData == null) {
@@ -357,7 +360,7 @@ public class ConfigResourceDaoImpl implements ConfigResourceDao {
}
return true;
}
-
+
private <T> T queryOneForObject(String sql, Object[] args, RowMapper<T> rowMapper) {
List<T> results = this.jdbcTemplate.query(sql, args, new RowMapperResultSetExtractor<T>(rowMapper, 1));
if (results != null && !results.isEmpty()) {
@@ -366,7 +369,7 @@ public class ConfigResourceDaoImpl implements ConfigResourceDao {
return null;
}
}
-
+
class ConfigResourceMapper implements RowMapper<ConfigResource> {
@Override
public ConfigResource mapRow(ResultSet rs, int rowNum) throws SQLException {
@@ -387,7 +390,7 @@ public class ConfigResourceDaoImpl implements ConfigResourceDao {
return configResource;
}
}
-
+
class ResourceAssignmentDataMapper implements RowMapper<ResourceAssignmentData> {
@Override
public ResourceAssignmentData mapRow(ResultSet rs, int rowNum) throws SQLException {
@@ -408,5 +411,5 @@ public class ConfigResourceDaoImpl implements ConfigResourceDao {
return resourceAssignmentData;
}
}
-
+
}
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/NamedQueryExecutorDao.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/NamedQueryExecutorDao.java
index d8d509022..4cebb3081 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/NamedQueryExecutorDao.java
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/NamedQueryExecutorDao.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.data.adaptor.dao;
@@ -24,7 +27,7 @@ public interface NamedQueryExecutorDao {
* Return NamedParameterJdbcTemplate object.
*/
public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() throws SvcLogicException;
-
+
/**
* Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the
* query, expecting a result list.
@@ -39,7 +42,7 @@ public interface NamedQueryExecutorDao {
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails
*/
public List<Map<String, Object>> query(String sql, Map<String, Object> parameters) throws SvcLogicException;
-
+
/**
* Issue an update via a prepared statement, binding the given arguments.
*
@@ -50,5 +53,5 @@ public interface NamedQueryExecutorDao {
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the update
*/
public int update(String sql, Map<String, Object> parameters) throws SvcLogicException;
-
+
}
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/NamedQueryExecutorDaoImpl.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/NamedQueryExecutorDaoImpl.java
index bbb12cf82..bcfe6b649 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/NamedQueryExecutorDaoImpl.java
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/NamedQueryExecutorDaoImpl.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.data.adaptor.dao;
@@ -25,26 +28,26 @@ import com.att.eelf.configuration.EELFManager;
public class NamedQueryExecutorDaoImpl implements NamedQueryExecutorDao {
private static EELFLogger logger = EELFManager.getInstance().getLogger(QueryExecutorDaoImpl.class);
private static final String CLASS_NAME = "NamedQueryExecutorDaoImpl";
-
+
@Autowired(required = true)
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
-
+
public NamedQueryExecutorDaoImpl(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
logger.info("{} Constructor initialised..", CLASS_NAME);
}
-
+
@Override
public List<Map<String, Object>> query(String sql, Map<String, Object> parameters) throws SvcLogicException {
logger.debug("Query ({}) with parameters ({})", sql, parameters);
return namedParameterJdbcTemplate.queryForList(sql, parameters);
}
-
+
@Override
public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() {
return namedParameterJdbcTemplate;
}
-
+
@Override
public int update(String sql, Map<String, Object> parameters) throws SvcLogicException {
logger.debug("update ({}) with parameters ({})", sql, parameters);
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/QueryExecutorDao.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/QueryExecutorDao.java
index f66cd4a4d..0c39524cf 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/QueryExecutorDao.java
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/QueryExecutorDao.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.data.adaptor.dao;
@@ -19,7 +22,7 @@ import java.util.Map;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
public interface QueryExecutorDao {
-
+
/**
* Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the
* query, expecting a result list.
@@ -35,7 +38,7 @@ public interface QueryExecutorDao {
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails
*/
public List<Map<String, Object>> query(String sql, Object[] data) throws SvcLogicException;
-
+
/**
* Issue a single SQL update operation (such as an insert, update or delete statement) via a
* prepared statement, binding the given arguments.
@@ -47,5 +50,5 @@ public interface QueryExecutorDao {
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the update
*/
public int update(String sql, Object[] data) throws SvcLogicException;
-
+
}
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/QueryExecutorDaoImpl.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/QueryExecutorDaoImpl.java
index bc3901a79..076ec1d0f 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/QueryExecutorDaoImpl.java
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/QueryExecutorDaoImpl.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.data.adaptor.dao;
@@ -23,28 +26,28 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
public class QueryExecutorDaoImpl implements QueryExecutorDao {
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(QueryExecutorDaoImpl.class);
private static final String CLASS_NAME = "QueryExecutorDaoImpl";
-
+
@Autowired(required = true)
private JdbcTemplate jdbcTemplate;
-
+
public QueryExecutorDaoImpl(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
logger.info("{} Constructor initialised..", CLASS_NAME);
}
-
+
@Override
public List<Map<String, Object>> query(String sql, Object[] data) throws SvcLogicException {
logger.debug("Query ({}) with data ({})", sql, data);
return jdbcTemplate.queryForList(sql, data);
}
-
+
@Override
public int update(String sql, Object[] data) throws SvcLogicException {
logger.debug("Query ({}) with data ({})", sql, data);
return jdbcTemplate.update(sql, data);
}
-
+
}
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/TransactionLogDao.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/TransactionLogDao.java
index f87dbb745..c4747e236 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/TransactionLogDao.java
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/TransactionLogDao.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.data.adaptor.dao;
@@ -19,7 +22,7 @@ import org.onap.ccsdk.config.data.adaptor.domain.TransactionLog;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
public interface TransactionLogDao {
-
+
/**
* Issue a single SQL Insert operation for CONFIG_TRANSACTION_LOG table via a prepared statement,
* binding the given arguments.
@@ -29,7 +32,7 @@ public interface TransactionLogDao {
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the insert
*/
public void save(TransactionLog transactionLog) throws SvcLogicException;
-
+
/**
* Query CONFIG_TRANSACTION_LOG table for given request_id, mapping each row to a Java object via a
* TransactionLog RowMapper.
@@ -40,7 +43,7 @@ public interface TransactionLogDao {
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails
*/
public List<TransactionLog> getTransactionsByRequestId(String requestId) throws SvcLogicException;
-
+
/**
* Query CONFIG_TRANSACTION_LOG table for given request_id, mapping each row to a Java object via a
* TransactionLog RowMapper.
@@ -54,5 +57,5 @@ public interface TransactionLogDao {
*/
public List<TransactionLog> getTransactionsByRequestId(String requestId, String messageType)
throws SvcLogicException;
-
+
}
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/TransactionLogDaoImpl.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/TransactionLogDaoImpl.java
index 88d9c846a..fd3d810e7 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/TransactionLogDaoImpl.java
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/dao/TransactionLogDaoImpl.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.data.adaptor.dao;
@@ -26,15 +29,15 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
public class TransactionLogDaoImpl implements TransactionLogDao {
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(TransactionLogDaoImpl.class);
-
+
private JdbcTemplate jdbcTemplate;
-
+
public TransactionLogDaoImpl(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
-
+
@Override
public void save(TransactionLog transactionLog) throws SvcLogicException {
if (transactionLog != null && StringUtils.isNotBlank(transactionLog.getRequestId())) {
@@ -44,9 +47,9 @@ public class TransactionLogDaoImpl implements TransactionLogDao {
transactionLog.getMessageType(), transactionLog.getMessage());
logger.trace("TransactionLog Updated Successfully for message_type {}", transactionLog.getMessageType());
}
-
+
}
-
+
@Override
public List<TransactionLog> getTransactionsByRequestId(String requestId) throws SvcLogicException {
if (StringUtils.isNotBlank(requestId)) {
@@ -57,7 +60,7 @@ public class TransactionLogDaoImpl implements TransactionLogDao {
throw new SvcLogicException("TransactionLog Request id (" + requestId + ")is missing ");
}
}
-
+
@Override
public List<TransactionLog> getTransactionsByRequestId(String requestId, String messageType)
throws SvcLogicException {
@@ -70,7 +73,7 @@ public class TransactionLogDaoImpl implements TransactionLogDao {
throw new SvcLogicException("TransactionLog Request id (" + requestId + ")is missing ");
}
}
-
+
private static final class TransactionLogMapper implements RowMapper<TransactionLog> {
@Override
public TransactionLog mapRow(ResultSet rs, int rowNum) throws SQLException {
@@ -83,5 +86,5 @@ public class TransactionLogDaoImpl implements TransactionLogDao {
return transactionLog;
}
}
-
+
}
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/db/DataSourceWrap.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/db/DataSourceWrap.java
index 888bdcb42..18ca9453c 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/db/DataSourceWrap.java
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/db/DataSourceWrap.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.data.adaptor.db;
@@ -23,51 +26,51 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
public class DataSourceWrap implements DataSource {
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(DataSourceWrap.class);
-
+
private DataSource dataSource;
-
+
public DataSourceWrap(DataSource dataSource) {
logger.info("Setting Data Source {} ", dataSource);
this.dataSource = dataSource;
}
-
+
@Override
public PrintWriter getLogWriter() throws SQLException {
return dataSource.getLogWriter();
}
-
+
@Override
public void setLogWriter(PrintWriter out) throws SQLException {
dataSource.setLogWriter(out);
}
-
+
@Override
public void setLoginTimeout(int seconds) throws SQLException {
dataSource.setLoginTimeout(seconds);
}
-
+
@Override
public int getLoginTimeout() throws SQLException {
return dataSource.getLoginTimeout();
}
-
+
@Override
public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException {
return dataSource.getParentLogger();
}
-
+
@Override
public <T> T unwrap(Class<T> iface) throws SQLException {
return dataSource.unwrap(iface);
}
-
+
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
return dataSource.isWrapperFor(iface);
}
-
+
@SuppressWarnings("squid:S2095")
@Override
public Connection getConnection() throws SQLException {
@@ -76,7 +79,7 @@ public class DataSourceWrap implements DataSource {
c.setAutoCommit(true);
return c;
}
-
+
@SuppressWarnings("squid:S2095")
@Override
public Connection getConnection(String username, String pass) throws SQLException {
@@ -84,5 +87,5 @@ public class DataSourceWrap implements DataSource {
c.setAutoCommit(true);
return c;
}
-
+
}
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/ConfigPropertyMapData.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/ConfigPropertyMapData.java
index 6cc796ec7..7d6bff98b 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/ConfigPropertyMapData.java
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/ConfigPropertyMapData.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.data.adaptor.domain;
@@ -18,29 +21,29 @@ import java.io.Serializable;
public class ConfigPropertyMapData implements Serializable {
private static final long serialVersionUID = 1L;
-
+
private String referenceKey;
private String referenceValue;
-
+
public String getReferenceKey() {
return referenceKey;
}
-
+
public void setReferenceKey(String referenceKey) {
this.referenceKey = referenceKey;
}
-
+
public String getReferenceValue() {
return referenceValue;
}
-
+
public void setReferenceValue(String referenceValue) {
this.referenceValue = referenceValue;
}
-
+
@Override
public String toString() {
return "ConfigPropertyMapData [referenceKey=" + referenceKey + ", referenceValue=" + referenceValue + "]";
}
-
+
}
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/ConfigResource.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/ConfigResource.java
index 2e46198fb..c8394a74d 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/ConfigResource.java
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/ConfigResource.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.data.adaptor.domain;
@@ -24,7 +27,7 @@ public class ConfigResource implements Serializable {
*
*/
private static final long serialVersionUID = 1L;
-
+
private String configResourceId;
private String resourceId;
private String resourceType;
@@ -39,119 +42,119 @@ public class ConfigResource implements Serializable {
private String status;
private String updatedBy;
private List<ResourceAssignmentData> resourceAssignments;
-
+
public String getConfigResourceId() {
return configResourceId;
}
-
+
public void setConfigResourceId(String configResourceId) {
this.configResourceId = configResourceId;
}
-
+
public String getResourceId() {
return resourceId;
}
-
+
public void setResourceId(String resourceId) {
this.resourceId = resourceId;
}
-
+
public String getResourceType() {
return resourceType;
}
-
+
public void setResourceType(String resourceType) {
this.resourceType = resourceType;
}
-
+
public String getServiceTemplateName() {
return serviceTemplateName;
}
-
+
public void setServiceTemplateName(String serviceTemplateName) {
this.serviceTemplateName = serviceTemplateName;
}
-
+
public String getServiceTemplateVersion() {
return serviceTemplateVersion;
}
-
+
public void setServiceTemplateVersion(String serviceTemplateVersion) {
this.serviceTemplateVersion = serviceTemplateVersion;
}
-
+
public String getTemplateName() {
return templateName;
}
-
+
public void setTemplateName(String templateName) {
this.templateName = templateName;
}
-
+
public String getRecipeName() {
return recipeName;
}
-
+
public void setRecipeName(String recipeName) {
this.recipeName = recipeName;
}
-
+
public String getRequestId() {
return requestId;
}
-
+
public void setRequestId(String requestId) {
this.requestId = requestId;
}
-
+
public String getResourceData() {
return resourceData;
}
-
+
public void setResourceData(String resourceData) {
this.resourceData = resourceData;
}
-
+
public String getMaskData() {
return maskData;
}
-
+
public void setMaskData(String maskData) {
this.maskData = maskData;
}
-
+
public Date getCreatedDate() {
return createdDate;
}
-
+
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
-
+
public String getStatus() {
return status;
}
-
+
public void setStatus(String status) {
this.status = status;
}
-
+
public String getUpdatedBy() {
return updatedBy;
}
-
+
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
-
+
public List<ResourceAssignmentData> getResourceAssignments() {
return resourceAssignments;
}
-
+
public void setResourceAssignments(List<ResourceAssignmentData> resourceAssignments) {
this.resourceAssignments = resourceAssignments;
}
-
+
@Override
public String toString() {
return "ConfigResource [configResourceId=" + configResourceId + ", resourceId=" + resourceId
@@ -160,9 +163,9 @@ public class ConfigResource implements Serializable {
+ ", requestId=" + requestId + ", resourceData= ******** , maskData=" + maskData + ", createdDate="
+ createdDate + ", updatedBy=" + updatedBy + "]";
}
-
+
public String getUniqueId() {
return UUID.randomUUID().toString();
}
-
+
}
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/ResourceAssignmentData.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/ResourceAssignmentData.java
index c213326c6..75c1a4957 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/ResourceAssignmentData.java
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/ResourceAssignmentData.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.data.adaptor.domain;
@@ -19,7 +22,7 @@ import java.util.Date;
import java.util.UUID;
public class ResourceAssignmentData implements Serializable {
-
+
private static final long serialVersionUID = 1L;
private String id;
private String configResourceId;
@@ -34,11 +37,11 @@ public class ResourceAssignmentData implements Serializable {
private String source;
private String status;
private String message;
-
+
public String getUniqueId() {
return UUID.randomUUID().toString();
}
-
+
@Override
public String toString() {
return "ResourceAssignmentData [id=" + id + ", configResourceId=" + configResourceId + ", version=" + version
@@ -46,109 +49,109 @@ public class ResourceAssignmentData implements Serializable {
+ ", resourceName=" + resourceName + ", dataType=" + dataType + ", source=" + source + ", status="
+ status + "]";
}
-
+
public String getId() {
return id;
}
-
+
public void setId(String id) {
this.id = id;
}
-
+
public String getConfigResourceId() {
return configResourceId;
}
-
+
public void setConfigResourceId(String configResourceId) {
this.configResourceId = configResourceId;
}
-
+
public Integer getVersion() {
return version;
}
-
+
public void setVersion(Integer version) {
this.version = version;
}
-
+
public Date getUpdatedDate() {
return updatedDate;
}
-
+
public void setUpdatedDate(Date updatedDate) {
this.updatedDate = updatedDate;
}
-
+
public String getUpdatedBy() {
return updatedBy;
}
-
+
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
-
+
public String getTemplateKeyName() {
return templateKeyName;
}
-
+
public void setTemplateKeyName(String templateKeyName) {
this.templateKeyName = templateKeyName;
}
-
+
public String getResourceName() {
return resourceName;
}
-
+
public void setResourceName(String resourceName) {
this.resourceName = resourceName;
}
-
+
public String getDataType() {
return dataType;
}
-
+
public void setDataType(String dataType) {
this.dataType = dataType;
}
-
+
public String getEntrySchema() {
return entrySchema;
}
-
+
public void setEntrySchema(String entrySchema) {
this.entrySchema = entrySchema;
}
-
+
public String getResourceValue() {
return resourceValue;
}
-
+
public void setResourceValue(String resourceValue) {
this.resourceValue = resourceValue;
}
-
+
public String getSource() {
return source;
}
-
+
public void setSource(String source) {
this.source = source;
}
-
+
public String getStatus() {
return status;
}
-
+
public void setStatus(String status) {
this.status = status;
}
-
+
public String getMessage() {
return message;
}
-
+
public void setMessage(String message) {
this.message = message;
}
-
+
}
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/TransactionLog.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/TransactionLog.java
index 3ae6ad3da..77235d137 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/TransactionLog.java
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/domain/TransactionLog.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.data.adaptor.domain;
@@ -20,23 +23,23 @@ import java.util.UUID;
public class TransactionLog implements Serializable {
private static final long serialVersionUID = 1L;
-
+
private String transactionLogId;
private String requestId;
private String messageType;
private Date creationDate;
private String message;
-
+
public TransactionLog() {
-
+
}
-
+
public TransactionLog(String requestId, String messageType, String message) {
this.requestId = requestId;
this.messageType = messageType;
this.message = message;
}
-
+
@Override
public String toString() {
StringBuilder buffer = new StringBuilder("[");
@@ -47,49 +50,49 @@ public class TransactionLog implements Serializable {
buffer.append("]");
return buffer.toString();
}
-
+
public String getTransactionLogId() {
return transactionLogId;
}
-
+
public void setTransactionLogId(String transactionLogId) {
this.transactionLogId = transactionLogId;
}
-
+
public String getRequestId() {
return requestId;
}
-
+
public void setRequestId(String requestId) {
this.requestId = requestId;
}
-
+
public String getMessageType() {
return messageType;
}
-
+
public void setMessageType(String messageType) {
this.messageType = messageType;
}
-
+
public Date getCreationDate() {
return creationDate;
}
-
+
public void setCreationDate(Date creationDate) {
this.creationDate = creationDate;
}
-
+
public String getMessage() {
return message;
}
-
+
public void setMessage(String message) {
this.message = message;
}
-
+
public String getUniqueId() {
return UUID.randomUUID().toString();
}
-
+
}
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceNode.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceNode.java
index e8f581799..f85da143b 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceNode.java
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceNode.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.data.adaptor.service;
@@ -23,30 +26,30 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
public class ConfigResourceNode implements SvcLogicJavaPlugin {
-
+
private ConfigResourceService configResourceService;
-
+
public ConfigResourceNode(ConfigResourceService configResourceService) {
this.configResourceService = configResourceService;
}
-
+
public void saveConfigTransactionLog(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
String responsePrefix = inParams.get(DataAdaptorConstants.INPUT_PARAM_RESPONSE_PRIFIX);
try {
responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";
-
+
String messageType = inParams.get(DataAdaptorConstants.INPUT_PARAM_MESSAGE_TYPE);
String message = inParams.get(DataAdaptorConstants.INPUT_PARAM_MESSAGE);
String requestId = ctx.getAttribute("request-id");
-
+
TransactionLog transactionLog = new TransactionLog();
-
+
transactionLog.setMessage(message);
transactionLog.setMessageType(messageType);
transactionLog.setRequestId(requestId);
-
+
configResourceService.save(transactionLog);
-
+
} catch (Exception e) {
ctx.setAttribute(responsePrefix + DataAdaptorConstants.OUTPUT_PARAM_STATUS,
DataAdaptorConstants.OUTPUT_STATUS_FAILURE);
@@ -54,5 +57,5 @@ public class ConfigResourceNode implements SvcLogicJavaPlugin {
throw new SvcLogicException("Failed in saveConfigTransactionLog :" + e.getMessage());
}
}
-
+
}
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceService.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceService.java
index f2b3fa787..b99b74f87 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceService.java
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceService.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.data.adaptor.service;
@@ -22,12 +25,12 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
public interface ConfigResourceService {
-
+
/**
* Return NamedParameterJdbcTemplate object.
*/
public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() throws SvcLogicException;
-
+
/**
* Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the
* query, expecting a result list.
@@ -42,7 +45,7 @@ public interface ConfigResourceService {
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails
*/
public List<Map<String, Object>> query(String sql, Map<String, Object> param) throws SvcLogicException;
-
+
/**
* Issue an update via a prepared statement, binding the given arguments.
*
@@ -53,7 +56,7 @@ public interface ConfigResourceService {
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the update
*/
public int update(String sql, Map<String, Object> param) throws SvcLogicException;
-
+
/**
* Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the
* query, expecting a result list.
@@ -68,7 +71,7 @@ public interface ConfigResourceService {
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails
*/
public List<Map<String, Object>> query(String sql, Object[] data) throws SvcLogicException;
-
+
/**
* Issue a single SQL update operation (such as an insert, update or delete statement) via a
* prepared statement, binding the given arguments.
@@ -80,7 +83,7 @@ public interface ConfigResourceService {
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the update
*/
public int update(String sql, Object[] data) throws SvcLogicException;
-
+
/**
* Issue a single SQL Insert operation for CONFIG_TRANSACTION_LOG table via a prepared statement,
* binding the given arguments.
@@ -90,7 +93,7 @@ public interface ConfigResourceService {
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the insert
*/
public void save(TransactionLog transactionLog) throws SvcLogicException;
-
+
/**
* Query CONFIG_TRANSACTION_LOG table for given request_id, mapping each row to a Java object via a
* TransactionLog RowMapper.
@@ -101,7 +104,7 @@ public interface ConfigResourceService {
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails
*/
public List<TransactionLog> getTransactionsByRequestId(String requestId) throws SvcLogicException;
-
+
/**
* Query CONFIG_RESOURCE table for given input param to create a prepared statement to bind to the
* query, mapping each row to a Java object via a ConfigResource RowMapper.
@@ -112,7 +115,7 @@ public interface ConfigResourceService {
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails
*/
public List<ConfigResource> getConfigResource(ConfigResource configResource) throws SvcLogicException;
-
+
/**
* Issue a single SQL update operation (insert or update statement) for CONFIG_RESOURCE table via a
* prepared statement, binding the given arguments.
@@ -122,7 +125,7 @@ public interface ConfigResourceService {
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the insert
*/
public ConfigResource saveConfigResource(ConfigResource configResource) throws SvcLogicException;
-
+
/**
* Query ConcurrentHashMap having CONFIG_PROPERTY_MAP table data for given key.
*
@@ -131,7 +134,7 @@ public interface ConfigResourceService {
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if fails
*/
public String getConfigPropertyByKey(String key) throws SvcLogicException;
-
+
/**
* Query CONFIG_TRANSACTION_LOG table for given request_id, mapping each row to a Java object via a
* TransactionLog RowMapper.
@@ -145,5 +148,5 @@ public interface ConfigResourceService {
*/
public List<TransactionLog> getTransactionsByRequestId(String requestId, String messageType)
throws SvcLogicException;
-
+
}
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceServiceImpl.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceServiceImpl.java
index 77fbbe1ab..c8803092a 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceServiceImpl.java
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceServiceImpl.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.data.adaptor.service;
@@ -31,18 +34,18 @@ import com.att.eelf.configuration.EELFManager;
public class ConfigResourceServiceImpl implements ConfigResourceService {
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigResourceServiceImpl.class);
private static final String CLASS_NAME = "ConfigResourceServiceImpl";
-
+
private TransactionLogDao transactionLogDao;
private ConfigResourceDao configResourceDao;
private QueryExecutorDao queryExecutorDao;
private NamedQueryExecutorDao namedQueryExecutorDao;
private ConfigPropertyMapDao configPropertyMapDao;
-
+
@SuppressWarnings("squid:S00107")
public ConfigResourceServiceImpl(TransactionLogDao transactionLogDao, ConfigResourceDao configResourceDao,
QueryExecutorDao queryExecutorDao, NamedQueryExecutorDao namedQueryExecutorDao,
ConfigPropertyMapDao configPropertyMapDao) {
-
+
logger.info("{} Constuctor Initated...", CLASS_NAME);
this.transactionLogDao = transactionLogDao;
this.configResourceDao = configResourceDao;
@@ -50,61 +53,61 @@ public class ConfigResourceServiceImpl implements ConfigResourceService {
this.namedQueryExecutorDao = namedQueryExecutorDao;
this.configPropertyMapDao = configPropertyMapDao;
}
-
+
@Override
public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() throws SvcLogicException {
return namedQueryExecutorDao.getNamedParameterJdbcTemplate();
}
-
+
@Override
public List<Map<String, Object>> query(String sql, Map<String, Object> parameters) throws SvcLogicException {
return namedQueryExecutorDao.query(sql, parameters);
}
-
+
@Override
public int update(String sql, Map<String, Object> parameters) throws SvcLogicException {
return namedQueryExecutorDao.update(sql, parameters);
}
-
+
@Override
public List<Map<String, Object>> query(String sql, Object[] data) throws SvcLogicException {
return queryExecutorDao.query(sql, data);
}
-
+
@Override
public int update(String sql, Object[] data) throws SvcLogicException {
return queryExecutorDao.update(sql, data);
}
-
+
@Override
public void save(TransactionLog transactionLog) throws SvcLogicException {
transactionLogDao.save(transactionLog);
}
-
+
@Override
public List<TransactionLog> getTransactionsByRequestId(String requestId) throws SvcLogicException {
return transactionLogDao.getTransactionsByRequestId(requestId);
}
-
+
@Override
public List<TransactionLog> getTransactionsByRequestId(String requestId, String messageType)
throws SvcLogicException {
return transactionLogDao.getTransactionsByRequestId(requestId, messageType);
}
-
+
@Override
public List<ConfigResource> getConfigResource(ConfigResource configResource) throws SvcLogicException {
return configResourceDao.findByConfigResource(configResource);
}
-
+
@Override
public ConfigResource saveConfigResource(ConfigResource configResource) throws SvcLogicException {
return configResourceDao.save(configResource);
}
-
+
@Override
public String getConfigPropertyByKey(String key) throws SvcLogicException {
return configPropertyMapDao.getConfigPropertyByKey(key);
}
-
+
}
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/blueprints-processor/adaptors/data-adaptor-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
index 445f623d8..4cf4d78cc 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright © 2017-2018 AT&T Intellectual Property.
+ Modifications Copyright © 2018 IBM.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigPropertyMapDaoTest.java b/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigPropertyMapDaoTest.java
index 487bcd932..28736386c 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigPropertyMapDaoTest.java
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigPropertyMapDaoTest.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.data.adaptor.dao;
@@ -27,22 +30,22 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@ContextConfiguration(locations = {"classpath:test-context-h2db.xml"})
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ConfigPropertyMapDaoTest {
-
+
@Autowired
private ConfigPropertyMapDao configPropertyMapDao;
-
+
@Autowired
private QueryExecutorDao queryExecutorDao;
-
+
@Test
public void testConfigResourcesData() throws Exception {
String sql = "INSERT INTO CONFIG_PROPERTY_MAP (reference_key, reference_value) VALUES ( ?, ?)";
Object[] data = new Object[] {"dummy123", "username123"};
int result = queryExecutorDao.update(sql, data);
Assert.assertNotNull("Failed to get Query Result", result);
-
+
String propKeyValye = configPropertyMapDao.getConfigPropertyByKey("org.onap.ccsdk.config.rest.adaptors.test");
Assert.assertNull("propKeyValue is null", propKeyValye);
}
-
+
}
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigResourceDaoTest.java b/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigResourceDaoTest.java
index ae493e692..0e57d3b5f 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigResourceDaoTest.java
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigResourceDaoTest.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.data.adaptor.dao;
@@ -37,24 +40,24 @@ import com.att.eelf.configuration.EELFManager;
@ContextConfiguration(locations = {"classpath:test-context-h2db.xml"})
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ConfigResourceDaoTest {
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigResourceDaoTest.class);
-
+
@Autowired
private ConfigResourceDao configResourceDao;
-
+
@Before
public void initialise() {
-
+
}
-
+
@Test
public void testAssignmentResourceData() throws Exception {
ConfigResource configResource = new ConfigResource();
String resourceData = IOUtils.toString(
ConfigResourceDaoTest.class.getClassLoader().getResourceAsStream("reference/resource_data.json"),
Charset.defaultCharset());
-
+
logger.trace("resourceData = " + resourceData);
configResource.setResourceData(resourceData);
configResource.setServiceTemplateName("sample-name");
@@ -68,7 +71,7 @@ public class ConfigResourceDaoTest {
configResource.setStatus("success");
configResource.setCreatedDate(new Date(System.currentTimeMillis()));
configResource.setUpdatedBy("an188a");
-
+
List<ResourceAssignmentData> resourceAssignments = new ArrayList<>();
ResourceAssignmentData resourceAssignmentData = new ResourceAssignmentData();
resourceAssignmentData.setDataType("string");
@@ -80,7 +83,7 @@ public class ConfigResourceDaoTest {
resourceAssignmentData.setSource("input");
resourceAssignments.add(resourceAssignmentData);
configResource.setResourceAssignments(resourceAssignments);
-
+
ConfigResource dbConfigResource = configResourceDao.save(configResource);
logger.info("Saved sucessfully : " + dbConfigResource.toString());
Assert.assertNotNull("ConfigResource is null", dbConfigResource);
@@ -88,7 +91,7 @@ public class ConfigResourceDaoTest {
Assert.assertEquals("Resource Assignment Data count missmatch", true,
dbConfigResource.getResourceAssignments().size() > 0);
}
-
+
@Test
public void testConfigResourcesData() throws Exception {
ConfigResource configResourceInput = new ConfigResource();
@@ -96,7 +99,7 @@ public class ConfigResourceDaoTest {
List<ConfigResource> dbConfigResources = configResourceDao.findByConfigResource(configResourceInput);
Assert.assertNotNull("ConfigResources is null", dbConfigResources);
Assert.assertEquals("ConfigResources size missmatch", true, dbConfigResources.size() > 0);
-
+
for (ConfigResource configResource : dbConfigResources) {
Assert.assertNotNull("ConfigResources Assignments is null", configResource.getResourceAssignments());
Assert.assertTrue("ConfigResources Assignments size miss mathch ",
@@ -104,18 +107,18 @@ public class ConfigResourceDaoTest {
logger.trace("ResourceAssignments = " + configResource.getResourceAssignments());
}
}
-
+
@Test
public void testDeleteByConfigResource() throws Exception {
ConfigResource configResourceInput = new ConfigResource();
configResourceInput.setResourceId("123456");
-
+
List<ConfigResource> dbConfigResources = configResourceDao.findByConfigResource(configResourceInput);
Assert.assertTrue("ConfigResources is null", !dbConfigResources.isEmpty());
-
+
configResourceInput.setConfigResourceId(dbConfigResources.get(0).getConfigResourceId());
configResourceDao.deleteByConfigResource(configResourceInput);
-
+
dbConfigResources = configResourceDao.findByConfigResource(configResourceInput);
Assert.assertTrue("ConfigResources is not null", dbConfigResources.isEmpty());
}
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigTransactionLogDaoTest.java b/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigTransactionLogDaoTest.java
index 1fceccebf..ba150d510 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigTransactionLogDaoTest.java
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/dao/ConfigTransactionLogDaoTest.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.data.adaptor.dao;
@@ -36,41 +39,41 @@ import com.att.eelf.configuration.EELFManager;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ConfigTransactionLogDaoTest {
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigTransactionLogDaoTest.class);
-
+
@Autowired
private TransactionLogDao transactionLogDao;
-
+
@Autowired
private NamedQueryExecutorDao namedQueryExecutorDao;
-
+
@Before
public void initialise() {
-
+
}
-
+
@Test
public void testQueryExecution() throws Exception {
String requestId = "12345";
-
+
transactionLogDao
.save(new TransactionLog(requestId, DataAdaptorConstants.LOG_MESSAGE_TYPE_LOG, "Received Request"));
-
+
List<TransactionLog> result = transactionLogDao.getTransactionsByRequestId(requestId);
logger.info("DB ArtifactReference :" + result);
Assert.assertNotNull("Failed to get Query Result", result);
-
+
List<TransactionLog> result2 =
transactionLogDao.getTransactionsByRequestId(requestId, DataAdaptorConstants.LOG_MESSAGE_TYPE_LOG);
logger.info("DB ArtifactReference :" + result2);
Assert.assertNotNull("Failed to get Query Result", result2);
-
+
String namedsql = "SELECT * FROM CONFIG_TRANSACTION_LOG WHERE request_id = :request_id";
Map<String, Object> parameters = new HashMap<>();
parameters.put("request_id", "12345");
List<Map<String, Object>> namedresult = namedQueryExecutorDao.query(namedsql, parameters);
logger.info("DB ArtifactReference :" + namedresult);
Assert.assertNotNull("Failed to get Query Result", namedresult);
-
+
}
-
+
}
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/dao/QueryExecutorDaoTest.java b/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/dao/QueryExecutorDaoTest.java
index ce3e95224..257bc3183 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/dao/QueryExecutorDaoTest.java
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/dao/QueryExecutorDaoTest.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.data.adaptor.dao;
@@ -32,18 +35,18 @@ import com.att.eelf.configuration.EELFManager;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class QueryExecutorDaoTest {
private static EELFLogger logger = EELFManager.getInstance().getLogger(QueryExecutorDaoTest.class);
-
+
@Autowired
private QueryExecutorDao queryExecutorDao;
-
+
@Before
public void initialise() {
-
+
}
-
+
@Test
public void testInsertQueryExecution() throws Exception {
-
+
String sql = "INSERT INTO CONFIG_RESOURCE"
+ "(config_resource_id, resource_id, resource_type, template_name, recipe_name, request_id, resource_data, mask_data, created_date, updated_by) "
+ "VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
@@ -54,25 +57,25 @@ public class QueryExecutorDaoTest {
logger.info("Updated successfully rows :" + result);
Assert.assertNotNull("Failed to get Query Result", result);
}
-
+
@Test
public void testUpdateQueryExecution() throws Exception {
-
+
String sql = "UPDATE CONFIG_RESOURCE set recipe_name=? where config_resource_id=?";
Object[] data = new Object[] {"vce-service-template", "12345"};
int result = queryExecutorDao.update(sql, data);
logger.info("Updated successfully rows :" + result);
Assert.assertNotNull("Failed to get Query Result", result);
}
-
+
@Test
public void testDeleteQueryExecution() throws Exception {
-
+
String sql = "DELETE FROM CONFIG_RESOURCE where config_resource_id=?";
Object[] data = new Object[] {"12345"};
int result = queryExecutorDao.update(sql, data);
logger.info("Updated successfully rows :" + result);
Assert.assertNotNull("Failed to get Query Result", result);
}
-
+
}
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceNodeTest.java b/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceNodeTest.java
index 847d5ed42..b2f24bf60 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceNodeTest.java
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceNodeTest.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.data.adaptor.service;
@@ -35,33 +38,33 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:test-context-h2db.xml"})
public class ConfigResourceNodeTest {
-
+
ConfigResourceNode configResourceNode;
-
+
ConfigResourceService configResourceService;
-
+
@Autowired
TransactionLogDao transactionLogDao;
-
+
@Autowired
ConfigResourceDao configResourceDao;
-
+
@Autowired
QueryExecutorDao queryExecutorDao;
-
+
@Autowired
NamedQueryExecutorDao namedQueryExecutorDao;
-
+
@Autowired
ConfigPropertyMapDao configPropertyMapDao;
-
+
@Before
public void before() {
configResourceService = new ConfigResourceServiceImpl(transactionLogDao, configResourceDao, queryExecutorDao,
namedQueryExecutorDao, configPropertyMapDao);
configResourceNode = new ConfigResourceNode(configResourceService);
}
-
+
@Test
public void testSaveConfigTransactionLog() throws Exception {
Map<String, String> inParams = new HashMap<>();
@@ -69,12 +72,12 @@ public class ConfigResourceNodeTest {
inParams.put(DataAdaptorConstants.INPUT_PARAM_MESSAGE, "message");
SvcLogicContext ctx = new SvcLogicContext();
ctx.setAttribute("request-id", "requestId12345");
-
+
configResourceNode.saveConfigTransactionLog(inParams, ctx);
-
+
Assert.assertTrue(!transactionLogDao.getTransactionsByRequestId("requestId12345").isEmpty());
}
-
+
@Test(expected = SvcLogicException.class)
public void testSaveConfigTransactionLogException() throws Exception {
configResourceNode = new ConfigResourceNode(null);
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceServiceTest.java b/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceServiceTest.java
index 1240ca237..6f861a3be 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceServiceTest.java
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/config/data/adaptor/service/ConfigResourceServiceTest.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.data.adaptor.service;
@@ -42,30 +45,30 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:test-context-h2db.xml"})
public class ConfigResourceServiceTest {
-
+
ConfigResourceService configResourceService;
-
+
@Autowired
TransactionLogDao transactionLogDao;
-
+
@Autowired
ConfigResourceDao configResourceDao;
-
+
@Autowired
QueryExecutorDao queryExecutorDao;
-
+
@Autowired
NamedQueryExecutorDao namedQueryExecutorDao;
-
+
@Autowired
ConfigPropertyMapDao configPropertyMapDao;
-
+
@Before
public void before() {
configResourceService = new ConfigResourceServiceImpl(transactionLogDao, configResourceDao, queryExecutorDao,
namedQueryExecutorDao, configPropertyMapDao);
}
-
+
@Test
public void testUpdate() throws Exception {
String sql = "INSERT INTO CONFIG_RESOURCE"
@@ -76,20 +79,20 @@ public class ConfigResourceServiceTest {
"resource-data", "mask-data", null, new Date(System.currentTimeMillis()), "ab1234"};
int result = configResourceService.update(sql, data);
Assert.assertTrue(result == 1);
-
+
sql = "SELECT * FROM CONFIG_RESOURCE WHERE config_resource_id = ?";
data = new Object[] {"54321"};
List<Map<String, Object>> queryResult = configResourceService.query(sql, data);
Assert.assertTrue(queryResult.size() == 1);
}
-
+
@Test
public void testSaveAndGetConfigResource() throws Exception {
ConfigResource configResource = new ConfigResource();
String resourceData = IOUtils.toString(
ConfigResourceDaoTest.class.getClassLoader().getResourceAsStream("reference/resource_data.json"),
Charset.defaultCharset());
-
+
configResource.setResourceData(resourceData);
configResource.setServiceTemplateName("sample-name");
configResource.setServiceTemplateVersion("1.0.0");
@@ -102,7 +105,7 @@ public class ConfigResourceServiceTest {
configResource.setStatus("success");
configResource.setCreatedDate(new Date(System.currentTimeMillis()));
configResource.setUpdatedBy("an188a");
-
+
List<ResourceAssignmentData> resourceAssignments = new ArrayList<>();
ResourceAssignmentData resourceAssignmentData = new ResourceAssignmentData();
resourceAssignmentData.setDataType("string");
@@ -114,7 +117,7 @@ public class ConfigResourceServiceTest {
resourceAssignmentData.setSource("input");
resourceAssignments.add(resourceAssignmentData);
configResource.setResourceAssignments(resourceAssignments);
-
+
// save
ConfigResource dbConfigResource = configResourceService.saveConfigResource(configResource);
Assert.assertNotNull("ConfigResource is null", dbConfigResource);
@@ -122,7 +125,7 @@ public class ConfigResourceServiceTest {
Assert.assertEquals("Resource Assignment Data count missmatch", true,
dbConfigResource.getResourceAssignments().size() > 0);
Assert.assertEquals(configResource.getServiceTemplateVersion(), dbConfigResource.getServiceTemplateVersion());
-
+
// update
configResource.setServiceTemplateVersion("1.0.1");
dbConfigResource = configResourceService.saveConfigResource(configResource);
@@ -131,7 +134,7 @@ public class ConfigResourceServiceTest {
Assert.assertEquals("Resource Assignment Data count missmatch", true,
dbConfigResource.getResourceAssignments().size() > 0);
Assert.assertEquals(configResource.getServiceTemplateVersion(), dbConfigResource.getServiceTemplateVersion());
-
+
// find
ConfigResource configResourceInput = new ConfigResource();
configResourceInput.setResourceId(configResource.getResourceId());
@@ -144,23 +147,23 @@ public class ConfigResourceServiceTest {
List<ConfigResource> dbConfigResources = configResourceService.getConfigResource(configResourceInput);
Assert.assertNotNull("ConfigResources is null", dbConfigResources);
Assert.assertEquals("ConfigResources size missmatch", true, dbConfigResources.size() > 0);
-
+
for (ConfigResource dbConfigResouce : dbConfigResources) {
Assert.assertNotNull("ConfigResources Assignments is null", dbConfigResouce.getResourceAssignments());
Assert.assertTrue("ConfigResources Assignments size miss mathch ",
dbConfigResouce.getResourceAssignments().size() > 0);
}
}
-
+
@Test
public void testSaveAndGetTransactionLog() throws Exception {
TransactionLog transactionLog = new TransactionLog();
transactionLog.setMessage("message");
transactionLog.setMessageType("messageType");
transactionLog.setRequestId("requestId");
-
+
configResourceService.save(transactionLog);
-
+
List<TransactionLog> transactions =
configResourceService.getTransactionsByRequestId(transactionLog.getRequestId());
Assert.assertTrue(transactions.size() == 1);
@@ -168,7 +171,7 @@ public class ConfigResourceServiceTest {
transactionLog.getMessageType());
Assert.assertTrue(transactions.size() == 1);
}
-
+
@Test
public void testNamedQueryExecutorUpdateNQuery() throws Exception {
Map<String, Object> parameters = new HashMap<>();
@@ -179,10 +182,10 @@ public class ConfigResourceServiceTest {
configResourceService.update(
"INSERT INTO CONFIG_TRANSACTION_LOG ( config_transaction_log_id, request_id, message_type, message ) VALUES (:config_transaction_log_id, :request_id, :message_type, :message) ",
parameters);
-
+
List<Map<String, Object>> result = configResourceService
.query("SELECT * FROM CONFIG_TRANSACTION_LOG WHERE request_id = :request_id", parameters);
-
+
Assert.assertTrue(!result.isEmpty());
Assert.assertNotNull(configResourceService.getNamedParameterJdbcTemplate());
}
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/log4j.properties b/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/log4j.properties
index ce75592ff..1f83d159a 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/log4j.properties
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/log4j.properties
@@ -1,5 +1,21 @@
-log4j.rootLogger=INFO, A1
-log4j.appender.A1=org.apache.log4j.ConsoleAppender
-log4j.appender.A1.layout=org.apache.log4j.PatternLayout
-log4j.appender.A1.layout.ConversionPattern=%d{ISO8601} %5p %t %X{UUID} %c{3}:%L - %m%n
-log4j.logger.org.hibernate=INFO
+###
+# Copyright © 2017-2018 AT&T Intellectual Property.
+# Modifications Copyright © 2018 IBM.
+#
+# 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.
+###
+log4j.rootLogger=INFO, A1
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%d{ISO8601} %5p %t %X{UUID} %c{3}:%L - %m%n
+log4j.logger.org.hibernate=INFO
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/test-context-h2db.xml b/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/test-context-h2db.xml
index 5b0004c1c..f0a50f440 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/test-context-h2db.xml
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/test-context-h2db.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright © 2017-2018 AT&T Intellectual Property.
+ Modifications Copyright © 2018 IBM.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/test-context.xml b/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/test-context.xml
index 0e73b40b3..17189f2f2 100644
--- a/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/test-context.xml
+++ b/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/test-context.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright © 2017-2018 AT&T Intellectual Property.
+ Modifications Copyright © 2018 IBM.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/ConfigRestAdaptorConstants.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/ConfigRestAdaptorConstants.java
index 4b0941652..af6b9f2b8 100644
--- a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/ConfigRestAdaptorConstants.java
+++ b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/ConfigRestAdaptorConstants.java
@@ -1,24 +1,27 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.rest.adaptor;
public class ConfigRestAdaptorConstants {
private ConfigRestAdaptorConstants() {
-
+
}
-
+
public static final String SDNC_ROOT_DIR_ENV_VAR_KEY = "SDNC_CONFIG_DIR";
public static final String REST_ADAPTOR_PROPERTIES_FILE_NAME = "config-rest-adaptor.properties";
public static final String PROXY_URL_KEY = "proxyUrl";
@@ -26,22 +29,22 @@ public class ConfigRestAdaptorConstants {
public static final String AAF_USERNAME_KEY = "aafUserName";
public static final String AAF_PSSWD_KEY = "aafPassword";
public static final String COMMON_SERVICE_VERSION_KEY = "commonServiceVersion";
-
+
public static final String PROPERTY_ENV_PROD = "field";
public static final String PROPERTY_ENV_SOLO = "solo";
-
+
public static final String REST_ADAPTOR_BASE_PROPERTY = "org.onap.ccsdk.config.rest.adaptors.";
public static final String REST_ADAPTOR_ENV_TYPE = "envtype";
public static final String REST_ADAPTOR_TYPE_GENERIC = "generic";
public static final String REST_ADAPTOR_TYPE_SSL = "ssl";
-
+
public static final String SSL_SERVICE_BASEURL = ".url";
public static final String SSL_SERVICE_APP = ".application";
public static final String SSL_SERVICE_TRUST = ".ssl.trust";
public static final String SSL_SERVICE_TRUST_PSSWD = ".ssl.trust.psswd";
public static final String SSL_SERVICE_KEY = ".ssl.key";
public static final String SSL_SERVICE_KEY_PSSWD = ".ssl.key.psswd";
-
+
public static final String SERVICE_TYPE_PROPERTY = ".type";
public static final String SERVICE_EANABLED_PROPERTY = ".enable";
public static final String SERVICE_ENV_PROPERTY = ".env";
@@ -52,7 +55,7 @@ public class ConfigRestAdaptorConstants {
public static final String SERVICE_PSSWD_PROPERTY = ".passwd";
public static final String SERVICE_CLIENTAUTH_PROPERTY = ".clientAuth";
public static final String SERVICE_AUTHORIZATION_PROPERTY = ".authorization";
-
+
public static final String SELECTOR_AAI = "aai";
public static final String SELECTOR_ALTS = "alts";
public static final String SELECTOR_EIPAM = "eipam";
@@ -62,5 +65,5 @@ public class ConfigRestAdaptorConstants {
public static final String SELECTOR_POLICY_MANAGER = "policymanager";
public static final String SELECTOR_NRD = "networkresourcediscovery";
public static final String SELECTOR_NSM = "nsm";
-
+
}
diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/ConfigRestAdaptorException.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/ConfigRestAdaptorException.java
index 3bb04a207..c6593f128 100644
--- a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/ConfigRestAdaptorException.java
+++ b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/ConfigRestAdaptorException.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.rest.adaptor;
@@ -20,12 +23,12 @@ package org.onap.ccsdk.config.rest.adaptor;
* @version 1.0
*/
public class ConfigRestAdaptorException extends Exception {
-
+
/**
*
*/
private static final long serialVersionUID = 1L;
-
+
/**
* This is a ConfigRestAdaptorException constructor
*
@@ -34,7 +37,7 @@ public class ConfigRestAdaptorException extends Exception {
public ConfigRestAdaptorException(String message) {
super(message);
}
-
+
/**
* This is a ConfigRestAdaptorException constructor
*
@@ -43,5 +46,5 @@ public class ConfigRestAdaptorException extends Exception {
public ConfigRestAdaptorException(String message, Throwable cause) {
super(message, cause);
}
-
+
}
diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/data/RestResponse.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/data/RestResponse.java
index ed39ea925..d31aa7e8a 100644
--- a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/data/RestResponse.java
+++ b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/data/RestResponse.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.rest.adaptor.data;
@@ -17,57 +20,57 @@ package org.onap.ccsdk.config.rest.adaptor.data;
import java.util.Map;
public class RestResponse {
-
+
private String statusCode;
private String body;
private Map<String, String> parameters;
private Map<String, String> responseHeaders;
private Map<String, String> requestHeaders;
-
+
public String getStatusCode() {
return statusCode;
}
-
+
public void setStatusCode(String statusCode) {
this.statusCode = statusCode;
}
-
+
public String getBody() {
return body;
}
-
+
public void setBody(String body) {
this.body = body;
}
-
+
public Map<String, String> getParameters() {
return parameters;
}
-
+
public void setParameters(Map<String, String> parameters) {
this.parameters = parameters;
}
-
+
public Map<String, String> getResponseHeaders() {
return responseHeaders;
}
-
+
public void setResponseHeaders(Map<String, String> responseHeaders) {
this.responseHeaders = responseHeaders;
}
-
+
public Map<String, String> getRequestHeaders() {
return requestHeaders;
}
-
+
public void setRequestHeaders(Map<String, String> requestHeaders) {
this.requestHeaders = requestHeaders;
}
-
+
@Override
public String toString() {
return "RestResponse [statusCode=" + statusCode + ", body=" + body + ", parameters=" + parameters
+ ", responseHeaders=" + responseHeaders + ", requestHeaders=" + requestHeaders + "]";
}
-
+
}
diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/AbstractConfigRestClientAdapter.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/AbstractConfigRestClientAdapter.java
index 7ccb6274d..97302620e 100644
--- a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/AbstractConfigRestClientAdapter.java
+++ b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/AbstractConfigRestClientAdapter.java
@@ -53,24 +53,24 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
abstract class AbstractConfigRestClientAdapter implements ConfigRestClientServiceAdapter {
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(AbstractConfigRestClientAdapter.class);
private static final String MS_INIT_FAIL = "Failed to initialise microservice client restTemplate.";
-
+
protected boolean isRestClientServiceAdapaterEnabled = false;
protected boolean isSSLServiceAdapaterEnabled = true;
-
+
protected Map<String, String> properties = new ConcurrentHashMap<>();
protected String serviceSelector;
-
+
protected RestTemplate restTemplate;
-
+
protected AbstractConfigRestClientAdapter(Map<String, String> properties, String serviceSelector) {
this.properties = properties;
this.serviceSelector = serviceSelector;
setRestClientServiceAdapaterEnabled();
}
-
+
private void setRestClientServiceAdapaterEnabled() {
String isEnabledProperty = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector
+ ConfigRestAdaptorConstants.SERVICE_EANABLED_PROPERTY;
@@ -82,7 +82,7 @@ abstract class AbstractConfigRestClientAdapter implements ConfigRestClientServic
isRestClientServiceAdapaterEnabled = true;
}
}
-
+
private List<HttpMessageConverter<?>> getMessageConverters() {
List<HttpMessageConverter<?>> converters = new ArrayList<>();
converters.add(new ByteArrayHttpMessageConverter());
@@ -92,85 +92,85 @@ abstract class AbstractConfigRestClientAdapter implements ConfigRestClientServic
converters.add(new MappingJackson2HttpMessageConverter());
return converters;
}
-
+
public void initialise(String user, String pass) {
logger.trace("Config rest template factory user ({}) ", user);
-
+
CloseableHttpClient httpClient =
HttpClients.custom().setSSLHostnameVerifier(new NoopHostnameVerifier()).build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setHttpClient(httpClient);
-
+
restTemplate = new RestTemplate(getMessageConverters());
restTemplate.setRequestFactory(requestFactory);
if (StringUtils.isNotBlank(user) && StringUtils.isNotBlank(pass)) {
restTemplate.getInterceptors().add(new BasicAuthorizationInterceptor(user, pass));
}
}
-
+
public void initialiseSSL(String keyStorePath, String trustStorePath, String keyPass, String trustPass)
throws ConfigRestAdaptorException {
logger.trace("SSL rest template factory");
-
+
TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true;
SSLContext sslContext = null;
-
+
try (InputStream keyInput = new FileInputStream(keyStorePath)) {
KeyStore keyStore = KeyStore.getInstance("PKCS12");
keyStore.load(keyInput, keyPass.toCharArray());
-
+
logger.info("key loaded successfully");
sslContext = SSLContextBuilder.create().loadKeyMaterial(keyStore, keyPass.toCharArray()).loadTrustMaterial(
ResourceUtils.getFile(trustStorePath), trustPass.toCharArray(), acceptingTrustStrategy).build();
} catch (Exception e) {
throw new ConfigRestAdaptorException(e.getMessage());
}
-
+
SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext);
CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(csf).build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
-
+
restTemplate = new RestTemplate(getMessageConverters());
restTemplate.setRequestFactory(requestFactory);
}
-
+
public <T> T getResource(HttpHeaders headers, String url, Class<T> responseType) throws ConfigRestAdaptorException {
ResponseEntity<T> response = exchangeForEntity(headers, url, HttpMethod.GET, null, responseType);
return processResponse(response, url, HttpMethod.GET);
}
-
+
public <T> T postResource(HttpHeaders headers, String url, Object request, Class<T> responseType)
throws ConfigRestAdaptorException {
ResponseEntity<T> response = exchangeForEntity(headers, url, HttpMethod.POST, request, responseType);
return processResponse(response, url, HttpMethod.POST);
}
-
+
public <T> T exchangeResource(HttpHeaders headers, String url, Object request, Class<T> responseType, String method)
throws ConfigRestAdaptorException {
ResponseEntity<T> response = exchangeForEntity(headers, url, HttpMethod.resolve(method), request, responseType);
return processResponse(response, url, HttpMethod.resolve(method));
}
-
+
public RestResponse getResource(HttpHeaders headers, String url) throws ConfigRestAdaptorException {
return exchangeForEntity(headers, url, HttpMethod.GET, null);
}
-
+
public RestResponse postResource(HttpHeaders headers, String url, Object request)
throws ConfigRestAdaptorException {
return exchangeForEntity(headers, url, HttpMethod.POST, request);
}
-
+
public RestResponse exchangeResource(HttpHeaders headers, String url, Object request, String method)
throws ConfigRestAdaptorException {
return exchangeForEntity(headers, url, HttpMethod.resolve(method), request);
}
-
+
private RestResponse exchangeForEntity(HttpHeaders headers, String url, HttpMethod httpMethod, Object request)
throws ConfigRestAdaptorException {
RestResponse restResponse = new RestResponse();
restResponse.setRequestHeaders(headers.toSingleValueMap());
ResponseEntity<String> response = null;
-
+
try {
if (restTemplate == null) {
logger.error(MS_INIT_FAIL);
@@ -179,7 +179,7 @@ abstract class AbstractConfigRestClientAdapter implements ConfigRestClientServic
logger.debug("url : ({})", url);
logger.debug("headers: ({})", headers);
logger.debug("request: ({})", request);
-
+
if (HttpMethod.GET == httpMethod) {
HttpEntity<String> entity = new HttpEntity<>("parameters", headers);
response = restTemplate.exchange(url, httpMethod, entity, String.class);
@@ -188,7 +188,7 @@ abstract class AbstractConfigRestClientAdapter implements ConfigRestClientServic
response = restTemplate.exchange(url, httpMethod, entity, String.class);
}
logger.debug("response: ({})", response);
-
+
if (response != null) {
logger.debug("response status code: ({})", response.getStatusCode());
restResponse.setBody(response.getBody());
@@ -210,11 +210,11 @@ abstract class AbstractConfigRestClientAdapter implements ConfigRestClientServic
}
return restResponse;
}
-
+
private <T> ResponseEntity<T> exchangeForEntity(HttpHeaders headers, String url, HttpMethod httpMethod,
Object request, Class<T> responseType) throws ConfigRestAdaptorException {
ResponseEntity<T> response = null;
-
+
try {
if (restTemplate == null) {
logger.error(MS_INIT_FAIL);
@@ -223,7 +223,7 @@ abstract class AbstractConfigRestClientAdapter implements ConfigRestClientServic
logger.debug("url : ({})", url);
logger.debug("headers: ({})", headers);
logger.debug("request: ({})", request);
-
+
if (HttpMethod.GET == httpMethod) {
HttpEntity<String> entity = new HttpEntity<>("parameters", headers);
response = restTemplate.exchange(url, httpMethod, entity, responseType);
@@ -232,7 +232,7 @@ abstract class AbstractConfigRestClientAdapter implements ConfigRestClientServic
response = restTemplate.exchange(url, httpMethod, entity, responseType);
}
logger.debug("response: ({})", response);
-
+
if (response != null) {
logger.debug("response status code: ({})", response.getStatusCode());
} else {
@@ -245,7 +245,7 @@ abstract class AbstractConfigRestClientAdapter implements ConfigRestClientServic
}
return response;
}
-
+
protected synchronized <T> T processResponse(ResponseEntity<T> response, String url, HttpMethod httpMethod)
throws ConfigRestAdaptorException {
if (response != null) {
@@ -262,7 +262,7 @@ abstract class AbstractConfigRestClientAdapter implements ConfigRestClientServic
}
throw new ConfigRestAdaptorException(String.format("Rest Operation is failed for the URL (%s)", url));
}
-
+
protected synchronized String constructUrl(String baseUrl, String path) {
if (StringUtils.isNotBlank(path)) {
return baseUrl + path;
@@ -270,5 +270,5 @@ abstract class AbstractConfigRestClientAdapter implements ConfigRestClientServic
return baseUrl;
}
}
-
+
}
diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/ConfigRestAdaptorService.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/ConfigRestAdaptorService.java
index e15f4ae71..98c598acb 100644
--- a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/ConfigRestAdaptorService.java
+++ b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/ConfigRestAdaptorService.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.rest.adaptor.service;
@@ -18,7 +21,7 @@ import org.onap.ccsdk.config.rest.adaptor.ConfigRestAdaptorException;
import org.onap.ccsdk.config.rest.adaptor.data.RestResponse;
public interface ConfigRestAdaptorService {
-
+
/**
* Retrieve an entity by doing a GET on the specified URL. The response is converted and stored in
* defined responseType.
@@ -28,7 +31,7 @@ public interface ConfigRestAdaptorService {
* @param responseType the type of the return value
*/
public <T> T getResource(String selectorName, String path, Class<T> responseType) throws ConfigRestAdaptorException;
-
+
/**
* Create a new resource by POSTing the given object to the URI template, and returns the response
* as defined responseType
@@ -40,7 +43,7 @@ public interface ConfigRestAdaptorService {
*/
public <T> T postResource(String selectorName, String path, Object request, Class<T> responseType)
throws ConfigRestAdaptorException;
-
+
/**
* Execute the HTTP method to the given URI template, writing the given request entity to the
* request, and returns the response as defined responseType
@@ -53,7 +56,7 @@ public interface ConfigRestAdaptorService {
*/
public <T> T exchangeResource(String selectorName, String path, Object request, Class<T> responseType,
String method) throws ConfigRestAdaptorException;
-
+
/**
* Retrieve an entity by doing a GET on the specified URL. The response is converted and stored in
* defined responseType.
@@ -62,7 +65,7 @@ public interface ConfigRestAdaptorService {
* @param path the URI path which will append in baseURL mentioned in selector property
*/
public RestResponse getResource(String selectorName, String path) throws ConfigRestAdaptorException;
-
+
/**
* Create a new resource by POSTing the given object to the URI template, and returns the response
* as defined responseType
@@ -73,7 +76,7 @@ public interface ConfigRestAdaptorService {
*/
public RestResponse postResource(String selectorName, String path, Object request)
throws ConfigRestAdaptorException;
-
+
/**
* Execute the HTTP method to the given URI template, writing the given request entity to the
* request, and returns the response as defined responseType
@@ -85,5 +88,5 @@ public interface ConfigRestAdaptorService {
*/
public RestResponse exchangeResource(String selectorName, String path, Object request, String method)
throws ConfigRestAdaptorException;
-
+
}
diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/ConfigRestAdaptorServiceImpl.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/ConfigRestAdaptorServiceImpl.java
index b17ed2262..65b9defd3 100644
--- a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/ConfigRestAdaptorServiceImpl.java
+++ b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/ConfigRestAdaptorServiceImpl.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.rest.adaptor.service;
@@ -31,16 +34,16 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
public class ConfigRestAdaptorServiceImpl implements ConfigRestAdaptorService {
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigRestAdaptorServiceImpl.class);
private Map<String, String> restProperties = new ConcurrentHashMap<>();
-
+
public ConfigRestAdaptorServiceImpl(String propertyPath) {
initializeProperties(propertyPath);
try {
String envType = restProperties.get(ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY
+ ConfigRestAdaptorConstants.REST_ADAPTOR_ENV_TYPE);
-
+
if (!(ConfigRestAdaptorConstants.PROPERTY_ENV_PROD.equalsIgnoreCase(envType)
|| ConfigRestAdaptorConstants.PROPERTY_ENV_SOLO.equalsIgnoreCase(envType))) {
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
@@ -53,72 +56,72 @@ public class ConfigRestAdaptorServiceImpl implements ConfigRestAdaptorService {
logger.error(e.getMessage(), e);
}
}
-
+
private void initializeProperties(String propertyPath) {
logger.trace("Initialising Config rest adaptor Service with property directory ({})", propertyPath);
try {
if (StringUtils.isBlank(propertyPath)) {
propertyPath = System.getProperty(ConfigRestAdaptorConstants.SDNC_ROOT_DIR_ENV_VAR_KEY);
}
-
+
if (StringUtils.isBlank(propertyPath)) {
throw new ConfigRestAdaptorException(
String.format("Failed to get the property directory (%s)", propertyPath));
}
-
+
// Loading Default config-rest-adaptor.properties
String propertyFile =
propertyPath + File.separator + ConfigRestAdaptorConstants.REST_ADAPTOR_PROPERTIES_FILE_NAME;
-
+
Properties properties = new Properties();
properties.load(new FileInputStream(propertyFile));
-
+
logger.trace("Initializing properties details for property file ({}) properties ({})", propertyFile,
properties);
restProperties.putAll(properties.entrySet().stream()
.collect(Collectors.toMap(e -> e.getKey().toString(), e -> e.getValue().toString())));
-
+
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
-
+
@Override
public <T> T getResource(String serviceSelector, String path, Class<T> responseType)
throws ConfigRestAdaptorException {
return getRestClientAdapterBySelectorName(serviceSelector).getResource(path, responseType);
}
-
+
@Override
public <T> T postResource(String serviceSelector, String path, Object request, Class<T> responseType)
throws ConfigRestAdaptorException {
return getRestClientAdapterBySelectorName(serviceSelector).postResource(path, request, responseType);
}
-
+
@Override
public <T> T exchangeResource(String serviceSelector, String path, Object request, Class<T> responseType,
String method) throws ConfigRestAdaptorException {
return getRestClientAdapterBySelectorName(serviceSelector).exchangeResource(path, request, responseType,
method);
}
-
+
@Override
public RestResponse getResource(String serviceSelector, String path) throws ConfigRestAdaptorException {
return getRestClientAdapterBySelectorName(serviceSelector).getResource(path);
}
-
+
@Override
public RestResponse postResource(String serviceSelector, String path, Object request)
throws ConfigRestAdaptorException {
return getRestClientAdapterBySelectorName(serviceSelector).postResource(path, request);
}
-
+
@Override
public RestResponse exchangeResource(String serviceSelector, String path, Object request, String method)
throws ConfigRestAdaptorException {
return getRestClientAdapterBySelectorName(serviceSelector).exchangeResource(path, request, method);
}
-
+
private ConfigRestClientServiceAdapter getRestClientAdapterBySelectorName(String serviceSelector)
throws ConfigRestAdaptorException {
String adoptorType = restProperties.get(ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector
@@ -138,5 +141,5 @@ public class ConfigRestAdaptorServiceImpl implements ConfigRestAdaptorService {
String.format("couldn't get rest adoptor type for the selector (%s)", serviceSelector));
}
}
-
+
}
diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/ConfigRestClientServiceAdapter.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/ConfigRestClientServiceAdapter.java
index e1adb3814..46e954fb6 100644
--- a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/ConfigRestClientServiceAdapter.java
+++ b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/ConfigRestClientServiceAdapter.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.rest.adaptor.service;
@@ -18,18 +21,18 @@ import org.onap.ccsdk.config.rest.adaptor.ConfigRestAdaptorException;
import org.onap.ccsdk.config.rest.adaptor.data.RestResponse;
interface ConfigRestClientServiceAdapter {
-
+
public <T> T getResource(String path, Class<T> responseType) throws ConfigRestAdaptorException;
-
+
public <T> T postResource(String path, Object request, Class<T> responseType) throws ConfigRestAdaptorException;
-
+
public <T> T exchangeResource(String path, Object request, Class<T> responseType, String method)
throws ConfigRestAdaptorException;
-
+
public RestResponse getResource(String path) throws ConfigRestAdaptorException;
-
+
public RestResponse postResource(String path, Object request) throws ConfigRestAdaptorException;
-
+
public RestResponse exchangeResource(String path, Object request, String method) throws ConfigRestAdaptorException;
-
+
}
diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/GenericRestClientAdapterImpl.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/GenericRestClientAdapterImpl.java
index 55cdca40b..8cb5e9bea 100644
--- a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/GenericRestClientAdapterImpl.java
+++ b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/GenericRestClientAdapterImpl.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.rest.adaptor.service;
@@ -26,16 +29,16 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
public class GenericRestClientAdapterImpl extends AbstractConfigRestClientAdapter {
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(GenericRestClientAdapterImpl.class);
private String baseUrl = "";
-
+
public GenericRestClientAdapterImpl(Map<String, String> properties, String serviceSelector)
throws ConfigRestAdaptorException {
super(properties, serviceSelector);
init(serviceSelector);
}
-
+
private void init(String serviceSelector) throws ConfigRestAdaptorException {
try {
if (isRestClientServiceAdapaterEnabled) {
@@ -45,11 +48,11 @@ public class GenericRestClientAdapterImpl extends AbstractConfigRestClientAdapte
+ ConfigRestAdaptorConstants.SERVICE_USER_PROPERTY;
String passProperty = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector
+ ConfigRestAdaptorConstants.SERVICE_PSSWD_PROPERTY;
-
+
baseUrl = properties.get(baseUrlProperty);
String userId = properties.get(userProperty);
String pass = properties.get(passProperty);
-
+
initialise(userId, pass);
logger.info("Initialised restconf adaptor service for selector ({})", serviceSelector);
if (restTemplate == null) {
@@ -58,52 +61,52 @@ public class GenericRestClientAdapterImpl extends AbstractConfigRestClientAdapte
} else {
throw new ConfigRestAdaptorException("rest selector (" + serviceSelector + ") is not enabled");
}
-
+
} catch (Exception e) {
throw new ConfigRestAdaptorException("GenericRestClientServiceAdapter : " + e.getMessage(), e);
}
}
-
+
@Override
public <T> T getResource(String path, Class<T> responseType) throws ConfigRestAdaptorException {
return super.getResource(formHttpHeaders(), constructUrl(baseUrl, path), responseType);
}
-
+
@Override
public <T> T postResource(String path, Object request, Class<T> responseType) throws ConfigRestAdaptorException {
return super.postResource(formHttpHeaders(), constructUrl(baseUrl, path), request, responseType);
}
-
+
@Override
public <T> T exchangeResource(String path, Object request, Class<T> responseType, String method)
throws ConfigRestAdaptorException {
return super.exchangeResource(formHttpHeaders(), constructUrl(baseUrl, path), request, responseType, method);
}
-
+
@Override
public RestResponse getResource(String path) throws ConfigRestAdaptorException {
return super.getResource(formHttpHeaders(), constructUrl(baseUrl, path));
}
-
+
@Override
public RestResponse postResource(String path, Object request) throws ConfigRestAdaptorException {
return super.postResource(formHttpHeaders(), constructUrl(baseUrl, path), request);
}
-
+
@Override
public RestResponse exchangeResource(String path, Object request, String method) throws ConfigRestAdaptorException {
return super.exchangeResource(formHttpHeaders(), constructUrl(baseUrl, path), request, method);
}
-
+
private HttpHeaders formHttpHeaders() {
-
+
HttpHeaders headers = new HttpHeaders();
-
+
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("Accept", MediaType.APPLICATION_JSON_VALUE);
headers.add("X-TransactionId", generateUUID());
headers.add("X-ECOMP-RequestID", headers.getFirst("X-TransactionId"));
-
+
String appIDPath = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector
+ ConfigRestAdaptorConstants.SERVICE_APPID_PROPERTY;
String environmentPath = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector
@@ -112,7 +115,7 @@ public class GenericRestClientAdapterImpl extends AbstractConfigRestClientAdapte
+ ConfigRestAdaptorConstants.SERVICE_CLIENTAUTH_PROPERTY;
String authorizationPath = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector
+ ConfigRestAdaptorConstants.SERVICE_AUTHORIZATION_PROPERTY;
-
+
if (StringUtils.isNotBlank(properties.get(appIDPath))) {
headers.add("X-FromAppId", properties.get(appIDPath));
}
@@ -125,12 +128,12 @@ public class GenericRestClientAdapterImpl extends AbstractConfigRestClientAdapte
if (StringUtils.isNotBlank(properties.get(environmentPath))) {
headers.add("Environment", properties.get(environmentPath));
}
-
+
return headers;
}
-
+
private synchronized String generateUUID() {
return UUID.randomUUID().toString();
}
-
+
}
diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/SSLRestClientAdapterImpl.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/SSLRestClientAdapterImpl.java
index 7d31b812e..e444d9f17 100644
--- a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/SSLRestClientAdapterImpl.java
+++ b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/service/SSLRestClientAdapterImpl.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.rest.adaptor.service;
@@ -25,23 +28,23 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
public class SSLRestClientAdapterImpl extends AbstractConfigRestClientAdapter {
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(SSLRestClientAdapterImpl.class);
private String baseUrl = "";
private String application = "";
-
+
public SSLRestClientAdapterImpl(Map<String, String> properties, String serviceSelector)
throws ConfigRestAdaptorException {
super(properties, serviceSelector);
init(serviceSelector);
}
-
+
private void init(String serviceSelector) throws ConfigRestAdaptorException {
try {
if (isSSLServiceAdapaterEnabled) {
-
+
logger.info("Initializing SSL client for selector ({}), properties ({})", serviceSelector, properties);
-
+
String baseUrlProp = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector
+ ConfigRestAdaptorConstants.SSL_SERVICE_BASEURL;
String applicationProp = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector
@@ -54,15 +57,15 @@ public class SSLRestClientAdapterImpl extends AbstractConfigRestClientAdapter {
+ ConfigRestAdaptorConstants.SSL_SERVICE_TRUST;
String trustStorePassProp = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector
+ ConfigRestAdaptorConstants.SSL_SERVICE_TRUST_PSSWD;
-
+
baseUrl = properties.get(baseUrlProp);
application = properties.get(applicationProp);
-
+
String keyStorePath = properties.get(keyStorePathProp);
String trustStorePath = properties.get(trustStorePathProp);
String keyStorePass = properties.get(keyStorePassProp);
String trustStorePass = properties.get(trustStorePassProp);
-
+
initialiseSSL(keyStorePath, trustStorePath, keyStorePass, trustStorePass);
logger.info("Initialised SSL Client Service adaptor service for selector ({})", serviceSelector);
if (restTemplate == null) {
@@ -72,55 +75,55 @@ public class SSLRestClientAdapterImpl extends AbstractConfigRestClientAdapter {
} else {
throw new ConfigRestAdaptorException("SSL Client selector (" + serviceSelector + ") is not enabled");
}
-
+
} catch (Exception e) {
throw new ConfigRestAdaptorException("SSLRestClientAdapterImpl : " + e.getMessage(), e);
}
}
-
+
@Override
public <T> T getResource(String path, Class<T> responseType) throws ConfigRestAdaptorException {
return super.getResource(formHttpHeaders(), constructUrl(baseUrl, path), responseType);
}
-
+
@Override
public <T> T postResource(String path, Object request, Class<T> responseType) throws ConfigRestAdaptorException {
return super.postResource(formHttpHeaders(), constructUrl(baseUrl, path), request, responseType);
}
-
+
@Override
public <T> T exchangeResource(String path, Object request, Class<T> responseType, String method)
throws ConfigRestAdaptorException {
return super.exchangeResource(formHttpHeaders(), constructUrl(baseUrl, path), request, responseType, method);
}
-
+
@Override
public RestResponse getResource(String path) throws ConfigRestAdaptorException {
return super.getResource(formHttpHeaders(), constructUrl(baseUrl, path));
}
-
+
@Override
public RestResponse postResource(String path, Object request) throws ConfigRestAdaptorException {
return super.postResource(formHttpHeaders(), constructUrl(baseUrl, path), request);
}
-
+
@Override
public RestResponse exchangeResource(String path, Object request, String method) throws ConfigRestAdaptorException {
return super.exchangeResource(formHttpHeaders(), constructUrl(baseUrl, path), request, method);
}
-
+
private HttpHeaders formHttpHeaders() {
-
+
HttpHeaders headers = new HttpHeaders();
-
+
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("Accept", MediaType.APPLICATION_JSON_VALUE);
headers.add("X-FromAppId", application);
headers.add("X-TransactionId", generateUUID());
-
+
return headers;
}
-
+
private synchronized String generateUUID() {
return UUID.randomUUID().toString();
}
diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/utils/BasicAuthorizationInterceptor.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/utils/BasicAuthorizationInterceptor.java
index bc486f4de..2318fd6ca 100644
--- a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/utils/BasicAuthorizationInterceptor.java
+++ b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/utils/BasicAuthorizationInterceptor.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.rest.adaptor.utils;
@@ -25,11 +28,11 @@ import org.springframework.util.Base64Utils;
public class BasicAuthorizationInterceptor implements ClientHttpRequestInterceptor {
private static final Charset UTF_8 = Charset.forName("UTF-8");
-
+
private final String username;
-
+
private final String pass;
-
+
/**
* Create a new interceptor which adds a BASIC authorization header for the given username and pass.
*
@@ -41,11 +44,11 @@ public class BasicAuthorizationInterceptor implements ClientHttpRequestIntercept
this.username = username;
this.pass = (pass != null ? pass : "");
}
-
+
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
throws IOException {
-
+
String token = Base64Utils.encodeToString((this.username + ":" + this.pass).getBytes(UTF_8));
request.getHeaders().add("Authorization", "Basic " + token);
return execution.execute(request, body);
diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/utils/LoggingRequestInterceptor.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/utils/LoggingRequestInterceptor.java
index 0fcc4654e..4095d62fe 100644
--- a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/utils/LoggingRequestInterceptor.java
+++ b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/config/rest/adaptor/utils/LoggingRequestInterceptor.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.rest.adaptor.utils;
@@ -25,9 +28,9 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
public class LoggingRequestInterceptor implements ClientHttpRequestInterceptor {
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(LoggingRequestInterceptor.class);
-
+
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
throws IOException {
@@ -36,7 +39,7 @@ public class LoggingRequestInterceptor implements ClientHttpRequestInterceptor {
traceResponse(response);
return response;
}
-
+
@SuppressWarnings({"squid:S2629", "squid:S3457"})
private void traceRequest(HttpRequest request, byte[] body) throws IOException {
logger.info("===========================request begin================================================");
@@ -46,7 +49,7 @@ public class LoggingRequestInterceptor implements ClientHttpRequestInterceptor {
logger.info("Request body: {}", new String(body, "UTF-8"));
logger.debug("==========================request end================================================");
}
-
+
@SuppressWarnings({"squid:S2629", "squid:S3457"})
private void traceResponse(ClientHttpResponse response) throws IOException {
StringBuilder inputStringBuilder = new StringBuilder();
@@ -64,5 +67,5 @@ public class LoggingRequestInterceptor implements ClientHttpRequestInterceptor {
logger.debug("Response body: {}", inputStringBuilder.toString());
logger.debug("=======================response end=================================================");
}
-
+
}
diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
index e6b26944d..0b6a6ae11 100644
--- a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
+++ b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright © 2017-2018 AT&T Intellectual Property.
+ Modifications Copyright © 2018 IBM.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/config/rest/adaptor/service/AbstractConfigRestClientAdapterTest.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/config/rest/adaptor/service/AbstractConfigRestClientAdapterTest.java
index e698567a0..6c7f114eb 100644
--- a/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/config/rest/adaptor/service/AbstractConfigRestClientAdapterTest.java
+++ b/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/config/rest/adaptor/service/AbstractConfigRestClientAdapterTest.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.rest.adaptor.service;
@@ -24,30 +27,30 @@ import org.junit.Before;
import org.junit.Test;
public class AbstractConfigRestClientAdapterTest {
-
+
Map<String, String> properties = new HashMap<>();
-
+
@Before
public void setup() throws Exception {
String propertyfile = "src/test/resources/config-rest-adaptor.properties";
-
+
Properties restProperties = new Properties();
restProperties.load(new FileInputStream(propertyfile));
-
+
properties.putAll(restProperties.entrySet().stream()
.collect(Collectors.toMap(e -> e.getKey().toString(), e -> e.getValue().toString())));
}
-
+
@Test
public void testInitGenericRestClient() throws Exception {
ConfigRestClientServiceAdapter genericRestClient = new GenericRestClientAdapterImpl(properties, "modelservice");
Assert.assertNotNull(genericRestClient);
}
-
+
@Test
public void testInitSSLClient() throws Exception {
ConfigRestClientServiceAdapter sslClient = new SSLRestClientAdapterImpl(properties, "aai");
Assert.assertNotNull(sslClient);
}
-
+
}
diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/config/rest/adaptor/service/GenericRestClientServiceTest.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/config/rest/adaptor/service/GenericRestClientServiceTest.java
index 65a90429d..7e7f52261 100644
--- a/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/config/rest/adaptor/service/GenericRestClientServiceTest.java
+++ b/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/config/rest/adaptor/service/GenericRestClientServiceTest.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.rest.adaptor.service;
@@ -22,7 +25,6 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Matchers;
-import org.mockito.Mockito;
import org.onap.ccsdk.config.rest.adaptor.ConfigRestAdaptorException;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
@@ -37,80 +39,80 @@ import org.springframework.web.client.RestTemplate;
@PowerMockIgnore("javax.net.ssl.*")
@PrepareForTest({AbstractConfigRestClientAdapter.class})
public class GenericRestClientServiceTest {
-
+
ConfigRestAdaptorService configRestAdaptorService;
-
+
RestTemplate mockRestTemplate = mock(RestTemplate.class);
-
+
String path = "path";
-
+
@Before
public void before() throws Exception {
whenNew(RestTemplate.class).withAnyArguments().thenReturn(mockRestTemplate);
-
+
String propertyDir = "src/test/resources";
configRestAdaptorService = new ConfigRestAdaptorServiceImpl(propertyDir);
}
-
+
@Test
public void testGetResource() throws Exception {
String responseBody = "sampleBodyString";
ResponseEntity<Object> response = new ResponseEntity<Object>(responseBody, HttpStatus.OK);
when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.GET), Matchers.any(),
Matchers.any(Class.class))).thenReturn(response);
-
+
String body = configRestAdaptorService.getResource("modelservice", path, String.class);
-
+
Assert.assertEquals(responseBody, body);
}
-
+
@Test
public void testPostResource() throws Exception {
String responseBody = "sampleBodyString";
ResponseEntity<Object> response = new ResponseEntity<Object>(responseBody, HttpStatus.OK);
when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.POST), Matchers.any(),
Matchers.any(Class.class))).thenReturn(response);
-
+
String body = configRestAdaptorService.postResource("modelservice", path, null, String.class);
-
+
Assert.assertEquals(responseBody, body);
}
-
+
@Test
public void testExchange() throws Exception {
String responseBody = "sampleBodyString";
ResponseEntity<Object> response = new ResponseEntity<Object>(responseBody, HttpStatus.OK);
when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.GET), Matchers.any(),
Matchers.any(Class.class))).thenReturn(response);
-
+
String body = configRestAdaptorService.exchangeResource("modelservice", path, null, String.class, "GET");
-
+
Assert.assertEquals(responseBody, body);
}
-
+
@Test(expected = ConfigRestAdaptorException.class)
public void testGetResourceError() throws Exception {
ResponseEntity<Object> response = new ResponseEntity<Object>("", HttpStatus.INTERNAL_SERVER_ERROR);
when(mockRestTemplate.getForEntity(Matchers.endsWith(path), Matchers.any())).thenReturn(response);
-
+
configRestAdaptorService.getResource("modelservice", path, String.class);
}
-
+
@Test(expected = ConfigRestAdaptorException.class)
public void testPostResourceError() throws Exception {
ResponseEntity<Object> response = new ResponseEntity<Object>("", HttpStatus.INTERNAL_SERVER_ERROR);
when(mockRestTemplate.postForEntity(Matchers.endsWith(path), Matchers.anyObject(), Matchers.any()))
.thenReturn(response);
-
+
configRestAdaptorService.postResource("modelservice", path, null, String.class);
}
-
+
@Test(expected = ConfigRestAdaptorException.class)
public void testExchangeError() throws Exception {
ResponseEntity<Object> response = new ResponseEntity<Object>("", HttpStatus.INTERNAL_SERVER_ERROR);
when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.GET), Matchers.any(),
Matchers.any(Class.class))).thenReturn(response);
-
+
configRestAdaptorService.exchangeResource("modelservice", path, null, String.class, "GET");
}
}
diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/config/rest/adaptor/service/SSLClientServiceTest.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/config/rest/adaptor/service/SSLClientServiceTest.java
index 4592de819..a5e757213 100644
--- a/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/config/rest/adaptor/service/SSLClientServiceTest.java
+++ b/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/config/rest/adaptor/service/SSLClientServiceTest.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.rest.adaptor.service;
@@ -22,7 +25,6 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Matchers;
-import org.mockito.Mockito;
import org.onap.ccsdk.config.rest.adaptor.ConfigRestAdaptorException;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
@@ -37,80 +39,80 @@ import org.springframework.web.client.RestTemplate;
@PowerMockIgnore("javax.net.ssl.*")
@PrepareForTest({AbstractConfigRestClientAdapter.class})
public class SSLClientServiceTest {
-
+
ConfigRestAdaptorService configRestAdaptorService;
-
+
RestTemplate mockRestTemplate = mock(RestTemplate.class);
-
+
String path = "path";
-
+
@Before
public void before() throws Exception {
whenNew(RestTemplate.class).withAnyArguments().thenReturn(mockRestTemplate);
-
+
String propertyDir = "src/test/resources";
configRestAdaptorService = new ConfigRestAdaptorServiceImpl(propertyDir);
}
-
+
@Test
public void testGetResource() throws Exception {
String responseBody = "sampleBodyString";
ResponseEntity<Object> response = new ResponseEntity<Object>(responseBody, HttpStatus.OK);
when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.GET), Matchers.any(),
Matchers.any(Class.class))).thenReturn(response);
-
+
String body = configRestAdaptorService.getResource("aai", path, String.class);
-
+
Assert.assertEquals(responseBody, body);
}
-
+
@Test
public void testPostResource() throws Exception {
String responseBody = "sampleBodyString";
ResponseEntity<Object> response = new ResponseEntity<Object>(responseBody, HttpStatus.OK);
when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.POST), Matchers.any(),
Matchers.any(Class.class))).thenReturn(response);
-
+
String body = configRestAdaptorService.postResource("aai", path, null, String.class);
-
+
Assert.assertEquals(responseBody, body);
}
-
+
@Test
public void testExchange() throws Exception {
String responseBody = "sampleBodyString";
ResponseEntity<Object> response = new ResponseEntity<Object>(responseBody, HttpStatus.OK);
when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.GET), Matchers.any(),
Matchers.any(Class.class))).thenReturn(response);
-
+
String body = configRestAdaptorService.exchangeResource("aai", path, null, String.class, "GET");
-
+
Assert.assertEquals(responseBody, body);
}
-
+
@Test(expected = ConfigRestAdaptorException.class)
public void testGetResourceError() throws Exception {
ResponseEntity<Object> response = new ResponseEntity<Object>("", HttpStatus.INTERNAL_SERVER_ERROR);
when(mockRestTemplate.getForEntity(Matchers.endsWith(path), Matchers.any())).thenReturn(response);
-
+
configRestAdaptorService.getResource("aai", path, String.class);
}
-
+
@Test(expected = ConfigRestAdaptorException.class)
public void testPostResourceError() throws Exception {
ResponseEntity<Object> response = new ResponseEntity<Object>("", HttpStatus.INTERNAL_SERVER_ERROR);
when(mockRestTemplate.postForEntity(Matchers.endsWith(path), Matchers.anyObject(), Matchers.any()))
.thenReturn(response);
-
+
configRestAdaptorService.postResource("aai", path, null, String.class);
}
-
+
@Test(expected = ConfigRestAdaptorException.class)
public void testExchangeError() throws Exception {
ResponseEntity<Object> response = new ResponseEntity<Object>("", HttpStatus.INTERNAL_SERVER_ERROR);
when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.GET), Matchers.any(),
Matchers.any(Class.class))).thenReturn(response);
-
+
configRestAdaptorService.exchangeResource("aai", path, null, String.class, "GET");
}
}
diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/config/rest/adaptor/utils/RestTemplateFactoryTest.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/config/rest/adaptor/utils/RestTemplateFactoryTest.java
index a01630d62..e1d0268e1 100644
--- a/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/config/rest/adaptor/utils/RestTemplateFactoryTest.java
+++ b/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/config/rest/adaptor/utils/RestTemplateFactoryTest.java
@@ -1,32 +1,49 @@
-package org.onap.ccsdk.config.rest.adaptor.utils;
-
-import org.onap.ccsdk.config.rest.adaptor.ConfigRestAdaptorConstants;
-import org.onap.ccsdk.config.rest.adaptor.ConfigRestAdaptorException;
-import org.onap.ccsdk.config.rest.adaptor.service.ConfigRestAdaptorServiceImpl;
-
-@SuppressWarnings("squid:S2187")
-public class RestTemplateFactoryTest {
-
- public static void main(String[] args) {
-
- String propertyFile = RestTemplateFactoryTest.class.getClassLoader().getResource(".").getPath();
- System.out.println(" Property : " + propertyFile);
-
- try {
- ConfigRestAdaptorServiceImpl configRestAdaptorServiceImpl = new ConfigRestAdaptorServiceImpl(propertyFile);
- String restconfResponse = genericRestGetMDSALOperation(args, configRestAdaptorServiceImpl);
- System.out.println("RestTemplateFactoryTest.main Completed with response :" + restconfResponse);
- } catch (ConfigRestAdaptorException e) {
- e.printStackTrace();
- }
- }
-
- public static String genericRestGetMDSALOperation(String[] args,
- ConfigRestAdaptorServiceImpl configRestAdaptorServiceImpl) throws ConfigRestAdaptorException {
- String path = "config/Dummy-API:services/service-list/dummy-1234";
- String restconfResponse = configRestAdaptorServiceImpl.getResource(ConfigRestAdaptorConstants.SELECTOR_RESTCONF,
- path, String.class);
- return restconfResponse;
- }
-
-}
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.config.rest.adaptor.utils;
+
+import org.onap.ccsdk.config.rest.adaptor.ConfigRestAdaptorConstants;
+import org.onap.ccsdk.config.rest.adaptor.ConfigRestAdaptorException;
+import org.onap.ccsdk.config.rest.adaptor.service.ConfigRestAdaptorServiceImpl;
+
+@SuppressWarnings("squid:S2187")
+public class RestTemplateFactoryTest {
+
+ public static void main(String[] args) {
+
+ String propertyFile = RestTemplateFactoryTest.class.getClassLoader().getResource(".").getPath();
+ System.out.println(" Property : " + propertyFile);
+
+ try {
+ ConfigRestAdaptorServiceImpl configRestAdaptorServiceImpl = new ConfigRestAdaptorServiceImpl(propertyFile);
+ String restconfResponse = genericRestGetMDSALOperation(args, configRestAdaptorServiceImpl);
+ System.out.println("RestTemplateFactoryTest.main Completed with response :" + restconfResponse);
+ } catch (ConfigRestAdaptorException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static String genericRestGetMDSALOperation(String[] args,
+ ConfigRestAdaptorServiceImpl configRestAdaptorServiceImpl) throws ConfigRestAdaptorException {
+ String path = "config/Dummy-API:services/service-list/dummy-1234";
+ String restconfResponse = configRestAdaptorServiceImpl.getResource(ConfigRestAdaptorConstants.SELECTOR_RESTCONF,
+ path, String.class);
+ return restconfResponse;
+ }
+
+}
diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/test/resources/config-rest-adaptor.properties b/blueprints-processor/adaptors/rest-adaptor-provider/src/test/resources/config-rest-adaptor.properties
index 725e48429..4527e8977 100644
--- a/blueprints-processor/adaptors/rest-adaptor-provider/src/test/resources/config-rest-adaptor.properties
+++ b/blueprints-processor/adaptors/rest-adaptor-provider/src/test/resources/config-rest-adaptor.properties
@@ -1,29 +1,45 @@
-#
-# Configuration file for SDNC Controller Module
-#
-
-org.onap.ccsdk.config.rest.adaptors.envtype=solo
-
-# Config Generator Microservices
-org.onap.ccsdk.config.rest.adaptors.modelservice.type=generic
-org.onap.ccsdk.config.rest.adaptors.modelservice.enable=true
-org.onap.ccsdk.config.rest.adaptors.modelservice.url=http://localhost:8080/configgenerator/service/
-org.onap.ccsdk.config.rest.adaptors.modelservice.user=admin
-org.onap.ccsdk.config.rest.adaptors.modelservice.passwd=admin
-
-# Generic RESTCONF Adaptor
-org.onap.ccsdk.config.rest.adaptors.restconf.type=generic
-org.onap.ccsdk.config.rest.adaptors.restconf.enable=true
-org.onap.ccsdk.config.rest.adaptors.restconf.user=admin
-org.onap.ccsdk.config.rest.adaptors.restconf.passwd=admin
-org.onap.ccsdk.config.rest.adaptors.restconf.url=http://localhost:8181/restconf/
-
-# SSL AAI Adaptor
-org.onap.ccsdk.config.rest.adaptors.aai.propertyfile=aai.properties
-org.onap.ccsdk.config.rest.adaptors.aai.type=ssl
-org.onap.ccsdk.config.rest.adaptors.aai.enable=true
-org.onap.ccsdk.config.rest.adaptors.aai.url=https://localhost:8443/onap-aai/
-org.onap.ccsdk.config.rest.adaptors.aai.ssl.trust=src/test/resources/truststore.client.jks
-org.onap.ccsdk.config.rest.adaptors.aai.ssl.trust.psswd=changeme
-org.onap.ccsdk.config.rest.adaptors.aai.ssl.key=src/test/resources/keystore.client.p12
-org.onap.ccsdk.config.rest.adaptors.aai.ssl.key.psswd=changeme
+###
+# Copyright © 2017-2018 AT&T Intellectual Property.
+# Modifications Copyright © 2018 IBM.
+#
+# 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.
+###
+#
+# Configuration file for SDNC Controller Module
+#
+
+org.onap.ccsdk.config.rest.adaptors.envtype=solo
+
+# Config Generator Microservices
+org.onap.ccsdk.config.rest.adaptors.modelservice.type=generic
+org.onap.ccsdk.config.rest.adaptors.modelservice.enable=true
+org.onap.ccsdk.config.rest.adaptors.modelservice.url=http://localhost:8080/configgenerator/service/
+org.onap.ccsdk.config.rest.adaptors.modelservice.user=admin
+org.onap.ccsdk.config.rest.adaptors.modelservice.passwd=admin
+
+# Generic RESTCONF Adaptor
+org.onap.ccsdk.config.rest.adaptors.restconf.type=generic
+org.onap.ccsdk.config.rest.adaptors.restconf.enable=true
+org.onap.ccsdk.config.rest.adaptors.restconf.user=admin
+org.onap.ccsdk.config.rest.adaptors.restconf.passwd=admin
+org.onap.ccsdk.config.rest.adaptors.restconf.url=http://localhost:8181/restconf/
+
+# SSL AAI Adaptor
+org.onap.ccsdk.config.rest.adaptors.aai.propertyfile=aai.properties
+org.onap.ccsdk.config.rest.adaptors.aai.type=ssl
+org.onap.ccsdk.config.rest.adaptors.aai.enable=true
+org.onap.ccsdk.config.rest.adaptors.aai.url=https://localhost:8443/onap-aai/
+org.onap.ccsdk.config.rest.adaptors.aai.ssl.trust=src/test/resources/truststore.client.jks
+org.onap.ccsdk.config.rest.adaptors.aai.ssl.trust.psswd=changeme
+org.onap.ccsdk.config.rest.adaptors.aai.ssl.key=src/test/resources/keystore.client.p12
+org.onap.ccsdk.config.rest.adaptors.aai.ssl.key.psswd=changeme
diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/ConfigAssignmentConstants.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/ConfigAssignmentConstants.java
index 9ab5ae6a6..10e217b8c 100644
--- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/ConfigAssignmentConstants.java
+++ b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/ConfigAssignmentConstants.java
@@ -1,34 +1,37 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment;
@SuppressWarnings("squid:S1118")
public class ConfigAssignmentConstants {
-
+
public static final String OUTPUT_PARAM_STATUS = "status";
public static final String OUTPUT_PARAM_RESOURCE_ASSIGNMENT_PARAMS = "resource-assignment-params";
public static final String OUTPUT_PARAM_MASHED_DATA = "mashed-data";
public static final String OUTPUT_PARAM_ERROR_MESSAGE = "error-message";
public static final String OUTPUT_STATUS_SUCCESS = "success";
public static final String OUTPUT_STATUS_FAILURE = "failure";
-
+
public static final String INPUT_PARAM_REQUEST_ID = "request-id";
public static final String INPUT_PARAM_RESOURCE_ID = "resource-id";
public static final String INPUT_PARAM_RESOURCE_TYPE = "resource-type";
public static final String INPUT_PARAM_ACTION_NAME = "action-name";
public static final String INPUT_PARAM_TEMPLATE_NAMES = "template-names";
public static final String INPUT_PARAM_INPUT_DATA = "input-data";
-
+
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/data/ResourceAssignmentData.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/data/ResourceAssignmentData.java
index d8a2745ea..816c943f3 100644
--- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/data/ResourceAssignmentData.java
+++ b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/data/ResourceAssignmentData.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.data;
@@ -21,7 +24,7 @@ import org.onap.ccsdk.config.model.data.ResourceAssignment;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
public class ResourceAssignmentData {
-
+
private String requestId;
private boolean reloadModel;
private String resourceType;
@@ -37,123 +40,123 @@ public class ResourceAssignmentData {
private Map<String, String> templatesMashedContents = new HashMap<>();
private Map<String, String> templatesData = new HashMap<>();
private Map<String, Object> context = new HashMap<>();
-
+
public String getRequestId() {
return requestId;
}
-
+
public void setRequestId(String requestId) {
this.requestId = requestId;
}
-
+
public String getResourceType() {
return resourceType;
}
-
+
public void setResourceType(String resourceType) {
this.resourceType = resourceType;
}
-
+
public String getResourceId() {
return resourceId;
}
-
+
public void setResourceId(String resourceId) {
this.resourceId = resourceId;
}
-
+
public String getServiceTemplateName() {
return serviceTemplateName;
}
-
+
public void setServiceTemplateName(String serviceTemplateName) {
this.serviceTemplateName = serviceTemplateName;
}
-
+
public String getServiceTemplateVersion() {
return serviceTemplateVersion;
}
-
+
public void setServiceTemplateVersion(String serviceTemplateVersion) {
this.serviceTemplateVersion = serviceTemplateVersion;
}
-
+
public String getActionName() {
return actionName;
}
-
+
public void setActionName(String actionName) {
this.actionName = actionName;
}
-
+
public String getInputData() {
return inputData;
}
-
+
public void setInputData(String inputData) {
this.inputData = inputData;
}
-
+
public List<String> getTemplateNames() {
return templateNames;
}
-
+
public void setTemplateNames(List<String> templateNames) {
this.templateNames = templateNames;
}
-
+
public Map<String, List<ResourceAssignment>> getTemplatesResourceAssignments() {
return templatesResourceAssignments;
}
-
+
public void setTemplatesResourceAssignments(Map<String, List<ResourceAssignment>> templatesResourceAssignments) {
this.templatesResourceAssignments = templatesResourceAssignments;
}
-
+
public Map<String, String> getTemplatesContents() {
return templatesContents;
}
-
+
public void setTemplatesContents(Map<String, String> templatesContents) {
this.templatesContents = templatesContents;
}
-
+
public Map<String, String> getTemplatesMashedContents() {
return templatesMashedContents;
}
-
+
public void setTemplatesMashedContents(Map<String, String> templatesMashedContents) {
this.templatesMashedContents = templatesMashedContents;
}
-
+
public Map<String, String> getTemplatesData() {
return templatesData;
}
-
+
public void setTemplatesData(Map<String, String> templatesData) {
this.templatesData = templatesData;
}
-
+
public Map<String, Object> getContext() {
return context;
}
-
+
public void setContext(Map<String, Object> context) {
this.context = context;
}
-
+
public SvcLogicContext getSvcLogicContext() {
return svcLogicContext;
}
-
+
public void setSvcLogicContext(SvcLogicContext svcLogicContext) {
this.svcLogicContext = svcLogicContext;
}
-
+
public boolean isReloadModel() {
return reloadModel;
}
-
+
public void setReloadModel(boolean reloadModel) {
this.reloadModel = reloadModel;
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/processor/ProcessorFactory.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/processor/ProcessorFactory.java
index d80fec8a9..5fcedd87f 100644
--- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/processor/ProcessorFactory.java
+++ b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/processor/ProcessorFactory.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.processor;
@@ -21,20 +24,20 @@ import org.onap.ccsdk.config.model.service.ComponentNodeService;
import org.onap.ccsdk.config.rest.adaptor.service.ConfigRestAdaptorService;
public class ProcessorFactory {
-
+
private ConfigResourceService configResourceService;
private ConfigRestAdaptorService configRestAdaptorService;
private ComponentNodeService componentNodeService;
-
+
public ProcessorFactory(ConfigResourceService configResourceService,
ConfigRestAdaptorService configRestAdaptorService, ComponentNodeService componentNodeService) {
this.componentNodeService = componentNodeService;
this.configResourceService = configResourceService;
this.configRestAdaptorService = configRestAdaptorService;
}
-
+
public ComponentNode getInstance(String source) {
-
+
if (ConfigModelConstant.SOURCE_DEFAULT.equalsIgnoreCase(source)) {
return new DefaultResourceProcessor(configResourceService);
} else if (ConfigModelConstant.SOURCE_DB.equalsIgnoreCase(source)) {
@@ -45,5 +48,5 @@ public class ProcessorFactory {
// Default
return new InputResourceProcessor(configResourceService);
}
-
+
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/processor/ResourceAssignmentProcessor.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/processor/ResourceAssignmentProcessor.java
index c1c9b93c0..70d9abc68 100644
--- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/processor/ResourceAssignmentProcessor.java
+++ b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/processor/ResourceAssignmentProcessor.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.processor;
@@ -27,16 +30,16 @@ import com.att.eelf.configuration.EELFManager;
public class ResourceAssignmentProcessor {
private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceAssignmentProcessor.class);
-
+
private List<ResourceAssignment> assignments;
private Map<String, ResourceAssignment> resourceAssignmentMap;
-
+
@SuppressWarnings("squid:S1172")
public ResourceAssignmentProcessor(List<ResourceAssignment> assignments, SvcLogicContext ctx) {
this.assignments = assignments;
this.resourceAssignmentMap = new HashMap<>();
}
-
+
@SuppressWarnings("squid:S3776")
public List<List<ResourceAssignment>> process() {
List<List<ResourceAssignment>> sequenceBatchResourceAssignment = new ArrayList<>();
@@ -48,7 +51,7 @@ public class ResourceAssignmentProcessor {
resourceAssignmentMap.put(resourceMapping.getName(), resourceMapping);
}
});
-
+
TopologicalSortingUtils<ResourceAssignment> topologySorting = new TopologicalSortingUtils<>();
this.resourceAssignmentMap.forEach((mappingKey, mapping) -> {
if (mapping != null) {
@@ -61,30 +64,30 @@ public class ResourceAssignmentProcessor {
}
}
});
-
+
List<ResourceAssignment> sequencedResourceAssignments = topologySorting.topSort();
logger.info("Sorted Sequenced Assignments ({})", sequencedResourceAssignments);
-
+
List<ResourceAssignment> batchResourceAssignment = null;
List<String> batchAssignmentName = null;
for (int i = 0; i < sequencedResourceAssignments.size(); i++) {
ResourceAssignment resourceAssignment = sequencedResourceAssignments.get(i);
ResourceAssignment previousResourceAssignment = null;
-
+
if (i > 0) {
previousResourceAssignment = sequencedResourceAssignments.get(i - 1);
}
if (resourceAssignment != null) {
-
+
boolean dependencyPresence = false;
if (batchAssignmentName != null && resourceAssignment.getDependencies() != null) {
dependencyPresence =
CollectionUtils.containsAny(batchAssignmentName, resourceAssignment.getDependencies());
}
-
+
logger.trace("({}) -> Checking ({}), with ({}), result ({})", resourceAssignment.getName(),
batchAssignmentName, resourceAssignment.getDependencies(), dependencyPresence);
-
+
if (previousResourceAssignment != null && resourceAssignment.getDictionarySource() != null
&& resourceAssignment.getDictionarySource()
.equalsIgnoreCase(previousResourceAssignment.getDictionarySource())
@@ -98,12 +101,12 @@ public class ResourceAssignmentProcessor {
}
batchResourceAssignment = new ArrayList<>();
batchResourceAssignment.add(resourceAssignment);
-
+
batchAssignmentName = new ArrayList<>();
batchAssignmentName.add(resourceAssignment.getName());
}
}
-
+
if (i == (sequencedResourceAssignments.size() - 1)) {
logger.trace("Created old Set ({})", batchAssignmentName);
sequenceBatchResourceAssignment.add(batchResourceAssignment);
@@ -113,5 +116,5 @@ public class ResourceAssignmentProcessor {
}
return sequenceBatchResourceAssignment;
}
-
+
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentPersistService.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentPersistService.java
index e27d57a79..320f4369b 100644
--- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentPersistService.java
+++ b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentPersistService.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.service;
@@ -31,59 +34,59 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
public class ConfigAssignmentPersistService {
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentPersistService.class);
-
+
private ConfigResourceService configResourceService;
-
+
public ConfigAssignmentPersistService(ConfigResourceService configResourceService) {
this.configResourceService = configResourceService;
}
-
+
public void saveResourceMapping(org.onap.ccsdk.config.assignment.data.ResourceAssignmentData resourceAssignmentData,
String templateName, List<ResourceAssignment> resourceAssignments) throws SvcLogicException {
try {
-
+
if (resourceAssignmentData == null) {
throw new SvcLogicException("Resource assignment data is missing");
}
-
+
if (StringUtils.isBlank(resourceAssignmentData.getRequestId())) {
logger.warn("Request Id ({}) is missing, may be getting request for resource update.",
resourceAssignmentData.getRequestId());
}
-
+
if (StringUtils.isBlank(resourceAssignmentData.getResourceId())) {
throw new SvcLogicException("Resource Id is missing");
}
-
+
if (StringUtils.isBlank(resourceAssignmentData.getResourceType())) {
throw new SvcLogicException("Resource type is missing");
}
-
+
if (StringUtils.isBlank(resourceAssignmentData.getActionName())) {
throw new SvcLogicException("Action name is missing");
}
-
+
if (StringUtils.isBlank(templateName)) {
throw new SvcLogicException("template name is missing");
}
-
+
StringBuilder builder = new StringBuilder();
builder.append("Resource Assignment for Template Name :");
builder.append(templateName);
builder.append("\n");
builder.append(TransformationUtils.getJson(resourceAssignments, true));
-
+
configResourceService.save(new TransactionLog(resourceAssignmentData.getRequestId(),
DataAdaptorConstants.LOG_MESSAGE_TYPE_LOG, builder.toString()));
-
+
// Resource Data should be Regenerated based on the new Updates
String resourceData = ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignments);
-
+
List<ResourceAssignmentData> resourceAssignmentDataList =
ConfigAssignmentUtils.convertResoureAssignmentList(resourceAssignments);
-
+
ConfigResource configResource = new ConfigResource();
configResource.setRequestId(resourceAssignmentData.getRequestId());
configResource.setServiceTemplateName(resourceAssignmentData.getServiceTemplateName());
@@ -95,14 +98,14 @@ public class ConfigAssignmentPersistService {
configResource.setTemplateName(templateName);
configResource.setStatus(ConfigModelConstant.STATUS_SUCCESS);
configResource.setUpdatedBy(ConfigModelConstant.USER_SYSTEM);
-
+
if (CollectionUtils.isNotEmpty(resourceAssignmentDataList)) {
configResource.setResourceAssignments(resourceAssignmentDataList);
}
configResource = configResourceService.saveConfigResource(configResource);
logger.info("Resource data saved successfully for the template ({}) with resource id ({})", templateName,
configResource.getResourceId());
-
+
builder = new StringBuilder();
builder.append("Resource Data Template Name :");
builder.append(templateName);
@@ -110,11 +113,11 @@ public class ConfigAssignmentPersistService {
builder.append(resourceData);
configResourceService.save(new TransactionLog(resourceAssignmentData.getRequestId(),
DataAdaptorConstants.LOG_MESSAGE_TYPE_LOG, builder.toString()));
-
+
} catch (Exception e) {
throw new SvcLogicException("ConfigAssignmentPersistService : " + e.getMessage(), e);
}
-
+
}
-
+
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentProcessService.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentProcessService.java
index 81e76897e..85ff82db6 100644
--- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentProcessService.java
+++ b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentProcessService.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.service;
@@ -40,15 +43,15 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
public class ConfigAssignmentProcessService {
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentProcessService.class);
-
+
private ComponentNodeService componentNodeService;
private ConfigResourceService configResourceService;
private ConfigModelService configModelService;
private ConfigRestAdaptorService configRestAdaptorService;
private ConfigGeneratorService configGeneratorService;
-
+
public ConfigAssignmentProcessService(ConfigResourceService configResourceService,
ConfigRestAdaptorService configRestAdaptorService, ConfigModelService configModelService,
ComponentNodeService componentNodeService, ConfigGeneratorService configGeneratorService) {
@@ -58,19 +61,19 @@ public class ConfigAssignmentProcessService {
this.configRestAdaptorService = configRestAdaptorService;
this.configGeneratorService = configGeneratorService;
}
-
+
@SuppressWarnings("squid:S1141")
public void resolveResources(ResourceAssignmentData resourceAssignmentData) throws SvcLogicException {
try {
validateInputParams(resourceAssignmentData);
-
+
String serviceTemplateName = resourceAssignmentData.getServiceTemplateName();
String serviceTemplateVersion = resourceAssignmentData.getServiceTemplateVersion();
String actionName = resourceAssignmentData.getActionName();
String inputData = resourceAssignmentData.getInputData();
SvcLogicContext svcLogicContext = resourceAssignmentData.getSvcLogicContext();
List<String> templateNames = resourceAssignmentData.getTemplateNames();
-
+
if (resourceAssignmentData.isReloadModel()) {
Map<String, String> context = new HashMap<>();
context.put(ConfigModelConstant.PROPERTY_ACTION_NAME, actionName);
@@ -79,21 +82,21 @@ public class ConfigAssignmentProcessService {
context.forEach((key, value) -> svcLogicContext.setAttribute(key, value));
logger.info("List of Resources provided in input: {}", svcLogicContext.toProperties());
}
-
+
Map<String, Object> componentContext = resourceAssignmentData.getContext();
-
+
if (CollectionUtils.isNotEmpty(templateNames)) {
// Get the Resource Assignments for templates and Validate the mappings
ResourceModelService resourceModelService = new ResourceModelService(configModelService);
-
+
// Get the Resource Assignment
Map<String, List<ResourceAssignment>> templatesResourceAssignments =
resourceModelService.getTemplatesResourceAssignments(svcLogicContext, templateNames);
-
+
// Get the Template Contents
Map<String, String> templatesContents =
resourceModelService.getTemplatesContents(svcLogicContext, templateNames);
-
+
// Process each template
for (String templateName : templateNames) {
List<ResourceAssignment> resourceAssignments = templatesResourceAssignments.get(templateName);
@@ -106,67 +109,67 @@ public class ConfigAssignmentProcessService {
new ResourceDictionaryService(configRestAdaptorService);
Map<String, ResourceDefinition> dictionaries =
resourceDictionaryService.getDataDictionaryDefinitions(resourceAssignments);
-
+
processResourceAssignments(resourceAssignmentData, svcLogicContext, componentContext,
templateName, resourceAssignments, dictionaries);
-
+
logger.info("decrypting config data for templateName {}", templateName);
templateData =
ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignments);
} finally {
saveResourceMapping(resourceAssignmentData, templateName, resourceAssignments);
}
-
+
logger.info("generating config preview for templateName {}", templateName);
ConfigPreviewService configPreviewService = new ConfigPreviewService(configResourceService,
configModelService, configGeneratorService);
String mashedData = configPreviewService.generatePreview(templateContent, templateData);
resourceAssignmentData.getTemplatesMashedContents().put(templateName, mashedData);
resourceAssignmentData.getTemplatesData().put(templateName, templateData);
-
+
} else {
// Do nothing for Mapping not found
logger.warn("No resource Assignment mappings to resolve for templateName {}", templateName);
}
}
}
-
+
} catch (Exception e) {
throw new SvcLogicException(e.getMessage(), e);
}
}
-
+
private void processResourceAssignments(ResourceAssignmentData resourceAssignmentData, SvcLogicContext ctx,
Map<String, Object> componentContext, String templateName, List<ResourceAssignment> resourceAssignments,
Map<String, ResourceDefinition> dictionaries) throws SvcLogicException {
-
+
String recipeName = resourceAssignmentData.getActionName();
-
+
ResourceAssignmentProcessor resourceAssignmentProcessor =
new ResourceAssignmentProcessor(resourceAssignments, ctx);
List<List<ResourceAssignment>> sequenceBatchResourceAssignment = resourceAssignmentProcessor.process();
-
+
logger.debug("Resource dictionary Info ({})", dictionaries);
-
+
if (sequenceBatchResourceAssignment != null) {
componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName);
componentContext.put(ConfigModelConstant.PROPERTY_TEMPLATE_NAME, templateName);
componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARIES, dictionaries);
for (List<ResourceAssignment> batchResourceAssignment : sequenceBatchResourceAssignment) {
-
+
processBatchResourceAssignments(resourceAssignmentData, ctx, componentContext, batchResourceAssignment);
-
+
logger.debug("Batch Resource data status ({})", TransformationUtils.getJson(batchResourceAssignment));
}
}
}
-
+
private void processBatchResourceAssignments(ResourceAssignmentData resourceAssignmentData, SvcLogicContext ctx,
Map<String, Object> componentContext, List<ResourceAssignment> batchResourceAssignment)
throws SvcLogicException {
-
+
if (CollectionUtils.isNotEmpty(batchResourceAssignment)) {
-
+
ResourceAssignment batchFirstResourceAssignment = batchResourceAssignment.get(0);
if (batchFirstResourceAssignment != null
&& StringUtils.isNotBlank(batchFirstResourceAssignment.getDictionarySource())) {
@@ -174,12 +177,12 @@ public class ConfigAssignmentProcessService {
// Processing their Source
logger.info("Processing source ({}) with batch ({}) ", source, batchResourceAssignment);
componentContext.put(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS, batchResourceAssignment);
-
+
ProcessorFactory factory =
new ProcessorFactory(configResourceService, configRestAdaptorService, componentNodeService);
-
+
ComponentNode processor = factory.getInstance(source);
-
+
Map<String, String> inParams = new HashMap<>();
inParams.put(ConfigAssignmentConstants.INPUT_PARAM_REQUEST_ID, resourceAssignmentData.getRequestId());
inParams.put(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_ID, resourceAssignmentData.getResourceId());
@@ -192,23 +195,23 @@ public class ConfigAssignmentProcessService {
}
}
}
-
+
private void saveResourceMapping(ResourceAssignmentData resourceAssignmentData, String templateName,
List<ResourceAssignment> resourceAssignments) throws SvcLogicException {
if (resourceAssignmentData != null && StringUtils.isNotBlank(templateName)) {
-
+
ConfigAssignmentPersistService configAssignmentPersistService =
new ConfigAssignmentPersistService(configResourceService);
configAssignmentPersistService.saveResourceMapping(resourceAssignmentData, templateName,
resourceAssignments);
}
}
-
+
private void validateInputParams(ResourceAssignmentData resourceAssignmentData) throws SvcLogicException {
if (resourceAssignmentData == null) {
throw new SvcLogicException("Input parameters missing");
}
-
+
String requestId = resourceAssignmentData.getRequestId();
if (StringUtils.isBlank(requestId)) {
throw new SvcLogicException("Request id parameters missing");
@@ -225,11 +228,11 @@ public class ConfigAssignmentProcessService {
if (StringUtils.isBlank(actionName)) {
throw new SvcLogicException("Action name is parameter is missing");
}
-
+
List<String> templatesNames = resourceAssignmentData.getTemplateNames();
if (CollectionUtils.isEmpty(templatesNames)) {
throw new SvcLogicException("Template names parameter missing");
}
}
-
+
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentService.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentService.java
index e0fcc9175..4866f258b 100644
--- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentService.java
+++ b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentService.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.service;
@@ -20,13 +23,13 @@ import org.onap.ccsdk.config.model.data.ResourceAssignment;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
public interface ConfigAssignmentService {
-
+
public void resolveResources(ResourceAssignmentData resourceAssignmentData) throws SvcLogicException;
-
+
public void saveResourceMapping(ResourceAssignmentData resourceAssignmentData, String templateName,
List<ResourceAssignment> resourceAssignments) throws SvcLogicException;
-
+
public ResourceAssignmentData generateTemplateResourceMash(ResourceAssignmentData resourceAssignmentData)
throws SvcLogicException;
-
+
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentServiceImpl.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentServiceImpl.java
index 48e15b15a..9e2bdcf8d 100644
--- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentServiceImpl.java
+++ b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentServiceImpl.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.service;
@@ -27,17 +30,17 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
public class ConfigAssignmentServiceImpl implements ConfigAssignmentService {
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentServiceImpl.class);
-
+
private ComponentNodeService componentNodeService;
private ConfigResourceService configResourceService;
private ConfigModelService configModelService;
private ConfigRestAdaptorService configRestAdaptorService;
private ConfigGeneratorService configGeneratorService;
-
+
private static final String CLASS_NAME = "ConfigAssignmentServiceImpl";
-
+
public ConfigAssignmentServiceImpl(ConfigResourceService configResourceService,
ConfigRestAdaptorService configRestAdaptorService, ConfigModelService configModelService,
ComponentNodeService componentNodeService, ConfigGeneratorService configGeneratorService) {
@@ -48,7 +51,7 @@ public class ConfigAssignmentServiceImpl implements ConfigAssignmentService {
this.configRestAdaptorService = configRestAdaptorService;
this.configGeneratorService = configGeneratorService;
}
-
+
@Override
public void resolveResources(ResourceAssignmentData resourceAssignmentData) throws SvcLogicException {
ConfigAssignmentProcessService configAssignmentProcessService =
@@ -56,7 +59,7 @@ public class ConfigAssignmentServiceImpl implements ConfigAssignmentService {
componentNodeService, configGeneratorService);
configAssignmentProcessService.resolveResources(resourceAssignmentData);
}
-
+
@Override
public void saveResourceMapping(ResourceAssignmentData resourceAssignmentData, String templateName,
List<ResourceAssignment> resourceAssignments) throws SvcLogicException {
@@ -64,7 +67,7 @@ public class ConfigAssignmentServiceImpl implements ConfigAssignmentService {
new ConfigAssignmentPersistService(configResourceService);
configAssignmentPersistService.saveResourceMapping(resourceAssignmentData, templateName, resourceAssignments);
}
-
+
@Override
public ResourceAssignmentData generateTemplateResourceMash(ResourceAssignmentData resourceAssignmentData)
throws SvcLogicException {
@@ -72,5 +75,5 @@ public class ConfigAssignmentServiceImpl implements ConfigAssignmentService {
new ConfigPreviewService(configResourceService, configModelService, configGeneratorService);
return configPreviewService.generateTemplateResourceMash(resourceAssignmentData);
}
-
+
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentUtils.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentUtils.java
index 1f74b71ad..32adbe249 100644
--- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentUtils.java
+++ b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentUtils.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.service;
@@ -44,13 +47,13 @@ import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
public class ConfigAssignmentUtils {
-
+
private ConfigAssignmentUtils() {
-
+
}
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentUtils.class);
-
+
public static synchronized Object getContextKeyValue(SvcLogicContext context, String key) {
Object value = null;
if (context != null && key != null) {
@@ -65,7 +68,7 @@ public class ConfigAssignmentUtils {
}
return value;
}
-
+
/*
* Populate the Field property type for the Data type
*/
@@ -98,7 +101,7 @@ public class ConfigAssignmentUtils {
}
return type;
}
-
+
/*
* Populate the Field property type for the Data type
*/
@@ -126,7 +129,7 @@ public class ConfigAssignmentUtils {
}
return propertyDefinition;
}
-
+
public static synchronized ResourceDefinition getDictionaryDefinition(Map<String, ResourceDictionary> dictionaries,
String dictionaryName) {
ResourceDefinition resourceDefinition = null;
@@ -139,7 +142,7 @@ public class ConfigAssignmentUtils {
}
return resourceDefinition;
}
-
+
@SuppressWarnings("squid:S3776")
public static synchronized void populateValueForOutputMapping(SvcLogicContext ctx,
Map<String, Object> componentContext, ResourceAssignment resourceAssignment,
@@ -148,19 +151,19 @@ public class ConfigAssignmentUtils {
if (resourceAssignment == null) {
throw new SvcLogicException("resourceAssignment is null.");
}
-
+
if (ctx == null) {
throw new SvcLogicException("service logic context is null.");
}
-
+
if (componentContext == null) {
throw new SvcLogicException("component context is null.");
}
-
+
logger.info("populating value for output mapping ({}), from json ({})", outputKeyMapping, responseNode);
String dictionaryName = resourceAssignment.getDictionaryName();
String type = resourceAssignment.getProperty().getType();
-
+
String entrySchema = null;
if (ValidTypes.getPrimitivePropertType().contains(type)) {
ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, responseNode);
@@ -169,7 +172,7 @@ public class ConfigAssignmentUtils {
if (resourceAssignment.getProperty().getEntrySchema() != null) {
entrySchema = resourceAssignment.getProperty().getEntrySchema().getType();
}
-
+
if (StringUtils.isNotBlank(entrySchema)) {
ArrayNode arrayNode = JsonNodeFactory.instance.arrayNode();
if (ValidTypes.getPrimitivePropertType().contains(entrySchema)) {
@@ -181,7 +184,7 @@ public class ConfigAssignmentUtils {
ObjectNode arrayChildNode = JsonNodeFactory.instance.objectNode();
for (Map.Entry<String, String> mapping : outputKeyMapping.entrySet()) {
JsonNode responseKeyValue = responseSingleJsonNode.get(mapping.getKey());
-
+
String propertyTypeForDataType =
ConfigAssignmentUtils.getPropertyType(ctx, entrySchema, mapping.getKey());
logger.info("For List Type Resource: key ({}), value ({}), type ({})",
@@ -221,7 +224,7 @@ public class ConfigAssignmentUtils {
ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, objectNode);
}
}
-
+
@SuppressWarnings("squid:S3776")
public static synchronized List<ResourceAssignment> convertResoureAssignmentDataList(
List<ResourceAssignmentData> resourceAssignmentDataList) {
@@ -240,7 +243,7 @@ public class ConfigAssignmentUtils {
resourceAssignment.setMessage(resourceAssignmentData.getMessage());
PropertyDefinition property = new PropertyDefinition();
property.setType(resourceAssignmentData.getDataType());
-
+
if (StringUtils.isNotBlank(resourceAssignmentData.getResourceValue())) {
if (ValidTypes.getPrimitivePropertType().contains(resourceAssignmentData.getDataType())) {
property.setValue(resourceAssignmentData.getResourceValue());
@@ -261,11 +264,11 @@ public class ConfigAssignmentUtils {
assignments.add(resourceAssignment);
}
}
-
+
}
return assignments;
}
-
+
@SuppressWarnings("squid:S3776")
public static synchronized List<ResourceAssignmentData> convertResoureAssignmentList(
List<ResourceAssignment> assignments) {
@@ -298,5 +301,5 @@ public class ConfigAssignmentUtils {
}
return resourceAssignmentDataList;
}
-
+
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigPreviewService.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigPreviewService.java
index 7aa2d438a..ae5c01c88 100644
--- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigPreviewService.java
+++ b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigPreviewService.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.service;
@@ -35,14 +38,14 @@ public class ConfigPreviewService {
private ConfigResourceService configResourceService;
private ConfigModelService configModelService;
private ConfigGeneratorService configGeneratorService;
-
+
public ConfigPreviewService(ConfigResourceService configResourceService, ConfigModelService configModelService,
ConfigGeneratorService configGeneratorService) {
this.configResourceService = configResourceService;
this.configModelService = configModelService;
this.configGeneratorService = configGeneratorService;
}
-
+
public String generatePreview(String templateContent, String templateData) throws SvcLogicException {
String mashedData = "";
ConfigGeneratorInfo configGeneratorInfo =
@@ -52,7 +55,7 @@ public class ConfigPreviewService {
}
return mashedData;
}
-
+
public ResourceAssignmentData generateTemplateResourceMash(ResourceAssignmentData resourceAssignmentData)
throws SvcLogicException {
if (resourceAssignmentData == null) {
@@ -73,25 +76,25 @@ public class ConfigPreviewService {
if (StringUtils.isBlank(resourceAssignmentData.getActionName())) {
throw new SvcLogicException("Action name is missing");
}
-
+
String serviceTemplateName = resourceAssignmentData.getServiceTemplateName();
String serviceTemplateVersion = resourceAssignmentData.getServiceTemplateVersion();
String actionName = resourceAssignmentData.getActionName();
String resourceId = resourceAssignmentData.getResourceId();
String resourceType = resourceAssignmentData.getResourceType();
String inputData = "{}";
-
+
Map<String, String> context = new HashMap<>();
context.put(ConfigModelConstant.PROPERTY_ACTION_NAME, actionName);
context = configModelService.prepareContext(context, inputData, serviceTemplateName, serviceTemplateVersion);
-
+
ConfigResource configResourceQuery = new ConfigResource();
configResourceQuery.setServiceTemplateVersion(serviceTemplateName);
configResourceQuery.setServiceTemplateVersion(serviceTemplateVersion);
configResourceQuery.setRecipeName(actionName);
configResourceQuery.setResourceId(resourceId);
configResourceQuery.setResourceType(resourceType);
-
+
List<ConfigResource> configResources = configResourceService.getConfigResource(configResourceQuery);
if (CollectionUtils.isNotEmpty(configResources)) {
for (ConfigResource cr : configResources) {
@@ -110,7 +113,7 @@ public class ConfigPreviewService {
serviceTemplateName, serviceTemplateVersion, actionName, resourceId, resourceType);
}
return resourceAssignmentData;
-
+
}
-
+
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ResourceDictionaryService.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ResourceDictionaryService.java
index 97a4dd45e..50562b0e8 100644
--- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ResourceDictionaryService.java
+++ b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ResourceDictionaryService.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.service;
@@ -31,14 +34,14 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
public class ResourceDictionaryService {
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceDictionaryService.class);
private ConfigRestAdaptorService configRestAdaptorService;
-
+
public ResourceDictionaryService(ConfigRestAdaptorService configRestAdaptorService) {
this.configRestAdaptorService = configRestAdaptorService;
}
-
+
@SuppressWarnings("squid:S3776")
public Map<String, ResourceDefinition> getDataDictionaryDefinitions(List<ResourceAssignment> resourceAssignments)
throws SvcLogicException {
@@ -48,11 +51,11 @@ public class ResourceDictionaryService {
List<String> names = new ArrayList<>();
for (ResourceAssignment resourceAssignment : resourceAssignments) {
if (resourceAssignment != null && StringUtils.isNotBlank(resourceAssignment.getDictionaryName())) {
-
+
if (!names.contains(resourceAssignment.getDictionaryName())) {
names.add(resourceAssignment.getDictionaryName());
}
-
+
if (resourceAssignment.getDependencies() != null
&& !resourceAssignment.getDependencies().isEmpty()) {
List<String> dependencieNames = resourceAssignment.getDependencies();
@@ -70,18 +73,18 @@ public class ResourceDictionaryService {
} catch (Exception e) {
throw new SvcLogicException("Failed in getting resource data dictionary : " + e.getMessage());
}
-
+
}
-
+
@SuppressWarnings("squid:S3776")
private void queryResourceDictionaryDefinitions(Map<String, ResourceDefinition> dictionaries, List<String> names)
throws SvcLogicException, ConfigRestAdaptorException {
logger.info("Getting resource dictionary definition for the names ({})", names);
if (!names.isEmpty()) {
-
+
String dictionaryContents = configRestAdaptorService.postResource(
ConfigRestAdaptorConstants.SELECTOR_MODEL_SERVICE, "dictionarybynames", names, String.class);
-
+
if (StringUtils.isNotBlank(dictionaryContents)) {
List<ResourceDictionary> dataDictionaries =
TransformationUtils.getListfromJson(dictionaryContents, ResourceDictionary.class);
diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ResourceModelService.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ResourceModelService.java
index 7eb21967d..9f3013b73 100644
--- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ResourceModelService.java
+++ b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ResourceModelService.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.service;
@@ -30,13 +33,13 @@ import com.att.eelf.configuration.EELFManager;
public class ResourceModelService {
private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceModelService.class);
-
+
private ConfigModelService configModelService;
-
+
public ResourceModelService(ConfigModelService configModelService) {
this.configModelService = configModelService;
}
-
+
public Map<String, String> getTemplatesContents(SvcLogicContext ctx, List<String> templateNames)
throws SvcLogicException {
Map<String, String> templatesContents = new HashMap<>();
@@ -53,7 +56,7 @@ public class ResourceModelService {
}
return templatesContents;
}
-
+
public Map<String, List<ResourceAssignment>> getTemplatesResourceAssignments(SvcLogicContext ctx,
List<String> templateNames) throws SvcLogicException {
Map<String, List<ResourceAssignment>> templatesResourceAssignments = new HashMap<>();
@@ -63,12 +66,12 @@ public class ResourceModelService {
String resourceMappingContent = this.configModelService.getNodeTemplateMapping(ctx, templateName);
logger.info("Processing template ({}) with resource assignment content : {}", templateName,
resourceMappingContent);
-
+
if (StringUtils.isNotBlank(resourceMappingContent)) {
-
+
List<ResourceAssignment> resourceAssignments =
TransformationUtils.getListfromJson(resourceMappingContent, ResourceAssignment.class);
-
+
if (resourceAssignments != null) {
ResourceAssignmentValidator resourceAssignmentValidator =
new ResourceAssignmentValidator(resourceAssignments);
@@ -88,7 +91,7 @@ public class ResourceModelService {
} catch (Exception e) {
throw new SvcLogicException(e.getMessage());
}
-
+
return templatesResourceAssignments;
}
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/blueprints-processor/plugin/assignment-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
index ebefd645c..c880c8d4f 100644
--- a/blueprints-processor/plugin/assignment-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
+++ b/blueprints-processor/plugin/assignment-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright © 2017-2018 AT&T Intellectual Property.
+ Modifications Copyright © 2018 IBM.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ConfigPreviewServiceTest.java b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ConfigPreviewServiceTest.java
index 4696fd281..75b7f2e28 100644
--- a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ConfigPreviewServiceTest.java
+++ b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ConfigPreviewServiceTest.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.service;
@@ -39,37 +42,37 @@ import com.att.eelf.configuration.EELFManager;
@RunWith(MockitoJUnitRunner.class)
public class ConfigPreviewServiceTest {
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigPreviewServiceTest.class);
-
+
@Rule
public ExpectedException thrown = ExpectedException.none();
-
+
@Mock
private ConfigResourceService configResourceService;
-
+
@Mock
private ConfigRestAdaptorService configRestAdaptorService;
-
+
private ConfigModelService configModelService;
private ConfigGeneratorService configGeneratorService;
-
+
@SuppressWarnings("unchecked")
@Before
public void before() throws Exception {
MockitoAnnotations.initMocks(this);
}
-
+
@Test
public void testGenerateTemplateResourceMash() throws Exception {
-
+
ConfigResourceAssignmentTestUtils.injectTransactionLogSaveMock(configResourceService);
-
+
ConfigResourceAssignmentTestUtils.injectConfigModelMock(configRestAdaptorService, "resource_assignment");
-
+
ConfigResourceAssignmentTestUtils.injectResourceDictionaryMock(configRestAdaptorService,
"assignments/empty-dictionary.json");
-
+
ConfigResource configResourceQuery = new ConfigResource();
configResourceQuery.setServiceTemplateVersion("sample-serviceTemplateName");
configResourceQuery.setServiceTemplateVersion("1.0.0");
@@ -80,28 +83,28 @@ public class ConfigPreviewServiceTest {
String inputContent = FileUtils.readFileToString(
new File("src/test/resources/service_templates/input/input.json"), Charset.defaultCharset());
configResourceQuery.setResourceData(inputContent);
-
+
ConfigResourceAssignmentTestUtils.injectGetConfigResourceMock(configResourceService, configResourceQuery);
-
+
configModelService = new ConfigModelServiceImpl(configRestAdaptorService);
configGeneratorService = new ConfigGeneratorServiceImpl(configResourceService);
-
+
ConfigPreviewService configPreviewService =
new ConfigPreviewService(configResourceService, configModelService, configGeneratorService);
-
+
ResourceAssignmentData resourceAssignmentData = new ResourceAssignmentData();
resourceAssignmentData.setResourceId("123-resourceId");
resourceAssignmentData.setResourceType("sample-resourceType");
resourceAssignmentData.setServiceTemplateName("sample-serviceTemplateName");
resourceAssignmentData.setServiceTemplateVersion("1.0.0");
resourceAssignmentData.setActionName("sample-action");
-
+
resourceAssignmentData = configPreviewService.generateTemplateResourceMash(resourceAssignmentData);
-
+
Assert.assertNotNull("Failed to get GenerateTemplateResourceMash response.", resourceAssignmentData);
Assert.assertNotNull("Failed to get template mashed contents.",
resourceAssignmentData.getTemplatesMashedContents());
-
+
Assert.assertNotNull("Failed to get base-config template mashed contents.",
resourceAssignmentData.getTemplatesMashedContents().get("base-config-template"));
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ConfigResourceAssignmentTestUtils.java b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ConfigResourceAssignmentTestUtils.java
index f4ee969fb..ee1c076ae 100644
--- a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ConfigResourceAssignmentTestUtils.java
+++ b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ConfigResourceAssignmentTestUtils.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.service;
@@ -44,9 +47,9 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
public class ConfigResourceAssignmentTestUtils {
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigResourceAssignmentTestUtils.class);
-
+
public static void injectTransactionLogSaveMock(ConfigResourceService configResourceService) throws Exception {
Mockito.doAnswer(new Answer<Void>() {
@Override
@@ -59,10 +62,10 @@ public class ConfigResourceAssignmentTestUtils {
}
}).when(configResourceService).save(any(TransactionLog.class));
}
-
+
public static void injectConfigModelMock(ConfigRestAdaptorService configRestAdaptorService,
String serviceTemplateName) throws Exception {
-
+
Mockito.doAnswer(new Answer<ConfigModel>() {
@Override
public org.onap.ccsdk.config.model.domain.ConfigModel answer(InvocationOnMock invocationOnMock)
@@ -70,23 +73,23 @@ public class ConfigResourceAssignmentTestUtils {
Object[] args = invocationOnMock.getArguments();
org.onap.ccsdk.config.model.domain.ConfigModel serviceArtifact = null;
if (args != null && args.length == 3) {
-
+
logger.info("Artifact info " + Arrays.asList(args));
String modelContent = IOUtils.toString(
ConfigResourceAssignmentTestUtils.class.getClassLoader().getResourceAsStream(
"service_templates/" + serviceTemplateName + "/" + serviceTemplateName + ".json"),
Charset.defaultCharset());
-
+
ConfigModelContent configModelContent = new ConfigModelContent();
configModelContent.setContent(modelContent);
configModelContent.setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON);
-
+
List<ConfigModelContent> configModelContents = new ArrayList<>();
configModelContents.add(configModelContent);
-
+
String velocityDir = ConfigResourceAssignmentTestUtils.class.getClassLoader()
.getResource("service_templates/" + serviceTemplateName + "/velocity").getPath();
-
+
Collection<File> templateFiles =
FileUtils.listFiles(new File(velocityDir), new String[] {"vtl"}, true);
logger.info("Template Files info " + templateFiles);
@@ -98,22 +101,22 @@ public class ConfigResourceAssignmentTestUtils {
configModelTemplateContent.setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TEMPLATE);
configModelContents.add(configModelTemplateContent);
}
-
+
serviceArtifact = new org.onap.ccsdk.config.model.domain.ConfigModel();
serviceArtifact.setArtifactName(String.valueOf(args[0]));
serviceArtifact.setArtifactVersion(String.valueOf(args[1]));
serviceArtifact.setPublished("Y");
serviceArtifact.setConfigModelContents(configModelContents);
}
-
+
return serviceArtifact;
}
}).when(configRestAdaptorService).getResource(anyString(), anyString(), Matchers.any(Class.class));
}
-
+
public static void injectResourceDictionaryMock(ConfigRestAdaptorService configRestAdaptorService,
String dictionaryFileName) throws Exception {
-
+
Mockito.doAnswer(new Answer<String>() {
@Override
public String answer(InvocationOnMock invocationOnMock) throws Throwable {
@@ -130,7 +133,7 @@ public class ConfigResourceAssignmentTestUtils {
}).when(configRestAdaptorService).postResource(Matchers.any(), Matchers.any(), Matchers.any(),
Matchers.any(Class.class));
}
-
+
public static void injectConfigResourceSaveMock(ConfigResourceService configResourceService) throws Exception {
Mockito.doAnswer(new Answer<ConfigResource>() {
@Override
@@ -146,7 +149,7 @@ public class ConfigResourceAssignmentTestUtils {
}
}).when(configResourceService).saveConfigResource(any(ConfigResource.class));
}
-
+
public static void injectGetConfigResourceMock(ConfigResourceService configResourceService,
ConfigResource configResource) throws Exception {
Mockito.doAnswer(new Answer<List<ConfigResource>>() {
@@ -161,12 +164,12 @@ public class ConfigResourceAssignmentTestUtils {
}
}).when(configResourceService).getConfigResource(any(ConfigResource.class));
}
-
+
public static String getFileContent(String filePath) throws Exception {
return IOUtils.toString(ConfigResourceAssignmentTestUtils.class.getClassLoader().getResourceAsStream(filePath),
Charset.defaultCharset());
}
-
+
public static Map<String, ResourceDefinition> getMapfromJson(String content) {
try {
ObjectMapper mapper = new ObjectMapper();
diff --git a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ResourceAssignmentGenerationTest.java b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ResourceAssignmentGenerationTest.java
index e979ea3d1..3dc7da7eb 100644
--- a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ResourceAssignmentGenerationTest.java
+++ b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ResourceAssignmentGenerationTest.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.service;
@@ -31,16 +34,16 @@ import com.att.eelf.configuration.EELFManager;
import com.fasterxml.jackson.databind.JsonNode;
public class ResourceAssignmentGenerationTest {
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceAssignmentGenerationTest.class);
-
+
@Test
public void testResourceDataSetting() {
try {
logger.info(" **************** testResourceDataSetting *****************");
String resourceAssignmentContents = IOUtils.toString(TopologicalSortingTest.class.getClassLoader()
.getResourceAsStream("assignments/alltype-empty-value-mapping.json"), Charset.defaultCharset());
-
+
List<ResourceAssignment> assignments =
TransformationUtils.getListfromJson(resourceAssignmentContents, ResourceAssignment.class);
if (assignments != null) {
@@ -75,33 +78,33 @@ public class ResourceAssignmentGenerationTest {
}
String generatedData = ResourceAssignmentUtils.generateResourceDataForAssignments(assignments);
logger.trace("Generated Data " + generatedData);
-
+
Assert.assertNotNull("Failed to generate resource data", generatedData);
}
} catch (Exception e) {
e.printStackTrace();
}
}
-
+
@Test
public void testGenerateResourceData() {
try {
logger.info(" **************** testGenerateResourceData *****************");
String resourceAssignmentContents = IOUtils.toString(TopologicalSortingTest.class.getClassLoader()
.getResourceAsStream("assignments/alltype-mapping.json"), Charset.defaultCharset());
-
+
List<ResourceAssignment> assignments =
TransformationUtils.getListfromJson(resourceAssignmentContents, ResourceAssignment.class);
if (assignments != null) {
-
+
String generatedData = ResourceAssignmentUtils.generateResourceDataForAssignments(assignments);
logger.trace("Generated Data " + generatedData);
-
+
Assert.assertNotNull("Failed to generate resource data", generatedData);
}
} catch (Exception e) {
e.printStackTrace();
}
}
-
+
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ResourceAssignmentValidation.java b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ResourceAssignmentValidation.java
index 0bf74b4c0..d708404f5 100644
--- a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ResourceAssignmentValidation.java
+++ b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ResourceAssignmentValidation.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.service;
@@ -31,10 +34,10 @@ import com.att.eelf.configuration.EELFManager;
public class ResourceAssignmentValidation {
private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceAssignmentValidation.class);
-
+
@Rule
public final ExpectedException exception = ExpectedException.none();
-
+
@Test
public void testValidateSuccess() {
try {
@@ -42,12 +45,12 @@ public class ResourceAssignmentValidation {
String resourceMapping = IOUtils.toString(
TopologicalSortingTest.class.getClassLoader().getResourceAsStream("validation/success.json"),
Charset.defaultCharset());
-
+
List<ResourceAssignment> assignments =
TransformationUtils.getListfromJson(resourceMapping, ResourceAssignment.class);
if (assignments != null) {
ResourceAssignmentValidator resourceAssignmentValidator = new ResourceAssignmentValidator(assignments);
-
+
boolean result = resourceAssignmentValidator.validateResourceAssignment();
Assert.assertTrue("Failed to Validate", result);
}
@@ -55,37 +58,37 @@ public class ResourceAssignmentValidation {
e.printStackTrace();
}
}
-
+
@Test(expected = ConfigModelException.class)
public void testValidateDuplicate() throws IOException, ConfigModelException {
logger.info(" **************** testValidateDuplicate *****************");
String resourceMapping = IOUtils.toString(
TopologicalSortingTest.class.getClassLoader().getResourceAsStream("validation/duplicate.json"),
Charset.defaultCharset());
-
+
List<ResourceAssignment> assignments =
TransformationUtils.getListfromJson(resourceMapping, ResourceAssignment.class);
if (assignments != null) {
ResourceAssignmentValidator resourceAssignmentValidator = new ResourceAssignmentValidator(assignments);
resourceAssignmentValidator.validateResourceAssignment();
}
-
+
}
-
+
@Test(expected = ConfigModelException.class)
public void testValidateCyclic() throws IOException, ConfigModelException {
logger.info(" **************** testValidateCyclic *****************");
String resourceMapping = IOUtils.toString(
TopologicalSortingTest.class.getClassLoader().getResourceAsStream("validation/cyclic.json"),
Charset.defaultCharset());
-
+
List<ResourceAssignment> assignments =
TransformationUtils.getListfromJson(resourceMapping, ResourceAssignment.class);
if (assignments != null) {
ResourceAssignmentValidator resourceAssignmentValidator = new ResourceAssignmentValidator(assignments);
-
+
resourceAssignmentValidator.validateResourceAssignment();
}
-
+
}
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/TopologicalSortingTest.java b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/TopologicalSortingTest.java
index 1b05e4b0e..e4b7f5dee 100644
--- a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/TopologicalSortingTest.java
+++ b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/TopologicalSortingTest.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.service;
@@ -28,7 +31,7 @@ import com.att.eelf.configuration.EELFManager;
public class TopologicalSortingTest {
private static EELFLogger logger = EELFManager.getInstance().getLogger(TopologicalSortingTest.class);
-
+
@Test
public void testBulkSequencingMapping() {
try {
@@ -36,7 +39,7 @@ public class TopologicalSortingTest {
String resourceMapping = IOUtils.toString(
TopologicalSortingTest.class.getClassLoader().getResourceAsStream("mapping/dependency.json"),
Charset.defaultCharset());
-
+
List<ResourceAssignment> assignments =
TransformationUtils.getListfromJson(resourceMapping, ResourceAssignment.class);
if (assignments != null) {
@@ -44,7 +47,7 @@ public class TopologicalSortingTest {
ResourceAssignmentProcessor resourceAssignmentProcessor =
new ResourceAssignmentProcessor(assignments, ctx);
List<List<ResourceAssignment>> sequenceBatchResourceAssignment = resourceAssignmentProcessor.process();
-
+
Assert.assertNotNull("Failed to populate Sequence Bulk Mappings", sequenceBatchResourceAssignment);
Assert.assertNotEquals("Failed to populate Sequence Bulk Mappings size ",
(sequenceBatchResourceAssignment.size() > 0));
@@ -53,5 +56,5 @@ public class TopologicalSortingTest {
e.printStackTrace();
}
}
-
+
}