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>
-# 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\r
+**/target/*\r
+**/target-ide/*\r
+\r
+# Logs dir in all projects\r
+**/logs/*\r
+**/debug-logs/*\r
+\r
+# Added for Intellij IDEA IDE\r
+**/.idea/*\r
+\r
+# Generated models and features\r
+**/bin/*\r
+\r
+# MANIFEST.MF is updated on every clean install\r
+**/src/main/resources/META-INF/\r
+**/src/main/yang-gen-sal\r
+**/src/main/yang-gen-config\r
+\r
+\r
+**/pom.xml.versionsBackup\r
+**/.flattened-pom.xml\r
+**/.pydevproject\r
+**/.settings\r
+**/.classpath\r
+**/.project\r
+\r
+**/*.class\r
+**/*.prefs\r
**/*.iml
\ No newline at end of file
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.data.adaptor;\r
* @version 1.0\r
*/\r
public class ConfigDataAdaptorException extends Exception {\r
- \r
+\r
/**\r
*\r
*/\r
private static final long serialVersionUID = 1L;\r
- \r
+\r
/**\r
* This is a ConfigDataAdaptorException constructor\r
*\r
public ConfigDataAdaptorException(String message) {\r
super(message);\r
}\r
- \r
+\r
/**\r
* This is a ConfigDataAdaptorException constructor\r
*\r
public ConfigDataAdaptorException(String message, Throwable cause) {\r
super(message, cause);\r
}\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.data.adaptor;\r
\r
@SuppressWarnings("squid:S1118")\r
public class DataAdaptorConstants {\r
- \r
+\r
public static final String OUTPUT_STATUS_SUCCESS = "success";\r
public static final String OUTPUT_STATUS_FAILURE = "failure";\r
- \r
+\r
public static final String PROPERTY_ENV_TYPE = "org.onap.ccsdk.config.rest.adaptors.envtype";\r
public static final String PROPERTY_ENV_PROD = "field";\r
public static final String PROPERTY_ENV_SOLO = "solo";\r
- \r
+\r
public static final String INPUT_PARAM_TAGS = "tags";\r
public static final String INPUT_PARAM_CAPABILITY_NAME = "capabilityName";\r
public static final String INPUT_PARAM_MESSAGE = "message";\r
public static final String INPUT_PARAM_ASDC_ARTIFACT_IND = "asdcArtifactInd";\r
public static final Object INPUT_PARAM_VNF_ID = "vnfId";\r
public static final Object INPUT_PARAM_VM_NAME = "vmName";\r
- \r
+\r
public static final Object INPUT_PARAM_CONFIG_CONTENT_TYPE = "configContentType";\r
- \r
+\r
public static final Object INPUT_PARAM_CONFIG_CONTENT = "configContent";\r
public static final Object INPUT_PARAM_CONFIG_INDICATOR = "configIndicator";\r
- \r
+\r
public static final Object CONFIG_CONTENT_TYPE_CONFIGURATION = "Configuration";\r
public static final Object CONFIG_CONTENT_TYPE_PARAMETERS = "Parameters";\r
public static final Object CONFIG_INDICATOR_PREPARE = "Prepare";\r
public static final Object CONFIG_INDICATOR_ACTIVE = "Active";\r
- \r
+\r
public static final String INPUT_PARAM_RESPONSE_PRIFIX = "response-prefix";\r
public static final String INPUT_PARAM_VNF_TYPE = "vnfType";\r
public static final String INPUT_PARAM_VNFC_TYPE = "vnfcType";\r
public static final String INPUT_PARAM_ACTION = "action";\r
public static final String INPUT_PARAM_API_VERSION = "apiVersion";\r
- \r
+\r
public static final String INPUT_PARAM_FILE_ID = "fileId";\r
public static final String INPUT_PARAM_UPLOAD_CONFIG_ID = "uploadConfigId";\r
public static final String FILE_CATEGORY_SERVICE_TEMPLATE = "service_template";\r
- \r
+\r
public static final String ARTIFACT_TYPE_SDNC_MODEL = "SDNC_MODEL";\r
- \r
+\r
public static final String LOG_MESSAGE_TYPE_LOG = "Log";\r
public static final String LOG_MESSAGE_TYPE_COMPONENT = "Component";\r
public static final String LOG_MESSAGE_TYPE_REQUEST = "Request";\r
public static final String LOG_MESSAGE_TYPE_MODEL = "Model";\r
public static final String LOG_MESSAGE_TYPE_DATA = "Data";\r
public static final String LOG_MESSAGE_TYPE_CONFIG = "Config";\r
- \r
+\r
public static final String SELF_SERVICE_STATUS_RECEIVED = "Received";\r
public static final String SELF_SERVICE_STATUS_ACKNOWLEDGED = "Acknowledged";\r
public static final String SELF_SERVICE_STATUS_REPLIED = "Replied";\r
public static final String SELF_SERVICE_STATUS_FAILED = "Failed";\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.data.adaptor.dao;\r
import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
\r
public interface ConfigPropertyMapDao {\r
- \r
+\r
/**\r
* Query ConcurrentHashMap having CONFIG_PROPERTY_MAP table data for given key.\r
*\r
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if fails\r
*/\r
public String getConfigPropertyByKey(String key) throws SvcLogicException;\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.data.adaptor.dao;\r
import com.google.common.base.Preconditions;\r
\r
public class ConfigPropertyMapDaoImpl implements ConfigPropertyMapDao {\r
- \r
+\r
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigPropertyMapDaoImpl.class);\r
- \r
+\r
private JdbcTemplate jdbcTemplate;\r
private Map<String, String> configPropertyMap = new ConcurrentHashMap<>();\r
- \r
+\r
public ConfigPropertyMapDaoImpl(JdbcTemplate jdbcTemplate) {\r
this.jdbcTemplate = jdbcTemplate;\r
initializeMap();\r
- \r
+\r
String envType = configPropertyMap.get(DataAdaptorConstants.PROPERTY_ENV_TYPE);\r
if (!(DataAdaptorConstants.PROPERTY_ENV_PROD.equalsIgnoreCase(envType)\r
|| DataAdaptorConstants.PROPERTY_ENV_SOLO.equalsIgnoreCase(envType))) {\r
executor.scheduleWithFixedDelay(task, 60, 15, TimeUnit.MINUTES);\r
}\r
}\r
- \r
+\r
private void initializeMap() {\r
String getPropQuery = "SELECT * FROM CONFIG_PROPERTY_MAP";\r
jdbcTemplate.queryForList(getPropQuery).forEach(rows -> {\r
});\r
logger.trace("loaded configPropertyMap : ({})", configPropertyMap);\r
}\r
- \r
+\r
@Override\r
public String getConfigPropertyByKey(String key) throws SvcLogicException {\r
Preconditions.checkArgument(StringUtils.isNotBlank(key), "missing property key");\r
return configPropertyMap.get(key);\r
}\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.data.adaptor.dao;\r
import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
\r
public interface ConfigResourceDao {\r
- \r
+\r
/**\r
* Issue a single SQL Insert operation for CONFIG_RESOURCE table via a prepared statement, binding\r
* the given arguments.\r
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the insert\r
*/\r
public ConfigResource save(ConfigResource configResourceInput) throws SvcLogicException;\r
- \r
+\r
/**\r
* Issue a single SQL Delete operation for CONFIG_RESOURCE table via a prepared statement, binding\r
* the given arguments.\r
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the insert\r
*/\r
public void deleteByConfigResource(ConfigResource configResourceInput) throws SvcLogicException;\r
- \r
+\r
/**\r
* Query CONFIG_RESOURCE table for given input param to create a prepared statement to bind to the\r
* query, mapping each row to a Java object via a ConfigResource RowMapper.\r
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
*/\r
public List<ConfigResource> findByConfigResource(ConfigResource configResourceInput) throws SvcLogicException;\r
- \r
+\r
public ConfigResource getConfigResource(ConfigResource configResource) throws SvcLogicException;\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.data.adaptor.dao;\r
import com.att.eelf.configuration.EELFManager;\r
\r
public class ConfigResourceDaoImpl implements ConfigResourceDao {\r
- \r
+\r
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigResourceDaoImpl.class);\r
- \r
+\r
private JdbcTemplate jdbcTemplate;\r
- \r
+\r
public ConfigResourceDaoImpl(JdbcTemplate jdbcTemplate) {\r
this.jdbcTemplate = jdbcTemplate;\r
}\r
- \r
+\r
@Override\r
public ConfigResource save(ConfigResource configResource) throws SvcLogicException {\r
- \r
+\r
ConfigResource dbConfigResource = checkConfigResource(configResource);\r
- \r
+\r
if (dbConfigResource != null && StringUtils.isNotBlank(dbConfigResource.getConfigResourceId())) {\r
configResource.setConfigResourceId(dbConfigResource.getConfigResourceId());\r
- \r
+\r
validateConfigResource(configResource);\r
- \r
+\r
update(configResource);\r
- \r
+\r
saveConfigResourceAssignmentData(configResource);\r
} else {\r
String addQuery = "INSERT INTO CONFIG_RESOURCE "\r
+ "( config_resource_id, resource_id, resource_type, service_template_name, service_template_version,"\r
+ "template_name, recipe_name, request_id, resource_data, mask_data, status, created_date, updated_by ) "\r
+ "VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";\r
- \r
+\r
configResource.setConfigResourceId(configResource.getUniqueId());\r
- \r
+\r
validateConfigResource(configResource);\r
- \r
+\r
logger.info("saving config resource ({}) ...", configResource);\r
jdbcTemplate.update(addQuery, configResource.getConfigResourceId(), configResource.getResourceId(),\r
configResource.getResourceType(), configResource.getServiceTemplateName(),\r
configResource.getRecipeName(), configResource.getRequestId(), configResource.getResourceData(),\r
configResource.getMaskData(), configResource.getStatus(), configResource.getCreatedDate(),\r
configResource.getUpdatedBy());\r
- \r
+\r
saveConfigResourceAssignmentData(configResource);\r
}\r
dbConfigResource = getConfigResource(configResource);\r
return dbConfigResource;\r
}\r
- \r
+\r
private void update(ConfigResource configResource) throws SvcLogicException {\r
if (StringUtils.isNotBlank(configResource.getConfigResourceId())) {\r
logger.info("updating config resource ({}) ...", configResource);\r
String updateQuery = "UPDATE CONFIG_RESOURCE SET "\r
+ "resource_data = ?, mask_data = ?, created_date = ?, updated_by = ? ,service_template_name = ?, service_template_version = ? "\r
+ "where config_resource_id = ?";\r
- \r
+\r
jdbcTemplate.update(updateQuery, configResource.getResourceData(), configResource.getMaskData(),\r
configResource.getCreatedDate(), configResource.getUpdatedBy(),\r
configResource.getServiceTemplateName(), configResource.getServiceTemplateVersion(),\r
throw new SvcLogicException("missing config resource id to update.");\r
}\r
}\r
- \r
+\r
private void saveConfigResourceAssignmentData(ConfigResource configResource) {\r
if (configResource != null && StringUtils.isNotBlank(configResource.getConfigResourceId())) {\r
List<Object> listOfArguments = new ArrayList<>();\r
this.jdbcTemplate.update(deleteQuery, listOfArguments.toArray());\r
logger.info("config resource assignment data deleted successfully for the config_resource_id ({})",\r
configResource.getConfigResourceId());\r
- \r
+\r
if (configResource.getResourceAssignments() != null) {\r
List<ResourceAssignmentData> resourceAssignments = configResource.getResourceAssignments();\r
for (ResourceAssignmentData resourceAssignmentData : resourceAssignments) {\r
}\r
}\r
}\r
- \r
+\r
private ResourceAssignmentData saveResourceAssignmentData(ResourceAssignmentData resourceAssignmentData) {\r
String addQuery = "INSERT INTO CONFIG_RESOURCE_ASSIGNMENT_DATA "\r
+ "( config_resource_assignment_data_id, config_resource_id, version, updated_by, template_key_name, "\r
+ "resource_name, data_type, entry_schema, resource_value, source, status, message ) "\r
+ "VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";\r
- \r
+\r
logger.debug("saving config resource assignment data ({}) ... ", resourceAssignmentData);\r
jdbcTemplate.update(addQuery, resourceAssignmentData.getId(), resourceAssignmentData.getConfigResourceId(),\r
resourceAssignmentData.getVersion(), resourceAssignmentData.getUpdatedBy(),\r
resourceAssignmentData.getDataType(), resourceAssignmentData.getEntrySchema(),\r
resourceAssignmentData.getResourceValue(), resourceAssignmentData.getSource(),\r
resourceAssignmentData.getStatus(), resourceAssignmentData.getMessage());\r
- \r
+\r
return resourceAssignmentData;\r
}\r
- \r
+\r
@Override\r
public void deleteByConfigResource(ConfigResource configResourceInput) throws SvcLogicException {\r
StringBuilder selectArtifactBuffer = new StringBuilder();\r
List<Object> listOfArguments = new ArrayList<>();\r
- \r
+\r
selectArtifactBuffer.append("DELETE FROM CONFIG_RESOURCE WHERE config_resource_id = ? ");\r
listOfArguments.add(configResourceInput.getConfigResourceId());\r
- \r
+\r
String queryString = selectArtifactBuffer.toString();\r
this.jdbcTemplate.update(queryString, listOfArguments.toArray());\r
logger.info("config resource ({}) deleted successfully ", configResourceInput);\r
}\r
- \r
+\r
@SuppressWarnings("squid:S3776")\r
@Override\r
public List<ConfigResource> findByConfigResource(ConfigResource configResourceInput) throws SvcLogicException {\r
StringBuilder selectArtifactBuffer = new StringBuilder();\r
List<Object> listOfArguments = new ArrayList<>();\r
- \r
+\r
selectArtifactBuffer.append("SELECT * FROM CONFIG_RESOURCE WHERE ");\r
- \r
+\r
StringBuilder whereClauseRemaining = new StringBuilder();\r
- \r
+\r
if (configResourceInput.getServiceTemplateName() != null) {\r
if (whereClauseRemaining.length() != 0) {\r
whereClauseRemaining.append("AND ");\r
whereClauseRemaining.append("service_template_name = ? ");\r
listOfArguments.add(configResourceInput.getServiceTemplateName());\r
}\r
- \r
+\r
if (configResourceInput.getServiceTemplateVersion() != null) {\r
if (whereClauseRemaining.length() != 0) {\r
whereClauseRemaining.append("AND ");\r
whereClauseRemaining.append("service_template_version = ? ");\r
listOfArguments.add(configResourceInput.getServiceTemplateVersion());\r
}\r
- \r
+\r
if (configResourceInput.getResourceId() != null) {\r
if (whereClauseRemaining.length() != 0) {\r
whereClauseRemaining.append("AND ");\r
whereClauseRemaining.append("resource_id = ? ");\r
listOfArguments.add(configResourceInput.getResourceId());\r
}\r
- \r
+\r
if (configResourceInput.getResourceType() != null) {\r
if (whereClauseRemaining.length() != 0) {\r
whereClauseRemaining.append("AND ");\r
whereClauseRemaining.append("resource_type = ? ");\r
listOfArguments.add(configResourceInput.getResourceType());\r
}\r
- \r
+\r
if (configResourceInput.getRequestId() != null) {\r
if (whereClauseRemaining.length() != 0) {\r
whereClauseRemaining.append("AND ");\r
whereClauseRemaining.append("request_id = ? ");\r
listOfArguments.add(configResourceInput.getRequestId());\r
}\r
- \r
+\r
if (configResourceInput.getTemplateName() != null) {\r
if (whereClauseRemaining.length() != 0) {\r
whereClauseRemaining.append("AND ");\r
whereClauseRemaining.append("template_name = ? ");\r
listOfArguments.add(configResourceInput.getTemplateName());\r
}\r
- \r
+\r
if (configResourceInput.getRecipeName() != null) {\r
if (whereClauseRemaining.length() != 0) {\r
whereClauseRemaining.append("AND ");\r
whereClauseRemaining.append("recipe_name = ? ");\r
listOfArguments.add(configResourceInput.getRecipeName());\r
}\r
- \r
+\r
String queryString = selectArtifactBuffer.toString() + whereClauseRemaining.toString();\r
logger.info("config resource queryString ({})", queryString);\r
List<ConfigResource> configResources =\r
this.jdbcTemplate.query(queryString, listOfArguments.toArray(), new ConfigResourceMapper());\r
- \r
+\r
List<ConfigResource> returnConfigResources = new ArrayList<>();\r
- \r
+\r
if (configResources != null) {\r
for (ConfigResource configResource : configResources) {\r
if (configResource != null) {\r
}\r
return returnConfigResources;\r
}\r
- \r
+\r
public ConfigResource checkConfigResource(ConfigResource configResource) {\r
StringBuilder selectBuffer = new StringBuilder();\r
List<Object> listOfArguments = new ArrayList<>();\r
- \r
+\r
selectBuffer.append(\r
"SELECT * FROM CONFIG_RESOURCE WHERE resource_id = ? AND resource_type = ? AND template_name = ? ");\r
listOfArguments.add(configResource.getResourceId());\r
listOfArguments.add(configResource.getTemplateName());\r
return queryOneForObject(selectBuffer.toString(), listOfArguments.toArray(), new ConfigResourceMapper());\r
}\r
- \r
+\r
@Override\r
public ConfigResource getConfigResource(ConfigResource configResource) throws SvcLogicException {\r
ConfigResource dbConfigResource = checkConfigResource(configResource);\r
}\r
return configResource;\r
}\r
- \r
+\r
private List<ResourceAssignmentData> getResourceAssignmentdata(String configResourceId) {\r
List<Object> listOfArguments = new ArrayList<>();\r
String queryString = "SELECT * FROM CONFIG_RESOURCE_ASSIGNMENT_DATA WHERE config_resource_id = ? ";\r
listOfArguments.add(configResourceId);\r
return this.jdbcTemplate.query(queryString, listOfArguments.toArray(), new ResourceAssignmentDataMapper());\r
}\r
- \r
+\r
@SuppressWarnings("squid:S3776")\r
private boolean validateConfigResource(ConfigResource configResource) throws SvcLogicException {\r
if (configResource == null) {\r
throw new SvcLogicException("config resource information is missing.");\r
}\r
- \r
+\r
if (StringUtils.isBlank(configResource.getConfigResourceId())) {\r
throw new SvcLogicException("config resource id is missing.");\r
}\r
- \r
+\r
if (StringUtils.isBlank(configResource.getResourceType())) {\r
throw new SvcLogicException("config resource type is missing.");\r
}\r
if (StringUtils.isBlank(configResource.getResourceId())) {\r
throw new SvcLogicException("config resource resource id is missing.");\r
}\r
- \r
+\r
if (StringUtils.isBlank(configResource.getRecipeName())) {\r
throw new SvcLogicException("config resource action name is missing.");\r
}\r
- \r
+\r
if (StringUtils.isBlank(configResource.getTemplateName())) {\r
throw new SvcLogicException("config resource template name is missing.");\r
}\r
- \r
+\r
if (configResource.getResourceAssignments() != null) {\r
List<ResourceAssignmentData> resourceAssignments = configResource.getResourceAssignments();\r
for (ResourceAssignmentData resourceAssignmentData : resourceAssignments) {\r
if (resourceAssignmentData.getResourceValue() == null) {\r
resourceAssignmentData.setResourceValue("");\r
}\r
- \r
+\r
validateResourceAssignmentData(resourceAssignmentData);\r
}\r
}\r
}\r
- \r
+\r
return true;\r
}\r
- \r
+\r
private boolean validateResourceAssignmentData(ResourceAssignmentData resourceAssignmentData)\r
throws SvcLogicException {\r
if (resourceAssignmentData == null) {\r
}\r
return true;\r
}\r
- \r
+\r
private <T> T queryOneForObject(String sql, Object[] args, RowMapper<T> rowMapper) {\r
List<T> results = this.jdbcTemplate.query(sql, args, new RowMapperResultSetExtractor<T>(rowMapper, 1));\r
if (results != null && !results.isEmpty()) {\r
return null;\r
}\r
}\r
- \r
+\r
class ConfigResourceMapper implements RowMapper<ConfigResource> {\r
@Override\r
public ConfigResource mapRow(ResultSet rs, int rowNum) throws SQLException {\r
return configResource;\r
}\r
}\r
- \r
+\r
class ResourceAssignmentDataMapper implements RowMapper<ResourceAssignmentData> {\r
@Override\r
public ResourceAssignmentData mapRow(ResultSet rs, int rowNum) throws SQLException {\r
return resourceAssignmentData;\r
}\r
}\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.data.adaptor.dao;\r
* Return NamedParameterJdbcTemplate object.\r
*/\r
public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() throws SvcLogicException;\r
- \r
+\r
/**\r
* Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the\r
* query, expecting a result list.\r
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
*/\r
public List<Map<String, Object>> query(String sql, Map<String, Object> parameters) throws SvcLogicException;\r
- \r
+\r
/**\r
* Issue an update via a prepared statement, binding the given arguments.\r
*\r
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the update\r
*/\r
public int update(String sql, Map<String, Object> parameters) throws SvcLogicException;\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.data.adaptor.dao;\r
public class NamedQueryExecutorDaoImpl implements NamedQueryExecutorDao {\r
private static EELFLogger logger = EELFManager.getInstance().getLogger(QueryExecutorDaoImpl.class);\r
private static final String CLASS_NAME = "NamedQueryExecutorDaoImpl";\r
- \r
+\r
@Autowired(required = true)\r
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;\r
- \r
+\r
public NamedQueryExecutorDaoImpl(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {\r
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;\r
logger.info("{} Constructor initialised..", CLASS_NAME);\r
}\r
- \r
+\r
@Override\r
public List<Map<String, Object>> query(String sql, Map<String, Object> parameters) throws SvcLogicException {\r
logger.debug("Query ({}) with parameters ({})", sql, parameters);\r
return namedParameterJdbcTemplate.queryForList(sql, parameters);\r
}\r
- \r
+\r
@Override\r
public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() {\r
return namedParameterJdbcTemplate;\r
}\r
- \r
+\r
@Override\r
public int update(String sql, Map<String, Object> parameters) throws SvcLogicException {\r
logger.debug("update ({}) with parameters ({})", sql, parameters);\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.data.adaptor.dao;\r
import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
\r
public interface QueryExecutorDao {\r
- \r
+\r
/**\r
* Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the\r
* query, expecting a result list.\r
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
*/\r
public List<Map<String, Object>> query(String sql, Object[] data) throws SvcLogicException;\r
- \r
+\r
/**\r
* Issue a single SQL update operation (such as an insert, update or delete statement) via a\r
* prepared statement, binding the given arguments.\r
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the update\r
*/\r
public int update(String sql, Object[] data) throws SvcLogicException;\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.data.adaptor.dao;\r
import com.att.eelf.configuration.EELFManager;\r
\r
public class QueryExecutorDaoImpl implements QueryExecutorDao {\r
- \r
+\r
private static EELFLogger logger = EELFManager.getInstance().getLogger(QueryExecutorDaoImpl.class);\r
private static final String CLASS_NAME = "QueryExecutorDaoImpl";\r
- \r
+\r
@Autowired(required = true)\r
private JdbcTemplate jdbcTemplate;\r
- \r
+\r
public QueryExecutorDaoImpl(JdbcTemplate jdbcTemplate) {\r
this.jdbcTemplate = jdbcTemplate;\r
logger.info("{} Constructor initialised..", CLASS_NAME);\r
}\r
- \r
+\r
@Override\r
public List<Map<String, Object>> query(String sql, Object[] data) throws SvcLogicException {\r
logger.debug("Query ({}) with data ({})", sql, data);\r
return jdbcTemplate.queryForList(sql, data);\r
}\r
- \r
+\r
@Override\r
public int update(String sql, Object[] data) throws SvcLogicException {\r
logger.debug("Query ({}) with data ({})", sql, data);\r
return jdbcTemplate.update(sql, data);\r
}\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.data.adaptor.dao;\r
import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
\r
public interface TransactionLogDao {\r
- \r
+\r
/**\r
* Issue a single SQL Insert operation for CONFIG_TRANSACTION_LOG table via a prepared statement,\r
* binding the given arguments.\r
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the insert\r
*/\r
public void save(TransactionLog transactionLog) throws SvcLogicException;\r
- \r
+\r
/**\r
* Query CONFIG_TRANSACTION_LOG table for given request_id, mapping each row to a Java object via a\r
* TransactionLog RowMapper.\r
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
*/\r
public List<TransactionLog> getTransactionsByRequestId(String requestId) throws SvcLogicException;\r
- \r
+\r
/**\r
* Query CONFIG_TRANSACTION_LOG table for given request_id, mapping each row to a Java object via a\r
* TransactionLog RowMapper.\r
*/\r
public List<TransactionLog> getTransactionsByRequestId(String requestId, String messageType)\r
throws SvcLogicException;\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.data.adaptor.dao;\r
import com.att.eelf.configuration.EELFManager;\r
\r
public class TransactionLogDaoImpl implements TransactionLogDao {\r
- \r
+\r
private static EELFLogger logger = EELFManager.getInstance().getLogger(TransactionLogDaoImpl.class);\r
- \r
+\r
private JdbcTemplate jdbcTemplate;\r
- \r
+\r
public TransactionLogDaoImpl(JdbcTemplate jdbcTemplate) {\r
this.jdbcTemplate = jdbcTemplate;\r
}\r
- \r
+\r
@Override\r
public void save(TransactionLog transactionLog) throws SvcLogicException {\r
if (transactionLog != null && StringUtils.isNotBlank(transactionLog.getRequestId())) {\r
transactionLog.getMessageType(), transactionLog.getMessage());\r
logger.trace("TransactionLog Updated Successfully for message_type {}", transactionLog.getMessageType());\r
}\r
- \r
+\r
}\r
- \r
+\r
@Override\r
public List<TransactionLog> getTransactionsByRequestId(String requestId) throws SvcLogicException {\r
if (StringUtils.isNotBlank(requestId)) {\r
throw new SvcLogicException("TransactionLog Request id (" + requestId + ")is missing ");\r
}\r
}\r
- \r
+\r
@Override\r
public List<TransactionLog> getTransactionsByRequestId(String requestId, String messageType)\r
throws SvcLogicException {\r
throw new SvcLogicException("TransactionLog Request id (" + requestId + ")is missing ");\r
}\r
}\r
- \r
+\r
private static final class TransactionLogMapper implements RowMapper<TransactionLog> {\r
@Override\r
public TransactionLog mapRow(ResultSet rs, int rowNum) throws SQLException {\r
return transactionLog;\r
}\r
}\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.data.adaptor.db;\r
import com.att.eelf.configuration.EELFManager;\r
\r
public class DataSourceWrap implements DataSource {\r
- \r
+\r
private static EELFLogger logger = EELFManager.getInstance().getLogger(DataSourceWrap.class);\r
- \r
+\r
private DataSource dataSource;\r
- \r
+\r
public DataSourceWrap(DataSource dataSource) {\r
logger.info("Setting Data Source {} ", dataSource);\r
this.dataSource = dataSource;\r
}\r
- \r
+\r
@Override\r
public PrintWriter getLogWriter() throws SQLException {\r
return dataSource.getLogWriter();\r
}\r
- \r
+\r
@Override\r
public void setLogWriter(PrintWriter out) throws SQLException {\r
dataSource.setLogWriter(out);\r
}\r
- \r
+\r
@Override\r
public void setLoginTimeout(int seconds) throws SQLException {\r
dataSource.setLoginTimeout(seconds);\r
}\r
- \r
+\r
@Override\r
public int getLoginTimeout() throws SQLException {\r
return dataSource.getLoginTimeout();\r
}\r
- \r
+\r
@Override\r
public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException {\r
return dataSource.getParentLogger();\r
}\r
- \r
+\r
@Override\r
public <T> T unwrap(Class<T> iface) throws SQLException {\r
return dataSource.unwrap(iface);\r
}\r
- \r
+\r
@Override\r
public boolean isWrapperFor(Class<?> iface) throws SQLException {\r
return dataSource.isWrapperFor(iface);\r
}\r
- \r
+\r
@SuppressWarnings("squid:S2095")\r
@Override\r
public Connection getConnection() throws SQLException {\r
c.setAutoCommit(true);\r
return c;\r
}\r
- \r
+\r
@SuppressWarnings("squid:S2095")\r
@Override\r
public Connection getConnection(String username, String pass) throws SQLException {\r
c.setAutoCommit(true);\r
return c;\r
}\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.data.adaptor.domain;\r
\r
public class ConfigPropertyMapData implements Serializable {\r
private static final long serialVersionUID = 1L;\r
- \r
+\r
private String referenceKey;\r
private String referenceValue;\r
- \r
+\r
public String getReferenceKey() {\r
return referenceKey;\r
}\r
- \r
+\r
public void setReferenceKey(String referenceKey) {\r
this.referenceKey = referenceKey;\r
}\r
- \r
+\r
public String getReferenceValue() {\r
return referenceValue;\r
}\r
- \r
+\r
public void setReferenceValue(String referenceValue) {\r
this.referenceValue = referenceValue;\r
}\r
- \r
+\r
@Override\r
public String toString() {\r
return "ConfigPropertyMapData [referenceKey=" + referenceKey + ", referenceValue=" + referenceValue + "]";\r
}\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.data.adaptor.domain;\r
*\r
*/\r
private static final long serialVersionUID = 1L;\r
- \r
+\r
private String configResourceId;\r
private String resourceId;\r
private String resourceType;\r
private String status;\r
private String updatedBy;\r
private List<ResourceAssignmentData> resourceAssignments;\r
- \r
+\r
public String getConfigResourceId() {\r
return configResourceId;\r
}\r
- \r
+\r
public void setConfigResourceId(String configResourceId) {\r
this.configResourceId = configResourceId;\r
}\r
- \r
+\r
public String getResourceId() {\r
return resourceId;\r
}\r
- \r
+\r
public void setResourceId(String resourceId) {\r
this.resourceId = resourceId;\r
}\r
- \r
+\r
public String getResourceType() {\r
return resourceType;\r
}\r
- \r
+\r
public void setResourceType(String resourceType) {\r
this.resourceType = resourceType;\r
}\r
- \r
+\r
public String getServiceTemplateName() {\r
return serviceTemplateName;\r
}\r
- \r
+\r
public void setServiceTemplateName(String serviceTemplateName) {\r
this.serviceTemplateName = serviceTemplateName;\r
}\r
- \r
+\r
public String getServiceTemplateVersion() {\r
return serviceTemplateVersion;\r
}\r
- \r
+\r
public void setServiceTemplateVersion(String serviceTemplateVersion) {\r
this.serviceTemplateVersion = serviceTemplateVersion;\r
}\r
- \r
+\r
public String getTemplateName() {\r
return templateName;\r
}\r
- \r
+\r
public void setTemplateName(String templateName) {\r
this.templateName = templateName;\r
}\r
- \r
+\r
public String getRecipeName() {\r
return recipeName;\r
}\r
- \r
+\r
public void setRecipeName(String recipeName) {\r
this.recipeName = recipeName;\r
}\r
- \r
+\r
public String getRequestId() {\r
return requestId;\r
}\r
- \r
+\r
public void setRequestId(String requestId) {\r
this.requestId = requestId;\r
}\r
- \r
+\r
public String getResourceData() {\r
return resourceData;\r
}\r
- \r
+\r
public void setResourceData(String resourceData) {\r
this.resourceData = resourceData;\r
}\r
- \r
+\r
public String getMaskData() {\r
return maskData;\r
}\r
- \r
+\r
public void setMaskData(String maskData) {\r
this.maskData = maskData;\r
}\r
- \r
+\r
public Date getCreatedDate() {\r
return createdDate;\r
}\r
- \r
+\r
public void setCreatedDate(Date createdDate) {\r
this.createdDate = createdDate;\r
}\r
- \r
+\r
public String getStatus() {\r
return status;\r
}\r
- \r
+\r
public void setStatus(String status) {\r
this.status = status;\r
}\r
- \r
+\r
public String getUpdatedBy() {\r
return updatedBy;\r
}\r
- \r
+\r
public void setUpdatedBy(String updatedBy) {\r
this.updatedBy = updatedBy;\r
}\r
- \r
+\r
public List<ResourceAssignmentData> getResourceAssignments() {\r
return resourceAssignments;\r
}\r
- \r
+\r
public void setResourceAssignments(List<ResourceAssignmentData> resourceAssignments) {\r
this.resourceAssignments = resourceAssignments;\r
}\r
- \r
+\r
@Override\r
public String toString() {\r
return "ConfigResource [configResourceId=" + configResourceId + ", resourceId=" + resourceId\r
+ ", requestId=" + requestId + ", resourceData= ******** , maskData=" + maskData + ", createdDate="\r
+ createdDate + ", updatedBy=" + updatedBy + "]";\r
}\r
- \r
+\r
public String getUniqueId() {\r
return UUID.randomUUID().toString();\r
}\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.data.adaptor.domain;\r
import java.util.UUID;\r
\r
public class ResourceAssignmentData implements Serializable {\r
- \r
+\r
private static final long serialVersionUID = 1L;\r
private String id;\r
private String configResourceId;\r
private String source;\r
private String status;\r
private String message;\r
- \r
+\r
public String getUniqueId() {\r
return UUID.randomUUID().toString();\r
}\r
- \r
+\r
@Override\r
public String toString() {\r
return "ResourceAssignmentData [id=" + id + ", configResourceId=" + configResourceId + ", version=" + version\r
+ ", resourceName=" + resourceName + ", dataType=" + dataType + ", source=" + source + ", status="\r
+ status + "]";\r
}\r
- \r
+\r
public String getId() {\r
return id;\r
}\r
- \r
+\r
public void setId(String id) {\r
this.id = id;\r
}\r
- \r
+\r
public String getConfigResourceId() {\r
return configResourceId;\r
}\r
- \r
+\r
public void setConfigResourceId(String configResourceId) {\r
this.configResourceId = configResourceId;\r
}\r
- \r
+\r
public Integer getVersion() {\r
return version;\r
}\r
- \r
+\r
public void setVersion(Integer version) {\r
this.version = version;\r
}\r
- \r
+\r
public Date getUpdatedDate() {\r
return updatedDate;\r
}\r
- \r
+\r
public void setUpdatedDate(Date updatedDate) {\r
this.updatedDate = updatedDate;\r
}\r
- \r
+\r
public String getUpdatedBy() {\r
return updatedBy;\r
}\r
- \r
+\r
public void setUpdatedBy(String updatedBy) {\r
this.updatedBy = updatedBy;\r
}\r
- \r
+\r
public String getTemplateKeyName() {\r
return templateKeyName;\r
}\r
- \r
+\r
public void setTemplateKeyName(String templateKeyName) {\r
this.templateKeyName = templateKeyName;\r
}\r
- \r
+\r
public String getResourceName() {\r
return resourceName;\r
}\r
- \r
+\r
public void setResourceName(String resourceName) {\r
this.resourceName = resourceName;\r
}\r
- \r
+\r
public String getDataType() {\r
return dataType;\r
}\r
- \r
+\r
public void setDataType(String dataType) {\r
this.dataType = dataType;\r
}\r
- \r
+\r
public String getEntrySchema() {\r
return entrySchema;\r
}\r
- \r
+\r
public void setEntrySchema(String entrySchema) {\r
this.entrySchema = entrySchema;\r
}\r
- \r
+\r
public String getResourceValue() {\r
return resourceValue;\r
}\r
- \r
+\r
public void setResourceValue(String resourceValue) {\r
this.resourceValue = resourceValue;\r
}\r
- \r
+\r
public String getSource() {\r
return source;\r
}\r
- \r
+\r
public void setSource(String source) {\r
this.source = source;\r
}\r
- \r
+\r
public String getStatus() {\r
return status;\r
}\r
- \r
+\r
public void setStatus(String status) {\r
this.status = status;\r
}\r
- \r
+\r
public String getMessage() {\r
return message;\r
}\r
- \r
+\r
public void setMessage(String message) {\r
this.message = message;\r
}\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.data.adaptor.domain;\r
\r
public class TransactionLog implements Serializable {\r
private static final long serialVersionUID = 1L;\r
- \r
+\r
private String transactionLogId;\r
private String requestId;\r
private String messageType;\r
private Date creationDate;\r
private String message;\r
- \r
+\r
public TransactionLog() {\r
- \r
+\r
}\r
- \r
+\r
public TransactionLog(String requestId, String messageType, String message) {\r
this.requestId = requestId;\r
this.messageType = messageType;\r
this.message = message;\r
}\r
- \r
+\r
@Override\r
public String toString() {\r
StringBuilder buffer = new StringBuilder("[");\r
buffer.append("]");\r
return buffer.toString();\r
}\r
- \r
+\r
public String getTransactionLogId() {\r
return transactionLogId;\r
}\r
- \r
+\r
public void setTransactionLogId(String transactionLogId) {\r
this.transactionLogId = transactionLogId;\r
}\r
- \r
+\r
public String getRequestId() {\r
return requestId;\r
}\r
- \r
+\r
public void setRequestId(String requestId) {\r
this.requestId = requestId;\r
}\r
- \r
+\r
public String getMessageType() {\r
return messageType;\r
}\r
- \r
+\r
public void setMessageType(String messageType) {\r
this.messageType = messageType;\r
}\r
- \r
+\r
public Date getCreationDate() {\r
return creationDate;\r
}\r
- \r
+\r
public void setCreationDate(Date creationDate) {\r
this.creationDate = creationDate;\r
}\r
- \r
+\r
public String getMessage() {\r
return message;\r
}\r
- \r
+\r
public void setMessage(String message) {\r
this.message = message;\r
}\r
- \r
+\r
public String getUniqueId() {\r
return UUID.randomUUID().toString();\r
}\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.data.adaptor.service;\r
import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;\r
\r
public class ConfigResourceNode implements SvcLogicJavaPlugin {\r
- \r
+\r
private ConfigResourceService configResourceService;\r
- \r
+\r
public ConfigResourceNode(ConfigResourceService configResourceService) {\r
this.configResourceService = configResourceService;\r
}\r
- \r
+\r
public void saveConfigTransactionLog(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {\r
String responsePrefix = inParams.get(DataAdaptorConstants.INPUT_PARAM_RESPONSE_PRIFIX);\r
try {\r
responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";\r
- \r
+\r
String messageType = inParams.get(DataAdaptorConstants.INPUT_PARAM_MESSAGE_TYPE);\r
String message = inParams.get(DataAdaptorConstants.INPUT_PARAM_MESSAGE);\r
String requestId = ctx.getAttribute("request-id");\r
- \r
+\r
TransactionLog transactionLog = new TransactionLog();\r
- \r
+\r
transactionLog.setMessage(message);\r
transactionLog.setMessageType(messageType);\r
transactionLog.setRequestId(requestId);\r
- \r
+\r
configResourceService.save(transactionLog);\r
- \r
+\r
} catch (Exception e) {\r
ctx.setAttribute(responsePrefix + DataAdaptorConstants.OUTPUT_PARAM_STATUS,\r
DataAdaptorConstants.OUTPUT_STATUS_FAILURE);\r
throw new SvcLogicException("Failed in saveConfigTransactionLog :" + e.getMessage());\r
}\r
}\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.data.adaptor.service;\r
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;\r
\r
public interface ConfigResourceService {\r
- \r
+\r
/**\r
* Return NamedParameterJdbcTemplate object.\r
*/\r
public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() throws SvcLogicException;\r
- \r
+\r
/**\r
* Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the\r
* query, expecting a result list.\r
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
*/\r
public List<Map<String, Object>> query(String sql, Map<String, Object> param) throws SvcLogicException;\r
- \r
+\r
/**\r
* Issue an update via a prepared statement, binding the given arguments.\r
*\r
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the update\r
*/\r
public int update(String sql, Map<String, Object> param) throws SvcLogicException;\r
- \r
+\r
/**\r
* Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the\r
* query, expecting a result list.\r
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
*/\r
public List<Map<String, Object>> query(String sql, Object[] data) throws SvcLogicException;\r
- \r
+\r
/**\r
* Issue a single SQL update operation (such as an insert, update or delete statement) via a\r
* prepared statement, binding the given arguments.\r
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the update\r
*/\r
public int update(String sql, Object[] data) throws SvcLogicException;\r
- \r
+\r
/**\r
* Issue a single SQL Insert operation for CONFIG_TRANSACTION_LOG table via a prepared statement,\r
* binding the given arguments.\r
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the insert\r
*/\r
public void save(TransactionLog transactionLog) throws SvcLogicException;\r
- \r
+\r
/**\r
* Query CONFIG_TRANSACTION_LOG table for given request_id, mapping each row to a Java object via a\r
* TransactionLog RowMapper.\r
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
*/\r
public List<TransactionLog> getTransactionsByRequestId(String requestId) throws SvcLogicException;\r
- \r
+\r
/**\r
* Query CONFIG_RESOURCE table for given input param to create a prepared statement to bind to the\r
* query, mapping each row to a Java object via a ConfigResource RowMapper.\r
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
*/\r
public List<ConfigResource> getConfigResource(ConfigResource configResource) throws SvcLogicException;\r
- \r
+\r
/**\r
* Issue a single SQL update operation (insert or update statement) for CONFIG_RESOURCE table via a\r
* prepared statement, binding the given arguments.\r
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the insert\r
*/\r
public ConfigResource saveConfigResource(ConfigResource configResource) throws SvcLogicException;\r
- \r
+\r
/**\r
* Query ConcurrentHashMap having CONFIG_PROPERTY_MAP table data for given key.\r
*\r
* @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if fails\r
*/\r
public String getConfigPropertyByKey(String key) throws SvcLogicException;\r
- \r
+\r
/**\r
* Query CONFIG_TRANSACTION_LOG table for given request_id, mapping each row to a Java object via a\r
* TransactionLog RowMapper.\r
*/\r
public List<TransactionLog> getTransactionsByRequestId(String requestId, String messageType)\r
throws SvcLogicException;\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.data.adaptor.service;\r
public class ConfigResourceServiceImpl implements ConfigResourceService {\r
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigResourceServiceImpl.class);\r
private static final String CLASS_NAME = "ConfigResourceServiceImpl";\r
- \r
+\r
private TransactionLogDao transactionLogDao;\r
private ConfigResourceDao configResourceDao;\r
private QueryExecutorDao queryExecutorDao;\r
private NamedQueryExecutorDao namedQueryExecutorDao;\r
private ConfigPropertyMapDao configPropertyMapDao;\r
- \r
+\r
@SuppressWarnings("squid:S00107")\r
public ConfigResourceServiceImpl(TransactionLogDao transactionLogDao, ConfigResourceDao configResourceDao,\r
QueryExecutorDao queryExecutorDao, NamedQueryExecutorDao namedQueryExecutorDao,\r
ConfigPropertyMapDao configPropertyMapDao) {\r
- \r
+\r
logger.info("{} Constuctor Initated...", CLASS_NAME);\r
this.transactionLogDao = transactionLogDao;\r
this.configResourceDao = configResourceDao;\r
this.namedQueryExecutorDao = namedQueryExecutorDao;\r
this.configPropertyMapDao = configPropertyMapDao;\r
}\r
- \r
+\r
@Override\r
public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() throws SvcLogicException {\r
return namedQueryExecutorDao.getNamedParameterJdbcTemplate();\r
}\r
- \r
+\r
@Override\r
public List<Map<String, Object>> query(String sql, Map<String, Object> parameters) throws SvcLogicException {\r
return namedQueryExecutorDao.query(sql, parameters);\r
}\r
- \r
+\r
@Override\r
public int update(String sql, Map<String, Object> parameters) throws SvcLogicException {\r
return namedQueryExecutorDao.update(sql, parameters);\r
}\r
- \r
+\r
@Override\r
public List<Map<String, Object>> query(String sql, Object[] data) throws SvcLogicException {\r
return queryExecutorDao.query(sql, data);\r
}\r
- \r
+\r
@Override\r
public int update(String sql, Object[] data) throws SvcLogicException {\r
return queryExecutorDao.update(sql, data);\r
}\r
- \r
+\r
@Override\r
public void save(TransactionLog transactionLog) throws SvcLogicException {\r
transactionLogDao.save(transactionLog);\r
}\r
- \r
+\r
@Override\r
public List<TransactionLog> getTransactionsByRequestId(String requestId) throws SvcLogicException {\r
return transactionLogDao.getTransactionsByRequestId(requestId);\r
}\r
- \r
+\r
@Override\r
public List<TransactionLog> getTransactionsByRequestId(String requestId, String messageType)\r
throws SvcLogicException {\r
return transactionLogDao.getTransactionsByRequestId(requestId, messageType);\r
}\r
- \r
+\r
@Override\r
public List<ConfigResource> getConfigResource(ConfigResource configResource) throws SvcLogicException {\r
return configResourceDao.findByConfigResource(configResource);\r
}\r
- \r
+\r
@Override\r
public ConfigResource saveConfigResource(ConfigResource configResource) throws SvcLogicException {\r
return configResourceDao.save(configResource);\r
}\r
- \r
+\r
@Override\r
public String getConfigPropertyByKey(String key) throws SvcLogicException {\r
return configPropertyMapDao.getConfigPropertyByKey(key);\r
}\r
- \r
+\r
}\r
<?xml version="1.0" encoding="UTF-8"?>\r
<!--\r
Copyright © 2017-2018 AT&T Intellectual Property.\r
+ Modifications Copyright © 2018 IBM.\r
\r
Licensed under the Apache License, Version 2.0 (the "License");\r
you may not use this file except in compliance with the License.\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.data.adaptor.dao;\r
@ContextConfiguration(locations = {"classpath:test-context-h2db.xml"})\r
@FixMethodOrder(MethodSorters.NAME_ASCENDING)\r
public class ConfigPropertyMapDaoTest {\r
- \r
+\r
@Autowired\r
private ConfigPropertyMapDao configPropertyMapDao;\r
- \r
+\r
@Autowired\r
private QueryExecutorDao queryExecutorDao;\r
- \r
+\r
@Test\r
public void testConfigResourcesData() throws Exception {\r
String sql = "INSERT INTO CONFIG_PROPERTY_MAP (reference_key, reference_value) VALUES ( ?, ?)";\r
Object[] data = new Object[] {"dummy123", "username123"};\r
int result = queryExecutorDao.update(sql, data);\r
Assert.assertNotNull("Failed to get Query Result", result);\r
- \r
+\r
String propKeyValye = configPropertyMapDao.getConfigPropertyByKey("org.onap.ccsdk.config.rest.adaptors.test");\r
Assert.assertNull("propKeyValue is null", propKeyValye);\r
}\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.data.adaptor.dao;\r
@ContextConfiguration(locations = {"classpath:test-context-h2db.xml"})\r
@FixMethodOrder(MethodSorters.NAME_ASCENDING)\r
public class ConfigResourceDaoTest {\r
- \r
+\r
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigResourceDaoTest.class);\r
- \r
+\r
@Autowired\r
private ConfigResourceDao configResourceDao;\r
- \r
+\r
@Before\r
public void initialise() {\r
- \r
+\r
}\r
- \r
+\r
@Test\r
public void testAssignmentResourceData() throws Exception {\r
ConfigResource configResource = new ConfigResource();\r
String resourceData = IOUtils.toString(\r
ConfigResourceDaoTest.class.getClassLoader().getResourceAsStream("reference/resource_data.json"),\r
Charset.defaultCharset());\r
- \r
+\r
logger.trace("resourceData = " + resourceData);\r
configResource.setResourceData(resourceData);\r
configResource.setServiceTemplateName("sample-name");\r
configResource.setStatus("success");\r
configResource.setCreatedDate(new Date(System.currentTimeMillis()));\r
configResource.setUpdatedBy("an188a");\r
- \r
+\r
List<ResourceAssignmentData> resourceAssignments = new ArrayList<>();\r
ResourceAssignmentData resourceAssignmentData = new ResourceAssignmentData();\r
resourceAssignmentData.setDataType("string");\r
resourceAssignmentData.setSource("input");\r
resourceAssignments.add(resourceAssignmentData);\r
configResource.setResourceAssignments(resourceAssignments);\r
- \r
+\r
ConfigResource dbConfigResource = configResourceDao.save(configResource);\r
logger.info("Saved sucessfully : " + dbConfigResource.toString());\r
Assert.assertNotNull("ConfigResource is null", dbConfigResource);\r
Assert.assertEquals("Resource Assignment Data count missmatch", true,\r
dbConfigResource.getResourceAssignments().size() > 0);\r
}\r
- \r
+\r
@Test\r
public void testConfigResourcesData() throws Exception {\r
ConfigResource configResourceInput = new ConfigResource();\r
List<ConfigResource> dbConfigResources = configResourceDao.findByConfigResource(configResourceInput);\r
Assert.assertNotNull("ConfigResources is null", dbConfigResources);\r
Assert.assertEquals("ConfigResources size missmatch", true, dbConfigResources.size() > 0);\r
- \r
+\r
for (ConfigResource configResource : dbConfigResources) {\r
Assert.assertNotNull("ConfigResources Assignments is null", configResource.getResourceAssignments());\r
Assert.assertTrue("ConfigResources Assignments size miss mathch ",\r
logger.trace("ResourceAssignments = " + configResource.getResourceAssignments());\r
}\r
}\r
- \r
+\r
@Test\r
public void testDeleteByConfigResource() throws Exception {\r
ConfigResource configResourceInput = new ConfigResource();\r
configResourceInput.setResourceId("123456");\r
- \r
+\r
List<ConfigResource> dbConfigResources = configResourceDao.findByConfigResource(configResourceInput);\r
Assert.assertTrue("ConfigResources is null", !dbConfigResources.isEmpty());\r
- \r
+\r
configResourceInput.setConfigResourceId(dbConfigResources.get(0).getConfigResourceId());\r
configResourceDao.deleteByConfigResource(configResourceInput);\r
- \r
+\r
dbConfigResources = configResourceDao.findByConfigResource(configResourceInput);\r
Assert.assertTrue("ConfigResources is not null", dbConfigResources.isEmpty());\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.data.adaptor.dao;\r
@FixMethodOrder(MethodSorters.NAME_ASCENDING)\r
public class ConfigTransactionLogDaoTest {\r
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigTransactionLogDaoTest.class);\r
- \r
+\r
@Autowired\r
private TransactionLogDao transactionLogDao;\r
- \r
+\r
@Autowired\r
private NamedQueryExecutorDao namedQueryExecutorDao;\r
- \r
+\r
@Before\r
public void initialise() {\r
- \r
+\r
}\r
- \r
+\r
@Test\r
public void testQueryExecution() throws Exception {\r
String requestId = "12345";\r
- \r
+\r
transactionLogDao\r
.save(new TransactionLog(requestId, DataAdaptorConstants.LOG_MESSAGE_TYPE_LOG, "Received Request"));\r
- \r
+\r
List<TransactionLog> result = transactionLogDao.getTransactionsByRequestId(requestId);\r
logger.info("DB ArtifactReference :" + result);\r
Assert.assertNotNull("Failed to get Query Result", result);\r
- \r
+\r
List<TransactionLog> result2 =\r
transactionLogDao.getTransactionsByRequestId(requestId, DataAdaptorConstants.LOG_MESSAGE_TYPE_LOG);\r
logger.info("DB ArtifactReference :" + result2);\r
Assert.assertNotNull("Failed to get Query Result", result2);\r
- \r
+\r
String namedsql = "SELECT * FROM CONFIG_TRANSACTION_LOG WHERE request_id = :request_id";\r
Map<String, Object> parameters = new HashMap<>();\r
parameters.put("request_id", "12345");\r
List<Map<String, Object>> namedresult = namedQueryExecutorDao.query(namedsql, parameters);\r
logger.info("DB ArtifactReference :" + namedresult);\r
Assert.assertNotNull("Failed to get Query Result", namedresult);\r
- \r
+\r
}\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.data.adaptor.dao;\r
@FixMethodOrder(MethodSorters.NAME_ASCENDING)\r
public class QueryExecutorDaoTest {\r
private static EELFLogger logger = EELFManager.getInstance().getLogger(QueryExecutorDaoTest.class);\r
- \r
+\r
@Autowired\r
private QueryExecutorDao queryExecutorDao;\r
- \r
+\r
@Before\r
public void initialise() {\r
- \r
+\r
}\r
- \r
+\r
@Test\r
public void testInsertQueryExecution() throws Exception {\r
- \r
+\r
String sql = "INSERT INTO CONFIG_RESOURCE"\r
+ "(config_resource_id, resource_id, resource_type, template_name, recipe_name, request_id, resource_data, mask_data, created_date, updated_by) "\r
+ "VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";\r
logger.info("Updated successfully rows :" + result);\r
Assert.assertNotNull("Failed to get Query Result", result);\r
}\r
- \r
+\r
@Test\r
public void testUpdateQueryExecution() throws Exception {\r
- \r
+\r
String sql = "UPDATE CONFIG_RESOURCE set recipe_name=? where config_resource_id=?";\r
Object[] data = new Object[] {"vce-service-template", "12345"};\r
int result = queryExecutorDao.update(sql, data);\r
logger.info("Updated successfully rows :" + result);\r
Assert.assertNotNull("Failed to get Query Result", result);\r
}\r
- \r
+\r
@Test\r
public void testDeleteQueryExecution() throws Exception {\r
- \r
+\r
String sql = "DELETE FROM CONFIG_RESOURCE where config_resource_id=?";\r
Object[] data = new Object[] {"12345"};\r
int result = queryExecutorDao.update(sql, data);\r
logger.info("Updated successfully rows :" + result);\r
Assert.assertNotNull("Failed to get Query Result", result);\r
}\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.data.adaptor.service;\r
@RunWith(SpringJUnit4ClassRunner.class)\r
@ContextConfiguration(locations = {"classpath:test-context-h2db.xml"})\r
public class ConfigResourceNodeTest {\r
- \r
+\r
ConfigResourceNode configResourceNode;\r
- \r
+\r
ConfigResourceService configResourceService;\r
- \r
+\r
@Autowired\r
TransactionLogDao transactionLogDao;\r
- \r
+\r
@Autowired\r
ConfigResourceDao configResourceDao;\r
- \r
+\r
@Autowired\r
QueryExecutorDao queryExecutorDao;\r
- \r
+\r
@Autowired\r
NamedQueryExecutorDao namedQueryExecutorDao;\r
- \r
+\r
@Autowired\r
ConfigPropertyMapDao configPropertyMapDao;\r
- \r
+\r
@Before\r
public void before() {\r
configResourceService = new ConfigResourceServiceImpl(transactionLogDao, configResourceDao, queryExecutorDao,\r
namedQueryExecutorDao, configPropertyMapDao);\r
configResourceNode = new ConfigResourceNode(configResourceService);\r
}\r
- \r
+\r
@Test\r
public void testSaveConfigTransactionLog() throws Exception {\r
Map<String, String> inParams = new HashMap<>();\r
inParams.put(DataAdaptorConstants.INPUT_PARAM_MESSAGE, "message");\r
SvcLogicContext ctx = new SvcLogicContext();\r
ctx.setAttribute("request-id", "requestId12345");\r
- \r
+\r
configResourceNode.saveConfigTransactionLog(inParams, ctx);\r
- \r
+\r
Assert.assertTrue(!transactionLogDao.getTransactionsByRequestId("requestId12345").isEmpty());\r
}\r
- \r
+\r
@Test(expected = SvcLogicException.class)\r
public void testSaveConfigTransactionLogException() throws Exception {\r
configResourceNode = new ConfigResourceNode(null);\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.data.adaptor.service;\r
@RunWith(SpringJUnit4ClassRunner.class)\r
@ContextConfiguration(locations = {"classpath:test-context-h2db.xml"})\r
public class ConfigResourceServiceTest {\r
- \r
+\r
ConfigResourceService configResourceService;\r
- \r
+\r
@Autowired\r
TransactionLogDao transactionLogDao;\r
- \r
+\r
@Autowired\r
ConfigResourceDao configResourceDao;\r
- \r
+\r
@Autowired\r
QueryExecutorDao queryExecutorDao;\r
- \r
+\r
@Autowired\r
NamedQueryExecutorDao namedQueryExecutorDao;\r
- \r
+\r
@Autowired\r
ConfigPropertyMapDao configPropertyMapDao;\r
- \r
+\r
@Before\r
public void before() {\r
configResourceService = new ConfigResourceServiceImpl(transactionLogDao, configResourceDao, queryExecutorDao,\r
namedQueryExecutorDao, configPropertyMapDao);\r
}\r
- \r
+\r
@Test\r
public void testUpdate() throws Exception {\r
String sql = "INSERT INTO CONFIG_RESOURCE"\r
"resource-data", "mask-data", null, new Date(System.currentTimeMillis()), "ab1234"};\r
int result = configResourceService.update(sql, data);\r
Assert.assertTrue(result == 1);\r
- \r
+\r
sql = "SELECT * FROM CONFIG_RESOURCE WHERE config_resource_id = ?";\r
data = new Object[] {"54321"};\r
List<Map<String, Object>> queryResult = configResourceService.query(sql, data);\r
Assert.assertTrue(queryResult.size() == 1);\r
}\r
- \r
+\r
@Test\r
public void testSaveAndGetConfigResource() throws Exception {\r
ConfigResource configResource = new ConfigResource();\r
String resourceData = IOUtils.toString(\r
ConfigResourceDaoTest.class.getClassLoader().getResourceAsStream("reference/resource_data.json"),\r
Charset.defaultCharset());\r
- \r
+\r
configResource.setResourceData(resourceData);\r
configResource.setServiceTemplateName("sample-name");\r
configResource.setServiceTemplateVersion("1.0.0");\r
configResource.setStatus("success");\r
configResource.setCreatedDate(new Date(System.currentTimeMillis()));\r
configResource.setUpdatedBy("an188a");\r
- \r
+\r
List<ResourceAssignmentData> resourceAssignments = new ArrayList<>();\r
ResourceAssignmentData resourceAssignmentData = new ResourceAssignmentData();\r
resourceAssignmentData.setDataType("string");\r
resourceAssignmentData.setSource("input");\r
resourceAssignments.add(resourceAssignmentData);\r
configResource.setResourceAssignments(resourceAssignments);\r
- \r
+\r
// save\r
ConfigResource dbConfigResource = configResourceService.saveConfigResource(configResource);\r
Assert.assertNotNull("ConfigResource is null", dbConfigResource);\r
Assert.assertEquals("Resource Assignment Data count missmatch", true,\r
dbConfigResource.getResourceAssignments().size() > 0);\r
Assert.assertEquals(configResource.getServiceTemplateVersion(), dbConfigResource.getServiceTemplateVersion());\r
- \r
+\r
// update\r
configResource.setServiceTemplateVersion("1.0.1");\r
dbConfigResource = configResourceService.saveConfigResource(configResource);\r
Assert.assertEquals("Resource Assignment Data count missmatch", true,\r
dbConfigResource.getResourceAssignments().size() > 0);\r
Assert.assertEquals(configResource.getServiceTemplateVersion(), dbConfigResource.getServiceTemplateVersion());\r
- \r
+\r
// find\r
ConfigResource configResourceInput = new ConfigResource();\r
configResourceInput.setResourceId(configResource.getResourceId());\r
List<ConfigResource> dbConfigResources = configResourceService.getConfigResource(configResourceInput);\r
Assert.assertNotNull("ConfigResources is null", dbConfigResources);\r
Assert.assertEquals("ConfigResources size missmatch", true, dbConfigResources.size() > 0);\r
- \r
+\r
for (ConfigResource dbConfigResouce : dbConfigResources) {\r
Assert.assertNotNull("ConfigResources Assignments is null", dbConfigResouce.getResourceAssignments());\r
Assert.assertTrue("ConfigResources Assignments size miss mathch ",\r
dbConfigResouce.getResourceAssignments().size() > 0);\r
}\r
}\r
- \r
+\r
@Test\r
public void testSaveAndGetTransactionLog() throws Exception {\r
TransactionLog transactionLog = new TransactionLog();\r
transactionLog.setMessage("message");\r
transactionLog.setMessageType("messageType");\r
transactionLog.setRequestId("requestId");\r
- \r
+\r
configResourceService.save(transactionLog);\r
- \r
+\r
List<TransactionLog> transactions =\r
configResourceService.getTransactionsByRequestId(transactionLog.getRequestId());\r
Assert.assertTrue(transactions.size() == 1);\r
transactionLog.getMessageType());\r
Assert.assertTrue(transactions.size() == 1);\r
}\r
- \r
+\r
@Test\r
public void testNamedQueryExecutorUpdateNQuery() throws Exception {\r
Map<String, Object> parameters = new HashMap<>();\r
configResourceService.update(\r
"INSERT INTO CONFIG_TRANSACTION_LOG ( config_transaction_log_id, request_id, message_type, message ) VALUES (:config_transaction_log_id, :request_id, :message_type, :message) ",\r
parameters);\r
- \r
+\r
List<Map<String, Object>> result = configResourceService\r
.query("SELECT * FROM CONFIG_TRANSACTION_LOG WHERE request_id = :request_id", parameters);\r
- \r
+\r
Assert.assertTrue(!result.isEmpty());\r
Assert.assertNotNull(configResourceService.getNamedParameterJdbcTemplate());\r
}\r
-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
+###\r
+# Copyright © 2017-2018 AT&T Intellectual Property.\r
+# Modifications Copyright © 2018 IBM.\r
+# \r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+# \r
+# http://www.apache.org/licenses/LICENSE-2.0\r
+# \r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
+###\r
+log4j.rootLogger=INFO, A1\r
+log4j.appender.A1=org.apache.log4j.ConsoleAppender\r
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout\r
+log4j.appender.A1.layout.ConversionPattern=%d{ISO8601} %5p %t %X{UUID} %c{3}:%L - %m%n\r
+log4j.logger.org.hibernate=INFO\r
<?xml version="1.0" encoding="utf-8"?>\r
<!--\r
Copyright © 2017-2018 AT&T Intellectual Property.\r
+ Modifications Copyright © 2018 IBM.\r
\r
Licensed under the Apache License, Version 2.0 (the "License");\r
you may not use this file except in compliance with the License.\r
<?xml version="1.0" encoding="utf-8"?>\r
<!--\r
Copyright © 2017-2018 AT&T Intellectual Property.\r
+ Modifications Copyright © 2018 IBM.\r
\r
Licensed under the Apache License, Version 2.0 (the "License");\r
you may not use this file except in compliance with the License.\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.rest.adaptor;\r
\r
public class ConfigRestAdaptorConstants {\r
private ConfigRestAdaptorConstants() {\r
- \r
+\r
}\r
- \r
+\r
public static final String SDNC_ROOT_DIR_ENV_VAR_KEY = "SDNC_CONFIG_DIR";\r
public static final String REST_ADAPTOR_PROPERTIES_FILE_NAME = "config-rest-adaptor.properties";\r
public static final String PROXY_URL_KEY = "proxyUrl";\r
public static final String AAF_USERNAME_KEY = "aafUserName";\r
public static final String AAF_PSSWD_KEY = "aafPassword";\r
public static final String COMMON_SERVICE_VERSION_KEY = "commonServiceVersion";\r
- \r
+\r
public static final String PROPERTY_ENV_PROD = "field";\r
public static final String PROPERTY_ENV_SOLO = "solo";\r
- \r
+\r
public static final String REST_ADAPTOR_BASE_PROPERTY = "org.onap.ccsdk.config.rest.adaptors.";\r
public static final String REST_ADAPTOR_ENV_TYPE = "envtype";\r
public static final String REST_ADAPTOR_TYPE_GENERIC = "generic";\r
public static final String REST_ADAPTOR_TYPE_SSL = "ssl";\r
- \r
+\r
public static final String SSL_SERVICE_BASEURL = ".url";\r
public static final String SSL_SERVICE_APP = ".application";\r
public static final String SSL_SERVICE_TRUST = ".ssl.trust";\r
public static final String SSL_SERVICE_TRUST_PSSWD = ".ssl.trust.psswd";\r
public static final String SSL_SERVICE_KEY = ".ssl.key";\r
public static final String SSL_SERVICE_KEY_PSSWD = ".ssl.key.psswd";\r
- \r
+\r
public static final String SERVICE_TYPE_PROPERTY = ".type";\r
public static final String SERVICE_EANABLED_PROPERTY = ".enable";\r
public static final String SERVICE_ENV_PROPERTY = ".env";\r
public static final String SERVICE_PSSWD_PROPERTY = ".passwd";\r
public static final String SERVICE_CLIENTAUTH_PROPERTY = ".clientAuth";\r
public static final String SERVICE_AUTHORIZATION_PROPERTY = ".authorization";\r
- \r
+\r
public static final String SELECTOR_AAI = "aai";\r
public static final String SELECTOR_ALTS = "alts";\r
public static final String SELECTOR_EIPAM = "eipam";\r
public static final String SELECTOR_POLICY_MANAGER = "policymanager";\r
public static final String SELECTOR_NRD = "networkresourcediscovery";\r
public static final String SELECTOR_NSM = "nsm";\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.rest.adaptor;\r
* @version 1.0\r
*/\r
public class ConfigRestAdaptorException extends Exception {\r
- \r
+\r
/**\r
*\r
*/\r
private static final long serialVersionUID = 1L;\r
- \r
+\r
/**\r
* This is a ConfigRestAdaptorException constructor\r
*\r
public ConfigRestAdaptorException(String message) {\r
super(message);\r
}\r
- \r
+\r
/**\r
* This is a ConfigRestAdaptorException constructor\r
*\r
public ConfigRestAdaptorException(String message, Throwable cause) {\r
super(message, cause);\r
}\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.rest.adaptor.data;\r
import java.util.Map;\r
\r
public class RestResponse {\r
- \r
+\r
private String statusCode;\r
private String body;\r
private Map<String, String> parameters;\r
private Map<String, String> responseHeaders;\r
private Map<String, String> requestHeaders;\r
- \r
+\r
public String getStatusCode() {\r
return statusCode;\r
}\r
- \r
+\r
public void setStatusCode(String statusCode) {\r
this.statusCode = statusCode;\r
}\r
- \r
+\r
public String getBody() {\r
return body;\r
}\r
- \r
+\r
public void setBody(String body) {\r
this.body = body;\r
}\r
- \r
+\r
public Map<String, String> getParameters() {\r
return parameters;\r
}\r
- \r
+\r
public void setParameters(Map<String, String> parameters) {\r
this.parameters = parameters;\r
}\r
- \r
+\r
public Map<String, String> getResponseHeaders() {\r
return responseHeaders;\r
}\r
- \r
+\r
public void setResponseHeaders(Map<String, String> responseHeaders) {\r
this.responseHeaders = responseHeaders;\r
}\r
- \r
+\r
public Map<String, String> getRequestHeaders() {\r
return requestHeaders;\r
}\r
- \r
+\r
public void setRequestHeaders(Map<String, String> requestHeaders) {\r
this.requestHeaders = requestHeaders;\r
}\r
- \r
+\r
@Override\r
public String toString() {\r
return "RestResponse [statusCode=" + statusCode + ", body=" + body + ", parameters=" + parameters\r
+ ", responseHeaders=" + responseHeaders + ", requestHeaders=" + requestHeaders + "]";\r
}\r
- \r
+\r
}\r
import com.att.eelf.configuration.EELFManager;\r
\r
abstract class AbstractConfigRestClientAdapter implements ConfigRestClientServiceAdapter {\r
- \r
+\r
private static EELFLogger logger = EELFManager.getInstance().getLogger(AbstractConfigRestClientAdapter.class);\r
private static final String MS_INIT_FAIL = "Failed to initialise microservice client restTemplate.";\r
- \r
+\r
protected boolean isRestClientServiceAdapaterEnabled = false;\r
protected boolean isSSLServiceAdapaterEnabled = true;\r
- \r
+\r
protected Map<String, String> properties = new ConcurrentHashMap<>();\r
protected String serviceSelector;\r
- \r
+\r
protected RestTemplate restTemplate;\r
- \r
+\r
protected AbstractConfigRestClientAdapter(Map<String, String> properties, String serviceSelector) {\r
this.properties = properties;\r
this.serviceSelector = serviceSelector;\r
setRestClientServiceAdapaterEnabled();\r
}\r
- \r
+\r
private void setRestClientServiceAdapaterEnabled() {\r
String isEnabledProperty = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector\r
+ ConfigRestAdaptorConstants.SERVICE_EANABLED_PROPERTY;\r
isRestClientServiceAdapaterEnabled = true;\r
}\r
}\r
- \r
+\r
private List<HttpMessageConverter<?>> getMessageConverters() {\r
List<HttpMessageConverter<?>> converters = new ArrayList<>();\r
converters.add(new ByteArrayHttpMessageConverter());\r
converters.add(new MappingJackson2HttpMessageConverter());\r
return converters;\r
}\r
- \r
+\r
public void initialise(String user, String pass) {\r
logger.trace("Config rest template factory user ({}) ", user);\r
- \r
+\r
CloseableHttpClient httpClient =\r
HttpClients.custom().setSSLHostnameVerifier(new NoopHostnameVerifier()).build();\r
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();\r
requestFactory.setHttpClient(httpClient);\r
- \r
+\r
restTemplate = new RestTemplate(getMessageConverters());\r
restTemplate.setRequestFactory(requestFactory);\r
if (StringUtils.isNotBlank(user) && StringUtils.isNotBlank(pass)) {\r
restTemplate.getInterceptors().add(new BasicAuthorizationInterceptor(user, pass));\r
}\r
}\r
- \r
+\r
public void initialiseSSL(String keyStorePath, String trustStorePath, String keyPass, String trustPass)\r
throws ConfigRestAdaptorException {\r
logger.trace("SSL rest template factory");\r
- \r
+\r
TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true;\r
SSLContext sslContext = null;\r
- \r
+\r
try (InputStream keyInput = new FileInputStream(keyStorePath)) {\r
KeyStore keyStore = KeyStore.getInstance("PKCS12");\r
keyStore.load(keyInput, keyPass.toCharArray());\r
- \r
+\r
logger.info("key loaded successfully");\r
sslContext = SSLContextBuilder.create().loadKeyMaterial(keyStore, keyPass.toCharArray()).loadTrustMaterial(\r
ResourceUtils.getFile(trustStorePath), trustPass.toCharArray(), acceptingTrustStrategy).build();\r
} catch (Exception e) {\r
throw new ConfigRestAdaptorException(e.getMessage());\r
}\r
- \r
+\r
SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext);\r
CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(csf).build();\r
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);\r
- \r
+\r
restTemplate = new RestTemplate(getMessageConverters());\r
restTemplate.setRequestFactory(requestFactory);\r
}\r
- \r
+\r
public <T> T getResource(HttpHeaders headers, String url, Class<T> responseType) throws ConfigRestAdaptorException {\r
ResponseEntity<T> response = exchangeForEntity(headers, url, HttpMethod.GET, null, responseType);\r
return processResponse(response, url, HttpMethod.GET);\r
}\r
- \r
+\r
public <T> T postResource(HttpHeaders headers, String url, Object request, Class<T> responseType)\r
throws ConfigRestAdaptorException {\r
ResponseEntity<T> response = exchangeForEntity(headers, url, HttpMethod.POST, request, responseType);\r
return processResponse(response, url, HttpMethod.POST);\r
}\r
- \r
+\r
public <T> T exchangeResource(HttpHeaders headers, String url, Object request, Class<T> responseType, String method)\r
throws ConfigRestAdaptorException {\r
ResponseEntity<T> response = exchangeForEntity(headers, url, HttpMethod.resolve(method), request, responseType);\r
return processResponse(response, url, HttpMethod.resolve(method));\r
}\r
- \r
+\r
public RestResponse getResource(HttpHeaders headers, String url) throws ConfigRestAdaptorException {\r
return exchangeForEntity(headers, url, HttpMethod.GET, null);\r
}\r
- \r
+\r
public RestResponse postResource(HttpHeaders headers, String url, Object request)\r
throws ConfigRestAdaptorException {\r
return exchangeForEntity(headers, url, HttpMethod.POST, request);\r
}\r
- \r
+\r
public RestResponse exchangeResource(HttpHeaders headers, String url, Object request, String method)\r
throws ConfigRestAdaptorException {\r
return exchangeForEntity(headers, url, HttpMethod.resolve(method), request);\r
}\r
- \r
+\r
private RestResponse exchangeForEntity(HttpHeaders headers, String url, HttpMethod httpMethod, Object request)\r
throws ConfigRestAdaptorException {\r
RestResponse restResponse = new RestResponse();\r
restResponse.setRequestHeaders(headers.toSingleValueMap());\r
ResponseEntity<String> response = null;\r
- \r
+\r
try {\r
if (restTemplate == null) {\r
logger.error(MS_INIT_FAIL);\r
logger.debug("url : ({})", url);\r
logger.debug("headers: ({})", headers);\r
logger.debug("request: ({})", request);\r
- \r
+\r
if (HttpMethod.GET == httpMethod) {\r
HttpEntity<String> entity = new HttpEntity<>("parameters", headers);\r
response = restTemplate.exchange(url, httpMethod, entity, String.class);\r
response = restTemplate.exchange(url, httpMethod, entity, String.class);\r
}\r
logger.debug("response: ({})", response);\r
- \r
+\r
if (response != null) {\r
logger.debug("response status code: ({})", response.getStatusCode());\r
restResponse.setBody(response.getBody());\r
}\r
return restResponse;\r
}\r
- \r
+\r
private <T> ResponseEntity<T> exchangeForEntity(HttpHeaders headers, String url, HttpMethod httpMethod,\r
Object request, Class<T> responseType) throws ConfigRestAdaptorException {\r
ResponseEntity<T> response = null;\r
- \r
+\r
try {\r
if (restTemplate == null) {\r
logger.error(MS_INIT_FAIL);\r
logger.debug("url : ({})", url);\r
logger.debug("headers: ({})", headers);\r
logger.debug("request: ({})", request);\r
- \r
+\r
if (HttpMethod.GET == httpMethod) {\r
HttpEntity<String> entity = new HttpEntity<>("parameters", headers);\r
response = restTemplate.exchange(url, httpMethod, entity, responseType);\r
response = restTemplate.exchange(url, httpMethod, entity, responseType);\r
}\r
logger.debug("response: ({})", response);\r
- \r
+\r
if (response != null) {\r
logger.debug("response status code: ({})", response.getStatusCode());\r
} else {\r
}\r
return response;\r
}\r
- \r
+\r
protected synchronized <T> T processResponse(ResponseEntity<T> response, String url, HttpMethod httpMethod)\r
throws ConfigRestAdaptorException {\r
if (response != null) {\r
}\r
throw new ConfigRestAdaptorException(String.format("Rest Operation is failed for the URL (%s)", url));\r
}\r
- \r
+\r
protected synchronized String constructUrl(String baseUrl, String path) {\r
if (StringUtils.isNotBlank(path)) {\r
return baseUrl + path;\r
return baseUrl;\r
}\r
}\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.rest.adaptor.service;\r
import org.onap.ccsdk.config.rest.adaptor.data.RestResponse;\r
\r
public interface ConfigRestAdaptorService {\r
- \r
+\r
/**\r
* Retrieve an entity by doing a GET on the specified URL. The response is converted and stored in\r
* defined responseType.\r
* @param responseType the type of the return value\r
*/\r
public <T> T getResource(String selectorName, String path, Class<T> responseType) throws ConfigRestAdaptorException;\r
- \r
+\r
/**\r
* Create a new resource by POSTing the given object to the URI template, and returns the response\r
* as defined responseType\r
*/\r
public <T> T postResource(String selectorName, String path, Object request, Class<T> responseType)\r
throws ConfigRestAdaptorException;\r
- \r
+\r
/**\r
* Execute the HTTP method to the given URI template, writing the given request entity to the\r
* request, and returns the response as defined responseType\r
*/\r
public <T> T exchangeResource(String selectorName, String path, Object request, Class<T> responseType,\r
String method) throws ConfigRestAdaptorException;\r
- \r
+\r
/**\r
* Retrieve an entity by doing a GET on the specified URL. The response is converted and stored in\r
* defined responseType.\r
* @param path the URI path which will append in baseURL mentioned in selector property\r
*/\r
public RestResponse getResource(String selectorName, String path) throws ConfigRestAdaptorException;\r
- \r
+\r
/**\r
* Create a new resource by POSTing the given object to the URI template, and returns the response\r
* as defined responseType\r
*/\r
public RestResponse postResource(String selectorName, String path, Object request)\r
throws ConfigRestAdaptorException;\r
- \r
+\r
/**\r
* Execute the HTTP method to the given URI template, writing the given request entity to the\r
* request, and returns the response as defined responseType\r
*/\r
public RestResponse exchangeResource(String selectorName, String path, Object request, String method)\r
throws ConfigRestAdaptorException;\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.rest.adaptor.service;\r
import com.att.eelf.configuration.EELFManager;\r
\r
public class ConfigRestAdaptorServiceImpl implements ConfigRestAdaptorService {\r
- \r
+\r
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigRestAdaptorServiceImpl.class);\r
private Map<String, String> restProperties = new ConcurrentHashMap<>();\r
- \r
+\r
public ConfigRestAdaptorServiceImpl(String propertyPath) {\r
initializeProperties(propertyPath);\r
try {\r
String envType = restProperties.get(ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY\r
+ ConfigRestAdaptorConstants.REST_ADAPTOR_ENV_TYPE);\r
- \r
+\r
if (!(ConfigRestAdaptorConstants.PROPERTY_ENV_PROD.equalsIgnoreCase(envType)\r
|| ConfigRestAdaptorConstants.PROPERTY_ENV_SOLO.equalsIgnoreCase(envType))) {\r
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);\r
logger.error(e.getMessage(), e);\r
}\r
}\r
- \r
+\r
private void initializeProperties(String propertyPath) {\r
logger.trace("Initialising Config rest adaptor Service with property directory ({})", propertyPath);\r
try {\r
if (StringUtils.isBlank(propertyPath)) {\r
propertyPath = System.getProperty(ConfigRestAdaptorConstants.SDNC_ROOT_DIR_ENV_VAR_KEY);\r
}\r
- \r
+\r
if (StringUtils.isBlank(propertyPath)) {\r
throw new ConfigRestAdaptorException(\r
String.format("Failed to get the property directory (%s)", propertyPath));\r
}\r
- \r
+\r
// Loading Default config-rest-adaptor.properties\r
String propertyFile =\r
propertyPath + File.separator + ConfigRestAdaptorConstants.REST_ADAPTOR_PROPERTIES_FILE_NAME;\r
- \r
+\r
Properties properties = new Properties();\r
properties.load(new FileInputStream(propertyFile));\r
- \r
+\r
logger.trace("Initializing properties details for property file ({}) properties ({})", propertyFile,\r
properties);\r
restProperties.putAll(properties.entrySet().stream()\r
.collect(Collectors.toMap(e -> e.getKey().toString(), e -> e.getValue().toString())));\r
- \r
+\r
} catch (Exception e) {\r
logger.error(e.getMessage(), e);\r
}\r
}\r
- \r
+\r
@Override\r
public <T> T getResource(String serviceSelector, String path, Class<T> responseType)\r
throws ConfigRestAdaptorException {\r
return getRestClientAdapterBySelectorName(serviceSelector).getResource(path, responseType);\r
}\r
- \r
+\r
@Override\r
public <T> T postResource(String serviceSelector, String path, Object request, Class<T> responseType)\r
throws ConfigRestAdaptorException {\r
return getRestClientAdapterBySelectorName(serviceSelector).postResource(path, request, responseType);\r
}\r
- \r
+\r
@Override\r
public <T> T exchangeResource(String serviceSelector, String path, Object request, Class<T> responseType,\r
String method) throws ConfigRestAdaptorException {\r
return getRestClientAdapterBySelectorName(serviceSelector).exchangeResource(path, request, responseType,\r
method);\r
}\r
- \r
+\r
@Override\r
public RestResponse getResource(String serviceSelector, String path) throws ConfigRestAdaptorException {\r
return getRestClientAdapterBySelectorName(serviceSelector).getResource(path);\r
}\r
- \r
+\r
@Override\r
public RestResponse postResource(String serviceSelector, String path, Object request)\r
throws ConfigRestAdaptorException {\r
return getRestClientAdapterBySelectorName(serviceSelector).postResource(path, request);\r
}\r
- \r
+\r
@Override\r
public RestResponse exchangeResource(String serviceSelector, String path, Object request, String method)\r
throws ConfigRestAdaptorException {\r
return getRestClientAdapterBySelectorName(serviceSelector).exchangeResource(path, request, method);\r
}\r
- \r
+\r
private ConfigRestClientServiceAdapter getRestClientAdapterBySelectorName(String serviceSelector)\r
throws ConfigRestAdaptorException {\r
String adoptorType = restProperties.get(ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector\r
String.format("couldn't get rest adoptor type for the selector (%s)", serviceSelector));\r
}\r
}\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.rest.adaptor.service;\r
import org.onap.ccsdk.config.rest.adaptor.data.RestResponse;\r
\r
interface ConfigRestClientServiceAdapter {\r
- \r
+\r
public <T> T getResource(String path, Class<T> responseType) throws ConfigRestAdaptorException;\r
- \r
+\r
public <T> T postResource(String path, Object request, Class<T> responseType) throws ConfigRestAdaptorException;\r
- \r
+\r
public <T> T exchangeResource(String path, Object request, Class<T> responseType, String method)\r
throws ConfigRestAdaptorException;\r
- \r
+\r
public RestResponse getResource(String path) throws ConfigRestAdaptorException;\r
- \r
+\r
public RestResponse postResource(String path, Object request) throws ConfigRestAdaptorException;\r
- \r
+\r
public RestResponse exchangeResource(String path, Object request, String method) throws ConfigRestAdaptorException;\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.rest.adaptor.service;\r
import com.att.eelf.configuration.EELFManager;\r
\r
public class GenericRestClientAdapterImpl extends AbstractConfigRestClientAdapter {\r
- \r
+\r
private static EELFLogger logger = EELFManager.getInstance().getLogger(GenericRestClientAdapterImpl.class);\r
private String baseUrl = "";\r
- \r
+\r
public GenericRestClientAdapterImpl(Map<String, String> properties, String serviceSelector)\r
throws ConfigRestAdaptorException {\r
super(properties, serviceSelector);\r
init(serviceSelector);\r
}\r
- \r
+\r
private void init(String serviceSelector) throws ConfigRestAdaptorException {\r
try {\r
if (isRestClientServiceAdapaterEnabled) {\r
+ ConfigRestAdaptorConstants.SERVICE_USER_PROPERTY;\r
String passProperty = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector\r
+ ConfigRestAdaptorConstants.SERVICE_PSSWD_PROPERTY;\r
- \r
+\r
baseUrl = properties.get(baseUrlProperty);\r
String userId = properties.get(userProperty);\r
String pass = properties.get(passProperty);\r
- \r
+\r
initialise(userId, pass);\r
logger.info("Initialised restconf adaptor service for selector ({})", serviceSelector);\r
if (restTemplate == null) {\r
} else {\r
throw new ConfigRestAdaptorException("rest selector (" + serviceSelector + ") is not enabled");\r
}\r
- \r
+\r
} catch (Exception e) {\r
throw new ConfigRestAdaptorException("GenericRestClientServiceAdapter : " + e.getMessage(), e);\r
}\r
}\r
- \r
+\r
@Override\r
public <T> T getResource(String path, Class<T> responseType) throws ConfigRestAdaptorException {\r
return super.getResource(formHttpHeaders(), constructUrl(baseUrl, path), responseType);\r
}\r
- \r
+\r
@Override\r
public <T> T postResource(String path, Object request, Class<T> responseType) throws ConfigRestAdaptorException {\r
return super.postResource(formHttpHeaders(), constructUrl(baseUrl, path), request, responseType);\r
}\r
- \r
+\r
@Override\r
public <T> T exchangeResource(String path, Object request, Class<T> responseType, String method)\r
throws ConfigRestAdaptorException {\r
return super.exchangeResource(formHttpHeaders(), constructUrl(baseUrl, path), request, responseType, method);\r
}\r
- \r
+\r
@Override\r
public RestResponse getResource(String path) throws ConfigRestAdaptorException {\r
return super.getResource(formHttpHeaders(), constructUrl(baseUrl, path));\r
}\r
- \r
+\r
@Override\r
public RestResponse postResource(String path, Object request) throws ConfigRestAdaptorException {\r
return super.postResource(formHttpHeaders(), constructUrl(baseUrl, path), request);\r
}\r
- \r
+\r
@Override\r
public RestResponse exchangeResource(String path, Object request, String method) throws ConfigRestAdaptorException {\r
return super.exchangeResource(formHttpHeaders(), constructUrl(baseUrl, path), request, method);\r
}\r
- \r
+\r
private HttpHeaders formHttpHeaders() {\r
- \r
+\r
HttpHeaders headers = new HttpHeaders();\r
- \r
+\r
headers.setContentType(MediaType.APPLICATION_JSON);\r
headers.add("Accept", MediaType.APPLICATION_JSON_VALUE);\r
headers.add("X-TransactionId", generateUUID());\r
headers.add("X-ECOMP-RequestID", headers.getFirst("X-TransactionId"));\r
- \r
+\r
String appIDPath = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector\r
+ ConfigRestAdaptorConstants.SERVICE_APPID_PROPERTY;\r
String environmentPath = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector\r
+ ConfigRestAdaptorConstants.SERVICE_CLIENTAUTH_PROPERTY;\r
String authorizationPath = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector\r
+ ConfigRestAdaptorConstants.SERVICE_AUTHORIZATION_PROPERTY;\r
- \r
+\r
if (StringUtils.isNotBlank(properties.get(appIDPath))) {\r
headers.add("X-FromAppId", properties.get(appIDPath));\r
}\r
if (StringUtils.isNotBlank(properties.get(environmentPath))) {\r
headers.add("Environment", properties.get(environmentPath));\r
}\r
- \r
+\r
return headers;\r
}\r
- \r
+\r
private synchronized String generateUUID() {\r
return UUID.randomUUID().toString();\r
}\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.rest.adaptor.service;\r
import com.att.eelf.configuration.EELFManager;\r
\r
public class SSLRestClientAdapterImpl extends AbstractConfigRestClientAdapter {\r
- \r
+\r
private static EELFLogger logger = EELFManager.getInstance().getLogger(SSLRestClientAdapterImpl.class);\r
private String baseUrl = "";\r
private String application = "";\r
- \r
+\r
public SSLRestClientAdapterImpl(Map<String, String> properties, String serviceSelector)\r
throws ConfigRestAdaptorException {\r
super(properties, serviceSelector);\r
init(serviceSelector);\r
}\r
- \r
+\r
private void init(String serviceSelector) throws ConfigRestAdaptorException {\r
try {\r
if (isSSLServiceAdapaterEnabled) {\r
- \r
+\r
logger.info("Initializing SSL client for selector ({}), properties ({})", serviceSelector, properties);\r
- \r
+\r
String baseUrlProp = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector\r
+ ConfigRestAdaptorConstants.SSL_SERVICE_BASEURL;\r
String applicationProp = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector\r
+ ConfigRestAdaptorConstants.SSL_SERVICE_TRUST;\r
String trustStorePassProp = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector\r
+ ConfigRestAdaptorConstants.SSL_SERVICE_TRUST_PSSWD;\r
- \r
+\r
baseUrl = properties.get(baseUrlProp);\r
application = properties.get(applicationProp);\r
- \r
+\r
String keyStorePath = properties.get(keyStorePathProp);\r
String trustStorePath = properties.get(trustStorePathProp);\r
String keyStorePass = properties.get(keyStorePassProp);\r
String trustStorePass = properties.get(trustStorePassProp);\r
- \r
+\r
initialiseSSL(keyStorePath, trustStorePath, keyStorePass, trustStorePass);\r
logger.info("Initialised SSL Client Service adaptor service for selector ({})", serviceSelector);\r
if (restTemplate == null) {\r
} else {\r
throw new ConfigRestAdaptorException("SSL Client selector (" + serviceSelector + ") is not enabled");\r
}\r
- \r
+\r
} catch (Exception e) {\r
throw new ConfigRestAdaptorException("SSLRestClientAdapterImpl : " + e.getMessage(), e);\r
}\r
}\r
- \r
+\r
@Override\r
public <T> T getResource(String path, Class<T> responseType) throws ConfigRestAdaptorException {\r
return super.getResource(formHttpHeaders(), constructUrl(baseUrl, path), responseType);\r
}\r
- \r
+\r
@Override\r
public <T> T postResource(String path, Object request, Class<T> responseType) throws ConfigRestAdaptorException {\r
return super.postResource(formHttpHeaders(), constructUrl(baseUrl, path), request, responseType);\r
}\r
- \r
+\r
@Override\r
public <T> T exchangeResource(String path, Object request, Class<T> responseType, String method)\r
throws ConfigRestAdaptorException {\r
return super.exchangeResource(formHttpHeaders(), constructUrl(baseUrl, path), request, responseType, method);\r
}\r
- \r
+\r
@Override\r
public RestResponse getResource(String path) throws ConfigRestAdaptorException {\r
return super.getResource(formHttpHeaders(), constructUrl(baseUrl, path));\r
}\r
- \r
+\r
@Override\r
public RestResponse postResource(String path, Object request) throws ConfigRestAdaptorException {\r
return super.postResource(formHttpHeaders(), constructUrl(baseUrl, path), request);\r
}\r
- \r
+\r
@Override\r
public RestResponse exchangeResource(String path, Object request, String method) throws ConfigRestAdaptorException {\r
return super.exchangeResource(formHttpHeaders(), constructUrl(baseUrl, path), request, method);\r
}\r
- \r
+\r
private HttpHeaders formHttpHeaders() {\r
- \r
+\r
HttpHeaders headers = new HttpHeaders();\r
- \r
+\r
headers.setContentType(MediaType.APPLICATION_JSON);\r
headers.add("Accept", MediaType.APPLICATION_JSON_VALUE);\r
headers.add("X-FromAppId", application);\r
headers.add("X-TransactionId", generateUUID());\r
- \r
+\r
return headers;\r
}\r
- \r
+\r
private synchronized String generateUUID() {\r
return UUID.randomUUID().toString();\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.rest.adaptor.utils;\r
\r
public class BasicAuthorizationInterceptor implements ClientHttpRequestInterceptor {\r
private static final Charset UTF_8 = Charset.forName("UTF-8");\r
- \r
+\r
private final String username;\r
- \r
+\r
private final String pass;\r
- \r
+\r
/**\r
* Create a new interceptor which adds a BASIC authorization header for the given username and pass.\r
*\r
this.username = username;\r
this.pass = (pass != null ? pass : "");\r
}\r
- \r
+\r
@Override\r
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)\r
throws IOException {\r
- \r
+\r
String token = Base64Utils.encodeToString((this.username + ":" + this.pass).getBytes(UTF_8));\r
request.getHeaders().add("Authorization", "Basic " + token);\r
return execution.execute(request, body);\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.rest.adaptor.utils;\r
import com.att.eelf.configuration.EELFManager;\r
\r
public class LoggingRequestInterceptor implements ClientHttpRequestInterceptor {\r
- \r
+\r
private static EELFLogger logger = EELFManager.getInstance().getLogger(LoggingRequestInterceptor.class);\r
- \r
+\r
@Override\r
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)\r
throws IOException {\r
traceResponse(response);\r
return response;\r
}\r
- \r
+\r
@SuppressWarnings({"squid:S2629", "squid:S3457"})\r
private void traceRequest(HttpRequest request, byte[] body) throws IOException {\r
logger.info("===========================request begin================================================");\r
logger.info("Request body: {}", new String(body, "UTF-8"));\r
logger.debug("==========================request end================================================");\r
}\r
- \r
+\r
@SuppressWarnings({"squid:S2629", "squid:S3457"})\r
private void traceResponse(ClientHttpResponse response) throws IOException {\r
StringBuilder inputStringBuilder = new StringBuilder();\r
logger.debug("Response body: {}", inputStringBuilder.toString());\r
logger.debug("=======================response end=================================================");\r
}\r
- \r
+\r
}\r
<?xml version="1.0" encoding="UTF-8"?>\r
<!--\r
Copyright © 2017-2018 AT&T Intellectual Property.\r
+ Modifications Copyright © 2018 IBM.\r
\r
Licensed under the Apache License, Version 2.0 (the "License");\r
you may not use this file except in compliance with the License.\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.rest.adaptor.service;\r
import org.junit.Test;\r
\r
public class AbstractConfigRestClientAdapterTest {\r
- \r
+\r
Map<String, String> properties = new HashMap<>();\r
- \r
+\r
@Before\r
public void setup() throws Exception {\r
String propertyfile = "src/test/resources/config-rest-adaptor.properties";\r
- \r
+\r
Properties restProperties = new Properties();\r
restProperties.load(new FileInputStream(propertyfile));\r
- \r
+\r
properties.putAll(restProperties.entrySet().stream()\r
.collect(Collectors.toMap(e -> e.getKey().toString(), e -> e.getValue().toString())));\r
}\r
- \r
+\r
@Test\r
public void testInitGenericRestClient() throws Exception {\r
ConfigRestClientServiceAdapter genericRestClient = new GenericRestClientAdapterImpl(properties, "modelservice");\r
Assert.assertNotNull(genericRestClient);\r
}\r
- \r
+\r
@Test\r
public void testInitSSLClient() throws Exception {\r
ConfigRestClientServiceAdapter sslClient = new SSLRestClientAdapterImpl(properties, "aai");\r
Assert.assertNotNull(sslClient);\r
}\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.rest.adaptor.service;\r
import org.junit.Test;\r
import org.junit.runner.RunWith;\r
import org.mockito.Matchers;\r
-import org.mockito.Mockito;\r
import org.onap.ccsdk.config.rest.adaptor.ConfigRestAdaptorException;\r
import org.powermock.core.classloader.annotations.PowerMockIgnore;\r
import org.powermock.core.classloader.annotations.PrepareForTest;\r
@PowerMockIgnore("javax.net.ssl.*")\r
@PrepareForTest({AbstractConfigRestClientAdapter.class})\r
public class GenericRestClientServiceTest {\r
- \r
+\r
ConfigRestAdaptorService configRestAdaptorService;\r
- \r
+\r
RestTemplate mockRestTemplate = mock(RestTemplate.class);\r
- \r
+\r
String path = "path";\r
- \r
+\r
@Before\r
public void before() throws Exception {\r
whenNew(RestTemplate.class).withAnyArguments().thenReturn(mockRestTemplate);\r
- \r
+\r
String propertyDir = "src/test/resources";\r
configRestAdaptorService = new ConfigRestAdaptorServiceImpl(propertyDir);\r
}\r
- \r
+\r
@Test\r
public void testGetResource() throws Exception {\r
String responseBody = "sampleBodyString";\r
ResponseEntity<Object> response = new ResponseEntity<Object>(responseBody, HttpStatus.OK);\r
when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.GET), Matchers.any(),\r
Matchers.any(Class.class))).thenReturn(response);\r
- \r
+\r
String body = configRestAdaptorService.getResource("modelservice", path, String.class);\r
- \r
+\r
Assert.assertEquals(responseBody, body);\r
}\r
- \r
+\r
@Test\r
public void testPostResource() throws Exception {\r
String responseBody = "sampleBodyString";\r
ResponseEntity<Object> response = new ResponseEntity<Object>(responseBody, HttpStatus.OK);\r
when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.POST), Matchers.any(),\r
Matchers.any(Class.class))).thenReturn(response);\r
- \r
+\r
String body = configRestAdaptorService.postResource("modelservice", path, null, String.class);\r
- \r
+\r
Assert.assertEquals(responseBody, body);\r
}\r
- \r
+\r
@Test\r
public void testExchange() throws Exception {\r
String responseBody = "sampleBodyString";\r
ResponseEntity<Object> response = new ResponseEntity<Object>(responseBody, HttpStatus.OK);\r
when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.GET), Matchers.any(),\r
Matchers.any(Class.class))).thenReturn(response);\r
- \r
+\r
String body = configRestAdaptorService.exchangeResource("modelservice", path, null, String.class, "GET");\r
- \r
+\r
Assert.assertEquals(responseBody, body);\r
}\r
- \r
+\r
@Test(expected = ConfigRestAdaptorException.class)\r
public void testGetResourceError() throws Exception {\r
ResponseEntity<Object> response = new ResponseEntity<Object>("", HttpStatus.INTERNAL_SERVER_ERROR);\r
when(mockRestTemplate.getForEntity(Matchers.endsWith(path), Matchers.any())).thenReturn(response);\r
- \r
+\r
configRestAdaptorService.getResource("modelservice", path, String.class);\r
}\r
- \r
+\r
@Test(expected = ConfigRestAdaptorException.class)\r
public void testPostResourceError() throws Exception {\r
ResponseEntity<Object> response = new ResponseEntity<Object>("", HttpStatus.INTERNAL_SERVER_ERROR);\r
when(mockRestTemplate.postForEntity(Matchers.endsWith(path), Matchers.anyObject(), Matchers.any()))\r
.thenReturn(response);\r
- \r
+\r
configRestAdaptorService.postResource("modelservice", path, null, String.class);\r
}\r
- \r
+\r
@Test(expected = ConfigRestAdaptorException.class)\r
public void testExchangeError() throws Exception {\r
ResponseEntity<Object> response = new ResponseEntity<Object>("", HttpStatus.INTERNAL_SERVER_ERROR);\r
when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.GET), Matchers.any(),\r
Matchers.any(Class.class))).thenReturn(response);\r
- \r
+\r
configRestAdaptorService.exchangeResource("modelservice", path, null, String.class, "GET");\r
}\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.rest.adaptor.service;\r
import org.junit.Test;\r
import org.junit.runner.RunWith;\r
import org.mockito.Matchers;\r
-import org.mockito.Mockito;\r
import org.onap.ccsdk.config.rest.adaptor.ConfigRestAdaptorException;\r
import org.powermock.core.classloader.annotations.PowerMockIgnore;\r
import org.powermock.core.classloader.annotations.PrepareForTest;\r
@PowerMockIgnore("javax.net.ssl.*")\r
@PrepareForTest({AbstractConfigRestClientAdapter.class})\r
public class SSLClientServiceTest {\r
- \r
+\r
ConfigRestAdaptorService configRestAdaptorService;\r
- \r
+\r
RestTemplate mockRestTemplate = mock(RestTemplate.class);\r
- \r
+\r
String path = "path";\r
- \r
+\r
@Before\r
public void before() throws Exception {\r
whenNew(RestTemplate.class).withAnyArguments().thenReturn(mockRestTemplate);\r
- \r
+\r
String propertyDir = "src/test/resources";\r
configRestAdaptorService = new ConfigRestAdaptorServiceImpl(propertyDir);\r
}\r
- \r
+\r
@Test\r
public void testGetResource() throws Exception {\r
String responseBody = "sampleBodyString";\r
ResponseEntity<Object> response = new ResponseEntity<Object>(responseBody, HttpStatus.OK);\r
when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.GET), Matchers.any(),\r
Matchers.any(Class.class))).thenReturn(response);\r
- \r
+\r
String body = configRestAdaptorService.getResource("aai", path, String.class);\r
- \r
+\r
Assert.assertEquals(responseBody, body);\r
}\r
- \r
+\r
@Test\r
public void testPostResource() throws Exception {\r
String responseBody = "sampleBodyString";\r
ResponseEntity<Object> response = new ResponseEntity<Object>(responseBody, HttpStatus.OK);\r
when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.POST), Matchers.any(),\r
Matchers.any(Class.class))).thenReturn(response);\r
- \r
+\r
String body = configRestAdaptorService.postResource("aai", path, null, String.class);\r
- \r
+\r
Assert.assertEquals(responseBody, body);\r
}\r
- \r
+\r
@Test\r
public void testExchange() throws Exception {\r
String responseBody = "sampleBodyString";\r
ResponseEntity<Object> response = new ResponseEntity<Object>(responseBody, HttpStatus.OK);\r
when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.GET), Matchers.any(),\r
Matchers.any(Class.class))).thenReturn(response);\r
- \r
+\r
String body = configRestAdaptorService.exchangeResource("aai", path, null, String.class, "GET");\r
- \r
+\r
Assert.assertEquals(responseBody, body);\r
}\r
- \r
+\r
@Test(expected = ConfigRestAdaptorException.class)\r
public void testGetResourceError() throws Exception {\r
ResponseEntity<Object> response = new ResponseEntity<Object>("", HttpStatus.INTERNAL_SERVER_ERROR);\r
when(mockRestTemplate.getForEntity(Matchers.endsWith(path), Matchers.any())).thenReturn(response);\r
- \r
+\r
configRestAdaptorService.getResource("aai", path, String.class);\r
}\r
- \r
+\r
@Test(expected = ConfigRestAdaptorException.class)\r
public void testPostResourceError() throws Exception {\r
ResponseEntity<Object> response = new ResponseEntity<Object>("", HttpStatus.INTERNAL_SERVER_ERROR);\r
when(mockRestTemplate.postForEntity(Matchers.endsWith(path), Matchers.anyObject(), Matchers.any()))\r
.thenReturn(response);\r
- \r
+\r
configRestAdaptorService.postResource("aai", path, null, String.class);\r
}\r
- \r
+\r
@Test(expected = ConfigRestAdaptorException.class)\r
public void testExchangeError() throws Exception {\r
ResponseEntity<Object> response = new ResponseEntity<Object>("", HttpStatus.INTERNAL_SERVER_ERROR);\r
when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.GET), Matchers.any(),\r
Matchers.any(Class.class))).thenReturn(response);\r
- \r
+\r
configRestAdaptorService.exchangeResource("aai", path, null, String.class, "GET");\r
}\r
}\r
-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;
- }
-
-}
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.rest.adaptor.utils;\r
+\r
+import org.onap.ccsdk.config.rest.adaptor.ConfigRestAdaptorConstants;\r
+import org.onap.ccsdk.config.rest.adaptor.ConfigRestAdaptorException;\r
+import org.onap.ccsdk.config.rest.adaptor.service.ConfigRestAdaptorServiceImpl;\r
+\r
+@SuppressWarnings("squid:S2187")\r
+public class RestTemplateFactoryTest {\r
+\r
+ public static void main(String[] args) {\r
+\r
+ String propertyFile = RestTemplateFactoryTest.class.getClassLoader().getResource(".").getPath();\r
+ System.out.println(" Property : " + propertyFile);\r
+\r
+ try {\r
+ ConfigRestAdaptorServiceImpl configRestAdaptorServiceImpl = new ConfigRestAdaptorServiceImpl(propertyFile);\r
+ String restconfResponse = genericRestGetMDSALOperation(args, configRestAdaptorServiceImpl);\r
+ System.out.println("RestTemplateFactoryTest.main Completed with response :" + restconfResponse);\r
+ } catch (ConfigRestAdaptorException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+ public static String genericRestGetMDSALOperation(String[] args,\r
+ ConfigRestAdaptorServiceImpl configRestAdaptorServiceImpl) throws ConfigRestAdaptorException {\r
+ String path = "config/Dummy-API:services/service-list/dummy-1234";\r
+ String restconfResponse = configRestAdaptorServiceImpl.getResource(ConfigRestAdaptorConstants.SELECTOR_RESTCONF,\r
+ path, String.class);\r
+ return restconfResponse;\r
+ }\r
+\r
+}\r
-#
-# 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
+###\r
+# Copyright © 2017-2018 AT&T Intellectual Property.\r
+# Modifications Copyright © 2018 IBM.\r
+# \r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+# \r
+# http://www.apache.org/licenses/LICENSE-2.0\r
+# \r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
+###\r
+#\r
+# Configuration file for SDNC Controller Module\r
+#\r
+\r
+org.onap.ccsdk.config.rest.adaptors.envtype=solo\r
+\r
+# Config Generator Microservices\r
+org.onap.ccsdk.config.rest.adaptors.modelservice.type=generic\r
+org.onap.ccsdk.config.rest.adaptors.modelservice.enable=true\r
+org.onap.ccsdk.config.rest.adaptors.modelservice.url=http://localhost:8080/configgenerator/service/\r
+org.onap.ccsdk.config.rest.adaptors.modelservice.user=admin\r
+org.onap.ccsdk.config.rest.adaptors.modelservice.passwd=admin\r
+\r
+# Generic RESTCONF Adaptor\r
+org.onap.ccsdk.config.rest.adaptors.restconf.type=generic\r
+org.onap.ccsdk.config.rest.adaptors.restconf.enable=true\r
+org.onap.ccsdk.config.rest.adaptors.restconf.user=admin\r
+org.onap.ccsdk.config.rest.adaptors.restconf.passwd=admin\r
+org.onap.ccsdk.config.rest.adaptors.restconf.url=http://localhost:8181/restconf/\r
+\r
+# SSL AAI Adaptor\r
+org.onap.ccsdk.config.rest.adaptors.aai.propertyfile=aai.properties\r
+org.onap.ccsdk.config.rest.adaptors.aai.type=ssl\r
+org.onap.ccsdk.config.rest.adaptors.aai.enable=true\r
+org.onap.ccsdk.config.rest.adaptors.aai.url=https://localhost:8443/onap-aai/\r
+org.onap.ccsdk.config.rest.adaptors.aai.ssl.trust=src/test/resources/truststore.client.jks\r
+org.onap.ccsdk.config.rest.adaptors.aai.ssl.trust.psswd=changeme\r
+org.onap.ccsdk.config.rest.adaptors.aai.ssl.key=src/test/resources/keystore.client.p12\r
+org.onap.ccsdk.config.rest.adaptors.aai.ssl.key.psswd=changeme\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.assignment;\r
\r
@SuppressWarnings("squid:S1118")\r
public class ConfigAssignmentConstants {\r
- \r
+\r
public static final String OUTPUT_PARAM_STATUS = "status";\r
public static final String OUTPUT_PARAM_RESOURCE_ASSIGNMENT_PARAMS = "resource-assignment-params";\r
public static final String OUTPUT_PARAM_MASHED_DATA = "mashed-data";\r
public static final String OUTPUT_PARAM_ERROR_MESSAGE = "error-message";\r
public static final String OUTPUT_STATUS_SUCCESS = "success";\r
public static final String OUTPUT_STATUS_FAILURE = "failure";\r
- \r
+\r
public static final String INPUT_PARAM_REQUEST_ID = "request-id";\r
public static final String INPUT_PARAM_RESOURCE_ID = "resource-id";\r
public static final String INPUT_PARAM_RESOURCE_TYPE = "resource-type";\r
public static final String INPUT_PARAM_ACTION_NAME = "action-name";\r
public static final String INPUT_PARAM_TEMPLATE_NAMES = "template-names";\r
public static final String INPUT_PARAM_INPUT_DATA = "input-data";\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.assignment.data;\r
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
\r
public class ResourceAssignmentData {\r
- \r
+\r
private String requestId;\r
private boolean reloadModel;\r
private String resourceType;\r
private Map<String, String> templatesMashedContents = new HashMap<>();\r
private Map<String, String> templatesData = new HashMap<>();\r
private Map<String, Object> context = new HashMap<>();\r
- \r
+\r
public String getRequestId() {\r
return requestId;\r
}\r
- \r
+\r
public void setRequestId(String requestId) {\r
this.requestId = requestId;\r
}\r
- \r
+\r
public String getResourceType() {\r
return resourceType;\r
}\r
- \r
+\r
public void setResourceType(String resourceType) {\r
this.resourceType = resourceType;\r
}\r
- \r
+\r
public String getResourceId() {\r
return resourceId;\r
}\r
- \r
+\r
public void setResourceId(String resourceId) {\r
this.resourceId = resourceId;\r
}\r
- \r
+\r
public String getServiceTemplateName() {\r
return serviceTemplateName;\r
}\r
- \r
+\r
public void setServiceTemplateName(String serviceTemplateName) {\r
this.serviceTemplateName = serviceTemplateName;\r
}\r
- \r
+\r
public String getServiceTemplateVersion() {\r
return serviceTemplateVersion;\r
}\r
- \r
+\r
public void setServiceTemplateVersion(String serviceTemplateVersion) {\r
this.serviceTemplateVersion = serviceTemplateVersion;\r
}\r
- \r
+\r
public String getActionName() {\r
return actionName;\r
}\r
- \r
+\r
public void setActionName(String actionName) {\r
this.actionName = actionName;\r
}\r
- \r
+\r
public String getInputData() {\r
return inputData;\r
}\r
- \r
+\r
public void setInputData(String inputData) {\r
this.inputData = inputData;\r
}\r
- \r
+\r
public List<String> getTemplateNames() {\r
return templateNames;\r
}\r
- \r
+\r
public void setTemplateNames(List<String> templateNames) {\r
this.templateNames = templateNames;\r
}\r
- \r
+\r
public Map<String, List<ResourceAssignment>> getTemplatesResourceAssignments() {\r
return templatesResourceAssignments;\r
}\r
- \r
+\r
public void setTemplatesResourceAssignments(Map<String, List<ResourceAssignment>> templatesResourceAssignments) {\r
this.templatesResourceAssignments = templatesResourceAssignments;\r
}\r
- \r
+\r
public Map<String, String> getTemplatesContents() {\r
return templatesContents;\r
}\r
- \r
+\r
public void setTemplatesContents(Map<String, String> templatesContents) {\r
this.templatesContents = templatesContents;\r
}\r
- \r
+\r
public Map<String, String> getTemplatesMashedContents() {\r
return templatesMashedContents;\r
}\r
- \r
+\r
public void setTemplatesMashedContents(Map<String, String> templatesMashedContents) {\r
this.templatesMashedContents = templatesMashedContents;\r
}\r
- \r
+\r
public Map<String, String> getTemplatesData() {\r
return templatesData;\r
}\r
- \r
+\r
public void setTemplatesData(Map<String, String> templatesData) {\r
this.templatesData = templatesData;\r
}\r
- \r
+\r
public Map<String, Object> getContext() {\r
return context;\r
}\r
- \r
+\r
public void setContext(Map<String, Object> context) {\r
this.context = context;\r
}\r
- \r
+\r
public SvcLogicContext getSvcLogicContext() {\r
return svcLogicContext;\r
}\r
- \r
+\r
public void setSvcLogicContext(SvcLogicContext svcLogicContext) {\r
this.svcLogicContext = svcLogicContext;\r
}\r
- \r
+\r
public boolean isReloadModel() {\r
return reloadModel;\r
}\r
- \r
+\r
public void setReloadModel(boolean reloadModel) {\r
this.reloadModel = reloadModel;\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.assignment.processor;\r
import org.onap.ccsdk.config.rest.adaptor.service.ConfigRestAdaptorService;\r
\r
public class ProcessorFactory {\r
- \r
+\r
private ConfigResourceService configResourceService;\r
private ConfigRestAdaptorService configRestAdaptorService;\r
private ComponentNodeService componentNodeService;\r
- \r
+\r
public ProcessorFactory(ConfigResourceService configResourceService,\r
ConfigRestAdaptorService configRestAdaptorService, ComponentNodeService componentNodeService) {\r
this.componentNodeService = componentNodeService;\r
this.configResourceService = configResourceService;\r
this.configRestAdaptorService = configRestAdaptorService;\r
}\r
- \r
+\r
public ComponentNode getInstance(String source) {\r
- \r
+\r
if (ConfigModelConstant.SOURCE_DEFAULT.equalsIgnoreCase(source)) {\r
return new DefaultResourceProcessor(configResourceService);\r
} else if (ConfigModelConstant.SOURCE_DB.equalsIgnoreCase(source)) {\r
// Default\r
return new InputResourceProcessor(configResourceService);\r
}\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.assignment.processor;\r
\r
public class ResourceAssignmentProcessor {\r
private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceAssignmentProcessor.class);\r
- \r
+\r
private List<ResourceAssignment> assignments;\r
private Map<String, ResourceAssignment> resourceAssignmentMap;\r
- \r
+\r
@SuppressWarnings("squid:S1172")\r
public ResourceAssignmentProcessor(List<ResourceAssignment> assignments, SvcLogicContext ctx) {\r
this.assignments = assignments;\r
this.resourceAssignmentMap = new HashMap<>();\r
}\r
- \r
+\r
@SuppressWarnings("squid:S3776")\r
public List<List<ResourceAssignment>> process() {\r
List<List<ResourceAssignment>> sequenceBatchResourceAssignment = new ArrayList<>();\r
resourceAssignmentMap.put(resourceMapping.getName(), resourceMapping);\r
}\r
});\r
- \r
+\r
TopologicalSortingUtils<ResourceAssignment> topologySorting = new TopologicalSortingUtils<>();\r
this.resourceAssignmentMap.forEach((mappingKey, mapping) -> {\r
if (mapping != null) {\r
}\r
}\r
});\r
- \r
+\r
List<ResourceAssignment> sequencedResourceAssignments = topologySorting.topSort();\r
logger.info("Sorted Sequenced Assignments ({})", sequencedResourceAssignments);\r
- \r
+\r
List<ResourceAssignment> batchResourceAssignment = null;\r
List<String> batchAssignmentName = null;\r
for (int i = 0; i < sequencedResourceAssignments.size(); i++) {\r
ResourceAssignment resourceAssignment = sequencedResourceAssignments.get(i);\r
ResourceAssignment previousResourceAssignment = null;\r
- \r
+\r
if (i > 0) {\r
previousResourceAssignment = sequencedResourceAssignments.get(i - 1);\r
}\r
if (resourceAssignment != null) {\r
- \r
+\r
boolean dependencyPresence = false;\r
if (batchAssignmentName != null && resourceAssignment.getDependencies() != null) {\r
dependencyPresence =\r
CollectionUtils.containsAny(batchAssignmentName, resourceAssignment.getDependencies());\r
}\r
- \r
+\r
logger.trace("({}) -> Checking ({}), with ({}), result ({})", resourceAssignment.getName(),\r
batchAssignmentName, resourceAssignment.getDependencies(), dependencyPresence);\r
- \r
+\r
if (previousResourceAssignment != null && resourceAssignment.getDictionarySource() != null\r
&& resourceAssignment.getDictionarySource()\r
.equalsIgnoreCase(previousResourceAssignment.getDictionarySource())\r
}\r
batchResourceAssignment = new ArrayList<>();\r
batchResourceAssignment.add(resourceAssignment);\r
- \r
+\r
batchAssignmentName = new ArrayList<>();\r
batchAssignmentName.add(resourceAssignment.getName());\r
}\r
}\r
- \r
+\r
if (i == (sequencedResourceAssignments.size() - 1)) {\r
logger.trace("Created old Set ({})", batchAssignmentName);\r
sequenceBatchResourceAssignment.add(batchResourceAssignment);\r
}\r
return sequenceBatchResourceAssignment;\r
}\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.assignment.service;\r
import com.att.eelf.configuration.EELFManager;\r
\r
public class ConfigAssignmentPersistService {\r
- \r
+\r
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentPersistService.class);\r
- \r
+\r
private ConfigResourceService configResourceService;\r
- \r
+\r
public ConfigAssignmentPersistService(ConfigResourceService configResourceService) {\r
this.configResourceService = configResourceService;\r
}\r
- \r
+\r
public void saveResourceMapping(org.onap.ccsdk.config.assignment.data.ResourceAssignmentData resourceAssignmentData,\r
String templateName, List<ResourceAssignment> resourceAssignments) throws SvcLogicException {\r
try {\r
- \r
+\r
if (resourceAssignmentData == null) {\r
throw new SvcLogicException("Resource assignment data is missing");\r
}\r
- \r
+\r
if (StringUtils.isBlank(resourceAssignmentData.getRequestId())) {\r
logger.warn("Request Id ({}) is missing, may be getting request for resource update.",\r
resourceAssignmentData.getRequestId());\r
}\r
- \r
+\r
if (StringUtils.isBlank(resourceAssignmentData.getResourceId())) {\r
throw new SvcLogicException("Resource Id is missing");\r
}\r
- \r
+\r
if (StringUtils.isBlank(resourceAssignmentData.getResourceType())) {\r
throw new SvcLogicException("Resource type is missing");\r
}\r
- \r
+\r
if (StringUtils.isBlank(resourceAssignmentData.getActionName())) {\r
throw new SvcLogicException("Action name is missing");\r
}\r
- \r
+\r
if (StringUtils.isBlank(templateName)) {\r
throw new SvcLogicException("template name is missing");\r
}\r
- \r
+\r
StringBuilder builder = new StringBuilder();\r
builder.append("Resource Assignment for Template Name :");\r
builder.append(templateName);\r
builder.append("\n");\r
builder.append(TransformationUtils.getJson(resourceAssignments, true));\r
- \r
+\r
configResourceService.save(new TransactionLog(resourceAssignmentData.getRequestId(),\r
DataAdaptorConstants.LOG_MESSAGE_TYPE_LOG, builder.toString()));\r
- \r
+\r
// Resource Data should be Regenerated based on the new Updates\r
String resourceData = ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignments);\r
- \r
+\r
List<ResourceAssignmentData> resourceAssignmentDataList =\r
ConfigAssignmentUtils.convertResoureAssignmentList(resourceAssignments);\r
- \r
+\r
ConfigResource configResource = new ConfigResource();\r
configResource.setRequestId(resourceAssignmentData.getRequestId());\r
configResource.setServiceTemplateName(resourceAssignmentData.getServiceTemplateName());\r
configResource.setTemplateName(templateName);\r
configResource.setStatus(ConfigModelConstant.STATUS_SUCCESS);\r
configResource.setUpdatedBy(ConfigModelConstant.USER_SYSTEM);\r
- \r
+\r
if (CollectionUtils.isNotEmpty(resourceAssignmentDataList)) {\r
configResource.setResourceAssignments(resourceAssignmentDataList);\r
}\r
configResource = configResourceService.saveConfigResource(configResource);\r
logger.info("Resource data saved successfully for the template ({}) with resource id ({})", templateName,\r
configResource.getResourceId());\r
- \r
+\r
builder = new StringBuilder();\r
builder.append("Resource Data Template Name :");\r
builder.append(templateName);\r
builder.append(resourceData);\r
configResourceService.save(new TransactionLog(resourceAssignmentData.getRequestId(),\r
DataAdaptorConstants.LOG_MESSAGE_TYPE_LOG, builder.toString()));\r
- \r
+\r
} catch (Exception e) {\r
throw new SvcLogicException("ConfigAssignmentPersistService : " + e.getMessage(), e);\r
}\r
- \r
+\r
}\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.assignment.service;\r
import com.att.eelf.configuration.EELFManager;\r
\r
public class ConfigAssignmentProcessService {\r
- \r
+\r
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentProcessService.class);\r
- \r
+\r
private ComponentNodeService componentNodeService;\r
private ConfigResourceService configResourceService;\r
private ConfigModelService configModelService;\r
private ConfigRestAdaptorService configRestAdaptorService;\r
private ConfigGeneratorService configGeneratorService;\r
- \r
+\r
public ConfigAssignmentProcessService(ConfigResourceService configResourceService,\r
ConfigRestAdaptorService configRestAdaptorService, ConfigModelService configModelService,\r
ComponentNodeService componentNodeService, ConfigGeneratorService configGeneratorService) {\r
this.configRestAdaptorService = configRestAdaptorService;\r
this.configGeneratorService = configGeneratorService;\r
}\r
- \r
+\r
@SuppressWarnings("squid:S1141")\r
public void resolveResources(ResourceAssignmentData resourceAssignmentData) throws SvcLogicException {\r
try {\r
validateInputParams(resourceAssignmentData);\r
- \r
+\r
String serviceTemplateName = resourceAssignmentData.getServiceTemplateName();\r
String serviceTemplateVersion = resourceAssignmentData.getServiceTemplateVersion();\r
String actionName = resourceAssignmentData.getActionName();\r
String inputData = resourceAssignmentData.getInputData();\r
SvcLogicContext svcLogicContext = resourceAssignmentData.getSvcLogicContext();\r
List<String> templateNames = resourceAssignmentData.getTemplateNames();\r
- \r
+\r
if (resourceAssignmentData.isReloadModel()) {\r
Map<String, String> context = new HashMap<>();\r
context.put(ConfigModelConstant.PROPERTY_ACTION_NAME, actionName);\r
context.forEach((key, value) -> svcLogicContext.setAttribute(key, value));\r
logger.info("List of Resources provided in input: {}", svcLogicContext.toProperties());\r
}\r
- \r
+\r
Map<String, Object> componentContext = resourceAssignmentData.getContext();\r
- \r
+\r
if (CollectionUtils.isNotEmpty(templateNames)) {\r
// Get the Resource Assignments for templates and Validate the mappings\r
ResourceModelService resourceModelService = new ResourceModelService(configModelService);\r
- \r
+\r
// Get the Resource Assignment\r
Map<String, List<ResourceAssignment>> templatesResourceAssignments =\r
resourceModelService.getTemplatesResourceAssignments(svcLogicContext, templateNames);\r
- \r
+\r
// Get the Template Contents\r
Map<String, String> templatesContents =\r
resourceModelService.getTemplatesContents(svcLogicContext, templateNames);\r
- \r
+\r
// Process each template\r
for (String templateName : templateNames) {\r
List<ResourceAssignment> resourceAssignments = templatesResourceAssignments.get(templateName);\r
new ResourceDictionaryService(configRestAdaptorService);\r
Map<String, ResourceDefinition> dictionaries =\r
resourceDictionaryService.getDataDictionaryDefinitions(resourceAssignments);\r
- \r
+\r
processResourceAssignments(resourceAssignmentData, svcLogicContext, componentContext,\r
templateName, resourceAssignments, dictionaries);\r
- \r
+\r
logger.info("decrypting config data for templateName {}", templateName);\r
templateData =\r
ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignments);\r
} finally {\r
saveResourceMapping(resourceAssignmentData, templateName, resourceAssignments);\r
}\r
- \r
+\r
logger.info("generating config preview for templateName {}", templateName);\r
ConfigPreviewService configPreviewService = new ConfigPreviewService(configResourceService,\r
configModelService, configGeneratorService);\r
String mashedData = configPreviewService.generatePreview(templateContent, templateData);\r
resourceAssignmentData.getTemplatesMashedContents().put(templateName, mashedData);\r
resourceAssignmentData.getTemplatesData().put(templateName, templateData);\r
- \r
+\r
} else {\r
// Do nothing for Mapping not found\r
logger.warn("No resource Assignment mappings to resolve for templateName {}", templateName);\r
}\r
}\r
}\r
- \r
+\r
} catch (Exception e) {\r
throw new SvcLogicException(e.getMessage(), e);\r
}\r
}\r
- \r
+\r
private void processResourceAssignments(ResourceAssignmentData resourceAssignmentData, SvcLogicContext ctx,\r
Map<String, Object> componentContext, String templateName, List<ResourceAssignment> resourceAssignments,\r
Map<String, ResourceDefinition> dictionaries) throws SvcLogicException {\r
- \r
+\r
String recipeName = resourceAssignmentData.getActionName();\r
- \r
+\r
ResourceAssignmentProcessor resourceAssignmentProcessor =\r
new ResourceAssignmentProcessor(resourceAssignments, ctx);\r
List<List<ResourceAssignment>> sequenceBatchResourceAssignment = resourceAssignmentProcessor.process();\r
- \r
+\r
logger.debug("Resource dictionary Info ({})", dictionaries);\r
- \r
+\r
if (sequenceBatchResourceAssignment != null) {\r
componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName);\r
componentContext.put(ConfigModelConstant.PROPERTY_TEMPLATE_NAME, templateName);\r
componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARIES, dictionaries);\r
for (List<ResourceAssignment> batchResourceAssignment : sequenceBatchResourceAssignment) {\r
- \r
+\r
processBatchResourceAssignments(resourceAssignmentData, ctx, componentContext, batchResourceAssignment);\r
- \r
+\r
logger.debug("Batch Resource data status ({})", TransformationUtils.getJson(batchResourceAssignment));\r
}\r
}\r
}\r
- \r
+\r
private void processBatchResourceAssignments(ResourceAssignmentData resourceAssignmentData, SvcLogicContext ctx,\r
Map<String, Object> componentContext, List<ResourceAssignment> batchResourceAssignment)\r
throws SvcLogicException {\r
- \r
+\r
if (CollectionUtils.isNotEmpty(batchResourceAssignment)) {\r
- \r
+\r
ResourceAssignment batchFirstResourceAssignment = batchResourceAssignment.get(0);\r
if (batchFirstResourceAssignment != null\r
&& StringUtils.isNotBlank(batchFirstResourceAssignment.getDictionarySource())) {\r
// Processing their Source\r
logger.info("Processing source ({}) with batch ({}) ", source, batchResourceAssignment);\r
componentContext.put(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS, batchResourceAssignment);\r
- \r
+\r
ProcessorFactory factory =\r
new ProcessorFactory(configResourceService, configRestAdaptorService, componentNodeService);\r
- \r
+\r
ComponentNode processor = factory.getInstance(source);\r
- \r
+\r
Map<String, String> inParams = new HashMap<>();\r
inParams.put(ConfigAssignmentConstants.INPUT_PARAM_REQUEST_ID, resourceAssignmentData.getRequestId());\r
inParams.put(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_ID, resourceAssignmentData.getResourceId());\r
}\r
}\r
}\r
- \r
+\r
private void saveResourceMapping(ResourceAssignmentData resourceAssignmentData, String templateName,\r
List<ResourceAssignment> resourceAssignments) throws SvcLogicException {\r
if (resourceAssignmentData != null && StringUtils.isNotBlank(templateName)) {\r
- \r
+\r
ConfigAssignmentPersistService configAssignmentPersistService =\r
new ConfigAssignmentPersistService(configResourceService);\r
configAssignmentPersistService.saveResourceMapping(resourceAssignmentData, templateName,\r
resourceAssignments);\r
}\r
}\r
- \r
+\r
private void validateInputParams(ResourceAssignmentData resourceAssignmentData) throws SvcLogicException {\r
if (resourceAssignmentData == null) {\r
throw new SvcLogicException("Input parameters missing");\r
}\r
- \r
+\r
String requestId = resourceAssignmentData.getRequestId();\r
if (StringUtils.isBlank(requestId)) {\r
throw new SvcLogicException("Request id parameters missing");\r
if (StringUtils.isBlank(actionName)) {\r
throw new SvcLogicException("Action name is parameter is missing");\r
}\r
- \r
+\r
List<String> templatesNames = resourceAssignmentData.getTemplateNames();\r
if (CollectionUtils.isEmpty(templatesNames)) {\r
throw new SvcLogicException("Template names parameter missing");\r
}\r
}\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.assignment.service;\r
import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
\r
public interface ConfigAssignmentService {\r
- \r
+\r
public void resolveResources(ResourceAssignmentData resourceAssignmentData) throws SvcLogicException;\r
- \r
+\r
public void saveResourceMapping(ResourceAssignmentData resourceAssignmentData, String templateName,\r
List<ResourceAssignment> resourceAssignments) throws SvcLogicException;\r
- \r
+\r
public ResourceAssignmentData generateTemplateResourceMash(ResourceAssignmentData resourceAssignmentData)\r
throws SvcLogicException;\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.assignment.service;\r
import com.att.eelf.configuration.EELFManager;\r
\r
public class ConfigAssignmentServiceImpl implements ConfigAssignmentService {\r
- \r
+\r
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentServiceImpl.class);\r
- \r
+\r
private ComponentNodeService componentNodeService;\r
private ConfigResourceService configResourceService;\r
private ConfigModelService configModelService;\r
private ConfigRestAdaptorService configRestAdaptorService;\r
private ConfigGeneratorService configGeneratorService;\r
- \r
+\r
private static final String CLASS_NAME = "ConfigAssignmentServiceImpl";\r
- \r
+\r
public ConfigAssignmentServiceImpl(ConfigResourceService configResourceService,\r
ConfigRestAdaptorService configRestAdaptorService, ConfigModelService configModelService,\r
ComponentNodeService componentNodeService, ConfigGeneratorService configGeneratorService) {\r
this.configRestAdaptorService = configRestAdaptorService;\r
this.configGeneratorService = configGeneratorService;\r
}\r
- \r
+\r
@Override\r
public void resolveResources(ResourceAssignmentData resourceAssignmentData) throws SvcLogicException {\r
ConfigAssignmentProcessService configAssignmentProcessService =\r
componentNodeService, configGeneratorService);\r
configAssignmentProcessService.resolveResources(resourceAssignmentData);\r
}\r
- \r
+\r
@Override\r
public void saveResourceMapping(ResourceAssignmentData resourceAssignmentData, String templateName,\r
List<ResourceAssignment> resourceAssignments) throws SvcLogicException {\r
new ConfigAssignmentPersistService(configResourceService);\r
configAssignmentPersistService.saveResourceMapping(resourceAssignmentData, templateName, resourceAssignments);\r
}\r
- \r
+\r
@Override\r
public ResourceAssignmentData generateTemplateResourceMash(ResourceAssignmentData resourceAssignmentData)\r
throws SvcLogicException {\r
new ConfigPreviewService(configResourceService, configModelService, configGeneratorService);\r
return configPreviewService.generateTemplateResourceMash(resourceAssignmentData);\r
}\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.assignment.service;\r
import com.fasterxml.jackson.databind.node.ObjectNode;\r
\r
public class ConfigAssignmentUtils {\r
- \r
+\r
private ConfigAssignmentUtils() {\r
- \r
+\r
}\r
- \r
+\r
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentUtils.class);\r
- \r
+\r
public static synchronized Object getContextKeyValue(SvcLogicContext context, String key) {\r
Object value = null;\r
if (context != null && key != null) {\r
}\r
return value;\r
}\r
- \r
+\r
/*\r
* Populate the Field property type for the Data type\r
*/\r
}\r
return type;\r
}\r
- \r
+\r
/*\r
* Populate the Field property type for the Data type\r
*/\r
}\r
return propertyDefinition;\r
}\r
- \r
+\r
public static synchronized ResourceDefinition getDictionaryDefinition(Map<String, ResourceDictionary> dictionaries,\r
String dictionaryName) {\r
ResourceDefinition resourceDefinition = null;\r
}\r
return resourceDefinition;\r
}\r
- \r
+\r
@SuppressWarnings("squid:S3776")\r
public static synchronized void populateValueForOutputMapping(SvcLogicContext ctx,\r
Map<String, Object> componentContext, ResourceAssignment resourceAssignment,\r
if (resourceAssignment == null) {\r
throw new SvcLogicException("resourceAssignment is null.");\r
}\r
- \r
+\r
if (ctx == null) {\r
throw new SvcLogicException("service logic context is null.");\r
}\r
- \r
+\r
if (componentContext == null) {\r
throw new SvcLogicException("component context is null.");\r
}\r
- \r
+\r
logger.info("populating value for output mapping ({}), from json ({})", outputKeyMapping, responseNode);\r
String dictionaryName = resourceAssignment.getDictionaryName();\r
String type = resourceAssignment.getProperty().getType();\r
- \r
+\r
String entrySchema = null;\r
if (ValidTypes.getPrimitivePropertType().contains(type)) {\r
ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, responseNode);\r
if (resourceAssignment.getProperty().getEntrySchema() != null) {\r
entrySchema = resourceAssignment.getProperty().getEntrySchema().getType();\r
}\r
- \r
+\r
if (StringUtils.isNotBlank(entrySchema)) {\r
ArrayNode arrayNode = JsonNodeFactory.instance.arrayNode();\r
if (ValidTypes.getPrimitivePropertType().contains(entrySchema)) {\r
ObjectNode arrayChildNode = JsonNodeFactory.instance.objectNode();\r
for (Map.Entry<String, String> mapping : outputKeyMapping.entrySet()) {\r
JsonNode responseKeyValue = responseSingleJsonNode.get(mapping.getKey());\r
- \r
+\r
String propertyTypeForDataType =\r
ConfigAssignmentUtils.getPropertyType(ctx, entrySchema, mapping.getKey());\r
logger.info("For List Type Resource: key ({}), value ({}), type ({})",\r
ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, objectNode);\r
}\r
}\r
- \r
+\r
@SuppressWarnings("squid:S3776")\r
public static synchronized List<ResourceAssignment> convertResoureAssignmentDataList(\r
List<ResourceAssignmentData> resourceAssignmentDataList) {\r
resourceAssignment.setMessage(resourceAssignmentData.getMessage());\r
PropertyDefinition property = new PropertyDefinition();\r
property.setType(resourceAssignmentData.getDataType());\r
- \r
+\r
if (StringUtils.isNotBlank(resourceAssignmentData.getResourceValue())) {\r
if (ValidTypes.getPrimitivePropertType().contains(resourceAssignmentData.getDataType())) {\r
property.setValue(resourceAssignmentData.getResourceValue());\r
assignments.add(resourceAssignment);\r
}\r
}\r
- \r
+\r
}\r
return assignments;\r
}\r
- \r
+\r
@SuppressWarnings("squid:S3776")\r
public static synchronized List<ResourceAssignmentData> convertResoureAssignmentList(\r
List<ResourceAssignment> assignments) {\r
}\r
return resourceAssignmentDataList;\r
}\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.assignment.service;\r
private ConfigResourceService configResourceService;\r
private ConfigModelService configModelService;\r
private ConfigGeneratorService configGeneratorService;\r
- \r
+\r
public ConfigPreviewService(ConfigResourceService configResourceService, ConfigModelService configModelService,\r
ConfigGeneratorService configGeneratorService) {\r
this.configResourceService = configResourceService;\r
this.configModelService = configModelService;\r
this.configGeneratorService = configGeneratorService;\r
}\r
- \r
+\r
public String generatePreview(String templateContent, String templateData) throws SvcLogicException {\r
String mashedData = "";\r
ConfigGeneratorInfo configGeneratorInfo =\r
}\r
return mashedData;\r
}\r
- \r
+\r
public ResourceAssignmentData generateTemplateResourceMash(ResourceAssignmentData resourceAssignmentData)\r
throws SvcLogicException {\r
if (resourceAssignmentData == null) {\r
if (StringUtils.isBlank(resourceAssignmentData.getActionName())) {\r
throw new SvcLogicException("Action name is missing");\r
}\r
- \r
+\r
String serviceTemplateName = resourceAssignmentData.getServiceTemplateName();\r
String serviceTemplateVersion = resourceAssignmentData.getServiceTemplateVersion();\r
String actionName = resourceAssignmentData.getActionName();\r
String resourceId = resourceAssignmentData.getResourceId();\r
String resourceType = resourceAssignmentData.getResourceType();\r
String inputData = "{}";\r
- \r
+\r
Map<String, String> context = new HashMap<>();\r
context.put(ConfigModelConstant.PROPERTY_ACTION_NAME, actionName);\r
context = configModelService.prepareContext(context, inputData, serviceTemplateName, serviceTemplateVersion);\r
- \r
+\r
ConfigResource configResourceQuery = new ConfigResource();\r
configResourceQuery.setServiceTemplateVersion(serviceTemplateName);\r
configResourceQuery.setServiceTemplateVersion(serviceTemplateVersion);\r
configResourceQuery.setRecipeName(actionName);\r
configResourceQuery.setResourceId(resourceId);\r
configResourceQuery.setResourceType(resourceType);\r
- \r
+\r
List<ConfigResource> configResources = configResourceService.getConfigResource(configResourceQuery);\r
if (CollectionUtils.isNotEmpty(configResources)) {\r
for (ConfigResource cr : configResources) {\r
serviceTemplateName, serviceTemplateVersion, actionName, resourceId, resourceType);\r
}\r
return resourceAssignmentData;\r
- \r
+\r
}\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.assignment.service;\r
import com.att.eelf.configuration.EELFManager;\r
\r
public class ResourceDictionaryService {\r
- \r
+\r
private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceDictionaryService.class);\r
private ConfigRestAdaptorService configRestAdaptorService;\r
- \r
+\r
public ResourceDictionaryService(ConfigRestAdaptorService configRestAdaptorService) {\r
this.configRestAdaptorService = configRestAdaptorService;\r
}\r
- \r
+\r
@SuppressWarnings("squid:S3776")\r
public Map<String, ResourceDefinition> getDataDictionaryDefinitions(List<ResourceAssignment> resourceAssignments)\r
throws SvcLogicException {\r
List<String> names = new ArrayList<>();\r
for (ResourceAssignment resourceAssignment : resourceAssignments) {\r
if (resourceAssignment != null && StringUtils.isNotBlank(resourceAssignment.getDictionaryName())) {\r
- \r
+\r
if (!names.contains(resourceAssignment.getDictionaryName())) {\r
names.add(resourceAssignment.getDictionaryName());\r
}\r
- \r
+\r
if (resourceAssignment.getDependencies() != null\r
&& !resourceAssignment.getDependencies().isEmpty()) {\r
List<String> dependencieNames = resourceAssignment.getDependencies();\r
} catch (Exception e) {\r
throw new SvcLogicException("Failed in getting resource data dictionary : " + e.getMessage());\r
}\r
- \r
+\r
}\r
- \r
+\r
@SuppressWarnings("squid:S3776")\r
private void queryResourceDictionaryDefinitions(Map<String, ResourceDefinition> dictionaries, List<String> names)\r
throws SvcLogicException, ConfigRestAdaptorException {\r
logger.info("Getting resource dictionary definition for the names ({})", names);\r
if (!names.isEmpty()) {\r
- \r
+\r
String dictionaryContents = configRestAdaptorService.postResource(\r
ConfigRestAdaptorConstants.SELECTOR_MODEL_SERVICE, "dictionarybynames", names, String.class);\r
- \r
+\r
if (StringUtils.isNotBlank(dictionaryContents)) {\r
List<ResourceDictionary> dataDictionaries =\r
TransformationUtils.getListfromJson(dictionaryContents, ResourceDictionary.class);\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.assignment.service;\r
\r
public class ResourceModelService {\r
private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceModelService.class);\r
- \r
+\r
private ConfigModelService configModelService;\r
- \r
+\r
public ResourceModelService(ConfigModelService configModelService) {\r
this.configModelService = configModelService;\r
}\r
- \r
+\r
public Map<String, String> getTemplatesContents(SvcLogicContext ctx, List<String> templateNames)\r
throws SvcLogicException {\r
Map<String, String> templatesContents = new HashMap<>();\r
}\r
return templatesContents;\r
}\r
- \r
+\r
public Map<String, List<ResourceAssignment>> getTemplatesResourceAssignments(SvcLogicContext ctx,\r
List<String> templateNames) throws SvcLogicException {\r
Map<String, List<ResourceAssignment>> templatesResourceAssignments = new HashMap<>();\r
String resourceMappingContent = this.configModelService.getNodeTemplateMapping(ctx, templateName);\r
logger.info("Processing template ({}) with resource assignment content : {}", templateName,\r
resourceMappingContent);\r
- \r
+\r
if (StringUtils.isNotBlank(resourceMappingContent)) {\r
- \r
+\r
List<ResourceAssignment> resourceAssignments =\r
TransformationUtils.getListfromJson(resourceMappingContent, ResourceAssignment.class);\r
- \r
+\r
if (resourceAssignments != null) {\r
ResourceAssignmentValidator resourceAssignmentValidator =\r
new ResourceAssignmentValidator(resourceAssignments);\r
} catch (Exception e) {\r
throw new SvcLogicException(e.getMessage());\r
}\r
- \r
+\r
return templatesResourceAssignments;\r
}\r
}\r
<?xml version="1.0" encoding="UTF-8"?>\r
<!--\r
Copyright © 2017-2018 AT&T Intellectual Property.\r
+ Modifications Copyright © 2018 IBM.\r
\r
Licensed under the Apache License, Version 2.0 (the "License");\r
you may not use this file except in compliance with the License.\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.assignment.service;\r
\r
@RunWith(MockitoJUnitRunner.class)\r
public class ConfigPreviewServiceTest {\r
- \r
+\r
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigPreviewServiceTest.class);\r
- \r
+\r
@Rule\r
public ExpectedException thrown = ExpectedException.none();\r
- \r
+\r
@Mock\r
private ConfigResourceService configResourceService;\r
- \r
+\r
@Mock\r
private ConfigRestAdaptorService configRestAdaptorService;\r
- \r
+\r
private ConfigModelService configModelService;\r
private ConfigGeneratorService configGeneratorService;\r
- \r
+\r
@SuppressWarnings("unchecked")\r
@Before\r
public void before() throws Exception {\r
MockitoAnnotations.initMocks(this);\r
}\r
- \r
+\r
@Test\r
public void testGenerateTemplateResourceMash() throws Exception {\r
- \r
+\r
ConfigResourceAssignmentTestUtils.injectTransactionLogSaveMock(configResourceService);\r
- \r
+\r
ConfigResourceAssignmentTestUtils.injectConfigModelMock(configRestAdaptorService, "resource_assignment");\r
- \r
+\r
ConfigResourceAssignmentTestUtils.injectResourceDictionaryMock(configRestAdaptorService,\r
"assignments/empty-dictionary.json");\r
- \r
+\r
ConfigResource configResourceQuery = new ConfigResource();\r
configResourceQuery.setServiceTemplateVersion("sample-serviceTemplateName");\r
configResourceQuery.setServiceTemplateVersion("1.0.0");\r
String inputContent = FileUtils.readFileToString(\r
new File("src/test/resources/service_templates/input/input.json"), Charset.defaultCharset());\r
configResourceQuery.setResourceData(inputContent);\r
- \r
+\r
ConfigResourceAssignmentTestUtils.injectGetConfigResourceMock(configResourceService, configResourceQuery);\r
- \r
+\r
configModelService = new ConfigModelServiceImpl(configRestAdaptorService);\r
configGeneratorService = new ConfigGeneratorServiceImpl(configResourceService);\r
- \r
+\r
ConfigPreviewService configPreviewService =\r
new ConfigPreviewService(configResourceService, configModelService, configGeneratorService);\r
- \r
+\r
ResourceAssignmentData resourceAssignmentData = new ResourceAssignmentData();\r
resourceAssignmentData.setResourceId("123-resourceId");\r
resourceAssignmentData.setResourceType("sample-resourceType");\r
resourceAssignmentData.setServiceTemplateName("sample-serviceTemplateName");\r
resourceAssignmentData.setServiceTemplateVersion("1.0.0");\r
resourceAssignmentData.setActionName("sample-action");\r
- \r
+\r
resourceAssignmentData = configPreviewService.generateTemplateResourceMash(resourceAssignmentData);\r
- \r
+\r
Assert.assertNotNull("Failed to get GenerateTemplateResourceMash response.", resourceAssignmentData);\r
Assert.assertNotNull("Failed to get template mashed contents.",\r
resourceAssignmentData.getTemplatesMashedContents());\r
- \r
+\r
Assert.assertNotNull("Failed to get base-config template mashed contents.",\r
resourceAssignmentData.getTemplatesMashedContents().get("base-config-template"));\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.assignment.service;\r
import com.fasterxml.jackson.databind.ObjectMapper;\r
\r
public class ConfigResourceAssignmentTestUtils {\r
- \r
+\r
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigResourceAssignmentTestUtils.class);\r
- \r
+\r
public static void injectTransactionLogSaveMock(ConfigResourceService configResourceService) throws Exception {\r
Mockito.doAnswer(new Answer<Void>() {\r
@Override\r
}\r
}).when(configResourceService).save(any(TransactionLog.class));\r
}\r
- \r
+\r
public static void injectConfigModelMock(ConfigRestAdaptorService configRestAdaptorService,\r
String serviceTemplateName) throws Exception {\r
- \r
+\r
Mockito.doAnswer(new Answer<ConfigModel>() {\r
@Override\r
public org.onap.ccsdk.config.model.domain.ConfigModel answer(InvocationOnMock invocationOnMock)\r
Object[] args = invocationOnMock.getArguments();\r
org.onap.ccsdk.config.model.domain.ConfigModel serviceArtifact = null;\r
if (args != null && args.length == 3) {\r
- \r
+\r
logger.info("Artifact info " + Arrays.asList(args));\r
String modelContent = IOUtils.toString(\r
ConfigResourceAssignmentTestUtils.class.getClassLoader().getResourceAsStream(\r
"service_templates/" + serviceTemplateName + "/" + serviceTemplateName + ".json"),\r
Charset.defaultCharset());\r
- \r
+\r
ConfigModelContent configModelContent = new ConfigModelContent();\r
configModelContent.setContent(modelContent);\r
configModelContent.setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON);\r
- \r
+\r
List<ConfigModelContent> configModelContents = new ArrayList<>();\r
configModelContents.add(configModelContent);\r
- \r
+\r
String velocityDir = ConfigResourceAssignmentTestUtils.class.getClassLoader()\r
.getResource("service_templates/" + serviceTemplateName + "/velocity").getPath();\r
- \r
+\r
Collection<File> templateFiles =\r
FileUtils.listFiles(new File(velocityDir), new String[] {"vtl"}, true);\r
logger.info("Template Files info " + templateFiles);\r
configModelTemplateContent.setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TEMPLATE);\r
configModelContents.add(configModelTemplateContent);\r
}\r
- \r
+\r
serviceArtifact = new org.onap.ccsdk.config.model.domain.ConfigModel();\r
serviceArtifact.setArtifactName(String.valueOf(args[0]));\r
serviceArtifact.setArtifactVersion(String.valueOf(args[1]));\r
serviceArtifact.setPublished("Y");\r
serviceArtifact.setConfigModelContents(configModelContents);\r
}\r
- \r
+\r
return serviceArtifact;\r
}\r
}).when(configRestAdaptorService).getResource(anyString(), anyString(), Matchers.any(Class.class));\r
}\r
- \r
+\r
public static void injectResourceDictionaryMock(ConfigRestAdaptorService configRestAdaptorService,\r
String dictionaryFileName) throws Exception {\r
- \r
+\r
Mockito.doAnswer(new Answer<String>() {\r
@Override\r
public String answer(InvocationOnMock invocationOnMock) throws Throwable {\r
}).when(configRestAdaptorService).postResource(Matchers.any(), Matchers.any(), Matchers.any(),\r
Matchers.any(Class.class));\r
}\r
- \r
+\r
public static void injectConfigResourceSaveMock(ConfigResourceService configResourceService) throws Exception {\r
Mockito.doAnswer(new Answer<ConfigResource>() {\r
@Override\r
}\r
}).when(configResourceService).saveConfigResource(any(ConfigResource.class));\r
}\r
- \r
+\r
public static void injectGetConfigResourceMock(ConfigResourceService configResourceService,\r
ConfigResource configResource) throws Exception {\r
Mockito.doAnswer(new Answer<List<ConfigResource>>() {\r
}\r
}).when(configResourceService).getConfigResource(any(ConfigResource.class));\r
}\r
- \r
+\r
public static String getFileContent(String filePath) throws Exception {\r
return IOUtils.toString(ConfigResourceAssignmentTestUtils.class.getClassLoader().getResourceAsStream(filePath),\r
Charset.defaultCharset());\r
}\r
- \r
+\r
public static Map<String, ResourceDefinition> getMapfromJson(String content) {\r
try {\r
ObjectMapper mapper = new ObjectMapper();\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.assignment.service;\r
import com.fasterxml.jackson.databind.JsonNode;\r
\r
public class ResourceAssignmentGenerationTest {\r
- \r
+\r
private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceAssignmentGenerationTest.class);\r
- \r
+\r
@Test\r
public void testResourceDataSetting() {\r
try {\r
logger.info(" **************** testResourceDataSetting *****************");\r
String resourceAssignmentContents = IOUtils.toString(TopologicalSortingTest.class.getClassLoader()\r
.getResourceAsStream("assignments/alltype-empty-value-mapping.json"), Charset.defaultCharset());\r
- \r
+\r
List<ResourceAssignment> assignments =\r
TransformationUtils.getListfromJson(resourceAssignmentContents, ResourceAssignment.class);\r
if (assignments != null) {\r
}\r
String generatedData = ResourceAssignmentUtils.generateResourceDataForAssignments(assignments);\r
logger.trace("Generated Data " + generatedData);\r
- \r
+\r
Assert.assertNotNull("Failed to generate resource data", generatedData);\r
}\r
} catch (Exception e) {\r
e.printStackTrace();\r
}\r
}\r
- \r
+\r
@Test\r
public void testGenerateResourceData() {\r
try {\r
logger.info(" **************** testGenerateResourceData *****************");\r
String resourceAssignmentContents = IOUtils.toString(TopologicalSortingTest.class.getClassLoader()\r
.getResourceAsStream("assignments/alltype-mapping.json"), Charset.defaultCharset());\r
- \r
+\r
List<ResourceAssignment> assignments =\r
TransformationUtils.getListfromJson(resourceAssignmentContents, ResourceAssignment.class);\r
if (assignments != null) {\r
- \r
+\r
String generatedData = ResourceAssignmentUtils.generateResourceDataForAssignments(assignments);\r
logger.trace("Generated Data " + generatedData);\r
- \r
+\r
Assert.assertNotNull("Failed to generate resource data", generatedData);\r
}\r
} catch (Exception e) {\r
e.printStackTrace();\r
}\r
}\r
- \r
+\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.assignment.service;\r
\r
public class ResourceAssignmentValidation {\r
private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceAssignmentValidation.class);\r
- \r
+\r
@Rule\r
public final ExpectedException exception = ExpectedException.none();\r
- \r
+\r
@Test\r
public void testValidateSuccess() {\r
try {\r
String resourceMapping = IOUtils.toString(\r
TopologicalSortingTest.class.getClassLoader().getResourceAsStream("validation/success.json"),\r
Charset.defaultCharset());\r
- \r
+\r
List<ResourceAssignment> assignments =\r
TransformationUtils.getListfromJson(resourceMapping, ResourceAssignment.class);\r
if (assignments != null) {\r
ResourceAssignmentValidator resourceAssignmentValidator = new ResourceAssignmentValidator(assignments);\r
- \r
+\r
boolean result = resourceAssignmentValidator.validateResourceAssignment();\r
Assert.assertTrue("Failed to Validate", result);\r
}\r
e.printStackTrace();\r
}\r
}\r
- \r
+\r
@Test(expected = ConfigModelException.class)\r
public void testValidateDuplicate() throws IOException, ConfigModelException {\r
logger.info(" **************** testValidateDuplicate *****************");\r
String resourceMapping = IOUtils.toString(\r
TopologicalSortingTest.class.getClassLoader().getResourceAsStream("validation/duplicate.json"),\r
Charset.defaultCharset());\r
- \r
+\r
List<ResourceAssignment> assignments =\r
TransformationUtils.getListfromJson(resourceMapping, ResourceAssignment.class);\r
if (assignments != null) {\r
ResourceAssignmentValidator resourceAssignmentValidator = new ResourceAssignmentValidator(assignments);\r
resourceAssignmentValidator.validateResourceAssignment();\r
}\r
- \r
+\r
}\r
- \r
+\r
@Test(expected = ConfigModelException.class)\r
public void testValidateCyclic() throws IOException, ConfigModelException {\r
logger.info(" **************** testValidateCyclic *****************");\r
String resourceMapping = IOUtils.toString(\r
TopologicalSortingTest.class.getClassLoader().getResourceAsStream("validation/cyclic.json"),\r
Charset.defaultCharset());\r
- \r
+\r
List<ResourceAssignment> assignments =\r
TransformationUtils.getListfromJson(resourceMapping, ResourceAssignment.class);\r
if (assignments != null) {\r
ResourceAssignmentValidator resourceAssignmentValidator = new ResourceAssignmentValidator(assignments);\r
- \r
+\r
resourceAssignmentValidator.validateResourceAssignment();\r
}\r
- \r
+\r
}\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
- * in compliance with the License. You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
* \r
* http://www.apache.org/licenses/LICENSE-2.0\r
* \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License\r
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
- * or implied. See the License for the specific language governing permissions and limitations under\r
- * the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
*/\r
\r
package org.onap.ccsdk.config.assignment.service;\r
\r
public class TopologicalSortingTest {\r
private static EELFLogger logger = EELFManager.getInstance().getLogger(TopologicalSortingTest.class);\r
- \r
+\r
@Test\r
public void testBulkSequencingMapping() {\r
try {\r
String resourceMapping = IOUtils.toString(\r
TopologicalSortingTest.class.getClassLoader().getResourceAsStream("mapping/dependency.json"),\r
Charset.defaultCharset());\r
- \r
+\r
List<ResourceAssignment> assignments =\r
TransformationUtils.getListfromJson(resourceMapping, ResourceAssignment.class);\r
if (assignments != null) {\r
ResourceAssignmentProcessor resourceAssignmentProcessor =\r
new ResourceAssignmentProcessor(assignments, ctx);\r
List<List<ResourceAssignment>> sequenceBatchResourceAssignment = resourceAssignmentProcessor.process();\r
- \r
+\r
Assert.assertNotNull("Failed to populate Sequence Bulk Mappings", sequenceBatchResourceAssignment);\r
Assert.assertNotEquals("Failed to populate Sequence Bulk Mappings size ",\r
(sequenceBatchResourceAssignment.size() > 0));\r
e.printStackTrace();\r
}\r
}\r
- \r
+\r
}\r