From d2cc0336c4dd9875e717e096d8f9bf815cb783b7 Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Tue, 4 Sep 2018 21:22:01 -0400 Subject: 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) --- blueprints-processor/.gitignore | 58 +++++----- .../data/adaptor/ConfigDataAdaptorException.java | 23 ++-- .../config/data/adaptor/DataAdaptorConstants.java | 39 ++++--- .../data/adaptor/dao/ConfigPropertyMapDao.java | 19 ++-- .../data/adaptor/dao/ConfigPropertyMapDaoImpl.java | 29 ++--- .../config/data/adaptor/dao/ConfigResourceDao.java | 23 ++-- .../data/adaptor/dao/ConfigResourceDaoImpl.java | 121 +++++++++++---------- .../data/adaptor/dao/NamedQueryExecutorDao.java | 21 ++-- .../adaptor/dao/NamedQueryExecutorDaoImpl.java | 25 +++-- .../config/data/adaptor/dao/QueryExecutorDao.java | 21 ++-- .../data/adaptor/dao/QueryExecutorDaoImpl.java | 27 +++-- .../config/data/adaptor/dao/TransactionLogDao.java | 23 ++-- .../data/adaptor/dao/TransactionLogDaoImpl.java | 33 +++--- .../config/data/adaptor/db/DataSourceWrap.java | 41 +++---- .../data/adaptor/domain/ConfigPropertyMapData.java | 29 ++--- .../config/data/adaptor/domain/ConfigResource.java | 79 +++++++------- .../adaptor/domain/ResourceAssignmentData.java | 75 +++++++------ .../config/data/adaptor/domain/TransactionLog.java | 49 +++++---- .../data/adaptor/service/ConfigResourceNode.java | 33 +++--- .../adaptor/service/ConfigResourceService.java | 39 ++++--- .../adaptor/service/ConfigResourceServiceImpl.java | 45 ++++---- .../org/opendaylight/blueprint/impl-blueprint.xml | 1 + .../data/adaptor/dao/ConfigPropertyMapDaoTest.java | 25 +++-- .../data/adaptor/dao/ConfigResourceDaoTest.java | 43 ++++---- .../adaptor/dao/ConfigTransactionLogDaoTest.java | 37 ++++--- .../data/adaptor/dao/QueryExecutorDaoTest.java | 35 +++--- .../adaptor/service/ConfigResourceNodeTest.java | 39 ++++--- .../adaptor/service/ConfigResourceServiceTest.java | 59 +++++----- .../src/test/resources/log4j.properties | 26 ++++- .../src/test/resources/test-context-h2db.xml | 1 + .../src/test/resources/test-context.xml | 1 + .../rest/adaptor/ConfigRestAdaptorConstants.java | 31 +++--- .../rest/adaptor/ConfigRestAdaptorException.java | 23 ++-- .../config/rest/adaptor/data/RestResponse.java | 41 +++---- .../service/AbstractConfigRestClientAdapter.java | 66 +++++------ .../adaptor/service/ConfigRestAdaptorService.java | 29 ++--- .../service/ConfigRestAdaptorServiceImpl.java | 49 +++++---- .../service/ConfigRestClientServiceAdapter.java | 29 ++--- .../service/GenericRestClientAdapterImpl.java | 55 +++++----- .../adaptor/service/SSLRestClientAdapterImpl.java | 55 +++++----- .../utils/BasicAuthorizationInterceptor.java | 25 +++-- .../adaptor/utils/LoggingRequestInterceptor.java | 25 +++-- .../org/opendaylight/blueprint/impl-blueprint.xml | 1 + .../AbstractConfigRestClientAdapterTest.java | 29 ++--- .../service/GenericRestClientServiceTest.java | 56 +++++----- .../rest/adaptor/service/SSLClientServiceTest.java | 56 +++++----- .../adaptor/utils/RestTemplateFactoryTest.java | 81 ++++++++------ .../test/resources/config-rest-adaptor.properties | 74 ++++++++----- .../assignment/ConfigAssignmentConstants.java | 21 ++-- .../assignment/data/ResourceAssignmentData.java | 77 ++++++------- .../assignment/processor/ProcessorFactory.java | 25 +++-- .../processor/ResourceAssignmentProcessor.java | 41 +++---- .../service/ConfigAssignmentPersistService.java | 55 +++++----- .../service/ConfigAssignmentProcessService.java | 85 ++++++++------- .../service/ConfigAssignmentService.java | 23 ++-- .../service/ConfigAssignmentServiceImpl.java | 31 +++--- .../assignment/service/ConfigAssignmentUtils.java | 53 ++++----- .../assignment/service/ConfigPreviewService.java | 33 +++--- .../service/ResourceDictionaryService.java | 33 +++--- .../assignment/service/ResourceModelService.java | 31 +++--- .../org/opendaylight/blueprint/impl-blueprint.xml | 1 + .../service/ConfigPreviewServiceTest.java | 51 +++++---- .../service/ConfigResourceAssignmentTestUtils.java | 49 +++++---- .../service/ResourceAssignmentGenerationTest.java | 33 +++--- .../service/ResourceAssignmentValidation.java | 37 ++++--- .../assignment/service/TopologicalSortingTest.java | 23 ++-- 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 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 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 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 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 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 findByConfigResource(ConfigResource configResourceInput) throws SvcLogicException { StringBuilder selectArtifactBuffer = new StringBuilder(); List 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 configResources = this.jdbcTemplate.query(queryString, listOfArguments.toArray(), new ConfigResourceMapper()); - + List 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 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 getResourceAssignmentdata(String configResourceId) { List 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 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 queryOneForObject(String sql, Object[] args, RowMapper rowMapper) { List results = this.jdbcTemplate.query(sql, args, new RowMapperResultSetExtractor(rowMapper, 1)); if (results != null && !results.isEmpty()) { @@ -366,7 +369,7 @@ public class ConfigResourceDaoImpl implements ConfigResourceDao { return null; } } - + class ConfigResourceMapper implements RowMapper { @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 { @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> query(String sql, Map 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 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> query(String sql, Map 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 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> 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> 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 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 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 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 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 { @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 unwrap(Class 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 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 getResourceAssignments() { return resourceAssignments; } - + public void setResourceAssignments(List 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 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> query(String sql, Map 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 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> 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 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 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 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> query(String sql, Map parameters) throws SvcLogicException { return namedQueryExecutorDao.query(sql, parameters); } - + @Override public int update(String sql, Map parameters) throws SvcLogicException { return namedQueryExecutorDao.update(sql, parameters); } - + @Override public List> 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 getTransactionsByRequestId(String requestId) throws SvcLogicException { return transactionLogDao.getTransactionsByRequestId(requestId); } - + @Override public List getTransactionsByRequestId(String requestId, String messageType) throws SvcLogicException { return transactionLogDao.getTransactionsByRequestId(requestId, messageType); } - + @Override public List 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 @@