+++ /dev/null
-# 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
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright © 2017-2018 AT&T Intellectual Property. Modifications Copyright
- © 2018 IBM. Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License. You may
- obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software distributed
- under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
- OR CONDITIONS OF ANY KIND, either express or implied. See the License for
- the specific language governing permissions and limitations under the License. -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onap.ccsdk.parent</groupId>
- <artifactId>binding-parent</artifactId>
- <version>1.5.2-SNAPSHOT</version>
- <relativePath/>
- </parent>
-
- <groupId>org.onap.ccsdk.features</groupId>
- <artifactId>blueprints-data-adaptor-provider</artifactId>
- <version>0.7.1-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <name>ccsdk-features :: blueprints-processor-adaptor :: ${project.artifactId}</name>
- <url>http://maven.apache.org</url>
-
- <properties>
- <ccsdk.sli.core.version>${project.version}</ccsdk.sli.core.version>
- </properties>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.onap.ccsdk.sli.core</groupId>
- <artifactId>sli-core-artifacts</artifactId>
- <version>${ccsdk.sli.core.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onap.ccsdk.sli.core</groupId>
- <artifactId>sli-provider</artifactId>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- </dependency>
- <dependency>
- <groupId>org.mariadb.jdbc</groupId>
- <artifactId>mariadb-java-client</artifactId>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-jdbc</artifactId>
- </dependency>
- <dependency>
- <groupId>com.att.eelf</groupId>
- <artifactId>eelf-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <configuration>
- <additionalparam>-Xdoclint:none</additionalparam>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Name>${project.artifactId}</Bundle-Name>
- <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>org.onap.ccsdk.features.data.adaptor,
- org.onap.ccsdk.features.data.adaptor.dao,
- org.onap.ccsdk.features.data.adaptor.db,
- org.onap.ccsdk.features.data.adaptor.domain,
- org.onap.ccsdk.features.data.adaptor.service
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-/*\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.features.data.adaptor;\r
-\r
-/**\r
- * ConfigDataAdaptorException.java Purpose: Provide Configuration Data Adaptor Exception\r
- *\r
- * @version 1.0\r
- */\r
-public class ConfigDataAdaptorException extends Exception {\r
-\r
- /**\r
- *\r
- */\r
- private static final long serialVersionUID = 1L;\r
-\r
- /**\r
- * This is a ConfigDataAdaptorException constructor\r
- *\r
- * @param message\r
- */\r
- public ConfigDataAdaptorException(String message) {\r
- super(message);\r
- }\r
-\r
- /**\r
- * This is a ConfigDataAdaptorException constructor\r
- *\r
- * @param message\r
- */\r
- public ConfigDataAdaptorException(String message, Throwable cause) {\r
- super(message, cause);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.data.adaptor;\r
-\r
-@SuppressWarnings("squid:S1118")\r
-public class DataAdaptorConstants {\r
-\r
- public static final String OUTPUT_STATUS_SUCCESS = "success";\r
- public static final String OUTPUT_STATUS_FAILURE = "failure";\r
-\r
- public static final String PROPERTY_ENV_TYPE = "org.onap.ccsdk.features.blueprints.adaptors.envtype";\r
- public static final String PROPERTY_ENV_PROD = "field";\r
- public static final String PROPERTY_ENV_SOLO = "solo";\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_MESSAGE_TYPE = "messageType";\r
- public static final String OUTPUT_PARAM_STATUS = "status";\r
- public static final String OUTPUT_PARAM_ERROR_MESSAGE = "error-message";\r
- public static final String INPUT_PARAM_FILE_CATEGORY = "fileCategory";\r
- public static final String INPUT_PARAM_VM_INSTANCE = "vmInstance";\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
- public static final Object INPUT_PARAM_CONFIG_CONTENT_TYPE = "configContentType";\r
-\r
- public static final Object INPUT_PARAM_CONFIG_CONTENT = "configContent";\r
- public static final Object INPUT_PARAM_CONFIG_INDICATOR = "configIndicator";\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
- 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
- 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
- public static final String ARTIFACT_TYPE_SDNC_MODEL = "SDNC_MODEL";\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
- 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
+++ /dev/null
-/*\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.features.data.adaptor.dao;\r
-\r
-import java.util.List;\r
-import org.onap.ccsdk.features.data.adaptor.domain.ConfigResource;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-\r
-public interface ConfigResourceDao {\r
-\r
- /**\r
- * Issue a single SQL Insert operation for CONFIG_RESOURCE table via a prepared statement, binding\r
- * the given arguments.\r
- *\r
- * @param transactionLog arguments to bind to the query (mapping it to the PreparedStatement to the\r
- * corresponding SQL type)\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
- * Issue a single SQL Delete operation for CONFIG_RESOURCE table via a prepared statement, binding\r
- * the given arguments.\r
- *\r
- * @param configResource arguments to bind to the query (mapping it to the PreparedStatement to the\r
- * corresponding SQL type)\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
- * 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
- *\r
- * @param configResource argument to bind to the query (mapping it to the PreparedStatement to the\r
- * corresponding SQL type)\r
- * @return the result List, containing mapped objects\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
- public ConfigResource getConfigResource(ConfigResource configResource) throws SvcLogicException;\r
-}\r
+++ /dev/null
-/*\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.features.data.adaptor.dao;\r
-\r
-import java.sql.ResultSet;\r
-import java.sql.SQLException;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.data.adaptor.domain.ConfigResource;\r
-import org.onap.ccsdk.features.data.adaptor.domain.ResourceAssignmentData;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import org.springframework.jdbc.core.JdbcTemplate;\r
-import org.springframework.jdbc.core.RowMapper;\r
-import org.springframework.jdbc.core.RowMapperResultSetExtractor;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class ConfigResourceDaoImpl implements ConfigResourceDao {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigResourceDaoImpl.class);\r
-\r
- private JdbcTemplate jdbcTemplate;\r
-\r
- public ConfigResourceDaoImpl(JdbcTemplate jdbcTemplate) {\r
- this.jdbcTemplate = jdbcTemplate;\r
- }\r
-\r
- @Override\r
- public ConfigResource save(ConfigResource configResource) throws SvcLogicException {\r
-\r
- ConfigResource dbConfigResource = checkConfigResource(configResource);\r
-\r
- if (dbConfigResource != null && StringUtils.isNotBlank(dbConfigResource.getConfigResourceId())) {\r
- configResource.setConfigResourceId(dbConfigResource.getConfigResourceId());\r
-\r
- validateConfigResource(configResource);\r
-\r
- update(configResource);\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
- configResource.setConfigResourceId(configResource.getUniqueId());\r
-\r
- validateConfigResource(configResource);\r
-\r
- logger.info("saving config resource ({}) ...", configResource);\r
- jdbcTemplate.update(addQuery, configResource.getConfigResourceId(), configResource.getResourceId(),\r
- configResource.getResourceType(), configResource.getServiceTemplateName(),\r
- configResource.getServiceTemplateVersion(), configResource.getTemplateName(),\r
- configResource.getRecipeName(), configResource.getRequestId(), configResource.getResourceData(),\r
- configResource.getMaskData(), configResource.getStatus(), configResource.getCreatedDate(),\r
- configResource.getUpdatedBy());\r
-\r
- saveConfigResourceAssignmentData(configResource);\r
- }\r
- dbConfigResource = getConfigResource(configResource);\r
- return dbConfigResource;\r
- }\r
-\r
- private void update(ConfigResource configResource) throws SvcLogicException {\r
- if (StringUtils.isNotBlank(configResource.getConfigResourceId())) {\r
- logger.info("updating config resource ({}) ...", configResource);\r
- // Added service_template_name and version in update query to update with 1802 data.\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
- jdbcTemplate.update(updateQuery, configResource.getResourceData(), configResource.getMaskData(),\r
- configResource.getCreatedDate(), configResource.getUpdatedBy(),\r
- configResource.getServiceTemplateName(), configResource.getServiceTemplateVersion(),\r
- configResource.getConfigResourceId());\r
- } else {\r
- throw new SvcLogicException("missing config resource id to update.");\r
- }\r
- }\r
-\r
- private void saveConfigResourceAssignmentData(ConfigResource configResource) {\r
- if (configResource != null && StringUtils.isNotBlank(configResource.getConfigResourceId())) {\r
- List<Object> listOfArguments = new ArrayList<>();\r
- String deleteQuery = "DELETE FROM CONFIG_RESOURCE_ASSIGNMENT_DATA WHERE config_resource_id = ? ";\r
- listOfArguments.add(configResource.getConfigResourceId());\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
- if (configResource.getResourceAssignments() != null) {\r
- List<ResourceAssignmentData> resourceAssignments = configResource.getResourceAssignments();\r
- for (ResourceAssignmentData resourceAssignmentData : resourceAssignments) {\r
- if (resourceAssignmentData != null) {\r
- resourceAssignmentData.setConfigResourceId(configResource.getConfigResourceId());\r
- saveResourceAssignmentData(resourceAssignmentData);\r
- }\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
- logger.debug("saving config resource assignment data ({}) ... ", resourceAssignmentData);\r
- jdbcTemplate.update(addQuery, resourceAssignmentData.getId(), resourceAssignmentData.getConfigResourceId(),\r
- resourceAssignmentData.getVersion(), resourceAssignmentData.getUpdatedBy(),\r
- resourceAssignmentData.getTemplateKeyName(), resourceAssignmentData.getResourceName(),\r
- resourceAssignmentData.getDataType(), resourceAssignmentData.getEntrySchema(),\r
- resourceAssignmentData.getResourceValue(), resourceAssignmentData.getSource(),\r
- resourceAssignmentData.getStatus(), resourceAssignmentData.getMessage());\r
-\r
- return resourceAssignmentData;\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
- selectArtifactBuffer.append("DELETE FROM CONFIG_RESOURCE WHERE config_resource_id = ? ");\r
- listOfArguments.add(configResourceInput.getConfigResourceId());\r
-\r
- String queryString = selectArtifactBuffer.toString();\r
- this.jdbcTemplate.update(queryString, listOfArguments.toArray());\r
- logger.info("config resource ({}) deleted successfully ", configResourceInput);\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
- selectArtifactBuffer.append("SELECT * FROM CONFIG_RESOURCE WHERE ");\r
-\r
- StringBuilder whereClauseRemaining = new StringBuilder();\r
-\r
- if (configResourceInput.getServiceTemplateName() != null) {\r
- if (whereClauseRemaining.length() != 0) {\r
- whereClauseRemaining.append("AND ");\r
- }\r
- whereClauseRemaining.append("service_template_name = ? ");\r
- listOfArguments.add(configResourceInput.getServiceTemplateName());\r
- }\r
-\r
- if (configResourceInput.getServiceTemplateVersion() != null) {\r
- if (whereClauseRemaining.length() != 0) {\r
- whereClauseRemaining.append("AND ");\r
- }\r
- whereClauseRemaining.append("service_template_version = ? ");\r
- listOfArguments.add(configResourceInput.getServiceTemplateVersion());\r
- }\r
-\r
- if (configResourceInput.getResourceId() != null) {\r
- if (whereClauseRemaining.length() != 0) {\r
- whereClauseRemaining.append("AND ");\r
- }\r
- whereClauseRemaining.append("resource_id = ? ");\r
- listOfArguments.add(configResourceInput.getResourceId());\r
- }\r
-\r
- if (configResourceInput.getResourceType() != null) {\r
- if (whereClauseRemaining.length() != 0) {\r
- whereClauseRemaining.append("AND ");\r
- }\r
- whereClauseRemaining.append("resource_type = ? ");\r
- listOfArguments.add(configResourceInput.getResourceType());\r
- }\r
-\r
- if (configResourceInput.getRequestId() != null) {\r
- if (whereClauseRemaining.length() != 0) {\r
- whereClauseRemaining.append("AND ");\r
- }\r
- whereClauseRemaining.append("request_id = ? ");\r
- listOfArguments.add(configResourceInput.getRequestId());\r
- }\r
-\r
- if (configResourceInput.getTemplateName() != null) {\r
- if (whereClauseRemaining.length() != 0) {\r
- whereClauseRemaining.append("AND ");\r
- }\r
- whereClauseRemaining.append("template_name = ? ");\r
- listOfArguments.add(configResourceInput.getTemplateName());\r
- }\r
-\r
- if (configResourceInput.getRecipeName() != null) {\r
- if (whereClauseRemaining.length() != 0) {\r
- whereClauseRemaining.append("AND ");\r
- }\r
- whereClauseRemaining.append("recipe_name = ? ");\r
- listOfArguments.add(configResourceInput.getRecipeName());\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
- List<ConfigResource> returnConfigResources = new ArrayList<>();\r
-\r
- if (configResources != null) {\r
- for (ConfigResource configResource : configResources) {\r
- if (configResource != null) {\r
- returnConfigResources.add(getConfigResource(configResource));\r
- }\r
- }\r
- }\r
- return returnConfigResources;\r
- }\r
-\r
- public ConfigResource checkConfigResource(ConfigResource configResource) {\r
- StringBuilder selectBuffer = new StringBuilder();\r
- List<Object> listOfArguments = new ArrayList<>();\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.getResourceType());\r
- listOfArguments.add(configResource.getTemplateName());\r
- return queryOneForObject(selectBuffer.toString(), listOfArguments.toArray(), new ConfigResourceMapper());\r
- }\r
-\r
- @Override\r
- public ConfigResource getConfigResource(ConfigResource configResource) throws SvcLogicException {\r
- ConfigResource dbConfigResource = checkConfigResource(configResource);\r
- if (dbConfigResource != null && StringUtils.isNotBlank(dbConfigResource.getConfigResourceId())) {\r
- List<ResourceAssignmentData> resourceAssignments =\r
- getResourceAssignmentdata(dbConfigResource.getConfigResourceId());\r
- configResource.setResourceAssignments(resourceAssignments);\r
- }\r
- return configResource;\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
- logger.info("getResourceAssignmentdata queryString ({}), query inputs ({})", queryString, configResourceId);\r
- listOfArguments.add(configResourceId);\r
- return this.jdbcTemplate.query(queryString, listOfArguments.toArray(), new ResourceAssignmentDataMapper());\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
- if (StringUtils.isBlank(configResource.getConfigResourceId())) {\r
- throw new SvcLogicException("config resource id is missing.");\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
- if (StringUtils.isBlank(configResource.getRecipeName())) {\r
- throw new SvcLogicException("config resource action name is missing.");\r
- }\r
-\r
- if (StringUtils.isBlank(configResource.getTemplateName())) {\r
- throw new SvcLogicException("config resource template name is missing.");\r
- }\r
-\r
- if (configResource.getResourceAssignments() != null) {\r
- List<ResourceAssignmentData> resourceAssignments = configResource.getResourceAssignments();\r
- for (ResourceAssignmentData resourceAssignmentData : resourceAssignments) {\r
- if (resourceAssignmentData != null) {\r
- resourceAssignmentData.setConfigResourceId(configResource.getConfigResourceId());\r
- if (StringUtils.isBlank(resourceAssignmentData.getId())) {\r
- resourceAssignmentData.setId(resourceAssignmentData.getUniqueId());\r
- }\r
- if (resourceAssignmentData.getVersion() == null || resourceAssignmentData.getVersion() == 0) {\r
- resourceAssignmentData.setVersion(1);\r
- }\r
- if (StringUtils.isBlank(resourceAssignmentData.getUpdatedBy())) {\r
- resourceAssignmentData.setUpdatedBy("System");\r
- }\r
- if (resourceAssignmentData.getStatus() == null) {\r
- logger.warn("{} status is missing and setting to undefined", resourceAssignmentData);\r
- resourceAssignmentData.setStatus("undefined");\r
- }\r
- if (resourceAssignmentData.getMessage() == null) {\r
- resourceAssignmentData.setMessage("");\r
- }\r
- if (resourceAssignmentData.getResourceValue() == null) {\r
- resourceAssignmentData.setResourceValue("");\r
- }\r
-\r
- validateResourceAssignmentData(resourceAssignmentData);\r
- }\r
- }\r
- }\r
-\r
- return true;\r
- }\r
-\r
- private boolean validateResourceAssignmentData(ResourceAssignmentData resourceAssignmentData)\r
- throws SvcLogicException {\r
- if (resourceAssignmentData == null) {\r
- throw new SvcLogicException("resource assignment data information is missing.");\r
- }\r
- if (StringUtils.isBlank(resourceAssignmentData.getConfigResourceId())) {\r
- throw new SvcLogicException("resource assignment data config resource id is missing.");\r
- }\r
- if (resourceAssignmentData.getVersion() == null) {\r
- throw new SvcLogicException(\r
- String.format("resource assignment data (%s) version is missing", resourceAssignmentData));\r
- }\r
- if (StringUtils.isBlank(resourceAssignmentData.getTemplateKeyName())) {\r
- throw new SvcLogicException(String.format("resource assignment data (%s) template key name is missing",\r
- resourceAssignmentData));\r
- }\r
- if (StringUtils.isBlank(resourceAssignmentData.getResourceName())) {\r
- throw new SvcLogicException(\r
- String.format("resource assignment data (%s) resource name is missing", resourceAssignmentData));\r
- }\r
- if (resourceAssignmentData.getResourceValue() == null) {\r
- throw new SvcLogicException(\r
- String.format("resource assignment data (%s) resource value is missing", resourceAssignmentData));\r
- }\r
- if (StringUtils.isBlank(resourceAssignmentData.getSource())) {\r
- throw new SvcLogicException(\r
- String.format("resource assignment data (%s) source is missing", resourceAssignmentData));\r
- }\r
- if (StringUtils.isBlank(resourceAssignmentData.getDataType())) {\r
- throw new SvcLogicException(\r
- String.format("resource assignment data (%s) data type is missing", resourceAssignmentData));\r
- }\r
- if (StringUtils.isBlank(resourceAssignmentData.getStatus())) {\r
- throw new SvcLogicException(\r
- String.format("resource assignment data (%s) status is missing", resourceAssignmentData));\r
- }\r
- if (resourceAssignmentData.getMessage() == null) {\r
- throw new SvcLogicException(\r
- String.format("resource assignment data (%s) message is missing", resourceAssignmentData));\r
- }\r
- return true;\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 results.get(0);\r
- } else {\r
- return null;\r
- }\r
- }\r
-\r
- class ConfigResourceMapper implements RowMapper<ConfigResource> {\r
- @Override\r
- public ConfigResource mapRow(ResultSet rs, int rowNum) throws SQLException {\r
- ConfigResource configResource = new ConfigResource();\r
- configResource.setConfigResourceId(rs.getString("config_resource_id"));\r
- configResource.setResourceId(rs.getString("resource_id"));\r
- configResource.setResourceType(rs.getString("resource_type"));\r
- configResource.setServiceTemplateName(rs.getString("service_template_name"));\r
- configResource.setServiceTemplateVersion(rs.getString("service_template_version"));\r
- configResource.setTemplateName(rs.getString("template_name"));\r
- configResource.setRecipeName(rs.getString("recipe_name"));\r
- configResource.setRequestId(rs.getString("request_id"));\r
- configResource.setResourceData(rs.getString("resource_data"));\r
- configResource.setMaskData(rs.getString("mask_data"));\r
- configResource.setStatus(rs.getString("status"));\r
- configResource.setCreatedDate(rs.getDate("created_date"));\r
- configResource.setUpdatedBy(rs.getString("updated_by"));\r
- return configResource;\r
- }\r
- }\r
-\r
- class ResourceAssignmentDataMapper implements RowMapper<ResourceAssignmentData> {\r
- @Override\r
- public ResourceAssignmentData mapRow(ResultSet rs, int rowNum) throws SQLException {\r
- ResourceAssignmentData resourceAssignmentData = new ResourceAssignmentData();\r
- resourceAssignmentData.setConfigResourceId(rs.getString("config_resource_id"));\r
- resourceAssignmentData.setDataType(rs.getString("data_type"));\r
- resourceAssignmentData.setEntrySchema(rs.getString("entry_schema"));\r
- resourceAssignmentData.setId(rs.getString("config_resource_assignment_data_id"));\r
- resourceAssignmentData.setMessage(rs.getString("message"));\r
- resourceAssignmentData.setResourceName(rs.getString("resource_name"));\r
- resourceAssignmentData.setResourceValue(rs.getString("resource_value"));\r
- resourceAssignmentData.setSource(rs.getString("source"));\r
- resourceAssignmentData.setStatus(rs.getString("status"));\r
- resourceAssignmentData.setTemplateKeyName(rs.getString("template_key_name"));\r
- resourceAssignmentData.setUpdatedBy(rs.getString("updated_by"));\r
- resourceAssignmentData.setUpdatedDate(rs.getTimestamp("updated_date"));\r
- resourceAssignmentData.setVersion(rs.getInt("version"));\r
- return resourceAssignmentData;\r
- }\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.data.adaptor.dao;\r
-\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;\r
-\r
-public interface NamedQueryExecutorDao {\r
- /**\r
- * Return NamedParameterJdbcTemplate object.\r
- */\r
- public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() throws SvcLogicException;\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
- * <p>\r
- * The results will be mapped to a List (one entry for each row) of Maps (one entry for each column,\r
- * using the column name as the key).\r
- *\r
- * @param sql SQL query to execute\r
- * @param param map of parameters to bind to the query (leaving it to the PreparedStatement to guess\r
- * the corresponding SQL type)\r
- * @return a List that contains a Map per row\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
- * Issue an update via a prepared statement, binding the given arguments.\r
- *\r
- * @param sql SQL containing named parameters\r
- * @param param map of parameters to bind to the query (leaving it to the PreparedStatement to guess\r
- * the corresponding SQL type)\r
- * @return the number of rows affected\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
+++ /dev/null
-/*\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.features.data.adaptor.dao;\r
-\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import org.springframework.beans.factory.annotation.Autowired;\r
-import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\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
- @Autowired(required = true)\r
- private NamedParameterJdbcTemplate namedParameterJdbcTemplate;\r
-\r
- public NamedQueryExecutorDaoImpl(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {\r
- this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;\r
- logger.info("{} Constructor initialised..", CLASS_NAME);\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
- @Override\r
- public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() {\r
- return namedParameterJdbcTemplate;\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
- return namedParameterJdbcTemplate.update(sql, parameters);\r
- }\r
-}\r
+++ /dev/null
-/*\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.features.data.adaptor.dao;\r
-\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-\r
-public interface QueryExecutorDao {\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
- * <p>\r
- * The results will be mapped to a List (one entry for each row) of Maps (one entry for each column,\r
- * using the column name as the key). Each element in the list will be of the form returned by this\r
- * interface's queryForMap() methods.\r
- *\r
- * @param sql SQL query to execute\r
- * @param data arguments to bind to the query (leaving it to the PreparedStatement to guess the\r
- * corresponding SQL type)\r
- * @return a List that contains a Map per row\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
- * Issue a single SQL update operation (such as an insert, update or delete statement) via a\r
- * prepared statement, binding the given arguments.\r
- *\r
- * @param sql SQL containing bind parameters\r
- * @param data arguments to bind to the query (leaving it to the PreparedStatement to guess the\r
- * corresponding SQL type)\r
- * @return the number of rows affected\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
+++ /dev/null
-/*\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.features.data.adaptor.dao;\r
-\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import org.springframework.beans.factory.annotation.Autowired;\r
-import org.springframework.jdbc.core.JdbcTemplate;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class QueryExecutorDaoImpl implements QueryExecutorDao {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(QueryExecutorDaoImpl.class);\r
- private static final String CLASS_NAME = "QueryExecutorDaoImpl";\r
-\r
- @Autowired(required = true)\r
- private JdbcTemplate jdbcTemplate;\r
-\r
- public QueryExecutorDaoImpl(JdbcTemplate jdbcTemplate) {\r
- this.jdbcTemplate = jdbcTemplate;\r
- logger.info("{} Constructor initialised..", CLASS_NAME);\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
- @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
+++ /dev/null
-/*\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.features.data.adaptor.dao;\r
-\r
-import java.util.List;\r
-import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-\r
-public interface TransactionLogDao {\r
-\r
- /**\r
- * Issue a single SQL Insert operation for CONFIG_TRANSACTION_LOG table via a prepared statement,\r
- * binding the given arguments.\r
- *\r
- * @param transactionLog arguments to bind to the query (mapping it to the PreparedStatement to the\r
- * corresponding SQL type)\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
- * Query CONFIG_TRANSACTION_LOG table for given request_id, mapping each row to a Java object via a\r
- * TransactionLog RowMapper.\r
- *\r
- * @param requestId argument to bind to the query (leaving it to the PreparedStatement to guess the\r
- * corresponding SQL type)\r
- * @return the result List, containing mapped objects\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
- * Query CONFIG_TRANSACTION_LOG table for given request_id, mapping each row to a Java object via a\r
- * TransactionLog RowMapper.\r
- *\r
- * @param requestId argument to bind to the query (leaving it to the PreparedStatement to guess the\r
- * corresponding SQL type)\r
- * @param messageType argument to bind to the query (leaving it to the PreparedStatement to guess\r
- * the corresponding SQL type)\r
- * @return the result List, containing mapped objects\r
- * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
- */\r
- public List<TransactionLog> getTransactionsByRequestId(String requestId, String messageType)\r
- throws SvcLogicException;\r
-\r
-}\r
+++ /dev/null
-/*\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.features.data.adaptor.dao;\r
-\r
-import java.sql.ResultSet;\r
-import java.sql.SQLException;\r
-import java.util.List;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import org.springframework.jdbc.core.JdbcTemplate;\r
-import org.springframework.jdbc.core.RowMapper;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class TransactionLogDaoImpl implements TransactionLogDao {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(TransactionLogDaoImpl.class);\r
-\r
- private JdbcTemplate jdbcTemplate;\r
-\r
- public TransactionLogDaoImpl(JdbcTemplate jdbcTemplate) {\r
- this.jdbcTemplate = jdbcTemplate;\r
- }\r
-\r
- @Override\r
- public void save(TransactionLog transactionLog) throws SvcLogicException {\r
- if (transactionLog != null && StringUtils.isNotBlank(transactionLog.getRequestId())) {\r
- String addSql =\r
- "INSERT INTO CONFIG_TRANSACTION_LOG ( config_transaction_log_id, request_id, message_type, message ) VALUES (?, ?, ?, ?) ";\r
- jdbcTemplate.update(addSql, transactionLog.getUniqueId(), transactionLog.getRequestId(),\r
- transactionLog.getMessageType(), transactionLog.getMessage());\r
- logger.trace("TransactionLog Updated Successfully for message_type {}", transactionLog.getMessageType());\r
- }\r
-\r
- }\r
-\r
- @Override\r
- public List<TransactionLog> getTransactionsByRequestId(String requestId) throws SvcLogicException {\r
- if (StringUtils.isNotBlank(requestId)) {\r
- String selectByRequestIdSql =\r
- "SELECT * FROM CONFIG_TRANSACTION_LOG WHERE request_id = ? ORDER BY creation_date DESC";\r
- return this.jdbcTemplate.query(selectByRequestIdSql, new Object[] {requestId}, new TransactionLogMapper());\r
- } else {\r
- throw new SvcLogicException("TransactionLog Request id (" + requestId + ")is missing ");\r
- }\r
- }\r
-\r
- @Override\r
- public List<TransactionLog> getTransactionsByRequestId(String requestId, String messageType)\r
- throws SvcLogicException {\r
- if (StringUtils.isNotBlank(requestId)) {\r
- String selectByRequestIdSql =\r
- "SELECT * FROM CONFIG_TRANSACTION_LOG WHERE request_id = ? and message_type = ? ORDER BY creation_date DESC";\r
- return this.jdbcTemplate.query(selectByRequestIdSql, new Object[] {requestId, messageType},\r
- new TransactionLogMapper());\r
- } else {\r
- throw new SvcLogicException("TransactionLog Request id (" + requestId + ")is missing ");\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
- TransactionLog transactionLog = new TransactionLog();\r
- transactionLog.setCreationDate(rs.getDate("creation_date"));\r
- transactionLog.setMessage(rs.getString("message"));\r
- transactionLog.setMessageType(rs.getString("message_type"));\r
- transactionLog.setRequestId(rs.getString("request_id"));\r
- transactionLog.setTransactionLogId(rs.getString("config_transaction_log_id"));\r
- return transactionLog;\r
- }\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.data.adaptor.db;\r
-\r
-import java.io.PrintWriter;\r
-import java.sql.Connection;\r
-import java.sql.SQLException;\r
-import java.sql.SQLFeatureNotSupportedException;\r
-import javax.sql.DataSource;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class DataSourceWrap implements DataSource {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(DataSourceWrap.class);\r
-\r
- private DataSource dataSource;\r
-\r
- public DataSourceWrap(DataSource dataSource) {\r
- logger.info("Setting Data Source {} ", dataSource);\r
- this.dataSource = dataSource;\r
- }\r
-\r
- @Override\r
- public PrintWriter getLogWriter() throws SQLException {\r
- return dataSource.getLogWriter();\r
- }\r
-\r
- @Override\r
- public void setLogWriter(PrintWriter out) throws SQLException {\r
- dataSource.setLogWriter(out);\r
- }\r
-\r
- @Override\r
- public void setLoginTimeout(int seconds) throws SQLException {\r
- dataSource.setLoginTimeout(seconds);\r
- }\r
-\r
- @Override\r
- public int getLoginTimeout() throws SQLException {\r
- return dataSource.getLoginTimeout();\r
- }\r
-\r
- @Override\r
- public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException {\r
- return dataSource.getParentLogger();\r
- }\r
-\r
- @Override\r
- public <T> T unwrap(Class<T> iface) throws SQLException {\r
- return dataSource.unwrap(iface);\r
- }\r
-\r
- @Override\r
- public boolean isWrapperFor(Class<?> iface) throws SQLException {\r
- return dataSource.isWrapperFor(iface);\r
- }\r
-\r
- @SuppressWarnings("squid:S2095")\r
- @Override\r
- public Connection getConnection() throws SQLException {\r
- Connection c = dataSource.getConnection();\r
- logger.trace("getConnection: ({})", c.getClass().getName());\r
- c.setAutoCommit(true);\r
- return c;\r
- }\r
-\r
- @SuppressWarnings("squid:S2095")\r
- @Override\r
- public Connection getConnection(String username, String pass) throws SQLException {\r
- Connection c = dataSource.getConnection(username, pass);\r
- c.setAutoCommit(true);\r
- return c;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.data.adaptor.domain;\r
-\r
-import java.io.Serializable;\r
-import java.util.Date;\r
-import java.util.List;\r
-import java.util.UUID;\r
-\r
-public class ConfigResource implements Serializable {\r
- /**\r
- *\r
- */\r
- private static final long serialVersionUID = 1L;\r
-\r
- private String configResourceId;\r
- private String resourceId;\r
- private String resourceType;\r
- private String serviceTemplateName;\r
- private String serviceTemplateVersion;\r
- private String templateName;\r
- private String recipeName;\r
- private String requestId;\r
- private String resourceData;\r
- private String maskData;\r
- private Date createdDate = new Date();\r
- private String status;\r
- private String updatedBy;\r
- private List<ResourceAssignmentData> resourceAssignments;\r
-\r
- public String getConfigResourceId() {\r
- return configResourceId;\r
- }\r
-\r
- public void setConfigResourceId(String configResourceId) {\r
- this.configResourceId = configResourceId;\r
- }\r
-\r
- public String getResourceId() {\r
- return resourceId;\r
- }\r
-\r
- public void setResourceId(String resourceId) {\r
- this.resourceId = resourceId;\r
- }\r
-\r
- public String getResourceType() {\r
- return resourceType;\r
- }\r
-\r
- public void setResourceType(String resourceType) {\r
- this.resourceType = resourceType;\r
- }\r
-\r
- public String getServiceTemplateName() {\r
- return serviceTemplateName;\r
- }\r
-\r
- public void setServiceTemplateName(String serviceTemplateName) {\r
- this.serviceTemplateName = serviceTemplateName;\r
- }\r
-\r
- public String getServiceTemplateVersion() {\r
- return serviceTemplateVersion;\r
- }\r
-\r
- public void setServiceTemplateVersion(String serviceTemplateVersion) {\r
- this.serviceTemplateVersion = serviceTemplateVersion;\r
- }\r
-\r
- public String getTemplateName() {\r
- return templateName;\r
- }\r
-\r
- public void setTemplateName(String templateName) {\r
- this.templateName = templateName;\r
- }\r
-\r
- public String getRecipeName() {\r
- return recipeName;\r
- }\r
-\r
- public void setRecipeName(String recipeName) {\r
- this.recipeName = recipeName;\r
- }\r
-\r
- public String getRequestId() {\r
- return requestId;\r
- }\r
-\r
- public void setRequestId(String requestId) {\r
- this.requestId = requestId;\r
- }\r
-\r
- public String getResourceData() {\r
- return resourceData;\r
- }\r
-\r
- public void setResourceData(String resourceData) {\r
- this.resourceData = resourceData;\r
- }\r
-\r
- public String getMaskData() {\r
- return maskData;\r
- }\r
-\r
- public void setMaskData(String maskData) {\r
- this.maskData = maskData;\r
- }\r
-\r
- public Date getCreatedDate() {\r
- return createdDate;\r
- }\r
-\r
- public void setCreatedDate(Date createdDate) {\r
- this.createdDate = createdDate;\r
- }\r
-\r
- public String getStatus() {\r
- return status;\r
- }\r
-\r
- public void setStatus(String status) {\r
- this.status = status;\r
- }\r
-\r
- public String getUpdatedBy() {\r
- return updatedBy;\r
- }\r
-\r
- public void setUpdatedBy(String updatedBy) {\r
- this.updatedBy = updatedBy;\r
- }\r
-\r
- public List<ResourceAssignmentData> getResourceAssignments() {\r
- return resourceAssignments;\r
- }\r
-\r
- public void setResourceAssignments(List<ResourceAssignmentData> resourceAssignments) {\r
- this.resourceAssignments = resourceAssignments;\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return "ConfigResource [configResourceId=" + configResourceId + ", resourceId=" + resourceId\r
- + ", serviceTemplateName=" + serviceTemplateName + ", serviceTemplateVersion=" + serviceTemplateVersion\r
- + ", resourceType=" + resourceType + ", templateName=" + templateName + ", recipeName=" + recipeName\r
- + ", requestId=" + requestId + ", resourceData= ******** , maskData=" + maskData + ", createdDate="\r
- + createdDate + ", updatedBy=" + updatedBy + "]";\r
- }\r
-\r
- public String getUniqueId() {\r
- return UUID.randomUUID().toString();\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.data.adaptor.domain;\r
-\r
-import java.io.Serializable;\r
-import java.util.Date;\r
-import java.util.UUID;\r
-\r
-public class ResourceAssignmentData implements Serializable {\r
-\r
- private static final long serialVersionUID = 1L;\r
- private String id;\r
- private String configResourceId;\r
- private Integer version;\r
- private Date updatedDate = new Date();\r
- private String updatedBy;\r
- private String templateKeyName;\r
- private String resourceName;\r
- private String dataType;\r
- private String entrySchema;\r
- private String resourceValue;\r
- private String source;\r
- private String status;\r
- private String message;\r
-\r
- public String getUniqueId() {\r
- return UUID.randomUUID().toString();\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return "ResourceAssignmentData [id=" + id + ", configResourceId=" + configResourceId + ", version=" + version\r
- + ", updatedDate=" + updatedDate + ", updatedBy=" + updatedBy + ", templateKeyName=" + templateKeyName\r
- + ", resourceName=" + resourceName + ", dataType=" + dataType + ", source=" + source + ", status="\r
- + status + "]";\r
- }\r
-\r
- public String getId() {\r
- return id;\r
- }\r
-\r
- public void setId(String id) {\r
- this.id = id;\r
- }\r
-\r
- public String getConfigResourceId() {\r
- return configResourceId;\r
- }\r
-\r
- public void setConfigResourceId(String configResourceId) {\r
- this.configResourceId = configResourceId;\r
- }\r
-\r
- public Integer getVersion() {\r
- return version;\r
- }\r
-\r
- public void setVersion(Integer version) {\r
- this.version = version;\r
- }\r
-\r
- public Date getUpdatedDate() {\r
- return updatedDate;\r
- }\r
-\r
- public void setUpdatedDate(Date updatedDate) {\r
- this.updatedDate = updatedDate;\r
- }\r
-\r
- public String getUpdatedBy() {\r
- return updatedBy;\r
- }\r
-\r
- public void setUpdatedBy(String updatedBy) {\r
- this.updatedBy = updatedBy;\r
- }\r
-\r
- public String getTemplateKeyName() {\r
- return templateKeyName;\r
- }\r
-\r
- public void setTemplateKeyName(String templateKeyName) {\r
- this.templateKeyName = templateKeyName;\r
- }\r
-\r
- public String getResourceName() {\r
- return resourceName;\r
- }\r
-\r
- public void setResourceName(String resourceName) {\r
- this.resourceName = resourceName;\r
- }\r
-\r
- public String getDataType() {\r
- return dataType;\r
- }\r
-\r
- public void setDataType(String dataType) {\r
- this.dataType = dataType;\r
- }\r
-\r
- public String getEntrySchema() {\r
- return entrySchema;\r
- }\r
-\r
- public void setEntrySchema(String entrySchema) {\r
- this.entrySchema = entrySchema;\r
- }\r
-\r
- public String getResourceValue() {\r
- return resourceValue;\r
- }\r
-\r
- public void setResourceValue(String resourceValue) {\r
- this.resourceValue = resourceValue;\r
- }\r
-\r
- public String getSource() {\r
- return source;\r
- }\r
-\r
- public void setSource(String source) {\r
- this.source = source;\r
- }\r
-\r
- public String getStatus() {\r
- return status;\r
- }\r
-\r
- public void setStatus(String status) {\r
- this.status = status;\r
- }\r
-\r
- public String getMessage() {\r
- return message;\r
- }\r
-\r
- public void setMessage(String message) {\r
- this.message = message;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.data.adaptor.domain;\r
-\r
-import java.io.Serializable;\r
-import java.util.Date;\r
-import java.util.UUID;\r
-\r
-public class TransactionLog implements Serializable {\r
- private static final long serialVersionUID = 1L;\r
-\r
- private String transactionLogId;\r
- private String requestId;\r
- private String messageType;\r
- private Date creationDate;\r
- private String message;\r
-\r
- public TransactionLog() {\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
- @Override\r
- public String toString() {\r
- StringBuilder buffer = new StringBuilder("[");\r
- buffer.append("transactionLogId =" + transactionLogId);\r
- buffer.append(", requestId =" + requestId);\r
- buffer.append(", messageType =" + messageType);\r
- buffer.append(", creationDate =" + creationDate);\r
- buffer.append("]");\r
- return buffer.toString();\r
- }\r
-\r
- public String getTransactionLogId() {\r
- return transactionLogId;\r
- }\r
-\r
- public void setTransactionLogId(String transactionLogId) {\r
- this.transactionLogId = transactionLogId;\r
- }\r
-\r
- public String getRequestId() {\r
- return requestId;\r
- }\r
-\r
- public void setRequestId(String requestId) {\r
- this.requestId = requestId;\r
- }\r
-\r
- public String getMessageType() {\r
- return messageType;\r
- }\r
-\r
- public void setMessageType(String messageType) {\r
- this.messageType = messageType;\r
- }\r
-\r
- public Date getCreationDate() {\r
- return creationDate;\r
- }\r
-\r
- public void setCreationDate(Date creationDate) {\r
- this.creationDate = creationDate;\r
- }\r
-\r
- public String getMessage() {\r
- return message;\r
- }\r
-\r
- public void setMessage(String message) {\r
- this.message = message;\r
- }\r
-\r
- public String getUniqueId() {\r
- return UUID.randomUUID().toString();\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.data.adaptor.service;\r
-\r
-import java.util.Map;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.data.adaptor.DataAdaptorConstants;\r
-import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;\r
-\r
-public class ConfigResourceNode implements SvcLogicJavaPlugin {\r
-\r
- private ConfigResourceService configResourceService;\r
-\r
- public ConfigResourceNode(ConfigResourceService configResourceService) {\r
- this.configResourceService = configResourceService;\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
- 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
- TransactionLog transactionLog = new TransactionLog();\r
-\r
- transactionLog.setMessage(message);\r
- transactionLog.setMessageType(messageType);\r
- transactionLog.setRequestId(requestId);\r
-\r
- configResourceService.save(transactionLog);\r
-\r
- } catch (Exception e) {\r
- ctx.setAttribute(responsePrefix + DataAdaptorConstants.OUTPUT_PARAM_STATUS,\r
- DataAdaptorConstants.OUTPUT_STATUS_FAILURE);\r
- ctx.setAttribute(responsePrefix + DataAdaptorConstants.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());\r
- throw new SvcLogicException("Failed in saveConfigTransactionLog :" + e.getMessage());\r
- }\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.data.adaptor.service;\r
-\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.onap.ccsdk.features.data.adaptor.domain.ConfigResource;\r
-import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;\r
-\r
-public interface ConfigResourceService {\r
-\r
- /**\r
- * Return NamedParameterJdbcTemplate object.\r
- */\r
- public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() throws SvcLogicException;\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
- * <p>\r
- * The results will be mapped to a List (one entry for each row) of Maps (one entry for each column,\r
- * using the column name as the key).\r
- *\r
- * @param sql SQL query to execute\r
- * @param param map of parameters to bind to the query (leaving it to the PreparedStatement to guess\r
- * the corresponding SQL type)\r
- * @return a List that contains a Map per row\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
- * Issue an update via a prepared statement, binding the given arguments.\r
- *\r
- * @param sql SQL containing named parameters\r
- * @param param map of parameters to bind to the query (leaving it to the PreparedStatement to guess\r
- * the corresponding SQL type)\r
- * @return the number of rows affected\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
- * 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
- * <p>\r
- * The results will be mapped to a List (one entry for each row) of Maps (one entry for each column,\r
- * using the column name as the key).\r
- *\r
- * @param sql SQL query to execute\r
- * @param data arguments to bind to the query (leaving it to the PreparedStatement to guess the\r
- * corresponding SQL type)\r
- * @return a List that contains a Map per row\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
- * Issue a single SQL update operation (such as an insert, update or delete statement) via a\r
- * prepared statement, binding the given arguments.\r
- *\r
- * @param sql SQL containing bind parameters\r
- * @param data arguments to bind to the query (leaving it to the PreparedStatement to guess the\r
- * corresponding SQL type)\r
- * @return the number of rows affected\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
- * Issue a single SQL Insert operation for CONFIG_TRANSACTION_LOG table via a prepared statement,\r
- * binding the given arguments.\r
- *\r
- * @param transactionLog arguments to bind to the query (mapping it to the PreparedStatement to the\r
- * corresponding SQL type)\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
- * Query CONFIG_TRANSACTION_LOG table for given request_id, mapping each row to a Java object via a\r
- * TransactionLog RowMapper.\r
- *\r
- * @param requestId argument to bind to the query (leaving it to the PreparedStatement to guess the\r
- * corresponding SQL type)\r
- * @return the result List, containing mapped objects\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
- * 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
- *\r
- * @param configResource argument to bind to the query (mapping it to the PreparedStatement to the\r
- * corresponding SQL type)\r
- * @return the result List, containing mapped objects\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
- * Issue a single SQL update operation (insert or update statement) for CONFIG_RESOURCE table via a\r
- * prepared statement, binding the given arguments.\r
- *\r
- * @param configResource arguments to bind to the query (mapping it to the PreparedStatement to the\r
- * corresponding SQL type)\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
- * Query CONFIG_TRANSACTION_LOG table for given request_id, mapping each row to a Java object via a\r
- * TransactionLog RowMapper.\r
- *\r
- * @param requestId argument to bind to the query (leaving it to the PreparedStatement to guess the\r
- * corresponding SQL type)\r
- * @param messageType argument to bind to the query (leaving it to the PreparedStatement to guess\r
- * the corresponding SQL type)\r
- * @return the result List, containing mapped objects\r
- * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
- */\r
- public List<TransactionLog> getTransactionsByRequestId(String requestId, String messageType)\r
- throws SvcLogicException;\r
-\r
-}\r
+++ /dev/null
-/*\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.features.data.adaptor.service;\r
-\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.onap.ccsdk.features.data.adaptor.dao.ConfigResourceDao;\r
-import org.onap.ccsdk.features.data.adaptor.dao.NamedQueryExecutorDao;\r
-import org.onap.ccsdk.features.data.adaptor.dao.QueryExecutorDao;\r
-import org.onap.ccsdk.features.data.adaptor.dao.TransactionLogDao;\r
-import org.onap.ccsdk.features.data.adaptor.domain.ConfigResource;\r
-import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\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
- private TransactionLogDao transactionLogDao;\r
- private ConfigResourceDao configResourceDao;\r
- private QueryExecutorDao queryExecutorDao;\r
- private NamedQueryExecutorDao namedQueryExecutorDao;\r
-\r
- @SuppressWarnings("squid:S00107")\r
- public ConfigResourceServiceImpl(TransactionLogDao transactionLogDao, ConfigResourceDao configResourceDao,\r
- QueryExecutorDao queryExecutorDao, NamedQueryExecutorDao namedQueryExecutorDao) {\r
-\r
- logger.info("{} Constuctor Initated...", CLASS_NAME);\r
- this.transactionLogDao = transactionLogDao;\r
- this.configResourceDao = configResourceDao;\r
- this.queryExecutorDao = queryExecutorDao;\r
- this.namedQueryExecutorDao = namedQueryExecutorDao;\r
- }\r
-\r
- @Override\r
- public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() throws SvcLogicException {\r
- return namedQueryExecutorDao.getNamedParameterJdbcTemplate();\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
- @Override\r
- public int update(String sql, Map<String, Object> parameters) throws SvcLogicException {\r
- return namedQueryExecutorDao.update(sql, parameters);\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
- @Override\r
- public int update(String sql, Object[] data) throws SvcLogicException {\r
- return queryExecutorDao.update(sql, data);\r
- }\r
-\r
- @Override\r
- public void save(TransactionLog transactionLog) throws SvcLogicException {\r
- transactionLogDao.save(transactionLog);\r
- }\r
-\r
- @Override\r
- public List<TransactionLog> getTransactionsByRequestId(String requestId) throws SvcLogicException {\r
- return transactionLogDao.getTransactionsByRequestId(requestId);\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
- @Override\r
- public List<ConfigResource> getConfigResource(ConfigResource configResource) throws SvcLogicException {\r
- return configResourceDao.findByConfigResource(configResource);\r
- }\r
-\r
- @Override\r
- public ConfigResource saveConfigResource(ConfigResource configResource) throws SvcLogicException {\r
- return configResourceDao.save(configResource);\r
- }\r
-\r
-}\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!-- Copyright © 2017-2018 AT&T Intellectual Property. Modifications Copyright \r
- © 2018 IBM. Licensed under the Apache License, Version 2.0 (the "License"); \r
- you may not use this file except in compliance with the License. You may \r
- obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 \r
- Unless required by applicable law or agreed to in writing, software distributed \r
- under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES \r
- OR CONDITIONS OF ANY KIND, either express or implied. See the License for \r
- the specific language governing permissions and limitations under the License. -->\r
-\r
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"\r
- xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"\r
- odl:use-default-for-reference-types="true">\r
-\r
- <!-- Dependencies -->\r
-\r
- <reference id="dataSource" interface="javax.sql.DataSource" />\r
-\r
- <!-- Data SourceInitialisation -->\r
-\r
- <bean id="config.dataSource"\r
- class="org.onap.ccsdk.features.data.adaptor.db.DataSourceWrap">\r
- <argument ref="dataSource" />\r
- </bean>\r
-\r
- <bean id="jdbcTemplate"\r
- class="org.springframework.jdbc.core.JdbcTemplate">\r
- <property name="dataSource" ref="config.dataSource" />\r
- </bean>\r
-\r
- <bean id="namedParameterJdbcTemplate"\r
- class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate">\r
- <argument ref="config.dataSource" />\r
- </bean>\r
-\r
- <!-- DAO Initialisation -->\r
- <bean id="transactionLogDao"\r
- class="org.onap.ccsdk.features.data.adaptor.dao.TransactionLogDaoImpl">\r
- <argument ref="jdbcTemplate" />\r
- </bean>\r
-\r
- <bean id="configResourceDao"\r
- class="org.onap.ccsdk.features.data.adaptor.dao.ConfigResourceDaoImpl">\r
- <argument ref="jdbcTemplate" />\r
- </bean>\r
-\r
- <bean id="queryExecutorDao"\r
- class="org.onap.ccsdk.features.data.adaptor.dao.QueryExecutorDaoImpl">\r
- <argument ref="jdbcTemplate" />\r
- </bean>\r
-\r
- <bean id="namedQueryExecutorDao"\r
- class="org.onap.ccsdk.features.data.adaptor.dao.NamedQueryExecutorDaoImpl">\r
- <argument ref="namedParameterJdbcTemplate" />\r
- </bean>\r
-\r
- <!-- Expose the Common Component Bean -->\r
-\r
- <bean id="configResourceService"\r
- class="org.onap.ccsdk.features.data.adaptor.service.ConfigResourceServiceImpl">\r
- <argument ref="transactionLogDao" />\r
- <argument ref="configResourceDao" />\r
- <argument ref="queryExecutorDao" />\r
- <argument ref="namedQueryExecutorDao" />\r
- </bean>\r
-\r
- <service ref="configResourceService"\r
- interface="org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService" />\r
-\r
-</blueprint>\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!-- Copyright © 2017-2018 AT&T Intellectual Property. Modifications Copyright \r
- © 2018 IBM. Licensed under the Apache License, Version 2.0 (the "License"); \r
- you may not use this file except in compliance with the License. You may \r
- obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 \r
- Unless required by applicable law or agreed to in writing, software distributed \r
- under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES \r
- OR CONDITIONS OF ANY KIND, either express or implied. See the License for \r
- the specific language governing permissions and limitations under the License. -->\r
-\r
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"\r
- xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"\r
- odl:use-default-for-reference-types="true">\r
-\r
- <!-- Dependencies -->\r
-\r
- <reference id="dataSource" interface="javax.sql.DataSource" />\r
-\r
- <!-- Data SourceInitialisation -->\r
-\r
- <bean id="config.dataSource"\r
- class="org.onap.ccsdk.features.data.adaptor.db.DataSourceWrap">\r
- <argument ref="dataSource" />\r
- </bean>\r
-\r
- <bean id="jdbcTemplate"\r
- class="org.springframework.jdbc.core.JdbcTemplate">\r
- <property name="dataSource" ref="config.dataSource" />\r
- </bean>\r
-\r
- <bean id="namedParameterJdbcTemplate"\r
- class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate">\r
- <argument ref="config.dataSource" />\r
- </bean>\r
-\r
- <!-- DAO Initialisation -->\r
- <bean id="transactionLogDao"\r
- class="org.onap.ccsdk.features.data.adaptor.dao.TransactionLogDaoImpl">\r
- <argument ref="jdbcTemplate" />\r
- </bean>\r
-\r
- <bean id="configResourceDao"\r
- class="org.onap.ccsdk.features.data.adaptor.dao.ConfigResourceDaoImpl">\r
- <argument ref="jdbcTemplate" />\r
- </bean>\r
-\r
- <bean id="queryExecutorDao"\r
- class="org.onap.ccsdk.features.data.adaptor.dao.QueryExecutorDaoImpl">\r
- <argument ref="jdbcTemplate" />\r
- </bean>\r
-\r
- <bean id="namedQueryExecutorDao"\r
- class="org.onap.ccsdk.features.data.adaptor.dao.NamedQueryExecutorDaoImpl">\r
- <argument ref="namedParameterJdbcTemplate" />\r
- </bean>\r
-\r
- <!-- Expose the Common Component Bean -->\r
-\r
- <bean id="configResourceService"\r
- class="org.onap.ccsdk.features.data.adaptor.service.ConfigResourceServiceImpl">\r
- <argument ref="transactionLogDao" />\r
- <argument ref="configResourceDao" />\r
- <argument ref="queryExecutorDao" />\r
- <argument ref="namedQueryExecutorDao" />\r
- </bean>\r
-\r
- <service ref="configResourceService"\r
- interface="org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService" />\r
-\r
-</blueprint>\r
+++ /dev/null
--- -----------------------------------------------------\r
--- Dropping tables ( One time )\r
--- -----------------------------------------------------\r
-\r
-DROP TABLE sdnctl.CONFIG_RESOURCE_ASSIGNMENT_DATA;\r
-DROP TABLE sdnctl.CONFIG_RESOURCE;\r
-DROP TABLE sdnctl.CONFIG_RESOURCE_RELATION;\r
-DROP TABLE sdnctl.CONFIG_TRANSACTION_LOG\r
-\r
-\r
--- -----------------------------------------------------\r
--- table sdnctl.CONFIG_TRANSACTION_LOG\r
--- -----------------------------------------------------\r
-CREATE TABLE IF NOT EXISTS sdnctl.CONFIG_TRANSACTION_LOG (\r
- config_transaction_log_id VARCHAR(50) NOT NULL,\r
- request_id VARCHAR(50) NULL DEFAULT NULL,\r
- message_type VARCHAR(100) NULL DEFAULT NULL,\r
- creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\r
- message LONGTEXT NULL DEFAULT NULL,\r
- PRIMARY KEY PK_CONFIG_TRANSACTION_LOG (config_transaction_log_id)\r
- ) ENGINE=InnoDB DEFAULT CHARSET=latin1;\r
-\r
-\r
--- -----------------------------------------------------\r
--- table sdnctl.CONFIG_RESOURCE\r
--- -----------------------------------------------------\r
-CREATE TABLE IF NOT EXISTS sdnctl.CONFIG_RESOURCE (\r
- config_resource_id VARCHAR(50) NOT NULL,\r
- resource_id VARCHAR(50) NOT NULL,\r
- resource_type VARCHAR(50) NOT NULL,\r
- service_template_name VARCHAR(50) NULL DEFAULT NULL,\r
- service_template_version VARCHAR(50) NULL DEFAULT NULL,\r
- template_name VARCHAR(50) NOT NULL,\r
- recipe_name VARCHAR(50) NOT NULL,\r
- request_id VARCHAR(50) NOT NULL,\r
- resource_data LONGTEXT NULL DEFAULT NULL,\r
- mask_data LONGTEXT NULL DEFAULT NULL,\r
- created_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\r
- status VARCHAR(20) NOT NULL,\r
- updated_by VARCHAR(50) NOT NULL,\r
- PRIMARY KEY PK_CONFIG_RESOURCE (config_resource_id),\r
- INDEX IX_CONFIG_RESOURCE (created_date desc)\r
- ) ENGINE=InnoDB DEFAULT CHARSET=latin1;\r
-\r
-\r
--- -----------------------------------------------------\r
--- table sdnctl.CONFIG_RESOURCE_RELATION\r
--- -----------------------------------------------------\r
-CREATE TABLE IF NOT EXISTS sdnctl.CONFIG_RESOURCE_RELATION (\r
- config_resource_relation_id VARCHAR(50) NOT NULL,\r
- resource_id VARCHAR(50) NOT NULL,\r
- related_resource_id VARCHAR(50) NOT NULL,\r
- relation_type VARCHAR(50) NOT NULL DEFAULT 'children',\r
- created_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\r
- updated_by VARCHAR(50) NOT NULL,\r
- PRIMARY KEY PK_CONFIG_RESOURCE_RELATION (config_resource_relation_id),\r
- INDEX IX_CONFIG_RESOURCE_RELATION (created_date desc),\r
- CONSTRAINT FK_CONFIG_RESOURCE_RELATION_TO_CONFIG_RESOURCE1\r
- FOREIGN KEY (resource_id)\r
- REFERENCES sdnctl.CONFIG_RESOURCE (config_resource_id)\r
- ON DELETE NO ACTION\r
- ON UPDATE NO ACTION,\r
- CONSTRAINT FK_CONFIG_RESOURCE_RELATION_TO_CONFIG_RESOURCE2\r
- FOREIGN KEY (related_resource_id)\r
- REFERENCES sdnctl.CONFIG_RESOURCE (config_resource_id)\r
- ON DELETE NO ACTION\r
- ON UPDATE NO ACTION\r
- ) ENGINE=InnoDB DEFAULT CHARSET=latin1;\r
-\r
-\r
--- -----------------------------------------------------\r
--- table sdnctl.CONFIG_RESOURCE_ASSIGNMENT_DATA\r
--- -----------------------------------------------------\r
-CREATE TABLE IF NOT EXISTS sdnctl.CONFIG_RESOURCE_ASSIGNMENT_DATA (\r
- config_resource_assignment_data_id VARCHAR(50) NOT NULL,\r
- config_resource_id VARCHAR(50) NOT NULL,\r
- version INT(11) NOT NULL,\r
- updated_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\r
- updated_by VARCHAR(50) NOT NULL, \r
- template_key_name VARCHAR(50) NOT NULL,\r
- resource_name VARCHAR(50) NOT NULL,\r
- data_type VARCHAR(100) NOT NULL,\r
- entry_schema VARCHAR(100) NULL DEFAULT NULL,\r
- resource_value LONGTEXT NOT NULL,\r
- source VARCHAR(50) NOT NULL,\r
- status VARCHAR(50) NOT NULL,\r
- message LONGTEXT NOT NULL,\r
- PRIMARY KEY PK_CONFIG_RESOURCE (config_resource_assignment_data_id),\r
- INDEX IX_CONFIG_RESOURCE (updated_date desc),\r
- CONSTRAINT FK_CONFIG_RESOURCE_ASSIGNMENT_DATA\r
- FOREIGN KEY (config_resource_id)\r
- REFERENCES sdnctl.CONFIG_RESOURCE (config_resource_id)\r
- ON DELETE NO ACTION\r
- ON UPDATE NO ACTION\r
- ) ENGINE=InnoDB DEFAULT CHARSET=latin1;\r
-\r
+++ /dev/null
-/*\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.features.data.adaptor.dao;\r
-\r
-import java.nio.charset.Charset;\r
-import java.util.ArrayList;\r
-import java.util.Date;\r
-import java.util.List;\r
-import org.apache.commons.io.IOUtils;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.FixMethodOrder;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.junit.runners.MethodSorters;\r
-import org.onap.ccsdk.features.data.adaptor.domain.ConfigResource;\r
-import org.onap.ccsdk.features.data.adaptor.domain.ResourceAssignmentData;\r
-import org.springframework.beans.factory.annotation.Autowired;\r
-import org.springframework.test.context.ContextConfiguration;\r
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-@RunWith(SpringJUnit4ClassRunner.class)\r
-@ContextConfiguration(locations = {"classpath:test-context-h2db.xml"})\r
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)\r
-public class ConfigResourceDaoTest {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigResourceDaoTest.class);\r
-\r
- @Autowired\r
- private ConfigResourceDao configResourceDao;\r
-\r
- @Before\r
- public void initialise() {\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
- logger.trace("resourceData = " + resourceData);\r
- configResource.setResourceData(resourceData);\r
- configResource.setServiceTemplateName("sample-name");\r
- configResource.setServiceTemplateVersion("1.0.0");\r
- configResource.setResourceId("123456");\r
- configResource.setResourceType("vUSP - vDBE-IPX HUB");\r
- configResource.setRequestId("123456");\r
- configResource.setRecipeName("activate-action");\r
- configResource.setTemplateName("vrr-service-template");\r
- configResource.setMaskData(null);\r
- configResource.setStatus("success");\r
- configResource.setCreatedDate(new Date(System.currentTimeMillis()));\r
- configResource.setUpdatedBy("an188a");\r
-\r
- List<ResourceAssignmentData> resourceAssignments = new ArrayList<>();\r
- ResourceAssignmentData resourceAssignmentData = new ResourceAssignmentData();\r
- resourceAssignmentData.setDataType("string");\r
- resourceAssignmentData.setStatus("success");\r
- resourceAssignmentData.setMessage("success");\r
- resourceAssignmentData.setTemplateKeyName("sample");\r
- resourceAssignmentData.setResourceName("sample");\r
- // resourceAssignmentData.setResourceValue("sample123");\r
- resourceAssignmentData.setSource("input");\r
- resourceAssignments.add(resourceAssignmentData);\r
- configResource.setResourceAssignments(resourceAssignments);\r
-\r
- ConfigResource dbConfigResource = configResourceDao.save(configResource);\r
- logger.info("Saved sucessfully : " + dbConfigResource.toString());\r
- Assert.assertNotNull("ConfigResource is null", dbConfigResource);\r
- Assert.assertNotNull("Resource Assignment Data is null", dbConfigResource.getResourceAssignments());\r
- Assert.assertEquals("Resource Assignment Data count missmatch", true,\r
- dbConfigResource.getResourceAssignments().size() > 0);\r
- }\r
-\r
- @Test\r
- public void testConfigResourcesData() throws Exception {\r
- ConfigResource configResourceInput = new ConfigResource();\r
- configResourceInput.setResourceId("123456");\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
- for (ConfigResource configResource : dbConfigResources) {\r
- Assert.assertNotNull("ConfigResources Assignments is null", configResource.getResourceAssignments());\r
- Assert.assertTrue("ConfigResources Assignments size miss mathch ",\r
- configResource.getResourceAssignments().size() > 0);\r
- logger.trace("ResourceAssignments = " + configResource.getResourceAssignments());\r
- }\r
- }\r
-\r
- @Test\r
- public void testDeleteByConfigResource() throws Exception {\r
- ConfigResource configResourceInput = new ConfigResource();\r
- configResourceInput.setResourceId("123456");\r
-\r
- List<ConfigResource> dbConfigResources = configResourceDao.findByConfigResource(configResourceInput);\r
- Assert.assertTrue("ConfigResources is null", !dbConfigResources.isEmpty());\r
-\r
- configResourceInput.setConfigResourceId(dbConfigResources.get(0).getConfigResourceId());\r
- configResourceDao.deleteByConfigResource(configResourceInput);\r
-\r
- dbConfigResources = configResourceDao.findByConfigResource(configResourceInput);\r
- Assert.assertTrue("ConfigResources is not null", dbConfigResources.isEmpty());\r
- }\r
-}\r
+++ /dev/null
-/*\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.features.data.adaptor.dao;\r
-\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.FixMethodOrder;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.junit.runners.MethodSorters;\r
-import org.onap.ccsdk.features.data.adaptor.DataAdaptorConstants;\r
-import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog;\r
-import org.springframework.beans.factory.annotation.Autowired;\r
-import org.springframework.test.context.ContextConfiguration;\r
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-@RunWith(SpringJUnit4ClassRunner.class)\r
-@ContextConfiguration(locations = {"classpath:test-context-h2db.xml"})\r
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)\r
-public class ConfigTransactionLogDaoTest {\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigTransactionLogDaoTest.class);\r
-\r
- @Autowired\r
- private TransactionLogDao transactionLogDao;\r
-\r
- @Autowired\r
- private NamedQueryExecutorDao namedQueryExecutorDao;\r
-\r
- @Before\r
- public void initialise() {\r
-\r
- }\r
-\r
- @Test\r
- public void testQueryExecution() throws Exception {\r
- String requestId = "12345";\r
-\r
- transactionLogDao\r
- .save(new TransactionLog(requestId, DataAdaptorConstants.LOG_MESSAGE_TYPE_LOG, "Received Request"));\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
- 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
- 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
+++ /dev/null
-/*\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.features.data.adaptor.dao;\r
-\r
-import java.util.Date;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.FixMethodOrder;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.junit.runners.MethodSorters;\r
-import org.springframework.beans.factory.annotation.Autowired;\r
-import org.springframework.test.context.ContextConfiguration;\r
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-@RunWith(SpringJUnit4ClassRunner.class)\r
-@ContextConfiguration(locations = {"classpath:test-context-h2db.xml"})\r
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)\r
-public class QueryExecutorDaoTest {\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(QueryExecutorDaoTest.class);\r
-\r
- @Autowired\r
- private QueryExecutorDao queryExecutorDao;\r
-\r
- @Before\r
- public void initialise() {\r
-\r
- }\r
-\r
- @Test\r
- public void testInsertQueryExecution() throws Exception {\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
- Object[] data =\r
- new Object[] {"12345", "vUSP - vDBE-IPX HUB", "1234567", "activate-action", "vrr-service-template",\r
- "resource-data", "mask-data", null, new Date(System.currentTimeMillis()), "ab1234"};\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
- @Test\r
- public void testUpdateQueryExecution() throws Exception {\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
- @Test\r
- public void testDeleteQueryExecution() throws Exception {\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
+++ /dev/null
-/*\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.features.data.adaptor.service;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.onap.ccsdk.features.data.adaptor.DataAdaptorConstants;\r
-import org.onap.ccsdk.features.data.adaptor.dao.ConfigResourceDao;\r
-import org.onap.ccsdk.features.data.adaptor.dao.NamedQueryExecutorDao;\r
-import org.onap.ccsdk.features.data.adaptor.dao.QueryExecutorDao;\r
-import org.onap.ccsdk.features.data.adaptor.dao.TransactionLogDao;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import org.springframework.beans.factory.annotation.Autowired;\r
-import org.springframework.test.context.ContextConfiguration;\r
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;\r
-\r
-@RunWith(SpringJUnit4ClassRunner.class)\r
-@ContextConfiguration(locations = {"classpath:test-context-h2db.xml"})\r
-public class ConfigResourceNodeTest {\r
-\r
- ConfigResourceNode configResourceNode;\r
-\r
- ConfigResourceService configResourceService;\r
-\r
- @Autowired\r
- TransactionLogDao transactionLogDao;\r
-\r
- @Autowired\r
- ConfigResourceDao configResourceDao;\r
-\r
- @Autowired\r
- QueryExecutorDao queryExecutorDao;\r
-\r
- @Autowired\r
- NamedQueryExecutorDao namedQueryExecutorDao;\r
-\r
- @Before\r
- public void before() {\r
- configResourceService = new ConfigResourceServiceImpl(transactionLogDao, configResourceDao, queryExecutorDao,\r
- namedQueryExecutorDao);\r
- configResourceNode = new ConfigResourceNode(configResourceService);\r
- }\r
-\r
- @Test\r
- public void testSaveConfigTransactionLog() throws Exception {\r
- Map<String, String> inParams = new HashMap<>();\r
- inParams.put(DataAdaptorConstants.INPUT_PARAM_MESSAGE_TYPE, "messageType");\r
- inParams.put(DataAdaptorConstants.INPUT_PARAM_MESSAGE, "message");\r
- SvcLogicContext ctx = new SvcLogicContext();\r
- ctx.setAttribute("request-id", "requestId12345");\r
-\r
- configResourceNode.saveConfigTransactionLog(inParams, ctx);\r
-\r
- Assert.assertTrue(!transactionLogDao.getTransactionsByRequestId("requestId12345").isEmpty());\r
- }\r
-\r
- @Test(expected = SvcLogicException.class)\r
- public void testSaveConfigTransactionLogException() throws Exception {\r
- configResourceNode = new ConfigResourceNode(null);\r
- configResourceNode.saveConfigTransactionLog(new HashMap<>(), new SvcLogicContext());\r
- }\r
-}\r
+++ /dev/null
-/*\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.features.data.adaptor.service;\r
-\r
-import java.nio.charset.Charset;\r
-import java.util.ArrayList;\r
-import java.util.Date;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.UUID;\r
-import org.apache.commons.io.IOUtils;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.onap.ccsdk.features.data.adaptor.dao.ConfigResourceDao;\r
-import org.onap.ccsdk.features.data.adaptor.dao.ConfigResourceDaoTest;\r
-import org.onap.ccsdk.features.data.adaptor.dao.NamedQueryExecutorDao;\r
-import org.onap.ccsdk.features.data.adaptor.dao.QueryExecutorDao;\r
-import org.onap.ccsdk.features.data.adaptor.dao.TransactionLogDao;\r
-import org.onap.ccsdk.features.data.adaptor.domain.ConfigResource;\r
-import org.onap.ccsdk.features.data.adaptor.domain.ResourceAssignmentData;\r
-import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog;\r
-import org.springframework.beans.factory.annotation.Autowired;\r
-import org.springframework.test.context.ContextConfiguration;\r
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;\r
-\r
-@RunWith(SpringJUnit4ClassRunner.class)\r
-@ContextConfiguration(locations = {"classpath:test-context-h2db.xml"})\r
-public class ConfigResourceServiceTest {\r
-\r
- ConfigResourceService configResourceService;\r
-\r
- @Autowired\r
- TransactionLogDao transactionLogDao;\r
-\r
- @Autowired\r
- ConfigResourceDao configResourceDao;\r
-\r
- @Autowired\r
- QueryExecutorDao queryExecutorDao;\r
-\r
- @Autowired\r
- NamedQueryExecutorDao namedQueryExecutorDao;\r
-\r
- @Before\r
- public void before() {\r
- configResourceService = new ConfigResourceServiceImpl(transactionLogDao, configResourceDao, queryExecutorDao,\r
- namedQueryExecutorDao);\r
- }\r
-\r
- @Test\r
- public void testUpdate() throws Exception {\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
- Object[] data =\r
- new Object[] {"54321", "vUSP - vDBE-IPX HUB", "1234567", "activate-action", "vrr-service-template",\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
- 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
- @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
- configResource.setResourceData(resourceData);\r
- configResource.setServiceTemplateName("sample-name");\r
- configResource.setServiceTemplateVersion("1.0.0");\r
- configResource.setResourceId("123456");\r
- configResource.setResourceType("vUSP - vDBE-IPX HUB");\r
- configResource.setRequestId("123456");\r
- configResource.setRecipeName("activate-action");\r
- configResource.setTemplateName("vrr-service-template");\r
- configResource.setMaskData(null);\r
- configResource.setStatus("success");\r
- configResource.setCreatedDate(new Date(System.currentTimeMillis()));\r
- configResource.setUpdatedBy("an188a");\r
-\r
- List<ResourceAssignmentData> resourceAssignments = new ArrayList<>();\r
- ResourceAssignmentData resourceAssignmentData = new ResourceAssignmentData();\r
- resourceAssignmentData.setDataType("string");\r
- resourceAssignmentData.setStatus("success");\r
- resourceAssignmentData.setMessage("success");\r
- resourceAssignmentData.setTemplateKeyName("sample");\r
- resourceAssignmentData.setResourceName("sample");\r
- // resourceAssignmentData.setResourceValue("sample123");\r
- resourceAssignmentData.setSource("input");\r
- resourceAssignments.add(resourceAssignmentData);\r
- configResource.setResourceAssignments(resourceAssignments);\r
-\r
- // save\r
- ConfigResource dbConfigResource = configResourceService.saveConfigResource(configResource);\r
- Assert.assertNotNull("ConfigResource is null", dbConfigResource);\r
- Assert.assertNotNull("Resource Assignment Data is null", dbConfigResource.getResourceAssignments());\r
- Assert.assertEquals("Resource Assignment Data count missmatch", true,\r
- dbConfigResource.getResourceAssignments().size() > 0);\r
- Assert.assertEquals(configResource.getServiceTemplateVersion(), dbConfigResource.getServiceTemplateVersion());\r
-\r
- // update\r
- configResource.setServiceTemplateVersion("1.0.1");\r
- dbConfigResource = configResourceService.saveConfigResource(configResource);\r
- Assert.assertNotNull("ConfigResource is null", dbConfigResource);\r
- Assert.assertNotNull("Resource Assignment Data is null", dbConfigResource.getResourceAssignments());\r
- Assert.assertEquals("Resource Assignment Data count missmatch", true,\r
- dbConfigResource.getResourceAssignments().size() > 0);\r
- Assert.assertEquals(configResource.getServiceTemplateVersion(), dbConfigResource.getServiceTemplateVersion());\r
-\r
- // find\r
- ConfigResource configResourceInput = new ConfigResource();\r
- configResourceInput.setResourceId(configResource.getResourceId());\r
- configResourceInput.setTemplateName(configResource.getTemplateName());\r
- configResourceInput.setServiceTemplateName(configResource.getServiceTemplateName());\r
- configResourceInput.setServiceTemplateVersion(configResource.getServiceTemplateVersion());\r
- configResourceInput.setRequestId(configResource.getRequestId());\r
- configResourceInput.setRecipeName(configResource.getRecipeName());\r
- configResourceInput.setResourceType(configResource.getResourceType());\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
- 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
- @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
- configResourceService.save(transactionLog);\r
-\r
- List<TransactionLog> transactions =\r
- configResourceService.getTransactionsByRequestId(transactionLog.getRequestId());\r
- Assert.assertTrue(transactions.size() == 1);\r
- transactions = configResourceService.getTransactionsByRequestId(transactionLog.getRequestId(),\r
- transactionLog.getMessageType());\r
- Assert.assertTrue(transactions.size() == 1);\r
- }\r
-\r
- @Test\r
- public void testNamedQueryExecutorUpdateNQuery() throws Exception {\r
- Map<String, Object> parameters = new HashMap<>();\r
- parameters.put("config_transaction_log_id", UUID.randomUUID().toString());\r
- parameters.put("request_id", "requestId123");\r
- parameters.put("message_type", "messageType");\r
- parameters.put("message", "message");\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
- List<Map<String, Object>> result = configResourceService\r
- .query("SELECT * FROM CONFIG_TRANSACTION_LOG WHERE request_id = :request_id", parameters);\r
-\r
- Assert.assertTrue(!result.isEmpty());\r
- Assert.assertNotNull(configResourceService.getNamedParameterJdbcTemplate());\r
- }\r
-}\r
+++ /dev/null
-###\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
+++ /dev/null
-{\r
- "resource": {\r
- "name": "bundle-mac",\r
- "searchCriteriaDefintion": {\r
- "sourceSystemResourceResolution": {\r
- "searchCriteriaValue": "$ptnni_equip_name",\r
- "searchCriteriaType": "equipment"\r
- }\r
- }\r
- }\r
-} \r
+++ /dev/null
-{\r
- "group-name": "AG_AUTORP_NOOVERRIDE"\r
-}\r
+++ /dev/null
-\r
-CREATE TABLE IF NOT EXISTS CONFIG_RESOURCE (\r
- config_resource_id VARCHAR(50) PRIMARY KEY,\r
- resource_id VARCHAR(50) NOT NULL,\r
- resource_type VARCHAR(50) NOT NULL,\r
- service_template_name VARCHAR(50) NULL DEFAULT NULL,\r
- service_template_version VARCHAR(50) NULL DEFAULT NULL,\r
- template_name VARCHAR(50) NOT NULL,\r
- recipe_name VARCHAR(50) NOT NULL,\r
- request_id VARCHAR(50) NOT NULL,\r
- resource_data LONGTEXT NULL DEFAULT NULL,\r
- mask_data LONGTEXT NULL DEFAULT NULL,\r
- created_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\r
- status VARCHAR(20) NOT NULL,\r
- updated_by VARCHAR(50) NOT NULL\r
-);\r
-\r
-CREATE TABLE IF NOT EXISTS CONFIG_RESOURCE_ASSIGNMENT_DATA (\r
- config_resource_assignment_data_id VARCHAR(50) PRIMARY KEY,\r
- config_resource_id VARCHAR(50) NOT NULL,\r
- version INT(11) NOT NULL,\r
- updated_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\r
- updated_by VARCHAR(50) NOT NULL,\r
- template_key_name VARCHAR(50) NOT NULL,\r
- resource_name VARCHAR(50) NOT NULL,\r
- data_type VARCHAR(100) NOT NULL,\r
- entry_schema VARCHAR(100) NULL DEFAULT NULL,\r
- resource_value LONGTEXT NOT NULL,\r
- source VARCHAR(50) NOT NULL,\r
- status VARCHAR(50) NOT NULL,\r
- message LONGTEXT NOT NULL\r
-);\r
-\r
-CREATE TABLE IF NOT EXISTS CONFIG_TRANSACTION_LOG (\r
- config_transaction_log_id VARCHAR(50) PRIMARY KEY,\r
- request_id VARCHAR(50) NULL DEFAULT NULL,\r
- message_type VARCHAR(100) NULL DEFAULT NULL,\r
- creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\r
- message LONGTEXT NULL DEFAULT NULL\r
-);\r
-\r
-\r
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<!-- Copyright © 2017-2018 AT&T Intellectual Property. Modifications Copyright \r
- © 2018 IBM. Licensed under the Apache License, Version 2.0 (the "License"); \r
- you may not use this file except in compliance with the License. You may \r
- obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 \r
- Unless required by applicable law or agreed to in writing, software distributed \r
- under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES \r
- OR CONDITIONS OF ANY KIND, either express or implied. See the License for \r
- the specific language governing permissions and limitations under the License. -->\r
-\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xmlns:jdbc="http://www.springframework.org/schema/jdbc"\r
- xmlns:context="http://www.springframework.org/schema/context"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans\r
- http://www.springframework.org/schema/beans/spring-beans-3.1.xsd\r
- http://www.springframework.org/schema/jdbc\r
- http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd\r
- http://www.springframework.org/schema/context\r
- http://www.springframework.org/schema/context/spring-context-3.1.xsd">\r
-\r
- <context:annotation-config />\r
-\r
- <bean id="test.dataSource"\r
- class="org.springframework.jdbc.datasource.DriverManagerDataSource"\r
- lazy-init="false">\r
- <property name="driverClassName" value="org.h2.Driver" />\r
- <property name="url"\r
- value="jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;MODE=MySQL" />\r
- </bean>\r
-\r
- <jdbc:initialize-database\r
- data-source="test.dataSource">\r
- <jdbc:script location="sql/schema.sql" />\r
- </jdbc:initialize-database>\r
-\r
- <bean id="jdbcTemplate"\r
- class="org.springframework.jdbc.core.JdbcTemplate">\r
- <property name="dataSource" ref="test.dataSource" />\r
- </bean>\r
-\r
- <bean id="namedParameterJdbcTemplate"\r
- class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate">\r
- <constructor-arg ref="test.dataSource" />\r
- </bean>\r
-\r
- <bean id="configResourceDao"\r
- class="org.onap.ccsdk.features.data.adaptor.dao.ConfigResourceDaoImpl">\r
- <constructor-arg ref="jdbcTemplate" />\r
- </bean>\r
-\r
- <bean id="queryExecutorDao"\r
- class="org.onap.ccsdk.features.data.adaptor.dao.QueryExecutorDaoImpl">\r
- <constructor-arg ref="jdbcTemplate" />\r
- </bean>\r
-\r
- <bean id="namedQueryExecutorDao"\r
- class="org.onap.ccsdk.features.data.adaptor.dao.NamedQueryExecutorDaoImpl">\r
- <constructor-arg ref="namedParameterJdbcTemplate" />\r
- </bean>\r
-\r
- <bean id="transactionLogDao"\r
- class="org.onap.ccsdk.features.data.adaptor.dao.TransactionLogDaoImpl">\r
- <constructor-arg ref="jdbcTemplate" />\r
- </bean>\r
-\r
- <context:component-scan\r
- base-package="org.onap.ccsdk.features.data.adaptor" />\r
-\r
-</beans>\r
+++ /dev/null
-<?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
- 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
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xmlns:jdbc="http://www.springframework.org/schema/jdbc"\r
- xmlns:context="http://www.springframework.org/schema/context"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans\r
- http://www.springframework.org/schema/beans/spring-beans-3.1.xsd\r
- http://www.springframework.org/schema/jdbc\r
- http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd\r
- http://www.springframework.org/schema/context\r
- http://www.springframework.org/schema/context/spring-context-3.1.xsd\r
- ">\r
-\r
- <context:annotation-config />\r
-\r
- <bean id="test.dataSource"\r
- class="org.springframework.jdbc.datasource.DriverManagerDataSource"\r
- lazy-init="false">\r
- <property name="driverClassName"\r
- value="org.mariadb.jdbc.Driver" />\r
- <property name="url"\r
- value="jdbc:mysql://localhost:3306/sdnctl" />\r
- <property name="username" value="sdnctl" />\r
- <property name="password" value="sdnctl" />\r
- </bean>\r
-\r
-\r
- <!-- <bean id="test.dataSource" -->\r
- <!-- class="org.springframework.jdbc.datasource.DriverManagerDataSource" -->\r
- <!-- lazy-init="false"> -->\r
- <!-- <property name="driverClassName" value="org.h2.Driver" /> -->\r
- <!-- <property name="url" -->\r
- <!-- value="jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;MODE=MySQL" /> -->\r
- <!-- </bean> -->\r
- <!-- <jdbc:initialize-database data-source="test.dataSource"> -->\r
- <!-- <jdbc:script location="sql/schema.sql" /> -->\r
- <!-- </jdbc:initialize-database> -->\r
- <!-- <bean id="dataSetup" -->\r
- <!-- class="org.onap.ccsdk.features.data.adaptor.db.utils.DataSetup"> -->\r
- <!-- <property name="testDb" ref="testDb" /> -->\r
- <!-- </bean> -->\r
- <!-- <bean id="testDb" class="org.onap.ccsdk.features.data.adaptor.db.utils.TestDb"> -->\r
- <!-- <property name="jdbcTemplate" ref="jdbcTemplate" /> -->\r
- <!-- </bean> -->\r
-\r
- <bean id="jdbcTemplate"\r
- class="org.springframework.jdbc.core.JdbcTemplate">\r
- <property name="dataSource" ref="test.dataSource" />\r
- </bean>\r
-\r
- <bean id="namedParameterJdbcTemplate"\r
- class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate">\r
- <constructor-arg ref="test.dataSource" />\r
- </bean>\r
-\r
- <bean id="configResourcelDao"\r
- class="org.onap.ccsdk.features.data.adaptor.dao.ConfigResourceDaoImpl">\r
- <constructor-arg ref="jdbcTemplate" />\r
- </bean>\r
-\r
- <bean id="queryExecutorDao"\r
- class="org.onap.ccsdk.features.data.adaptor.dao.QueryExecutorDaoImpl">\r
- <constructor-arg ref="jdbcTemplate" />\r
- </bean>\r
-\r
- <bean id="namedQueryExecutorDao"\r
- class="org.onap.ccsdk.features.data.adaptor.dao.NamedQueryExecutorDaoImpl">\r
- <constructor-arg ref="namedParameterJdbcTemplate" />\r
- </bean>\r
-\r
- <context:component-scan\r
- base-package="org.onap.ccsdk.features.data.adaptor" />\r
-\r
-</beans>\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright © 2017-2018 AT&T Intellectual Property.
- Modifications Copyright © 2018 IBM.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onap.ccsdk.parent</groupId>
- <artifactId>odlparent-lite</artifactId>
- <version>1.5.2-SNAPSHOT</version>
- <relativePath/>
- </parent>
-
- <groupId>org.onap.ccsdk.features</groupId>
- <artifactId>blueprints-processor-adaptors</artifactId>
- <version>0.7.1-SNAPSHOT</version>
- <packaging>pom</packaging>
-
- <name>ccsdk-features :: ${project.artifactId}</name>
- <description>Blueprints Processor Adaptors - POM</description>
-
- <modules>
- <module>data-adaptor-provider</module>
- <module>rest-adaptor-provider</module>
- </modules>
-</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright © 2017-2018 AT&T Intellectual Property.
- Modifications Copyright © 2018 IBM.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onap.ccsdk.parent</groupId>
- <artifactId>binding-parent</artifactId>
- <version>1.5.2-SNAPSHOT</version>
- <relativePath/>
- </parent>
-
- <groupId>org.onap.ccsdk.features</groupId>
- <artifactId>blueprints-rest-adaptor-provider</artifactId>
- <version>0.7.1-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <name>ccsdk-features :: blueprints-processor-adaptor :: ${project.artifactId}</name>
- <url>http://maven.apache.org</url>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpcore</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-web</artifactId>
- </dependency>
- <dependency>
- <groupId>com.att.eelf</groupId>
- <artifactId>eelf-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito</artifactId>
- <version>1.6.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.javassist</groupId>
- <artifactId>javassist</artifactId>
- <version>3.21.0-GA</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <version>1.10.19</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-junit4</artifactId>
- <version>1.6.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-support</artifactId>
- <version>1.6.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-reflect</artifactId>
- <version>1.6.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-core</artifactId>
- <version>1.6.4</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <configuration>
- <additionalparam>-Xdoclint:none</additionalparam>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Name>${project.artifactId}</Bundle-Name>
- <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>org.onap.ccsdk.features.rest.adaptor,
- org.onap.ccsdk.features.rest.adaptor.data,
- org.onap.ccsdk.features.rest.adaptor.service,
- org.onap.ccsdk.features.rest.adaptor.utils
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-/*\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\rpackage org.onap.ccsdk.features.rest.adaptor;\r\rpublic class ConfigRestAdaptorConstants {\r private ConfigRestAdaptorConstants() {\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 = "blueprints-processor-adaptor.properties";\r public static final String PROXY_URL_KEY = "proxyUrl";\r public static final String PROXY_URLS_VALUE_SEPARATOR = ",";\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 public static final String PROPERTY_ENV_PROD = "field";\r public static final String PROPERTY_ENV_SOLO = "solo";\r\r public static final String REST_ADAPTOR_BASE_PROPERTY = "org.onap.ccsdk.features.blueprints.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 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 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_BASEURL_PROPERTY = ".url";\r public static final String SERVICE_PROPERTYFILE = ".propertyfile";\r public static final String SERVICE_USER_PROPERTY = ".user";\r public static final String SERVICE_APPID_PROPERTY = ".appId";\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 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_COSMS = "cosms";\r public static final String SELECTOR_RESTCONF = "restconf";\r public static final String SELECTOR_MODEL_SERVICE = "modelservice";\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
\ No newline at end of file
+++ /dev/null
-/*\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.features.rest.adaptor;\r
-\r
-/**\r
- * ConfigRestAdaptorException.java Purpose: Provide Configuration Rest Adaptor Exception\r
- *\r
- * @version 1.0\r
- */\r
-public class ConfigRestAdaptorException extends Exception {\r
-\r
- /**\r
- *\r
- */\r
- private static final long serialVersionUID = 1L;\r
-\r
- /**\r
- * This is a ConfigRestAdaptorException constructor\r
- *\r
- * @param message\r
- */\r
- public ConfigRestAdaptorException(String message) {\r
- super(message);\r
- }\r
-\r
- /**\r
- * This is a ConfigRestAdaptorException constructor\r
- *\r
- * @param message\r
- */\r
- public ConfigRestAdaptorException(String message, Throwable cause) {\r
- super(message, cause);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.rest.adaptor.data;\r
-\r
-import java.util.Map;\r
-\r
-public class RestResponse {\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
- public String getStatusCode() {\r
- return statusCode;\r
- }\r
-\r
- public void setStatusCode(String statusCode) {\r
- this.statusCode = statusCode;\r
- }\r
-\r
- public String getBody() {\r
- return body;\r
- }\r
-\r
- public void setBody(String body) {\r
- this.body = body;\r
- }\r
-\r
- public Map<String, String> getParameters() {\r
- return parameters;\r
- }\r
-\r
- public void setParameters(Map<String, String> parameters) {\r
- this.parameters = parameters;\r
- }\r
-\r
- public Map<String, String> getResponseHeaders() {\r
- return responseHeaders;\r
- }\r
-\r
- public void setResponseHeaders(Map<String, String> responseHeaders) {\r
- this.responseHeaders = responseHeaders;\r
- }\r
-\r
- public Map<String, String> getRequestHeaders() {\r
- return requestHeaders;\r
- }\r
-\r
- public void setRequestHeaders(Map<String, String> requestHeaders) {\r
- this.requestHeaders = requestHeaders;\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
+++ /dev/null
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\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
- * \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
- */\r
-\r
-package org.onap.ccsdk.features.rest.adaptor.service;\r
-\r
-import java.io.FileInputStream;\r
-import java.io.InputStream;\r
-import java.security.KeyStore;\r
-import java.security.cert.X509Certificate;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.concurrent.ConcurrentHashMap;\r
-import javax.net.ssl.SSLContext;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.apache.http.conn.ssl.NoopHostnameVerifier;\r
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;\r
-import org.apache.http.impl.client.CloseableHttpClient;\r
-import org.apache.http.impl.client.HttpClients;\r
-import org.apache.http.ssl.SSLContextBuilder;\r
-import org.apache.http.ssl.TrustStrategy;\r
-import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorConstants;\r
-import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorException;\r
-import org.onap.ccsdk.features.rest.adaptor.data.RestResponse;\r
-import org.onap.ccsdk.features.rest.adaptor.utils.BasicAuthorizationInterceptor;\r
-import org.springframework.http.HttpEntity;\r
-import org.springframework.http.HttpHeaders;\r
-import org.springframework.http.HttpMethod;\r
-import org.springframework.http.HttpStatus;\r
-import org.springframework.http.ResponseEntity;\r
-import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;\r
-import org.springframework.http.converter.ByteArrayHttpMessageConverter;\r
-import org.springframework.http.converter.HttpMessageConverter;\r
-import org.springframework.http.converter.ResourceHttpMessageConverter;\r
-import org.springframework.http.converter.StringHttpMessageConverter;\r
-import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;\r
-import org.springframework.http.converter.xml.SourceHttpMessageConverter;\r
-import org.springframework.util.ResourceUtils;\r
-import org.springframework.web.client.HttpClientErrorException;\r
-import org.springframework.web.client.RestTemplate;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-abstract class AbstractConfigRestClientAdapter implements ConfigRestClientServiceAdapter {\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
- protected boolean isRestClientServiceAdapaterEnabled = false;\r
- protected boolean isSSLServiceAdapaterEnabled = true;\r
-\r
- protected Map<String, String> properties = new ConcurrentHashMap<>();\r
- protected String serviceSelector;\r
-\r
- protected RestTemplate restTemplate;\r
-\r
- protected AbstractConfigRestClientAdapter(Map<String, String> properties, String serviceSelector) {\r
- this.properties = properties;\r
- this.serviceSelector = serviceSelector;\r
- setRestClientServiceAdapaterEnabled();\r
- }\r
-\r
- private void setRestClientServiceAdapaterEnabled() {\r
- String isEnabledProperty = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector\r
- + ConfigRestAdaptorConstants.SERVICE_EANABLED_PROPERTY;\r
- String isRestClientServiceAdapaterEnabledStr = properties.get(isEnabledProperty);\r
- logger.info("Service selector ({}) enable status ({}) ", serviceSelector,\r
- isRestClientServiceAdapaterEnabledStr);\r
- if (StringUtils.isNotBlank(isRestClientServiceAdapaterEnabledStr)\r
- && Boolean.parseBoolean(isRestClientServiceAdapaterEnabledStr)) {\r
- isRestClientServiceAdapaterEnabled = true;\r
- }\r
- }\r
-\r
- private List<HttpMessageConverter<?>> getMessageConverters() {\r
- List<HttpMessageConverter<?>> converters = new ArrayList<>();\r
- converters.add(new ByteArrayHttpMessageConverter());\r
- converters.add(new StringHttpMessageConverter());\r
- converters.add(new ResourceHttpMessageConverter());\r
- converters.add(new SourceHttpMessageConverter());\r
- converters.add(new MappingJackson2HttpMessageConverter());\r
- return converters;\r
- }\r
-\r
- public void initialise(String user, String pass) {\r
- logger.trace("Config rest template factory user ({}) ", user);\r
-\r
- CloseableHttpClient httpClient =\r
- HttpClients.custom().setSSLHostnameVerifier(new NoopHostnameVerifier()).build();\r
- HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();\r
- requestFactory.setHttpClient(httpClient);\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
- public void initialiseSSL(String keyStorePath, String trustStorePath, String keyPass, String trustPass)\r
- throws ConfigRestAdaptorException {\r
- logger.trace("SSL rest template factory");\r
-\r
- TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true;\r
- SSLContext sslContext = null;\r
-\r
- try (InputStream keyInput = new FileInputStream(keyStorePath)) {\r
- KeyStore keyStore = KeyStore.getInstance("PKCS12");\r
- keyStore.load(keyInput, keyPass.toCharArray());\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
- SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext);\r
- CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(csf).build();\r
- HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);\r
-\r
- restTemplate = new RestTemplate(getMessageConverters());\r
- restTemplate.setRequestFactory(requestFactory);\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
- 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
- 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.valueOf(method), request, responseType);\r
- return processResponse(response, url, HttpMethod.valueOf(method));\r
- }\r
-\r
- public RestResponse getResource(HttpHeaders headers, String url) throws ConfigRestAdaptorException {\r
- return exchangeForEntity(headers, url, HttpMethod.GET, null);\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
- public RestResponse exchangeResource(HttpHeaders headers, String url, Object request, String method)\r
- throws ConfigRestAdaptorException {\r
- return exchangeForEntity(headers, url, HttpMethod.valueOf(method), request);\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
- try {\r
- if (restTemplate == null) {\r
- logger.error(MS_INIT_FAIL);\r
- } else {\r
- logger.debug("Rest Operation: {}", httpMethod);\r
- logger.debug("url : ({})", url);\r
- logger.debug("headers: ({})", headers);\r
- logger.debug("request: ({})", request);\r
-\r
- if (HttpMethod.GET == httpMethod) {\r
- HttpEntity<String> entity = new HttpEntity<>("parameters", headers);\r
- response = restTemplate.exchange(url, httpMethod, entity, String.class);\r
- } else {\r
- HttpEntity<?> entity = new HttpEntity<>(request, headers);\r
- response = restTemplate.exchange(url, httpMethod, entity, String.class);\r
- }\r
- logger.debug("response: ({})", response);\r
-\r
- if (response != null) {\r
- logger.debug("response status code: ({})", response.getStatusCode());\r
- restResponse.setBody(response.getBody());\r
- restResponse.setStatusCode(response.getStatusCode().toString());\r
- restResponse.setResponseHeaders(\r
- response.getHeaders() != null ? response.getHeaders().toSingleValueMap() : null);\r
- return restResponse;\r
- }\r
- throw new ConfigRestAdaptorException("Rest exchangeForEntity failed to perform ");\r
- }\r
- } catch (HttpClientErrorException clientError) {\r
- logger.debug("clientError: ({})", clientError);\r
- restResponse.setBody(StringUtils.isBlank(clientError.getResponseBodyAsString()) ? clientError.getMessage()\r
- : clientError.getResponseBodyAsString());\r
- restResponse.setStatusCode(clientError.getStatusCode().toString());\r
- } catch (Exception e) {\r
- throw new ConfigRestAdaptorException(\r
- String.format("httpMethod (%s) for url (%s) resulted in Exception (%s)", httpMethod, url, e));\r
- }\r
- return restResponse;\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
- try {\r
- if (restTemplate == null) {\r
- logger.error(MS_INIT_FAIL);\r
- } else {\r
- logger.debug("Rest Operation: {}", httpMethod);\r
- logger.debug("url : ({})", url);\r
- logger.debug("headers: ({})", headers);\r
- logger.debug("request: ({})", request);\r
-\r
- if (HttpMethod.GET == httpMethod) {\r
- HttpEntity<String> entity = new HttpEntity<>("parameters", headers);\r
- response = restTemplate.exchange(url, httpMethod, entity, responseType);\r
- } else {\r
- HttpEntity<?> entity = new HttpEntity<>(request, headers);\r
- response = restTemplate.exchange(url, httpMethod, entity, responseType);\r
- }\r
- logger.debug("response: ({})", response);\r
-\r
- if (response != null) {\r
- logger.debug("response status code: ({})", response.getStatusCode());\r
- } else {\r
- throw new ConfigRestAdaptorException("exchangeForEntity failed to perform ");\r
- }\r
- }\r
- } catch (Exception e) {\r
- throw new ConfigRestAdaptorException(\r
- String.format("httpMethod (%s) for url (%s) resulted in Exception (%s)", httpMethod, url, e));\r
- }\r
- return response;\r
- }\r
-\r
- protected synchronized <T> T processResponse(ResponseEntity<T> response, String url, HttpMethod httpMethod)\r
- throws ConfigRestAdaptorException {\r
- if (response != null) {\r
- if ((HttpMethod.DELETE == httpMethod && (response.getStatusCode() == HttpStatus.NO_CONTENT\r
- || response.getStatusCode() == HttpStatus.NOT_FOUND))\r
- || ((HttpMethod.GET == httpMethod || HttpMethod.PUT == httpMethod || HttpMethod.POST == httpMethod)\r
- && (response.getStatusCode() == HttpStatus.OK\r
- || response.getStatusCode() == HttpStatus.CREATED))) {\r
- return response.getBody();\r
- }\r
- throw new ConfigRestAdaptorException(\r
- String.format("Rest Operation is failed with response-code (%s) for the URL (%s)",\r
- response.getStatusCode(), url));\r
- }\r
- throw new ConfigRestAdaptorException(String.format("Rest Operation is failed for the URL (%s)", url));\r
- }\r
-\r
- protected synchronized String constructUrl(String baseUrl, String path) {\r
- if (StringUtils.isNotBlank(path)) {\r
- return baseUrl + path;\r
- } else {\r
- return baseUrl;\r
- }\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.rest.adaptor.service;\r
-\r
-import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorException;\r
-import org.onap.ccsdk.features.rest.adaptor.data.RestResponse;\r
-\r
-public interface ConfigRestAdaptorService {\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
- * \r
- * @param selectorName the property selector\r
- * @param path the URI path which will append in baseURL mentioned in selector property\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
- * Create a new resource by POSTing the given object to the URI template, and returns the response\r
- * as defined responseType\r
- * \r
- * @param selectorName the property selector\r
- * @param path the URI path which will append in baseURL mentioned in selector property\r
- * @param request the Object to be POSTed, may be {@code null}\r
- * @param responseType the type of the return value\r
- */\r
- public <T> T postResource(String selectorName, String path, Object request, Class<T> responseType)\r
- throws ConfigRestAdaptorException;\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
- * @param selectorName the property selector\r
- * @param path the URI path which will append in baseURL mentioned in selector property\r
- * @param request the Object to be POSTed, may be {@code null}\r
- * @param responseType the type of the return value\r
- * @param method the HTTP method (GET, POST, etc)\r
- */\r
- public <T> T exchangeResource(String selectorName, String path, Object request, Class<T> responseType,\r
- String method) throws ConfigRestAdaptorException;\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
- * \r
- * @param selectorName the property selector\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
- * Create a new resource by POSTing the given object to the URI template, and returns the response\r
- * as defined responseType\r
- * \r
- * @param selectorName the property selector\r
- * @param path the URI path which will append in baseURL mentioned in selector property\r
- * @param request the Object to be POSTed, may be {@code null}\r
- */\r
- public RestResponse postResource(String selectorName, String path, Object request)\r
- throws ConfigRestAdaptorException;\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
- * @param selectorName the property selector\r
- * @param path the URI path which will append in baseURL mentioned in selector property\r
- * @param request the Object to be POSTed, may be {@code null}\r
- * @param method the HTTP method (GET, POST, etc)\r
- */\r
- public RestResponse exchangeResource(String selectorName, String path, Object request, String method)\r
- throws ConfigRestAdaptorException;\r
-\r
-}\r
+++ /dev/null
-/*\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.features.rest.adaptor.service;\r
-\r
-import java.io.File;\r
-import java.io.FileInputStream;\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.net.URL;\r
-import java.util.Map;\r
-import java.util.Properties;\r
-import java.util.concurrent.ConcurrentHashMap;\r
-import java.util.concurrent.Executors;\r
-import java.util.concurrent.ScheduledExecutorService;\r
-import java.util.concurrent.TimeUnit;\r
-import java.util.stream.Collectors;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorConstants;\r
-import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorException;\r
-import org.onap.ccsdk.features.rest.adaptor.data.RestResponse;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-import org.osgi.framework.Bundle;\r
-import org.osgi.framework.BundleContext;\r
-import org.osgi.framework.FrameworkUtil;\r
-\r
-public class ConfigRestAdaptorServiceImpl implements ConfigRestAdaptorService {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigRestAdaptorServiceImpl.class);\r
- private Map<String, String> restProperties = new ConcurrentHashMap<>();\r
-\r
- public ConfigRestAdaptorServiceImpl() {\r
- this(null);\r
- }\r
-\r
- public ConfigRestAdaptorServiceImpl(final String propertyFilePath) {\r
- loadProps(propertyFilePath);\r
- try {\r
- String envType = restProperties.get(ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY\r
- + ConfigRestAdaptorConstants.REST_ADAPTOR_ENV_TYPE);\r
-\r
- if (!(ConfigRestAdaptorConstants.PROPERTY_ENV_PROD.equalsIgnoreCase(envType)\r
- || ConfigRestAdaptorConstants.PROPERTY_ENV_SOLO.equalsIgnoreCase(envType))) {\r
- ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);\r
- Runnable task = () -> loadProps(propertyFilePath);\r
- executor.scheduleWithFixedDelay(task, 60, 15, TimeUnit.MINUTES);\r
- }\r
- } catch (Exception e) {\r
- logger.error(e.getMessage(), e);\r
- }\r
- }\r
-\r
-\r
- // propertyFilePath is only specified in test case.\r
- private void loadProps(final String propertyFilePath) {\r
- Properties properties = new Properties();\r
- if (propertyFilePath != null) {\r
- // Loading Default properties\r
- String propertyFile =\r
- propertyFilePath + File.separator + ConfigRestAdaptorConstants.REST_ADAPTOR_PROPERTIES_FILE_NAME;\r
- doLoadFromPath(propertyFile, properties);\r
- } else {\r
- // Try to load config from dir\r
- final String ccsdkConfigDir =\r
- System.getProperty(ConfigRestAdaptorConstants.SDNC_ROOT_DIR_ENV_VAR_KEY) + File.separator\r
- + ConfigRestAdaptorConstants.REST_ADAPTOR_PROPERTIES_FILE_NAME;\r
- try (FileInputStream in = new FileInputStream(ccsdkConfigDir)) {\r
- properties.load(in);\r
- logger.info("Loaded {} properties from file {}", properties.size(), ccsdkConfigDir);\r
- } catch (Exception e) {\r
- // Try to load config from jar\r
- final Bundle bundle = FrameworkUtil.getBundle(ConfigRestAdaptorServiceImpl.class);\r
- final BundleContext ctx = bundle.getBundleContext();\r
- final URL url = ctx.getBundle()\r
- .getResource(ConfigRestAdaptorConstants.REST_ADAPTOR_PROPERTIES_FILE_NAME);\r
- doLoadFromPath(url.getPath(), properties);\r
- }\r
- }\r
- restProperties.putAll(properties.entrySet().stream()\r
- .collect(Collectors.toMap(e -> e.getKey().toString(), e -> e.getValue().toString())));\r
- }\r
-\r
- private void doLoadFromPath(final String propertyFile, final Properties properties) {\r
- try (FileInputStream in = new FileInputStream(propertyFile)) {\r
- properties.load(in);\r
- logger.info("Loaded {} properties from file {}", properties.size(), propertyFile);\r
- } catch (Exception e) {\r
- logger.error("Failed to load properties for file: {} "\r
- + ConfigRestAdaptorConstants.REST_ADAPTOR_PROPERTIES_FILE_NAME, e);\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
- @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
- @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
- @Override\r
- public RestResponse getResource(String serviceSelector, String path) throws ConfigRestAdaptorException {\r
- return getRestClientAdapterBySelectorName(serviceSelector).getResource(path);\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
- @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
- private ConfigRestClientServiceAdapter getRestClientAdapterBySelectorName(String serviceSelector)\r
- throws ConfigRestAdaptorException {\r
- String adoptorType = restProperties.get(ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector\r
- + ConfigRestAdaptorConstants.SERVICE_TYPE_PROPERTY);\r
- if (StringUtils.isNotBlank(adoptorType)) {\r
- if (ConfigRestAdaptorConstants.REST_ADAPTOR_TYPE_GENERIC.equalsIgnoreCase(adoptorType)) {\r
- return new GenericRestClientAdapterImpl(restProperties, serviceSelector);\r
- } else if (ConfigRestAdaptorConstants.REST_ADAPTOR_TYPE_SSL.equalsIgnoreCase(adoptorType)) {\r
- return new SSLRestClientAdapterImpl(restProperties, serviceSelector);\r
- } else {\r
- throw new ConfigRestAdaptorException(\r
- String.format("no implementation for rest adoptor type (%s) for the selector (%s).",\r
- adoptorType, serviceSelector));\r
- }\r
- } else {\r
- throw new ConfigRestAdaptorException(\r
- String.format("couldn't get rest adoptor type for the selector (%s)", serviceSelector));\r
- }\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.rest.adaptor.service;\r
-\r
-import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorException;\r
-import org.onap.ccsdk.features.rest.adaptor.data.RestResponse;\r
-\r
-interface ConfigRestClientServiceAdapter {\r
-\r
- public <T> T getResource(String path, Class<T> responseType) throws ConfigRestAdaptorException;\r
-\r
- public <T> T postResource(String path, Object request, Class<T> responseType) throws ConfigRestAdaptorException;\r
-\r
- public <T> T exchangeResource(String path, Object request, Class<T> responseType, String method)\r
- throws ConfigRestAdaptorException;\r
-\r
- public RestResponse getResource(String path) throws ConfigRestAdaptorException;\r
-\r
- public RestResponse postResource(String path, Object request) throws ConfigRestAdaptorException;\r
-\r
- public RestResponse exchangeResource(String path, Object request, String method) throws ConfigRestAdaptorException;\r
-\r
-}\r
+++ /dev/null
-/*\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.features.rest.adaptor.service;\r
-\r
-import java.util.Map;\r
-import java.util.UUID;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorConstants;\r
-import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorException;\r
-import org.onap.ccsdk.features.rest.adaptor.data.RestResponse;\r
-import org.springframework.http.HttpHeaders;\r
-import org.springframework.http.MediaType;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class GenericRestClientAdapterImpl extends AbstractConfigRestClientAdapter {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(GenericRestClientAdapterImpl.class);\r
- private String baseUrl = "";\r
-\r
- public GenericRestClientAdapterImpl(Map<String, String> properties, String serviceSelector)\r
- throws ConfigRestAdaptorException {\r
- super(properties, serviceSelector);\r
- init(serviceSelector);\r
- }\r
-\r
- private void init(String serviceSelector) throws ConfigRestAdaptorException {\r
- try {\r
- if (isRestClientServiceAdapaterEnabled) {\r
- String baseUrlProperty = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector\r
- + ConfigRestAdaptorConstants.SERVICE_BASEURL_PROPERTY;\r
- String userProperty = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector\r
- + ConfigRestAdaptorConstants.SERVICE_USER_PROPERTY;\r
- String passProperty = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector\r
- + ConfigRestAdaptorConstants.SERVICE_PSSWD_PROPERTY;\r
-\r
- baseUrl = properties.get(baseUrlProperty);\r
- String userId = properties.get(userProperty);\r
- String pass = properties.get(passProperty);\r
-\r
- initialise(userId, pass);\r
- logger.info("Initialised restconf adaptor service for selector ({})", serviceSelector);\r
- if (restTemplate == null) {\r
- throw new ConfigRestAdaptorException("couldn't initialise rest selector (" + serviceSelector + ")");\r
- }\r
- } else {\r
- throw new ConfigRestAdaptorException("rest selector (" + serviceSelector + ") is not enabled");\r
- }\r
-\r
- } catch (Exception e) {\r
- throw new ConfigRestAdaptorException("GenericRestClientServiceAdapter : " + e.getMessage(), e);\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
- @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
- @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
- @Override\r
- public RestResponse getResource(String path) throws ConfigRestAdaptorException {\r
- return super.getResource(formHttpHeaders(), constructUrl(baseUrl, path));\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
- @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
- private HttpHeaders formHttpHeaders() {\r
-\r
- HttpHeaders headers = new HttpHeaders();\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
- 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_ENV_PROPERTY;\r
- String clientAuthPath = 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
- if (StringUtils.isNotBlank(properties.get(appIDPath))) {\r
- headers.add("X-FromAppId", properties.get(appIDPath));\r
- }\r
- if (StringUtils.isNotBlank(properties.get(clientAuthPath))) {\r
- headers.add("ClientAuth", properties.get(clientAuthPath));\r
- }\r
- if (StringUtils.isNotBlank(properties.get(authorizationPath))) {\r
- headers.add("Authorization", properties.get(authorizationPath));\r
- }\r
- if (StringUtils.isNotBlank(properties.get(environmentPath))) {\r
- headers.add("Environment", properties.get(environmentPath));\r
- }\r
-\r
- return headers;\r
- }\r
-\r
- private synchronized String generateUUID() {\r
- return UUID.randomUUID().toString();\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.rest.adaptor.service;\r
-\r
-import java.util.Map;\r
-import java.util.UUID;\r
-import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorConstants;\r
-import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorException;\r
-import org.onap.ccsdk.features.rest.adaptor.data.RestResponse;\r
-import org.springframework.http.HttpHeaders;\r
-import org.springframework.http.MediaType;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class SSLRestClientAdapterImpl extends AbstractConfigRestClientAdapter {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(SSLRestClientAdapterImpl.class);\r
- private String baseUrl = "";\r
- private String application = "";\r
-\r
- public SSLRestClientAdapterImpl(Map<String, String> properties, String serviceSelector)\r
- throws ConfigRestAdaptorException {\r
- super(properties, serviceSelector);\r
- init(serviceSelector);\r
- }\r
-\r
- private void init(String serviceSelector) throws ConfigRestAdaptorException {\r
- try {\r
- if (isSSLServiceAdapaterEnabled) {\r
-\r
- logger.info("Initializing SSL client for selector ({}), properties ({})", serviceSelector, properties);\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_APP;\r
- String keyStorePathProp = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector\r
- + ConfigRestAdaptorConstants.SSL_SERVICE_KEY;\r
- String keyStorePassProp = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector\r
- + ConfigRestAdaptorConstants.SSL_SERVICE_KEY_PSSWD;\r
- String trustStorePathProp = 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
- baseUrl = properties.get(baseUrlProp);\r
- application = properties.get(applicationProp);\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
- initialiseSSL(keyStorePath, trustStorePath, keyStorePass, trustStorePass);\r
- logger.info("Initialised SSL Client Service adaptor service for selector ({})", serviceSelector);\r
- if (restTemplate == null) {\r
- throw new ConfigRestAdaptorException(\r
- "couldn't initialise SSL Client selector (" + serviceSelector + ")");\r
- }\r
- } else {\r
- throw new ConfigRestAdaptorException("SSL Client selector (" + serviceSelector + ") is not enabled");\r
- }\r
-\r
- } catch (Exception e) {\r
- throw new ConfigRestAdaptorException("SSLRestClientAdapterImpl : " + e.getMessage(), e);\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
- @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
- @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
- @Override\r
- public RestResponse getResource(String path) throws ConfigRestAdaptorException {\r
- return super.getResource(formHttpHeaders(), constructUrl(baseUrl, path));\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
- @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
- private HttpHeaders formHttpHeaders() {\r
-\r
- HttpHeaders headers = new HttpHeaders();\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
- return headers;\r
- }\r
-\r
- private synchronized String generateUUID() {\r
- return UUID.randomUUID().toString();\r
- }\r
-}\r
+++ /dev/null
-/*\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.features.rest.adaptor.utils;\r
-\r
-import java.io.IOException;\r
-import java.nio.charset.Charset;\r
-import java.util.Base64;\r
-import org.springframework.http.HttpRequest;\r
-import org.springframework.http.client.ClientHttpRequestExecution;\r
-import org.springframework.http.client.ClientHttpRequestInterceptor;\r
-import org.springframework.http.client.ClientHttpResponse;\r
-import org.springframework.util.Assert;\r
-\r
-public class BasicAuthorizationInterceptor implements ClientHttpRequestInterceptor {\r
- private static final Charset UTF_8 = Charset.forName("UTF-8");\r
-\r
- private final String username;\r
-\r
- private final String pass;\r
-\r
- /**\r
- * Create a new interceptor which adds a BASIC authorization header for the given username and pass.\r
- *\r
- * @param username the username to use\r
- * @param pass the password to use\r
- */\r
- public BasicAuthorizationInterceptor(String username, String pass) {\r
- Assert.hasLength(username, "Username must not be empty");\r
- this.username = username;\r
- this.pass = (pass != null ? pass : "");\r
- }\r
-\r
- @Override\r
- public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)\r
- throws IOException {\r
-\r
- String token = Base64.getEncoder().encodeToString((this.username + ":" + this.pass).getBytes(UTF_8));\r
- request.getHeaders().add("Authorization", "Basic " + token);\r
- return execution.execute(request, body);\r
- }\r
-}\r
+++ /dev/null
-/*\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.features.rest.adaptor.utils;\r
-\r
-import java.io.BufferedReader;\r
-import java.io.IOException;\r
-import java.io.InputStreamReader;\r
-import org.springframework.http.HttpRequest;\r
-import org.springframework.http.client.ClientHttpRequestExecution;\r
-import org.springframework.http.client.ClientHttpRequestInterceptor;\r
-import org.springframework.http.client.ClientHttpResponse;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class LoggingRequestInterceptor implements ClientHttpRequestInterceptor {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(LoggingRequestInterceptor.class);\r
-\r
- @Override\r
- public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)\r
- throws IOException {\r
- traceRequest(request, body);\r
- ClientHttpResponse response = execution.execute(request, body);\r
- traceResponse(response);\r
- return response;\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("URI : {}", request.getURI());\r
- logger.info("Method : {}", request.getMethod());\r
- logger.info("Headers : {}", request.getHeaders());\r
- logger.info("Request body: {}", new String(body, "UTF-8"));\r
- logger.debug("==========================request end================================================");\r
- }\r
-\r
- @SuppressWarnings({"squid:S2629", "squid:S3457"})\r
- private void traceResponse(ClientHttpResponse response) throws IOException {\r
- StringBuilder inputStringBuilder = new StringBuilder();\r
- BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(response.getBody(), "UTF-8"));\r
- String line = bufferedReader.readLine();\r
- while (line != null) {\r
- inputStringBuilder.append(line);\r
- inputStringBuilder.append('\n');\r
- line = bufferedReader.readLine();\r
- }\r
- logger.info("============================response begin==========================================");\r
- logger.info("Status code : {}", response.getStatusCode());\r
- logger.info("Status text : {}", response.getStatusText());\r
- logger.info("Headers : {}", response.getHeaders());\r
- logger.debug("Response body: {}", inputStringBuilder.toString());\r
- logger.debug("=======================response end=================================================");\r
- }\r
-\r
-}\r
+++ /dev/null
-<?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
- 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
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"\r
- xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"\r
- odl:use-default-for-reference-types="true">\r
-\r
- <!-- Expose the Common Component Bean -->\r
-\r
- <bean id="configRestAdaptorService"\r
- class="org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorServiceImpl">\r
- </bean>\r
-\r
- <service ref="configRestAdaptorService"\r
- interface="org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService" />\r
-\r
-</blueprint>\r
+++ /dev/null
-###
-# Copyright � 2017-2018 AT&T Intellectual Property.
-# Modifications Copyright � 2018 IBM.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-###
-#
-# Configuration file for SDNC Controller Module
-#
-
-org.onap.ccsdk.features.blueprints.adaptors.envtype=solo
-
-# Config Generator Microservices
-org.onap.ccsdk.features.blueprints.adaptors.modelservice.type=generic
-org.onap.ccsdk.features.blueprints.adaptors.modelservice.enable=true
-org.onap.ccsdk.features.blueprints.adaptors.modelservice.url=http://controller-blueprints:8080/api/v1/
-org.onap.ccsdk.features.blueprints.adaptors.modelservice.user=ccsdkapps
-org.onap.ccsdk.features.blueprints.adaptors.modelservice.passwd=ccsdkapps
-
-# Generic RESTCONF Adaptor
-org.onap.ccsdk.features.blueprints.adaptors.restconf.type=generic
-org.onap.ccsdk.features.blueprints.adaptors.restconf.enable=true
-org.onap.ccsdk.features.blueprints.adaptors.restconf.user=admin
-org.onap.ccsdk.features.blueprints.adaptors.restconf.passwd=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U
-org.onap.ccsdk.features.blueprints.adaptors.restconf.url=http://sdnc:8282/restconf/
+++ /dev/null
-<?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
- 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
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"\r
- xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"\r
- odl:use-default-for-reference-types="true">\r
-\r
- <!-- Expose the Common Component Bean -->\r
-\r
- <bean id="configRestAdaptorService"\r
- class="org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorServiceImpl">\r
- </bean>\r
-\r
- <service ref="configRestAdaptorService"\r
- interface="org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService" />\r
-\r
-</blueprint>\r
+++ /dev/null
-/*\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.features.rest.adaptor.service;\r
-\r
-import java.io.FileInputStream;\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-import java.util.Properties;\r
-import java.util.stream.Collectors;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-\r
-public class AbstractConfigRestClientAdapterTest {\r
-\r
- Map<String, String> properties = new HashMap<>();\r
-\r
- @Before\r
- public void setup() throws Exception {\r
- String propertyfile = "src/test/resources/blueprints-processor-adaptor.properties";\r
-\r
- Properties restProperties = new Properties();\r
- restProperties.load(new FileInputStream(propertyfile));\r
-\r
- properties.putAll(restProperties.entrySet().stream()\r
- .collect(Collectors.toMap(e -> e.getKey().toString(), e -> e.getValue().toString())));\r
- }\r
-\r
- @Test\r
- public void testInitGenericRestClient() throws Exception {\r
- ConfigRestClientServiceAdapter genericRestClient = new GenericRestClientAdapterImpl(properties, "modelservice");\r
- Assert.assertNotNull(genericRestClient);\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
+++ /dev/null
-/*\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.features.rest.adaptor.service;\r
-\r
-import static org.powermock.api.mockito.PowerMockito.mock;\r
-import static org.powermock.api.mockito.PowerMockito.when;\r
-import static org.powermock.api.mockito.PowerMockito.whenNew;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Matchers;\r
-import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorException;\r
-import org.powermock.core.classloader.annotations.PowerMockIgnore;\r
-import org.powermock.core.classloader.annotations.PrepareForTest;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-import org.springframework.http.HttpMethod;\r
-import org.springframework.http.HttpStatus;\r
-import org.springframework.http.ResponseEntity;\r
-import org.springframework.web.client.RestTemplate;\r
-\r
-@SuppressWarnings("unchecked")\r
-@RunWith(PowerMockRunner.class)\r
-@PowerMockIgnore("javax.net.ssl.*")\r
-@PrepareForTest({AbstractConfigRestClientAdapter.class})\r
-public class GenericRestClientServiceTest {\r
-\r
- ConfigRestAdaptorService configRestAdaptorService;\r
-\r
- RestTemplate mockRestTemplate = mock(RestTemplate.class);\r
-\r
- String path = "path";\r
-\r
- @Before\r
- public void before() throws Exception {\r
- whenNew(RestTemplate.class).withAnyArguments().thenReturn(mockRestTemplate);\r
-\r
- String propertyDir = "src/test/resources";\r
- configRestAdaptorService = new ConfigRestAdaptorServiceImpl(propertyDir);\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
- String body = configRestAdaptorService.getResource("modelservice", path, String.class);\r
-\r
- Assert.assertEquals(responseBody, body);\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
- String body = configRestAdaptorService.postResource("modelservice", path, null, String.class);\r
-\r
- Assert.assertEquals(responseBody, body);\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
- String body = configRestAdaptorService.exchangeResource("modelservice", path, null, String.class, "GET");\r
-\r
- Assert.assertEquals(responseBody, body);\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
- configRestAdaptorService.getResource("modelservice", path, String.class);\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
- configRestAdaptorService.postResource("modelservice", path, null, String.class);\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
- configRestAdaptorService.exchangeResource("modelservice", path, null, String.class, "GET");\r
- }\r
-}\r
+++ /dev/null
-/*\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.features.rest.adaptor.service;\r
-\r
-import static org.powermock.api.mockito.PowerMockito.mock;\r
-import static org.powermock.api.mockito.PowerMockito.when;\r
-import static org.powermock.api.mockito.PowerMockito.whenNew;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Matchers;\r
-import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorException;\r
-import org.powermock.core.classloader.annotations.PowerMockIgnore;\r
-import org.powermock.core.classloader.annotations.PrepareForTest;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-import org.springframework.http.HttpMethod;\r
-import org.springframework.http.HttpStatus;\r
-import org.springframework.http.ResponseEntity;\r
-import org.springframework.web.client.RestTemplate;\r
-\r
-@SuppressWarnings("unchecked")\r
-@RunWith(PowerMockRunner.class)\r
-@PowerMockIgnore("javax.net.ssl.*")\r
-@PrepareForTest({AbstractConfigRestClientAdapter.class})\r
-public class SSLClientServiceTest {\r
-\r
- ConfigRestAdaptorService configRestAdaptorService;\r
-\r
- RestTemplate mockRestTemplate = mock(RestTemplate.class);\r
-\r
- String path = "path";\r
-\r
- @Before\r
- public void before() throws Exception {\r
- whenNew(RestTemplate.class).withAnyArguments().thenReturn(mockRestTemplate);\r
-\r
- String propertyDir = "src/test/resources";\r
- configRestAdaptorService = new ConfigRestAdaptorServiceImpl(propertyDir);\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
- String body = configRestAdaptorService.getResource("aai", path, String.class);\r
-\r
- Assert.assertEquals(responseBody, body);\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
- String body = configRestAdaptorService.postResource("aai", path, null, String.class);\r
-\r
- Assert.assertEquals(responseBody, body);\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
- String body = configRestAdaptorService.exchangeResource("aai", path, null, String.class, "GET");\r
-\r
- Assert.assertEquals(responseBody, body);\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
- configRestAdaptorService.getResource("aai", path, String.class);\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
- configRestAdaptorService.postResource("aai", path, null, String.class);\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
- configRestAdaptorService.exchangeResource("aai", path, null, String.class, "GET");\r
- }\r
-}\r
+++ /dev/null
-/*\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.features.rest.adaptor.utils;\r
-\r
-import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorConstants;\r
-import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorException;\r
-import org.onap.ccsdk.features.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
+++ /dev/null
-###
-# Copyright © 2017-2018 AT&T Intellectual Property.
-# Modifications Copyright © 2018 IBM.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-###
-#
-# Configuration file for SDNC Controller Module
-#
-
-org.onap.ccsdk.features.blueprints.adaptors.envtype=solo
-
-# Config Generator Microservices
-org.onap.ccsdk.features.blueprints.adaptors.modelservice.type=generic
-org.onap.ccsdk.features.blueprints.adaptors.modelservice.enable=true
-org.onap.ccsdk.features.blueprints.adaptors.modelservice.url=http://localhost:8080/configgenerator/service/
-org.onap.ccsdk.features.blueprints.adaptors.modelservice.user=admin
-org.onap.ccsdk.features.blueprints.adaptors.modelservice.passwd=admin
-
-# Generic RESTCONF Adaptor
-org.onap.ccsdk.features.blueprints.adaptors.restconf.type=generic
-org.onap.ccsdk.features.blueprints.adaptors.restconf.enable=true
-org.onap.ccsdk.features.blueprints.adaptors.restconf.user=admin
-org.onap.ccsdk.features.blueprints.adaptors.restconf.passwd=admin
-org.onap.ccsdk.features.blueprints.adaptors.restconf.url=http://localhost:8181/restconf/
-
-# SSL AAI Adaptor
-org.onap.ccsdk.features.blueprints.adaptors.aai.propertyfile=aai.properties
-org.onap.ccsdk.features.blueprints.adaptors.aai.type=ssl
-org.onap.ccsdk.features.blueprints.adaptors.aai.enable=true
-org.onap.ccsdk.features.blueprints.adaptors.aai.url=https://localhost:8443/onap-aai/
-org.onap.ccsdk.features.blueprints.adaptors.aai.ssl.trust=src/test/resources/truststore.client.jks
-org.onap.ccsdk.features.blueprints.adaptors.aai.ssl.trust.psswd=changeme
-org.onap.ccsdk.features.blueprints.adaptors.aai.ssl.key=src/test/resources/keystore.client.p12
-org.onap.ccsdk.features.blueprints.adaptors.aai.ssl.key.psswd=changeme
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (C) 2018 AT&T, Bell Canada
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onap.ccsdk.parent</groupId>
- <artifactId>single-feature-parent</artifactId>
- <version>1.5.2-SNAPSHOT</version>
- <relativePath/>
- </parent>
-
- <groupId>org.onap.ccsdk.features</groupId>
- <artifactId>ccsdk-blueprints-processor</artifactId>
- <version>0.7.1-SNAPSHOT</version>
- <packaging>feature</packaging>
-
- <name>ccsdk-features :: blueprints-processor-features :: ${project.artifactId}</name>
- <properties>
- <ccsdk.sli.core.version>${project.version}</ccsdk.sli.core.version>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>odl-mdsal-broker</artifactId>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
-
- <dependency>
- <groupId>org.onap.ccsdk.sli.core</groupId>
- <artifactId>ccsdk-sli</artifactId>
- <version>${ccsdk.sli.core.version}</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>blueprints-rest-adaptor-provider</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>blueprints-data-adaptor-provider</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>blueprints-model-provider</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>blueprints-generator-provider</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>blueprints-assignment-provider</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-core</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.module</groupId>
- <artifactId>jackson-module-jsonSchema</artifactId>
- </dependency>
- </dependencies>
-</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (C) 2018 AT&T, Bell Canada
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onap.ccsdk.parent</groupId>
- <artifactId>feature-repo-parent</artifactId>
- <version>1.5.2-SNAPSHOT</version>
- <relativePath/>
- </parent>
-
- <groupId>org.onap.ccsdk.features</groupId>
- <artifactId>features-blueprints-processor</artifactId>
- <version>0.7.1-SNAPSHOT</version>
- <packaging>feature</packaging>
-
- <name>ccsdk-features :: blueprints-processor-features :: ${project.artifactId}</name>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ccsdk-blueprints-processor</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
-
- </dependencies>
-</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (C) 2018 AT&T, Bell Canada
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onap.ccsdk.parent</groupId>
- <artifactId>odlparent-lite</artifactId>
- <version>1.5.2-SNAPSHOT</version>
- <relativePath/>
- </parent>
-
- <groupId>org.onap.ccsdk.features</groupId>
- <artifactId>blueprints-processor-features</artifactId>
- <version>0.7.1-SNAPSHOT</version>
- <packaging>pom</packaging>
-
- <name>ccsdk-features :: ${project.artifactId}</name>
-
- <modules>
- <module>ccsdk-blueprints-processor</module>
- <module>features-blueprints-processor</module>
- </modules>
-</project>
+++ /dev/null
-/target-ide/\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright © 2017-2018 AT&T Intellectual Property.
- Modifications Copyright © 2018 IBM.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onap.ccsdk.parent</groupId>
- <artifactId>odlparent-lite</artifactId>
- <version>1.5.2-SNAPSHOT</version>
- <relativePath/>
- </parent>
-
- <groupId>org.onap.ccsdk.features</groupId>
- <artifactId>blueprints-processor-installer</artifactId>
- <version>0.7.1-SNAPSHOT</version>
- <packaging>pom</packaging>
-
- <name>ccsdk-features :: ${project.artifactId}</name>
-
- <properties>
- <application.name>blueprints-processor</application.name>
- <features.boot>blueprints-processor-features</features.boot>
- <features.repositories>mvn:org.onap.ccsdk.features/ccsdk-features/blueprints-processor-features/${project.version}/xml/features</features.repositories>
- <include.transitive.dependencies>false</include.transitive.dependencies>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.onap.ccsdk.features</groupId>
- <artifactId>ccsdk-blueprints-processor</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>features</classifier>
- <exclusions>
- <exclusion>
- <groupId>*</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.onap.ccsdk.features</groupId>
- <artifactId>blueprints-data-adaptor-provider</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.ccsdk.features</groupId>
- <artifactId>blueprints-rest-adaptor-provider</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.ccsdk.features</groupId>
- <artifactId>blueprints-assignment-provider</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.ccsdk.features</groupId>
- <artifactId>blueprints-generator-provider</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.ccsdk.features</groupId>
- <artifactId>blueprints-model-provider</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <id>maven-repo-zip</id>
- <goals>
- <goal>single</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <attach>true</attach>
- <finalName>stage/${application.name}-${project.version}</finalName>
- <descriptors>
- <descriptor>src/assembly/assemble_mvnrepo_zip.xml</descriptor>
- </descriptors>
- <appendAssemblyId>true</appendAssemblyId>
- </configuration>
- </execution>
- <execution>
- <id>installer-zip</id>
- <goals>
- <goal>single</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <attach>true</attach>
- <finalName>${application.name}-${project.version}-installer</finalName>
- <descriptors>
- <descriptor>src/assembly/assemble_installer_zip.xml</descriptor>
- </descriptors>
- <appendAssemblyId>false</appendAssemblyId>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-dependencies</id>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <phase>prepare-package</phase>
- <configuration>
- <transitive>false</transitive>
- <outputDirectory>${project.build.directory}/assembly/system</outputDirectory>
- <overWriteReleases>false</overWriteReleases>
- <overWriteSnapshots>true</overWriteSnapshots>
- <overWriteIfNewer>true</overWriteIfNewer>
- <useRepositoryLayout>true</useRepositoryLayout>
- <addParentPoms>false</addParentPoms>
- <copyPom>false</copyPom>
- <includeGroupIds>org.onap.ccsdk.features</includeGroupIds>
- <scope>provided</scope>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-resources-plugin</artifactId>
- <version>2.6</version>
- <executions>
- <execution>
- <id>copy-version</id>
- <goals>
- <goal>copy-resources</goal>
- </goals><!-- here the phase you need -->
- <phase>validate</phase>
- <configuration>
- <outputDirectory>${basedir}/target/stage</outputDirectory>
- <resources>
- <resource>
- <directory>src/main/resources/scripts</directory>
- <includes>
- <include>install-feature.sh</include>
- </includes>
- <filtering>true</filtering>
- </resource>
- </resources>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-<!--\r
- Copyright (C) 2018 AT&T, Bell Canada\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
-<!-- Defines how we build the .zip file which is our distribution. -->\r
-\r
-<assembly\r
-xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"\r
-xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">\r
- <id>installer_zip</id>\r
- <formats>\r
- <format>zip</format>\r
- </formats>\r
-\r
- <!-- we want "system" and related files right at the root level\r
- as this file is suppose to be unzip on top of a karaf\r
- distro. -->\r
- <includeBaseDirectory>false</includeBaseDirectory>\r
-\r
- <fileSets>\r
- <fileSet>\r
- <directory>target/stage/</directory>\r
- <outputDirectory>${application.name}</outputDirectory>\r
- <fileMode>755</fileMode>\r
- <includes>\r
- <include>*.sh</include>\r
- </includes>\r
- </fileSet>\r
- <fileSet>\r
- <directory>target/stage/</directory>\r
- <outputDirectory>${application.name}</outputDirectory>\r
- <fileMode>644</fileMode>\r
- <excludes>\r
- <exclude>*.sh</exclude>\r
- </excludes>\r
- </fileSet>\r
- </fileSets>\r
-\r
-\r
-</assembly>\r
+++ /dev/null
-<!--\r
- Copyright (C) 2018 AT&T, Bell Canada\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
-<!-- Defines how we build the .zip file which is our distribution. -->\r
-\r
-<assembly\r
-xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"\r
-xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">\r
- <id>repo</id>\r
- <formats>\r
- <format>zip</format>\r
- </formats>\r
-\r
- <!-- we want "system" and related files right at the root level\r
- as this file is suppose to be unzip on top of a karaf\r
- distro. -->\r
- <includeBaseDirectory>false</includeBaseDirectory>\r
-\r
- <fileSets>\r
- <fileSet>\r
- <directory>target/assembly/</directory>\r
- <outputDirectory>.</outputDirectory>\r
- <excludes>\r
- </excludes>\r
- </fileSet>\r
- </fileSets>\r
-\r
-\r
-</assembly>\r
+++ /dev/null
-#!/bin/bash\r
-\r
-###\r
-#\r
-# Copyright © 2017-2018 AT&T Intellectual Property.\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
-\r
-ODL_HOME=${ODL_HOME:-/opt/opendaylight/current}\r
-ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client}\r
-INSTALLERDIR=$(dirname $0)\r
-\r
-REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip\r
-\r
-if [ -f ${REPOZIP} ]\r
-then\r
- unzip -d ${ODL_HOME} ${REPOZIP}\r
-else\r
- echo "ERROR : repo zip ($REPOZIP) not found!"\r
- exit 1\r
-fi\r
-\r
-${ODL_KARAF_CLIENT} feature:repo-add ${features.repositories}\r
-${ODL_KARAF_CLIENT} feature:install ${features.boot}\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright © 2017-2018 AT&T Intellectual Property.
- Modifications Copyright © 2018 IBM.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onap.ccsdk.parent</groupId>
- <artifactId>binding-parent</artifactId>
- <version>1.5.2-SNAPSHOT</version>
- <relativePath/>
- </parent>
-
- <groupId>org.onap.ccsdk.features</groupId>
- <artifactId>blueprints-assignment-provider</artifactId>
- <version>0.7.1-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <name>ccsdk-features :: blueprints-processor-plugin :: ${project.artifactId}</name>
- <url>http://maven.apache.org</url>
-
- <dependencies>
- <dependency>
- <groupId>org.onap.ccsdk.features</groupId>
- <artifactId>blueprints-generator-provider</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-core</artifactId>
- <version>${jackson.version}</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- <version>${jackson.version}</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-annotations</artifactId>
- <version>${jackson.version}</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.module</groupId>
- <artifactId>jackson-module-jsonSchema</artifactId>
- <version>${jackson.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.osgi-mock</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito</artifactId>
- <version>1.6.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.javassist</groupId>
- <artifactId>javassist</artifactId>
- <version>3.21.0-GA</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <version>1.10.19</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-junit4</artifactId>
- <version>1.6.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-support</artifactId>
- <version>1.6.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-reflect</artifactId>
- <version>1.6.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-core</artifactId>
- <version>1.6.4</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <configuration>
- <additionalparam>-Xdoclint:none</additionalparam>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Name>${project.artifactId}</Bundle-Name>
- <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>org.onap.ccsdk.features.assignment,
- org.onap.ccsdk.features.assignment.data,
- org.onap.ccsdk.features.assignment.service,
- org.onap.ccsdk.features.assignment.processor,
- org.onap.ccsdk.features.assignment.processor.custom
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-/*\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.features.assignment;\r
-\r
-@SuppressWarnings("squid:S1118")\r
-public class ConfigAssignmentConstants {\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
- 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
+++ /dev/null
-/*\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.features.assignment.data;\r
-\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.onap.ccsdk.features.model.data.ResourceAssignment;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-\r
-public class ResourceAssignmentData {\r
-\r
- private String requestId;\r
- private boolean reloadModel;\r
- private String resourceType;\r
- private String resourceId;\r
- private String serviceTemplateName;\r
- private String serviceTemplateVersion;\r
- private String actionName;\r
- private String inputData;\r
- private SvcLogicContext svcLogicContext;\r
- private List<String> templateNames;\r
- private Map<String, List<ResourceAssignment>> templatesResourceAssignments = new HashMap<>();\r
- private Map<String, String> templatesContents = new HashMap<>();\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
- public String getRequestId() {\r
- return requestId;\r
- }\r
-\r
- public void setRequestId(String requestId) {\r
- this.requestId = requestId;\r
- }\r
-\r
- public String getResourceType() {\r
- return resourceType;\r
- }\r
-\r
- public void setResourceType(String resourceType) {\r
- this.resourceType = resourceType;\r
- }\r
-\r
- public String getResourceId() {\r
- return resourceId;\r
- }\r
-\r
- public void setResourceId(String resourceId) {\r
- this.resourceId = resourceId;\r
- }\r
-\r
- public String getServiceTemplateName() {\r
- return serviceTemplateName;\r
- }\r
-\r
- public void setServiceTemplateName(String serviceTemplateName) {\r
- this.serviceTemplateName = serviceTemplateName;\r
- }\r
-\r
- public String getServiceTemplateVersion() {\r
- return serviceTemplateVersion;\r
- }\r
-\r
- public void setServiceTemplateVersion(String serviceTemplateVersion) {\r
- this.serviceTemplateVersion = serviceTemplateVersion;\r
- }\r
-\r
- public String getActionName() {\r
- return actionName;\r
- }\r
-\r
- public void setActionName(String actionName) {\r
- this.actionName = actionName;\r
- }\r
-\r
- public String getInputData() {\r
- return inputData;\r
- }\r
-\r
- public void setInputData(String inputData) {\r
- this.inputData = inputData;\r
- }\r
-\r
- public List<String> getTemplateNames() {\r
- return templateNames;\r
- }\r
-\r
- public void setTemplateNames(List<String> templateNames) {\r
- this.templateNames = templateNames;\r
- }\r
-\r
- public Map<String, List<ResourceAssignment>> getTemplatesResourceAssignments() {\r
- return templatesResourceAssignments;\r
- }\r
-\r
- public void setTemplatesResourceAssignments(Map<String, List<ResourceAssignment>> templatesResourceAssignments) {\r
- this.templatesResourceAssignments = templatesResourceAssignments;\r
- }\r
-\r
- public Map<String, String> getTemplatesContents() {\r
- return templatesContents;\r
- }\r
-\r
- public void setTemplatesContents(Map<String, String> templatesContents) {\r
- this.templatesContents = templatesContents;\r
- }\r
-\r
- public Map<String, String> getTemplatesMashedContents() {\r
- return templatesMashedContents;\r
- }\r
-\r
- public void setTemplatesMashedContents(Map<String, String> templatesMashedContents) {\r
- this.templatesMashedContents = templatesMashedContents;\r
- }\r
-\r
- public Map<String, String> getTemplatesData() {\r
- return templatesData;\r
- }\r
-\r
- public void setTemplatesData(Map<String, String> templatesData) {\r
- this.templatesData = templatesData;\r
- }\r
-\r
- public Map<String, Object> getContext() {\r
- return context;\r
- }\r
-\r
- public void setContext(Map<String, Object> context) {\r
- this.context = context;\r
- }\r
-\r
- public SvcLogicContext getSvcLogicContext() {\r
- return svcLogicContext;\r
- }\r
-\r
- public void setSvcLogicContext(SvcLogicContext svcLogicContext) {\r
- this.svcLogicContext = svcLogicContext;\r
- }\r
-\r
- public boolean isReloadModel() {\r
- return reloadModel;\r
- }\r
-\r
- public void setReloadModel(boolean reloadModel) {\r
- this.reloadModel = reloadModel;\r
- }\r
-}\r
+++ /dev/null
-/*\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.features.assignment.processor;\r
-\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.apache.commons.collections.CollectionUtils;\r
-import org.apache.commons.collections.MapUtils;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.assignment.service.ConfigAssignmentUtils;\r
-import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.ConfigModelException;\r
-import org.onap.ccsdk.features.model.ValidTypes;\r
-import org.onap.ccsdk.features.model.data.ResourceAssignment;\r
-import org.onap.ccsdk.features.model.data.dict.ResourceDefinition;\r
-import org.onap.ccsdk.features.model.data.dict.SourcesDefinition;\r
-import org.onap.ccsdk.features.model.service.ComponentNode;\r
-import org.onap.ccsdk.features.model.utils.JsonUtils;\r
-import org.onap.ccsdk.features.model.utils.ResourceAssignmentUtils;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-import com.fasterxml.jackson.databind.node.ArrayNode;\r
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;\r
-import com.fasterxml.jackson.databind.node.ObjectNode;\r
-\r
-public class DBResourceProcessor implements ComponentNode {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(DBResourceProcessor.class);\r
- private ConfigResourceService configResourceService;\r
- private Map<String, ResourceDefinition> dictionaries;\r
-\r
- public DBResourceProcessor(ConfigResourceService configResourceService) {\r
- this.configResourceService = configResourceService;\r
- }\r
-\r
- @Override\r
- public Boolean preCondition(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- return Boolean.TRUE;\r
- }\r
-\r
- @Override\r
- public void preProcess(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- // Auto-generated method stub\r
- }\r
-\r
- @Override\r
- public void process(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {\r
- // Auto-generated method stub\r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- @Override\r
- public void process(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- try {\r
- List<ResourceAssignment> batchResourceAssignment =\r
- (List<ResourceAssignment>) componentContext.get(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS);\r
- dictionaries =\r
- (Map<String, ResourceDefinition>) componentContext.get(ConfigModelConstant.PROPERTY_DICTIONARIES);\r
-\r
- if (CollectionUtils.isNotEmpty(batchResourceAssignment)) {\r
- for (ResourceAssignment resourceAssignment : batchResourceAssignment) {\r
- processResourceAssignment(ctx, componentContext, resourceAssignment);\r
- }\r
- }\r
- } catch (Exception e) {\r
- throw new SvcLogicException(String.format("DBResourceProcessor Exception : (%s)", e), e);\r
- }\r
- }\r
-\r
- private void processResourceAssignment(SvcLogicContext ctx, Map<String, Object> componentContext,\r
- ResourceAssignment resourceAssignment) throws SvcLogicException, ConfigModelException {\r
- if (resourceAssignment != null) {\r
- try {\r
- validate(resourceAssignment);\r
-\r
- // Check if It has Input\r
- Object value = ConfigAssignmentUtils.getContextKeyValue(ctx, resourceAssignment.getName());\r
- if (value != null) {\r
- logger.info("db source template key ({}) found from input and value is ({})",\r
- resourceAssignment.getName(), value);\r
- ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, value);\r
- return;\r
- }\r
-\r
- ResourceDefinition resourceDefinition = dictionaries.get(resourceAssignment.getDictionaryName());\r
- SourcesDefinition sourceDb = resourceDefinition.getSources().get("db");\r
- if (StringUtils.isBlank(sourceDb.getProperties().getQuery())) {\r
- throw new SvcLogicException("db query property is missing");\r
- }\r
-\r
- String sql = sourceDb.getProperties().getQuery();\r
- Map<String, String> inputKeyMapping = sourceDb.getProperties().getInputKeyMapping();\r
-\r
- logger.info("Db dictionary information : ({}), ({}), ({})", sql, inputKeyMapping,\r
- sourceDb.getProperties().getOutputKeyMapping());\r
-\r
- Map<String, Object> namedParameters = populateNamedParameter(componentContext, inputKeyMapping);\r
-\r
- logger.info("Parameter information : ({})", namedParameters);\r
- List<Map<String, Object>> rows = configResourceService.query(sql, namedParameters);\r
- if (rows != null && !rows.isEmpty()) {\r
- processDBResults(ctx, componentContext, resourceAssignment, sourceDb, rows);\r
- } else {\r
- logger.warn("Failed to get db result for dictionary name ({}) the query ({})",\r
- resourceAssignment.getDictionaryName(), sql);\r
- }\r
-\r
- // Check the value has populated for mandatory case\r
- ResourceAssignmentUtils.assertTemplateKeyValueNotNull(componentContext, resourceAssignment);\r
- } catch (Exception e) {\r
- ResourceAssignmentUtils.setFailedResourceDataValue(componentContext, resourceAssignment,\r
- e.getMessage());\r
- throw new SvcLogicException(\r
- String.format("Failed in template key (%s) assignments : (%s)", resourceAssignment, e), e);\r
- }\r
- } else {\r
- // Do Nothing\r
- }\r
- }\r
-\r
- private void validate(ResourceAssignment resourceAssignment) throws SvcLogicException {\r
- if (resourceAssignment == null) {\r
- throw new SvcLogicException("resource assignment is not defined");\r
- }\r
-\r
- if (StringUtils.isBlank(resourceAssignment.getName())) {\r
- throw new SvcLogicException("resource assignment template key is not defined");\r
- }\r
-\r
- if (StringUtils.isBlank(resourceAssignment.getDictionaryName())) {\r
- throw new SvcLogicException(\r
- String.format("resource assignment dictionary name is not defined for template key (%s)",\r
- resourceAssignment.getName()));\r
- }\r
-\r
- if (!ConfigModelConstant.SOURCE_DB.equalsIgnoreCase(resourceAssignment.getDictionarySource())) {\r
- throw new SvcLogicException(String.format("resource assignment source is not db, it is (%s)",\r
- resourceAssignment.getDictionarySource()));\r
- }\r
-\r
- ResourceDefinition resourceDefinition = dictionaries.get(resourceAssignment.getDictionaryName());\r
- if (resourceDefinition == null) {\r
- throw new SvcLogicException(String.format("missing resource dictionary definition for name (%s) ",\r
- resourceAssignment.getDictionaryName()));\r
- }\r
-\r
- if (resourceDefinition.getSources() == null || resourceDefinition.getSources().get("db") == null) {\r
- throw new SvcLogicException(String.format("missing resource dictionary db source definition for name (%s) ",\r
- resourceAssignment.getDictionaryName()));\r
- }\r
-\r
- SourcesDefinition sourceDb = resourceDefinition.getSources().get("db");\r
- if (StringUtils.isBlank(sourceDb.getProperties().getQuery())) {\r
- throw new SvcLogicException(String.format("Failed to get request Query for dictionary (%s)",\r
- resourceAssignment.getDictionaryName()));\r
- }\r
-\r
- }\r
-\r
- private Map<String, Object> populateNamedParameter(Map<String, Object> componentContext,\r
- Map<String, String> inputKeyMapping) {\r
- Map<String, Object> namedParameters = new HashMap<>();\r
- if (MapUtils.isNotEmpty(inputKeyMapping)) {\r
-\r
- for (Map.Entry<String, String> mapping : inputKeyMapping.entrySet()) {\r
- ResourceDefinition referenceDictionaryDefinition = dictionaries.get(mapping.getValue());\r
- Object expressionValue =\r
- ResourceAssignmentUtils.getDictionaryKeyValue(componentContext, referenceDictionaryDefinition);\r
- logger.trace("Reference dictionary key ({}), value ({})", mapping.getKey(), expressionValue);\r
- namedParameters.put(mapping.getKey(), expressionValue);\r
- }\r
- }\r
- return namedParameters;\r
- }\r
-\r
- @SuppressWarnings("squid:S3776")\r
- private void processDBResults(SvcLogicContext ctx, Map<String, Object> componentContext,\r
- ResourceAssignment resourceAssignment, SourcesDefinition sourceDb, List<Map<String, Object>> rows)\r
- throws SvcLogicException, ConfigModelException {\r
-\r
- Map<String, String> outputKeyMapping = sourceDb.getProperties().getOutputKeyMapping();\r
- String type = resourceAssignment.getProperty().getType();\r
- String entrySchema = null;\r
- logger.info("Response processing type({})", type);\r
- // Primitive Types\r
- if (ValidTypes.getPrimitivePropertType().contains(type)) {\r
-\r
- Map<String, Object> row = rows.get(0);\r
- String dbColumnName = outputKeyMapping.get(resourceAssignment.getDictionaryName());\r
- Object dbColumnValue = row.get(dbColumnName);\r
- ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, dbColumnValue);\r
-\r
- } else if (ValidTypes.getListPropertType().contains(type)) {\r
- // Array Types\r
- if (resourceAssignment.getProperty().getEntrySchema() != null) {\r
- entrySchema = resourceAssignment.getProperty().getEntrySchema().getType();\r
- }\r
-\r
- if (StringUtils.isNotBlank(entrySchema)) {\r
- ArrayNode arrayNode = JsonNodeFactory.instance.arrayNode();\r
-\r
- for (Map<String, Object> row : rows) {\r
- if (ValidTypes.getPrimitivePropertType().contains(entrySchema)) {\r
- String dbColumnName = outputKeyMapping.get(resourceAssignment.getDictionaryName());\r
- Object dbColumnValue = row.get(dbColumnName);\r
- // Add Array JSON\r
- JsonUtils.populatePrimitiveValues(dbColumnValue, entrySchema, arrayNode);\r
- } else {\r
- ObjectNode arrayChildNode = JsonNodeFactory.instance.objectNode();\r
- for (Map.Entry<String, String> mapping : outputKeyMapping.entrySet()) {\r
- Object dbColumnValue = row.get(mapping.getKey());\r
- String propertyTypeForDataType =\r
- ConfigAssignmentUtils.getPropertyType(ctx, entrySchema, mapping.getKey());\r
- JsonUtils.populatePrimitiveValues(mapping.getKey(), dbColumnValue, propertyTypeForDataType,\r
- arrayChildNode);\r
- }\r
- arrayNode.add(arrayChildNode);\r
- }\r
- }\r
- // Set the List of Complex Values\r
- ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, arrayNode);\r
- } else {\r
- throw new SvcLogicException(String.format("Entry schema is not defined for dictionary (%s) info",\r
- resourceAssignment.getDictionaryName()));\r
- }\r
- } else {\r
- // Complex Types\r
- Map<String, Object> row = rows.get(0);\r
- ObjectNode objectNode = JsonNodeFactory.instance.objectNode();\r
- for (Map.Entry<String, String> mapping : outputKeyMapping.entrySet()) {\r
- Object dbColumnValue = row.get(mapping.getKey());\r
- String propertyTypeForDataType = ConfigAssignmentUtils.getPropertyType(ctx, type, mapping.getKey());\r
- JsonUtils.populatePrimitiveValues(mapping.getKey(), dbColumnValue, propertyTypeForDataType, objectNode);\r
- }\r
- ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, objectNode);\r
- }\r
- }\r
-\r
- @Override\r
- public void postProcess(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- // Auto-generated method stub\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.assignment.processor;\r
-\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.assignment.service.ConfigAssignmentUtils;\r
-import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.ConfigModelException;\r
-import org.onap.ccsdk.features.model.data.ResourceAssignment;\r
-import org.onap.ccsdk.features.model.service.ComponentNode;\r
-import org.onap.ccsdk.features.model.utils.ResourceAssignmentUtils;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-\r
-public class DefaultResourceProcessor implements ComponentNode {\r
-\r
- public DefaultResourceProcessor(ConfigResourceService configResourceService) {}\r
-\r
- @Override\r
- public Boolean preCondition(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- return Boolean.TRUE;\r
- }\r
-\r
- @Override\r
- public void preProcess(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- // Auto-generated method stub\r
- }\r
-\r
- @Override\r
- public void process(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {\r
- // Auto-generated method stub\r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- @Override\r
- public void process(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- try {\r
- List<ResourceAssignment> batchResourceAssignment =\r
- (List<ResourceAssignment>) componentContext.get(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS);\r
-\r
- if (batchResourceAssignment != null && !batchResourceAssignment.isEmpty()) {\r
- for (ResourceAssignment resourceAssignment : batchResourceAssignment) {\r
- processResourceAssignment(ctx, componentContext, resourceAssignment);\r
- }\r
- }\r
- } catch (Exception e) {\r
- throw new SvcLogicException(String.format("DefaultResourceProcessor Exception : (%s)", e), e);\r
- }\r
-\r
- }\r
-\r
- private void processResourceAssignment(SvcLogicContext ctx, Map<String, Object> componentContext,\r
- ResourceAssignment resourceAssignment) throws ConfigModelException, SvcLogicException {\r
- if (resourceAssignment != null && StringUtils.isNotBlank(resourceAssignment.getName())\r
- && resourceAssignment.getProperty() != null) {\r
- try {\r
- // Check if It has Input\r
- Object value = ConfigAssignmentUtils.getContextKeyValue(ctx, resourceAssignment.getName());\r
- if (value == null) {\r
- value = resourceAssignment.getProperty().getDefaultValue();\r
- }\r
-\r
- // if value is null don't call setResourceDataValue to populate the value\r
- if (value != null) {\r
- ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, value);\r
- }\r
-\r
- // Check the value has populated for mandatory case\r
- ResourceAssignmentUtils.assertTemplateKeyValueNotNull(componentContext, resourceAssignment);\r
- } catch (Exception e) {\r
- ResourceAssignmentUtils.setFailedResourceDataValue(componentContext, resourceAssignment,\r
- e.getMessage());\r
- throw new SvcLogicException(\r
- String.format("Failed in template key (%s) assignments with : (%s)", resourceAssignment, e), e);\r
- }\r
- }\r
- }\r
-\r
- @Override\r
- public void postProcess(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- // Auto-generated method stub\r
-\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.assignment.processor;\r
-\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.ConfigModelException;\r
-import org.onap.ccsdk.features.model.data.ResourceAssignment;\r
-import org.onap.ccsdk.features.model.service.ComponentNode;\r
-import org.onap.ccsdk.features.model.utils.ResourceAssignmentUtils;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-\r
-public class InputResourceProcessor implements ComponentNode {\r
-\r
- public InputResourceProcessor(ConfigResourceService configResourceService) {}\r
-\r
- @Override\r
- public Boolean preCondition(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- return Boolean.TRUE;\r
- }\r
-\r
- @Override\r
- public void preProcess(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- // Auto-generated method stub\r
- }\r
-\r
- @Override\r
- public void process(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {\r
- // Auto-generated method stub\r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- @Override\r
- public void process(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- try {\r
- List<ResourceAssignment> batchResourceAssignment =\r
- (List<ResourceAssignment>) componentContext.get(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS);\r
- if (batchResourceAssignment != null && !batchResourceAssignment.isEmpty()) {\r
- for (ResourceAssignment resourceAssignment : batchResourceAssignment) {\r
- processResourceAssignment(ctx, componentContext, resourceAssignment);\r
- }\r
- }\r
- } catch (Exception e) {\r
- throw new SvcLogicException(String.format("InputResourceProcessor Exception : (%s)", e), e);\r
- }\r
- }\r
-\r
- private void processResourceAssignment(SvcLogicContext ctx, Map<String, Object> componentContext,\r
- ResourceAssignment resourceAssignment) throws ConfigModelException, SvcLogicException {\r
- try {\r
- if (StringUtils.isNotBlank(resourceAssignment.getName())) {\r
- String value = ctx.getAttribute(resourceAssignment.getName());\r
- // if value is null don't call setResourceDataValue to populate the value\r
- if (StringUtils.isNotBlank(value)) {\r
- ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, value);\r
- }\r
- }\r
-\r
- // Check the value has populated for mandatory case\r
- ResourceAssignmentUtils.assertTemplateKeyValueNotNull(componentContext, resourceAssignment);\r
- } catch (Exception e) {\r
- ResourceAssignmentUtils.setFailedResourceDataValue(componentContext, resourceAssignment, e.getMessage());\r
- throw new SvcLogicException(\r
- String.format("Failed in template key (%s) assignments with : (%s)", resourceAssignment, e), e);\r
- }\r
- }\r
-\r
- @Override\r
- public void postProcess(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- // Auto-generated method stub\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.assignment.processor;\r
-\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.apache.commons.collections.CollectionUtils;\r
-import org.apache.commons.collections.MapUtils;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.assignment.service.ConfigAssignmentUtils;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.ConfigModelException;\r
-import org.onap.ccsdk.features.model.data.ResourceAssignment;\r
-import org.onap.ccsdk.features.model.data.dict.ResourceDefinition;\r
-import org.onap.ccsdk.features.model.data.dict.SourcesDefinition;\r
-import org.onap.ccsdk.features.model.service.ComponentNode;\r
-import org.onap.ccsdk.features.model.utils.ResourceAssignmentUtils;\r
-import org.onap.ccsdk.features.model.utils.TransformationUtils;\r
-import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorConstants;\r
-import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-import com.fasterxml.jackson.databind.JsonNode;\r
-\r
-public class MdsalResourceProcessor implements ComponentNode {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(MdsalResourceProcessor.class);\r
- private ConfigRestAdaptorService configRestAdaptorService;\r
- private Map<String, ResourceDefinition> dictionaries;\r
-\r
- public MdsalResourceProcessor(ConfigRestAdaptorService configRestAdaptorService) {\r
- this.configRestAdaptorService = configRestAdaptorService;\r
- }\r
-\r
- @Override\r
- public Boolean preCondition(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- return Boolean.TRUE;\r
- }\r
-\r
- @Override\r
- public void preProcess(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- // Auto-generated method stub\r
- }\r
-\r
- @Override\r
- public void process(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {\r
- // Auto-generated method stub\r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- @Override\r
- public void process(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- try {\r
- List<ResourceAssignment> batchResourceAssignment =\r
- (List<ResourceAssignment>) componentContext.get(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS);\r
- dictionaries =\r
- (Map<String, ResourceDefinition>) componentContext.get(ConfigModelConstant.PROPERTY_DICTIONARIES);\r
-\r
- if (CollectionUtils.isNotEmpty(batchResourceAssignment)) {\r
- for (ResourceAssignment resourceAssignment : batchResourceAssignment) {\r
- processResourceAssignmnet(ctx, componentContext, resourceAssignment);\r
- }\r
- }\r
- } catch (Exception e) {\r
- throw new SvcLogicException(String.format("MdsalResourceProcessor Exception : (%s) ", e), e);\r
- }\r
- }\r
-\r
- private void processResourceAssignmnet(SvcLogicContext ctx, Map<String, Object> componentContext,\r
- ResourceAssignment resourceAssignment) throws ConfigModelException, SvcLogicException {\r
-\r
- try {\r
- // Validating Resource Assignment and Dictionary Definition data\r
- validate(resourceAssignment);\r
-\r
- // Check if It has Input\r
- Object value = ConfigAssignmentUtils.getContextKeyValue(ctx, resourceAssignment.getName());\r
- if (value != null) {\r
- logger.info("mdsal source template key ({}) found from input and value is ({})",\r
- resourceAssignment.getName(), value);\r
- ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, value);\r
- return;\r
- }\r
-\r
- ResourceDefinition resourceDefinition = dictionaries.get(resourceAssignment.getDictionaryName());\r
- SourcesDefinition sourceMdsal = resourceDefinition.getSources().get("mdsal");\r
- String urlPath = sourceMdsal.getProperties().getUrlPath();\r
- String path = sourceMdsal.getProperties().getPath();\r
- Map<String, String> inputKeyMapping = sourceMdsal.getProperties().getInputKeyMapping();\r
- Map<String, String> outputKeyMapping = sourceMdsal.getProperties().getOutputKeyMapping();\r
-\r
- logger.info(\r
- "mdsal dictionary information : urlpath ({}), path({}), inputKeyMapping ({}), outputKeyMapping ({})",\r
- urlPath, path, inputKeyMapping, outputKeyMapping);\r
-\r
- // Resolving url Variables\r
- Map<String, Object> urlVariables = populateUrlVariables(inputKeyMapping, componentContext);\r
- for (Map.Entry<String, Object> entry : urlVariables.entrySet()) {\r
- urlPath = urlPath.replaceAll("\\$" + entry.getKey(), entry.getValue().toString());\r
- }\r
-\r
- String restResponse = fetchResourceFromMDSAL(urlPath);\r
- // if restResponse is null don't call processMdsalResults to populate the value\r
- if (StringUtils.isNotBlank(restResponse)) {\r
- // Processing MDSAL Response\r
- processMdsalResults(ctx, componentContext, resourceAssignment, sourceMdsal, restResponse);\r
- } else {\r
- logger.warn("Coudn't get proper mdsal Response content ({}) for Resource Name ({}) for URI ({})",\r
- restResponse, resourceAssignment.getDictionaryName(), urlPath);\r
- }\r
-\r
- // Check the value has populated for mandatory case\r
- ResourceAssignmentUtils.assertTemplateKeyValueNotNull(componentContext, resourceAssignment);\r
- } catch (Exception e) {\r
- ResourceAssignmentUtils.setFailedResourceDataValue(componentContext, resourceAssignment, e.getMessage());\r
- throw new SvcLogicException(\r
- String.format("Failed in assignments for (%s) with (%s)", resourceAssignment, e), e);\r
- }\r
- }\r
-\r
- private String fetchResourceFromMDSAL(String urlPath) {\r
- String response = null;\r
- try {\r
- response = configRestAdaptorService.getResource(ConfigRestAdaptorConstants.SELECTOR_RESTCONF, urlPath,\r
- String.class);\r
- } catch (Exception e) {\r
- logger.warn("Fetching MDSAL data for URL ({}) failed with Error ({})", urlPath, e);\r
- }\r
- return response;\r
- }\r
-\r
- private void validate(ResourceAssignment resourceAssignment) throws SvcLogicException {\r
- if (resourceAssignment == null) {\r
- throw new SvcLogicException("resource assignment is not defined");\r
- }\r
-\r
- if (StringUtils.isBlank(resourceAssignment.getName())) {\r
- throw new SvcLogicException("resource assignment template key is not defined");\r
- }\r
-\r
- if (StringUtils.isBlank(resourceAssignment.getDictionaryName())) {\r
- throw new SvcLogicException(\r
- String.format("resource assignment dictionary name is not defined for template key (%s)",\r
- resourceAssignment.getName()));\r
- }\r
-\r
- if (!ConfigModelConstant.SOURCE_MDSAL.equalsIgnoreCase(resourceAssignment.getDictionarySource())) {\r
- throw new SvcLogicException(String.format("resource assignment source is not mdsal, it is (%s)",\r
- resourceAssignment.getDictionarySource()));\r
- }\r
-\r
- ResourceDefinition resourceDefinition = dictionaries.get(resourceAssignment.getDictionaryName());\r
- if (resourceDefinition == null) {\r
- throw new SvcLogicException(String.format("missing resource dictionary definition for name (%s) ",\r
- resourceAssignment.getDictionaryName()));\r
- }\r
-\r
- if (StringUtils.isBlank(resourceDefinition.getProperty().getType())) {\r
- throw new SvcLogicException(String.format(String.format("Failed to get dictionary (%s) data type info.",\r
- resourceAssignment.getDictionaryName())));\r
- }\r
-\r
- if (resourceDefinition.getSources() == null || resourceDefinition.getSources().get("mdsal") == null) {\r
- throw new SvcLogicException(\r
- String.format("missing resource dictionary mdsal source definition for name (%s) ",\r
- resourceAssignment.getDictionaryName()));\r
- }\r
-\r
- SourcesDefinition sourceMdsal = resourceDefinition.getSources().get("mdsal");\r
- if (StringUtils.isBlank(sourceMdsal.getProperties().getUrlPath())) {\r
- throw new SvcLogicException(String.format("Failed to get request URL Path for dictionary (%s)",\r
- resourceAssignment.getDictionaryName()));\r
- }\r
-\r
- if (StringUtils.isBlank(sourceMdsal.getProperties().getPath())) {\r
- throw new SvcLogicException(String.format("Failed to get request Path for dictionary (%s)",\r
- resourceAssignment.getDictionaryName()));\r
- }\r
- }\r
-\r
- private Map<String, Object> populateUrlVariables(Map<String, String> inputKeyMapping,\r
- Map<String, Object> componentContext) {\r
- Map<String, Object> urlVariables = new HashMap<>();\r
- if (MapUtils.isNotEmpty(inputKeyMapping)) {\r
-\r
- for (Map.Entry<String, String> mapping : inputKeyMapping.entrySet()) {\r
- ResourceDefinition referenceDictionaryDefinition = dictionaries.get(mapping.getValue());\r
- Object expressionValue =\r
- ResourceAssignmentUtils.getDictionaryKeyValue(componentContext, referenceDictionaryDefinition);\r
- logger.trace("Reference dictionary key ({}), value ({})", mapping.getKey(), expressionValue);\r
- urlVariables.put(mapping.getKey(), expressionValue);\r
- }\r
- }\r
- return urlVariables;\r
- }\r
-\r
- private void processMdsalResults(SvcLogicContext ctx, Map<String, Object> componentContext,\r
- ResourceAssignment resourceAssignment, SourcesDefinition sourceMdsal, String restResponse)\r
- throws SvcLogicException, ConfigModelException {\r
-\r
- Map<String, String> outputKeyMapping = sourceMdsal.getProperties().getOutputKeyMapping();\r
- JsonNode responseNode = TransformationUtils.getJsonNodeForString(restResponse);\r
- if (StringUtils.isNotBlank(sourceMdsal.getProperties().getPath())) {\r
- responseNode = responseNode.at(sourceMdsal.getProperties().getPath());\r
- }\r
- if (responseNode != null) {\r
- ConfigAssignmentUtils.populateValueForOutputMapping(ctx, componentContext, resourceAssignment,\r
- outputKeyMapping, responseNode);\r
- }\r
- }\r
-\r
- @Override\r
- public void postProcess(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- // Do Nothing\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.assignment.processor;\r
-\r
-import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.service.ComponentNode;\r
-import org.onap.ccsdk.features.model.service.ComponentNodeService;\r
-import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService;\r
-\r
-public class ProcessorFactory {\r
-\r
- private ConfigResourceService configResourceService;\r
- private ConfigRestAdaptorService configRestAdaptorService;\r
- private ComponentNodeService componentNodeService;\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
- public ComponentNode getInstance(String source) {\r
-\r
- if (ConfigModelConstant.SOURCE_DEFAULT.equalsIgnoreCase(source)) {\r
- return new DefaultResourceProcessor(configResourceService);\r
- } else if (ConfigModelConstant.SOURCE_DB.equalsIgnoreCase(source)) {\r
- return new DBResourceProcessor(configResourceService);\r
- } else if (ConfigModelConstant.SOURCE_MDSAL.equalsIgnoreCase(source)) {\r
- return new MdsalResourceProcessor(configRestAdaptorService);\r
- }\r
- // Default\r
- return new InputResourceProcessor(configResourceService);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.assignment.processor;\r
-\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.apache.commons.collections.CollectionUtils;\r
-import org.onap.ccsdk.features.model.data.ResourceAssignment;\r
-import org.onap.ccsdk.features.model.utils.TopologicalSortingUtils;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class ResourceAssignmentProcessor {\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceAssignmentProcessor.class);\r
-\r
- private List<ResourceAssignment> assignments;\r
- private Map<String, ResourceAssignment> resourceAssignmentMap;\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
- @SuppressWarnings("squid:S3776")\r
- public List<List<ResourceAssignment>> process() {\r
- List<List<ResourceAssignment>> sequenceBatchResourceAssignment = new ArrayList<>();\r
- if (this.assignments != null) {\r
- logger.info("Assignments ({})", this.assignments);\r
- this.assignments.forEach(resourceMapping -> {\r
- if (resourceMapping != null) {\r
- logger.trace("Processing Key ({})", resourceMapping.getName());\r
- resourceAssignmentMap.put(resourceMapping.getName(), resourceMapping);\r
- }\r
- });\r
-\r
- TopologicalSortingUtils<ResourceAssignment> topologySorting = new TopologicalSortingUtils<>();\r
- this.resourceAssignmentMap.forEach((mappingKey, mapping) -> {\r
- if (mapping != null) {\r
- if (mapping.getDependencies() != null && !mapping.getDependencies().isEmpty()) {\r
- for (String dependency : mapping.getDependencies()) {\r
- topologySorting.add(resourceAssignmentMap.get(dependency), mapping);\r
- }\r
- } else {\r
- topologySorting.add(null, mapping);\r
- }\r
- }\r
- });\r
-\r
- List<ResourceAssignment> sequencedResourceAssignments = topologySorting.topSort();\r
- logger.info("Sorted Sequenced Assignments ({})", sequencedResourceAssignments);\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
- if (i > 0) {\r
- previousResourceAssignment = sequencedResourceAssignments.get(i - 1);\r
- }\r
- if (resourceAssignment != null) {\r
-\r
- boolean dependencyPresence = false;\r
- if (batchAssignmentName != null && resourceAssignment.getDependencies() != null) {\r
- dependencyPresence =\r
- CollectionUtils.containsAny(batchAssignmentName, resourceAssignment.getDependencies());\r
- }\r
-\r
- logger.trace("({}) -> Checking ({}), with ({}), result ({})", resourceAssignment.getName(),\r
- batchAssignmentName, resourceAssignment.getDependencies(), dependencyPresence);\r
-\r
- if (previousResourceAssignment != null && resourceAssignment.getDictionarySource() != null\r
- && resourceAssignment.getDictionarySource()\r
- .equalsIgnoreCase(previousResourceAssignment.getDictionarySource())\r
- && !dependencyPresence) {\r
- batchResourceAssignment.add(resourceAssignment);\r
- batchAssignmentName.add(resourceAssignment.getName());\r
- } else {\r
- if (batchResourceAssignment != null) {\r
- sequenceBatchResourceAssignment.add(batchResourceAssignment);\r
- logger.trace("Created old Set ({})", batchAssignmentName);\r
- }\r
- batchResourceAssignment = new ArrayList<>();\r
- batchResourceAssignment.add(resourceAssignment);\r
-\r
- batchAssignmentName = new ArrayList<>();\r
- batchAssignmentName.add(resourceAssignment.getName());\r
- }\r
- }\r
-\r
- if (i == (sequencedResourceAssignments.size() - 1)) {\r
- logger.trace("Created old Set ({})", batchAssignmentName);\r
- sequenceBatchResourceAssignment.add(batchResourceAssignment);\r
- }\r
- }\r
- logger.info("Batched Sequence : ({})", sequenceBatchResourceAssignment);\r
- }\r
- return sequenceBatchResourceAssignment;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.assignment.service;\r
-\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.apache.commons.collections.MapUtils;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.assignment.ConfigAssignmentConstants;\r
-import org.onap.ccsdk.features.assignment.data.ResourceAssignmentData;\r
-import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService;\r
-import org.onap.ccsdk.features.generator.service.ConfigGeneratorService;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.service.ComponentNode;\r
-import org.onap.ccsdk.features.model.service.ComponentNodeService;\r
-import org.onap.ccsdk.features.model.service.ConfigModelService;\r
-import org.onap.ccsdk.features.model.utils.TransformationUtils;\r
-import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class ConfigAssignmentNode implements ComponentNode {\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentNode.class);\r
-\r
- private ComponentNodeService componentNodeService;\r
- private ConfigResourceService configResourceService;\r
- private ConfigModelService configModelService;\r
- private ConfigRestAdaptorService configRestAdaptorService;\r
- private ConfigGeneratorService configGeneratorService;\r
-\r
- public ConfigAssignmentNode(ConfigResourceService configResourceService,\r
- ConfigRestAdaptorService configRestAdaptorService, ConfigModelService configModelService,\r
- ComponentNodeService componentNodeService, ConfigGeneratorService configGeneratorService) {\r
- logger.info("{} Constrctor Initiated", "ConfigAssignmentNode");\r
- this.componentNodeService = componentNodeService;\r
- this.configResourceService = configResourceService;\r
- this.configModelService = configModelService;\r
- this.configRestAdaptorService = configRestAdaptorService;\r
- this.configGeneratorService = configGeneratorService;\r
- }\r
-\r
- @Override\r
- public Boolean preCondition(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- return Boolean.TRUE;\r
- }\r
-\r
- @Override\r
- public void preProcess(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- // Auto-generated method stub\r
- }\r
-\r
- /**\r
- * This method is used to resolve the resources defined in the template. Generic Resource API DG\r
- * calls this execute node.\r
- *\r
- * @param inParams This is the input parameter to process this node\r
- * \r
- * <pre>\r
- request-id (string): Tracking Id \r
- resource-type (string): Resource Type ( ex : vnf-type) \r
- resource-id (string): Resource Id \r
- service-template-name (string): Blueprint Name \r
- service-template-version (string): Blueprint Version \r
- action-name (string): \r
- template-names (List of string): Template Names / Artifact Node Names to resolve. ["template1", "template2"] \r
- input-data (string): Input Data in JSON String, for the substitution in the Template. \r
- prifix (string): Return Value selector\r
- * </pre>\r
- * \r
- * @param ctx This is the service logger context, Output will be stored (\r
- * <responsePrefix>.resource-assignment-params.<template-name> : Output Data in JSON String.\r
- * <responsePrefix>.status <responsePrefix>.error-message )\r
- * @throws SvcLogicException On processing error.\r
- */\r
-\r
- @Override\r
- public void process(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {\r
-\r
- final String responsePrefix = StringUtils.isNotBlank(inParams.get(ConfigModelConstant.PROPERTY_SELECTOR))\r
- ? (inParams.get(ConfigModelConstant.PROPERTY_SELECTOR) + ".")\r
- : "";\r
- try {\r
-\r
- ResourceAssignmentData resourceAssignmentData = populateResourceData(inParams);\r
- resourceAssignmentData.setSvcLogicContext(ctx);\r
- Map<String, Object> componentContext = new HashMap<>();\r
- resourceAssignmentData.setContext(componentContext);\r
- resourceAssignmentData.setReloadModel(true);\r
-\r
- ConfigAssignmentProcessService configAssignmentProcessService =\r
- new ConfigAssignmentProcessService(configResourceService, configRestAdaptorService,\r
- configModelService, componentNodeService, configGeneratorService);\r
- configAssignmentProcessService.resolveResources(resourceAssignmentData);\r
-\r
- if (MapUtils.isNotEmpty(resourceAssignmentData.getTemplatesMashedContents())) {\r
- resourceAssignmentData.getTemplatesMashedContents().forEach((templateName, previewContent) -> {\r
- logger.debug("For Template name : ({}),\n Preview Content is : ({})", templateName, previewContent);\r
- ctx.setAttribute(\r
- responsePrefix + ConfigAssignmentConstants.OUTPUT_PARAM_MASHED_DATA + "." + templateName,\r
- previewContent);\r
- });\r
- }\r
- ctx.setAttribute(responsePrefix + ConfigAssignmentConstants.OUTPUT_PARAM_STATUS,\r
- ConfigAssignmentConstants.OUTPUT_STATUS_SUCCESS);\r
- } catch (Exception e) {\r
- ctx.setAttribute(responsePrefix + ConfigAssignmentConstants.OUTPUT_PARAM_STATUS,\r
- ConfigAssignmentConstants.OUTPUT_STATUS_FAILURE);\r
- ctx.setAttribute(responsePrefix + ConfigAssignmentConstants.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());\r
- throw new SvcLogicException(e.getMessage(), e);\r
- }\r
- }\r
-\r
- @Override\r
- public void process(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
-\r
- final String responsePrefix = StringUtils.isNotBlank(inParams.get(ConfigModelConstant.PROPERTY_SELECTOR))\r
- ? (inParams.get(ConfigModelConstant.PROPERTY_SELECTOR) + ".")\r
- : "";\r
- try {\r
-\r
- ResourceAssignmentData resourceAssignmentData = populateResourceData(inParams);\r
- resourceAssignmentData.setSvcLogicContext(ctx);\r
- resourceAssignmentData.setContext(componentContext);\r
- resourceAssignmentData.setReloadModel(false);\r
-\r
- ConfigAssignmentProcessService configAssignmentProcessService =\r
- new ConfigAssignmentProcessService(configResourceService, configRestAdaptorService,\r
- configModelService, componentNodeService, configGeneratorService);\r
- configAssignmentProcessService.resolveResources(resourceAssignmentData);\r
- ctx.setAttribute(responsePrefix + ConfigAssignmentConstants.OUTPUT_PARAM_STATUS,\r
- ConfigAssignmentConstants.OUTPUT_STATUS_SUCCESS);\r
-\r
- } catch (Exception e) {\r
- ctx.setAttribute(responsePrefix + ConfigAssignmentConstants.OUTPUT_PARAM_STATUS,\r
- ConfigAssignmentConstants.OUTPUT_STATUS_FAILURE);\r
- ctx.setAttribute(responsePrefix + ConfigAssignmentConstants.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());\r
- throw new SvcLogicException(e.getMessage(), e);\r
- }\r
- }\r
-\r
- @Override\r
- public void postProcess(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- // Do Nothing\r
- }\r
-\r
- private ResourceAssignmentData populateResourceData(Map<String, String> inParams) throws SvcLogicException {\r
- validateInputParams(inParams);\r
-\r
- String requestId = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_REQUEST_ID);\r
- String resourceId = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_ID);\r
- String resourceType = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_TYPE);\r
- String serviceTemplateName = inParams.get(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_NAME);\r
- String serviceTemplateVersion = inParams.get(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_VERSION);\r
- String actionName = inParams.get(ConfigModelConstant.PROPERTY_ACTION_NAME);\r
- String inputData = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_INPUT_DATA);\r
-\r
- String templateNamesStr = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_TEMPLATE_NAMES);\r
- List<String> templateNames = TransformationUtils.getListfromJson(templateNamesStr, String.class);\r
-\r
- ResourceAssignmentData resourceAssignmentData = new ResourceAssignmentData();\r
- resourceAssignmentData.setRequestId(requestId);\r
- resourceAssignmentData.setResourceId(resourceId);\r
- resourceAssignmentData.setResourceType(resourceType);\r
- resourceAssignmentData.setServiceTemplateName(serviceTemplateName);\r
- resourceAssignmentData.setServiceTemplateVersion(serviceTemplateVersion);\r
- resourceAssignmentData.setActionName(actionName);\r
- resourceAssignmentData.setInputData(inputData);\r
- resourceAssignmentData.setTemplateNames(templateNames);\r
-\r
- return resourceAssignmentData;\r
- }\r
-\r
- private void validateInputParams(Map<String, String> inParams) throws SvcLogicException {\r
- if (inParams == null) {\r
- throw new SvcLogicException("Input parameters missing");\r
- }\r
-\r
- String requestId = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_REQUEST_ID);\r
- if (StringUtils.isBlank(requestId)) {\r
- throw new SvcLogicException("Request id parameters missing");\r
- }\r
- String resourceId = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_ID);\r
- if (StringUtils.isBlank(resourceId)) {\r
- throw new SvcLogicException("Resource id parameter is missing");\r
- }\r
- String resourceType = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_TYPE);\r
- if (StringUtils.isBlank(resourceType)) {\r
- throw new SvcLogicException("Resource type parameter is missing");\r
- }\r
- String recipeName = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_ACTION_NAME);\r
- if (StringUtils.isBlank(recipeName)) {\r
- throw new SvcLogicException("Action name is parameter is missing");\r
- }\r
- String templateNames = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_TEMPLATE_NAMES);\r
- if (StringUtils.isBlank(templateNames)) {\r
- throw new SvcLogicException("Template names parameter missing");\r
- }\r
- String serviceTemplateName = inParams.get(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_NAME);\r
- if (StringUtils.isBlank(serviceTemplateName)) {\r
- throw new SvcLogicException("Service Template name parameter missing");\r
- }\r
- String serviceTemplateVersion = inParams.get(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_VERSION);\r
- if (StringUtils.isBlank(serviceTemplateVersion)) {\r
- throw new SvcLogicException("Service Template version parameter missing");\r
- }\r
-\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.assignment.service;\r
-\r
-import java.util.List;\r
-import org.apache.commons.collections.CollectionUtils;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.data.adaptor.DataAdaptorConstants;\r
-import org.onap.ccsdk.features.data.adaptor.domain.ConfigResource;\r
-import org.onap.ccsdk.features.data.adaptor.domain.ResourceAssignmentData;\r
-import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog;\r
-import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.data.ResourceAssignment;\r
-import org.onap.ccsdk.features.model.utils.ResourceAssignmentUtils;\r
-import org.onap.ccsdk.features.model.utils.TransformationUtils;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class ConfigAssignmentPersistService {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentPersistService.class);\r
-\r
- private ConfigResourceService configResourceService;\r
-\r
- public ConfigAssignmentPersistService(ConfigResourceService configResourceService) {\r
- this.configResourceService = configResourceService;\r
- }\r
-\r
- public void saveResourceMapping(\r
- org.onap.ccsdk.features.assignment.data.ResourceAssignmentData resourceAssignmentData, String templateName,\r
- List<ResourceAssignment> resourceAssignments) throws SvcLogicException {\r
- try {\r
-\r
- if (resourceAssignmentData == null) {\r
- throw new SvcLogicException("Resource assignment data is missing");\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
- if (StringUtils.isBlank(resourceAssignmentData.getResourceId())) {\r
- throw new SvcLogicException("Resource Id is missing");\r
- }\r
-\r
- if (StringUtils.isBlank(resourceAssignmentData.getResourceType())) {\r
- throw new SvcLogicException("Resource type is missing");\r
- }\r
-\r
- if (StringUtils.isBlank(resourceAssignmentData.getActionName())) {\r
- throw new SvcLogicException("Action name is missing");\r
- }\r
-\r
- if (StringUtils.isBlank(templateName)) {\r
- throw new SvcLogicException("template name is missing");\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
- configResourceService.save(new TransactionLog(resourceAssignmentData.getRequestId(),\r
- DataAdaptorConstants.LOG_MESSAGE_TYPE_LOG, builder.toString()));\r
-\r
- // Resource Data should be Regenerated based on the new Updates\r
- String resourceData = ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignments);\r
-\r
- List<ResourceAssignmentData> resourceAssignmentDataList =\r
- ConfigAssignmentUtils.convertResoureAssignmentList(resourceAssignments);\r
-\r
- ConfigResource configResource = new ConfigResource();\r
- configResource.setRequestId(resourceAssignmentData.getRequestId());\r
- configResource.setServiceTemplateName(resourceAssignmentData.getServiceTemplateName());\r
- configResource.setServiceTemplateVersion(resourceAssignmentData.getServiceTemplateVersion());\r
- configResource.setRecipeName(resourceAssignmentData.getActionName());\r
- configResource.setResourceId(resourceAssignmentData.getResourceId());\r
- configResource.setResourceType(resourceAssignmentData.getResourceType());\r
- configResource.setResourceData(resourceData);\r
- configResource.setTemplateName(templateName);\r
- configResource.setStatus(ConfigModelConstant.STATUS_SUCCESS);\r
- configResource.setUpdatedBy(ConfigModelConstant.USER_SYSTEM);\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
- builder = new StringBuilder();\r
- builder.append("Resource Data Template Name :");\r
- builder.append(templateName);\r
- builder.append("\n");\r
- builder.append(resourceData);\r
- configResourceService.save(new TransactionLog(resourceAssignmentData.getRequestId(),\r
- DataAdaptorConstants.LOG_MESSAGE_TYPE_LOG, builder.toString()));\r
-\r
- } catch (Exception e) {\r
- throw new SvcLogicException("ConfigAssignmentPersistService : " + e.getMessage(), e);\r
- }\r
-\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.assignment.service;\r
-\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.apache.commons.collections.CollectionUtils;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.assignment.ConfigAssignmentConstants;\r
-import org.onap.ccsdk.features.assignment.data.ResourceAssignmentData;\r
-import org.onap.ccsdk.features.assignment.processor.ProcessorFactory;\r
-import org.onap.ccsdk.features.assignment.processor.ResourceAssignmentProcessor;\r
-import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService;\r
-import org.onap.ccsdk.features.generator.service.ConfigGeneratorService;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.data.ResourceAssignment;\r
-import org.onap.ccsdk.features.model.data.dict.ResourceDefinition;\r
-import org.onap.ccsdk.features.model.service.ComponentNode;\r
-import org.onap.ccsdk.features.model.service.ComponentNodeService;\r
-import org.onap.ccsdk.features.model.service.ConfigModelService;\r
-import org.onap.ccsdk.features.model.utils.ResourceAssignmentUtils;\r
-import org.onap.ccsdk.features.model.utils.TransformationUtils;\r
-import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class ConfigAssignmentProcessService {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentProcessService.class);\r
-\r
- private ComponentNodeService componentNodeService;\r
- private ConfigResourceService configResourceService;\r
- private ConfigModelService configModelService;\r
- private ConfigRestAdaptorService configRestAdaptorService;\r
- private ConfigGeneratorService configGeneratorService;\r
-\r
- public ConfigAssignmentProcessService(ConfigResourceService configResourceService,\r
- ConfigRestAdaptorService configRestAdaptorService, ConfigModelService configModelService,\r
- ComponentNodeService componentNodeService, ConfigGeneratorService configGeneratorService) {\r
- this.componentNodeService = componentNodeService;\r
- this.configResourceService = configResourceService;\r
- this.configModelService = configModelService;\r
- this.configRestAdaptorService = configRestAdaptorService;\r
- this.configGeneratorService = configGeneratorService;\r
- }\r
-\r
- @SuppressWarnings("squid:S1141")\r
- public void resolveResources(ResourceAssignmentData resourceAssignmentData) throws SvcLogicException {\r
- try {\r
- validateInputParams(resourceAssignmentData);\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
- if (resourceAssignmentData.isReloadModel()) {\r
- Map<String, String> context = new HashMap<>();\r
- context.put(ConfigModelConstant.PROPERTY_ACTION_NAME, actionName);\r
- context = configModelService.prepareContext(context, inputData, serviceTemplateName,\r
- serviceTemplateVersion);\r
- context.forEach((key, value) -> svcLogicContext.setAttribute(key, value));\r
- logger.info("List of Resources provided in input: {}", svcLogicContext.toProperties());\r
- }\r
-\r
- Map<String, Object> componentContext = resourceAssignmentData.getContext();\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
- // Get the Resource Assignment\r
- Map<String, List<ResourceAssignment>> templatesResourceAssignments =\r
- resourceModelService.getTemplatesResourceAssignments(svcLogicContext, templateNames);\r
-\r
- // Get the Template Contents\r
- Map<String, String> templatesContents =\r
- resourceModelService.getTemplatesContents(svcLogicContext, templateNames);\r
-\r
- // Process each template\r
- for (String templateName : templateNames) {\r
- List<ResourceAssignment> resourceAssignments = templatesResourceAssignments.get(templateName);\r
- String templateContent = templatesContents.get(templateName);\r
- if (resourceAssignments != null) {\r
- String templateData = null;\r
- try {\r
- // Populate the Dictionary\r
- ResourceDictionaryService resourceDictionaryService =\r
- new ResourceDictionaryService(configRestAdaptorService);\r
- Map<String, ResourceDefinition> dictionaries =\r
- resourceDictionaryService.getDataDictionaryDefinitions(resourceAssignments);\r
-\r
- processResourceAssignments(resourceAssignmentData, svcLogicContext, componentContext,\r
- templateName, resourceAssignments, dictionaries);\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
- 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
- } 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
- } catch (Exception e) {\r
- throw new SvcLogicException(e.getMessage(), e);\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
- String recipeName = resourceAssignmentData.getActionName();\r
-\r
- ResourceAssignmentProcessor resourceAssignmentProcessor =\r
- new ResourceAssignmentProcessor(resourceAssignments, ctx);\r
- List<List<ResourceAssignment>> sequenceBatchResourceAssignment = resourceAssignmentProcessor.process();\r
-\r
- logger.debug("Resource dictionary Info ({})", dictionaries);\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
- processBatchResourceAssignments(resourceAssignmentData, ctx, componentContext, batchResourceAssignment);\r
-\r
- logger.debug("Batch Resource data status ({})", TransformationUtils.getJson(batchResourceAssignment));\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
- if (CollectionUtils.isNotEmpty(batchResourceAssignment)) {\r
-\r
- ResourceAssignment batchFirstResourceAssignment = batchResourceAssignment.get(0);\r
- if (batchFirstResourceAssignment != null\r
- && StringUtils.isNotBlank(batchFirstResourceAssignment.getDictionarySource())) {\r
- String source = 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
- ProcessorFactory factory =\r
- new ProcessorFactory(configResourceService, configRestAdaptorService, componentNodeService);\r
-\r
- ComponentNode processor = factory.getInstance(source);\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
- inParams.put(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_TYPE,\r
- resourceAssignmentData.getResourceType());\r
- inParams.put(ConfigAssignmentConstants.INPUT_PARAM_ACTION_NAME, resourceAssignmentData.getActionName());\r
- inParams.put(ConfigAssignmentConstants.INPUT_PARAM_TEMPLATE_NAMES,\r
- resourceAssignmentData.getTemplateNames().toString());\r
- processor.process(inParams, ctx, componentContext);\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
- ConfigAssignmentPersistService configAssignmentPersistService =\r
- new ConfigAssignmentPersistService(configResourceService);\r
- configAssignmentPersistService.saveResourceMapping(resourceAssignmentData, templateName,\r
- resourceAssignments);\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
- String requestId = resourceAssignmentData.getRequestId();\r
- if (StringUtils.isBlank(requestId)) {\r
- throw new SvcLogicException("Request id parameters missing");\r
- }\r
- String resourceId = resourceAssignmentData.getResourceId();\r
- if (StringUtils.isBlank(resourceId)) {\r
- throw new SvcLogicException("Resource id parameter is missing");\r
- }\r
- String resourceType = resourceAssignmentData.getResourceType();\r
- if (StringUtils.isBlank(resourceType)) {\r
- throw new SvcLogicException("Resource type parameter is missing");\r
- }\r
- String actionName = resourceAssignmentData.getActionName();\r
- if (StringUtils.isBlank(actionName)) {\r
- throw new SvcLogicException("Action name is parameter is missing");\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
+++ /dev/null
-/*\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.features.assignment.service;\r
-\r
-import java.util.List;\r
-import org.onap.ccsdk.features.assignment.data.ResourceAssignmentData;\r
-import org.onap.ccsdk.features.model.data.ResourceAssignment;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-\r
-public interface ConfigAssignmentService {\r
-\r
- public void resolveResources(ResourceAssignmentData resourceAssignmentData) throws SvcLogicException;\r
-\r
- public void saveResourceMapping(ResourceAssignmentData resourceAssignmentData, String templateName,\r
- List<ResourceAssignment> resourceAssignments) throws SvcLogicException;\r
-\r
- public ResourceAssignmentData generateTemplateResourceMash(ResourceAssignmentData resourceAssignmentData)\r
- throws SvcLogicException;\r
-\r
-}\r
+++ /dev/null
-/*\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.features.assignment.service;\r
-\r
-import java.util.List;\r
-import org.onap.ccsdk.features.assignment.data.ResourceAssignmentData;\r
-import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService;\r
-import org.onap.ccsdk.features.generator.service.ConfigGeneratorService;\r
-import org.onap.ccsdk.features.model.data.ResourceAssignment;\r
-import org.onap.ccsdk.features.model.service.ComponentNodeService;\r
-import org.onap.ccsdk.features.model.service.ConfigModelService;\r
-import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class ConfigAssignmentServiceImpl implements ConfigAssignmentService {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentServiceImpl.class);\r
-\r
- private ComponentNodeService componentNodeService;\r
- private ConfigResourceService configResourceService;\r
- private ConfigModelService configModelService;\r
- private ConfigRestAdaptorService configRestAdaptorService;\r
- private ConfigGeneratorService configGeneratorService;\r
-\r
- private static final String CLASS_NAME = "ConfigAssignmentServiceImpl";\r
-\r
- public ConfigAssignmentServiceImpl(ConfigResourceService configResourceService,\r
- ConfigRestAdaptorService configRestAdaptorService, ConfigModelService configModelService,\r
- ComponentNodeService componentNodeService, ConfigGeneratorService configGeneratorService) {\r
- logger.info("{} Constuctor Initated...", CLASS_NAME);\r
- this.componentNodeService = componentNodeService;\r
- this.configResourceService = configResourceService;\r
- this.configModelService = configModelService;\r
- this.configRestAdaptorService = configRestAdaptorService;\r
- this.configGeneratorService = configGeneratorService;\r
- }\r
-\r
- @Override\r
- public void resolveResources(ResourceAssignmentData resourceAssignmentData) throws SvcLogicException {\r
- ConfigAssignmentProcessService configAssignmentProcessService =\r
- new ConfigAssignmentProcessService(configResourceService, configRestAdaptorService, configModelService,\r
- componentNodeService, configGeneratorService);\r
- configAssignmentProcessService.resolveResources(resourceAssignmentData);\r
- }\r
-\r
- @Override\r
- public void saveResourceMapping(ResourceAssignmentData resourceAssignmentData, String templateName,\r
- List<ResourceAssignment> resourceAssignments) throws SvcLogicException {\r
- ConfigAssignmentPersistService configAssignmentPersistService =\r
- new ConfigAssignmentPersistService(configResourceService);\r
- configAssignmentPersistService.saveResourceMapping(resourceAssignmentData, templateName, resourceAssignments);\r
- }\r
-\r
- @Override\r
- public ResourceAssignmentData generateTemplateResourceMash(ResourceAssignmentData resourceAssignmentData)\r
- throws SvcLogicException {\r
- ConfigPreviewService configPreviewService =\r
- new ConfigPreviewService(configResourceService, configModelService, configGeneratorService);\r
- return configPreviewService.generateTemplateResourceMash(resourceAssignmentData);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.assignment.service;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.apache.commons.collections.CollectionUtils;\r
-import org.apache.commons.collections.IteratorUtils;\r
-import org.apache.commons.collections.MapUtils;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.data.adaptor.domain.ResourceAssignmentData;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.ConfigModelException;\r
-import org.onap.ccsdk.features.model.ValidTypes;\r
-import org.onap.ccsdk.features.model.data.DataType;\r
-import org.onap.ccsdk.features.model.data.EntrySchema;\r
-import org.onap.ccsdk.features.model.data.PropertyDefinition;\r
-import org.onap.ccsdk.features.model.data.ResourceAssignment;\r
-import org.onap.ccsdk.features.model.data.dict.ResourceDefinition;\r
-import org.onap.ccsdk.features.model.domain.ResourceDictionary;\r
-import org.onap.ccsdk.features.model.utils.JsonUtils;\r
-import org.onap.ccsdk.features.model.utils.ResourceAssignmentUtils;\r
-import org.onap.ccsdk.features.model.utils.TransformationUtils;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-import com.fasterxml.jackson.databind.JsonNode;\r
-import com.fasterxml.jackson.databind.node.ArrayNode;\r
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;\r
-import com.fasterxml.jackson.databind.node.ObjectNode;\r
-\r
-public class ConfigAssignmentUtils {\r
-\r
- private ConfigAssignmentUtils() {\r
-\r
- }\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentUtils.class);\r
-\r
- public static synchronized Object getContextKeyValue(SvcLogicContext context, String key) {\r
- Object value = null;\r
- if (context != null && key != null && context.getAttributeKeySet().contains(key)) {\r
- String strValue = context.getAttribute(key);\r
- if (StringUtils.isNotBlank(strValue)) {\r
- value = strValue;\r
- }\r
- }\r
- return value;\r
- }\r
-\r
- /*\r
- * Populate the Field property type for the Data type\r
- */\r
- public static synchronized String getPropertyType(SvcLogicContext ctx, String dataTypeName, String propertyName)\r
- throws SvcLogicException {\r
- String type = ValidTypes.DATA_TYPE_STRING;\r
- try {\r
- if (ctx != null && StringUtils.isNotBlank(dataTypeName) && StringUtils.isNotBlank(propertyName)) {\r
- String dataTypeContent = ctx.getAttribute(ConfigModelConstant.PROPERTY_DATA_TYPES_DOT + dataTypeName);\r
- if (StringUtils.isNotBlank(dataTypeContent)) {\r
- DataType dataType = TransformationUtils.readValue(dataTypeContent, DataType.class);\r
- if (dataType != null && dataType.getProperties() != null\r
- && dataType.getProperties().containsKey(propertyName)) {\r
- PropertyDefinition propertyDefinition = dataType.getProperties().get(propertyName);\r
- if (StringUtils.isNotBlank(propertyDefinition.getType())) {\r
- type = propertyDefinition.getType();\r
- logger.trace("Data type({})'s property ({}) is ({})", dataTypeName, propertyName, type);\r
- } else {\r
- throw new SvcLogicException(String.format("Couldn't get data type (%s) ", dataTypeName));\r
- }\r
- }\r
- } else {\r
- throw new SvcLogicException(String.format("Couldn't get data type (%s) content", dataTypeName));\r
- }\r
- }\r
- } catch (Exception e) {\r
- logger.error("couldn't get data type({})'s property ({}), type ({}), error message ({}).", dataTypeName,\r
- propertyName, type, e.getMessage());\r
- throw new SvcLogicException(e.getMessage());\r
- }\r
- return type;\r
- }\r
-\r
- /*\r
- * Populate the Field property type for the Data type\r
- */\r
- public static synchronized PropertyDefinition getPropertyDefinition(SvcLogicContext ctx, String dataTypeName,\r
- String propertyName) throws SvcLogicException {\r
- PropertyDefinition propertyDefinition = null;\r
- try {\r
- if (ctx != null && StringUtils.isNotBlank(dataTypeName) && StringUtils.isNotBlank(propertyName)) {\r
- String dataTypeContent = ctx.getAttribute(ConfigModelConstant.PROPERTY_DATA_TYPES_DOT + dataTypeName);\r
- if (StringUtils.isNotBlank(dataTypeContent)) {\r
- DataType dataType = TransformationUtils.readValue(dataTypeContent, DataType.class);\r
- if (dataType != null && dataType.getProperties() != null\r
- && dataType.getProperties().containsKey(propertyName)) {\r
- propertyDefinition = dataType.getProperties().get(propertyName);\r
- if (propertyDefinition == null) {\r
- throw new SvcLogicException(String.format("couldn't get data type (%s) ", dataTypeName));\r
- }\r
- }\r
- } else {\r
- throw new SvcLogicException(String.format("couldn't get data type (%s) content.", dataTypeName));\r
- }\r
- }\r
- } catch (Exception e) {\r
- throw new SvcLogicException(e.getMessage());\r
- }\r
- return propertyDefinition;\r
- }\r
-\r
- public static synchronized ResourceDefinition getDictionaryDefinition(Map<String, ResourceDictionary> dictionaries,\r
- String dictionaryName) {\r
- ResourceDefinition resourceDefinition = null;\r
- if (dictionaries != null && StringUtils.isNotBlank(dictionaryName)) {\r
- ResourceDictionary resourceDictionary = dictionaries.get(dictionaryName);\r
- if (resourceDictionary != null && resourceDictionary.getDefinition() != null) {\r
- resourceDefinition =\r
- TransformationUtils.treeToValue(resourceDictionary.getDefinition(), ResourceDefinition.class);\r
- }\r
- }\r
- return resourceDefinition;\r
- }\r
-\r
- @SuppressWarnings("squid:S3776")\r
- public static synchronized void populateValueForOutputMapping(SvcLogicContext ctx,\r
- Map<String, Object> componentContext, ResourceAssignment resourceAssignment,\r
- Map<String, String> outputKeyMapping, JsonNode responseNode)\r
- throws ConfigModelException, SvcLogicException {\r
- if (resourceAssignment == null) {\r
- throw new SvcLogicException("resourceAssignment is null.");\r
- }\r
-\r
- if (ctx == null) {\r
- throw new SvcLogicException("service logic context is null.");\r
- }\r
-\r
- if (componentContext == null) {\r
- throw new SvcLogicException("component context is null.");\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
- String entrySchema = null;\r
- if (ValidTypes.getPrimitivePropertType().contains(type)) {\r
- ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, responseNode);\r
- } else if (ValidTypes.getListPropertType().contains(type)) {\r
- // Array Types\r
- if (resourceAssignment.getProperty().getEntrySchema() != null) {\r
- entrySchema = resourceAssignment.getProperty().getEntrySchema().getType();\r
- }\r
-\r
- if (StringUtils.isNotBlank(entrySchema)) {\r
- ArrayNode arrayNode = JsonNodeFactory.instance.arrayNode();\r
- if (ValidTypes.getPrimitivePropertType().contains(entrySchema)) {\r
- arrayNode = (ArrayNode) responseNode;\r
- } else if (MapUtils.isNotEmpty(outputKeyMapping)) {\r
- List<JsonNode> responseArrayNode = IteratorUtils.toList(responseNode.elements());\r
- for (JsonNode responseSingleJsonNode : responseArrayNode) {\r
- if (responseSingleJsonNode != null) {\r
- ObjectNode arrayChildNode = JsonNodeFactory.instance.objectNode();\r
- for (Map.Entry<String, String> mapping : outputKeyMapping.entrySet()) {\r
- JsonNode responseKeyValue = responseSingleJsonNode.get(mapping.getKey());\r
-\r
- String propertyTypeForDataType =\r
- ConfigAssignmentUtils.getPropertyType(ctx, entrySchema, mapping.getKey());\r
- logger.info("For List Type Resource: key ({}), value ({}), type ({})",\r
- mapping.getKey(), responseKeyValue, propertyTypeForDataType);\r
- JsonUtils.populateJsonNodeValues(mapping.getValue(), responseKeyValue,\r
- propertyTypeForDataType, arrayChildNode);\r
- }\r
- arrayNode.add(arrayChildNode);\r
- }\r
- }\r
- } else {\r
- arrayNode = (ArrayNode) responseNode;\r
- }\r
- // Set the List of Complex Values\r
- ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, arrayNode);\r
- } else {\r
- throw new SvcLogicException(\r
- String.format("Entry schema is not defined for dictionary (%s) info", dictionaryName));\r
- }\r
- } else {\r
- // Complex Types\r
- ObjectNode objectNode = null;\r
- if (MapUtils.isNotEmpty(outputKeyMapping)) {\r
- objectNode = JsonNodeFactory.instance.objectNode();\r
- for (Map.Entry<String, String> mapping : outputKeyMapping.entrySet()) {\r
- JsonNode responseKeyValue = responseNode.get(mapping.getKey());\r
- String propertyTypeForDataType =\r
- ConfigAssignmentUtils.getPropertyType(ctx, entrySchema, mapping.getKey());\r
- logger.info("For Complex Type Resource: key ({}), value ({}), type ({})", mapping.getKey(),\r
- responseKeyValue, propertyTypeForDataType);\r
- JsonUtils.populateJsonNodeValues(mapping.getValue(), responseKeyValue, propertyTypeForDataType,\r
- objectNode);\r
- }\r
- } else {\r
- objectNode = (ObjectNode) responseNode;\r
- }\r
- ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, objectNode);\r
- }\r
- }\r
-\r
- @SuppressWarnings("squid:S3776")\r
- public static synchronized List<ResourceAssignment> convertResoureAssignmentDataList(\r
- List<ResourceAssignmentData> resourceAssignmentDataList) {\r
- List<ResourceAssignment> assignments = new ArrayList<>();\r
- if (CollectionUtils.isNotEmpty(resourceAssignmentDataList)) {\r
- for (ResourceAssignmentData resourceAssignmentData : resourceAssignmentDataList) {\r
- if (resourceAssignmentData != null) {\r
- ResourceAssignment resourceAssignment = new ResourceAssignment();\r
- resourceAssignment.setName(resourceAssignmentData.getTemplateKeyName());\r
- resourceAssignment.setVersion(resourceAssignmentData.getVersion());\r
- resourceAssignment.setUpdatedBy(resourceAssignmentData.getUpdatedBy());\r
- resourceAssignment.setUpdatedDate(resourceAssignmentData.getUpdatedDate());\r
- resourceAssignment.setDictionaryName(resourceAssignmentData.getResourceName());\r
- resourceAssignment.setDictionarySource(resourceAssignmentData.getSource());\r
- resourceAssignment.setStatus(resourceAssignmentData.getStatus());\r
- resourceAssignment.setMessage(resourceAssignmentData.getMessage());\r
- PropertyDefinition property = new PropertyDefinition();\r
- property.setType(resourceAssignmentData.getDataType());\r
-\r
- if (StringUtils.isNotBlank(resourceAssignmentData.getResourceValue())) {\r
- if (ValidTypes.getPrimitivePropertType().contains(resourceAssignmentData.getDataType())) {\r
- property.setValue(resourceAssignmentData.getResourceValue());\r
- } else {\r
- JsonNode valueNode =\r
- TransformationUtils.getJsonNodeForString(resourceAssignmentData.getResourceValue());\r
- property.setValue(valueNode);\r
- }\r
- }\r
- if (StringUtils.isNotBlank(resourceAssignmentData.getEntrySchema())) {\r
- EntrySchema entrySchema = new EntrySchema();\r
- entrySchema.setType(resourceAssignmentData.getEntrySchema());\r
- property.setEntrySchema(entrySchema);\r
- } else {\r
- property.setEntrySchema(null);\r
- }\r
- resourceAssignment.setProperty(property);\r
- assignments.add(resourceAssignment);\r
- }\r
- }\r
-\r
- }\r
- return assignments;\r
- }\r
-\r
- @SuppressWarnings("squid:S3776")\r
- public static synchronized List<ResourceAssignmentData> convertResoureAssignmentList(\r
- List<ResourceAssignment> assignments) {\r
- List<ResourceAssignmentData> resourceAssignmentDataList = new ArrayList<>();\r
- if (CollectionUtils.isNotEmpty(assignments)) {\r
- for (ResourceAssignment assignment : assignments) {\r
- if (assignment != null) {\r
- ResourceAssignmentData resourceAssignmentData = new ResourceAssignmentData();\r
- resourceAssignmentData.setTemplateKeyName(assignment.getName());\r
- resourceAssignmentData.setVersion(assignment.getVersion());\r
- resourceAssignmentData.setUpdatedBy(assignment.getUpdatedBy());\r
- resourceAssignmentData.setUpdatedDate(assignment.getUpdatedDate());\r
- if (assignment.getProperty() != null) {\r
- resourceAssignmentData.setDataType(assignment.getProperty().getType());\r
- if (assignment.getProperty().getEntrySchema() != null) {\r
- resourceAssignmentData.setEntrySchema(assignment.getProperty().getEntrySchema().getType());\r
- }\r
- if (assignment.getProperty().getValue() != null) {\r
- String valueContent = TransformationUtils.getJson(assignment.getProperty().getValue());\r
- resourceAssignmentData.setResourceValue(valueContent);\r
- }\r
- }\r
- resourceAssignmentData.setResourceName(assignment.getDictionaryName());\r
- resourceAssignmentData.setSource(assignment.getDictionarySource());\r
- resourceAssignmentData.setStatus(assignment.getStatus());\r
- resourceAssignmentData.setMessage(assignment.getMessage());\r
- resourceAssignmentDataList.add(resourceAssignmentData);\r
- }\r
- }\r
- }\r
- return resourceAssignmentDataList;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.assignment.service;\r
-\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.apache.commons.collections.CollectionUtils;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.assignment.data.ResourceAssignmentData;\r
-import org.onap.ccsdk.features.data.adaptor.domain.ConfigResource;\r
-import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService;\r
-import org.onap.ccsdk.features.generator.data.ConfigGeneratorInfo;\r
-import org.onap.ccsdk.features.generator.service.ConfigGeneratorService;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.service.ConfigModelService;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class ConfigPreviewService {\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentPersistService.class);\r
- private ConfigResourceService configResourceService;\r
- private ConfigModelService configModelService;\r
- private ConfigGeneratorService configGeneratorService;\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
- public String generatePreview(String templateContent, String templateData) throws SvcLogicException {\r
- String mashedData = "";\r
- ConfigGeneratorInfo configGeneratorInfo =\r
- configGeneratorService.generateConfiguration(templateContent, templateData);\r
- if (configGeneratorInfo != null) {\r
- mashedData = configGeneratorInfo.getMashedData();\r
- }\r
- return mashedData;\r
- }\r
-\r
- public ResourceAssignmentData generateTemplateResourceMash(ResourceAssignmentData resourceAssignmentData)\r
- throws SvcLogicException {\r
- if (resourceAssignmentData == null) {\r
- throw new SvcLogicException("Resource assignment data is missing");\r
- }\r
- if (StringUtils.isBlank(resourceAssignmentData.getServiceTemplateName())) {\r
- throw new SvcLogicException("Service template name is missing");\r
- }\r
- if (StringUtils.isBlank(resourceAssignmentData.getServiceTemplateVersion())) {\r
- throw new SvcLogicException("Service template version is missing");\r
- }\r
- if (StringUtils.isBlank(resourceAssignmentData.getResourceType())) {\r
- throw new SvcLogicException("Resource type is missing");\r
- }\r
- if (StringUtils.isBlank(resourceAssignmentData.getResourceId())) {\r
- throw new SvcLogicException("Resource Id is missing");\r
- }\r
- if (StringUtils.isBlank(resourceAssignmentData.getActionName())) {\r
- throw new SvcLogicException("Action name is missing");\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
- Map<String, String> context = new HashMap<>();\r
- context.put(ConfigModelConstant.PROPERTY_ACTION_NAME, actionName);\r
- context = configModelService.prepareContext(context, inputData, serviceTemplateName, serviceTemplateVersion);\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
- List<ConfigResource> configResources = configResourceService.getConfigResource(configResourceQuery);\r
- if (CollectionUtils.isNotEmpty(configResources)) {\r
- for (ConfigResource cr : configResources) {\r
- String templateContent = context\r
- .get(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + cr.getTemplateName() + ".content");\r
- String templateData = cr.getResourceData();\r
- String previewContent = generatePreview(templateContent, templateData);\r
- resourceAssignmentData.getTemplatesMashedContents().put(cr.getTemplateName(), previewContent);\r
- logger.info("Preview generated for template name ({}) ", cr.getTemplateName());\r
- logger.trace("Preview generated for preview ({}) ", previewContent);\r
- }\r
- } else {\r
- logger.info(\r
- "Couldn't get config resource for service template name ({}) service template version ({})"\r
- + " action ({}) resource id ({}) resource type ({})",\r
- serviceTemplateName, serviceTemplateVersion, actionName, resourceId, resourceType);\r
- }\r
- return resourceAssignmentData;\r
-\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.assignment.service;\r
-\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.model.data.ResourceAssignment;\r
-import org.onap.ccsdk.features.model.data.dict.ResourceDefinition;\r
-import org.onap.ccsdk.features.model.domain.ResourceDictionary;\r
-import org.onap.ccsdk.features.model.utils.TransformationUtils;\r
-import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorConstants;\r
-import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorException;\r
-import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class ResourceDictionaryService {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceDictionaryService.class);\r
- private ConfigRestAdaptorService configRestAdaptorService;\r
-\r
- public ResourceDictionaryService(ConfigRestAdaptorService configRestAdaptorService) {\r
- this.configRestAdaptorService = configRestAdaptorService;\r
- }\r
-\r
- @SuppressWarnings("squid:S3776")\r
- public Map<String, ResourceDefinition> getDataDictionaryDefinitions(List<ResourceAssignment> resourceAssignments)\r
- throws SvcLogicException {\r
- try {\r
- Map<String, ResourceDefinition> dictionaries = new HashMap<>();\r
- if (resourceAssignments != null) {\r
- List<String> names = new ArrayList<>();\r
- for (ResourceAssignment resourceAssignment : resourceAssignments) {\r
- if (resourceAssignment != null && StringUtils.isNotBlank(resourceAssignment.getDictionaryName())) {\r
- if (!names.contains(resourceAssignment.getDictionaryName())) {\r
- names.add(resourceAssignment.getDictionaryName());\r
- }\r
- if (resourceAssignment.getDependencies() != null\r
- && !resourceAssignment.getDependencies().isEmpty()) {\r
- List<String> dependencieNames = resourceAssignment.getDependencies();\r
- for (String dependencieName : dependencieNames) {\r
- if (StringUtils.isNotBlank(dependencieName) && !names.contains(dependencieName)) {\r
- names.add(dependencieName);\r
- }\r
- }\r
- }\r
- }\r
- }\r
- queryResourceDictionaryDefinitions(dictionaries, names);\r
- }\r
- return dictionaries;\r
- } catch (Exception e) {\r
- throw new SvcLogicException("Failed in getting resource data dictionary : " + e.getMessage());\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
- String dictionaryContents = configRestAdaptorService.postResource(\r
- ConfigRestAdaptorConstants.SELECTOR_MODEL_SERVICE, "dictionary/by-names", names, String.class);\r
-\r
- if (StringUtils.isNotBlank(dictionaryContents)) {\r
- List<ResourceDictionary> dataDictionaries =\r
- TransformationUtils.getListfromJson(dictionaryContents, ResourceDictionary.class);\r
- if (dataDictionaries != null) {\r
- for (ResourceDictionary dataDictionary : dataDictionaries) {\r
- if (dataDictionary != null && StringUtils.isNotBlank(dataDictionary.getName())\r
- && dataDictionary.getDefinition() != null) {\r
- ResourceDefinition resourceDefinition = TransformationUtils\r
- .treeToValue(dataDictionary.getDefinition(), ResourceDefinition.class);\r
- if (resourceDefinition != null && StringUtils.isNotBlank(resourceDefinition.getName())) {\r
- dictionaries.put(resourceDefinition.getName(), resourceDefinition);\r
- } else {\r
- throw new SvcLogicException(\r
- "Failed in getting resource data dictionary definition for : "\r
- + dataDictionary.getName());\r
- }\r
- }\r
- }\r
- }\r
- } else {\r
- logger.warn("No resource dictionary definition found for the names ({})", names);\r
- }\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*\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.features.assignment.service;\r
-\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.apache.commons.collections.CollectionUtils;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.model.data.ResourceAssignment;\r
-import org.onap.ccsdk.features.model.service.ConfigModelService;\r
-import org.onap.ccsdk.features.model.utils.TransformationUtils;\r
-import org.onap.ccsdk.features.model.validator.ResourceAssignmentValidator;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class ResourceModelService {\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceModelService.class);\r
-\r
- private ConfigModelService configModelService;\r
-\r
- public ResourceModelService(ConfigModelService configModelService) {\r
- this.configModelService = configModelService;\r
- }\r
-\r
- public Map<String, String> getTemplatesContents(SvcLogicContext ctx, List<String> templateNames)\r
- throws SvcLogicException {\r
- Map<String, String> templatesContents = new HashMap<>();\r
- try {\r
- if (CollectionUtils.isNotEmpty(templateNames)) {\r
- for (String templateName : templateNames) {\r
- String templateContent = this.configModelService.getNodeTemplateContent(ctx, templateName);\r
- logger.trace("Processing template ({}) with content : {}", templateName, templateContent);\r
- templatesContents.put(templateName, templateContent);\r
- }\r
- }\r
- } catch (Exception e) {\r
- throw new SvcLogicException(e.getMessage());\r
- }\r
- return templatesContents;\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
- try {\r
- if (CollectionUtils.isNotEmpty(templateNames)) {\r
- for (String templateName : templateNames) {\r
- String resourceMappingContent = this.configModelService.getNodeTemplateMapping(ctx, templateName);\r
- logger.info("Processing template ({}) with resource assignment content : {}", templateName,\r
- resourceMappingContent);\r
-\r
- if (StringUtils.isNotBlank(resourceMappingContent)) {\r
-\r
- List<ResourceAssignment> resourceAssignments =\r
- TransformationUtils.getListfromJson(resourceMappingContent, ResourceAssignment.class);\r
-\r
- if (resourceAssignments != null) {\r
- ResourceAssignmentValidator resourceAssignmentValidator =\r
- new ResourceAssignmentValidator(resourceAssignments);\r
- resourceAssignmentValidator.validateResourceAssignment();\r
- logger.info("Resource assignment validated successfully for the template ({})",\r
- templateName);\r
- templatesResourceAssignments.put(templateName, resourceAssignments);\r
- } else {\r
- throw new SvcLogicException(String.format(\r
- "Failed to convert assignment content (%s) to object", resourceMappingContent));\r
- }\r
- } else {\r
- // Do nothing, because som e templates may not have mappings\r
- }\r
- }\r
- }\r
- } catch (Exception e) {\r
- throw new SvcLogicException(e.getMessage());\r
- }\r
-\r
- return templatesResourceAssignments;\r
- }\r
-}\r
+++ /dev/null
-<?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
- 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
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"\r
- xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"\r
- odl:use-default-for-reference-types="true">\r
-\r
- <reference id="componentNodeService"\r
- interface="org.onap.ccsdk.features.model.service.ComponentNodeService" />\r
-\r
- <reference id="configResourceService"\r
- interface="org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService" />\r
-\r
- <reference id="configModelService"\r
- interface="org.onap.ccsdk.features.model.service.ConfigModelService" />\r
-\r
- <reference id="configRestAdaptorService"\r
- interface="org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService" />\r
-\r
- <reference id="configGeneratorService"\r
- interface="org.onap.ccsdk.features.generator.service.ConfigGeneratorService" />\r
-\r
- <!-- Expose the Common Component Bean -->\r
- <bean id="configAssignmentNode"\r
- class="org.onap.ccsdk.features.assignment.service.ConfigAssignmentNode">\r
- <argument ref="configResourceService" />\r
- <argument ref="configRestAdaptorService" />\r
- <argument ref="configModelService" />\r
- <argument ref="componentNodeService" />\r
- <argument ref="configGeneratorService" />\r
- </bean>\r
-\r
- <service ref="configAssignmentNode"\r
- interface="org.onap.ccsdk.features.assignment.service.ConfigAssignmentNode" />\r
-\r
- <bean id="configAssignmentService"\r
- class="org.onap.ccsdk.features.assignment.service.ConfigAssignmentServiceImpl">\r
- <argument ref="configResourceService" />\r
- <argument ref="configRestAdaptorService" />\r
- <argument ref="configModelService" />\r
- <argument ref="componentNodeService" />\r
- <argument ref="configGeneratorService" />\r
- </bean>\r
-\r
- <service ref="configAssignmentService"\r
- interface="org.onap.ccsdk.features.assignment.service.ConfigAssignmentService" />\r
-\r
-</blueprint>\r
+++ /dev/null
-<?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
- 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
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"\r
- xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"\r
- odl:use-default-for-reference-types="true">\r
-\r
- <reference id="componentNodeService"\r
- interface="org.onap.ccsdk.features.model.service.ComponentNodeService" />\r
-\r
- <reference id="configResourceService"\r
- interface="org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService" />\r
-\r
- <reference id="configModelService"\r
- interface="org.onap.ccsdk.features.model.service.ConfigModelService" />\r
-\r
- <reference id="configRestAdaptorService"\r
- interface="org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService" />\r
-\r
- <reference id="configGeneratorService"\r
- interface="org.onap.ccsdk.features.generator.service.ConfigGeneratorService" />\r
-\r
- <!-- Expose the Common Component Bean -->\r
- <bean id="configAssignmentNode"\r
- class="org.onap.ccsdk.features.assignment.service.ConfigAssignmentNode">\r
- <argument ref="configResourceService" />\r
- <argument ref="configRestAdaptorService" />\r
- <argument ref="configModelService" />\r
- <argument ref="componentNodeService" />\r
- <argument ref="configGeneratorService" />\r
- </bean>\r
-\r
- <service ref="configAssignmentNode"\r
- interface="org.onap.ccsdk.features.assignment.service.ConfigAssignmentNode" />\r
-\r
- <bean id="configAssignmentService"\r
- class="org.onap.ccsdk.features.assignment.service.ConfigAssignmentServiceImpl">\r
- <argument ref="configResourceService" />\r
- <argument ref="configRestAdaptorService" />\r
- <argument ref="configModelService" />\r
- <argument ref="componentNodeService" />\r
- <argument ref="configGeneratorService" />\r
- </bean>\r
-\r
- <service ref="configAssignmentService"\r
- interface="org.onap.ccsdk.features.assignment.service.ConfigAssignmentService" />\r
-\r
-</blueprint>\r
+++ /dev/null
-/*\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.features.assignment.processor;\r
-\r
-import static org.mockito.Matchers.any;\r
-import java.io.File;\r
-import java.nio.charset.Charset;\r
-import java.util.ArrayList;\r
-import java.util.Arrays;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.apache.commons.io.FileUtils;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Matchers;\r
-import org.mockito.Mock;\r
-import org.mockito.Mockito;\r
-import org.mockito.MockitoAnnotations;\r
-import org.mockito.invocation.InvocationOnMock;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.mockito.stubbing.Answer;\r
-import org.onap.ccsdk.features.assignment.service.ConfigResourceAssignmentTestUtils;\r
-import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog;\r
-import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.data.ResourceAssignment;\r
-import org.onap.ccsdk.features.model.data.dict.ResourceDefinition;\r
-import org.onap.ccsdk.features.model.utils.TransformationUtils;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class DBResourceProcessorTest {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(DBResourceProcessorTest.class);\r
-\r
- @Mock\r
- private ConfigResourceService configResourceService;\r
-\r
- @SuppressWarnings("unchecked")\r
- @Before\r
- public void before() {\r
- MockitoAnnotations.initMocks(this);\r
-\r
- try {\r
- Mockito.doAnswer(new Answer<Void>() {\r
- @Override\r
- public Void answer(InvocationOnMock invocationOnMock) throws Throwable {\r
- Object[] args = invocationOnMock.getArguments();\r
- if (args != null) {\r
- logger.trace("Transaction info " + Arrays.asList(args));\r
- }\r
- return null;\r
- }\r
- }).when(configResourceService).save(any(TransactionLog.class));\r
-\r
- } catch (SvcLogicException e) {\r
- e.printStackTrace();\r
- }\r
- }\r
-\r
- @Test\r
- public void testDbSimpleProcess() throws Exception {\r
- logger.info(" ******************************* testDbSimpleProcess ***************************");\r
-\r
- Mockito.doAnswer(new Answer<List<Map<String, Object>>>() {\r
- @Override\r
- public List<Map<String, Object>> answer(InvocationOnMock invocationOnMock) throws Throwable {\r
- Object[] args = invocationOnMock.getArguments();\r
- List<Map<String, Object>> results = new ArrayList<>();\r
- if (args != null) {\r
- logger.info("Query " + Arrays.asList(args));\r
- Map<String, Object> record = new HashMap<>();\r
- record.put("country", "US");\r
- results.add(record);\r
- }\r
- return results;\r
- }\r
- }).when(configResourceService).query(Matchers.anyString(), Matchers.<Map<String, Object>>any());\r
-\r
- String recipeName = "sample-recipe";\r
-\r
- String resourceassignmentContent = FileUtils.readFileToString(\r
- new File("src/test/resources/mapping/db/resource-assignments-simple.json"), Charset.defaultCharset());\r
- List<ResourceAssignment> batchResourceAssignment =\r
- TransformationUtils.getListfromJson(resourceassignmentContent, ResourceAssignment.class);\r
-\r
- String dictionaryContent = FileUtils.readFileToString(new File("src/test/resources/mapping/db/db-simple.json"),\r
- Charset.defaultCharset());\r
- Map<String, ResourceDefinition> dictionaries =\r
- ConfigResourceAssignmentTestUtils.getMapfromJson(dictionaryContent);\r
- DBResourceProcessor dbResourceProcessor = new DBResourceProcessor(configResourceService);\r
- Map<String, Object> componentContext = new HashMap<>();\r
- componentContext.put(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS, batchResourceAssignment);\r
- componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName);\r
- componentContext.put(ConfigModelConstant.PROPERTY_TEMPLATE_NAME, "sample-template");\r
- componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARIES, dictionaries);\r
-\r
- componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".profile_name", "sample");\r
-\r
- Map<String, String> inParams = new HashMap<>();\r
- SvcLogicContext ctx = new SvcLogicContext();\r
- dbResourceProcessor.process(inParams, ctx, componentContext);\r
-\r
- logger.info(" Context " + componentContext);\r
-\r
- }\r
-\r
- @Test\r
- public void testDbComplexProcess() throws Exception {\r
- logger.info(" ******************************* testDbComplexProcess ***************************");\r
-\r
- Mockito.doAnswer(new Answer<List<Map<String, Object>>>() {\r
- @Override\r
- public List<Map<String, Object>> answer(InvocationOnMock invocationOnMock) throws Throwable {\r
- Object[] args = invocationOnMock.getArguments();\r
- List<Map<String, Object>> results = new ArrayList<>();\r
- if (args != null) {\r
- logger.info("Query " + Arrays.asList(args));\r
- Map<String, Object> record = new HashMap<>();\r
- record.put("db-country", "US");\r
- record.put("db-state", "NJ");\r
- results.add(record);\r
- }\r
- return results;\r
- }\r
- }).when(configResourceService).query(Matchers.anyString(), Matchers.<Map<String, Object>>any());\r
-\r
- String recipeName = "sample-recipe";\r
-\r
- String resourceassignmentContent = FileUtils.readFileToString(\r
- new File("src/test/resources/mapping/db/resource-assignments-complex.json"), Charset.defaultCharset());\r
- List<ResourceAssignment> batchResourceAssignment =\r
- TransformationUtils.getListfromJson(resourceassignmentContent, ResourceAssignment.class);\r
-\r
- String dictionaryContent = FileUtils.readFileToString(new File("src/test/resources/mapping/db/db-complex.json"),\r
- Charset.defaultCharset());\r
- Map<String, ResourceDefinition> dictionaries =\r
- ConfigResourceAssignmentTestUtils.getMapfromJson(dictionaryContent);\r
- DBResourceProcessor dbResourceProcessor = new DBResourceProcessor(configResourceService);\r
- Map<String, Object> componentContext = new HashMap<>();\r
- componentContext.put(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS, batchResourceAssignment);\r
- componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName);\r
- componentContext.put(ConfigModelConstant.PROPERTY_TEMPLATE_NAME, "sample-template");\r
- componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARIES, dictionaries);\r
- componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".profile_name", "sample");\r
-\r
- Map<String, String> inParams = new HashMap<>();\r
- SvcLogicContext ctx = new SvcLogicContext();\r
- String datatypeContent = FileUtils.readFileToString(new File("src/test/resources/mapping/db/dt-location.json"),\r
- Charset.defaultCharset());\r
- ctx.setAttribute("data_types.dt-location", datatypeContent);\r
- dbResourceProcessor.process(inParams, ctx, componentContext);\r
-\r
- }\r
-\r
- @Test\r
- public void testDbArrayComplexProcess() throws Exception {\r
- logger.info(" ******************************* testDbArrayComplexProcess ***************************");\r
- Mockito.doAnswer(new Answer<List<Map<String, Object>>>() {\r
- @Override\r
- public List<Map<String, Object>> answer(InvocationOnMock invocationOnMock) throws Throwable {\r
- Object[] args = invocationOnMock.getArguments();\r
- List<Map<String, Object>> results = new ArrayList<>();\r
- if (args != null) {\r
- logger.info("Query " + Arrays.asList(args));\r
- Map<String, Object> record = new HashMap<>();\r
- record.put("db-country", "US");\r
- record.put("db-state", "NJ");\r
- results.add(record);\r
-\r
- Map<String, Object> record2 = new HashMap<>();\r
- record2.put("db-country", "INDIA");\r
- record2.put("db-state", "TN");\r
- results.add(record2);\r
- }\r
- return results;\r
- }\r
- }).when(configResourceService).query(Matchers.anyString(), Matchers.<Map<String, Object>>any());\r
-\r
- String recipeName = "sample-recipe";\r
-\r
- String resourceassignmentContent = FileUtils.readFileToString(\r
- new File("src/test/resources/mapping/db/resource-assignments-array.json"), Charset.defaultCharset());\r
- List<ResourceAssignment> batchResourceAssignment =\r
- TransformationUtils.getListfromJson(resourceassignmentContent, ResourceAssignment.class);\r
-\r
- String dictionaryContent = FileUtils.readFileToString(new File("src/test/resources/mapping/db/db-array.json"),\r
- Charset.defaultCharset());\r
- Map<String, ResourceDefinition> dictionaries =\r
- ConfigResourceAssignmentTestUtils.getMapfromJson(dictionaryContent);\r
- DBResourceProcessor dbResourceProcessor = new DBResourceProcessor(configResourceService);\r
- Map<String, Object> componentContext = new HashMap<>();\r
- componentContext.put(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS, batchResourceAssignment);\r
- componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName);\r
- componentContext.put(ConfigModelConstant.PROPERTY_TEMPLATE_NAME, "sample-template");\r
- componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARIES, dictionaries);\r
- componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".profile_name", "sample");\r
-\r
- Map<String, String> inParams = new HashMap<>();\r
- SvcLogicContext ctx = new SvcLogicContext();\r
- String datatypeContent = FileUtils.readFileToString(new File("src/test/resources/mapping/db/dt-location.json"),\r
- Charset.defaultCharset());\r
- ctx.setAttribute("data_types.dt-location", datatypeContent);\r
- dbResourceProcessor.process(inParams, ctx, componentContext);\r
- logger.info("Component Context = ({})", componentContext);\r
- Assert.assertNotNull("faile dto populate Array Complex response ", componentContext);\r
-\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.assignment.processor;\r
-\r
-import static org.mockito.Matchers.any;\r
-import java.io.File;\r
-import java.nio.charset.Charset;\r
-import java.util.Arrays;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.apache.commons.io.FileUtils;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mock;\r
-import org.mockito.Mockito;\r
-import org.mockito.MockitoAnnotations;\r
-import org.mockito.invocation.InvocationOnMock;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.mockito.stubbing.Answer;\r
-import org.onap.ccsdk.features.assignment.service.ConfigResourceAssignmentTestUtils;\r
-import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog;\r
-import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.data.ResourceAssignment;\r
-import org.onap.ccsdk.features.model.data.dict.ResourceDefinition;\r
-import org.onap.ccsdk.features.model.utils.TransformationUtils;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class DefaultResourceProcessorTest {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(DefaultResourceProcessorTest.class);\r
-\r
- @Mock\r
- private ConfigResourceService configResourceService;\r
-\r
- @SuppressWarnings("unchecked")\r
- @Before\r
- public void before() {\r
- MockitoAnnotations.initMocks(this);\r
-\r
- try {\r
- Mockito.doAnswer(new Answer<Void>() {\r
- @Override\r
- public Void answer(InvocationOnMock invocationOnMock) throws Throwable {\r
- Object[] args = invocationOnMock.getArguments();\r
- if (args != null) {\r
- logger.trace("Transaction info " + Arrays.asList(args));\r
- }\r
- return null;\r
- }\r
- }).when(configResourceService).save(any(TransactionLog.class));\r
-\r
- } catch (SvcLogicException e) {\r
- e.printStackTrace();\r
- }\r
- }\r
-\r
- @Test\r
- public void testDefaultSimpleProcess() throws Exception {\r
- logger.info(" ******************************* testDefaultSimpleProcess ***************************");\r
-\r
- String recipeName = "sample-recipe";\r
-\r
- String resourceassignmentContent = FileUtils.readFileToString(\r
- new File("src/test/resources/mapping/default/resource-assignments-simple.json"),\r
- Charset.defaultCharset());\r
- List<ResourceAssignment> batchResourceAssignment =\r
- TransformationUtils.getListfromJson(resourceassignmentContent, ResourceAssignment.class);\r
-\r
- String dictionaryContent = FileUtils.readFileToString(\r
- new File("src/test/resources/mapping/default/default-simple.json"), Charset.defaultCharset());\r
- Map<String, ResourceDefinition> dictionaries =\r
- ConfigResourceAssignmentTestUtils.getMapfromJson(dictionaryContent);\r
-\r
- DefaultResourceProcessor defaultResourceProcessor = new DefaultResourceProcessor(configResourceService);\r
- Map<String, Object> componentContext = new HashMap<>();\r
- componentContext.put(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS, batchResourceAssignment);\r
- componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName);\r
- componentContext.put(ConfigModelConstant.PROPERTY_TEMPLATE_NAME, "sample-template");\r
- componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARIES, dictionaries);\r
- componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".profile_name", "sample");\r
-\r
- Map<String, String> inParams = new HashMap<>();\r
- SvcLogicContext ctx = new SvcLogicContext();\r
- defaultResourceProcessor.process(inParams, ctx, componentContext);\r
- logger.trace(" componentContext " + componentContext);\r
-\r
- Assert.assertEquals("Failed to populate default country value ", "US",\r
- componentContext.get(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + "sample-recipe.country"));\r
- Assert.assertEquals("Failed to populate default country value ", "US",\r
- componentContext.get(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + "sample-recipe.country"));\r
-\r
- Assert.assertEquals("Failed to populate default port value ", 830,\r
- componentContext.get(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + "sample-recipe.port"));\r
- Assert.assertEquals("Failed to populate default port value ", 830,\r
- componentContext.get(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + "sample-recipe.port"));\r
-\r
- Assert.assertEquals("Failed to populate default voip-enabled value ", true,\r
- componentContext.get(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + "sample-recipe.voip-enabled"));\r
- Assert.assertEquals("Failed to populate default voip-enabled value ", true,\r
- componentContext.get(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + "sample-recipe.voip-enabled"));\r
-\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.assignment.processor;\r
-\r
-import static org.mockito.Matchers.any;\r
-import java.io.File;\r
-import java.nio.charset.Charset;\r
-import java.util.Arrays;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.apache.commons.io.FileUtils;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mock;\r
-import org.mockito.Mockito;\r
-import org.mockito.MockitoAnnotations;\r
-import org.mockito.invocation.InvocationOnMock;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.mockito.stubbing.Answer;\r
-import org.onap.ccsdk.features.assignment.service.ConfigResourceAssignmentTestUtils;\r
-import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog;\r
-import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.data.ResourceAssignment;\r
-import org.onap.ccsdk.features.model.data.dict.ResourceDefinition;\r
-import org.onap.ccsdk.features.model.utils.TransformationUtils;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class InputResourceProcessorTest {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(InputResourceProcessorTest.class);\r
-\r
- @Mock\r
- private ConfigResourceService configResourceService;\r
-\r
- @SuppressWarnings("unchecked")\r
- @Before\r
- public void before() {\r
- MockitoAnnotations.initMocks(this);\r
-\r
- try {\r
- Mockito.doAnswer(new Answer<Void>() {\r
- @Override\r
- public Void answer(InvocationOnMock invocationOnMock) throws Throwable {\r
- Object[] args = invocationOnMock.getArguments();\r
- if (args != null) {\r
- logger.trace("Transaction info " + Arrays.asList(args));\r
- }\r
- return null;\r
- }\r
- }).when(configResourceService).save(any(TransactionLog.class));\r
-\r
- } catch (SvcLogicException e) {\r
- e.printStackTrace();\r
- }\r
- }\r
-\r
- @Test\r
- public void testInputSimpleProcess() throws Exception {\r
- logger.info(" ******************************* testInputSimpleProcess ***************************");\r
-\r
- String recipeName = "sample-recipe";\r
-\r
- String resourceassignmentContent = FileUtils.readFileToString(\r
- new File("src/test/resources/mapping/input/resource-assignments-simple.json"),\r
- Charset.defaultCharset());\r
- List<ResourceAssignment> batchResourceAssignment =\r
- TransformationUtils.getListfromJson(resourceassignmentContent, ResourceAssignment.class);\r
-\r
- String dictionaryContent = FileUtils.readFileToString(\r
- new File("src/test/resources/mapping/default/default-simple.json"), Charset.defaultCharset());\r
- Map<String, ResourceDefinition> dictionaries =\r
- ConfigResourceAssignmentTestUtils.getMapfromJson(dictionaryContent);\r
-\r
- InputResourceProcessor inputResourceProcessor = new InputResourceProcessor(configResourceService);\r
- Map<String, Object> componentContext = new HashMap<>();\r
- componentContext.put(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS, batchResourceAssignment);\r
- componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName);\r
- componentContext.put(ConfigModelConstant.PROPERTY_TEMPLATE_NAME, "sample-template");\r
- componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARIES, dictionaries);\r
- componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".profile_name", "sample");\r
-\r
- Map<String, String> inParams = new HashMap<>();\r
- SvcLogicContext ctx = new SvcLogicContext();\r
- ctx.setAttribute("country", "US");\r
- ctx.setAttribute("port", "830");\r
- ctx.setAttribute("voip-enabled", "true");\r
-\r
- inputResourceProcessor.process(inParams, ctx, componentContext);\r
- logger.trace(" componentContext " + componentContext);\r
-\r
- Assert.assertEquals("Failed to populate default recipe country value ", "US",\r
- componentContext.get(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + "sample-recipe.country"));\r
- Assert.assertEquals("Failed to populate default dictionary country value ", "US",\r
- componentContext.get(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + "sample-recipe.country"));\r
-\r
- Assert.assertEquals("Failed to populate default recipe port value ", 830,\r
- componentContext.get(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + "sample-recipe.port"));\r
- Assert.assertEquals("Failed to populate default dictionary port value ", 830,\r
- componentContext.get(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + "sample-recipe.port"));\r
-\r
- Assert.assertEquals("Failed to populate default recipe voip-enabled value ", true,\r
- componentContext.get(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + "sample-recipe.voip-enabled"));\r
- Assert.assertEquals("Failed to populate default dictionary voip-enabled value ", true,\r
- componentContext.get(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + "sample-recipe.voip-enabled"));\r
-\r
- }\r
-\r
- @Test\r
- public void testInputComplexProcess() throws Exception {\r
- logger.info(" ******************************* testInputComplexProcess ***************************");\r
-\r
- String recipeName = "sample-recipe";\r
-\r
- String resourceassignmentContent = FileUtils.readFileToString(\r
- new File("src/test/resources/mapping/input/resource-assignments-complex.json"),\r
- Charset.defaultCharset());\r
- List<ResourceAssignment> batchResourceAssignment =\r
- TransformationUtils.getListfromJson(resourceassignmentContent, ResourceAssignment.class);\r
-\r
- String dictionaryContent = FileUtils.readFileToString(\r
- new File("src/test/resources/mapping/input/input-complex.json"), Charset.defaultCharset());\r
- Map<String, ResourceDefinition> dictionaries =\r
- ConfigResourceAssignmentTestUtils.getMapfromJson(dictionaryContent);\r
-\r
- InputResourceProcessor inputResourceProcessor = new InputResourceProcessor(configResourceService);\r
- Map<String, Object> componentContext = new HashMap<>();\r
- componentContext.put(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS, batchResourceAssignment);\r
- componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName);\r
- componentContext.put(ConfigModelConstant.PROPERTY_TEMPLATE_NAME, "sample-template");\r
- componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARIES, dictionaries);\r
- componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".profile_name", "sample");\r
-\r
- Map<String, String> inParams = new HashMap<>();\r
- SvcLogicContext ctx = new SvcLogicContext();\r
- String datatypeContent = FileUtils.readFileToString(\r
- new File("src/test/resources/mapping/input/dt-location.json"), Charset.defaultCharset());\r
- ctx.setAttribute("data_types.dt-location", datatypeContent);\r
-\r
- String samplelocation = FileUtils.readFileToString(\r
- new File("src/test/resources/mapping/input/sample-location.json"), Charset.defaultCharset());\r
- ctx.setAttribute("location", samplelocation);\r
-\r
- inputResourceProcessor.process(inParams, ctx, componentContext);\r
-\r
- logger.trace(" componentContext " + componentContext);\r
- logger.trace(" Resource Mapping " + TransformationUtils.getJson(batchResourceAssignment, true));\r
-\r
- Assert.assertNotNull("Failed to populate input recipe location value ",\r
- componentContext.get(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + "sample-recipe.location"));\r
- Assert.assertNotNull("Failed to populate input dictionary location value ",\r
- componentContext.get(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + "sample-recipe.location"));\r
-\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.assignment.processor;\r
-\r
-import java.io.File;\r
-import java.nio.charset.Charset;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.apache.commons.io.FileUtils;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Matchers;\r
-import org.mockito.Mock;\r
-import org.mockito.Mockito;\r
-import org.mockito.invocation.InvocationOnMock;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.mockito.stubbing.Answer;\r
-import org.onap.ccsdk.features.assignment.service.ConfigResourceAssignmentTestUtils;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.data.ResourceAssignment;\r
-import org.onap.ccsdk.features.model.data.dict.ResourceDefinition;\r
-import org.onap.ccsdk.features.model.utils.TransformationUtils;\r
-import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class MdsalResourceProcessorTest {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(MdsalResourceProcessorTest.class);\r
-\r
- @Mock\r
- private ConfigRestAdaptorService configRestAdaptorService;\r
-\r
- @SuppressWarnings("unchecked")\r
- @Before\r
- public void before() {\r
-\r
- }\r
-\r
- @Test\r
- @SuppressWarnings("unchecked")\r
- public void testMdsalSimpleProcess() throws Exception {\r
- logger.info(" ******************************* testMdsalSimpleProcess ***************************");\r
-\r
- Mockito.doAnswer(new Answer<String>() {\r
- @Override\r
- public String answer(InvocationOnMock invocationOnMock) throws Throwable {\r
- Object[] args = invocationOnMock.getArguments();\r
- String response = null;\r
- if (args != null) {\r
- response = FileUtils.readFileToString(\r
- new File("src/test/resources/mapping/Mdsal/simple-response.json"),\r
- Charset.defaultCharset());\r
- logger.info(" Returning response :" + response);\r
- }\r
- return response;\r
- }\r
- }).when(configRestAdaptorService).getResource(Matchers.anyString(), Matchers.anyString(),\r
- Matchers.any(Class.class));\r
-\r
- String recipeName = "sample-recipe";\r
-\r
- String resourceassignmentContent = FileUtils.readFileToString(\r
- new File("src/test/resources/mapping/Mdsal/resource-assignments-simple.json"),\r
- Charset.defaultCharset());\r
- List<ResourceAssignment> batchResourceAssignment =\r
- TransformationUtils.getListfromJson(resourceassignmentContent, ResourceAssignment.class);\r
-\r
- String dictionaryContent = FileUtils.readFileToString(\r
- new File("src/test/resources/mapping/Mdsal/mdsal-simple.json"), Charset.defaultCharset());\r
- Map<String, ResourceDefinition> dictionaries =\r
- ConfigResourceAssignmentTestUtils.getMapfromJson(dictionaryContent);\r
- MdsalResourceProcessor mdsalResourceProcessor = new MdsalResourceProcessor(configRestAdaptorService);\r
- Map<String, Object> componentContext = new HashMap<>();\r
- componentContext.put(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS, batchResourceAssignment);\r
- componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName);\r
- componentContext.put(ConfigModelConstant.PROPERTY_TEMPLATE_NAME, "sample-template");\r
- componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARIES, dictionaries);\r
-\r
- componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".profile_name", "sample");\r
-\r
- Map<String, String> inParams = new HashMap<>();\r
- SvcLogicContext ctx = new SvcLogicContext();\r
- mdsalResourceProcessor.process(inParams, ctx, componentContext);\r
-\r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- @Test\r
- public void testMDSALComplexProcess() throws Exception {\r
- logger.info(" ******************************* testMDSALComplexProcess ***************************");\r
-\r
- Mockito.doAnswer(new Answer<String>() {\r
- @Override\r
- public String answer(InvocationOnMock invocationOnMock) throws Throwable {\r
- Object[] args = invocationOnMock.getArguments();\r
- String response = null;\r
- if (args != null) {\r
- response = FileUtils.readFileToString(\r
- new File("src/test/resources/mapping/Mdsal/complex-response.json"),\r
- Charset.defaultCharset());\r
- }\r
- return response;\r
- }\r
- }).when(configRestAdaptorService).getResource(Matchers.anyString(), Matchers.anyString(),\r
- Matchers.any(Class.class));\r
-\r
- String recipeName = "sample-recipe";\r
-\r
- String resourceassignmentContent = FileUtils.readFileToString(\r
- new File("src/test/resources/mapping/Mdsal/resource-assignments-complex.json"),\r
- Charset.defaultCharset());\r
- List<ResourceAssignment> batchResourceAssignment =\r
- TransformationUtils.getListfromJson(resourceassignmentContent, ResourceAssignment.class);\r
-\r
- String dictionaryContent = FileUtils.readFileToString(\r
- new File("src/test/resources/mapping/Mdsal/mdsal-complex.json"), Charset.defaultCharset());\r
- Map<String, ResourceDefinition> dictionaries =\r
- ConfigResourceAssignmentTestUtils.getMapfromJson(dictionaryContent);\r
- MdsalResourceProcessor dbResourceProcessor = new MdsalResourceProcessor(configRestAdaptorService);\r
- Map<String, Object> componentContext = new HashMap<>();\r
- componentContext.put(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS, batchResourceAssignment);\r
- componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName);\r
- componentContext.put(ConfigModelConstant.PROPERTY_TEMPLATE_NAME, "sample-template");\r
- componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARIES, dictionaries);\r
- componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".profile_name", "sample");\r
-\r
- Map<String, String> inParams = new HashMap<>();\r
- SvcLogicContext ctx = new SvcLogicContext();\r
- String datatypeContent = FileUtils.readFileToString(\r
- new File("src/test/resources/mapping/Mdsal/dt-location.json"), Charset.defaultCharset());\r
- ctx.setAttribute("data_types.dt-location", datatypeContent);\r
- dbResourceProcessor.process(inParams, ctx, componentContext);\r
-\r
- }\r
-\r
- @Test\r
- @SuppressWarnings("unchecked")\r
- public void testMDSALArrayComplexProcess() throws Exception {\r
- logger.info(" ******************************* testMDSALArrayComplexProcess ***************************");\r
-\r
- Mockito.doAnswer(new Answer<String>() {\r
- @Override\r
- public String answer(InvocationOnMock invocationOnMock) throws Throwable {\r
- Object[] args = invocationOnMock.getArguments();\r
- String response = null;\r
- if (args != null) {\r
- response = FileUtils.readFileToString(\r
- new File("src/test/resources/mapping/Mdsal/array-complex-response.json"),\r
- Charset.defaultCharset());\r
- }\r
- return response;\r
- }\r
- }).when(configRestAdaptorService).getResource(Matchers.anyString(), Matchers.anyString(),\r
- Matchers.any(Class.class));\r
-\r
- String recipeName = "sample-recipe";\r
-\r
- String resourceassignmentContent = FileUtils.readFileToString(\r
- new File("src/test/resources/mapping/Mdsal/resource-assignments-array.json"), Charset.defaultCharset());\r
- List<ResourceAssignment> batchResourceAssignment =\r
- TransformationUtils.getListfromJson(resourceassignmentContent, ResourceAssignment.class);\r
-\r
- String dictionaryContent = FileUtils.readFileToString(\r
- new File("src/test/resources/mapping/Mdsal/mdsal-array.json"), Charset.defaultCharset());\r
-\r
- Map<String, ResourceDefinition> dictionaries =\r
- ConfigResourceAssignmentTestUtils.getMapfromJson(dictionaryContent);\r
- MdsalResourceProcessor dbResourceProcessor = new MdsalResourceProcessor(configRestAdaptorService);\r
- Map<String, Object> componentContext = new HashMap<>();\r
- componentContext.put(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS, batchResourceAssignment);\r
- componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName);\r
- componentContext.put(ConfigModelConstant.PROPERTY_TEMPLATE_NAME, "sample-template");\r
- componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARIES, dictionaries);\r
- componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".profile_name", "sample");\r
-\r
- Map<String, String> inParams = new HashMap<>();\r
- SvcLogicContext ctx = new SvcLogicContext();\r
- String datatypeContent = FileUtils.readFileToString(\r
- new File("src/test/resources/mapping/Mdsal/dt-location.json"), Charset.defaultCharset());\r
- ctx.setAttribute("data_types.dt-location", datatypeContent);\r
- dbResourceProcessor.process(inParams, ctx, componentContext);\r
- logger.info("Component Context = ({})", componentContext);\r
- Assert.assertNotNull("failed to populate Array Complex response ", componentContext);\r
-\r
- }\r
-\r
- @Test\r
- @SuppressWarnings("unchecked")\r
- public void testMDSALArraySimpleProcess() throws Exception {\r
- logger.info(" ******************************* testMDSALArrayComplexProcess ***************************");\r
-\r
- Mockito.doAnswer(new Answer<String>() {\r
- @Override\r
- public String answer(InvocationOnMock invocationOnMock) throws Throwable {\r
- Object[] args = invocationOnMock.getArguments();\r
- String response = null;\r
- if (args != null) {\r
- response = FileUtils.readFileToString(\r
- new File("src/test/resources/mapping/Mdsal/array-complex-v4-assigned-response.json"),\r
- Charset.defaultCharset());\r
- }\r
- return response;\r
- }\r
- }).when(configRestAdaptorService).getResource(Matchers.anyString(), Matchers.anyString(),\r
- Matchers.any(Class.class));\r
-\r
- String recipeName = "sample-recipe";\r
-\r
- String resourceassignmentContent = FileUtils.readFileToString(\r
- new File("src/test/resources/mapping/Mdsal/resource-assignments-complex-simple.json"),\r
- Charset.defaultCharset());\r
- List<ResourceAssignment> batchResourceAssignment =\r
- TransformationUtils.getListfromJson(resourceassignmentContent, ResourceAssignment.class);\r
-\r
- String dictionaryContent = FileUtils.readFileToString(\r
- new File("src/test/resources/mapping/Mdsal/mdsal-array-v4iplist.json"), Charset.defaultCharset());\r
- Map<String, ResourceDefinition> dictionaries =\r
- ConfigResourceAssignmentTestUtils.getMapfromJson(dictionaryContent);\r
- MdsalResourceProcessor mdsalResourceProcessor = new MdsalResourceProcessor(configRestAdaptorService);\r
- Map<String, Object> componentContext = new HashMap<>();\r
- componentContext.put(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS, batchResourceAssignment);\r
- componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName);\r
- componentContext.put(ConfigModelConstant.PROPERTY_TEMPLATE_NAME, "sample-template");\r
- componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARIES, dictionaries);\r
- componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".service-instance-id",\r
- "3c8d5a63-a793-4206-a67c-4b2e8e648196");\r
- componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".oam-network-role",\r
- "sample");\r
- componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".oam-ipv4-ip-type",\r
- "sample");\r
- componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".profile_name", "sample");\r
- componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".oam-vm-type", "sample");\r
-\r
- Map<String, String> inParams = new HashMap<>();\r
- SvcLogicContext ctx = new SvcLogicContext();\r
- // String datatypeContent = FileUtils.readFileToString(new\r
- // File("src/test/resources/mapping/Mdsal/dt-v4-assigned-ip-list.json"), Charset.defaultCharset() );\r
- // ctx.setAttribute("data_types.dt-v4-assigned-ip-list", datatypeContent);\r
- mdsalResourceProcessor.process(inParams, ctx, componentContext);\r
- logger.info("Component Context = ({})", componentContext);\r
- Assert.assertNotNull("failed to populate Array Complex response ", componentContext);\r
- Assert.assertEquals("Compare String ", "10.66.1.152",\r
- componentContext.get(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + recipeName + ".v4-ip-prefix"));\r
-\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.assignment.service;\r
-\r
-import java.io.File;\r
-import java.nio.charset.Charset;\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-import org.apache.commons.io.FileUtils;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.apache.sling.testing.mock.osgi.MockOsgi;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Rule;\r
-import org.junit.Test;\r
-import org.junit.rules.ExpectedException;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mock;\r
-import org.mockito.MockitoAnnotations;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.ccsdk.features.assignment.ConfigAssignmentConstants;\r
-import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService;\r
-import org.onap.ccsdk.features.generator.service.ConfigGeneratorService;\r
-import org.onap.ccsdk.features.generator.service.ConfigGeneratorServiceImpl;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.service.ComponentNodeDelegate;\r
-import org.onap.ccsdk.features.model.service.ComponentNodeService;\r
-import org.onap.ccsdk.features.model.service.ComponentNodeServiceImpl;\r
-import org.onap.ccsdk.features.model.service.ConfigModelService;\r
-import org.onap.ccsdk.features.model.service.ConfigModelServiceImpl;\r
-import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import org.osgi.framework.BundleContext;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class ConfigAssignmentNodeTest {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentNodeTest.class);\r
-\r
- @Rule\r
- public ExpectedException thrown = ExpectedException.none();\r
-\r
- @Mock\r
- private ConfigResourceService configResourceService;\r
-\r
- @Mock\r
- private ConfigRestAdaptorService configRestAdaptorService;\r
-\r
- private ConfigModelService configModelService;\r
-\r
- private ComponentNodeService componentNodeService;\r
-\r
- private ConfigGeneratorService configGeneratorService;\r
-\r
- BundleContext bundleContext = MockOsgi.newBundleContext();\r
-\r
- @SuppressWarnings("unchecked")\r
- @Before\r
- public void before() throws Exception {\r
- MockitoAnnotations.initMocks(this);\r
- /*\r
- * ConfigAssignmentNode configAssignmentNode = new ConfigAssignmentNode(componentNodeService,\r
- * configResourceService, configModelService, configRestAdaptorService, configGeneratorService);\r
- * bundleContext.registerService(ConfigAssignmentNode.class, configAssignmentNode, null);\r
- */\r
- }\r
-\r
- @Test\r
- public void testResourceAssignment() throws Exception {\r
- ConfigResourceAssignmentTestUtils.injectTransactionLogSaveMock(configResourceService);\r
-\r
- ConfigResourceAssignmentTestUtils.injectConfigModelMock(configRestAdaptorService, "resource_assignment");\r
-\r
- ConfigResourceAssignmentTestUtils.injectResourceDictionaryMock(configRestAdaptorService,\r
- "assignments/empty-dictionary.json");\r
-\r
- ConfigResourceAssignmentTestUtils.injectConfigResourceSaveMock(configResourceService);\r
-\r
- componentNodeService =\r
- new ComponentNodeServiceImpl(bundleContext, configResourceService, configRestAdaptorService);\r
- configModelService = new ConfigModelServiceImpl(configRestAdaptorService);\r
- configGeneratorService = new ConfigGeneratorServiceImpl(configResourceService);\r
-\r
- ConfigAssignmentNode configAssignmentNode = new ConfigAssignmentNode(configResourceService,\r
- configRestAdaptorService, configModelService, componentNodeService, configGeneratorService);\r
-\r
- String inputContent = FileUtils.readFileToString(\r
- new File("src/test/resources/service_templates/input/input.json"), Charset.defaultCharset());\r
-\r
- Map<String, String> inParams = new HashMap<>();\r
- inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "test");\r
- inParams.put(ConfigAssignmentConstants.INPUT_PARAM_REQUEST_ID, "1234");\r
- inParams.put(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_ID, "resourceid-1234");\r
- inParams.put(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_TYPE, "vnf-type");\r
- inParams.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_NAME, "vpe-201802-baseconfig");\r
- inParams.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_VERSION, "1.0.0");\r
- inParams.put(ConfigModelConstant.PROPERTY_ACTION_NAME, "resource-assignment-action");\r
- inParams.put(ConfigAssignmentConstants.INPUT_PARAM_INPUT_DATA, inputContent);\r
- inParams.put(ConfigAssignmentConstants.INPUT_PARAM_TEMPLATE_NAMES, "[\"base-config-template\"]");\r
-\r
- // Populate the SvcContext ( Simulation)\r
- SvcLogicContext svcLogicContext = new SvcLogicContext();\r
- Map<String, String> context = new HashMap<>();\r
- context.put(ConfigModelConstant.PROPERTY_ACTION_NAME, "resource-assignment-action");\r
- context = configModelService.prepareContext(context, inputContent, "vpe-201802-baseconfig", "1.0.0");\r
- context.forEach((key, value) -> svcLogicContext.setAttribute(key, value));\r
-\r
- Map<String, Object> componentContext = new HashMap<>();\r
- configAssignmentNode.process(inParams, svcLogicContext, componentContext);\r
- Assert.assertNotNull("Failed to get response status", svcLogicContext.getAttribute("test.status"));\r
-\r
- }\r
-\r
- @Test\r
- public void testSimplePreview() throws Exception {\r
- ConfigResourceAssignmentTestUtils.injectTransactionLogSaveMock(configResourceService);\r
-\r
- ConfigResourceAssignmentTestUtils.injectConfigModelMock(configRestAdaptorService, "resource_assignment");\r
-\r
- ConfigResourceAssignmentTestUtils.injectResourceDictionaryMock(configRestAdaptorService,\r
- "assignments/empty-dictionary.json");\r
-\r
- ConfigResourceAssignmentTestUtils.injectConfigResourceSaveMock(configResourceService);\r
-\r
- componentNodeService =\r
- new ComponentNodeServiceImpl(bundleContext, configResourceService, configRestAdaptorService);\r
- configModelService = new ConfigModelServiceImpl(configRestAdaptorService);\r
- configGeneratorService = new ConfigGeneratorServiceImpl(configResourceService);\r
-\r
- ConfigAssignmentNode configAssignmentNode = new ConfigAssignmentNode(configResourceService,\r
- configRestAdaptorService, configModelService, componentNodeService, configGeneratorService);\r
-\r
- String inputContent = FileUtils.readFileToString(\r
- new File("src/test/resources/service_templates/input/input.json"), Charset.defaultCharset());\r
-\r
- Map<String, String> inParams = new HashMap<>();\r
- inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "test");\r
- inParams.put(ConfigAssignmentConstants.INPUT_PARAM_REQUEST_ID, "1234");\r
- inParams.put(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_ID, "resourceid-1234");\r
- inParams.put(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_TYPE, "vnf-type");\r
- inParams.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_NAME, "vpe-201802-baseconfig");\r
- inParams.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_VERSION, "1.0.0");\r
- inParams.put(ConfigModelConstant.PROPERTY_ACTION_NAME, "resource-assignment-action");\r
- inParams.put(ConfigAssignmentConstants.INPUT_PARAM_INPUT_DATA, inputContent);\r
- inParams.put(ConfigAssignmentConstants.INPUT_PARAM_TEMPLATE_NAMES, "[\"base-config-template\"]");\r
- SvcLogicContext ctx = new SvcLogicContext();\r
- configAssignmentNode.process(inParams, ctx);\r
- Assert.assertNotNull("Failed to get response mashed Content",\r
- ctx.getAttribute("test.mashed-data.base-config-template"));\r
- }\r
-\r
- @Test\r
- public void testComplexPreview() throws Exception {\r
- ConfigResourceAssignmentTestUtils.injectTransactionLogSaveMock(configResourceService);\r
-\r
- ConfigResourceAssignmentTestUtils.injectConfigModelMock(configRestAdaptorService, "vpe-201802-baseconfig");\r
-\r
- ConfigResourceAssignmentTestUtils.injectResourceDictionaryMock(configRestAdaptorService,\r
- "service_templates/vpe-201802-baseconfig/dict.json");\r
-\r
- ConfigResourceAssignmentTestUtils.injectConfigResourceSaveMock(configResourceService);\r
-\r
- componentNodeService =\r
- new ComponentNodeServiceImpl(bundleContext, configResourceService, configRestAdaptorService);\r
- configModelService = new ConfigModelServiceImpl(configRestAdaptorService);\r
- configGeneratorService = new ConfigGeneratorServiceImpl(configResourceService);\r
-\r
- ConfigAssignmentNode configAssignmentNode = new ConfigAssignmentNode(configResourceService,\r
- configRestAdaptorService, configModelService, componentNodeService, configGeneratorService);\r
-\r
- String inputContent = FileUtils.readFileToString(\r
- new File("src/test/resources/service_templates/vpe-201802-baseconfig/input-complex.json"),\r
- Charset.defaultCharset());\r
-\r
- Map<String, String> inParams = new HashMap<>();\r
- inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "complex-test");\r
- inParams.put(ConfigAssignmentConstants.INPUT_PARAM_REQUEST_ID, "request-1234");\r
- inParams.put(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_ID, "resourceid-1234");\r
- inParams.put(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_TYPE, "vnf-type");\r
- inParams.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_NAME, "vpe-201802-baseconfig");\r
- inParams.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_VERSION, "1.0.0");\r
- inParams.put(ConfigModelConstant.PROPERTY_ACTION_NAME, "resource-assignment-action");\r
- inParams.put(ConfigAssignmentConstants.INPUT_PARAM_INPUT_DATA, inputContent);\r
- inParams.put(ConfigAssignmentConstants.INPUT_PARAM_TEMPLATE_NAMES, "[\"base-config-template\"]");\r
- SvcLogicContext ctx = new SvcLogicContext();\r
- configAssignmentNode.process(inParams, ctx);\r
- Assert.assertNotNull("Failed to get response mashed Content",\r
- ctx.getAttribute("complex-test.mashed-data.base-config-template"));\r
-\r
- }\r
-\r
- @Test\r
- public void inputValidator() {\r
- SvcLogicContext ctx = new SvcLogicContext();\r
- try {\r
-\r
- logger.info(" ******************************* inputValidator ***************************");\r
- String serviceTemplateContent = FileUtils.readFileToString(\r
- new File("src/test/resources/service_templates/resource_assignment.json"),\r
- Charset.defaultCharset());\r
-\r
- String inputcontent = FileUtils.readFileToString(\r
- new File("src/test/resources/service_templates/input/inputValidateTest.json"),\r
- Charset.defaultCharset());\r
-\r
- Map<String, String> context = new HashMap<>();\r
- configModelService.prepareContext(context, inputcontent, serviceTemplateContent);\r
-\r
- // TransformationUtils.printMap(context);\r
-\r
- context.forEach((name, value) -> {\r
- if (StringUtils.isNotBlank(name) && StringUtils.isNotBlank(value)) {\r
- ctx.setAttribute(name, value);\r
- }\r
- });\r
-\r
- ComponentNodeDelegate componentNodeDelegate = new ComponentNodeDelegate(componentNodeService);\r
- Map<String, String> inParams = new HashMap<>();\r
- inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "resource-assignment");\r
- componentNodeDelegate.process(inParams, ctx);\r
- Assert.fail();\r
- } catch (Exception e) {\r
- logger.error("Failed in inputValidator" + e.getMessage());\r
- logger.info("** ctx.getAttribute Check for **" + ctx.getAttribute("resource-assignment.error-message"));\r
- }\r
-\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.assignment.service;\r
-\r
-import java.io.File;\r
-import java.nio.charset.Charset;\r
-import org.apache.commons.io.FileUtils;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Rule;\r
-import org.junit.Test;\r
-import org.junit.rules.ExpectedException;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mock;\r
-import org.mockito.MockitoAnnotations;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.ccsdk.features.assignment.data.ResourceAssignmentData;\r
-import org.onap.ccsdk.features.data.adaptor.domain.ConfigResource;\r
-import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService;\r
-import org.onap.ccsdk.features.generator.service.ConfigGeneratorService;\r
-import org.onap.ccsdk.features.generator.service.ConfigGeneratorServiceImpl;\r
-import org.onap.ccsdk.features.model.service.ConfigModelService;\r
-import org.onap.ccsdk.features.model.service.ConfigModelServiceImpl;\r
-import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class ConfigPreviewServiceTest {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigPreviewServiceTest.class);\r
-\r
- @Rule\r
- public ExpectedException thrown = ExpectedException.none();\r
-\r
- @Mock\r
- private ConfigResourceService configResourceService;\r
-\r
- @Mock\r
- private ConfigRestAdaptorService configRestAdaptorService;\r
-\r
- private ConfigModelService configModelService;\r
- private ConfigGeneratorService configGeneratorService;\r
-\r
- @SuppressWarnings("unchecked")\r
- @Before\r
- public void before() throws Exception {\r
- MockitoAnnotations.initMocks(this);\r
- }\r
-\r
- @Test\r
- public void testGenerateTemplateResourceMash() throws Exception {\r
-\r
- ConfigResourceAssignmentTestUtils.injectTransactionLogSaveMock(configResourceService);\r
-\r
- ConfigResourceAssignmentTestUtils.injectConfigModelMock(configRestAdaptorService, "resource_assignment");\r
-\r
- ConfigResourceAssignmentTestUtils.injectResourceDictionaryMock(configRestAdaptorService,\r
- "assignments/empty-dictionary.json");\r
-\r
- ConfigResource configResourceQuery = new ConfigResource();\r
- configResourceQuery.setServiceTemplateVersion("sample-serviceTemplateName");\r
- configResourceQuery.setServiceTemplateVersion("1.0.0");\r
- configResourceQuery.setRecipeName("sample-action");\r
- configResourceQuery.setResourceId("123-resourceId");\r
- configResourceQuery.setResourceType("sample-resourceType");\r
- configResourceQuery.setTemplateName("base-config-template");\r
- String inputContent = FileUtils.readFileToString(\r
- new File("src/test/resources/service_templates/input/input.json"), Charset.defaultCharset());\r
- configResourceQuery.setResourceData(inputContent);\r
-\r
- ConfigResourceAssignmentTestUtils.injectGetConfigResourceMock(configResourceService, configResourceQuery);\r
-\r
- configModelService = new ConfigModelServiceImpl(configRestAdaptorService);\r
- configGeneratorService = new ConfigGeneratorServiceImpl(configResourceService);\r
-\r
- ConfigPreviewService configPreviewService =\r
- new ConfigPreviewService(configResourceService, configModelService, configGeneratorService);\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
- resourceAssignmentData = configPreviewService.generateTemplateResourceMash(resourceAssignmentData);\r
-\r
- Assert.assertNotNull("Failed to get GenerateTemplateResourceMash response.", resourceAssignmentData);\r
- Assert.assertNotNull("Failed to get template mashed contents.",\r
- resourceAssignmentData.getTemplatesMashedContents());\r
-\r
- Assert.assertNotNull("Failed to get base-config template mashed contents.",\r
- resourceAssignmentData.getTemplatesMashedContents().get("base-config-template"));\r
- }\r
-}\r
+++ /dev/null
-/*\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.features.assignment.service;\r
-\r
-import static org.mockito.Matchers.any;\r
-import static org.mockito.Matchers.anyString;\r
-import java.io.File;\r
-import java.nio.charset.Charset;\r
-import java.util.ArrayList;\r
-import java.util.Arrays;\r
-import java.util.Collection;\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.apache.commons.io.FileUtils;\r
-import org.apache.commons.io.FilenameUtils;\r
-import org.apache.commons.io.IOUtils;\r
-import org.mockito.Matchers;\r
-import org.mockito.Mockito;\r
-import org.mockito.invocation.InvocationOnMock;\r
-import org.mockito.stubbing.Answer;\r
-import org.onap.ccsdk.features.data.adaptor.domain.ConfigResource;\r
-import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog;\r
-import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.data.dict.ResourceDefinition;\r
-import org.onap.ccsdk.features.model.domain.ConfigModel;\r
-import org.onap.ccsdk.features.model.domain.ConfigModelContent;\r
-import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-import com.fasterxml.jackson.core.type.TypeReference;\r
-import com.fasterxml.jackson.databind.ObjectMapper;\r
-\r
-public class ConfigResourceAssignmentTestUtils {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigResourceAssignmentTestUtils.class);\r
-\r
- public static void injectTransactionLogSaveMock(ConfigResourceService configResourceService) throws Exception {\r
- Mockito.doAnswer(new Answer<Void>() {\r
- @Override\r
- public Void answer(InvocationOnMock invocationOnMock) throws Throwable {\r
- Object[] args = invocationOnMock.getArguments();\r
- if (args != null) {\r
- logger.trace("Transaction info " + Arrays.asList(args));\r
- }\r
- return null;\r
- }\r
- }).when(configResourceService).save(any(TransactionLog.class));\r
- }\r
-\r
- public static void injectConfigModelMock(ConfigRestAdaptorService configRestAdaptorService,\r
- String serviceTemplateName) throws Exception {\r
-\r
- Mockito.doAnswer(new Answer<ConfigModel>() {\r
- @Override\r
- public org.onap.ccsdk.features.model.domain.ConfigModel answer(InvocationOnMock invocationOnMock)\r
- throws Throwable {\r
- Object[] args = invocationOnMock.getArguments();\r
- org.onap.ccsdk.features.model.domain.ConfigModel serviceArtifact = null;\r
- if (args != null && args.length == 3) {\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
- ConfigModelContent configModelContent = new ConfigModelContent();\r
- configModelContent.setContent(modelContent);\r
- configModelContent.setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON);\r
-\r
- List<ConfigModelContent> configModelContents = new ArrayList<>();\r
- configModelContents.add(configModelContent);\r
-\r
- String velocityDir = ConfigResourceAssignmentTestUtils.class.getClassLoader()\r
- .getResource("service_templates/" + serviceTemplateName + "/velocity").getPath();\r
-\r
- Collection<File> templateFiles =\r
- FileUtils.listFiles(new File(velocityDir), new String[] {"vtl"}, true);\r
- logger.info("Template Files info " + templateFiles);\r
- for (File templateFile : templateFiles) {\r
- String templateContent = FileUtils.readFileToString(templateFile, Charset.defaultCharset());\r
- ConfigModelContent configModelTemplateContent = new ConfigModelContent();\r
- configModelTemplateContent.setContent(templateContent);\r
- configModelTemplateContent.setName(FilenameUtils.getBaseName(templateFile.getName()));\r
- configModelTemplateContent.setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TEMPLATE);\r
- configModelContents.add(configModelTemplateContent);\r
- }\r
-\r
- serviceArtifact = new org.onap.ccsdk.features.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
- return serviceArtifact;\r
- }\r
- }).when(configRestAdaptorService).getResource(anyString(), anyString(), Matchers.any(Class.class));\r
- }\r
-\r
- public static void injectResourceDictionaryMock(ConfigRestAdaptorService configRestAdaptorService,\r
- String dictionaryFileName) throws Exception {\r
-\r
- Mockito.doAnswer(new Answer<String>() {\r
- @Override\r
- public String answer(InvocationOnMock invocationOnMock) throws Throwable {\r
- Object[] args = invocationOnMock.getArguments();\r
- String dictionaties = "[]";\r
- if (args != null) {\r
- logger.info("getResourceDictionaryByNames " + Arrays.asList(args));\r
- dictionaties = IOUtils.toString(\r
- ConfigAssignmentNodeTest.class.getClassLoader().getResourceAsStream(dictionaryFileName),\r
- Charset.defaultCharset());\r
- }\r
- return dictionaties;\r
- }\r
- }).when(configRestAdaptorService).postResource(Matchers.any(), Matchers.any(), Matchers.any(),\r
- Matchers.any(Class.class));\r
- }\r
-\r
- public static void injectConfigResourceSaveMock(ConfigResourceService configResourceService) throws Exception {\r
- Mockito.doAnswer(new Answer<ConfigResource>() {\r
- @Override\r
- public ConfigResource answer(InvocationOnMock invocationOnMock) throws Throwable {\r
- Object[] args = invocationOnMock.getArguments();\r
- ConfigResource configResource = null;\r
- if (args != null) {\r
- configResource = (ConfigResource) args[0];\r
- logger.info("Config Resource Save info " + configResource);\r
- return configResource;\r
- }\r
- return configResource;\r
- }\r
- }).when(configResourceService).saveConfigResource(any(ConfigResource.class));\r
- }\r
-\r
- public static void injectGetConfigResourceMock(ConfigResourceService configResourceService,\r
- ConfigResource configResource) throws Exception {\r
- Mockito.doAnswer(new Answer<List<ConfigResource>>() {\r
- @Override\r
- public List<ConfigResource> answer(InvocationOnMock invocationOnMock) throws Throwable {\r
- Object[] args = invocationOnMock.getArguments();\r
- List<ConfigResource> configResources = new ArrayList<>();\r
- if (args != null) {\r
- configResources.add(configResource);\r
- }\r
- return configResources;\r
- }\r
- }).when(configResourceService).getConfigResource(any(ConfigResource.class));\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
- public static Map<String, ResourceDefinition> getMapfromJson(String content) {\r
- try {\r
- ObjectMapper mapper = new ObjectMapper();\r
- return mapper.readValue(content, new TypeReference<Map<String, ResourceDefinition>>() {});\r
- } catch (Exception e) {\r
- logger.info("getMapfromJson Exception ({})", e);\r
- }\r
- return null;\r
- }\r
-}\r
+++ /dev/null
-/*\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.features.assignment.service;\r
-\r
-import java.nio.charset.Charset;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.apache.commons.io.IOUtils;\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.ValidTypes;\r
-import org.onap.ccsdk.features.model.data.ResourceAssignment;\r
-import org.onap.ccsdk.features.model.utils.ResourceAssignmentUtils;\r
-import org.onap.ccsdk.features.model.utils.TransformationUtils;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-import com.fasterxml.jackson.databind.JsonNode;\r
-\r
-public class ResourceAssignmentGenerationTest {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceAssignmentGenerationTest.class);\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
- List<ResourceAssignment> assignments =\r
- TransformationUtils.getListfromJson(resourceAssignmentContents, ResourceAssignment.class);\r
- if (assignments != null) {\r
- Map<String, Object> componentContext = new HashMap<>();\r
- componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, "sample-recipe");\r
- for (ResourceAssignment resourceAssignment : assignments) {\r
- if (resourceAssignment != null && resourceAssignment.getProperty() != null) {\r
- String type = resourceAssignment.getProperty().getType();\r
- Object value = null;\r
- if (ValidTypes.DATA_TYPE_STRING.equals(type)) {\r
- value = new String("abcdef");\r
- } else if (ValidTypes.DATA_TYPE_INTEGER.equals(type)) {\r
- value = new Integer(1234);\r
- } else if (ValidTypes.DATA_TYPE_BOOLEAN.equals(type)) {\r
- value = new Boolean(true);\r
- } else if (ValidTypes.DATA_TYPE_LIST.equals(type)) {\r
- String entityType = resourceAssignment.getProperty().getEntrySchema().getType();\r
- if (ValidTypes.DATA_TYPE_STRING.equals(entityType)) {\r
- value = "[\"abcd-array\"]";\r
- } else {\r
- String content = "[{\"name\" : \"abcd-array-complex\"}]";\r
- JsonNode node = TransformationUtils.getJsonNodeForString(content);\r
- value = node;\r
- }\r
- } else {\r
- String content = "{\"name\" : \"abcd-complex\"}";\r
- JsonNode node = TransformationUtils.getJsonNodeForString(content);\r
- value = node;\r
- }\r
- ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, value);\r
- }\r
- }\r
- String generatedData = ResourceAssignmentUtils.generateResourceDataForAssignments(assignments);\r
- logger.trace("Generated Data " + generatedData);\r
-\r
- Assert.assertNotNull("Failed to generate resource data", generatedData);\r
- }\r
- } catch (Exception e) {\r
- e.printStackTrace();\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
- 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
- Assert.assertNotNull("Failed to generate resource data", generatedData);\r
- }\r
- } catch (Exception e) {\r
- e.printStackTrace();\r
- }\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.assignment.service;\r
-\r
-import java.io.IOException;\r
-import java.nio.charset.Charset;\r
-import java.util.List;\r
-import org.apache.commons.io.IOUtils;\r
-import org.junit.Assert;\r
-import org.junit.Rule;\r
-import org.junit.Test;\r
-import org.junit.rules.ExpectedException;\r
-import org.onap.ccsdk.features.model.ConfigModelException;\r
-import org.onap.ccsdk.features.model.data.ResourceAssignment;\r
-import org.onap.ccsdk.features.model.utils.TransformationUtils;\r
-import org.onap.ccsdk.features.model.validator.ResourceAssignmentValidator;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class ResourceAssignmentValidation {\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceAssignmentValidation.class);\r
-\r
- @Rule\r
- public final ExpectedException exception = ExpectedException.none();\r
-\r
- @Test\r
- public void testValidateSuccess() {\r
- try {\r
- logger.info(" **************** testValidateSuccess *****************");\r
- String resourceMapping = IOUtils.toString(\r
- TopologicalSortingTest.class.getClassLoader().getResourceAsStream("validation/success.json"),\r
- Charset.defaultCharset());\r
-\r
- List<ResourceAssignment> assignments =\r
- TransformationUtils.getListfromJson(resourceMapping, ResourceAssignment.class);\r
- if (assignments != null) {\r
- ResourceAssignmentValidator resourceAssignmentValidator = new ResourceAssignmentValidator(assignments);\r
-\r
- boolean result = resourceAssignmentValidator.validateResourceAssignment();\r
- Assert.assertTrue("Failed to Validate", result);\r
- }\r
- } catch (Exception e) {\r
- e.printStackTrace();\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
- 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
- @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
- List<ResourceAssignment> assignments =\r
- TransformationUtils.getListfromJson(resourceMapping, ResourceAssignment.class);\r
- if (assignments != null) {\r
- ResourceAssignmentValidator resourceAssignmentValidator = new ResourceAssignmentValidator(assignments);\r
-\r
- resourceAssignmentValidator.validateResourceAssignment();\r
- }\r
-\r
- }\r
-}\r
+++ /dev/null
-/*\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.features.assignment.service;\r
-\r
-import java.nio.charset.Charset;\r
-import java.util.List;\r
-import org.apache.commons.io.IOUtils;\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.onap.ccsdk.features.assignment.processor.ResourceAssignmentProcessor;\r
-import org.onap.ccsdk.features.model.data.ResourceAssignment;\r
-import org.onap.ccsdk.features.model.utils.TransformationUtils;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class TopologicalSortingTest {\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(TopologicalSortingTest.class);\r
-\r
- @Test\r
- public void testBulkSequencingMapping() {\r
- try {\r
- logger.info(" **************** Bulk Sequencing Default *****************");\r
- String resourceMapping = IOUtils.toString(\r
- TopologicalSortingTest.class.getClassLoader().getResourceAsStream("mapping/dependency.json"),\r
- Charset.defaultCharset());\r
-\r
- List<ResourceAssignment> assignments =\r
- TransformationUtils.getListfromJson(resourceMapping, ResourceAssignment.class);\r
- if (assignments != null) {\r
- SvcLogicContext ctx = new SvcLogicContext();\r
- ResourceAssignmentProcessor resourceAssignmentProcessor =\r
- new ResourceAssignmentProcessor(assignments, ctx);\r
- List<List<ResourceAssignment>> sequenceBatchResourceAssignment = resourceAssignmentProcessor.process();\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
- }\r
- } catch (Exception e) {\r
- e.printStackTrace();\r
- }\r
- }\r
-\r
-}\r
+++ /dev/null
-[\r
- {\r
- "name": "vnf-id-string",\r
- "property": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "input-param": true,\r
- "dictionary-name": "vnf-id-string",\r
- "dictionary-source": "input",\r
- "version": 0,\r
- "status": "success",\r
- "updated-by": "System"\r
- },\r
- {\r
- "name": "vnf-id-integer",\r
- "property": {\r
- "required": true,\r
- "type": "integer"\r
- },\r
- "input-param": true,\r
- "dictionary-name": "vnf-id-integer",\r
- "dictionary-source": "input",\r
- "version": 0,\r
- "status": "success",\r
- "updated-by": "System"\r
- },\r
- {\r
- "name": "vnf-boolean",\r
- "property": {\r
- "required": true,\r
- "type": "boolean"\r
- },\r
- "input-param": true,\r
- "dictionary-name": "vnf-boolean",\r
- "dictionary-source": "input",\r
- "version": 0,\r
- "status": "success",\r
- "updated-by": "System"\r
- },\r
- {\r
- "name": "vnf-complex",\r
- "property": {\r
- "required": true,\r
- "type": "dt-complex"\r
- },\r
- "input-param": true,\r
- "dictionary-name": "vnf-complex",\r
- "dictionary-source": "input",\r
- "version": 0,\r
- "status": "success",\r
- "updated-by": "System"\r
- },\r
- {\r
- "name": "vnf-id-array",\r
- "property": {\r
- "required": true,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "string"\r
- }\r
- },\r
- "input-param": true,\r
- "dictionary-name": "vnf-id-array",\r
- "dictionary-source": "input",\r
- "version": 0,\r
- "status": "success",\r
- "updated-by": "System"\r
- },\r
- {\r
- "name": "vnf-array-complex",\r
- "property": {\r
- "required": true,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "dt-complex"\r
- }\r
- },\r
- "input-param": true,\r
- "dictionary-name": "vnf-array-complex",\r
- "dictionary-source": "input",\r
- "version": 0,\r
- "status": "success",\r
- "updated-by": "System"\r
- }\r
-]\r
+++ /dev/null
-[\r
- {\r
- "name": "vnf-id-string",\r
- "property": {\r
- "required": true,\r
- "type": "string",\r
- "value": "123456"\r
- },\r
- "input-param": true,\r
- "dictionary-name": "vnf-id-string",\r
- "dictionary-source": "input",\r
- "version": 0,\r
- "status": "success",\r
- "updated-by": "System"\r
- },\r
- {\r
- "name": "vnf-id-integer",\r
- "property": {\r
- "required": true,\r
- "type": "integer",\r
- "value": 123456\r
- },\r
- "input-param": true,\r
- "dictionary-name": "vnf-id-integer",\r
- "dictionary-source": "input",\r
- "version": 0,\r
- "status": "success",\r
- "updated-by": "System"\r
- },\r
- {\r
- "name": "vnf-boolean",\r
- "property": {\r
- "required": true,\r
- "type": "boolean",\r
- "value": true\r
- },\r
- "input-param": true,\r
- "dictionary-name": "vnf-boolean",\r
- "dictionary-source": "input",\r
- "version": 0,\r
- "status": "success",\r
- "updated-by": "System"\r
- },\r
- {\r
- "name": "vnf-complex",\r
- "property": {\r
- "required": true,\r
- "type": "dt-complex",\r
- "value": {\r
- "name": "Brinda",\r
- "location": "Madurai",\r
- "count": 2\r
- }\r
- },\r
- "input-param": true,\r
- "dictionary-name": "vnf-complex",\r
- "dictionary-source": "input",\r
- "version": 0,\r
- "status": "success",\r
- "updated-by": "System"\r
- },\r
- {\r
- "name": "vnf-id-array",\r
- "property": {\r
- "required": true,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "string"\r
- },\r
- "value": [\r
- "A",\r
- "B",\r
- "C"\r
- ]\r
- },\r
- "input-param": true,\r
- "dictionary-name": "vnf-id-array",\r
- "dictionary-source": "input",\r
- "version": 0,\r
- "status": "success",\r
- "updated-by": "System"\r
- },\r
- {\r
- "name": "vnf-array-complex",\r
- "property": {\r
- "required": true,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "dt-complex"\r
- },\r
- "value": [\r
- {\r
- "name": "A"\r
- },\r
- {\r
- "name": "B"\r
- },\r
- {\r
- "name": "C"\r
- }\r
- ]\r
- },\r
- "input-param": true,\r
- "dictionary-name": "vnf-array-complex",\r
- "dictionary-source": "input",\r
- "version": 0,\r
- "status": "success",\r
- "updated-by": "System"\r
- }\r
-]\r
+++ /dev/null
-[]
\ No newline at end of file
+++ /dev/null
-{\r
- "locations": [\r
- {\r
- "mdsal-country": "US",\r
- "mdsal-state": "NJ"\r
- },\r
- {\r
- "mdsal-country": "INDIA",\r
- "mdsal-state": "TN"\r
- }\r
- ]\r
-}\r
+++ /dev/null
-{
- "v4-assigned-ip-list": [
- {
- "v4-ip-type": "NMLAN",
- "ipv4-gateway-prefix": "10.66.1.129",
- "v4-ip-prefix": "10.66.1.152",
- "v4-ip-prefix-length": 32,
- "ip-count": 1,
- "v4-ip-source": "EIPAM",
- "client-key": "ADIG_19_vnf_name061rej01"
- }
- ]
-}
+++ /dev/null
-{\r
- "locations": {\r
- "mdsal-country": "US",\r
- "mdsal-state": "NJ"\r
- }\r
-}\r
+++ /dev/null
-{\r
- "vnf-topology-information": {\r
- "vnf-assignments": {\r
- "availability-zones": [\r
- {\r
- "availability-zone": "frkde-esx-az01"\r
- }\r
- ],\r
- "vnf-vms": [\r
- {\r
- "vm-type": "vre",\r
- "vm-count": 1,\r
- "vm-networks": [\r
- {\r
- "network-role": "ADIGOam.OAM",\r
- "network-name": "ADIGOAM.OAM",\r
- "v4-assigned-ip-list": [\r
- {\r
- "v4-ip-type": "NMLAN",\r
- "ipv4-gateway-prefix": "10.66.1.129",\r
- "v4-ip-prefix": "10.66.1.152",\r
- "v4-ip-prefix-length": 32,\r
- "ip-count": 1,\r
- "v4-ip-source": "EIPAM",\r
- "client-key": "ADIG_19_vnf_name061rej01"\r
- }\r
- ],\r
- "network-id": "VPEADIG1d77c-1086-41ec-b7f3-94bb30936807"\r
- },\r
- {\r
- "network-role": "Internal-Network",\r
- "network-name": "VMX-INTTERNAL056",\r
- "v4-assigned-ip-list": [\r
- {\r
- "v4-ip-type": "INTERNAL",\r
- "v4-ip-prefix": "128.0.0.1",\r
- "ipv4-prefix-block": "128.0.0.0",\r
- "v4-ip-prefix-length": 24,\r
- "v4-ip-source": "OTHER"\r
- }\r
- ],\r
- "network-forwarding": "l2",\r
- "network-id": "VMX-INT1"\r
- }\r
- ],\r
- "vm-names": [\r
- {\r
- "vm-name": "ADIG_19_vnf_name061rej",\r
- "vm-uuid": "50d2032d-fe15-4e82-94f3-8b73c566a345"\r
- }\r
- ]\r
- },\r
- {\r
- "vm-type": "vpfe",\r
- "vm-count": 1,\r
- "vm-networks": [\r
- {\r
- "network-role": "ADIG_SRIOV_3",\r
- "network-name": "ADIG_SRIOV_3",\r
- "multicast-allow": true,\r
- "broadcast-allow": true,\r
- "network-id": "VPEADIG1d77c-1086-41ec-b7f3-94bb30936810",\r
- "vlan-filter": "[4013,4014]",\r
- "network-macs": [\r
- {\r
- "mac-address": "dc:38:e1:69:bf:5f"\r
- }\r
- ],\r
- "vlan-strip": false,\r
- "unicast-allow": true\r
- },\r
- {\r
- "network-role": "ADIG_SRIOV_4",\r
- "network-name": "ADIG_SRIOV_4",\r
- "multicast-allow": true,\r
- "broadcast-allow": true,\r
- "network-id": "VPEADIG1d77c-1086-41ec-b7f3-94bb30936811",\r
- "vlan-filter": "[4013,4014]",\r
- "network-macs": [\r
- {\r
- "mac-address": "dc:38:e1:69:bf:5f"\r
- }\r
- ],\r
- "vlan-strip": false,\r
- "unicast-allow": true\r
- },\r
- {\r
- "network-role": "ADIG_SRIOV_1",\r
- "network-name": "ADIG_SRIOV_1",\r
- "multicast-allow": true,\r
- "broadcast-allow": true,\r
- "network-id": "VPEADIG1d77c-1086-41ec-b7f3-94bb30936808",\r
- "vlan-filter": "[4013,4014]",\r
- "network-macs": [\r
- {\r
- "mac-address": "dc:38:e1:69:bf:5f"\r
- }\r
- ],\r
- "vlan-strip": false,\r
- "unicast-allow": true\r
- },\r
- {\r
- "network-role": "ADIG_SRIOV_2",\r
- "network-name": "ADIG_SRIOV_2",\r
- "multicast-allow": true,\r
- "broadcast-allow": true,\r
- "network-id": "VPEADIG1d77c-1086-41ec-b7f3-94bb30936809",\r
- "vlan-filter": "[4013,4014]",\r
- "network-macs": [\r
- {\r
- "mac-address": "dc:38:e1:69:bf:5f"\r
- }\r
- ],\r
- "vlan-strip": false,\r
- "unicast-allow": true\r
- },\r
- {\r
- "network-role": "Internal-Network",\r
- "network-name": "VMX-INTTERNAL056",\r
- "v4-assigned-ip-list": [\r
- {\r
- "v4-ip-type": "INTERNAL",\r
- "v4-ip-prefix": "128.0.0.16",\r
- "ipv4-prefix-block": "128.0.0.0",\r
- "v4-ip-prefix-length": 24,\r
- "v4-ip-source": "OTHER"\r
- }\r
- ],\r
- "network-forwarding": "l2",\r
- "network-id": "VMX-INT1"\r
- }\r
- ],\r
- "vm-names": [\r
- {\r
- "vm-name": "ADIG_19_vnf_name056fej",\r
- "vm-uuid": "d2ce6023-a3ab-412e-bc63-360307aac165"\r
- }\r
- ]\r
- }\r
- ],\r
- "vnf-status": "Deactivated",\r
- "vnf-networks": [\r
- {\r
- "network-role": "ADIGOam.OAM",\r
- "network-id": "VPEADIG1d77c-1086-41ec-b7f3-94bb30936807"\r
- },\r
- {\r
- "network-role": "ADIG_SRIOV_3",\r
- "network-id": "VPEADIG1d77c-1086-41ec-b7f3-94bb30936810"\r
- },\r
- {\r
- "network-role": "ADIG_SRIOV_2",\r
- "network-id": "VPEADIG1d77c-1086-41ec-b7f3-94bb30936809"\r
- },\r
- {\r
- "network-role": "ADIG_SRIOV_4",\r
- "network-id": "VPEADIG1d77c-1086-41ec-b7f3-94bb30936811"\r
- },\r
- {\r
- "network-role": "ADIG_SRIOV_1",\r
- "network-id": "VPEADIG1d77c-1086-41ec-b7f3-94bb30936808"\r
- }\r
- ]\r
- }\r
- }\r
-}\r
+++ /dev/null
-{\r
- "version": "1.0.0",\r
- "description": "test Data Type",\r
- "properties": {\r
- "country": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "state": {\r
- "required": false,\r
- "type": "string"\r
- }\r
- },\r
- "derived_from": "tosca.datatypes.Root"\r
-}\r
+++ /dev/null
-{
- "version": "1.0.0",
- "description": "This is dt-v4-assigned-ip-list Data Type",
- "properties": {
- "v4-ip-type": {
- "required": true,
- "type": "string"
- },
- "ipv4-gateway-prefix": {
- "required": true,
- "type": "string"
- },
- "v4-ip-prefix": {
- "required": true,
- "type": "string"
- },
- "v4-ip-prefix-length": {
- "required": true,
- "type": "string"
- },
- "v4-ip-source": {
- "required": true,
- "type": "string"
- }
- },
- "derived_from": "tosca.datatypes.Root"
-}
+++ /dev/null
-{\r
- "v4-ip-prefix": {\r
- "name": "v4-ip-prefix",\r
- "property": {\r
- "type": "string"\r
- },\r
- "sources": {\r
- "mdsal": {\r
- "type": "source-mdsal",\r
- "properties": {\r
- "url-path": "/restconf/config/L3VNF-API:services/service-list/$service-instance-id/service-data/vnf-topology-information/vnf-assignments/vnf-vms/$oam-ipv4-ip-type/vm-networks/$oam-network-role/v4-assigned-ip-list/$oam-vm-type",\r
- "path": "/v4-assigned-ip-list/0/v4-ip-prefix",\r
- "input-key-mapping": {\r
- "service-instance-id": "service-instance-id",\r
- "oam-network-role": "oam-network-role",\r
- "oam-ipv4-ip-type": "oam-ipv4-ip-type",\r
- "oam-vm-type": "oam-vm-type"\r
- },\r
- "output-key-mapping": {\r
- "v4-ip-prefix": "v4-ip-prefix"\r
- },\r
- "key-dependencies": [\r
- "service-instance-id",\r
- "oam-network-role",\r
- "oam-ipv4-ip-type",\r
- "oam-vm-type"\r
- ]\r
- }\r
- }\r
- }\r
- },\r
- "service-instance-id": {\r
- "name": "service-instance-id",\r
- "property": {\r
- "type": "string"\r
- },\r
- "sources": {\r
- "default": {\r
- "type": "source-input"\r
- }\r
- }\r
- },\r
- "oam-network-role": {\r
- "name": "oam-network-role",\r
- "property": {\r
- "type": "string"\r
- },\r
- "sources": {\r
- "default": {\r
- "type": "source-input"\r
- }\r
- }\r
- },\r
- "oam-ipv4-ip-type": {\r
- "name": "oam-ipv4-ip-type",\r
- "property": {\r
- "type": "string"\r
- },\r
- "sources": {\r
- "default": {\r
- "type": "source-input"\r
- }\r
- }\r
- },\r
- "oam-vm-type": {\r
- "name": "oam-vm-type",\r
- "property": {\r
- "type": "string"\r
- },\r
- "sources": {\r
- "default": {\r
- "type": "source-input"\r
- }\r
- }\r
- }\r
-}\r
+++ /dev/null
-{\r
- "locations": {\r
- "name": "locations",\r
- "property": {\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "dt-location"\r
- }\r
- },\r
- "sources": {\r
- "mdsal": {\r
- "type": "source-mdsal",\r
- "properties": {\r
- "url-path": "/restconf/config/L3VNF-API/services/service-list/$profile_name/12345",\r
- "path": "/locations",\r
- "input-key-mapping": {\r
- "profile_name": "profile_name"\r
- },\r
- "output-key-mapping": {\r
- "mdsal-country": "country",\r
- "mdsal-state": "state"\r
- },\r
- "key-dependencies": [\r
- "profile_name"\r
- ]\r
- }\r
- }\r
- }\r
- },\r
- "profile_name": {\r
- "name": "profile_name",\r
- "property": {\r
- "type": "string"\r
- },\r
- "sources": {\r
- "default": {\r
- "type": "source-input"\r
- }\r
- }\r
- }\r
-}\r
-\r
+++ /dev/null
-{\r
- "location": {\r
- "name": "location",\r
- "property": {\r
- "type": "dt-location"\r
- },\r
- "sources": {\r
- "mdsal": {\r
- "type": "source-mdsal",\r
- "properties": {\r
- "url-path": "/restconf/config/L3VNF-API/services/service-list/$profile_name/12345",\r
- "path": "/locations",\r
- "input-key-mapping": {\r
- "profile_name": "profile_name"\r
- },\r
- "output-key-mapping": {\r
- "mdsal-country": "country",\r
- "mdsal-state": "state"\r
- },\r
- "key-dependencies": [\r
- "profile_name"\r
- ]\r
- }\r
- }\r
- }\r
- },\r
- "profile_name": {\r
- "name": "profile_name",\r
- "property": {\r
- "type": "string"\r
- },\r
- "sources": {\r
- "default": {\r
- "type": "source-input"\r
- }\r
- }\r
- }\r
-}\r
+++ /dev/null
-{\r
- "country": {\r
- "name": "country",\r
- "property": {\r
- "type": "string"\r
- },\r
- "sources": {\r
- "mdsal": {\r
- "type": "source-mdsal",\r
- "properties": {\r
- "url-path": "/restconf/config/L3VNF-API/services/service-list/$profile_name/12345",\r
- "path": "/locations",\r
- "input-key-mapping": {\r
- "profile_name": "profile_name"\r
- },\r
- "output-key-mapping": {\r
- "country": "country"\r
- },\r
- "key-dependencies": [\r
- "profile_name"\r
- ]\r
- }\r
- }\r
- }\r
- },\r
- "profile_name": {\r
- "name": "profile_name",\r
- "property": {\r
- "type": "string"\r
- },\r
- "sources": {\r
- "input": {\r
- "type": "source-input"\r
- }\r
- }\r
- }\r
-}\r
+++ /dev/null
-[\r
- {\r
- "name": "locations",\r
- "input-param": true,\r
- "property": {\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "dt-location"\r
- }\r
- },\r
- "dictionary-name": "locations",\r
- "dictionary-source": "mdsal",\r
- "dependencies": []\r
- }\r
-]\r
+++ /dev/null
-[\r
- {\r
- "name": "v4-ip-prefix",\r
- "input-param": true,\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "v4-ip-prefix",\r
- "dictionary-source": "mdsal",\r
- "dependencies": []\r
- }\r
-]\r
+++ /dev/null
-[\r
- {\r
- "name": "location",\r
- "input-param": true,\r
- "property": {\r
- "type": "dt-location"\r
- },\r
- "dictionary-name": "location",\r
- "dictionary-source": "mdsal",\r
- "dependencies": []\r
- }\r
-]\r
+++ /dev/null
-[\r
- {\r
- "name": "country",\r
- "input-param": true,\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "country",\r
- "dictionary-source": "mdsal",\r
- "dependencies": []\r
- }\r
-]\r
+++ /dev/null
-{\r
- "locations": "US"\r
-}\r
+++ /dev/null
-{\r
- "locations": {\r
- "name": "locations",\r
- "property": {\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "dt-location"\r
- }\r
- },\r
- "sources": {\r
- "db": {\r
- "type": "source-sdnctl-db",\r
- "properties": {\r
- "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name",\r
- "input-key-mapping": {\r
- "profile_name": "profile_name"\r
- },\r
- "output-key-mapping": {\r
- "db-country": "country",\r
- "db-state": "state"\r
- },\r
- "key-dependencies": [\r
- "profile_name"\r
- ]\r
- }\r
- }\r
- }\r
- },\r
- "profile_name": {\r
- "name": "profile_name",\r
- "property": {\r
- "type": "string"\r
- },\r
- "sources": {\r
- "input": {\r
- "type": "source-input"\r
- }\r
- }\r
- }\r
-}
\ No newline at end of file
+++ /dev/null
-{\r
- "location": {\r
- "name": "location",\r
- "property": {\r
- "type": "dt-location"\r
- },\r
- "sources": {\r
- "db": {\r
- "type": "source-sdnctl-db",\r
- "properties": {\r
- "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name",\r
- "input-key-mapping": {\r
- "profile_name": "profile_name"\r
- },\r
- "output-key-mapping": {\r
- "db-country": "country",\r
- "db-state": "state"\r
- },\r
- "key-dependencies": [\r
- "profile_name"\r
- ]\r
- }\r
- }\r
- }\r
- },\r
- "profile_name": {\r
- "name": "profile_name",\r
- "property": {\r
- "type": "string"\r
- },\r
- "sources": {\r
- "input": {\r
- "type": "source-input"\r
- }\r
- }\r
- }\r
-}\r
+++ /dev/null
-{\r
- "country": {\r
- "name": "country",\r
- "property": {\r
- "type": "string"\r
- },\r
- "sources": {\r
- "db": {\r
- "type": "source-sdnctl-db",\r
- "properties": {\r
- "query": "SELECT country FROM DEVICE_PROFILE WHERE profile_name = :profile_name",\r
- "input-key-mapping": {\r
- "profile_name": "profile_name"\r
- },\r
- "output-key-mapping": {\r
- "country": "country"\r
- },\r
- "key-dependencies": [\r
- "profile_name"\r
- ]\r
- }\r
- }\r
- }\r
- },\r
- "profile_name": {\r
- "name": "profile_name",\r
- "property": {\r
- "type": "string"\r
- },\r
- "sources": {\r
- "input": {\r
- "type": "source-input"\r
- }\r
- }\r
- }\r
-}\r
+++ /dev/null
-{\r
- "version": "1.0.0",\r
- "description": "test Data Type",\r
- "properties": {\r
- "country": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "state": {\r
- "required": false,\r
- "type": "string"\r
- }\r
- },\r
- "derived_from": "tosca.datatypes.Root"\r
-}\r
+++ /dev/null
-[\r
- {\r
- "name": "locations",\r
- "input-param": true,\r
- "property": {\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "dt-location"\r
- }\r
- },\r
- "dictionary-name": "locations",\r
- "dictionary-source": "db",\r
- "dependencies": []\r
- }\r
-]\r
+++ /dev/null
-[\r
- {\r
- "name": "location",\r
- "input-param": true,\r
- "property": {\r
- "type": "dt-location"\r
- },\r
- "dictionary-name": "location",\r
- "dictionary-source": "db",\r
- "dependencies": []\r
- }\r
-]\r
+++ /dev/null
-[\r
- {\r
- "name": "country",\r
- "input-param": true,\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "country",\r
- "dictionary-source": "db",\r
- "dependencies": []\r
- }\r
-]\r
+++ /dev/null
-{\r
- "country": {\r
- "name": "country",\r
- "property": {\r
- "type": "string"\r
- },\r
- "sources": {\r
- "default": {\r
- "type": "source-default"\r
- }\r
- }\r
- },\r
- "port": {\r
- "name": "port",\r
- "property": {\r
- "type": "integer"\r
- },\r
- "sources": {\r
- "default": {\r
- "type": "source-default"\r
- }\r
- }\r
- },\r
- "voip-enabled": {\r
- "name": "voip-enabled",\r
- "property": {\r
- "type": "boolean"\r
- },\r
- "sources": {\r
- "default": {\r
- "type": "source-default"\r
- }\r
- }\r
- }\r
-}\r
+++ /dev/null
-[\r
- {\r
- "name": "country",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "default": "US"\r
- },\r
- "dictionary-name": "country",\r
- "dictionary-source": "default",\r
- "dependencies": []\r
- },\r
- {\r
- "name": "port",\r
- "input-param": true,\r
- "property": {\r
- "type": "integer",\r
- "default": 830\r
- },\r
- "dictionary-name": "port",\r
- "dictionary-source": "default",\r
- "dependencies": []\r
- },\r
- {\r
- "name": "voip-enabled",\r
- "input-param": true,\r
- "property": {\r
- "type": "boolean",\r
- "default": true\r
- },\r
- "dictionary-name": "voip-enabled",\r
- "dictionary-source": "default",\r
- "dependencies": []\r
- }\r
-]\r
+++ /dev/null
-[\r
- {\r
- "name": "vnf-id",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "vnf-id",\r
- "dictionary-source": "input",\r
- "dependencies": []\r
- },\r
- {\r
- "name": "service-instance-id",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "service-instance-id",\r
- "dictionary-source": "input",\r
- "dependencies": []\r
- },\r
- {\r
- "name": "bundle-id",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "bundle-id",\r
- "dictionary-source": "mdsal",\r
- "dependencies": [\r
- "vnf-id"\r
- ]\r
- },\r
- {\r
- "name": "bundle-ip",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "bundle-ip",\r
- "dictionary-source": "mdsal",\r
- "dependencies": [\r
- "vnf-id"\r
- ]\r
- },\r
- {\r
- "name": "bundle-mac",\r
- "input-param": true,\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "bundle-mac",\r
- "dictionary-source": "mdsal",\r
- "dependencies": [\r
- "vnf-id",\r
- "bundle-id"\r
- ]\r
- },\r
- {\r
- "name": "managed-ip",\r
- "input-param": true,\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "managed-ip",\r
- "dictionary-source": "mdsal",\r
- "dependencies": [\r
- "loopback-ip"\r
- ]\r
- },\r
- {\r
- "name": "vnf-name",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "vnf-name",\r
- "dictionary-source": "input",\r
- "dependencies": []\r
- },\r
- {\r
- "name": "managed-ip1",\r
- "input-param": true,\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "managed-ip1",\r
- "dictionary-source": "mdsal",\r
- "dependencies": [\r
- "loopback-ip"\r
- ]\r
- },\r
- {\r
- "name": "loopback-ip",\r
- "input-param": true,\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "loopback-ip",\r
- "dictionary-source": "db",\r
- "dependencies": [\r
- "bundle-mac"\r
- ]\r
- }\r
-]\r
+++ /dev/null
-{\r
- "version": "1.0.0",\r
- "description": "test Data Type",\r
- "properties": {\r
- "country": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "state": {\r
- "required": false,\r
- "type": "string"\r
- }\r
- },\r
- "derived_from": "tosca.datatypes.Root"\r
-}\r
+++ /dev/null
-{\r
- "location": {\r
- "name": "location",\r
- "property": {\r
- "type": "dt-location"\r
- },\r
- "sources": {\r
- "default": {\r
- "type": "source-input"\r
- }\r
- }\r
- },\r
- "profile_name": {\r
- "name": "profile_name",\r
- "property": {\r
- "type": "string"\r
- },\r
- "sources": {\r
- "default": {\r
- "type": "source-input"\r
- }\r
- }\r
- }\r
-}\r
+++ /dev/null
-{\r
- "country": {\r
- "name": "country",\r
- "property": {\r
- "type": "string"\r
- },\r
- "sources": {\r
- "default": {\r
- "type": "source-input"\r
- }\r
- }\r
- },\r
- "port": {\r
- "name": "port",\r
- "property": {\r
- "type": "integer"\r
- },\r
- "sources": {\r
- "default": {\r
- "type": "source-input"\r
- }\r
- }\r
- },\r
- "voip-enabled": {\r
- "name": "voip-enabled",\r
- "property": {\r
- "type": "boolean"\r
- },\r
- "sources": {\r
- "default": {\r
- "type": "source-input"\r
- }\r
- }\r
- }\r
-}\r
+++ /dev/null
-[\r
- {\r
- "name": "location",\r
- "input-param": true,\r
- "property": {\r
- "type": "dt-location",\r
- "required": true\r
- },\r
- "dictionary-name": "location",\r
- "dictionary-source": "input",\r
- "dependencies": []\r
- }\r
-]\r
+++ /dev/null
-[\r
- {\r
- "name": "country",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "default": "US"\r
- },\r
- "dictionary-source": "input",\r
- "dependencies": []\r
- },\r
- {\r
- "name": "port",\r
- "input-param": true,\r
- "property": {\r
- "type": "integer",\r
- "default": 830\r
- },\r
- "dictionary-source": "input",\r
- "dependencies": []\r
- },\r
- {\r
- "name": "voip-enabled",\r
- "input-param": true,\r
- "property": {\r
- "type": "boolean",\r
- "default": true\r
- },\r
- "dictionary-source": "input",\r
- "dependencies": []\r
- }\r
-]\r
+++ /dev/null
-{\r
- "country": "US",\r
- "state": "NJ"\r
-}\r
+++ /dev/null
-{\r
- "api-ver": "2.00",\r
- "originator-id": "MSO",\r
- "request-id": "123456",\r
- "service-instance-id": "ibcx0001vm001",\r
- "service-type": "AVPN",\r
- "vnf-type": "vUSP - vDBE-IPX HUB",\r
- "vnf-id": 123456,\r
- "service-template-name": "VRR-baseconfiguration",\r
- "service-template-version": "1.0.0",\r
- "action-name": "resource-assignment-action",\r
- "group-name": "sample group name",\r
- "bundle-id": "sample bundle id",\r
- "bundle-mac": [\r
- "Sample bundle mac",\r
- "Sample bundle mac"\r
- ]\r
-}\r
+++ /dev/null
-{\r
- "api-ver": "2.00",\r
- "originator-id": "MSO",\r
- "request-id": "123456",\r
- "service-instance-id": "ibcx0001vm001",\r
- "service-type": "AVPN",\r
- "vnf-type": "vUSP - vDBE-IPX HUB",\r
- "vnf-id": "",\r
- "service-template-name": "VRR-baseconfiguration",\r
- "service-template-version": "1.0.0",\r
- "action-name": "resource-assignment-action",\r
- "group-name": "sample group name",\r
- "bundle-id": "sample bundle id",\r
- "bundle-mac": [\r
- "Sample bundle mac",\r
- "Sample bundle mac"\r
- ]\r
-}\r
+++ /dev/null
-{\r
- "metadata": {\r
- "author": "ks220y@att.com",\r
- "service-template-name": "VRR-baseconfiguration",\r
- "service-template-version": "1.0.0",\r
- "release": "1802",\r
- "service-type": "AVPN",\r
- "vnf-type": "VRR"\r
- },\r
- "topology_template": {\r
- "inputs": {\r
- "request-id": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "service-instance-id": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "action-name": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "scope-type": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "hostname": {\r
- "required": true,\r
- "type": "string"\r
- }\r
- },\r
- "node_templates": {\r
- "base-config-template": {\r
- "type": "artifact-config-template",\r
- "properties": {\r
- "action-names": [\r
- "resource-assignment-action"\r
- ]\r
- },\r
- "capabilities": {\r
- "content": {\r
- "properties": {\r
- "content": "db://base-config-template"\r
- }\r
- },\r
- "mapping": {\r
- "properties": {\r
- "mapping": [\r
- {\r
- "name": "vnf-id",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "vnf-id",\r
- "dictionary-source": "input"\r
- },\r
- {\r
- "name": "group-name",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "group-name",\r
- "dictionary-source": "input"\r
- }\r
- ]\r
- }\r
- }\r
- }\r
- },\r
- "resource-assignment-action": {\r
- "type": "dg-resource-assignment",\r
- "interfaces": {\r
- "CONFIG": {\r
- "operations": {\r
- "ResourceAssignment": {\r
- \r
- }\r
- }\r
- }\r
- },\r
- "capabilities": {\r
- "dg-node": {\r
- \r
- }\r
- },\r
- "requirements": {\r
- "component-dependency": {\r
- "capability": "component-node",\r
- "node": "resource-assignment",\r
- "relationship": "tosca.relationships.DependsOn"\r
- }\r
- }\r
- },\r
- "licence-template": {\r
- "type": "artifact-config-template",\r
- "properties": {\r
- "action-names": [\r
- "resource-assignment-action"\r
- ]\r
- },\r
- "capabilities": {\r
- "content": {\r
- "properties": {\r
- "content": "db://licence-template"\r
- }\r
- },\r
- "mapping": {\r
- "properties": {\r
- "mapping": [\r
- {\r
- "name": "bundle-id",\r
- "input-param": true,\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "bundle-id",\r
- "dictionary-source": "input"\r
- },\r
- {\r
- "name": "bundle-mac",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "bundle-mac",\r
- "dictionary-source": "input"\r
- }\r
- ]\r
- }\r
- }\r
- }\r
- },\r
- "resource-assignment": {\r
- "type": "component-resource-assignment",\r
- "interfaces": {\r
- "org-onap-ccsdk-features-assignment-service-ConfigAssignmentNode": {\r
- "operations": {\r
- "process": {\r
- "inputs": {\r
- "action-name": "{ \"get_input\" : \"action-name\" }",\r
- "resource-type": "vnf-type",\r
- "template-names": [\r
- "base-config-template",\r
- "licence-template"\r
- ],\r
- "request-id": "{ \"get_input\" : \"request-id\" }",\r
- "resource-id": "{ \"get_input\" : \"vnf-id\" }"\r
- },\r
- "outputs": {\r
- "resource-assignment-params": "",\r
- "status": ""\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "capabilities": {\r
- "component-node": {\r
- \r
- }\r
- }\r
- }\r
- }\r
- },\r
- "node_types": {\r
- "dg-resource-assignment": {\r
- "description": "This is Resource Assignment Directed Graph",\r
- "version": "1.0.0",\r
- "properties": {\r
- "mode": {\r
- "required": false,\r
- "type": "string",\r
- "default": "sync"\r
- },\r
- "version": {\r
- "required": false,\r
- "type": "string",\r
- "default": "LATEST"\r
- },\r
- "is-start-flow": {\r
- "required": false,\r
- "type": "boolean",\r
- "default": "false"\r
- }\r
- },\r
- "capabilities": {\r
- "dg-node": {\r
- "type": "tosca.capabilities.Node"\r
- },\r
- "content": {\r
- "type": "tosca.capabilities.Content",\r
- "properties": {\r
- "type": {\r
- "required": false,\r
- "type": "string",\r
- "default": "json"\r
- },\r
- "content": {\r
- "required": true,\r
- "type": "string"\r
- }\r
- }\r
- }\r
- },\r
- "requirements": {\r
- "component-dependency": {\r
- "capability": "component-node",\r
- "node": "component-resource-assignment",\r
- "relationship": "tosca.relationships.DependsOn"\r
- }\r
- },\r
- "interfaces": {\r
- "CONFIG": {\r
- "operations": {\r
- "ResourceAssignment": {\r
- "inputs": {\r
- "params": {\r
- "required": false,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "datatype-property"\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "derived_from": "tosca.nodes.DG"\r
- },\r
- "component-resource-assignment": {\r
- "description": "This is Resource Assignment Component API",\r
- "version": "1.0.0",\r
- "capabilities": {\r
- "component-node": {\r
- "type": "tosca.capabilities.Node"\r
- }\r
- },\r
- "interfaces": {\r
- "org-onap-ccsdk-features-assignment-service-ConfigAssignmentNode": {\r
- "operations": {\r
- "process": {\r
- "inputs": {\r
- "action-name": {\r
- "description": "Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",\r
- "required": false,\r
- "type": "string"\r
- },\r
- "handler-name": {\r
- "description": "Name of the Artifact Node Template, to get the template Content. If template-content is present, then content wont be reterived from the Artifact Node Template.",\r
- "required": true,\r
- "type": "string"\r
- },\r
- "resource-type": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "template-names": {\r
- "description": "Name of the Artifact Node Templates, to get the template Content.",\r
- "required": true,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "string"\r
- }\r
- },\r
- "request-id": {\r
- "description": "Request Id used to store the generated configuration, in the database along with the template-name",\r
- "required": true,\r
- "type": "string"\r
- },\r
- "resource-id": {\r
- "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present",\r
- "required": true,\r
- "type": "string"\r
- }\r
- },\r
- "outputs": {\r
- "resource-assignment-params": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "status": {\r
- "required": true,\r
- "type": "string"\r
- }\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "derived_from": "tosca.nodes.Component"\r
- },\r
- "artifact-config-template": {\r
- "description": "This is Configuration Velocity Template",\r
- "version": "1.0.0",\r
- "properties": {\r
- "action-names": {\r
- "required": true,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "string"\r
- }\r
- },\r
- "content": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "mapping": {\r
- "required": false,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "datatype-resource-assignment"\r
- }\r
- }\r
- },\r
- "capabilities": {\r
- "content": {\r
- "type": "tosca.capabilities.Content",\r
- "properties": {\r
- "content": {\r
- "required": true,\r
- "type": "string"\r
- }\r
- }\r
- },\r
- "mapping": {\r
- "type": "tosca.capabilities.Mapping",\r
- "properties": {\r
- "mapping": {\r
- "required": false,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "datatype-resource-assignment"\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "derived_from": "tosca.nodes.Artifact"\r
- }\r
- },\r
- "data_types": {\r
- "datatype-resource-assignment": {\r
- "version": "1.0.0",\r
- "description": "This is Resource Assignment Data Type",\r
- "properties": {\r
- "property": {\r
- "required": true,\r
- "type": "datatype-property"\r
- },\r
- "input-param": {\r
- "required": true,\r
- "type": "boolean"\r
- },\r
- "dictionary-name": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "dictionary-source": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "dependencies": {\r
- "required": true,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "string"\r
- }\r
- }\r
- },\r
- "derived_from": "tosca.datatypes.Root"\r
- },\r
- "datatype-property": {\r
- "version": "1.0.0",\r
- "description": "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs",\r
- "properties": {\r
- "type": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "description": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "required": {\r
- "required": false,\r
- "type": "boolean"\r
- },\r
- "default": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "entry_schema": {\r
- "required": false,\r
- "type": "string"\r
- }\r
- },\r
- "derived_from": "tosca.datatypes.Root"\r
- }\r
- }\r
-}\r
+++ /dev/null
-{\r
- "metadata": {\r
- "author": "ks220y@att.com",\r
- "service-template-name": "VRR-baseconfiguration",\r
- "service-template-version": "1.0.0",\r
- "release": "1802",\r
- "service-type": "AVPN",\r
- "vnf-type": "VRR"\r
- },\r
- "topology_template": {\r
- "inputs": {\r
- "request-id": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "service-instance-id": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "action-name": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "scope-type": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "hostname": {\r
- "required": true,\r
- "type": "string"\r
- }\r
- },\r
- "node_templates": {\r
- "base-config-template": {\r
- "type": "artifact-config-template",\r
- "properties": {\r
- "action-names": [\r
- "resource-assignment-action"\r
- ]\r
- },\r
- "capabilities": {\r
- "content": {\r
- "properties": {\r
- "content": "db://base-config-template"\r
- }\r
- },\r
- "mapping": {\r
- "properties": {\r
- "mapping": [\r
- {\r
- "name": "vnf-id",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "vnf-id",\r
- "dictionary-source": "input"\r
- },\r
- {\r
- "name": "group-name",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "group-name",\r
- "dictionary-source": "input"\r
- }\r
- ]\r
- }\r
- }\r
- }\r
- },\r
- "resource-assignment-action": {\r
- "type": "dg-resource-assignment",\r
- "interfaces": {\r
- "CONFIG": {\r
- "operations": {\r
- "ResourceAssignment": {\r
- \r
- }\r
- }\r
- }\r
- },\r
- "capabilities": {\r
- "dg-node": {\r
- \r
- }\r
- },\r
- "requirements": {\r
- "component-dependency": {\r
- "capability": "component-node",\r
- "node": "resource-assignment",\r
- "relationship": "tosca.relationships.DependsOn"\r
- }\r
- }\r
- },\r
- "licence-template": {\r
- "type": "artifact-config-template",\r
- "properties": {\r
- "action-names": [\r
- "resource-assignment-action"\r
- ]\r
- },\r
- "capabilities": {\r
- "content": {\r
- "properties": {\r
- "content": "db://licence-template"\r
- }\r
- },\r
- "mapping": {\r
- "properties": {\r
- "mapping": [\r
- {\r
- "name": "bundle-id",\r
- "input-param": true,\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "bundle-id",\r
- "dictionary-source": "input"\r
- },\r
- {\r
- "name": "bundle-mac",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "bundle-mac",\r
- "dictionary-source": "input"\r
- }\r
- ]\r
- }\r
- }\r
- }\r
- },\r
- "resource-assignment": {\r
- "type": "component-resource-assignment",\r
- "interfaces": {\r
- "org-onap-ccsdk-features-assignment-service-ConfigAssignmentNode": {\r
- "operations": {\r
- "process": {\r
- "inputs": {\r
- "service-template-name": "VRR-baseconfiguration",\r
- "service-template-version": "1.0.0",\r
- "action-name": "{ \"get_input\" : \"action-name\" }",\r
- "resource-type": "vnf-type",\r
- "template-names": [\r
- "base-config-template",\r
- "licence-template"\r
- ],\r
- "request-id": "{ \"get_input\" : \"request-id\" }",\r
- "resource-id": "{ \"get_input\" : \"vnf-id\" }"\r
- },\r
- "outputs": {\r
- "resource-assignment-params": "",\r
- "status": ""\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "capabilities": {\r
- "component-node": {\r
- \r
- }\r
- }\r
- }\r
- }\r
- },\r
- "node_types": {\r
- "dg-resource-assignment": {\r
- "description": "This is Resource Assignment Directed Graph",\r
- "version": "1.0.0",\r
- "properties": {\r
- "mode": {\r
- "required": false,\r
- "type": "string",\r
- "default": "sync"\r
- },\r
- "version": {\r
- "required": false,\r
- "type": "string",\r
- "default": "LATEST"\r
- },\r
- "is-start-flow": {\r
- "required": false,\r
- "type": "boolean",\r
- "default": "false"\r
- }\r
- },\r
- "capabilities": {\r
- "dg-node": {\r
- "type": "tosca.capabilities.Node"\r
- },\r
- "content": {\r
- "type": "tosca.capabilities.Content",\r
- "properties": {\r
- "type": {\r
- "required": false,\r
- "type": "string",\r
- "default": "json"\r
- },\r
- "content": {\r
- "required": true,\r
- "type": "string"\r
- }\r
- }\r
- }\r
- },\r
- "requirements": {\r
- "component-dependency": {\r
- "capability": "component-node",\r
- "node": "component-resource-assignment",\r
- "relationship": "tosca.relationships.DependsOn"\r
- }\r
- },\r
- "interfaces": {\r
- "CONFIG": {\r
- "operations": {\r
- "ResourceAssignment": {\r
- "inputs": {\r
- "params": {\r
- "required": false,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "datatype-property"\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "derived_from": "tosca.nodes.DG"\r
- },\r
- "component-resource-assignment": {\r
- "description": "This is Resource Assignment Component API",\r
- "version": "1.0.0",\r
- "capabilities": {\r
- "component-node": {\r
- "type": "tosca.capabilities.Node"\r
- }\r
- },\r
- "interfaces": {\r
- "org-onap-ccsdk-features-assignment-service-ConfigAssignmentNode": {\r
- "operations": {\r
- "process": {\r
- "inputs": {\r
- "action-name": {\r
- "description": "Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",\r
- "required": false,\r
- "type": "string"\r
- },\r
- "handler-name": {\r
- "description": "Name of the Artifact Node Template, to get the template Content. If template-content is present, then content wont be reterived from the Artifact Node Template.",\r
- "required": true,\r
- "type": "string"\r
- },\r
- "resource-type": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "service-template-name": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "service-template-version": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "template-names": {\r
- "description": "Name of the Artifact Node Templates, to get the template Content.",\r
- "required": true,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "string"\r
- }\r
- },\r
- "request-id": {\r
- "description": "Request Id used to store the generated configuration, in the database along with the template-name",\r
- "required": true,\r
- "type": "string"\r
- },\r
- "resource-id": {\r
- "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present",\r
- "required": true,\r
- "type": "string"\r
- }\r
- },\r
- "outputs": {\r
- "resource-assignment-params": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "status": {\r
- "required": true,\r
- "type": "string"\r
- }\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "derived_from": "tosca.nodes.Component"\r
- },\r
- "artifact-config-template": {\r
- "description": "This is Configuration Velocity Template",\r
- "version": "1.0.0",\r
- "properties": {\r
- "action-names": {\r
- "required": true,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "string"\r
- }\r
- },\r
- "content": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "mapping": {\r
- "required": false,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "datatype-resource-assignment"\r
- }\r
- }\r
- },\r
- "capabilities": {\r
- "content": {\r
- "type": "tosca.capabilities.Content",\r
- "properties": {\r
- "content": {\r
- "required": true,\r
- "type": "string"\r
- }\r
- }\r
- },\r
- "mapping": {\r
- "type": "tosca.capabilities.Mapping",\r
- "properties": {\r
- "mapping": {\r
- "required": false,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "datatype-resource-assignment"\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "derived_from": "tosca.nodes.Artifact"\r
- }\r
- },\r
- "data_types": {\r
- "datatype-resource-assignment": {\r
- "version": "1.0.0",\r
- "description": "This is Resource Assignment Data Type",\r
- "properties": {\r
- "property": {\r
- "required": true,\r
- "type": "datatype-property"\r
- },\r
- "input-param": {\r
- "required": true,\r
- "type": "boolean"\r
- },\r
- "dictionary-name": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "dictionary-source": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "dependencies": {\r
- "required": true,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "string"\r
- }\r
- }\r
- },\r
- "derived_from": "tosca.datatypes.Root"\r
- },\r
- "datatype-property": {\r
- "version": "1.0.0",\r
- "description": "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs",\r
- "properties": {\r
- "type": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "description": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "required": {\r
- "required": false,\r
- "type": "boolean"\r
- },\r
- "default": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "entry_schema": {\r
- "required": false,\r
- "type": "string"\r
- }\r
- },\r
- "derived_from": "tosca.datatypes.Root"\r
- }\r
- }\r
-}\r
+++ /dev/null
- <config>\r
- <configuration>\r
- <groups>\r
- <name>${group-name}</name>\r
- <routing-instances>\r
- <instance>\r
- <name><*></name>\r
- <protocols>\r
- <pim>\r
- <dense-groups>\r
- <dynamic-reject />\r
- <pim-dense-group-type>\r
- <name>224.0.1.40/32</name>\r
- </pim-dense-group-type>\r
- <pim-dense-group-type>\r
- <name>224.0.1.39/32</name>\r
- </pim-dense-group-type>\r
- <pim-dense-group-type>\r
- <name>224.0.0.0/4</name>\r
- <reject />\r
- </pim-dense-group-type>\r
- </dense-groups>\r
- <rp>\r
- <auto-rp>\r
- <discovery />\r
- </auto-rp>\r
- </rp>\r
- <interface>\r
- <name><*></name>\r
- <disable />\r
- <priority>1000</priority>\r
- </interface>\r
- <reset-tracking-bit />\r
- </pim>\r
- </protocols>\r
- </instance>\r
- </routing-instances>\r
- </groups>\r
- </configuration>\r
- </config>
\ No newline at end of file
+++ /dev/null
-[\r
- {\r
- "name": "adiod-unicast-route-reflectors",\r
- "resourcePath": "vnf/protocol/adiod-unicast-route-reflectors",\r
- "resourceType": "ATT",\r
- "dataType": "list",\r
- "entrySchema": "dt-adiod-unicast-route-reflectors",\r
- "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"adiod-unicast-route-reflectors\",\r\n \"description\" : \"dd\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"vnf/protocol/adiod-unicast-route-reflectors\",\r\n \"data-type\" : \"list\",\r\n \"entry-schema\" : \"dt-adiod-unicast-route-reflectors\",\r\n \"source\" : {\r\n \"input\" : { },\r\n \"network-resource-discovery\" : {\r\n \"input-key-mapping\" : {\r\n \"complex-code-char8\" : \"complex-code-char8\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"adiod-unicast-route-reflectors\" : \"adiod-unicast-route-reflectors\"\r\n }\r\n }\r\n },\r\n \"candidate-dependency\" : {\r\n \"network-resource-discovery\" : {\r\n \"names\" : [ \"complex-code-char8\" ]\r\n }\r\n }\r\n}",\r
- "description": "dd",\r
- "tags": "ADIOD3",\r
- "creationDate": "2017-11-16T17:31:38.000+0000",\r
- "updatedBy": "ks220y@att.com"\r
- },\r
- {\r
- "name": "adiod-vpnv4-route-reflectors",\r
- "resourcePath": "vnf/servers/adiod-vpnv4-route-reflectors",\r
- "resourceType": "ATT",\r
- "dataType": "list",\r
- "entrySchema": "dt-adiod-vpnv4-route-reflectors",\r
- "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"adiod-vpnv4-route-reflectors\",\r\n \"description\" : \"To be provided\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"vnf/servers/adiod-vpnv4-route-reflectors\",\r\n \"data-type\" : \"list\",\r\n \"entry-schema\" : \"dt-adiod-vpnv4-route-reflectors\",\r\n \"source\" : {\r\n \"input\" : { }\r\n }\r\n}",\r
- "description": "To be provided",\r
- "tags": "ADIOD3",\r
- "creationDate": "2017-11-16T17:31:38.000+0000",\r
- "updatedBy": "ks220y@att.com"\r
- },\r
- {\r
- "name": "asn-region",\r
- "resourcePath": "vnf/protocols/asn-region",\r
- "resourceType": "ATT",\r
- "dataType": "string",\r
- "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"asn-region\",\r\n \"description\" : \"To be provided\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"vnf/protocols/asn-region\",\r\n \"data-type\" : \"string\",\r\n \"source\" : {\r\n \"input\" : { },\r\n \"network-resource-discovery\" : {\r\n \"input-key-mapping\" : {\r\n \"hostname\" : \"hostname\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"asn-region\" : \"asn-region\"\r\n }\r\n }\r\n },\r\n \"candidate-dependency\" : {\r\n \"network-resource-discovery\" : {\r\n \"names\" : [ \"hostname\" ]\r\n }\r\n }\r\n}",\r
- "description": "To be provided",\r
- "tags": "ADIOD3",\r
- "creationDate": "2017-11-17T11:31:29.000+0000",\r
- "updatedBy": "ks220y@att.com"\r
- },\r
- {\r
- "name": "bundle-id",\r
- "resourcePath": "vnf/interface/bundle-id",\r
- "resourceType": "ATT",\r
- "dataType": "string",\r
- "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"bundle-id\",\r\n \"description\" : \"To be provided\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"vnf/interface/bundle-id\",\r\n \"data-type\" : \"string\",\r\n \"source\" : {\r\n \"input\" : { },\r\n \"network-resource-discovery\" : {\r\n \"input-key-mapping\" : {\r\n \"hostname\" : \"hostname\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"bundle-id\" : \"bundle-id\"\r\n }\r\n }\r\n },\r\n \"candidate-dependency\" : {\r\n \"network-resource-discovery\" : {\r\n \"names\" : [ \"hostname\" ]\r\n }\r\n }\r\n}",\r
- "description": "To be provided",\r
- "tags": "ADIOD3",\r
- "creationDate": "2017-11-16T17:31:39.000+0000",\r
- "updatedBy": "ks220y@att.com"\r
- },\r
- {\r
- "name": "lo0-local-ipv4-address",\r
- "resourcePath": "vnf/interface/lo0-local-ipv4",\r
- "resourceType": "ATT",\r
- "dataType": "ipv4-address",\r
- "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"lo0-local-ipv4-address\",\r\n \"description\" : \"To be provided\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"vnf/interface/lo0-local-ipv4\",\r\n \"data-type\" : \"string\",\r\n \"source\" : {\r\n \"input\" : { },\r\n \"network-resource-discovery\" : {\r\n \"input-key-mapping\" : {\r\n \"hostname\" : \"hostname\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"lo0-local-ipv4\" : \"lo0-local-ipv4\"\r\n }\r\n }\r\n },\r\n \"candidate-dependency\" : {\r\n \"network-resource-discovery\" : {\r\n \"names\" : [ \"hostname\" ]\r\n }\r\n }\r\n}",\r
- "description": "To be provided",\r
- "tags": "ADIOD3",\r
- "creationDate": "2017-11-16T17:31:40.000+0000",\r
- "updatedBy": "ks220y@att.com"\r
- },\r
- {\r
- "name": "lo10-local-ipv4-address",\r
- "resourcePath": "vnf/interface/lo10-local-ipv4",\r
- "resourceType": "ATT",\r
- "dataType": "ipv4-address",\r
- "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"lo10-local-ipv4-address\",\r\n \"description\" : \"To be provided\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"vnf/interface/lo10-local-ipv4\",\r\n \"data-type\" : \"string\",\r\n \"source\" : {\r\n \"input\" : { },\r\n \"network-resource-discovery\" : {\r\n \"input-key-mapping\" : {\r\n \"hostname\" : \"hostname\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"lo10-local-ipv4\" : \"lo10-local-ipv4\"\r\n }\r\n }\r\n },\r\n \"candidate-dependency\" : {\r\n \"network-resource-discovery\" : {\r\n \"names\" : [ \"hostname\" ]\r\n }\r\n }\r\n}",\r
- "description": "To be provided",\r
- "tags": "ADIOD3",\r
- "creationDate": "2017-11-16T17:31:41.000+0000",\r
- "updatedBy": "ks220y@att.com"\r
- },\r
- {\r
- "name": "oam-remote-ipv4-address",\r
- "resourcePath": "vnf/oam-remote-ipv4-address",\r
- "resourceType": "ATT",\r
- "dataType": "string",\r
- "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"oam-remote-ipv4-address\",\r\n \"description\" : \"To be provided\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"vnf/oam-remote-ipv4-address\",\r\n \"data-type\" : \"string\",\r\n \"source\" : {\r\n \"input\" : {\r\n \"key\" : \"oam-remote-ipv4-address\"\r\n },\r\n \"mdsal\" : {\r\n \"base\" : \"sdnc-gc\",\r\n \"type\" : \"JSON\",\r\n \"url-path\" : \"/restconf/config/L3VNF-API\",\r\n \"path\" : \"/${services/service-list/$service-instance-id/service-data/vnf-topology-information/vnf-assignments/vnf-vms/$oam-ipv4-ip-type/vm-networks/$oam-network-role/v4-assigned-ip-list/$oam-vm-type\",\r\n \"input-key-mapping\" : {\r\n \"service-instance-id\" : \"service-instance-id\",\r\n \"oam-network-role\" : \"oam-network-role\",\r\n \"oam-ipv4-ip-type\" : \"oam-ipv4-ip-type\",\r\n \"oam-vm-type\" : \"oam-vm-type\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"oam-remote-ipv4-address\" : \"ipv4-gateway-prefix\"\r\n }\r\n }\r\n },\r\n \"candidate-dependency\" : {\r\n \"mdsal\" : {\r\n \"names\" : [ \"service-instance-id\", \"oam-network-role\", \"oam-v4-ip-type \", \"oam-vm-type\" ]\r\n }\r\n }\r\n}",\r
- "description": "To be provided",\r
- "tags": "ADIOD3",\r
- "creationDate": "2017-11-16T10:52:24.000+0000",\r
- "updatedBy": "ks220y@att.com"\r
- },\r
- {\r
- "name": "ospf-area",\r
- "resourcePath": "/ospf-area",\r
- "resourceType": "ATT",\r
- "dataType": "string",\r
- "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"ospf-area\",\r\n \"description\" : \"ospf-area\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"/ospf-area\",\r\n \"data-type\" : \"string\",\r\n \"source\" : {\r\n \"input\" : {\r\n \"key\" : \"ospf-area\"\r\n },\r\n \"network-resource-discovery\" : {\r\n \"input-key-mapping\" : {\r\n \"hostname\" : \"mainResource\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"ospf-area\" : \"ospf-area\"\r\n }\r\n }\r\n }\r\n}",\r
- "description": "ospf-area",\r
- "tags": "ADIOD3",\r
- "creationDate": "2017-11-16T10:52:24.000+0000",\r
- "updatedBy": "ks220y@att.com"\r
- },\r
- {\r
- "name": "ospf-cost",\r
- "resourcePath": "/ospf-cost",\r
- "resourceType": "ATT",\r
- "dataType": "string",\r
- "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"ospf-cost\",\r\n \"description\" : \"ospf-cost\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"/ospf-cost\",\r\n \"data-type\" : \"string\",\r\n \"source\" : {\r\n \"input\" : {\r\n \"key\" : \"ospf-cost\"\r\n },\r\n \"network-resource-discovery\" : {\r\n \"input-key-mapping\" : {\r\n \"hostname\" : \"mainResource\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"ospf-cost\" : \"ospf-cost\"\r\n }\r\n }\r\n }\r\n}",\r
- "description": "ospf-cost",\r
- "tags": "ADIOD3",\r
- "creationDate": "2017-11-16T10:52:25.000+0000",\r
- "updatedBy": "ks220y@att.com"\r
- },\r
- {\r
- "name": "si-local-ipv4-address",\r
- "resourcePath": "vnf/interface/si-local-ipv4",\r
- "resourceType": "ATT",\r
- "dataType": "string",\r
- "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"si-local-ipv4-address\",\r\n \"description\" : \"To be provided\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"vnf/interface/si-local-ipv4\",\r\n \"data-type\" : \"string\",\r\n \"source\" : {\r\n \"input\" : { },\r\n \"network-resource-discovery\" : {\r\n \"input-key-mapping\" : {\r\n \"hostname\" : \"hostname\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"si-local-ipv4\" : \"si-local-ipv4\"\r\n }\r\n }\r\n },\r\n \"candidate-dependency\" : {\r\n \"network-resource-discovery\" : {\r\n \"names\" : [ \"hostname\" ]\r\n }\r\n }\r\n}",\r
- "description": "To be provided",\r
- "tags": "ADIOD3",\r
- "creationDate": "2017-11-16T10:52:25.000+0000",\r
- "updatedBy": "ks220y@att.com"\r
- },\r
- {\r
- "name": "tacacs-server-ipv4-addresses",\r
- "resourcePath": "vnf/servers/tacacs-server-ipv4-addresses",\r
- "resourceType": "ATT",\r
- "dataType": "list",\r
- "entrySchema": "dt-tacacs-server-ipv4-addresses",\r
- "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"tacacs-server-ipv4-addresses\",\r\n \"description\" : \"to be provided\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"vnf/servers/tacacs-server-ipv4-addresses\",\r\n \"data-type\" : \"list\",\r\n \"entry-schema\" : \"dt-tacacs-server-ipv4-addresses\",\r\n \"source\" : {\r\n \"input\" : { },\r\n \"network-resource-discovery\" : {\r\n \"input-key-mapping\" : {\r\n \"region\" : \"region\",\r\n \"complex-code-char8\" : \"complex-code-char8\",\r\n \"tacacs-domain-name\" : \"tacacs-domain-name\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"tacacs-server-ipv4-addresses\" : \"tacacs-server-ipv4-addresses\"\r\n }\r\n }\r\n },\r\n \"candidate-dependency\" : {\r\n \"network-resource-discovery\" : {\r\n \"names\" : [ \"region\", \"complex-code-char8\", \"tacacs-domain-name\" ]\r\n }\r\n }\r\n}",\r
- "description": "to be provided",\r
- "tags": "ADIOD3",\r
- "creationDate": "2017-11-16T17:31:43.000+0000",\r
- "updatedBy": "ks220y@att.com"\r
- },\r
- {\r
- "name": "uplink-1-unit",\r
- "resourcePath": "vnf/interface/uplink-1-unit",\r
- "resourceType": "ATT",\r
- "dataType": "string",\r
- "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"uplink-1-unit\",\r\n \"description\" : \"To be provided\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"vnf/interface/uplink-1-unit\",\r\n \"data-type\" : \"string\",\r\n \"source\" : {\r\n \"input\" : { },\r\n \"network-resource-discovery\" : {\r\n \"input-key-mapping\" : {\r\n \"hostname\" : \"hostname\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"uplink-1-unit\" : \"uplink-1-unit\"\r\n }\r\n }\r\n },\r\n \"candidate-dependency\" : {\r\n \"network-resource-discovery\" : {\r\n \"names\" : [ \"hostname\" ]\r\n }\r\n }\r\n}",\r
- "description": "To be provided",\r
- "tags": "ADIOD3",\r
- "creationDate": "2017-11-16T17:31:44.000+0000",\r
- "updatedBy": "ks220y@att.com"\r
- },\r
- {\r
- "name": "uplink-2-unit",\r
- "resourcePath": "vnf/interface/uplink-2-unit",\r
- "resourceType": "ATT",\r
- "dataType": "string",\r
- "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"uplink-2-unit\",\r\n \"description\" : \"To be provided\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"vnf/interface/uplink-2-unit\",\r\n \"data-type\" : \"string\",\r\n \"source\" : {\r\n \"input\" : { },\r\n \"network-resource-discovery\" : {\r\n \"input-key-mapping\" : {\r\n \"hostname\" : \"hostname\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"uplink-2-unit\" : \"uplink-2-unit\"\r\n }\r\n }\r\n },\r\n \"candidate-dependency\" : {\r\n \"network-resource-discovery\" : {\r\n \"names\" : [ \"hostname\" ]\r\n }\r\n }\r\n}",\r
- "description": "To be provided",\r
- "tags": "ADIOD3",\r
- "creationDate": "2017-11-16T17:31:45.000+0000",\r
- "updatedBy": "ks220y@att.com"\r
- },\r
- {\r
- "name": "wan-aggregate-ipv4-addresses",\r
- "resourcePath": "vnf/wan-aggregate-ipv4-addresses",\r
- "resourceType": "ATT",\r
- "dataType": "list",\r
- "entrySchema": "dt-v4-aggregate",\r
- "definition": "{\r\n \"tags\" : \"wan-aggregate-ipv4-addresses, tosca.datatypes.Root, data_type, ks220y@att.com\",\r\n \"name\" : \"wan-aggregate-ipv4-addresses\",\r\n \"description\" : \"To be provided\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"vnf/wan-aggregate-ipv4-addresses\",\r\n \"data-type\" : \"list\",\r\n \"entry-schema\" : \"dt-v4-aggregate\",\r\n \"source\" : {\r\n \"input\" : { },\r\n \"mdsal\" : {\r\n \"base\" : \"sdnc-gc\",\r\n \"type\" : \"JSON\",\r\n \"url-path\" : \"/restconf/config/L3VNF-API\",\r\n \"path\" : \"/${services/service-list/$service-instance-id/service-data/vnf-topology-information/vnf-assignments/vnf-vms/$oam-ipv4-ip-type/vm-networks/$oam-network-role/v4-assigned-ip-list/$oam-vm-type\",\r\n \"input-key-mapping\" : {\r\n \"service-instance-id\" : \"service-instance-id\",\r\n \"oam-network-role\" : \"oam-network-role\",\r\n \"oam-ipv4-ip-type\" : \"oam-ipv4-ip-type\",\r\n \"oam-vm-type\" : \"oam-vm-type\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"wan-aggregate-ipv4-addresses\" : \"v4-ip-prefix-length\"\r\n }\r\n }\r\n },\r\n \"candidate-dependency\" : {\r\n \"mdsal\" : {\r\n \"names\" : [ \"service-instance-id\", \"oam-network-role\", \"oam-v4-ip-type \", \"oam-vm-type\" ]\r\n }\r\n }\r\n}",\r
- "description": "To be provided",\r
- "tags": "wan-aggregate-ipv4-addresses, tosca.datatypes.Root, data_type, ks220y@att.com",\r
- "creationDate": "2017-11-16T17:31:45.000+0000",\r
- "updatedBy": "ks220y@att.com"\r
- },\r
- {\r
- "name": "wan-aggregate-ipv6-addresses",\r
- "resourcePath": "vnf/wan-aggregate-ipv6-addresses",\r
- "resourceType": "ATT",\r
- "dataType": "list",\r
- "entrySchema": "dt-v6-aggregate",\r
- "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"wan-aggregate-ipv6-addresses\",\r\n \"description\" : \"To be provided\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"vnf/wan-aggregate-ipv6-addresses\",\r\n \"data-type\" : \"list\",\r\n \"entry-schema\" : \"dt-v6-aggregate\",\r\n \"source\" : {\r\n \"input\" : { },\r\n \"mdsal\" : {\r\n \"base\" : \"sdnc-gc\",\r\n \"type\" : \"JSON\",\r\n \"url-path\" : \"/restconf/config/L3VNF-API\",\r\n \"path\" : \"/${services/service-list/$service-instance-id/service-data/vnf-topology-information/vnf-assignments/vnf-vms/VCO\",\r\n \"input-key-mapping\" : {\r\n \"service-instance-id\" : \"service-instance-id\",\r\n \"oam-network-role\" : \"oam-network-role\",\r\n \"oam-ipv4-ip-type\" : \"oam-ipv4-ip-type\",\r\n \"oam-vm-type\" : \"oam-vm-type\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"wan-aggregate-ipv6.addresses\" : \"v4-ip-prefix-length\"\r\n }\r\n }\r\n },\r\n \"candidate-dependency\" : {\r\n \"mdsal\" : {\r\n \"names\" : [ \"service-instance-id\", \"oam-network-role\", \"oam-v4-ip-type \", \"oam-vm-type\" ]\r\n }\r\n }\r\n}",\r
- "description": "To be provided",\r
- "tags": "ADIOD3",\r
- "creationDate": "2017-11-16T17:31:46.000+0000",\r
- "updatedBy": "ks220y@att.com"\r
- }\r
-]\r
+++ /dev/null
-{\r
- "request-id": "1234",\r
- "service-instance-id": "adsfdsf",\r
- "action-name": "resource-assignment-action",\r
- "scope-type": "vnf-type",\r
- "hostname": "sample-host",\r
- "resource-assignment-request": {\r
- "uplink-2-unit": "sample-uplink-2-unit",\r
- "bundle-mac": "sample-bundle-mac",\r
- "wan-aggregate-ipv6-addresses": [\r
- {\r
- "v6-address": "sample-v6-address",\r
- "v6-plen": "sample-v6-plen"\r
- }\r
- ],\r
- "ospf-area": "sample-ospf-area",\r
- "ospf-cost": 10.0,\r
- "bundle-id": "bundle-id",\r
- "adiod-unicast-route-reflectors": [\r
- {\r
- "v4-address": "sample-v4-address",\r
- "name": "sample-name"\r
- }\r
- ],\r
- "oam-remote-ipv4-address": "",\r
- "adiod-vpnv4-route-reflectors": [\r
- {\r
- "v4-address": "sample-v4-address",\r
- "name": "sample-name"\r
- }\r
- ],\r
- "lo10-local-ipv4-address": "sample-lo10-local-ipv4-address",\r
- "wan-aggregate-ipv4-addresses": [\r
- {\r
- "v4-address": "sample-v4-address",\r
- "v4-plen": 0\r
- }\r
- ],\r
- "lo0-local-ipv4-address": "sample-lo0-local-ipv4-address",\r
- "uplink-1-unit": "sample-uplink-1-unit",\r
- "tacacs-server-ipv4-addresses": [\r
- {\r
- "tacacs-server-ipv4-address": "sample-tacacs-server-ipv4-address"\r
- }\r
- ],\r
- "asn-region": "sample-asn-region",\r
- "si-local-ipv4-address": "sample-si-local-ipv4-address"\r
- }\r
-}\r
+++ /dev/null
- <config>\r
- <configuration>\r
- <groups>\r
- <name>${group-name}</name>\r
- <routing-instances>\r
- <instance>\r
- <name><*></name>\r
- <protocols>\r
- <pim>\r
- <dense-groups>\r
- <dynamic-reject />\r
- <pim-dense-group-type>\r
- <name>224.0.1.40/32</name>\r
- </pim-dense-group-type>\r
- <pim-dense-group-type>\r
- <name>224.0.1.39/32</name>\r
- </pim-dense-group-type>\r
- <pim-dense-group-type>\r
- <name>224.0.0.0/4</name>\r
- <reject />\r
- </pim-dense-group-type>\r
- </dense-groups>\r
- <rp>\r
- <auto-rp>\r
- <discovery />\r
- </auto-rp>\r
- </rp>\r
- <interface>\r
- <name><*></name>\r
- <disable />\r
- <priority>1000</priority>\r
- </interface>\r
- <reset-tracking-bit />\r
- </pim>\r
- </protocols>\r
- </instance>\r
- </routing-instances>\r
- </groups>\r
- </configuration>\r
- </config>
\ No newline at end of file
+++ /dev/null
-{\r
- "metadata": {\r
- "author": "ks220y@att.com",\r
- "service-template-name": "vpe-201802-baseconfig",\r
- "service-template-version": "1.0.0",\r
- "release": "1802",\r
- "service-type": "ADIOD",\r
- "vnf-type": "VPE"\r
- },\r
- "topology_template": {\r
- "inputs": {\r
- "request-id": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "service-instance-id": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "action-name": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "scope-type": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "hostname": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "resource-assignment-request": {\r
- "description": "This is Dynamic Data type for the receipe resource-assignment-action.",\r
- "required": false,\r
- "type": "dt-resource-assignment-request"\r
- }\r
- },\r
- "node_templates": {\r
- "base-config-template": {\r
- "type": "artifact-config-template",\r
- "properties": {\r
- "action-names": [\r
- "resource-assignment-action"\r
- ]\r
- },\r
- "capabilities": {\r
- "content": {\r
- "properties": {\r
- "content": "db://base-config-template"\r
- }\r
- },\r
- "mapping": {\r
- "properties": {\r
- "mapping": [\r
- {\r
- "name": "wan-aggregate-ipv6-addresses",\r
- "input-param": true,\r
- "property": {\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "dt-v6-aggregate"\r
- }\r
- },\r
- "dictionary-name": "wan-aggregate-ipv6-addresses",\r
- "dictionary-source": "input"\r
- },\r
- {\r
- "name": "wan-aggregate-ipv4-addresses",\r
- "input-param": true,\r
- "property": {\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "dt-v4-aggregate"\r
- }\r
- },\r
- "dictionary-name": "wan-aggregate-ipv4-addresses",\r
- "dictionary-source": "input"\r
- },\r
- {\r
- "name": "tacacs-server-ipv4-addresses",\r
- "input-param": true,\r
- "property": {\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "dt-tacacs-server-ipv4"\r
- }\r
- },\r
- "dictionary-name": "tacacs-server-ipv4-addresses",\r
- "dictionary-source": "input"\r
- },\r
- {\r
- "name": "oam-remote-ipv4-address",\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "oam-remote-ipv4-address",\r
- "dictionary-source": "input"\r
- },\r
- {\r
- "name": "si-local-ipv4-address",\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "si-local-ipv4-address",\r
- "dictionary-source": "input"\r
- },\r
- {\r
- "name": "lo0-local-ipv4-address",\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "lo0-local-ipv4-address",\r
- "dictionary-source": "input"\r
- },\r
- {\r
- "name": "asn-region",\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "asn-region",\r
- "dictionary-source": "input"\r
- },\r
- {\r
- "name": "adiod-unicast-route-reflectors",\r
- "input-param": true,\r
- "property": {\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "dt-adiod-unicast-route-reflector"\r
- }\r
- },\r
- "dictionary-name": "adiod-unicast-route-reflectors",\r
- "dictionary-source": "input"\r
- },\r
- {\r
- "name": "adiod-vpnv4-route-reflectors",\r
- "input-param": true,\r
- "property": {\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "dt-adiod-vpnv4-route-reflector"\r
- }\r
- },\r
- "dictionary-name": "adiod-vpnv4-route-reflectors",\r
- "dictionary-source": "input"\r
- },\r
- {\r
- "name": "bundle-id",\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "bundle-id",\r
- "dictionary-source": "input"\r
- },\r
- {\r
- "name": "uplink-1-unit",\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "uplink-1-unit",\r
- "dictionary-source": "input"\r
- },\r
- {\r
- "name": "uplink-2-unit",\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "uplink-2-unit",\r
- "dictionary-source": "input"\r
- },\r
- {\r
- "name": "ospf-area",\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "ospf-area",\r
- "dictionary-source": "input"\r
- },\r
- {\r
- "name": "ospf-cost",\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "ospf-cost",\r
- "dictionary-source": "input"\r
- },\r
- {\r
- "name": "lo10-local-ipv4-address",\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "lo10-local-ipv4-address",\r
- "dictionary-source": "input"\r
- }\r
- ]\r
- }\r
- }\r
- }\r
- },\r
- "resource-assignment-action": {\r
- "type": "dg-resource-assignment",\r
- "interfaces": {\r
- "CONFIG": {\r
- "operations": {\r
- "ResourceAssignment": {\r
- \r
- }\r
- }\r
- }\r
- },\r
- "capabilities": {\r
- "dg-node": {\r
- \r
- }\r
- },\r
- "requirements": {\r
- "component-dependency": {\r
- "capability": "component-node",\r
- "node": "resource-assignment",\r
- "relationship": "tosca.relationships.DependsOn"\r
- }\r
- }\r
- },\r
- "resource-assignment": {\r
- "type": "component-resource-assignment",\r
- "interfaces": {\r
- "org-onap-ccsdk-features-assignment-service-ConfigAssignmentNode": {\r
- "operations": {\r
- "process": {\r
- "inputs": {\r
- "action-name": "{ \"get_input\" : \"action-name\" }",\r
- "resource-type": "vnf-type",\r
- "template-names": [\r
- "base-config-template",\r
- "licence-template"\r
- ],\r
- "request-id": "{ \"get_input\" : \"request-id\" }",\r
- "resource-id": "{ \"get_input\" : \"hostname\" }"\r
- },\r
- "outputs": {\r
- "resource-assignment-params": "",\r
- "status": ""\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "capabilities": {\r
- "component-node": {\r
- \r
- }\r
- }\r
- }\r
- }\r
- },\r
- "node_types": {\r
- "dg-resource-assignment": {\r
- "description": "This is Resource Assignment Directed Graph",\r
- "version": "1.0.0",\r
- "properties": {\r
- "mode": {\r
- "required": false,\r
- "type": "string",\r
- "default": "sync"\r
- },\r
- "version": {\r
- "required": false,\r
- "type": "string",\r
- "default": "LATEST"\r
- },\r
- "is-start-flow": {\r
- "required": false,\r
- "type": "boolean",\r
- "default": "false"\r
- }\r
- },\r
- "capabilities": {\r
- "dg-node": {\r
- "type": "tosca.capabilities.Node"\r
- },\r
- "content": {\r
- "type": "tosca.capabilities.Content",\r
- "properties": {\r
- "type": {\r
- "required": false,\r
- "type": "string",\r
- "default": "json"\r
- },\r
- "content": {\r
- "required": true,\r
- "type": "string"\r
- }\r
- }\r
- }\r
- },\r
- "requirements": {\r
- "component-dependency": {\r
- "capability": "component-node",\r
- "node": "component-resource-assignment",\r
- "relationship": "tosca.relationships.DependsOn"\r
- }\r
- },\r
- "interfaces": {\r
- "CONFIG": {\r
- "operations": {\r
- "ResourceAssignment": {\r
- "inputs": {\r
- "params": {\r
- "required": false,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "datatype-property"\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "derived_from": "tosca.nodes.DG"\r
- },\r
- "component-resource-assignment": {\r
- "description": "This is Resource Assignment Component API",\r
- "version": "1.0.0",\r
- "capabilities": {\r
- "component-node": {\r
- "type": "tosca.capabilities.Node"\r
- }\r
- },\r
- "interfaces": {\r
- "org-onap-ccsdk-features-assignment-service-ConfigAssignmentNode": {\r
- "operations": {\r
- "process": {\r
- "inputs": {\r
- "action-name": {\r
- "description": "Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",\r
- "required": false,\r
- "type": "string"\r
- },\r
- "handler-name": {\r
- "description": "Name of the Artifact Node Template, to get the template Content. If template-content is present, then content wont be reterived from the Artifact Node Template.",\r
- "required": true,\r
- "type": "string"\r
- },\r
- "resource-type": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "template-names": {\r
- "description": "Name of the Artifact Node Templates, to get the template Content.",\r
- "required": true,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "string"\r
- }\r
- },\r
- "request-id": {\r
- "description": "Request Id used to store the generated configuration, in the database along with the template-name",\r
- "required": true,\r
- "type": "string"\r
- },\r
- "resource-id": {\r
- "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present",\r
- "required": true,\r
- "type": "string"\r
- }\r
- },\r
- "outputs": {\r
- "resource-assignment-params": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "status": {\r
- "required": true,\r
- "type": "string"\r
- }\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "derived_from": "tosca.nodes.Component"\r
- },\r
- "artifact-config-template": {\r
- "description": "This is Configuration Velocity Template",\r
- "version": "1.0.0",\r
- "properties": {\r
- "action-names": {\r
- "required": true,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "string"\r
- }\r
- }\r
- },\r
- "capabilities": {\r
- "content": {\r
- "type": "tosca.capabilities.Content",\r
- "properties": {\r
- "content": {\r
- "required": true,\r
- "type": "string"\r
- }\r
- }\r
- },\r
- "mapping": {\r
- "type": "tosca.capabilities.Mapping",\r
- "properties": {\r
- "mapping": {\r
- "required": false,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "datatype-resource-assignment"\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "derived_from": "tosca.nodes.Artifact"\r
- }\r
- },\r
- "data_types": {\r
- "dt-v4-aggregate": {\r
- "version": "1.0.0",\r
- "description": "This is dt-v4-aggregate Data Type",\r
- "properties": {\r
- "v4-address": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "v4-plen": {\r
- "required": false,\r
- "type": "integer"\r
- }\r
- },\r
- "derived_from": "tosca.datatypes.Root"\r
- },\r
- "dt-tacacs-server-ipv4": {\r
- "version": "1.0.0",\r
- "description": "This is dt-tacacs-server-ipv4 Data Type",\r
- "properties": {\r
- "tacacs-server-ipv4-address": {\r
- "required": true,\r
- "type": "string"\r
- }\r
- },\r
- "derived_from": "tosca.datatypes.Root"\r
- },\r
- "dt-adiod-vpnv4-route-reflector": {\r
- "version": "1.0.0",\r
- "description": "This is dt-adiod-unicast-route-reflector Data Type",\r
- "properties": {\r
- "v4-address": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "name": {\r
- "required": false,\r
- "type": "string"\r
- }\r
- },\r
- "derived_from": "tosca.datatypes.Root"\r
- },\r
- "datatype-resource-assignment": {\r
- "version": "1.0.0",\r
- "description": "This is Resource Assignment Data Type",\r
- "properties": {\r
- "property": {\r
- "required": true,\r
- "type": "datatype-property"\r
- },\r
- "input-param": {\r
- "required": true,\r
- "type": "boolean"\r
- },\r
- "dictionary-name": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "dictionary-source": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "dependencies": {\r
- "required": true,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "string"\r
- }\r
- },\r
- "status": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "message": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "updated-date": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "updated-by": {\r
- "required": false,\r
- "type": "string"\r
- }\r
- },\r
- "derived_from": "tosca.datatypes.Root"\r
- },\r
- "dt-adiod-unicast-route-reflector": {\r
- "version": "1.0.0",\r
- "description": "This is dt-adiod-unicast-route-reflector Data Type",\r
- "properties": {\r
- "v4-address": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "name": {\r
- "required": false,\r
- "type": "string"\r
- }\r
- },\r
- "derived_from": "tosca.datatypes.Root"\r
- },\r
- "datatype-property": {\r
- "version": "1.0.0",\r
- "description": "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs",\r
- "properties": {\r
- "type": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "description": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "required": {\r
- "required": false,\r
- "type": "boolean"\r
- },\r
- "default": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "entry_schema": {\r
- "required": false,\r
- "type": "string"\r
- }\r
- },\r
- "derived_from": "tosca.datatypes.Root"\r
- },\r
- "dt-v6-aggregate": {\r
- "version": "1.0.0",\r
- "description": "This is dt-v6-aggregate Data Type",\r
- "properties": {\r
- "v6-address": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "v6-plen": {\r
- "required": false,\r
- "type": "string"\r
- }\r
- },\r
- "derived_from": "tosca.datatypes.Root"\r
- },\r
- "dt-resource-assignment-request": {\r
- "version": "1.0.0",\r
- "description": "This is Dynamic Data type definition generated from resource mapping for the config template name base-config-template.",\r
- "properties": {\r
- "uplink-2-unit": {\r
- "type": "string"\r
- },\r
- "bundle-mac": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "wan-aggregate-ipv6-addresses": {\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "dt-v6-aggregate"\r
- }\r
- },\r
- "ospf-area": {\r
- "type": "string"\r
- },\r
- "ospf-cost": {\r
- "type": "string"\r
- },\r
- "bundle-id": {\r
- "type": "string"\r
- },\r
- "adiod-unicast-route-reflectors": {\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "dt-adiod-unicast-route-reflector"\r
- }\r
- },\r
- "oam-remote-ipv4-address": {\r
- "type": "string"\r
- },\r
- "adiod-vpnv4-route-reflectors": {\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "dt-adiod-vpnv4-route-reflector"\r
- }\r
- },\r
- "lo10-local-ipv4-address": {\r
- "type": "string"\r
- },\r
- "wan-aggregate-ipv4-addresses": {\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "dt-v4-aggregate"\r
- }\r
- },\r
- "lo0-local-ipv4-address": {\r
- "type": "string"\r
- },\r
- "uplink-1-unit": {\r
- "type": "string"\r
- },\r
- "tacacs-server-ipv4-addresses": {\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "dt-tacacs-server-ipv4"\r
- }\r
- },\r
- "asn-region": {\r
- "type": "string"\r
- },\r
- "si-local-ipv4-address": {\r
- "type": "string"\r
- }\r
- },\r
- "derived_from": "tosca.datatypes.Dynamic"\r
- }\r
- }\r
-}\r
+++ /dev/null
-[\r
- {\r
- "name": "vnf-id",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "vnf-id",\r
- "dictionary-source": "input",\r
- "dependencies": []\r
- },\r
- {\r
- "name": "service-instance-id",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "service-instance-id",\r
- "dictionary-source": "input",\r
- "dependencies": []\r
- },\r
- {\r
- "name": "bundle-id",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "bundle-id",\r
- "dictionary-source": "mdsal",\r
- "dependencies": [\r
- "vnf-id"\r
- ]\r
- },\r
- {\r
- "name": "bundle-ip",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "bundle-ip",\r
- "dictionary-source": "mdsal",\r
- "dependencies": [\r
- "vnf-id"\r
- ]\r
- },\r
- {\r
- "name": "bundle-mac",\r
- "input-param": true,\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "bundle-mac",\r
- "dictionary-source": "mdsal",\r
- "dependencies": [\r
- "vnf-id",\r
- "bundle-id"\r
- ]\r
- },\r
- {\r
- "name": "managed-ip",\r
- "input-param": true,\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "managed-ip",\r
- "dictionary-source": "mdsal",\r
- "dependencies": [\r
- "loopback-ip"\r
- ]\r
- },\r
- {\r
- "name": "vnf-name",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "vnf-name",\r
- "dictionary-source": "input",\r
- "dependencies": []\r
- },\r
- {\r
- "name": "managed-ip1",\r
- "input-param": true,\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "managed-ip1",\r
- "dictionary-source": "mdsal",\r
- "dependencies": [\r
- "loopback-ip"\r
- ]\r
- },\r
- {\r
- "name": "loopback-ip",\r
- "input-param": true,\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "loopback-ip",\r
- "dictionary-source": "db",\r
- "dependencies": [\r
- "bundle-mac",\r
- "managed-ip1"\r
- ]\r
- }\r
-]\r
+++ /dev/null
-[\r
- {\r
- "name": "vnf-id",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "vnf-id",\r
- "dictionary-source": "input",\r
- "dependencies": []\r
- },\r
- {\r
- "name": "service-instance-id",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "service-instance-id",\r
- "dictionary-source": "input",\r
- "dependencies": []\r
- },\r
- {\r
- "name": "bundle-id",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "bundle-id",\r
- "dictionary-source": "mdsal",\r
- "dependencies": [\r
- "vnf-id"\r
- ]\r
- },\r
- {\r
- "name": "bundle-ip",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "bundle-ip",\r
- "dictionary-source": "mdsal",\r
- "dependencies": [\r
- "vnf-id"\r
- ]\r
- },\r
- {\r
- "name": "bundle-mac",\r
- "input-param": true,\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "bundle-mac",\r
- "dictionary-source": "mdsal",\r
- "dependencies": [\r
- "vnf-id",\r
- "bundle-id"\r
- ]\r
- },\r
- {\r
- "name": "bundle-mac",\r
- "input-param": true,\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "bundle-mac",\r
- "dictionary-source": "mdsal",\r
- "dependencies": [\r
- "loopback-ip"\r
- ]\r
- },\r
- {\r
- "name": "vnf-name",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "vnf-name",\r
- "dictionary-source": "input",\r
- "dependencies": []\r
- },\r
- {\r
- "name": "managed-ip1",\r
- "input-param": true,\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "managed-ip1",\r
- "dictionary-source": "mdsal",\r
- "dependencies": [\r
- "loopback-ip"\r
- ]\r
- },\r
- {\r
- "name": "loopback-ip",\r
- "input-param": true,\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "loopback-ip",\r
- "dictionary-source": "db",\r
- "dependencies": [\r
- "bundle-mac"\r
- ]\r
- }\r
-]\r
+++ /dev/null
-[\r
- {\r
- "name": "vnf-id",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "vnf-id",\r
- "dictionary-source": "input",\r
- "dependencies": []\r
- },\r
- {\r
- "name": "service-instance-id",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "service-instance-id",\r
- "dictionary-source": "input",\r
- "dependencies": []\r
- },\r
- {\r
- "name": "bundle-id",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "bundle-id",\r
- "dictionary-source": "mdsal",\r
- "dependencies": [\r
- "vnf-id"\r
- ]\r
- },\r
- {\r
- "name": "bundle-ip",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "bundle-ip",\r
- "dictionary-source": "mdsal",\r
- "dependencies": [\r
- "vnf-id"\r
- ]\r
- },\r
- {\r
- "name": "bundle-mac",\r
- "input-param": true,\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "bundle-mac",\r
- "dictionary-source": "mdsal",\r
- "dependencies": [\r
- "vnf-id",\r
- "bundle-id"\r
- ]\r
- },\r
- {\r
- "name": "managed-ip",\r
- "input-param": true,\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "managed-ip",\r
- "dictionary-source": "mdsal",\r
- "dependencies": [\r
- "loopback-ip"\r
- ]\r
- },\r
- {\r
- "name": "vnf-name",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "vnf-name",\r
- "dictionary-source": "input",\r
- "dependencies": []\r
- },\r
- {\r
- "name": "managed-ip1",\r
- "input-param": true,\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "managed-ip1",\r
- "dictionary-source": "mdsal",\r
- "dependencies": [\r
- "loopback-ip"\r
- ]\r
- },\r
- {\r
- "name": "loopback-ip",\r
- "input-param": true,\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "loopback-ip",\r
- "dictionary-source": "db",\r
- "dependencies": [\r
- "bundle-mac"\r
- ]\r
- }\r
-]\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright © 2017-2018 AT&T Intellectual Property.
- Modifications Copyright © 2018 IBM.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onap.ccsdk.parent</groupId>
- <artifactId>binding-parent</artifactId>
- <version>1.5.2-SNAPSHOT</version>
- <relativePath/>
- </parent>
-
- <groupId>org.onap.ccsdk.features</groupId>
- <artifactId>blueprints-generator-provider</artifactId>
- <version>0.7.1-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <name>ccsdk-features :: blueprints-processor-plugin :: ${project.artifactId}</name>
- <url>http://maven.apache.org</url>
-
- <dependencies>
- <dependency>
- <groupId>org.onap.ccsdk.features</groupId>
- <artifactId>blueprints-model-provider</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.ccsdk.features</groupId>
- <artifactId>blueprints-data-adaptor-provider</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-core</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.module</groupId>
- <artifactId>jackson-module-jsonSchema</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity</artifactId>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito</artifactId>
- <version>1.6.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.javassist</groupId>
- <artifactId>javassist</artifactId>
- <version>3.21.0-GA</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <version>1.10.19</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-junit4</artifactId>
- <version>1.6.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-support</artifactId>
- <version>1.6.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-reflect</artifactId>
- <version>1.6.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-core</artifactId>
- <version>1.6.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Name>${project.artifactId}</Bundle-Name>
- <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>
- org.onap.ccsdk.features.generator,
- org.onap.ccsdk.features.generator.data,
- org.onap.ccsdk.features.generator.service,
- org.onap.ccsdk.features.generator.tool
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-/*\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.features.generator;\r
-\r
-public class ConfigGeneratorConstant {\r
-\r
- private ConfigGeneratorConstant() {\r
-\r
- }\r
-\r
- public static final String STRING_ENCODING = "utf-8";\r
- public static final String Y = "Y";\r
- public static final String N = "N";\r
- public static final String DATA_TYPE_TEXT = "TEXT";\r
- public static final String DATA_TYPE_JSON = "JSON";\r
- public static final String DATA_TYPE_XML = "XML";\r
- public static final String DATA_TYPE_SQL = "SQL";\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_NAME = "template-name";\r
- public static final String INPUT_PARAM_TEMPLATE_CONTENT = "template-content";\r
- public static final String INPUT_PARAM_TEMPLATE_DATA = "template-data";\r
-\r
- public static final String OUTPUT_PARAM_GENERATED_CONFIG = "generated-config";\r
- public static final String OUTPUT_PARAM_MASK_INFO = "mask-info";\r
- public static final String OUTPUT_PARAM_STATUS = "status";\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
+++ /dev/null
-/*\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.features.generator.data;\r
-\r
-public class ConfigGeneratorInfo {\r
-\r
- private String requestId;\r
- private String resourceId;\r
- private String resourceType;\r
- private String templateName;\r
- private String recipeName;\r
- private String resourceData;\r
- private String templateContent;\r
- private String mashedData;\r
-\r
- public String getRequestId() {\r
- return requestId;\r
- }\r
-\r
- public void setRequestId(String requestId) {\r
- this.requestId = requestId;\r
- }\r
-\r
- public String getResourceId() {\r
- return resourceId;\r
- }\r
-\r
- public void setResourceId(String resourceId) {\r
- this.resourceId = resourceId;\r
- }\r
-\r
- public String getResourceType() {\r
- return resourceType;\r
- }\r
-\r
- public void setResourceType(String resourceType) {\r
- this.resourceType = resourceType;\r
- }\r
-\r
- public String getTemplateName() {\r
- return templateName;\r
- }\r
-\r
- public void setTemplateName(String templateName) {\r
- this.templateName = templateName;\r
- }\r
-\r
- public String getRecipeName() {\r
- return recipeName;\r
- }\r
-\r
- public void setRecipeName(String recipeName) {\r
- this.recipeName = recipeName;\r
- }\r
-\r
- public String getResourceData() {\r
- return resourceData;\r
- }\r
-\r
- public void setResourceData(String resourceData) {\r
- this.resourceData = resourceData;\r
- }\r
-\r
- public String getTemplateContent() {\r
- return templateContent;\r
- }\r
-\r
- public void setTemplateContent(String templateContent) {\r
- this.templateContent = templateContent;\r
- }\r
-\r
- public String getMashedData() {\r
- return mashedData;\r
- }\r
-\r
- public void setMashedData(String mashedData) {\r
- this.mashedData = mashedData;\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return "ConfigGeneratorInfo [requestId=" + requestId + ", resourceId=" + resourceId + ", resourceType="\r
- + resourceType + ", templateName=" + templateName + ", recipeName=" + recipeName + ", resourceData="\r
- + resourceData + ", templateContent=" + templateContent + ", mashedData=" + mashedData + "]";\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.generator.service;\r
-\r
-import java.util.Map;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService;\r
-import org.onap.ccsdk.features.generator.ConfigGeneratorConstant;\r
-import org.onap.ccsdk.features.generator.data.ConfigGeneratorInfo;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.service.ComponentNode;\r
-import org.onap.ccsdk.features.model.service.ConfigModelService;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class ConfigGeneratorNode implements ComponentNode {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigGeneratorNode.class);\r
-\r
- private ConfigModelService configModelService;\r
- private ConfigResourceService configResourceService;\r
- private ConfigGeneratorService configGeneratorService;\r
-\r
- public ConfigGeneratorNode(ConfigResourceService configResourceService, ConfigModelService configModelService) {\r
- this.configResourceService = configResourceService;\r
- this.configModelService = configModelService;\r
- this.configGeneratorService = new ConfigGeneratorServiceImpl(this.configResourceService);\r
- }\r
-\r
- @Override\r
- public Boolean preCondition(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- logger.trace("Received generateConfiguration preCondition call with params : ({})", inParams);\r
- return Boolean.TRUE;\r
- }\r
-\r
- @Override\r
- public void preProcess(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- logger.trace("Received generateConfiguration preProcess call with params : ({})", inParams);\r
- }\r
-\r
- @Override\r
- public void process(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {\r
- logger.trace("Received generateConfiguration process call with params : ({})", inParams);\r
- }\r
-\r
- @SuppressWarnings("squid:S3776")\r
- @Override\r
- public void process(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- logger.trace("Received generateConfiguration process with params : ({})", inParams);\r
- String prifix = inParams.get(ConfigModelConstant.PROPERTY_SELECTOR);\r
- try {\r
- prifix = StringUtils.isNotBlank(prifix) ? (prifix + ".") : "";\r
-\r
- String templateContent = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_CONTENT);\r
- String templateData = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_DATA);\r
- String requestId = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_REQUEST_ID);\r
- String resourceId = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_RESOURCE_ID);\r
- String resourceType = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_RESOURCE_TYPE);\r
- String recipeName = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_ACTION_NAME);\r
- String templateName = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_NAME);\r
-\r
- ConfigGeneratorInfo configGeneratorInfo = null;\r
- if (StringUtils.isNotBlank(templateContent) && StringUtils.isNotBlank(templateData)) {\r
- configGeneratorInfo = this.configGeneratorService.generateConfiguration(templateContent, templateData);\r
- } else {\r
- if (StringUtils.isBlank(requestId)) {\r
- throw new SvcLogicException("Config Generator Request Id is missing.");\r
- }\r
- if (StringUtils.isBlank(resourceId)) {\r
- throw new SvcLogicException("Config Generator Resource Id is missing.");\r
- }\r
- if (StringUtils.isBlank(resourceType)) {\r
- throw new SvcLogicException("Config Generator Resource Type is missing.");\r
- }\r
- if (StringUtils.isBlank(recipeName)) {\r
- throw new SvcLogicException("Config Generator Action Name is missing.");\r
- }\r
- if (StringUtils.isBlank(templateName)) {\r
- throw new SvcLogicException("Config Generator Template Name Id is missing.");\r
- }\r
-\r
- templateContent = configModelService.getNodeTemplateContent(ctx, templateName);\r
-\r
- if (StringUtils.isBlank(templateContent)) {\r
- throw new SvcLogicException(\r
- "Failed to get the Template Content for the Temaple Name :" + templateName);\r
- }\r
-\r
- configGeneratorInfo = new ConfigGeneratorInfo();\r
- configGeneratorInfo.setRequestId(requestId);\r
- configGeneratorInfo.setResourceId(resourceId);\r
- configGeneratorInfo.setResourceType(resourceType);\r
- configGeneratorInfo.setRecipeName(recipeName);\r
- configGeneratorInfo.setTemplateName(templateName);\r
- configGeneratorInfo.setTemplateContent(templateContent);\r
-\r
- this.configGeneratorService.generateConfiguration(configGeneratorInfo);\r
- }\r
- if (configGeneratorInfo != null) {\r
- ctx.setAttribute(prifix + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG,\r
- configGeneratorInfo.getMashedData());\r
- }\r
- ctx.setAttribute(prifix + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS,\r
- ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS);\r
- } catch (Exception e) {\r
- ctx.setAttribute(prifix + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS,\r
- ConfigGeneratorConstant.OUTPUT_STATUS_FAILURE);\r
- ctx.setAttribute(prifix + ConfigGeneratorConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());\r
- logger.error("Failed in generateConfiguration ({})", e);\r
- throw new SvcLogicException(e.getMessage());\r
- }\r
- }\r
-\r
- @Override\r
- public void postProcess(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- logger.info("Received generateConfiguration postProcess with params : ({})", inParams);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.generator.service;\r
-\r
-import org.onap.ccsdk.features.generator.data.ConfigGeneratorInfo;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-\r
-public interface ConfigGeneratorService {\r
-\r
- public ConfigGeneratorInfo generateConfiguration(String templateContent, String templateData)\r
- throws SvcLogicException;\r
-\r
- public ConfigGeneratorInfo generateConfiguration(String templateContent, String templateData, boolean ignoreNull)\r
- throws SvcLogicException;\r
-\r
- public ConfigGeneratorInfo generateConfiguration(ConfigGeneratorInfo configGeneratorInfo) throws SvcLogicException;\r
-\r
-}\r
+++ /dev/null
-/*\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.features.generator.service;\r
-\r
-import java.io.StringWriter;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-import org.apache.commons.collections.CollectionUtils;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.apache.velocity.VelocityContext;\r
-import org.apache.velocity.app.Velocity;\r
-import org.onap.ccsdk.features.data.adaptor.domain.ConfigResource;\r
-import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService;\r
-import org.onap.ccsdk.features.generator.data.ConfigGeneratorInfo;\r
-import org.onap.ccsdk.features.generator.tool.CustomJsonNodeFactory;\r
-import org.onap.ccsdk.features.model.utils.TransformationUtils;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-import com.fasterxml.jackson.databind.JsonNode;\r
-import com.fasterxml.jackson.databind.ObjectMapper;\r
-\r
-public class ConfigGeneratorServiceImpl implements ConfigGeneratorService {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigGeneratorServiceImpl.class);\r
- private static final String CLASS_NAME = "ConfigGeneratorServiceImpl";\r
-\r
- private ConfigResourceService configResourceService;\r
-\r
- public ConfigGeneratorServiceImpl(ConfigResourceService configResourceService) {\r
- logger.info("{} Constuctor Initated...", CLASS_NAME);\r
- this.configResourceService = configResourceService;\r
- }\r
-\r
- @Override\r
- public ConfigGeneratorInfo generateConfiguration(ConfigGeneratorInfo configGeneratorInfo) throws SvcLogicException {\r
-\r
- if (configGeneratorInfo != null && StringUtils.isNotBlank(configGeneratorInfo.getResourceId())\r
- && StringUtils.isNotBlank(configGeneratorInfo.getResourceType())\r
- && StringUtils.isNotBlank(configGeneratorInfo.getRecipeName())\r
- && StringUtils.isNotBlank(configGeneratorInfo.getTemplateName())\r
- && StringUtils.isNotBlank(configGeneratorInfo.getTemplateContent())) {\r
-\r
- ConfigResource configResourceQuery = new ConfigResource();\r
- configResourceQuery.setResourceId(configGeneratorInfo.getResourceId());\r
- configResourceQuery.setResourceType(configGeneratorInfo.getResourceType());\r
- configResourceQuery.setTemplateName(configGeneratorInfo.getTemplateName());\r
-\r
- List<ConfigResource> configResourceList = configResourceService.getConfigResource(configResourceQuery);\r
-\r
- if (CollectionUtils.isEmpty(configResourceList)) {\r
- throw new SvcLogicException("No Config Resource found");\r
- } else if (configResourceList.size() > 1) {\r
- throw new SvcLogicException("More than one Config Resource found for specified parameter for"\r
- + " resourceId " + configGeneratorInfo.getResourceId() + ", resourceType "\r
- + configGeneratorInfo.getResourceType() + ", recipeName " + configGeneratorInfo.getRecipeName()\r
- + ", templateName " + configGeneratorInfo.getTemplateName());\r
- }\r
-\r
- ConfigResource configResource = configResourceList.get(0);\r
-\r
- if (configResource != null && StringUtils.isNotBlank(configResource.getResourceData())) {\r
- configGeneratorInfo.setResourceData(configResource.getResourceData());\r
- logger.debug("Retrieve ConfigResource Data : ({})", configResource.getResourceData());\r
- ConfigGeneratorInfo generatorInfo = generateConfiguration(configGeneratorInfo.getTemplateContent(),\r
- configResource.getResourceData());\r
- if (generatorInfo != null) {\r
- configGeneratorInfo.setMashedData(generatorInfo.getMashedData());\r
- }\r
- } else {\r
- throw new SvcLogicException(\r
- "Failed to get the Resource Data for the Resource Id :" + configGeneratorInfo.getResourceId()\r
- + " of template :" + configGeneratorInfo.getTemplateName());\r
- }\r
- }\r
- return configGeneratorInfo;\r
- }\r
-\r
- @Override\r
- public ConfigGeneratorInfo generateConfiguration(String templateContent, String templateData)\r
- throws SvcLogicException {\r
- return generateConfiguration(templateContent, templateData, true);\r
- }\r
-\r
- @Override\r
- public ConfigGeneratorInfo generateConfiguration(String templateContent, String templateData, boolean ignoreNull)\r
- throws SvcLogicException {\r
- ConfigGeneratorInfo configGeneratorInfo = null;\r
- try {\r
- if (StringUtils.isNotBlank(templateContent) && StringUtils.isNotBlank(templateData)) {\r
- configGeneratorInfo = new ConfigGeneratorInfo();\r
-\r
- Velocity.init();\r
-\r
- ObjectMapper mapper = new ObjectMapper();\r
- CustomJsonNodeFactory f = new CustomJsonNodeFactory();\r
- mapper.setNodeFactory(f);\r
-\r
- JsonNode jsonObj = mapper.readValue(templateData, JsonNode.class);\r
- if (ignoreNull) {\r
- TransformationUtils.removeJsonNullNode(jsonObj);\r
- }\r
-\r
- VelocityContext context = new VelocityContext();\r
- context.put("StringUtils", org.apache.commons.lang3.StringUtils.class);\r
- context.put("BooleanUtils", org.apache.commons.lang3.BooleanUtils.class);\r
-\r
- Iterator<String> ii = jsonObj.fieldNames();\r
- while (ii.hasNext()) {\r
- String key = ii.next();\r
- JsonNode node = jsonObj.get(key);\r
- logger.info("Adding key ({}) with value ({})", key, node);\r
- context.put(key, node);\r
- }\r
-\r
- StringWriter writer = new StringWriter();\r
- Velocity.evaluate(context, writer, "TemplateData", templateContent);\r
- writer.flush();\r
- configGeneratorInfo.setMashedData(writer.toString());\r
- }\r
- } catch (Exception e) {\r
- logger.error("Failed to generate Configuration ({})", e.getMessage());\r
- throw new SvcLogicException(e.getMessage(), e);\r
- }\r
- return configGeneratorInfo;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.generator.tool;\r
-\r
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;\r
-import com.fasterxml.jackson.databind.node.TextNode;\r
-\r
-public class CustomJsonNodeFactory extends JsonNodeFactory {\r
-\r
- @Override\r
- public TextNode textNode(String text) {\r
- return new CustomTextNode(text);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.generator.tool;\r
-\r
-import com.fasterxml.jackson.core.io.CharTypes;\r
-import com.fasterxml.jackson.databind.node.TextNode;\r
-\r
-public class CustomTextNode extends TextNode {\r
-\r
- public CustomTextNode(String v) {\r
- super(v);\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- int len = textValue().length();\r
- len = len + 2 + (len >> 4);\r
- StringBuilder sb = new StringBuilder(len);\r
- appendQuoted(sb, textValue());\r
- return sb.toString();\r
- }\r
-\r
- protected static void appendQuoted(StringBuilder sb, String content) {\r
- CharTypes.appendQuoted(sb, content);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.generator.tool;\r
-\r
-import org.apache.commons.lang3.StringUtils;\r
-\r
-@SuppressWarnings("squid:S1118")\r
-public class EscapeUtils {\r
-\r
- public static String escapeSql(String str) {\r
- if (str == null) {\r
- return null;\r
- }\r
- String[] searchList = new String[] {"'", "\\"};\r
- String[] replacementList = new String[] {"''", "\\\\"};\r
- return StringUtils.replaceEach(str, searchList, replacementList);\r
- }\r
-\r
- // For Generic Purpose\r
- public static String escapeSequence(String s) {\r
- if (s == null) {\r
- return null;\r
- }\r
-\r
- int length = s.length();\r
- int newLength = length;\r
- for (int i = 0; i < length; i++) {\r
- char c = s.charAt(i);\r
- switch (c) {\r
- case '\\':\r
- case '\"':\r
- case '\'':\r
- case '\0':\r
- newLength += 1;\r
- break;\r
- default:\r
- // do nothing\r
- }\r
- }\r
- if (length == newLength) {\r
- // nothing to escape in the string\r
- return s;\r
- }\r
- StringBuilder sb = new StringBuilder(newLength);\r
- for (int i = 0; i < length; i++) {\r
- char c = s.charAt(i);\r
- switch (c) {\r
- case '\\':\r
- sb.append("\\\\");\r
- break;\r
- case '\"':\r
- sb.append("\\\"");\r
- break;\r
- case '\'':\r
- sb.append("\\\'");\r
- break;\r
- case '\0':\r
- sb.append("\\0");\r
- break;\r
- default:\r
- sb.append(c);\r
- }\r
- }\r
- return sb.toString();\r
- }\r
-\r
-}\r
+++ /dev/null
-<?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
- 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
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"\r
- xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"\r
- odl:use-default-for-reference-types="true">\r
-\r
- <reference id="configModelService"\r
- interface="org.onap.ccsdk.features.model.service.ConfigModelService" />\r
-\r
- <reference id="configResourceService"\r
- interface="org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService" />\r
-\r
- <!-- Expose the Common Component Bean -->\r
-\r
- <bean id="configGeneratorService"\r
- class="org.onap.ccsdk.features.generator.service.ConfigGeneratorServiceImpl">\r
- <argument ref="configResourceService" />\r
- </bean>\r
-\r
- <service ref="configGeneratorService"\r
- interface="org.onap.ccsdk.features.generator.service.ConfigGeneratorService" />\r
-\r
- <bean id="configGeneratorNode"\r
- class="org.onap.ccsdk.features.generator.service.ConfigGeneratorNode">\r
- <argument ref="configResourceService" />\r
- <argument ref="configModelService" />\r
- </bean>\r
-\r
- <service ref="configGeneratorNode"\r
- interface="org.onap.ccsdk.features.generator.service.ConfigGeneratorNode" />\r
-\r
-\r
-</blueprint>\r
+++ /dev/null
-<?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
- 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
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"\r
- xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"\r
- odl:use-default-for-reference-types="true">\r
-\r
- <reference id="configModelService"\r
- interface="org.onap.ccsdk.features.model.service.ConfigModelService" />\r
-\r
- <reference id="configResourceService"\r
- interface="org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService" />\r
-\r
- <!-- Expose the Common Component Bean -->\r
-\r
- <bean id="configGeneratorService"\r
- class="org.onap.ccsdk.features.generator.service.ConfigGeneratorServiceImpl">\r
- <argument ref="configResourceService" />\r
- </bean>\r
-\r
- <service ref="configGeneratorService"\r
- interface="org.onap.ccsdk.features.generator.service.ConfigGeneratorService" />\r
-\r
- <bean id="configGeneratorNode"\r
- class="org.onap.ccsdk.features.generator.service.ConfigGeneratorNode">\r
- <argument ref="configResourceService" />\r
- <argument ref="configModelService" />\r
- </bean>\r
-\r
- <service ref="configGeneratorNode"\r
- interface="org.onap.ccsdk.features.generator.service.ConfigGeneratorNode" />\r
-\r
-\r
-</blueprint>\r
+++ /dev/null
-/*\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.features.generator.service;\r
-\r
-import static org.mockito.Matchers.any;\r
-import java.nio.charset.Charset;\r
-import java.util.ArrayList;\r
-import java.util.Arrays;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.apache.commons.io.IOUtils;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mock;\r
-import org.mockito.Mockito;\r
-import org.mockito.MockitoAnnotations;\r
-import org.mockito.invocation.InvocationOnMock;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.mockito.stubbing.Answer;\r
-import org.onap.ccsdk.features.data.adaptor.domain.ConfigResource;\r
-import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog;\r
-import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService;\r
-import org.onap.ccsdk.features.generator.ConfigGeneratorConstant;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.service.ConfigModelService;\r
-import org.onap.ccsdk.features.model.service.ConfigModelServiceImpl;\r
-import org.onap.ccsdk.features.model.utils.TransformationUtils;\r
-import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class ConfigGeneratorNodeTest {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigGeneratorNodeTest.class);\r
-\r
- @Mock\r
- private ConfigResourceService configResourceService;\r
-\r
- @Mock\r
- private ConfigRestAdaptorService configRestAdaptorService;\r
-\r
- private ConfigModelService configModelService;\r
-\r
- @Before\r
- public void setUp() throws Exception {\r
-\r
- configModelService = new ConfigModelServiceImpl(configRestAdaptorService);\r
-\r
- MockitoAnnotations.initMocks(this);\r
-\r
- try {\r
- Mockito.doAnswer(new Answer<Void>() {\r
- @Override\r
- public Void answer(InvocationOnMock invocationOnMock) throws Throwable {\r
- Object[] args = invocationOnMock.getArguments();\r
- if (args != null) {\r
- logger.trace("Transaction info " + Arrays.asList(args));\r
- }\r
- return null;\r
- }\r
- }).when(configResourceService).save(any(TransactionLog.class));\r
-\r
- Mockito.doAnswer(new Answer<List<ConfigResource>>() {\r
- @Override\r
- public List<ConfigResource> answer(InvocationOnMock invocationOnMock) throws Throwable {\r
- List<ConfigResource> configResources = new ArrayList<>();\r
- Object[] args = invocationOnMock.getArguments();\r
- if (args != null) {\r
- logger.trace("Transaction info " + Arrays.asList(args));\r
- String resourceData = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader()\r
- .getResourceAsStream("service_templates/configdata.json"), Charset.defaultCharset());\r
- ConfigResource configResource = (ConfigResource) args[0];\r
- configResource.setRecipeName("Sample-recipe");\r
- configResource.setResourceData(resourceData);\r
- configResources.add(configResource);\r
- }\r
- return configResources;\r
- }\r
- }).when(configResourceService).getConfigResource(any(ConfigResource.class));\r
-\r
- } catch (SvcLogicException e) {\r
- e.printStackTrace();\r
- }\r
- }\r
-\r
- @Test\r
- public void testInputTemplateContentNData() throws Exception {\r
-\r
- ConfigGeneratorNode configGeneratorNode = new ConfigGeneratorNode(configResourceService, configModelService);\r
-\r
- Map<String, String> inParams = new HashMap<String, String>();\r
- inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "test");\r
-\r
- String jsonData = IOUtils.toString(\r
- ConfigGeneratorNodeTest.class.getClassLoader().getResourceAsStream("service_templates/configdata.json"),\r
- Charset.defaultCharset());\r
- inParams.put(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_DATA, jsonData);\r
-\r
- String templateData = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader()\r
- .getResourceAsStream("service_templates/velocity/base-config-template.vtl"), Charset.defaultCharset());\r
- inParams.put(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_CONTENT, templateData);\r
-\r
- SvcLogicContext ctx = new SvcLogicContext();\r
- Map<String, Object> componentContext = new HashMap<>();\r
- configGeneratorNode.process(inParams, ctx, componentContext);\r
- Assert.assertEquals("Failed to generate Configuration Status as Failure",\r
- ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS,\r
- ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS));\r
- Assert.assertNotNull("Failed to generate Configuration",\r
- ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG));\r
-\r
- logger.trace("Generated Configuration:\n "\r
- + ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG));\r
- logger.trace("Generated Configuration:\n "\r
- + ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_MASK_INFO));\r
-\r
- }\r
-\r
- @Test\r
- public void testInputTemplateWithNullData() throws Exception {\r
-\r
- ConfigGeneratorNode configGeneratorNode = new ConfigGeneratorNode(configResourceService, configModelService);\r
-\r
- Map<String, String> inParams = new HashMap<String, String>();\r
- inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "test");\r
-\r
- String jsonData = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader()\r
- .getResourceAsStream("service_templates/configdata_with_null.json"), Charset.defaultCharset());\r
- inParams.put(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_DATA, jsonData);\r
-\r
- String templateData = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader()\r
- .getResourceAsStream("service_templates/velocity/base-config-template.vtl"), Charset.defaultCharset());\r
- inParams.put(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_CONTENT, templateData);\r
-\r
- SvcLogicContext ctx = new SvcLogicContext();\r
- Map<String, Object> componentContext = new HashMap<>();\r
- configGeneratorNode.process(inParams, ctx, componentContext);\r
- Assert.assertEquals("Failed to generate Configuration Status as Failure",\r
- ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS,\r
- ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS));\r
- Assert.assertNotNull("Failed to generate Configuration",\r
- ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG));\r
-\r
- logger.trace("Generated Configuration:\n "\r
- + ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG));\r
- logger.trace("Generated Configuration:\n "\r
- + ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_MASK_INFO));\r
-\r
- }\r
-\r
- @Test\r
- public void testDBTemplateContentNData() throws Exception {\r
-\r
- String fileContent = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader()\r
- .getResourceAsStream("service_templates/generate_configuration.json"), Charset.defaultCharset());\r
-\r
- String baseConfigTemplateContent = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader()\r
- .getResourceAsStream("service_templates/velocity/base-config-template.vtl"), Charset.defaultCharset());\r
-\r
- Map<String, String> context = new HashMap<>();\r
- context = configModelService.convertServiceTemplate2Properties(fileContent, context);\r
-\r
- context.put("node_templates.base-config-template.content", baseConfigTemplateContent);\r
-\r
- Assert.assertNotNull("Failed to Prepare Context : ", context);\r
-\r
- context.put("request-id", "12345");\r
- context.put("vnf-id", "vnf12345");\r
- context.put("action-name", "config-generator-action");\r
-\r
- Map<String, String> inparams = new HashMap<String, String>();\r
- inparams.put(ConfigModelConstant.PROPERTY_SELECTOR, "generate-configuration");\r
-\r
- SvcLogicContext inputContext = new SvcLogicContext();\r
- context.forEach((name, value) -> {\r
- inputContext.setAttribute(name, value);\r
- });\r
-\r
- TransformationUtils.printMap(context);\r
- configModelService.assignInParamsFromModel(inputContext, inparams);\r
- ConfigGeneratorNode configGeneratorNode = new ConfigGeneratorNode(configResourceService, configModelService);\r
-\r
- Map<String, Object> componentContext = new HashMap<>();\r
- configGeneratorNode.process(inparams, inputContext, componentContext);\r
-\r
- Assert.assertEquals("Failed to generate Configuration Status as Failure",\r
- ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS,\r
- inputContext.getAttribute("generate-configuration." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS));\r
- Assert.assertNotNull("Failed to generate Configuration", inputContext\r
- .getAttribute("generate-configuration." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG));\r
-\r
- logger.trace("Generated Configuration:\n " + inputContext\r
- .getAttribute("generate-configuration." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG));\r
- }\r
-\r
- @Test\r
- public void testTemplateContentNDataForMask() throws Exception {\r
-\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.generator.tool;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-\r
-public class EscapeUtilsTest {\r
-\r
- @Test\r
- public void testEscapeSql() {\r
- Assert.assertEquals("", EscapeUtils.escapeSql(""));\r
- Assert.assertEquals("text", EscapeUtils.escapeSql("text"));\r
-\r
- Assert.assertEquals("''", EscapeUtils.escapeSql("'"));\r
- Assert.assertEquals("\\\\", EscapeUtils.escapeSql("\\"));\r
-\r
- Assert.assertEquals("text''text", EscapeUtils.escapeSql("text'text"));\r
- Assert.assertEquals("text\\\\text", EscapeUtils.escapeSql("text\\text"));\r
- }\r
-\r
- @Test\r
- public void testEscapeSequence() {\r
- Assert.assertEquals("", EscapeUtils.escapeSequence(""));\r
- Assert.assertEquals("text", EscapeUtils.escapeSequence("text"));\r
-\r
- Assert.assertEquals("\\\'", EscapeUtils.escapeSequence("'"));\r
- Assert.assertEquals("\\\"", EscapeUtils.escapeSequence("\""));\r
- Assert.assertEquals("\\\\", EscapeUtils.escapeSequence("\\"));\r
-\r
- Assert.assertEquals("text\\\'text", EscapeUtils.escapeSequence("text'text"));\r
- Assert.assertEquals("text\\\"text", EscapeUtils.escapeSequence("text\"text"));\r
- Assert.assertEquals("text\\\\text", EscapeUtils.escapeSequence("text\\text"));\r
- }\r
-\r
-}\r
+++ /dev/null
-{\r
- "node0_hostname": "appc-host",\r
- "node0_backup_router_address": "2001:2001:2001:2001:2001:2001:2001:2001",\r
- "servers": [\r
- "Server1",\r
- "Server2",\r
- "Server3"\r
- ],\r
- "tacplus-servers": [\r
- {\r
- "tacplus-server-name": "tacplus-server-name1",\r
- "tacplus-server-source-address": "enc-dsdsasa1"\r
- },\r
- {\r
- "tacplus-server-name": "tacplus-server-name2",\r
- "tacplus-server-source-address": "enc-dsdsasa2"\r
- }\r
- ],\r
- "classes": [\r
- {\r
- "name": "superuser-class",\r
- "idle-timeout": 5,\r
- "permissions": "all"\r
- },\r
- {\r
- "name": "tacacs-adv-class",\r
- "idle-timeout": 5\r
- },\r
- {\r
- "name": "tacacs-base-class",\r
- "idle-timeout": 5\r
- }\r
- ],\r
- "system-password": "teamops-system-password",\r
- "root-password": "teamops-root-password"\r
-}\r
+++ /dev/null
-{\r
- "node0_hostname": null,\r
- "node0_backup_router_address": "2001:2001:2001:2001:2001:2001:2001:2001",\r
- "servers": [\r
- "Server1",\r
- "Server2",\r
- "Server3"\r
- ],\r
- "tacplus-servers": [\r
- {\r
- "tacplus-server-name": null,\r
- "tacplus-server-source-address": "enc-dsdsasa1"\r
- },\r
- {\r
- "tacplus-server-name": "tacplus-server-name2",\r
- "tacplus-server-source-address": "enc-dsdsasa2"\r
- }\r
- ],\r
- "classes": [\r
- {\r
- "name": "superuser-class",\r
- "idle-timeout": 5,\r
- "permissions": "all"\r
- },\r
- {\r
- "name": "tacacs-adv-class",\r
- "idle-timeout": 5\r
- },\r
- {\r
- "name": "tacacs-base-class",\r
- "idle-timeout": 5\r
- }\r
- ],\r
- "system-password": "teamops-system-password",\r
- "root-password": "teamops-root-password"\r
-}
\ No newline at end of file
+++ /dev/null
-{\r
- "metadata": {\r
- "author": "ks220y@att.com",\r
- "service-template-name": "VRR-baseconfiguration",\r
- "service-template-version": "1.0.0",\r
- "service-type": "AVPN",\r
- "vnf-type": "VRR",\r
- "action": "Base Configuration",\r
- "sub-action": "Generate Configuration"\r
- },\r
- "topology_template": {\r
- "inputs": {\r
- "request-id": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "service-instance-id": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "vnf-id": {\r
- "required": true,\r
- "type": "string"\r
- }\r
- },\r
- "node_templates": {\r
- "base-config-template": {\r
- "type": "artifact-config-template",\r
- "properties": {\r
- "action-names": [\r
- "resource-assignment-action"\r
- ]\r
- },\r
- "capabilities": {\r
- "content": {\r
- "properties": {\r
- "content": "db://base-config-template"\r
- }\r
- },\r
- "mapping": {\r
- "properties": {\r
- "mapping": [\r
- {\r
- "name": "bundle-id",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "bundle-id",\r
- "dictionary-source": "mdsal"\r
- },\r
- {\r
- "name": "bundle-mac",\r
- "input-param": true,\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "bundle-mac",\r
- "dictionary-source": "db"\r
- }\r
- ]\r
- }\r
- }\r
- }\r
- },\r
- "generate-configuration": {\r
- "type": "component-config-generator",\r
- "interfaces": {\r
- "org-onap-ccsdk-features-generator-service-ConfigGeneratorNode": {\r
- "operations": {\r
- "process": {\r
- "inputs": {\r
- "resource-type": "vnf-type",\r
- "request-id": "{ \"get_attribute\" : \"request-id\" }",\r
- "resource-id": "{ \"get_input\" : \"vnf-id\" }",\r
- "action-name": "{ \"get_attribute\" : \"action-name\" }",\r
- "template-name": "base-config-template"\r
- },\r
- "outputs": {\r
- "generated-config": "",\r
- "status": ""\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "capabilities": {\r
- "component-node": {\r
- \r
- }\r
- }\r
- },\r
- "config-generator-action": {\r
- "type": "dg-config-generator",\r
- "interfaces": {\r
- "CONFIG": {\r
- "operations": {\r
- "GenerateConfiguration": {\r
- \r
- }\r
- }\r
- }\r
- },\r
- "capabilities": {\r
- "dg-node": {\r
- \r
- }\r
- },\r
- "requirements": {\r
- "component-dependency": {\r
- "capability": "component-node",\r
- "node": "generate-configuration",\r
- "relationship": "tosca.relationships.DependsOn"\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "node_types": {\r
- "artifact-config-template": {\r
- "description": "This is Configuration Velocity Template",\r
- "version": "1.0.0",\r
- "properties": {\r
- "action-names": {\r
- "required": true,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "string"\r
- }\r
- }\r
- },\r
- "capabilities": {\r
- "content": {\r
- "type": "tosca.capabilities.Content",\r
- "properties": {\r
- "content": {\r
- "required": true,\r
- "type": "string"\r
- }\r
- }\r
- },\r
- "mapping": {\r
- "type": "tosca.capabilities.Mapping",\r
- "properties": {\r
- "mapping": {\r
- "required": false,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "datatype-resource-assignment"\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "derived_from": "tosca.nodes.Artifact"\r
- },\r
- "component-config-generator": {\r
- "description": "This is Generate Configuration Component API",\r
- "version": "1.0.0",\r
- "capabilities": {\r
- "component-node": {\r
- "type": "tosca.capabilities.Node"\r
- }\r
- },\r
- "interfaces": {\r
- "org-onap-ccsdk-features-generator-service-ConfigGeneratorNode": {\r
- "operations": {\r
- "process": {\r
- "inputs": {\r
- "template-data": {\r
- "description": "Conditional : JSON string which is used to mash with template. Either template-data or ( resource-id and resource-type ) should be present",\r
- "required": false,\r
- "type": "string"\r
- },\r
- "template-content": {\r
- "description": "Conditional : Dynamic Template used to generate Configuration.",\r
- "required": false,\r
- "type": "string"\r
- },\r
- "resource-type": {\r
- "description": "Conditional : resource-type used to pull the data content from the data base. Either template-data or ( resource-id and resource-type ) should be present",\r
- "required": false,\r
- "type": "string"\r
- },\r
- "request-id": {\r
- "description": "Request Id used to store the generated configuration, in the database along with the template-name",\r
- "required": true,\r
- "type": "string"\r
- },\r
- "resource-id": {\r
- "description": "Conditional : Id used to pull the data content from the data base. Either template-data or ( resource-id and resource-type ) should be present",\r
- "required": false,\r
- "type": "string"\r
- },\r
- "action-name": {\r
- "description": "Conditional : Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",\r
- "required": false,\r
- "type": "string"\r
- },\r
- "template-name": {\r
- "description": "Conditional : Name of the Artifact Node Template, to get the template Content. If template-content is present, then content wont be reterived from the Artifact Node Template.",\r
- "required": true,\r
- "type": "string"\r
- }\r
- },\r
- "outputs": {\r
- "generated-config": {\r
- "description": "Generated Configuration for the Template adn Resource Data",\r
- "required": true,\r
- "type": "string"\r
- },\r
- "mask-info": {\r
- "description": "If template contains mask encription keys, then this mask-info field will be generated, This JSON Content alligns to the bean org.onap.ccsdk.features.model.data.custom.MaskInfo ",\r
- "required": false,\r
- "type": "string"\r
- },\r
- "status": {\r
- "description": "Status of the Component Execution ( success or failure )",\r
- "required": true,\r
- "type": "string"\r
- }\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "derived_from": "tosca.nodes.Component"\r
- },\r
- "dg-config-generator": {\r
- "description": "This is Activate DG for Config Generator Directed Graph",\r
- "version": "1.0.0",\r
- "properties": {\r
- "mode": {\r
- "required": false,\r
- "type": "string",\r
- "default": "sync"\r
- },\r
- "version": {\r
- "required": false,\r
- "type": "string",\r
- "default": "LATEST"\r
- },\r
- "is-start-flow": {\r
- "required": false,\r
- "type": "boolean",\r
- "default": "false"\r
- }\r
- },\r
- "capabilities": {\r
- "dg-node": {\r
- "type": "tosca.capabilities.Node"\r
- },\r
- "content": {\r
- "type": "tosca.capabilities.Content",\r
- "properties": {\r
- "type": {\r
- "required": false,\r
- "type": "string",\r
- "default": "json"\r
- },\r
- "content": {\r
- "required": true,\r
- "type": "string"\r
- }\r
- }\r
- }\r
- },\r
- "requirements": {\r
- "component-dependency": {\r
- "capability": "component-node",\r
- "node": "component-config-generator",\r
- "relationship": "tosca.relationships.DependsOn"\r
- }\r
- },\r
- "interfaces": {\r
- "CONFIG": {\r
- "operations": {\r
- "GenerateConfiguration": {\r
- "inputs": {\r
- "params": {\r
- "required": false,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "datatype-property"\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "derived_from": "tosca.nodes.DG"\r
- }\r
- },\r
- "data_types": {\r
- "datatype-resource-assignment": {\r
- "version": "1.0.0",\r
- "description": "This is Resource Assignment Data Type",\r
- "properties": {\r
- "property": {\r
- "required": true,\r
- "type": "datatype-property"\r
- },\r
- "input-param": {\r
- "required": true,\r
- "type": "boolean"\r
- },\r
- "dictionary-name": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "dictionary-source": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "dependencies": {\r
- "required": true,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "string"\r
- }\r
- }\r
- },\r
- "derived_from": "tosca.datatypes.Root"\r
- },\r
- "datatype-property": {\r
- "version": "1.0.0",\r
- "description": "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs",\r
- "properties": {\r
- "type": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "description": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "required": {\r
- "required": false,\r
- "type": "boolean"\r
- },\r
- "default": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "entry_schema": {\r
- "required": false,\r
- "type": "string"\r
- }\r
- },\r
- "derived_from": "tosca.datatypes.Root"\r
- }\r
- }\r
-}\r
+++ /dev/null
-<configuration xmlns="http://xml.juniper.net/xnm/1.1/xnm"\r
-xmlns:a="http://xml.juniper.net/junos/15.1X49/junos">\r
- <version>15.1X49-D50.3</version> \r
- <groups>\r
- <name>node0</name>\r
- <system>\r
- #foreach($server in ${servers})\r
- <server-host-name>$StringUtils.upperCase("$server")</server-host-name>\r
- #end\r
- </system>\r
- <system>\r
- <host-name>${node0_hostname}</host-name>\r
- <backup-router>\r
- <address>${node0_backup_router_address}</address>\r
- <destination>$node0_backup_router_address</destination>\r
- </backup-router>\r
- #foreach($tacplus-server in ${tacplus-servers})\r
- <tacplus-server>\r
- <name>$tacplus-server.tacplus-server-name</name>\r
- <source-address>$tacplus-server.tacplus-server-source-address</source-address>\r
- </tacplus-server>\r
- #end\r
- <login>\r
- <message>AT&T information assets</message>\r
- #foreach($class in ${classes})\r
- <class>\r
- <name>$class.name</name>\r
- <idle-timeout>$class.idle-timeout</idle-timeout>\r
- #if ($class.permissions)\r
- <permissions>$class.permissions</permissions>\r
- #end\r
- </class>\r
- #end \r
- <user>\r
- <name>readonly</name>\r
- <full-name>Read Only Account Access</full-name>\r
- <uid>1001</uid>\r
- <class>tacacs-base-class</class>\r
- </user>\r
- <user>\r
- <name>readwrite</name>\r
- <full-name>Read - Write Account Access</full-name>\r
- <uid>1002</uid>\r
- <class>tacacs-adv-class</class>\r
- <authentication>\r
- <encrypted-password>${system-password}</encrypted-password>\r
- </authentication>\r
- </user>\r
- <user>\r
- <name>readwrite</name>\r
- <full-name>Emergency Access Only</full-name>\r
- <uid>1000</uid>\r
- <class>superuser-class</class>\r
- <authentication>\r
- <encrypted-password>${root-password}</encrypted-password>\r
- </authentication>\r
- </user>\r
- </login>\r
- </system> \r
- </groups> \r
-</configuration>
\ No newline at end of file
+++ /dev/null
- <config>\r
- <configuration>\r
- <groups>\r
- <name>${group-name}</name>\r
- <routing-instances>\r
- <instance>\r
- <name><*></name>\r
- <protocols>\r
- <pim>\r
- <dense-groups>\r
- <dynamic-reject />\r
- <pim-dense-group-type>\r
- <name>224.0.1.40/32</name>\r
- </pim-dense-group-type>\r
- <pim-dense-group-type>\r
- <name>224.0.1.39/32</name>\r
- </pim-dense-group-type>\r
- <pim-dense-group-type>\r
- <name>224.0.0.0/4</name>\r
- <reject />\r
- </pim-dense-group-type>\r
- </dense-groups>\r
- <rp>\r
- <auto-rp>\r
- <discovery />\r
- </auto-rp>\r
- </rp>\r
- <interface>\r
- <name><*></name>\r
- <disable />\r
- <priority>1000</priority>\r
- </interface>\r
- <reset-tracking-bit />\r
- </pim>\r
- </protocols>\r
- </instance>\r
- </routing-instances>\r
- </groups>\r
- </configuration>\r
- </config>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright © 2017-2018 AT&T Intellectual Property.
- Modifications Copyright © 2018 IBM.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onap.ccsdk.parent</groupId>
- <artifactId>binding-parent</artifactId>
- <version>1.5.2-SNAPSHOT</version>
- <relativePath/>
- </parent>
-
- <groupId>org.onap.ccsdk.features</groupId>
- <artifactId>blueprints-model-provider</artifactId>
- <version>0.7.1-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <name>ccsdk-features :: blueprints-processor-plugin :: ${project.artifactId}</name>
- <url>http://maven.apache.org</url>
-
- <dependencies>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-core</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.module</groupId>
- <artifactId>jackson-module-jsonSchema</artifactId>
- </dependency>
- <dependency>
- <groupId>com.jayway.jsonpath</groupId>
- <artifactId>json-path</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onap.ccsdk.features</groupId>
- <artifactId>blueprints-rest-adaptor-provider</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.ccsdk.features</groupId>
- <artifactId>blueprints-data-adaptor-provider</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito</artifactId>
- <version>1.6.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.javassist</groupId>
- <artifactId>javassist</artifactId>
- <version>3.21.0-GA</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <version>1.10.19</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-junit4</artifactId>
- <version>1.6.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-support</artifactId>
- <version>1.6.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-reflect</artifactId>
- <version>1.6.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-core</artifactId>
- <version>1.6.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-junit4</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.osgi-mock</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <configuration>
- <additionalparam>-Xdoclint:none</additionalparam>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Name>${project.artifactId}</Bundle-Name>
- <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>org.onap.ccsdk.features.model,
- org.onap.ccsdk.features.model.data,
- org.onap.ccsdk.features.model.data.api,
- org.onap.ccsdk.features.model.data.dict,
- org.onap.ccsdk.features.model.domain,
- org.onap.ccsdk.features.model.service,
- org.onap.ccsdk.features.model.utils,
- org.onap.ccsdk.features.model.validator
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-/*\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.features.model;\r
-\r
-public class ConfigModelConstant {\r
-\r
- private ConfigModelConstant() {\r
-\r
- }\r
-\r
- public static final String STATUS_CODE_SUCCESS = "200";\r
- public static final String STATUS_CODE_FAILURE = "400";\r
-\r
- public static final String STATUS_SUCCESS = "success";\r
- public static final String STATUS_FAILURE = "failure";\r
- public static final String STATUS_SKIPPED = "skipped";\r
-\r
- public static final String CONFIG_STATUS_PENDING = "pending";\r
- public static final String CONFIG_STATUS_FAILED = "failed";\r
- public static final String CONFIG_STATUS_SUCCESS = "success";\r
-\r
- public static final String USER_SYSTEM = "System";\r
- public static final String PROTOCOL_NETCONF = "netconf";\r
-\r
- public static final String MODEL_CONTENT_TYPE_TOSCA_JSON = "TOSCA_JSON";\r
- public static final String MODEL_CONTENT_TYPE_TOSCA_YAML = "TOSCA_YAML";\r
- public static final String MODEL_CONTENT_TYPE_TEMPLATE = "TEMPLATE";\r
- public static final String MODEL_CONTENT_TYPE_YANG = "YANG";\r
- public static final String MODEL_CONTENT_TYPE_SCHEMA = "SCHEMA";\r
-\r
- public static final String SERVICE_TEMPLATE_KEY_ARTIFACT_AUTHOR = "author";\r
- public static final String SERVICE_TEMPLATE_KEY_ARTIFACT_NAME = "service-template-name";\r
- public static final String SERVICE_TEMPLATE_KEY_ARTIFACT_VERSION = "service-template-version";\r
-\r
- public static final String MODEL_DEFINITION_TYPE_NODE_TYPE = "node_type";\r
- public static final String MODEL_DEFINITION_TYPE_CAPABILITY_TYPE = "capability_type";\r
- public static final String MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE = "relationship_type";\r
- public static final String MODEL_DEFINITION_TYPE_DATA_TYPE = "data_type";\r
- public static final String MODEL_DEFINITION_TYPE_ARTIFACT_TYPE = "artifact_type";\r
-\r
- public static final String MODEL_TYPE_DATA_TYPE = "tosca.datatypes.Root";\r
- public static final String MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic";\r
- public static final String MODEL_TYPE_NODE_TYPE = "tosca.nodes.Root";\r
-\r
- public static final String MODEL_TYPE_NODE_DG = "tosca.nodes.DG";\r
- public static final String MODEL_TYPE_NODE_COMPONENT = "tosca.nodes.Component";\r
- public static final String MODEL_TYPE_NODE_COMPONENT_PYTHON = "tosca.nodes.Component.Python";\r
- public static final String MODEL_TYPE_NODE_VNF = "tosca.nodes.Vnf";\r
- public static final String MODEL_TYPE_NODE_ARTIFACT = "tosca.nodes.Artifact";\r
-\r
- public static final String MODEL_TYPE_ARTIFACT_TEMPLATE = "tosca.artifact.Template";\r
- public static final String MODEL_TYPE_ARTIFACT_LICENCE = "tosca.artifacts.Licence";\r
-\r
- public static final String MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON = "tosca.relationships.DependsOn";\r
- public static final String MODEL_TYPE_RELATIONSHIPS_HOSTED_ON = "tosca.relationships.HostedOn";\r
- public static final String MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO = "tosca.relationships.ConnectsTo";\r
- public static final String MODEL_TYPE_RELATIONSHIPS_ATTACH_TO = "tosca.relationships.AttachesTo";\r
- public static final String MODEL_TYPE_RELATIONSHIPS_ROUTES_TO = "tosca.relationships.RoutesTo";\r
-\r
- public static final String NODE_TEMPLATE_TYPE_ARTIFACT_CONFIG_TEMPLATE = "artifact-config-template";\r
-\r
- public static final String CAPABILITY_PROPERTY_MAPPING = "mapping";\r
- public static final String CAPABILITY_PROPERTY_CONTENT = "content";\r
-\r
- public static final String SOURCE_INPUT = "input";\r
- public static final String SOURCE_DEFAULT = "default";\r
- public static final String SOURCE_MDSAL = "mdsal";\r
- public static final String SOURCE_DB = "db";\r
- public static final String SOURCE_COMPONENT = "component";\r
-\r
- public static final String PROPERTY_STATUS = "status";\r
- public static final String PROPERTY_ERROR_CODE = "error-code";\r
- public static final String PROPERTY_ERROR_MESSAGE = "error-message";\r
-\r
- public static final String PROPERTY_REQUEST_INPUT = "request-input";\r
- public static final String PROPERTY_REQUEST_HEADER = "request-header";\r
- public static final String PROPERTY_REQUEST_PAYLOAD = "request-payload";\r
-\r
- public static final String PROPERTY_RESPONSE_PAYLOAD = "response-payload";\r
- public static final String PROPERTY_RESPONSE_JSON_NODE = "response-json-node";\r
-\r
- public static final String PROPERTY_PAYLOAD = "payload";\r
- public static final String PROPERTY_INPUTS = "inputs";\r
- public static final String PROPERTY_ORGINATOR_ID = "originator-id";\r
- public static final String PROPERTY_API_VERSION = "api-ver";\r
- public static final String PROPERTY_REQUEST_ID = "request-id";\r
- public static final String PROPERTY_SUB_REQUEST_ID = "sub-request-id";\r
- public static final String PROPERTY_REQUEST = "request";\r
- public static final String PROPERTY_RECIPE = "action";\r
-\r
- public static final String PROPERTY_SELECTOR = "prifix";\r
- public static final String PROPERTY_NODE_TEMPLATES = "node_templates";\r
- public static final String PROPERTY_NODE_TYPES = "node_types";\r
- public static final String PROPERTY_DATA_TYPES = "data_types";\r
- public static final String PROPERTY_ACTION_NAME = "action-name";\r
- public static final String PROPERTY_ACTION_PREFIX = "action-prefix";\r
- public static final String PROPERTY_TEMPLATE_NAME = "template-name";\r
-\r
- public static final String PROPERTY_CURRENT_INTERFACE = "current-interface";\r
- public static final String PROPERTY_CURRENT_OPERATION = "current-operation";\r
- public static final String PROPERTY_CURRENT_IMPLEMENTATION = "current-implementation";\r
- public static final String PROPERTY_CURRENT_NODETYPE_DERIVED_FROM = "current-node-type-derived-from";\r
- public static final String PROPERTY_CURRENT_RESOURCE_ASSIGNMENT = "current-resource-assignment";\r
- public static final String PROPERTY_CURRENT_DICTIONARY_DEFINITION = "current-dictionary-definition";\r
- public static final String PROPERTY_RESOURCE_ASSIGNMENTS_DATA = "resource-assignments-data";\r
-\r
- public static final String PROPERTY_RECIPE_NAMES = "action-names";\r
- public static final String PROPERTY_DICTIONARIES = "dictionaries";\r
- public static final String PROPERTY_RESOURCE_ASSIGNMENTS = "resource-assignments";\r
- public static final String PROPERTY_RESOURCE_KEY = "resource-key";\r
- public static final String PROPERTY_RESOURCE_NAME = "resource-name";\r
- public static final String PROPERTY_RESERVATION_ID = "reservation-id";\r
-\r
- public static final String PROPERTY_NODE_TEMPLATES_DOT = "node_templates.";\r
- public static final String PROPERTY_NODE_TYPES_DOT = "node_types.";\r
- public static final String PROPERTY_DATA_TYPES_DOT = "data_types.";\r
- public static final String PROPERTY_INPUTS_DOT = "inputs.";\r
- public static final String PROPERTY_ARTIFACTS_DOT = "artifacts.";\r
- public static final String PROPERTY_DICTIONARY_KEY_DOT = "dictionary-key.";\r
- public static final String PROPERTY_TEMPLATE_KEY_DOT = "template-key.";\r
- public static final String PROPERTY_RECIPE_KEY_DOT = "recipe-key.";\r
-\r
- public static final String PROPERTY_DOT_STATUS = ".status";\r
- public static final String PROPERTY_DOT_ERROR_MESSAGE = ".error-message";\r
-\r
- public static final String EXPRESSION_GET_INPUT = "get_input";\r
- public static final String EXPRESSION_GET_ATTRIBUTE = "get_attribute";\r
- public static final String EXPRESSION_SET_VALUE = "set_value";\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model;\r
-\r
-/**\r
- * ConfigGeneratorException.java Purpose: Provide Configuration Generator ConfigGeneratorException\r
- *\r
- * @version 1.0\r
- */\r
-public class ConfigModelException extends Exception {\r
-\r
- /**\r
- *\r
- */\r
- private static final long serialVersionUID = 1L;\r
-\r
- /**\r
- * This is a ConfigGeneratorException constructor\r
- *\r
- * @param message\r
- */\r
- public ConfigModelException(String message) {\r
- super(message);\r
- }\r
-\r
- /**\r
- * This is a ConfigGeneratorException constructor\r
- *\r
- * @param message\r
- */\r
- public ConfigModelException(String message, Throwable cause) {\r
- super(message, cause);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-/**\r
- * ValidTypes.java Purpose: Provide Configuration Generator ValidTypes\r
- *\r
- * @version 1.0\r
- */\r
-public class ValidTypes {\r
-\r
- public static final String DATA_TYPE_STRING = "string";\r
- public static final String DATA_TYPE_INTEGER = "integer";\r
- public static final String DATA_TYPE_FLOAT = "float";\r
- public static final String DATA_TYPE_BOOLEAN = "boolean";\r
- public static final String DATA_TYPE_TIMESTAMP = "timestamp";\r
- public static final String DATA_TYPE_NULL = "null";\r
- public static final String DATA_TYPE_LIST = "list";\r
- public static final String DATA_TYPE_LONGTEXT = "longtext";\r
-\r
- private ValidTypes() {\r
-\r
- }\r
-\r
- public static List<String> getValidModelTypes() {\r
- List<String> validTypes = new ArrayList<>();\r
- validTypes.add(ConfigModelConstant.MODEL_DEFINITION_TYPE_DATA_TYPE);\r
- validTypes.add(ConfigModelConstant.MODEL_DEFINITION_TYPE_NODE_TYPE);\r
- validTypes.add(ConfigModelConstant.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE);\r
- validTypes.add(ConfigModelConstant.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE);\r
- return validTypes;\r
- }\r
-\r
- public static List<String> getValidNodeTypes() {\r
- List<String> validTypes = new ArrayList<>();\r
- validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_DG);\r
- validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_COMPONENT);\r
- validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_VNF);\r
- validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_ARTIFACT);\r
- return validTypes;\r
- }\r
-\r
- public static List<String> getValidDerivedFrom() {\r
- List<String> validTypes = new ArrayList<>();\r
- validTypes.add(ConfigModelConstant.MODEL_TYPE_DATA_TYPE_DYNAMIC);\r
- validTypes.add(ConfigModelConstant.MODEL_TYPE_DATA_TYPE);\r
- validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_TYPE);\r
- return validTypes;\r
- }\r
-\r
- public static List<String> getValidDataTypeDerivedFrom() {\r
- List<String> validTypes = new ArrayList<>();\r
- validTypes.add(ConfigModelConstant.MODEL_TYPE_DATA_TYPE_DYNAMIC);\r
- validTypes.add(ConfigModelConstant.MODEL_TYPE_DATA_TYPE);\r
- return validTypes;\r
- }\r
-\r
- public static List<String> getValidPropertType() {\r
- List<String> validTypes = new ArrayList<>();\r
- validTypes.add(DATA_TYPE_STRING);\r
- validTypes.add(DATA_TYPE_INTEGER);\r
- validTypes.add(DATA_TYPE_FLOAT);\r
- validTypes.add(DATA_TYPE_BOOLEAN);\r
- validTypes.add(DATA_TYPE_TIMESTAMP);\r
- validTypes.add(DATA_TYPE_NULL);\r
- validTypes.add(DATA_TYPE_LIST);\r
- return validTypes;\r
- }\r
-\r
- public static List<String> getPrimitivePropertType() {\r
- List<String> validTypes = new ArrayList<>();\r
- validTypes.add(DATA_TYPE_STRING);\r
- validTypes.add(DATA_TYPE_INTEGER);\r
- validTypes.add(DATA_TYPE_FLOAT);\r
- validTypes.add(DATA_TYPE_BOOLEAN);\r
- validTypes.add(DATA_TYPE_TIMESTAMP);\r
- validTypes.add(DATA_TYPE_NULL);\r
- return validTypes;\r
- }\r
-\r
- public static List<String> getListPropertType() {\r
- List<String> validTypes = new ArrayList<>();\r
- validTypes.add(DATA_TYPE_LIST);\r
- return validTypes;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.data;\r
-\r
-import com.fasterxml.jackson.annotation.JsonIgnore;\r
-import com.fasterxml.jackson.annotation.JsonProperty;\r
-\r
-/**\r
- * ArtifactDefinition.java Purpose: Provide ArtifactDefinition TOSCO Model POJO bean.\r
- *\r
- * @version 1.0\r
- */\r
-public class ArtifactDefinition {\r
- @JsonIgnore\r
- private String id;\r
- private String type;\r
- private String file;\r
- private String repository;\r
- private String description;\r
- @JsonProperty("deploy_Path")\r
- private String deployPath;\r
- // Used for Template Type\r
- private String content;\r
- private String mappingContent;\r
-\r
- public String getId() {\r
- return id;\r
- }\r
-\r
- public void setId(String id) {\r
- this.id = id;\r
- }\r
-\r
- public String getType() {\r
- return type;\r
- }\r
-\r
- public void setType(String type) {\r
- this.type = type;\r
- }\r
-\r
- public String getFile() {\r
- return file;\r
- }\r
-\r
- public void setFile(String file) {\r
- this.file = file;\r
- }\r
-\r
- public String getRepository() {\r
- return repository;\r
- }\r
-\r
- public void setRepository(String repository) {\r
- this.repository = repository;\r
- }\r
-\r
- public String getDescription() {\r
- return description;\r
- }\r
-\r
- public void setDescription(String description) {\r
- this.description = description;\r
- }\r
-\r
- public String getDeployPath() {\r
- return deployPath;\r
- }\r
-\r
- public void setDeployPath(String deployPath) {\r
- this.deployPath = deployPath;\r
- }\r
-\r
- public String getContent() {\r
- return content;\r
- }\r
-\r
- public void setContent(String content) {\r
- this.content = content;\r
- }\r
-\r
- public String getMappingContent() {\r
- return mappingContent;\r
- }\r
-\r
- public void setMappingContent(String mappingContent) {\r
- this.mappingContent = mappingContent;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.data;\r
-\r
-import java.util.List;\r
-import java.util.Map;\r
-import com.fasterxml.jackson.annotation.JsonIgnore;\r
-import com.fasterxml.jackson.annotation.JsonProperty;\r
-\r
-public class ArtifactType {\r
- @JsonIgnore\r
- private String id;\r
- private String description;\r
- private String version;\r
- private Map<String, String> metadata;\r
- @JsonProperty("derived_from")\r
- private String derivedFrom;\r
- private Map<String, PropertyDefinition> properties;\r
- @JsonProperty("mime_type")\r
- private String mimeType;\r
- @JsonProperty("file_ext")\r
- private List<String> fileExt;\r
-\r
- public String getId() {\r
- return id;\r
- }\r
-\r
- public void setId(String id) {\r
- this.id = id;\r
- }\r
-\r
- public String getDescription() {\r
- return description;\r
- }\r
-\r
- public void setDescription(String description) {\r
- this.description = description;\r
- }\r
-\r
- public String getVersion() {\r
- return version;\r
- }\r
-\r
- public void setVersion(String version) {\r
- this.version = version;\r
- }\r
-\r
- public Map<String, String> getMetadata() {\r
- return metadata;\r
- }\r
-\r
- public void setMetadata(Map<String, String> metadata) {\r
- this.metadata = metadata;\r
- }\r
-\r
- public String getDerivedFrom() {\r
- return derivedFrom;\r
- }\r
-\r
- public void setDerivedFrom(String derivedFrom) {\r
- this.derivedFrom = derivedFrom;\r
- }\r
-\r
- public Map<String, PropertyDefinition> getProperties() {\r
- return properties;\r
- }\r
-\r
- public void setProperties(Map<String, PropertyDefinition> properties) {\r
- this.properties = properties;\r
- }\r
-\r
- public String getMimeType() {\r
- return mimeType;\r
- }\r
-\r
- public void setMimeType(String mimeType) {\r
- this.mimeType = mimeType;\r
- }\r
-\r
- public List<String> getFileExt() {\r
- return fileExt;\r
- }\r
-\r
- public void setFileExt(List<String> fileExt) {\r
- this.fileExt = fileExt;\r
- }\r
-}\r
+++ /dev/null
-/*\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.features.model.data;\r
-\r
-import java.util.Map;\r
-import com.fasterxml.jackson.annotation.JsonIgnore;\r
-\r
-/**\r
- * CapabilityAssignment.java Purpose: Provide CapabilityAssignment TOSCO Model POJO bean.\r
- *\r
- * @version 1.0\r
- */\r
-public class CapabilityAssignment {\r
- @JsonIgnore\r
- private String id;\r
- private Map<String, Object> properties;\r
-\r
- public String getId() {\r
- return id;\r
- }\r
-\r
- public void setId(String id) {\r
- this.id = id;\r
- }\r
-\r
- public Map<String, Object> getProperties() {\r
- return properties;\r
- }\r
-\r
- public void setProperties(Map<String, Object> properties) {\r
- this.properties = properties;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.data;\r
-\r
-import java.util.List;\r
-import java.util.Map;\r
-import com.fasterxml.jackson.annotation.JsonIgnore;\r
-import com.fasterxml.jackson.annotation.JsonProperty;\r
-\r
-/**\r
- * CapabilityDefinition.java Purpose: Provide CapabilityDefinition TOSCO Model POJO bean.\r
- *\r
- * @version 1.0\r
- */\r
-public class CapabilityDefinition {\r
- @JsonIgnore\r
- private String id;\r
- private String type;\r
- private String description;\r
- private Map<String, PropertyDefinition> properties;\r
- @JsonProperty("valid_source_types")\r
- private List<String> validSourceTypes;\r
- private List<Object> occurrences;\r
-\r
- public String getId() {\r
- return id;\r
- }\r
-\r
- public void setId(String id) {\r
- this.id = id;\r
- }\r
-\r
- public String getType() {\r
- return type;\r
- }\r
-\r
- public void setType(String type) {\r
- this.type = type;\r
- }\r
-\r
- public String getDescription() {\r
- return description;\r
- }\r
-\r
- public void setDescription(String description) {\r
- this.description = description;\r
- }\r
-\r
- public Map<String, PropertyDefinition> getProperties() {\r
- return properties;\r
- }\r
-\r
- public void setProperties(Map<String, PropertyDefinition> properties) {\r
- this.properties = properties;\r
- }\r
-\r
- public List<String> getValidSourceTypes() {\r
- return validSourceTypes;\r
- }\r
-\r
- public void setValidSourceTypes(List<String> validSourceTypes) {\r
- this.validSourceTypes = validSourceTypes;\r
- }\r
-\r
- public List<Object> getOccurrences() {\r
- return occurrences;\r
- }\r
-\r
- public void setOccurrences(List<Object> occurrences) {\r
- this.occurrences = occurrences;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.data;\r
-\r
-import java.util.List;\r
-import com.fasterxml.jackson.annotation.JsonProperty;\r
-\r
-/**\r
- * ConstraintClause.java Purpose: 3.5.2 Constraint clause.\r
- *\r
- * @version 1.0\r
- */\r
-public class ConstraintClause {\r
- @JsonProperty("equal")\r
- private Object equal;\r
-\r
- @JsonProperty("greater_than")\r
- private Object greaterThan;\r
-\r
- @JsonProperty("greater_or_equal")\r
- private Object greaterOrEqual;\r
-\r
- @JsonProperty("less_than")\r
- private Object lessThan;\r
-\r
- @JsonProperty("less_or_equal")\r
- private Object lessOrEqual;\r
-\r
- @JsonProperty("in_range")\r
- private Object inRange;\r
-\r
- @JsonProperty("valid_values")\r
- private List<Object> validValues;\r
-\r
- @JsonProperty("length")\r
- private Object length;\r
-\r
- @JsonProperty("min_length")\r
- private Object minLength;\r
-\r
- @JsonProperty("max_length")\r
- private Object maxLength;\r
-\r
- @JsonProperty("pattern")\r
- private String pattern;\r
-\r
- public Object getEqual() {\r
- return equal;\r
- }\r
-\r
- public void setEqual(Object equal) {\r
- this.equal = equal;\r
- }\r
-\r
- public Object getGreaterThan() {\r
- return greaterThan;\r
- }\r
-\r
- public void setGreaterThan(Object greaterThan) {\r
- this.greaterThan = greaterThan;\r
- }\r
-\r
- public Object getGreaterOrEqual() {\r
- return greaterOrEqual;\r
- }\r
-\r
- public void setGreaterOrEqual(Object greaterOrEqual) {\r
- this.greaterOrEqual = greaterOrEqual;\r
- }\r
-\r
- public Object getLessThan() {\r
- return lessThan;\r
- }\r
-\r
- public void setLessThan(Object lessThan) {\r
- this.lessThan = lessThan;\r
- }\r
-\r
- public Object getLessOrEqual() {\r
- return lessOrEqual;\r
- }\r
-\r
- public void setLessOrEqual(Object lessOrEqual) {\r
- this.lessOrEqual = lessOrEqual;\r
- }\r
-\r
- public Object getInRange() {\r
- return inRange;\r
- }\r
-\r
- public void setInRange(Object inRange) {\r
- this.inRange = inRange;\r
- }\r
-\r
- public List<Object> getValidValues() {\r
- return validValues;\r
- }\r
-\r
- public void setValidValues(List<Object> validValues) {\r
- this.validValues = validValues;\r
- }\r
-\r
- public Object getLength() {\r
- return length;\r
- }\r
-\r
- public void setLength(Object length) {\r
- this.length = length;\r
- }\r
-\r
- public Object getMinLength() {\r
- return minLength;\r
- }\r
-\r
- public void setMinLength(Object minLength) {\r
- this.minLength = minLength;\r
- }\r
-\r
- public Object getMaxLength() {\r
- return maxLength;\r
- }\r
-\r
- public void setMaxLength(Object maxLength) {\r
- this.maxLength = maxLength;\r
- }\r
-\r
- public String getPattern() {\r
- return pattern;\r
- }\r
-\r
- public void setPattern(String pattern) {\r
- this.pattern = pattern;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.data;\r
-\r
-import java.util.List;\r
-import java.util.Map;\r
-import com.fasterxml.jackson.annotation.JsonIgnore;\r
-import com.fasterxml.jackson.annotation.JsonProperty;\r
-\r
-/**\r
- * DataType.java Purpose: Provide DataType TOSCO Model POJO bean.\r
- *\r
- * @version 1.0\r
- */\r
-public class DataType {\r
- @JsonIgnore\r
- private String id;\r
- private String version;\r
- private String description;\r
- @JsonProperty("derived_from")\r
- private String derivedFrom;\r
- private List<Map<String, Object>> constraints;\r
- private Map<String, PropertyDefinition> properties;\r
-\r
- public String getId() {\r
- return id;\r
- }\r
-\r
- public void setId(String id) {\r
- this.id = id;\r
- }\r
-\r
- public String getVersion() {\r
- return version;\r
- }\r
-\r
- public void setVersion(String version) {\r
- this.version = version;\r
- }\r
-\r
- public String getDescription() {\r
- return description;\r
- }\r
-\r
- public void setDescription(String description) {\r
- this.description = description;\r
- }\r
-\r
- public String getDerivedFrom() {\r
- return derivedFrom;\r
- }\r
-\r
- public void setDerivedFrom(String derivedFrom) {\r
- this.derivedFrom = derivedFrom;\r
- }\r
-\r
- public List<Map<String, Object>> getConstraints() {\r
- return constraints;\r
- }\r
-\r
- public void setConstraints(List<Map<String, Object>> constraints) {\r
- this.constraints = constraints;\r
- }\r
-\r
- public Map<String, PropertyDefinition> getProperties() {\r
- return properties;\r
- }\r
-\r
- public void setProperties(Map<String, PropertyDefinition> properties) {\r
- this.properties = properties;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.data;\r
-\r
-/**\r
- * EntrySchema.java Purpose: Provide EntrySchema TOSCO Model POJO bean.\r
- *\r
- * @version 1.0\r
- */\r
-public class EntrySchema {\r
- private String type;\r
-\r
- public String getType() {\r
- return type;\r
- }\r
-\r
- public void setType(String type) {\r
- this.type = type;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.data;\r
-\r
-import java.util.List;\r
-import com.fasterxml.jackson.annotation.JsonIgnore;\r
-\r
-/**\r
- * Implementation.java Purpose: Provide Operation Implementation TOSCO Model POJO bean.\r
- *\r
- * @version 1.0\r
- */\r
-public class Implementation {\r
- @JsonIgnore\r
- private String primary;\r
- private List<String> dependencies;\r
-\r
- public String getPrimary() {\r
- return primary;\r
- }\r
-\r
- public void setPrimary(String primary) {\r
- this.primary = primary;\r
- }\r
-\r
- public List<String> getDependencies() {\r
- return dependencies;\r
- }\r
-\r
- public void setDependencies(List<String> dependencies) {\r
- this.dependencies = dependencies;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.data;\r
-\r
-import java.util.Map;\r
-import com.fasterxml.jackson.annotation.JsonIgnore;\r
-\r
-/**\r
- * InterfaceAssignment.java Purpose: Provide InterfaceAssignment TOSCO Model POJO bean.\r
- *\r
- * @version 1.0\r
- */\r
-public class InterfaceAssignment {\r
- @JsonIgnore\r
- private String id;\r
- private String type;\r
- private Map<String, OperationAssignment> operations;\r
-\r
- public String getId() {\r
- return id;\r
- }\r
-\r
- public void setId(String id) {\r
- this.id = id;\r
- }\r
-\r
- public String getType() {\r
- return type;\r
- }\r
-\r
- public void setType(String type) {\r
- this.type = type;\r
- }\r
-\r
- public Map<String, OperationAssignment> getOperations() {\r
- return operations;\r
- }\r
-\r
- public void setOperations(Map<String, OperationAssignment> operations) {\r
- this.operations = operations;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.data;\r
-\r
-import java.util.Map;\r
-import com.fasterxml.jackson.annotation.JsonIgnore;\r
-\r
-/**\r
- * InterfaceAssignment.java Purpose: Provide InterfaceAssignment TOSCO Model POJO bean.\r
- *\r
- * @version 1.0\r
- */\r
-public class InterfaceDefinition {\r
- @JsonIgnore\r
- private String id;\r
- private String type;\r
- private Map<String, OperationDefinition> operations;\r
-\r
- public String getId() {\r
- return id;\r
- }\r
-\r
- public void setId(String id) {\r
- this.id = id;\r
- }\r
-\r
- public String getType() {\r
- return type;\r
- }\r
-\r
- public void setType(String type) {\r
- this.type = type;\r
- }\r
-\r
- public Map<String, OperationDefinition> getOperations() {\r
- return operations;\r
- }\r
-\r
- public void setOperations(Map<String, OperationDefinition> operations) {\r
- this.operations = operations;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.data;\r
-\r
-import java.util.Map;\r
-import com.fasterxml.jackson.annotation.JsonIgnore;\r
-\r
-/**\r
- * NodeTemplate.java Purpose: Provide NodeTemplate TOSCO Model POJO bean.\r
- *\r
- * @version 1.0\r
- */\r
-public class NodeTemplate {\r
- @JsonIgnore\r
- private String id;\r
- private String description;\r
- private String type;\r
- private Map<String, String> metadata;\r
- private Map<String, Object> properties;\r
- private Map<String, InterfaceAssignment> interfaces;\r
- private Map<String, ArtifactDefinition> artifacts;\r
- private Map<String, CapabilityAssignment> capabilities;\r
- private Map<String, RequirementAssignment> requirements;\r
-\r
- public String getId() {\r
- return id;\r
- }\r
-\r
- public void setId(String id) {\r
- this.id = id;\r
- }\r
-\r
- public String getDescription() {\r
- return description;\r
- }\r
-\r
- public void setDescription(String description) {\r
- this.description = description;\r
- }\r
-\r
- public String getType() {\r
- return type;\r
- }\r
-\r
- public void setType(String type) {\r
- this.type = type;\r
- }\r
-\r
- public Map<String, String> getMetadata() {\r
- return metadata;\r
- }\r
-\r
- public void setMetadata(Map<String, String> metadata) {\r
- this.metadata = metadata;\r
- }\r
-\r
- public Map<String, Object> getProperties() {\r
- return properties;\r
- }\r
-\r
- public void setProperties(Map<String, Object> properties) {\r
- this.properties = properties;\r
- }\r
-\r
- public Map<String, InterfaceAssignment> getInterfaces() {\r
- return interfaces;\r
- }\r
-\r
- public void setInterfaces(Map<String, InterfaceAssignment> interfaces) {\r
- this.interfaces = interfaces;\r
- }\r
-\r
- public Map<String, ArtifactDefinition> getArtifacts() {\r
- return artifacts;\r
- }\r
-\r
- public void setArtifacts(Map<String, ArtifactDefinition> artifacts) {\r
- this.artifacts = artifacts;\r
- }\r
-\r
- public Map<String, CapabilityAssignment> getCapabilities() {\r
- return capabilities;\r
- }\r
-\r
- public void setCapabilities(Map<String, CapabilityAssignment> capabilities) {\r
- this.capabilities = capabilities;\r
- }\r
-\r
- public Map<String, RequirementAssignment> getRequirements() {\r
- return requirements;\r
- }\r
-\r
- public void setRequirements(Map<String, RequirementAssignment> requirements) {\r
- this.requirements = requirements;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.data;\r
-\r
-import java.util.Map;\r
-import com.fasterxml.jackson.annotation.JsonIgnore;\r
-import com.fasterxml.jackson.annotation.JsonProperty;\r
-\r
-/**\r
- * NodeType.java Purpose: Provide NodeType TOSCO Model POJO bean.\r
- *\r
- * @version 1.0\r
- */\r
-public class NodeType {\r
- @JsonIgnore\r
- private String id;\r
- private String description;\r
- private String version;\r
- private Map<String, String> metadata;\r
- @JsonProperty("derived_from")\r
- private String derivedFrom;\r
- private Map<String, PropertyDefinition> properties;\r
- private Map<String, CapabilityDefinition> capabilities;\r
- private Map<String, RequirementDefinition> requirements;\r
- private Map<String, InterfaceDefinition> interfaces;\r
-\r
- public String getId() {\r
- return id;\r
- }\r
-\r
- public void setId(String id) {\r
- this.id = id;\r
- }\r
-\r
- public String getDescription() {\r
- return description;\r
- }\r
-\r
- public void setDescription(String description) {\r
- this.description = description;\r
- }\r
-\r
- public String getVersion() {\r
- return version;\r
- }\r
-\r
- public void setVersion(String version) {\r
- this.version = version;\r
- }\r
-\r
- public Map<String, String> getMetadata() {\r
- return metadata;\r
- }\r
-\r
- public void setMetadata(Map<String, String> metadata) {\r
- this.metadata = metadata;\r
- }\r
-\r
- public String getDerivedFrom() {\r
- return derivedFrom;\r
- }\r
-\r
- public void setDerivedFrom(String derivedFrom) {\r
- this.derivedFrom = derivedFrom;\r
- }\r
-\r
- public Map<String, PropertyDefinition> getProperties() {\r
- return properties;\r
- }\r
-\r
- public void setProperties(Map<String, PropertyDefinition> properties) {\r
- this.properties = properties;\r
- }\r
-\r
- public Map<String, CapabilityDefinition> getCapabilities() {\r
- return capabilities;\r
- }\r
-\r
- public void setCapabilities(Map<String, CapabilityDefinition> capabilities) {\r
- this.capabilities = capabilities;\r
- }\r
-\r
- public Map<String, RequirementDefinition> getRequirements() {\r
- return requirements;\r
- }\r
-\r
- public void setRequirements(Map<String, RequirementDefinition> requirements) {\r
- this.requirements = requirements;\r
- }\r
-\r
- public Map<String, InterfaceDefinition> getInterfaces() {\r
- return interfaces;\r
- }\r
-\r
- public void setInterfaces(Map<String, InterfaceDefinition> interfaces) {\r
- this.interfaces = interfaces;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.data;\r
-\r
-import java.util.Map;\r
-import com.fasterxml.jackson.annotation.JsonIgnore;\r
-\r
-/**\r
- * OperationAssignment.java Purpose: Provide OperationAssignment TOSCO Model POJO bean.\r
- *\r
- * @version 1.0\r
- */\r
-public class OperationAssignment {\r
- @JsonIgnore\r
- private String id;\r
- private String description;\r
- private String implementation;\r
- private Map<String, Object> inputs;\r
- private Map<String, Object> outputs;\r
-\r
- public String getId() {\r
- return id;\r
- }\r
-\r
- public void setId(String id) {\r
- this.id = id;\r
- }\r
-\r
- public String getDescription() {\r
- return description;\r
- }\r
-\r
- public void setDescription(String description) {\r
- this.description = description;\r
- }\r
-\r
- public String getImplementation() {\r
- return implementation;\r
- }\r
-\r
- public void setImplementation(String implementation) {\r
- this.implementation = implementation;\r
- }\r
-\r
- public Map<String, Object> getInputs() {\r
- return inputs;\r
- }\r
-\r
- public void setInputs(Map<String, Object> inputs) {\r
- this.inputs = inputs;\r
- }\r
-\r
- public Map<String, Object> getOutputs() {\r
- return outputs;\r
- }\r
-\r
- public void setOutputs(Map<String, Object> outputs) {\r
- this.outputs = outputs;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.data;\r
-\r
-import java.util.Map;\r
-import com.fasterxml.jackson.annotation.JsonIgnore;\r
-\r
-/**\r
- * OperationDefinition.java Purpose: Provide OperationDefinition TOSCO Model POJO bean.\r
- *\r
- * @version 1.0\r
- */\r
-public class OperationDefinition {\r
- @JsonIgnore\r
- private String id;\r
- private String description;\r
- private Implementation implementation;\r
- private Map<String, PropertyDefinition> inputs;\r
- private Map<String, PropertyDefinition> outputs;\r
-\r
- public String getId() {\r
- return id;\r
- }\r
-\r
- public void setId(String id) {\r
- this.id = id;\r
- }\r
-\r
- public String getDescription() {\r
- return description;\r
- }\r
-\r
- public void setDescription(String description) {\r
- this.description = description;\r
- }\r
-\r
- public Implementation getImplementation() {\r
- return implementation;\r
- }\r
-\r
- public void setImplementation(Implementation implementation) {\r
- this.implementation = implementation;\r
- }\r
-\r
- public Map<String, PropertyDefinition> getInputs() {\r
- return inputs;\r
- }\r
-\r
- public void setInputs(Map<String, PropertyDefinition> inputs) {\r
- this.inputs = inputs;\r
- }\r
-\r
- public Map<String, PropertyDefinition> getOutputs() {\r
- return outputs;\r
- }\r
-\r
- public void setOutputs(Map<String, PropertyDefinition> outputs) {\r
- this.outputs = outputs;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.data;\r
-\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import com.fasterxml.jackson.annotation.JsonIgnore;\r
-import com.fasterxml.jackson.annotation.JsonProperty;\r
-\r
-/**\r
- * PropertyDefinition.java Purpose: Provide PropertyDefinition TOSCO Model POJO bean.\r
- *\r
- * @version 1.0\r
- */\r
-public class PropertyDefinition {\r
- @JsonIgnore\r
- private String id;\r
- private String description;\r
- private Boolean required;\r
- private String type;\r
- @JsonProperty("default")\r
- private Object defaultValue;\r
- private String status;\r
- private List<HashMap<String, Object>> constraints;\r
- @JsonProperty("entry_schema")\r
- private EntrySchema entrySchema;\r
- private Object value;\r
-\r
- @Override\r
- public String toString() {\r
- StringBuilder builder = new StringBuilder("[");\r
- builder.append(" type :" + getType());\r
- builder.append(", value :" + getValue());\r
- builder.append("]");\r
- return builder.toString();\r
- }\r
-\r
- public String getId() {\r
- return id;\r
- }\r
-\r
- public void setId(String id) {\r
- this.id = id;\r
- }\r
-\r
- public String getDescription() {\r
- return description;\r
- }\r
-\r
- public void setDescription(String description) {\r
- this.description = description;\r
- }\r
-\r
- public Boolean getRequired() {\r
- return required;\r
- }\r
-\r
- public void setRequired(Boolean required) {\r
- this.required = required;\r
- }\r
-\r
- public String getType() {\r
- return type;\r
- }\r
-\r
- public void setType(String type) {\r
- this.type = type;\r
- }\r
-\r
- public Object getDefaultValue() {\r
- return defaultValue;\r
- }\r
-\r
- public void setDefaultValue(Object defaultValue) {\r
- this.defaultValue = defaultValue;\r
- }\r
-\r
- public String getStatus() {\r
- return status;\r
- }\r
-\r
- public void setStatus(String status) {\r
- this.status = status;\r
- }\r
-\r
- public List<HashMap<String, Object>> getConstraints() {\r
- return constraints;\r
- }\r
-\r
- public void setConstraints(List<HashMap<String, Object>> constraints) {\r
- this.constraints = constraints;\r
- }\r
-\r
- public EntrySchema getEntrySchema() {\r
- return entrySchema;\r
- }\r
-\r
- public void setEntrySchema(EntrySchema entrySchema) {\r
- this.entrySchema = entrySchema;\r
- }\r
-\r
- public Object getValue() {\r
- return value;\r
- }\r
-\r
- public void setValue(Object value) {\r
- this.value = value;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.data;\r
-\r
-import java.util.Map;\r
-\r
-/**\r
- * RelationshipTemplate.java Purpose: Provide RelationshipTemplate TOSCO Model POJO bean.\r
- *\r
- * @version 1.0\r
- */\r
-public class RelationshipTemplate {\r
- private String description;\r
- private String type;\r
- private Map<String, PropertyDefinition> properties;\r
-\r
- public String getDescription() {\r
- return description;\r
- }\r
-\r
- public void setDescription(String description) {\r
- this.description = description;\r
- }\r
-\r
- public String getType() {\r
- return type;\r
- }\r
-\r
- public void setType(String type) {\r
- this.type = type;\r
- }\r
-\r
- public Map<String, PropertyDefinition> getProperties() {\r
- return properties;\r
- }\r
-\r
- public void setProperties(Map<String, PropertyDefinition> properties) {\r
- this.properties = properties;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.data;\r
-\r
-import com.fasterxml.jackson.annotation.JsonIgnore;\r
-\r
-/**\r
- * RequirementAssignment.java Purpose: Provide RequirementAssignment TOSCO Model POJO bean.\r
- *\r
- * @version 1.0\r
- */\r
-public class RequirementAssignment {\r
- @JsonIgnore\r
- private String id;\r
- private String capability;\r
- private String node;\r
- // Relationship Type or Relationship Template\r
- private String relationship;\r
-\r
- public String getId() {\r
- return id;\r
- }\r
-\r
- public void setId(String id) {\r
- this.id = id;\r
- }\r
-\r
- public String getCapability() {\r
- return capability;\r
- }\r
-\r
- public void setCapability(String capability) {\r
- this.capability = capability;\r
- }\r
-\r
- public String getNode() {\r
- return node;\r
- }\r
-\r
- public void setNode(String node) {\r
- this.node = node;\r
- }\r
-\r
- public String getRelationship() {\r
- return relationship;\r
- }\r
-\r
- public void setRelationship(String relationship) {\r
- this.relationship = relationship;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.data;\r
-\r
-import java.util.List;\r
-import com.fasterxml.jackson.annotation.JsonIgnore;\r
-\r
-/**\r
- * RequirementDefinition.java Purpose: Provide RequirementDefinition TOSCO Model POJO bean.\r
- *\r
- * @version 1.0\r
- */\r
-public class RequirementDefinition {\r
- @JsonIgnore\r
- private String id;\r
- private String description;\r
- private String capability;\r
- private String node;\r
- private String relationship;\r
- private List<Object> occurrences;\r
-\r
- public String getId() {\r
- return id;\r
- }\r
-\r
- public void setId(String id) {\r
- this.id = id;\r
- }\r
-\r
- public String getDescription() {\r
- return description;\r
- }\r
-\r
- public void setDescription(String description) {\r
- this.description = description;\r
- }\r
-\r
- public String getCapability() {\r
- return capability;\r
- }\r
-\r
- public void setCapability(String capability) {\r
- this.capability = capability;\r
- }\r
-\r
- public String getNode() {\r
- return node;\r
- }\r
-\r
- public void setNode(String node) {\r
- this.node = node;\r
- }\r
-\r
- public String getRelationship() {\r
- return relationship;\r
- }\r
-\r
- public void setRelationship(String relationship) {\r
- this.relationship = relationship;\r
- }\r
-\r
- public List<Object> getOccurrences() {\r
- return occurrences;\r
- }\r
-\r
- public void setOccurrences(List<Object> occurrences) {\r
- this.occurrences = occurrences;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.data;\r
-\r
-import java.util.Date;\r
-import java.util.List;\r
-import com.fasterxml.jackson.annotation.JsonFormat;\r
-import com.fasterxml.jackson.annotation.JsonProperty;\r
-\r
-/**\r
- * ResourceAssignment.java Purpose: Provide ResourceAssignment Custom TOSCO Model POJO bean.\r
- *\r
- * @version 1.0\r
- */\r
-public class ResourceAssignment {\r
-\r
- private String name;\r
-\r
- @JsonProperty("property")\r
- private PropertyDefinition property;\r
-\r
- @JsonProperty("input-param")\r
- private Boolean inputParameter;\r
-\r
- @JsonProperty("dictionary-name")\r
- private String dictionaryName;\r
-\r
- @JsonProperty("dictionary-source")\r
- private String dictionarySource;\r
-\r
- @JsonProperty("dependencies")\r
- private List<String> dependencies;\r
-\r
- @JsonProperty("version")\r
- private int version;\r
-\r
- @JsonProperty("status")\r
- private String status;\r
-\r
- @JsonProperty("message")\r
- private String message;\r
-\r
- @JsonProperty("updated-date")\r
- @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")\r
- private Date updatedDate;\r
-\r
- @JsonProperty("updated-by")\r
- private String updatedBy;\r
-\r
- @Override\r
- public String toString() {\r
- StringBuilder builder = new StringBuilder("[");\r
- builder.append("name = " + name);\r
- builder.append(", source = " + dictionarySource);\r
- if (dependencies != null) {\r
- builder.append(", dependencies = " + dependencies);\r
- }\r
- builder.append("]");\r
- return builder.toString();\r
- }\r
-\r
- public String getName() {\r
- return name;\r
- }\r
-\r
- public void setName(String name) {\r
- this.name = name;\r
- }\r
-\r
- public PropertyDefinition getProperty() {\r
- return property;\r
- }\r
-\r
- public void setProperty(PropertyDefinition property) {\r
- this.property = property;\r
- }\r
-\r
- public Boolean getInputParameter() {\r
- return inputParameter;\r
- }\r
-\r
- public void setInputParameter(Boolean inputParameter) {\r
- this.inputParameter = inputParameter;\r
- }\r
-\r
- public String getDictionaryName() {\r
- return dictionaryName;\r
- }\r
-\r
- public void setDictionaryName(String dictionaryName) {\r
- this.dictionaryName = dictionaryName;\r
- }\r
-\r
- public String getDictionarySource() {\r
- return dictionarySource;\r
- }\r
-\r
- public void setDictionarySource(String dictionarySource) {\r
- this.dictionarySource = dictionarySource;\r
- }\r
-\r
- public List<String> getDependencies() {\r
- return dependencies;\r
- }\r
-\r
- public void setDependencies(List<String> dependencies) {\r
- this.dependencies = dependencies;\r
- }\r
-\r
- public int getVersion() {\r
- return version;\r
- }\r
-\r
- public void setVersion(int version) {\r
- this.version = version;\r
- }\r
-\r
- public String getStatus() {\r
- return status;\r
- }\r
-\r
- public void setStatus(String status) {\r
- this.status = status;\r
- }\r
-\r
- public String getMessage() {\r
- return message;\r
- }\r
-\r
- public void setMessage(String message) {\r
- this.message = message;\r
- }\r
-\r
- public Date getUpdatedDate() {\r
- return updatedDate;\r
- }\r
-\r
- public void setUpdatedDate(Date updatedDate) {\r
- this.updatedDate = updatedDate;\r
- }\r
-\r
- public String getUpdatedBy() {\r
- return updatedBy;\r
- }\r
-\r
- public void setUpdatedBy(String updatedBy) {\r
- this.updatedBy = updatedBy;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.data;\r
-\r
-import java.util.Map;\r
-import com.fasterxml.jackson.annotation.JsonIgnore;\r
-import com.fasterxml.jackson.annotation.JsonProperty;\r
-\r
-/**\r
- * ServiceTemplate.java Purpose: Provide ServiceTemplate TOSCO Model POJO bean.\r
- *\r
- * @version 1.0\r
- */\r
-public class ServiceTemplate {\r
- @JsonIgnore\r
- private String id;\r
- @JsonProperty("tosca_definitions_version")\r
- private String toscaDefinitionsVersion;\r
- private Map<String, String> metadata;\r
- private String description;\r
- @JsonProperty("dsl_definitions")\r
- private Map<String, Object> dslDefinitions;\r
- @JsonProperty("topology_template")\r
- private TopologyTemplate topologyTemplate;\r
- @JsonProperty("artifact_types")\r
- private Map<String, ArtifactType> artifactTypes;\r
- @JsonProperty("node_types")\r
- private Map<String, NodeType> nodeTypes;\r
- @JsonProperty("data_types")\r
- private Map<String, DataType> dataTypes;\r
-\r
- public String getId() {\r
- return id;\r
- }\r
-\r
- public void setId(String id) {\r
- this.id = id;\r
- }\r
-\r
- public String getToscaDefinitionsVersion() {\r
- return toscaDefinitionsVersion;\r
- }\r
-\r
- public void setToscaDefinitionsVersion(String toscaDefinitionsVersion) {\r
- this.toscaDefinitionsVersion = toscaDefinitionsVersion;\r
- }\r
-\r
- public Map<String, String> getMetadata() {\r
- return metadata;\r
- }\r
-\r
- public void setMetadata(Map<String, String> metadata) {\r
- this.metadata = metadata;\r
- }\r
-\r
- public String getDescription() {\r
- return description;\r
- }\r
-\r
- public void setDescription(String description) {\r
- this.description = description;\r
- }\r
-\r
- public Map<String, Object> getDslDefinitions() {\r
- return dslDefinitions;\r
- }\r
-\r
- public void setDslDefinitions(Map<String, Object> dslDefinitions) {\r
- this.dslDefinitions = dslDefinitions;\r
- }\r
-\r
- public TopologyTemplate getTopologyTemplate() {\r
- return topologyTemplate;\r
- }\r
-\r
- public void setTopologyTemplate(TopologyTemplate topologyTemplate) {\r
- this.topologyTemplate = topologyTemplate;\r
- }\r
-\r
- public Map<String, NodeType> getNodeTypes() {\r
- return nodeTypes;\r
- }\r
-\r
- public void setNodeTypes(Map<String, NodeType> nodeTypes) {\r
- this.nodeTypes = nodeTypes;\r
- }\r
-\r
- public Map<String, DataType> getDataTypes() {\r
- return dataTypes;\r
- }\r
-\r
- public void setDataTypes(Map<String, DataType> dataTypes) {\r
- this.dataTypes = dataTypes;\r
- }\r
-\r
- public Map<String, ArtifactType> getArtifactTypes() {\r
- return artifactTypes;\r
- }\r
-\r
- public void setArtifactTypes(Map<String, ArtifactType> artifactTypes) {\r
- this.artifactTypes = artifactTypes;\r
- }\r
-}\r
+++ /dev/null
-/*\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.features.model.data;\r
-\r
-import java.util.Map;\r
-import com.fasterxml.jackson.annotation.JsonIgnore;\r
-import com.fasterxml.jackson.annotation.JsonProperty;\r
-\r
-/**\r
- * TopologyTemplate.java Purpose: Provide TopologyTemplate TOSCO Model POJO bean.\r
- *\r
- * @version 1.0\r
- */\r
-public class TopologyTemplate {\r
- @JsonIgnore\r
- private String id;\r
- private String description;\r
- private Map<String, PropertyDefinition> inputs;\r
- @JsonProperty("node_templates")\r
- private Map<String, NodeTemplate> nodeTemplates;\r
- @JsonProperty("relationship_templates")\r
- private Map<String, RelationshipTemplate> relationshipTemplates;\r
- private Map<String, CapabilityAssignment> capabilities;\r
- private Map<String, Workflow> workflows;\r
-\r
- public String getId() {\r
- return id;\r
- }\r
-\r
- public void setId(String id) {\r
- this.id = id;\r
- }\r
-\r
- public String getDescription() {\r
- return description;\r
- }\r
-\r
- public void setDescription(String description) {\r
- this.description = description;\r
- }\r
-\r
- public Map<String, PropertyDefinition> getInputs() {\r
- return inputs;\r
- }\r
-\r
- public void setInputs(Map<String, PropertyDefinition> inputs) {\r
- this.inputs = inputs;\r
- }\r
-\r
- public Map<String, NodeTemplate> getNodeTemplates() {\r
- return nodeTemplates;\r
- }\r
-\r
- public void setNodeTemplates(Map<String, NodeTemplate> nodeTemplates) {\r
- this.nodeTemplates = nodeTemplates;\r
- }\r
-\r
- public Map<String, RelationshipTemplate> getRelationshipTemplates() {\r
- return relationshipTemplates;\r
- }\r
-\r
- public void setRelationshipTemplates(Map<String, RelationshipTemplate> relationshipTemplates) {\r
- this.relationshipTemplates = relationshipTemplates;\r
- }\r
-\r
- public Map<String, CapabilityAssignment> getCapabilities() {\r
- return capabilities;\r
- }\r
-\r
- public void setCapabilities(Map<String, CapabilityAssignment> capabilities) {\r
- this.capabilities = capabilities;\r
- }\r
-\r
- public Map<String, Workflow> getWorkflows() {\r
- return workflows;\r
- }\r
-\r
- public void setWorkflows(Map<String, Workflow> workflows) {\r
- this.workflows = workflows;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.data;\r
-\r
-import com.fasterxml.jackson.annotation.JsonIgnore;\r
-\r
-/**\r
- * Workflow.java Purpose: Provide Workflow TOSCO Model POJO bean.\r
- *\r
- * @version 1.0\r
- */\r
-public class Workflow {\r
- @JsonIgnore\r
- private String id;\r
-\r
- public String getId() {\r
- return id;\r
- }\r
-\r
- public void setId(String id) {\r
- this.id = id;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.data.api;\r
-\r
-import com.fasterxml.jackson.annotation.JsonProperty;\r
-\r
-public class ActionIdentifiers {\r
- @JsonProperty("service-template-name")\r
- private String serviceTemplateName;\r
- @JsonProperty("service-template-version")\r
- private String serviceTemplateVersion;\r
- @JsonProperty("action-name")\r
- private String actionName;\r
- private String mode;\r
-\r
- public String getServiceTemplateName() {\r
- return serviceTemplateName;\r
- }\r
-\r
- public void setServiceTemplateName(String serviceTemplateName) {\r
- this.serviceTemplateName = serviceTemplateName;\r
- }\r
-\r
- public String getServiceTemplateVersion() {\r
- return serviceTemplateVersion;\r
- }\r
-\r
- public void setServiceTemplateVersion(String serviceTemplateVersion) {\r
- this.serviceTemplateVersion = serviceTemplateVersion;\r
- }\r
-\r
- public String getActionName() {\r
- return actionName;\r
- }\r
-\r
- public void setActionName(String actionName) {\r
- this.actionName = actionName;\r
- }\r
-\r
- public String getMode() {\r
- return mode;\r
- }\r
-\r
- public void setMode(String mode) {\r
- this.mode = mode;\r
- }\r
-}\r
+++ /dev/null
-/*\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.features.model.data.api;\r
-\r
-import com.fasterxml.jackson.annotation.JsonProperty;\r
-\r
-public class CommonHeader {\r
-\r
- private String timestamp;\r
- @JsonProperty("api-ver")\r
- private String apiVer;\r
- @JsonProperty("originator-id")\r
- private String originatorId;\r
- @JsonProperty("request-id")\r
- private String requestId;\r
- @JsonProperty("sub-request-id")\r
- private String subRequestId;\r
- private Flags flags;\r
-\r
- public String getTimestamp() {\r
- return timestamp;\r
- }\r
-\r
- public void setTimestamp(String timestamp) {\r
- this.timestamp = timestamp;\r
- }\r
-\r
- public String getApiVer() {\r
- return apiVer;\r
- }\r
-\r
- public void setApiVer(String apiVer) {\r
- this.apiVer = apiVer;\r
- }\r
-\r
- public String getOriginatorId() {\r
- return originatorId;\r
- }\r
-\r
- public void setOriginatorId(String originatorId) {\r
- this.originatorId = originatorId;\r
- }\r
-\r
- public String getRequestId() {\r
- return requestId;\r
- }\r
-\r
- public void setRequestId(String requestId) {\r
- this.requestId = requestId;\r
- }\r
-\r
- public String getSubRequestId() {\r
- return subRequestId;\r
- }\r
-\r
- public void setSubRequestId(String subRequestId) {\r
- this.subRequestId = subRequestId;\r
- }\r
-\r
- public Flags getFlags() {\r
- return flags;\r
- }\r
-\r
- public void setFlags(Flags flags) {\r
- this.flags = flags;\r
- }\r
-}\r
+++ /dev/null
-/*\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.features.model.data.api;\r
-\r
-public class Flags {\r
- private boolean force;\r
- private Integer ttl;\r
-\r
- public boolean isForce() {\r
- return force;\r
- }\r
-\r
- public void setForce(boolean force) {\r
- this.force = force;\r
- }\r
-\r
- public Integer getTtl() {\r
- return ttl;\r
- }\r
-\r
- public void setTtl(Integer ttl) {\r
- this.ttl = ttl;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.data.api;\r
-\r
-import com.fasterxml.jackson.annotation.JsonProperty;\r
-\r
-public class Status {\r
-\r
- private Integer code;\r
- @JsonProperty("error-message")\r
- private String errorMessage;\r
- private String message;\r
- private String completed;\r
-\r
- public Integer getCode() {\r
- return code;\r
- }\r
-\r
- public void setCode(Integer code) {\r
- this.code = code;\r
- }\r
-\r
- public String getErrorMessage() {\r
- return errorMessage;\r
- }\r
-\r
- public void setErrorMessage(String errorMessage) {\r
- this.errorMessage = errorMessage;\r
- }\r
-\r
- public String getMessage() {\r
- return message;\r
- }\r
-\r
- public void setMessage(String message) {\r
- this.message = message;\r
- }\r
-\r
- public String getCompleted() {\r
- return completed;\r
- }\r
-\r
- public void setCompleted(String completed) {\r
- this.completed = completed;\r
- }\r
-}\r
+++ /dev/null
-/*\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.features.model.data.api;\r
-\r
-import com.fasterxml.jackson.annotation.JsonProperty;\r
-\r
-public class TransactionRequest {\r
-\r
- @JsonProperty("transaction-request-id")\r
- private String transactionRequestId;\r
- @JsonProperty("message-type")\r
- private String messageType;\r
-\r
- public String getTransactionRequestId() {\r
- return transactionRequestId;\r
- }\r
-\r
- public void setTransactionRequestId(String transactionRequestId) {\r
- this.transactionRequestId = transactionRequestId;\r
- }\r
-\r
- public String getMessageType() {\r
- return messageType;\r
- }\r
-\r
- public void setMessageType(String messageType) {\r
- this.messageType = messageType;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.data.api;\r
-\r
-import java.util.List;\r
-import com.fasterxml.jackson.annotation.JsonProperty;\r
-\r
-public class TransactionResponse {\r
-\r
- @JsonProperty("transaction-request-id")\r
- private String transactionRequestId;\r
- @JsonProperty("event-message")\r
- private List<String> eventMessage;\r
-\r
- public String getTransactionRequestId() {\r
- return transactionRequestId;\r
- }\r
-\r
- public void setTransactionRequestId(String transactionRequestId) {\r
- this.transactionRequestId = transactionRequestId;\r
- }\r
-\r
- public List<String> getEventMessage() {\r
- return eventMessage;\r
- }\r
-\r
- public void setEventMessage(List<String> eventMessage) {\r
- this.eventMessage = eventMessage;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.data.dict;\r
-\r
-import java.util.Map;\r
-import org.onap.ccsdk.features.model.data.PropertyDefinition;\r
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;\r
-import com.fasterxml.jackson.annotation.JsonProperty;\r
-\r
-@JsonIgnoreProperties(ignoreUnknown = true)\r
-public class ResourceDefinition {\r
-\r
- @JsonProperty(value = "name", required = true)\r
- private String name;\r
-\r
- @JsonProperty(value = "tags")\r
- private String tags;\r
-\r
- @JsonProperty(value = "property")\r
- private PropertyDefinition property;\r
-\r
- @JsonProperty(value = "updated-by")\r
- private String updatedBy;\r
-\r
- @JsonProperty(value = "sources", required = true)\r
- private Map<String, SourcesDefinition> sourcesDefinition;\r
-\r
- public String getName() {\r
- return name;\r
- }\r
-\r
- public void setName(String name) {\r
- this.name = name;\r
- }\r
-\r
- public PropertyDefinition getProperty() {\r
- return property;\r
- }\r
-\r
- public void setProperty(PropertyDefinition property) {\r
- this.property = property;\r
- }\r
-\r
- public String getTags() {\r
- return tags;\r
- }\r
-\r
- public void setTags(String tags) {\r
- this.tags = tags;\r
- }\r
-\r
- public String getUpdatedBy() {\r
- return updatedBy;\r
- }\r
-\r
- public void setUpdatedBy(String updatedBy) {\r
- this.updatedBy = updatedBy;\r
- }\r
-\r
- public Map<String, SourcesDefinition> getSources() {\r
- return sourcesDefinition;\r
- }\r
-\r
- public void setSources(Map<String, SourcesDefinition> sourcesDefinition) {\r
- this.sourcesDefinition = sourcesDefinition;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.data.dict;\r
-\r
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;\r
-import com.fasterxml.jackson.annotation.JsonProperty;\r
-\r
-@JsonIgnoreProperties(ignoreUnknown = true)\r
-public class SourcesDefinition {\r
-\r
- @JsonProperty(value = "type", required = true)\r
- private String type;\r
-\r
- @JsonProperty(value = "properties", required = true)\r
- private SourcesProperties properties;\r
-\r
- public String getType() {\r
- return type;\r
- }\r
-\r
- public void setType(String type) {\r
- this.type = type;\r
- }\r
-\r
- public SourcesProperties getProperties() {\r
- return properties;\r
- }\r
-\r
- public void setProperties(SourcesProperties properties) {\r
- this.properties = properties;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.data.dict;\r
-\r
-import java.util.List;\r
-import java.util.Map;\r
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;\r
-import com.fasterxml.jackson.annotation.JsonProperty;\r
-\r
-@JsonIgnoreProperties(ignoreUnknown = true)\r
-public class SourcesProperties {\r
-\r
- @JsonProperty(value = "key")\r
- private String key;\r
-\r
- @JsonProperty(value = "type")\r
- private String type;\r
-\r
- @JsonProperty(value = "query")\r
- private String query;\r
-\r
- @JsonProperty(value = "url-path")\r
- private String urlPath;\r
-\r
- @JsonProperty(value = "expression-type")\r
- private String expressionType;\r
-\r
- @JsonProperty(value = "path")\r
- private String path;\r
-\r
- @JsonProperty("input-key-mapping")\r
- private Map<String, String> inputKeyMapping;\r
-\r
- @JsonProperty("output-key-mapping")\r
- private Map<String, String> outputKeyMapping;\r
-\r
- @JsonProperty("key-dependencies")\r
- private List<String> dependencies;\r
-\r
- public String getKey() {\r
- return key;\r
- }\r
-\r
- public void setKey(String key) {\r
- this.key = key;\r
- }\r
-\r
- public String getType() {\r
- return type;\r
- }\r
-\r
- public void setType(String type) {\r
- this.type = type;\r
- }\r
-\r
- public String getQuery() {\r
- return query;\r
- }\r
-\r
- public void setQuery(String query) {\r
- this.query = query;\r
- }\r
-\r
- public String getUrlPath() {\r
- return urlPath;\r
- }\r
-\r
- public void setUrlPath(String urlPath) {\r
- this.urlPath = urlPath;\r
- }\r
-\r
- public String getPath() {\r
- return path;\r
- }\r
-\r
- public void setExpressionType(String expressionType) {\r
- this.expressionType = expressionType;\r
- }\r
-\r
- public String getExpressionType() {\r
- return expressionType;\r
- }\r
-\r
- public void setPath(String path) {\r
- this.path = path;\r
- }\r
-\r
- public Map<String, String> getInputKeyMapping() {\r
- return inputKeyMapping;\r
- }\r
-\r
- public void setInputKeyMapping(Map<String, String> inputKeyMapping) {\r
- this.inputKeyMapping = inputKeyMapping;\r
- }\r
-\r
- public Map<String, String> getOutputKeyMapping() {\r
- return outputKeyMapping;\r
- }\r
-\r
- public void setOutputKeyMapping(Map<String, String> outputKeyMapping) {\r
- this.outputKeyMapping = outputKeyMapping;\r
- }\r
-\r
- public List<String> getDependencies() {\r
- return dependencies;\r
- }\r
-\r
- public void setDependencies(List<String> dependencies) {\r
- this.dependencies = dependencies;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.domain;\r
-\r
-import java.io.Serializable;\r
-import java.util.Date;\r
-import java.util.List;\r
-import com.fasterxml.jackson.annotation.JsonFormat;\r
-\r
-public class ConfigModel implements Serializable {\r
-\r
- private Long id;\r
- private String serviceUUID;\r
- private String distributionId;\r
- private String serviceName;\r
- private String serviceDescription;\r
- private String resourceUUID;\r
- private String resourceInstanceName;\r
- private String resourceName;\r
- private String resourceVersion;\r
- private String resourceType;\r
- private String artifactUUId;\r
- private String artifactType;\r
- private String artifactVersion;\r
- private String artifactDescription;\r
- private Integer internalVersion;\r
- @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")\r
- private Date createdDate = new Date();\r
- private String artifactName;\r
- private String published;\r
- private String updatedBy;\r
- private String tags;\r
- @SuppressWarnings("squid:S1948")\r
- private List<ConfigModelContent> configModelContents;\r
-\r
- @Override\r
- public String toString() {\r
- StringBuilder buffer = new StringBuilder("[");\r
- buffer.append("id = " + id);\r
- buffer.append(", artifactType = " + artifactType);\r
- buffer.append(", artifactVersion = " + artifactVersion);\r
- buffer.append(", artifactName = " + artifactName);\r
- buffer.append(", active = " + published);\r
- buffer.append("]");\r
- return buffer.toString();\r
- }\r
-\r
- public Long getId() {\r
- return id;\r
- }\r
-\r
- public void setId(Long id) {\r
- this.id = id;\r
- }\r
-\r
- public String getServiceUUID() {\r
- return serviceUUID;\r
- }\r
-\r
- public void setServiceUUID(String serviceUUID) {\r
- this.serviceUUID = serviceUUID;\r
- }\r
-\r
- public String getDistributionId() {\r
- return distributionId;\r
- }\r
-\r
- public void setDistributionId(String distributionId) {\r
- this.distributionId = distributionId;\r
- }\r
-\r
- public String getServiceName() {\r
- return serviceName;\r
- }\r
-\r
- public void setServiceName(String serviceName) {\r
- this.serviceName = serviceName;\r
- }\r
-\r
- public String getServiceDescription() {\r
- return serviceDescription;\r
- }\r
-\r
- public void setServiceDescription(String serviceDescription) {\r
- this.serviceDescription = serviceDescription;\r
- }\r
-\r
- public String getResourceUUID() {\r
- return resourceUUID;\r
- }\r
-\r
- public void setResourceUUID(String resourceUUID) {\r
- this.resourceUUID = resourceUUID;\r
- }\r
-\r
- public String getResourceInstanceName() {\r
- return resourceInstanceName;\r
- }\r
-\r
- public void setResourceInstanceName(String resourceInstanceName) {\r
- this.resourceInstanceName = resourceInstanceName;\r
- }\r
-\r
- public String getResourceName() {\r
- return resourceName;\r
- }\r
-\r
- public void setResourceName(String resourceName) {\r
- this.resourceName = resourceName;\r
- }\r
-\r
- public String getResourceVersion() {\r
- return resourceVersion;\r
- }\r
-\r
- public void setResourceVersion(String resourceVersion) {\r
- this.resourceVersion = resourceVersion;\r
- }\r
-\r
- public String getResourceType() {\r
- return resourceType;\r
- }\r
-\r
- public void setResourceType(String resourceType) {\r
- this.resourceType = resourceType;\r
- }\r
-\r
- public String getArtifactUUId() {\r
- return artifactUUId;\r
- }\r
-\r
- public void setArtifactUUId(String artifactUUId) {\r
- this.artifactUUId = artifactUUId;\r
- }\r
-\r
- public String getArtifactType() {\r
- return artifactType;\r
- }\r
-\r
- public void setArtifactType(String artifactType) {\r
- this.artifactType = artifactType;\r
- }\r
-\r
- public String getArtifactVersion() {\r
- return artifactVersion;\r
- }\r
-\r
- public void setArtifactVersion(String artifactVersion) {\r
- this.artifactVersion = artifactVersion;\r
- }\r
-\r
- public String getArtifactDescription() {\r
- return artifactDescription;\r
- }\r
-\r
- public void setArtifactDescription(String artifactDescription) {\r
- this.artifactDescription = artifactDescription;\r
- }\r
-\r
- public Integer getInternalVersion() {\r
- return internalVersion;\r
- }\r
-\r
- public void setInternalVersion(Integer internalVersion) {\r
- this.internalVersion = internalVersion;\r
- }\r
-\r
- public Date getCreatedDate() {\r
- return createdDate;\r
- }\r
-\r
- public void setCreatedDate(Date createdDate) {\r
- this.createdDate = createdDate;\r
- }\r
-\r
- public String getArtifactName() {\r
- return artifactName;\r
- }\r
-\r
- public void setArtifactName(String artifactName) {\r
- this.artifactName = artifactName;\r
- }\r
-\r
- public String getPublished() {\r
- return published;\r
- }\r
-\r
- public void setPublished(String published) {\r
- this.published = published;\r
- }\r
-\r
- public String getUpdatedBy() {\r
- return updatedBy;\r
- }\r
-\r
- public void setUpdatedBy(String updatedBy) {\r
- this.updatedBy = updatedBy;\r
- }\r
-\r
- public String getTags() {\r
- return tags;\r
- }\r
-\r
- public void setTags(String tags) {\r
- this.tags = tags;\r
- }\r
-\r
- public List<ConfigModelContent> getConfigModelContents() {\r
- return configModelContents;\r
- }\r
-\r
- public void setConfigModelContents(List<ConfigModelContent> configModelContents) {\r
- this.configModelContents = configModelContents;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.domain;\r
-\r
-import java.util.Date;\r
-import com.fasterxml.jackson.annotation.JsonFormat;\r
-\r
-public class ConfigModelContent {\r
-\r
- private Long id;\r
- private String name;\r
- private String contentType;\r
- private String description;\r
- private String content;\r
- @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")\r
- private Date creationDate = new Date();\r
-\r
- @Override\r
- public String toString() {\r
- StringBuilder buffer = new StringBuilder("[");\r
- buffer.append("id = " + id);\r
- buffer.append(", name = " + name);\r
- buffer.append(", type = " + contentType);\r
- buffer.append("]");\r
- return buffer.toString();\r
- }\r
-\r
- public Long getId() {\r
- return id;\r
- }\r
-\r
- public void setId(Long id) {\r
- this.id = id;\r
- }\r
-\r
- public String getName() {\r
- return name;\r
- }\r
-\r
- public void setName(String name) {\r
- this.name = name;\r
- }\r
-\r
- public String getContentType() {\r
- return contentType;\r
- }\r
-\r
- public void setContentType(String type) {\r
- this.contentType = type;\r
- }\r
-\r
- public String getDescription() {\r
- return description;\r
- }\r
-\r
- public void setDescription(String description) {\r
- this.description = description;\r
- }\r
-\r
- public String getContent() {\r
- return content;\r
- }\r
-\r
- public void setContent(String content) {\r
- this.content = content;\r
- }\r
-\r
- public Date getCreationDate() {\r
- return creationDate;\r
- }\r
-\r
- public void setCreationDate(Date creationDate) {\r
- this.creationDate = creationDate;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.domain;\r
-\r
-import com.fasterxml.jackson.databind.JsonNode;\r
-import java.io.Serializable;\r
-import java.util.Date;\r
-\r
-public class ResourceDictionary implements Serializable {\r
- private static final long serialVersionUID = 1L;\r
- private Long id;\r
- private String name;\r
- private String dataType;\r
- private String entrySchema;\r
- private JsonNode definition;\r
- private String description;\r
- private String tags;\r
- private Date creationDate;\r
- private String updatedBy;\r
-\r
- @Override\r
- public String toString() {\r
- StringBuilder buffer = new StringBuilder("[");\r
- buffer.append("name = " + name);\r
- buffer.append(", dataType = " + dataType);\r
- buffer.append(", entrySchema = " + entrySchema);\r
- buffer.append(", creationDate = " + creationDate);\r
- buffer.append("]");\r
- return buffer.toString();\r
- }\r
-\r
- public Long getId() {\r
- return id;\r
- }\r
-\r
- public void setId(Long id) {\r
- this.id = id;\r
- }\r
-\r
- public String getName() {\r
- return name;\r
- }\r
-\r
- public void setName(String name) {\r
- this.name = name;\r
- }\r
-\r
- public String getDataType() {\r
- return dataType;\r
- }\r
-\r
- public void setDataType(String dataType) {\r
- this.dataType = dataType;\r
- }\r
-\r
- public String getEntrySchema() {\r
- return entrySchema;\r
- }\r
-\r
- public void setEntrySchema(String entrySchema) {\r
- this.entrySchema = entrySchema;\r
- }\r
-\r
- public JsonNode getDefinition() {\r
- return definition;\r
- }\r
-\r
- public void setDefinition(JsonNode definition) {\r
- this.definition = definition;\r
- }\r
-\r
- public String getDescription() {\r
- return description;\r
- }\r
-\r
- public void setDescription(String description) {\r
- this.description = description;\r
- }\r
-\r
- public String getTags() {\r
- return tags;\r
- }\r
-\r
- public void setTags(String tags) {\r
- this.tags = tags;\r
- }\r
-\r
- public Date getCreationDate() {\r
- return creationDate;\r
- }\r
-\r
- public void setCreationDate(Date creationDate) {\r
- this.creationDate = creationDate;\r
- }\r
-\r
- public String getUpdatedBy() {\r
- return updatedBy;\r
- }\r
-\r
- public void setUpdatedBy(String updatedBy) {\r
- this.updatedBy = updatedBy;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.service;\r
-\r
-import java.util.Map;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;\r
-\r
-public interface ComponentNode extends SvcLogicJavaPlugin {\r
-\r
- public Boolean preCondition(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException;\r
-\r
- public void preProcess(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException;\r
-\r
- public void process(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException;\r
-\r
- public void process(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException;\r
-\r
- public void postProcess(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException;\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.service;\r
-\r
-import java.util.Map;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class ComponentNodeDelegate implements SvcLogicJavaPlugin {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ComponentNodeDelegate.class);\r
- private ComponentNodeService componentNodeService;\r
-\r
- public ComponentNodeDelegate(ComponentNodeService componentNodeService) {\r
- logger.info("{} Constructor Initiated", "ComponentNodeDelegate");\r
- this.componentNodeService = componentNodeService;\r
-\r
- }\r
-\r
- public void process(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {\r
- this.componentNodeService.process(inParams, ctx, null);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.service;\r
-\r
-import java.util.Map;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-\r
-public interface ComponentNodeService {\r
-\r
- public void process(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException;\r
-\r
- public ComponentNode getComponentNodeInterface(String pluginName, String componentType) throws SvcLogicException;\r
-\r
- public ComponentNode getComponentNode(SvcLogicContext ctx, String selectorName) throws SvcLogicException;\r
-}\r
+++ /dev/null
-/*\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.features.model.service;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.data.adaptor.DataAdaptorConstants;\r
-import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog;\r
-import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.data.InterfaceAssignment;\r
-import org.onap.ccsdk.features.model.data.NodeTemplate;\r
-import org.onap.ccsdk.features.model.utils.TransformationUtils;\r
-import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import org.osgi.framework.BundleContext;\r
-import org.osgi.framework.ServiceReference;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class ComponentNodeServiceImpl implements ComponentNodeService {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ComponentNodeServiceImpl.class);\r
-\r
- private BundleContext bcontext;\r
- private ConfigResourceService configResourceService;\r
- private ConfigModelService configModelService;\r
-\r
- public ComponentNodeServiceImpl(BundleContext blueprintBundleContext, ConfigResourceService configResourceService,\r
- ConfigRestAdaptorService configRestAdaptorService) {\r
- logger.info("{} Constructor Initiated", "ComponentNodeServiceImpl");\r
- this.bcontext = blueprintBundleContext;\r
- this.configResourceService = configResourceService;\r
- this.configModelService = new ConfigModelServiceImpl(configRestAdaptorService);\r
- }\r
-\r
- @Override\r
- public void process(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- String requestId = null;\r
- String selector = null;\r
- try {\r
- selector = inParams.get(ConfigModelConstant.PROPERTY_SELECTOR);\r
- requestId = ctx.getAttribute(ConfigModelConstant.PROPERTY_REQUEST_ID);\r
-\r
- logger.info("Component execution started with input params ({})", inParams);\r
- configModelService.assignInParamsFromModel(ctx, inParams);\r
-\r
- String currentInterface = inParams.get(ConfigModelConstant.PROPERTY_CURRENT_INTERFACE);\r
- String currentNodeDerivedFrom = inParams.get(ConfigModelConstant.PROPERTY_CURRENT_NODETYPE_DERIVED_FROM);\r
-\r
- configResourceService.save(new TransactionLog(requestId, DataAdaptorConstants.LOG_MESSAGE_TYPE_COMPONENT,\r
- String.format("Executing Component (%s) derived from (%s) with Params : (%s) ", currentInterface,\r
- currentNodeDerivedFrom, inParams)));\r
-\r
- ComponentNode handler = getComponentNodeInterface(currentInterface, currentNodeDerivedFrom);\r
-\r
- if (handler == null) {\r
- throw new SvcLogicException(\r
- String.format("Could not find Component for Interface %s", currentInterface));\r
- }\r
- if (componentContext == null) {\r
- componentContext = new HashMap<>();\r
- }\r
-\r
- logger.debug("Executing component ({})", currentInterface);\r
-\r
- if (handler.preCondition(inParams, ctx, componentContext)) {\r
- handler.preProcess(inParams, ctx, componentContext);\r
- handler.process(inParams, ctx, componentContext);\r
- handler.postProcess(inParams, ctx, componentContext);\r
- logger.debug("Executed component ({}) successfully.", currentInterface);\r
- configResourceService\r
- .save(new TransactionLog(requestId, DataAdaptorConstants.LOG_MESSAGE_TYPE_COMPONENT,\r
- String.format("Component (%s) executed successfully. ", currentInterface)));\r
-\r
- ctx.setAttribute(selector + ConfigModelConstant.PROPERTY_DOT_STATUS,\r
- ConfigModelConstant.STATUS_SUCCESS);\r
- } else {\r
- logger.info("Skipped component execution ({})", handler.getClass());\r
- configResourceService\r
- .save(new TransactionLog(requestId, DataAdaptorConstants.LOG_MESSAGE_TYPE_COMPONENT,\r
- String.format("Skipping component (%s) execution.", handler.getClass())));\r
- ctx.setAttribute(selector + ConfigModelConstant.PROPERTY_DOT_STATUS,\r
- ConfigModelConstant.STATUS_SKIPPED);\r
- }\r
-\r
- configModelService.assignOutParamsFromModel(ctx, inParams);\r
- ctx.setStatus(ConfigModelConstant.STATUS_SUCCESS);\r
- } catch (Exception e) {\r
- logger.error(String.format("Failed in component (%s) execution for request id (%s) with error %s", selector,\r
- requestId, e.getMessage()));\r
- configResourceService.save(new TransactionLog(requestId, DataAdaptorConstants.LOG_MESSAGE_TYPE_COMPONENT,\r
- String.format("Failed in component (%s) execution for request id (%s) with error %s", selector,\r
- requestId, e.getMessage())));\r
-\r
- ctx.setAttribute(selector + ConfigModelConstant.PROPERTY_DOT_STATUS, ConfigModelConstant.STATUS_FAILURE);\r
- ctx.setAttribute(selector + ConfigModelConstant.PROPERTY_DOT_ERROR_MESSAGE, e.getMessage());\r
- ctx.setAttribute(ConfigModelConstant.PROPERTY_ERROR_MESSAGE, e.getMessage());\r
- ctx.setStatus(ConfigModelConstant.STATUS_FAILURE);\r
- throw new SvcLogicException(e.getMessage(), e);\r
- }\r
- }\r
-\r
- @Override\r
- public ComponentNode getComponentNodeInterface(String pluginName, String componentType) throws SvcLogicException {\r
-\r
- logger.info("Searching for component node plugin ({}) component type ({})", pluginName, componentType);\r
-\r
- if (StringUtils.isBlank(pluginName)) {\r
- throw new SvcLogicException(\r
- String.format("Could not get Interface Name from Service Template : %s ", pluginName));\r
- }\r
-\r
- pluginName = pluginName.replace("-", ".");\r
- ServiceReference sref = bcontext.getServiceReference(pluginName);\r
-\r
- if (sref == null) {\r
- throw new SvcLogicException(\r
- String.format("Could not find service reference object for plugin %s", pluginName));\r
- }\r
- return (ComponentNode) bcontext.getService(sref);\r
- }\r
-\r
- @Override\r
- public ComponentNode getComponentNode(SvcLogicContext ctx, String componentKey) throws SvcLogicException {\r
-\r
- if (StringUtils.isBlank(componentKey)) {\r
- logger.warn("Can't get node template content for a component key ({})", componentKey);\r
- return null;\r
- }\r
-\r
- String nodeTemplateContent = ctx.getAttribute(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + componentKey);\r
- logger.info("Processing component template : ({})", nodeTemplateContent);\r
-\r
- if (StringUtils.isBlank(nodeTemplateContent)) {\r
- logger.warn("Couldn't get node template content for component key ({})", componentKey);\r
- return null;\r
- }\r
-\r
- NodeTemplate nodeTemplate = TransformationUtils.readValue(nodeTemplateContent, NodeTemplate.class);\r
- if (nodeTemplate == null || StringUtils.isBlank(nodeTemplate.getType())) {\r
- logger.warn("Failed to convert content ({}) to node template.", nodeTemplateContent);\r
- return null;\r
- }\r
-\r
- ComponentNode componentNode = null;\r
- for (Map.Entry<String, InterfaceAssignment> nodeTemplateInterface : nodeTemplate.getInterfaces().entrySet()) {\r
- if (nodeTemplateInterface != null && nodeTemplateInterface.getValue() != null) {\r
- String pluginName = nodeTemplateInterface.getKey();\r
- componentNode = getComponentNodeInterface(pluginName, ConfigModelConstant.MODEL_TYPE_NODE_COMPONENT);\r
- }\r
- }\r
- return componentNode;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.service;\r
-\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.domain.ConfigModel;\r
-import org.onap.ccsdk.features.model.domain.ConfigModelContent;\r
-import org.onap.ccsdk.features.model.utils.PrepareContextUtils;\r
-import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorConstants;\r
-import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorException;\r
-import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class ConfigBlueprintService {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigBlueprintService.class);\r
-\r
- private final ConfigRestAdaptorService configRestAdaptorService;\r
-\r
- public ConfigBlueprintService(ConfigRestAdaptorService configRestAdaptorService) {\r
- this.configRestAdaptorService = configRestAdaptorService;\r
- }\r
-\r
- public Map<String, String> prepareContext(Map<String, String> context, String input, String serviceTemplateName,\r
- String serviceTemplateVersion) throws SvcLogicException {\r
- try {\r
- PrepareContextUtils prepareContextUtils = new PrepareContextUtils();\r
- String serviceTemplateContent = getServiceModel(context, serviceTemplateName, serviceTemplateVersion);\r
-\r
- if (StringUtils.isBlank(serviceTemplateContent)) {\r
- throw new SvcLogicException(String.format("Failed to get the Service Template (%s), version (%s)",\r
- serviceTemplateName, serviceTemplateVersion));\r
- }\r
-\r
- return prepareContextUtils.prepareContext(context, input, serviceTemplateContent);\r
- } catch (Exception e) {\r
- throw new SvcLogicException(e.getMessage(), e);\r
- }\r
- }\r
-\r
- @SuppressWarnings("squid:S3776")\r
- private String getServiceModel(Map<String, String> context, String serviceTemplateName,\r
- String serviceTemplateVersion) throws SvcLogicException, ConfigRestAdaptorException {\r
- String content = null;\r
-\r
- logger.info("Getting service template ({}) of version ({}) ", serviceTemplateName, serviceTemplateVersion);\r
-\r
- String path = "config-model/by-name/" + serviceTemplateName + "/version/" + serviceTemplateVersion;\r
-\r
- ConfigModel configModel = configRestAdaptorService\r
- .getResource(ConfigRestAdaptorConstants.SELECTOR_MODEL_SERVICE, path, ConfigModel.class);\r
-\r
- if (configModel == null || configModel.getConfigModelContents() == null\r
- || configModel.getConfigModelContents().isEmpty()) {\r
- throw new SvcLogicException("Service template model is missing for service template name ("\r
- + serviceTemplateName + "), service template version (" + serviceTemplateVersion + ") ");\r
- } else {\r
- if (configModel.getPublished() == null || !configModel.getPublished().equalsIgnoreCase("Y")) {\r
- throw new SvcLogicException(String.format(\r
- "Service template model is not published for service template (%s) ", serviceTemplateName));\r
- }\r
-\r
- List<ConfigModelContent> configModelContents = configModel.getConfigModelContents();\r
- for (ConfigModelContent configModelContent : configModelContents) {\r
- if (configModelContent != null) {\r
- if (ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON.equals(configModelContent.getContentType())) {\r
- content = configModelContent.getContent();\r
- } else if (ConfigModelConstant.MODEL_CONTENT_TYPE_TEMPLATE\r
- .equals(configModelContent.getContentType())) {\r
- context.put(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + configModelContent.getName()\r
- + ".content", configModelContent.getContent());\r
- }\r
- }\r
- }\r
- logger.trace("Service model data : {} ", content);\r
- }\r
- return content;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.service;\r
-\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;\r
-\r
-public class ConfigModelNode implements SvcLogicJavaPlugin {\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.service;\r
-\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.onap.ccsdk.features.model.data.ServiceTemplate;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-\r
-public interface ConfigModelService {\r
-\r
- public Boolean validateServiceTemplate(ServiceTemplate serviceTemplate) throws SvcLogicException;\r
-\r
- public Map<String, String> prepareContext(Map<String, String> context, String input, String serviceTemplateName,\r
- String serviceTemplateVersion) throws SvcLogicException;\r
-\r
- public Map<String, String> prepareContext(Map<String, String> context, String input, String serviceTemplateContent)\r
- throws SvcLogicException;\r
-\r
- public Map<String, String> convertJson2properties(Map<String, String> context, String jsonContent,\r
- List<String> blockKeys) throws SvcLogicException;\r
-\r
- public Map<String, String> convertServiceTemplate2Properties(String serviceTemplateContent,\r
- final Map<String, String> context) throws SvcLogicException;\r
-\r
- public Map<String, String> convertServiceTemplate2Properties(ServiceTemplate serviceTemplate,\r
- final Map<String, String> context) throws SvcLogicException;\r
-\r
- public SvcLogicContext assignInParamsFromModel(final SvcLogicContext context, final Map<String, String> inParams)\r
- throws SvcLogicException;\r
-\r
- public SvcLogicContext assignOutParamsFromModel(final SvcLogicContext context, final Map<String, String> inParams)\r
- throws SvcLogicException;\r
-\r
- public String getNodeTemplateContent(final SvcLogicContext context, String templateName) throws SvcLogicException;\r
-\r
- public String getNodeTemplateMapping(final SvcLogicContext context, String templateName) throws SvcLogicException;\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.service;\r
-\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.ConfigModelException;\r
-import org.onap.ccsdk.features.model.data.CapabilityAssignment;\r
-import org.onap.ccsdk.features.model.data.NodeTemplate;\r
-import org.onap.ccsdk.features.model.data.NodeType;\r
-import org.onap.ccsdk.features.model.data.ServiceTemplate;\r
-import org.onap.ccsdk.features.model.utils.NodePropertyUtils;\r
-import org.onap.ccsdk.features.model.utils.PrepareContextUtils;\r
-import org.onap.ccsdk.features.model.utils.ServiceTemplateUtils;\r
-import org.onap.ccsdk.features.model.utils.TransformationUtils;\r
-import org.onap.ccsdk.features.model.validator.ServiceTemplateValidator;\r
-import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class ConfigModelServiceImpl implements ConfigModelService {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigModelServiceImpl.class);\r
- private static final String CLASS_NAME = "ConfigModelServiceImpl";\r
-\r
- private final ConfigRestAdaptorService configRestAdaptorService;\r
-\r
- public ConfigModelServiceImpl(ConfigRestAdaptorService configRestAdaptorService) {\r
- logger.info("{} Constuctor Initated...", CLASS_NAME);\r
- this.configRestAdaptorService = configRestAdaptorService;\r
- }\r
-\r
- @Override\r
- public Boolean validateServiceTemplate(ServiceTemplate serviceTemplate) throws SvcLogicException {\r
- try {\r
- ServiceTemplateValidator serviceTemplateValidator = new ServiceTemplateValidator();\r
- return serviceTemplateValidator.validateServiceTemplate(serviceTemplate);\r
- } catch (ConfigModelException e) {\r
- throw new SvcLogicException(e.getMessage());\r
- }\r
- }\r
-\r
- @Override\r
- public Map<String, String> prepareContext(Map<String, String> context, String input, String serviceTemplateName,\r
- String serviceTemplateVersion) throws SvcLogicException {\r
-\r
- ConfigBlueprintService configBlueprintService = new ConfigBlueprintService(configRestAdaptorService);\r
- return configBlueprintService.prepareContext(context, input, serviceTemplateName, serviceTemplateVersion);\r
- }\r
-\r
- @Override\r
- public Map<String, String> prepareContext(Map<String, String> context, String input, String serviceTemplateContent)\r
- throws SvcLogicException {\r
- try {\r
- PrepareContextUtils prepareContextUtils = new PrepareContextUtils();\r
- return prepareContextUtils.prepareContext(context, input, serviceTemplateContent);\r
- } catch (Exception e) {\r
- throw new SvcLogicException(e.getMessage());\r
- }\r
- }\r
-\r
- @Override\r
- public Map<String, String> convertJson2properties(Map<String, String> context, String jsonContent,\r
- List<String> blockKeys) throws SvcLogicException {\r
- try {\r
- return TransformationUtils.convertJson2Properties(context, jsonContent, blockKeys);\r
- } catch (Exception e) {\r
- throw new SvcLogicException(e.getMessage());\r
- }\r
- }\r
-\r
- @Override\r
- public Map<String, String> convertServiceTemplate2Properties(String serviceTemplateContent,\r
- final Map<String, String> context) throws SvcLogicException {\r
- try {\r
- ServiceTemplateUtils serviceTemplateUtils = new ServiceTemplateUtils();\r
- return serviceTemplateUtils.convertServiceTemplate2Properties(serviceTemplateContent, context);\r
- } catch (Exception e) {\r
- throw new SvcLogicException(e.getMessage());\r
- }\r
- }\r
-\r
- @Override\r
- public Map<String, String> convertServiceTemplate2Properties(ServiceTemplate serviceTemplate,\r
- final Map<String, String> context) throws SvcLogicException {\r
- try {\r
- ServiceTemplateUtils serviceTemplateUtils = new ServiceTemplateUtils();\r
- return serviceTemplateUtils.convertServiceTemplate2Properties(serviceTemplate, context);\r
- } catch (Exception e) {\r
- throw new SvcLogicException(e.getMessage());\r
- }\r
- }\r
-\r
- @SuppressWarnings("squid:S3776")\r
- @Override\r
- public SvcLogicContext assignInParamsFromModel(final SvcLogicContext context, final Map<String, String> inParams)\r
- throws SvcLogicException {\r
- logger.debug("Processing component input param ({})", inParams);\r
- try {\r
- if (context != null && inParams != null && inParams.containsKey(ConfigModelConstant.PROPERTY_SELECTOR)) {\r
- String componentKey = inParams.get(ConfigModelConstant.PROPERTY_SELECTOR);\r
- if (StringUtils.isNotBlank(componentKey)) {\r
- String nodeTemplateContent =\r
- context.getAttribute(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + componentKey);\r
- logger.info("Processing node template content ({})", nodeTemplateContent);\r
- if (StringUtils.isNotBlank(nodeTemplateContent)) {\r
- NodeTemplate nodeTemplate =\r
- TransformationUtils.readValue(nodeTemplateContent, NodeTemplate.class);\r
- if (nodeTemplate != null && StringUtils.isNotBlank(nodeTemplate.getType())) {\r
- String nodeTypeContent = context\r
- .getAttribute(ConfigModelConstant.PROPERTY_NODE_TYPES_DOT + nodeTemplate.getType());\r
- NodeType nodetype = TransformationUtils.readValue(nodeTypeContent, NodeType.class);\r
- if (nodetype != null) {\r
- inParams.put(ConfigModelConstant.PROPERTY_CURRENT_NODETYPE_DERIVED_FROM,\r
- nodetype.getDerivedFrom());\r
- NodePropertyUtils nodePropertyUtils = new NodePropertyUtils(context, inParams);\r
- nodePropertyUtils.assignInParamsFromModel(nodetype, nodeTemplate);\r
- } else {\r
- throw new SvcLogicException(\r
- String.format("Failed to get node type (%s) for node template (%s).",\r
- nodeTemplate.getType(), componentKey));\r
- }\r
-\r
- } else {\r
- throw new SvcLogicException(String\r
- .format("Failed to convert content (%s) to node template.", nodeTemplateContent));\r
- }\r
- } else {\r
- throw new SvcLogicException(String\r
- .format("Couldn't get node template content for component key (%s).", componentKey));\r
- }\r
- } else {\r
- throw new SvcLogicException(\r
- String.format("Couldn't get component key (prefix) from inparam (%s)", inParams));\r
- }\r
- }\r
- } catch (Exception e) {\r
- throw new SvcLogicException(e.getMessage());\r
- }\r
- return context;\r
- }\r
-\r
- @Override\r
- public SvcLogicContext assignOutParamsFromModel(final SvcLogicContext context, final Map<String, String> inParams)\r
- throws SvcLogicException {\r
- try {\r
- if (context != null && inParams != null && inParams.containsKey(ConfigModelConstant.PROPERTY_SELECTOR)) {\r
- String componentKey = inParams.get(ConfigModelConstant.PROPERTY_SELECTOR);\r
- logger.info("Processing component output for prefix key ({})", componentKey);\r
- if (StringUtils.isNotBlank(componentKey)) {\r
- String nodeTemplateContent =\r
- context.getAttribute(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + componentKey);\r
- if (StringUtils.isNotBlank(nodeTemplateContent)) {\r
- NodeTemplate nodeTemplate =\r
- TransformationUtils.readValue(nodeTemplateContent, NodeTemplate.class);\r
- if (nodeTemplate != null && StringUtils.isNotBlank(nodeTemplate.getType())) {\r
- String nodeTypeContent = context\r
- .getAttribute(ConfigModelConstant.PROPERTY_NODE_TYPES_DOT + nodeTemplate.getType());\r
- NodeType nodetype = TransformationUtils.readValue(nodeTypeContent, NodeType.class);\r
- NodePropertyUtils nodePropertyUtils = new NodePropertyUtils(context, inParams);\r
- nodePropertyUtils.assignOutParamsFromModel(nodetype, nodeTemplate);\r
- }\r
- }\r
- }\r
- }\r
- } catch (Exception e) {\r
- throw new SvcLogicException(e.getMessage());\r
- }\r
- return context;\r
- }\r
-\r
- @Override\r
- public String getNodeTemplateContent(final SvcLogicContext context, String templateName) throws SvcLogicException {\r
- String content = null;\r
- try {\r
- if (context != null && StringUtils.isNotBlank(templateName)) {\r
- logger.info("Processing Artifact Node Template for content : ({})", templateName);\r
- content = context\r
- .getAttribute(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + templateName + ".content");\r
- }\r
- } catch (Exception e) {\r
- throw new SvcLogicException(e.getMessage());\r
- }\r
- return content;\r
- }\r
-\r
- @SuppressWarnings("squid:S3776")\r
- @Override\r
- public String getNodeTemplateMapping(final SvcLogicContext context, String templateName) throws SvcLogicException {\r
- String mapping = null;\r
- try {\r
- if (context != null && StringUtils.isNotBlank(templateName)) {\r
- logger.info("Processing artifact node template for mapping : ({})", templateName);\r
- if (StringUtils.isNotBlank(templateName)) {\r
- String nodeTemplateContent =\r
- context.getAttribute(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + templateName);\r
- if (StringUtils.isNotBlank(nodeTemplateContent)) {\r
-\r
- NodeTemplate nodeTemplate =\r
- TransformationUtils.readValue(nodeTemplateContent, NodeTemplate.class);\r
-\r
- if (nodeTemplate != null && nodeTemplate.getCapabilities() != null && nodeTemplate\r
- .getCapabilities().containsKey(ConfigModelConstant.CAPABILITY_PROPERTY_MAPPING)) {\r
-\r
- CapabilityAssignment capability =\r
- nodeTemplate.getCapabilities().get(ConfigModelConstant.CAPABILITY_PROPERTY_MAPPING);\r
- if (capability.getProperties() != null) {\r
- List mappingList = (List) capability.getProperties()\r
- .get(ConfigModelConstant.CAPABILITY_PROPERTY_MAPPING);\r
- if (mappingList != null) {\r
- mapping = TransformationUtils.getJson(mappingList);\r
- }\r
-\r
- }\r
- }\r
- }\r
- }\r
- }\r
- } catch (Exception e) {\r
- throw new SvcLogicException(e.getMessage());\r
- }\r
- return mapping;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.utils;\r
-\r
-import java.io.IOException;\r
-import java.util.HashMap;\r
-import java.util.Iterator;\r
-import java.util.Map;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.data.PropertyDefinition;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-import com.fasterxml.jackson.databind.JsonNode;\r
-import com.fasterxml.jackson.databind.ObjectMapper;\r
-import com.fasterxml.jackson.databind.node.ObjectNode;\r
-\r
-public class ExpressionUtils {\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ExpressionUtils.class);\r
-\r
- private final SvcLogicContext context;\r
- private final Map<String, String> inParams;\r
-\r
- public ExpressionUtils(final SvcLogicContext context, final Map<String, String> inParams) {\r
- this.context = context;\r
- this.inParams = inParams;\r
- }\r
-\r
- public void populatePropertAssignmentsWithPrefix(String prefix, Map<String, PropertyDefinition> typeProperties,\r
- Map<String, Object> templateProperties) throws IOException {\r
- if (typeProperties != null && templateProperties != null) {\r
- ObjectMapper mapper = new ObjectMapper();\r
- String templatejsonContent = mapper.writeValueAsString(templateProperties);\r
- logger.debug("Expression inputs ({}).", templatejsonContent);\r
-\r
- JsonNode rootArray = mapper.readTree(templatejsonContent);\r
- processJsonExpression(rootArray);\r
- if (rootArray != null) {\r
- Map<String, String> prefixParams = new HashMap<>();\r
- TransformationUtils.convertJson2RootProperties(prefixParams, rootArray);\r
- logger.info("Resolved inputs ({}).", rootArray);\r
- prefixParams.forEach((key, value) -> {\r
- this.inParams.put(prefix + "." + key, value);\r
- });\r
- }\r
- }\r
- }\r
-\r
- public void populatePropertAssignments(Map<String, PropertyDefinition> typeProperties,\r
- Map<String, Object> templateProperties) throws IOException {\r
- if (typeProperties != null && templateProperties != null) {\r
- ObjectMapper mapper = new ObjectMapper();\r
- String templatejsonContent = mapper.writeValueAsString(templateProperties);\r
- logger.info("Expression inputs ({}).", templatejsonContent);\r
-\r
- JsonNode rootArray = mapper.readTree(templatejsonContent);\r
- processJsonExpression(rootArray);\r
- TransformationUtils.convertJson2RootProperties(this.inParams, rootArray);\r
- logger.info("Resolved inputs ({}).", rootArray);\r
-\r
- }\r
- }\r
-\r
- public void populateOutPropertAssignments(Map<String, PropertyDefinition> typeProperties,\r
- Map<String, Object> templateProperties) throws IOException {\r
- if (typeProperties != null && templateProperties != null) {\r
- ObjectMapper mapper = new ObjectMapper();\r
- String templatejsonContent = mapper.writeValueAsString(templateProperties);\r
- logger.info("Expression outputs ({}).", templatejsonContent);\r
-\r
- JsonNode rootArray = mapper.readTree(templatejsonContent);\r
- processJsonExpression(rootArray);\r
- logger.info("Resolved outputs ({}).", rootArray);\r
- }\r
- }\r
-\r
- public void processJsonExpression(JsonNode rootArray) throws IOException {\r
- if (rootArray != null) {\r
- Iterator<Map.Entry<String, JsonNode>> fields = rootArray.fields();\r
- while (fields.hasNext()) {\r
- Map.Entry<String, JsonNode> entry = fields.next();\r
- processJsonNode(rootArray, entry.getKey(), entry.getValue());\r
- }\r
- }\r
- }\r
-\r
- private void processJsonNode(JsonNode parentNode, String nodeName, JsonNode node) throws IOException {\r
- if (node == null) {\r
- // Do Nothing\r
- } else if (node.isArray()) {\r
- String[] a = new String[node.size()];\r
-\r
- for (int i = 0; i < a.length; i++) {\r
- processJsonNode(null, null, node.get(i));\r
- }\r
- } else if (node.isObject()) {\r
-\r
- Iterator<Map.Entry<String, JsonNode>> fields = node.fields();\r
- while (fields.hasNext()) {\r
- Map.Entry<String, JsonNode> entry = fields.next();\r
- processJsonNode(node, entry.getKey(), entry.getValue());\r
- }\r
- } else if (node.isTextual()) {\r
- boolean expression = checkExpressionContent(node.asText());\r
- if (expression) {\r
- processExpressionContent(parentNode, nodeName, node);\r
- }\r
- }\r
- }\r
-\r
- private boolean checkExpressionContent(String content) {\r
- return (StringUtils.isNotBlank(content) && (content.contains(ConfigModelConstant.EXPRESSION_GET_INPUT)\r
- || content.contains(ConfigModelConstant.EXPRESSION_GET_ATTRIBUTE)\r
- || content.contains(ConfigModelConstant.EXPRESSION_SET_VALUE)));\r
- }\r
-\r
- @SuppressWarnings("squid:S3776")\r
- private void processExpressionContent(JsonNode parentNode, String nodeName, JsonNode node) throws IOException {\r
-\r
- if (node != null && StringUtils.isNotBlank(node.asText())) {\r
- String content = node.asText();\r
- ObjectMapper mapper = new ObjectMapper();\r
- Map<String, String> expressionMap = mapper.readValue(content, Map.class);\r
- boolean isExpressionNode = false;\r
-\r
- if (expressionMap != null) {\r
- String expressionValue = null;\r
- String expressionKey = null;\r
-\r
- if (expressionMap.containsKey(ConfigModelConstant.EXPRESSION_GET_INPUT)) {\r
- isExpressionNode = true;\r
- expressionKey = expressionMap.get(ConfigModelConstant.EXPRESSION_GET_INPUT);\r
- expressionValue = resolveGetInputExpression(expressionKey, context);\r
- if (expressionValue == null) {\r
- expressionValue = resolveGetInputExpression("inputs." + expressionKey + ".default", context);\r
- }\r
- } else if (expressionMap.containsKey(ConfigModelConstant.EXPRESSION_GET_ATTRIBUTE)) {\r
- isExpressionNode = true;\r
- expressionValue =\r
- context.getAttribute(expressionMap.get(ConfigModelConstant.EXPRESSION_GET_ATTRIBUTE));\r
- } else if (expressionMap.containsKey(ConfigModelConstant.EXPRESSION_SET_VALUE)) {\r
- isExpressionNode = true;\r
- expressionKey = expressionMap.get(ConfigModelConstant.EXPRESSION_SET_VALUE);\r
- expressionValue = context.getAttribute(expressionKey);\r
-\r
- if (StringUtils.isNotBlank(expressionKey)) {\r
- context.setAttribute(expressionKey, expressionValue);\r
- }\r
- }\r
-\r
- if (isExpressionNode && expressionValue == null) {\r
- ((ObjectNode) parentNode).put(nodeName, "");\r
- }\r
- if (StringUtils.isNotBlank(expressionValue)) {\r
- if (expressionValue.trim().startsWith("[") || expressionValue.trim().startsWith("{")) {\r
- JsonNode valueNode = mapper.readTree(expressionValue);\r
- ((ObjectNode) parentNode).put(nodeName, valueNode);\r
- } else {\r
- ((ObjectNode) parentNode).put(nodeName, expressionValue);\r
- }\r
- }\r
- logger.debug("expression ({}), expression key ({}), expression Value ({})", expressionMap,\r
- expressionKey, expressionValue);\r
- }\r
- }\r
- }\r
-\r
- private String resolveGetInputExpression(String key, final SvcLogicContext context) {\r
- if (StringUtils.isNotBlank(key) && context != null) {\r
- return context.getAttribute(key);\r
- }\r
- return null;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.utils;\r
-\r
-import static com.jayway.jsonpath.JsonPath.using;\r
-import java.util.List;\r
-import com.fasterxml.jackson.databind.JsonNode;\r
-import com.jayway.jsonpath.Configuration;\r
-import com.jayway.jsonpath.Option;\r
-import com.jayway.jsonpath.spi.json.JacksonJsonNodeJsonProvider;\r
-import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider;\r
-\r
-@SuppressWarnings("squid:S1118")\r
-public class JsonParserUtils {\r
-\r
- public static final Configuration JACKSON_JSON_NODE_CONFIGURATION = Configuration.builder()\r
- .mappingProvider(new JacksonMappingProvider()).jsonProvider(new JacksonJsonNodeJsonProvider()).build();\r
-\r
- public static final Configuration PATH_CONFIGURATION = Configuration.builder().options(Option.AS_PATH_LIST).build();\r
-\r
- public static List<String> paths(String jsonContent, String expression) {\r
- return using(PATH_CONFIGURATION).parse(jsonContent).read(expression);\r
- }\r
-\r
- public static List<String> paths(JsonNode jsonNode, String expression) {\r
- return paths(jsonNode.toString(), expression);\r
- }\r
-\r
- public static JsonNode parse(String jsonContent, String expression) {\r
- return using(JACKSON_JSON_NODE_CONFIGURATION).parse(jsonContent).read(expression);\r
- }\r
-\r
- public static JsonNode parse(JsonNode jsonNode, String expression) {\r
- return parse(jsonNode.toString(), expression);\r
- }\r
-\r
- public static JsonNode parseNSet(String jsonContent, String expression, JsonNode value) {\r
- return using(JACKSON_JSON_NODE_CONFIGURATION).parse(jsonContent).set(expression, value).json();\r
- }\r
-\r
- public static JsonNode parseNSet(JsonNode jsonNode, String expression, JsonNode valueNode) {\r
- return parseNSet(jsonNode.toString(), expression, valueNode);\r
- }\r
-}\r
+++ /dev/null
-/*\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.features.model.utils;\r
-\r
-import org.onap.ccsdk.features.model.ValidTypes;\r
-import com.fasterxml.jackson.databind.JsonNode;\r
-import com.fasterxml.jackson.databind.node.ArrayNode;\r
-import com.fasterxml.jackson.databind.node.NullNode;\r
-import com.fasterxml.jackson.databind.node.ObjectNode;\r
-\r
-/**\r
- * JsonUtils.java Purpose: Provide Configuration Generator JsonUtils Information\r
- *\r
- * @version 1.0\r
- */\r
-public class JsonUtils {\r
-\r
- private JsonUtils() {\r
-\r
- }\r
-\r
- public static void populatePrimitiveValues(String key, Object value, String primitiveType, ObjectNode objectNode) {\r
- if (ValidTypes.DATA_TYPE_BOOLEAN.equals(primitiveType)) {\r
- objectNode.put(key, (Boolean) value);\r
- } else if (ValidTypes.DATA_TYPE_INTEGER.equals(primitiveType)) {\r
- objectNode.put(key, (Integer) value);\r
- } else if (ValidTypes.DATA_TYPE_FLOAT.equals(primitiveType)) {\r
- objectNode.put(key, (Float) value);\r
- } else if (ValidTypes.DATA_TYPE_TIMESTAMP.equals(primitiveType)) {\r
- objectNode.put(key, (String) value);\r
- } else {\r
- objectNode.put(key, (String) value);\r
- }\r
- }\r
-\r
- public static void populatePrimitiveValues(Object value, String primitiveType, ArrayNode objectNode) {\r
- if (ValidTypes.DATA_TYPE_BOOLEAN.equals(primitiveType)) {\r
- objectNode.add((Boolean) value);\r
- } else if (ValidTypes.DATA_TYPE_INTEGER.equals(primitiveType)) {\r
- objectNode.add((Integer) value);\r
- } else if (ValidTypes.DATA_TYPE_FLOAT.equals(primitiveType)) {\r
- objectNode.add((Float) value);\r
- } else if (ValidTypes.DATA_TYPE_TIMESTAMP.equals(primitiveType)) {\r
- objectNode.add((String) value);\r
- } else {\r
- objectNode.add((String) value);\r
- }\r
- }\r
-\r
- public static void populatePrimitiveDefaultValues(String key, String primitiveType, ObjectNode objectNode) {\r
- if (ValidTypes.DATA_TYPE_BOOLEAN.equals(primitiveType)) {\r
- objectNode.put(key, false);\r
- } else if (ValidTypes.DATA_TYPE_INTEGER.equals(primitiveType)) {\r
- objectNode.put(key, 0);\r
- } else if (ValidTypes.DATA_TYPE_FLOAT.equals(primitiveType)) {\r
- objectNode.put(key, 0.0);\r
- } else {\r
- objectNode.put(key, "");\r
- }\r
- }\r
-\r
- public static void populatePrimitiveDefaultValuesForArrayNode(String primitiveType, ArrayNode arrayNode) {\r
- if (ValidTypes.DATA_TYPE_BOOLEAN.equals(primitiveType)) {\r
- arrayNode.add(false);\r
- } else if (ValidTypes.DATA_TYPE_INTEGER.equals(primitiveType)) {\r
- arrayNode.add(0);\r
- } else if (ValidTypes.DATA_TYPE_FLOAT.equals(primitiveType)) {\r
- arrayNode.add(0.0);\r
- } else {\r
- arrayNode.add("");\r
- }\r
- }\r
-\r
- public static void populateJsonNodeValues(String key, JsonNode nodeValue, String type, ObjectNode objectNode) {\r
- if (nodeValue == null || nodeValue instanceof NullNode) {\r
- objectNode.put(key, nodeValue);\r
- } else if (ValidTypes.getPrimitivePropertType().contains(type)) {\r
- if (ValidTypes.DATA_TYPE_BOOLEAN.equals(type)) {\r
- objectNode.put(key, nodeValue.asBoolean());\r
- } else if (ValidTypes.DATA_TYPE_INTEGER.equals(type)) {\r
- objectNode.put(key, nodeValue.asInt());\r
- } else if (ValidTypes.DATA_TYPE_FLOAT.equals(type)) {\r
- objectNode.put(key, nodeValue.floatValue());\r
- } else if (ValidTypes.DATA_TYPE_TIMESTAMP.equals(type)) {\r
- objectNode.put(key, nodeValue.asText());\r
- } else {\r
- objectNode.put(key, nodeValue.asText());\r
- }\r
- } else {\r
- objectNode.set(key, nodeValue);\r
- }\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.utils;\r
-\r
-import java.io.IOException;\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.data.CapabilityAssignment;\r
-import org.onap.ccsdk.features.model.data.CapabilityDefinition;\r
-import org.onap.ccsdk.features.model.data.InterfaceAssignment;\r
-import org.onap.ccsdk.features.model.data.InterfaceDefinition;\r
-import org.onap.ccsdk.features.model.data.NodeTemplate;\r
-import org.onap.ccsdk.features.model.data.NodeType;\r
-import org.onap.ccsdk.features.model.data.OperationAssignment;\r
-import org.onap.ccsdk.features.model.data.OperationDefinition;\r
-import org.onap.ccsdk.features.model.data.PropertyDefinition;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class NodePropertyUtils {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(NodePropertyUtils.class);\r
- private final SvcLogicContext context;\r
- private final Map<String, String> inParams;\r
- private ExpressionUtils jsonExpressionUtils;\r
-\r
- public NodePropertyUtils(final SvcLogicContext context, final Map<String, String> inParams) {\r
- this.context = context;\r
- this.inParams = inParams;\r
- jsonExpressionUtils = new ExpressionUtils(this.context, this.inParams);\r
- }\r
-\r
- @SuppressWarnings("squid:S3776")\r
- public SvcLogicContext assignInParamsFromModel(NodeType nodetype, NodeTemplate nodeTemplate) throws IOException {\r
- if (nodeTemplate != null) {\r
- Map<String, Object> inputs = null;\r
- // Populate the Type inputs\r
- Map<String, PropertyDefinition> nodeTypeinputs = new HashMap<>();\r
- for (Map.Entry<String, InterfaceDefinition> nodeTypeInterface : nodetype.getInterfaces().entrySet()) {\r
- if (nodeTypeInterface != null && nodeTypeInterface.getValue() != null) {\r
- for (Map.Entry<String, OperationDefinition> nodeTypeOperation : nodeTypeInterface.getValue()\r
- .getOperations().entrySet()) {\r
- nodeTypeinputs = nodeTypeOperation.getValue().getInputs();\r
- logger.trace("Populated node type input ({}).", nodeTypeinputs);\r
- }\r
- }\r
- }\r
-\r
- if (!nodeTypeinputs.isEmpty()) {\r
- // Populate the Template inputs\r
- for (Map.Entry<String, InterfaceAssignment> nodeTemplateInterface : nodeTemplate.getInterfaces()\r
- .entrySet()) {\r
- if (nodeTemplateInterface != null && nodeTemplateInterface.getValue() != null) {\r
- this.inParams.put(ConfigModelConstant.PROPERTY_CURRENT_INTERFACE,\r
- nodeTemplateInterface.getKey());\r
- for (Map.Entry<String, OperationAssignment> nodeTemplateOperation : nodeTemplateInterface\r
- .getValue().getOperations().entrySet()) {\r
- if (nodeTemplateOperation != null) {\r
- this.inParams.put(ConfigModelConstant.PROPERTY_CURRENT_OPERATION,\r
- nodeTemplateOperation.getKey());\r
- if (StringUtils.isNotBlank(nodeTemplateOperation.getValue().getImplementation())) {\r
- this.inParams.put(ConfigModelConstant.PROPERTY_CURRENT_IMPLEMENTATION,\r
- nodeTemplateOperation.getValue().getImplementation());\r
- }\r
- inputs = nodeTemplateOperation.getValue().getInputs();\r
- logger.trace("Populated node template input({}).", inputs);\r
- // Assign Default Values & Types\r
- jsonExpressionUtils.populatePropertAssignments(nodeTypeinputs, inputs);\r
- }\r
- }\r
- }\r
- }\r
- }\r
-\r
- if (nodeTemplate.getRequirements() != null && !nodeTemplate.getRequirements().isEmpty()) {\r
- assignInParamsFromRequirementModel(nodeTemplate, context, inParams);\r
- }\r
- }\r
- return context;\r
- }\r
-\r
- @SuppressWarnings("squid:S3776")\r
- public SvcLogicContext assignOutParamsFromModel(NodeType nodetype, NodeTemplate nodeTemplate) throws IOException {\r
-\r
- if (nodeTemplate != null) {\r
- Map<String, Object> outputs = null;\r
- // Populate the Type Outputs\r
- Map<String, PropertyDefinition> nodeTypeOutputs = new HashMap<>();\r
-\r
- for (Map.Entry<String, InterfaceDefinition> nodeTypeInterface : nodetype.getInterfaces().entrySet()) {\r
- if (nodeTypeInterface != null && nodeTypeInterface.getValue() != null) {\r
- for (Map.Entry<String, OperationDefinition> nodeTypeOperation : nodeTypeInterface.getValue()\r
- .getOperations().entrySet()) {\r
- nodeTypeOutputs = nodeTypeOperation.getValue().getOutputs();\r
- logger.info("Populated node type output ({}).", nodeTypeOutputs);\r
- }\r
- }\r
- }\r
-\r
- if (!nodeTypeOutputs.isEmpty()) {\r
- // Populate the Template Outputs\r
- for (Map.Entry<String, InterfaceAssignment> nodeTemplateInterface : nodeTemplate.getInterfaces()\r
- .entrySet()) {\r
- if (nodeTemplateInterface != null && nodeTemplateInterface.getValue() != null) {\r
- for (Map.Entry<String, OperationAssignment> nodeTemplateOperation : nodeTemplateInterface\r
- .getValue().getOperations().entrySet()) {\r
- outputs = nodeTemplateOperation.getValue().getOutputs();\r
- logger.info("Populated node template output ({}).", outputs);\r
- // Assign Default Values & Types\r
- jsonExpressionUtils.populateOutPropertAssignments(nodeTypeOutputs, outputs);\r
- // TO DO\r
- }\r
- }\r
- }\r
- }\r
- }\r
- return context;\r
- }\r
-\r
- @SuppressWarnings({"squid:S3776", "squid:S00112"})\r
- public SvcLogicContext assignInParamsFromRequirementModel(NodeTemplate nodeTemplate, final SvcLogicContext context,\r
- final Map<String, String> inParams) {\r
- if (nodeTemplate != null && nodeTemplate.getRequirements() != null && context != null && inParams != null) {\r
- nodeTemplate.getRequirements().forEach((requrementKey, requirement) -> {\r
- if (requirement != null && StringUtils.isNotBlank(requirement.getNode())\r
- && StringUtils.isNotBlank(requirement.getCapability())) {\r
- String requirementNodeTemplateContent = context\r
- .getAttribute(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + requirement.getNode());\r
- logger.info("Processing requirement node ({}) template content ({}) ", requirement.getNode(),\r
- requirementNodeTemplateContent);\r
- NodeTemplate requirementNodeTemplate =\r
- TransformationUtils.readValue(requirementNodeTemplateContent, NodeTemplate.class);\r
- if (requirementNodeTemplate != null && requirementNodeTemplate.getCapabilities() != null) {\r
- String nodeTypeContent = context.getAttribute(\r
- ConfigModelConstant.PROPERTY_NODE_TYPES_DOT + requirementNodeTemplate.getType());\r
- NodeType nodeType = TransformationUtils.readValue(nodeTypeContent, NodeType.class);\r
- if (nodeType != null && nodeType.getCapabilities() != null\r
- && nodeType.getCapabilities().containsKey(requirement.getCapability())) {\r
- CapabilityDefinition capabilityDefinition =\r
- nodeType.getCapabilities().get(requirement.getCapability());\r
- if (capabilityDefinition != null) {\r
- CapabilityAssignment capabilityAssignment =\r
- requirementNodeTemplate.getCapabilities().get(requirement.getCapability());\r
- try {\r
- assignInParamsFromCapabilityModel(requrementKey, capabilityDefinition,\r
- capabilityAssignment, context);\r
- } catch (Exception e) {\r
- throw new RuntimeException(e);\r
- }\r
- }\r
- }\r
- }\r
- }\r
- });\r
- }\r
- return context;\r
- }\r
-\r
- public SvcLogicContext assignInParamsFromCapabilityModel(String requirementName,\r
- CapabilityDefinition capabilityDefinition, CapabilityAssignment capabilityAssignment,\r
- final SvcLogicContext context) throws IOException {\r
- if (capabilityAssignment != null && capabilityAssignment.getProperties() != null) {\r
- jsonExpressionUtils.populatePropertAssignmentsWithPrefix(requirementName,\r
- capabilityDefinition.getProperties(), capabilityAssignment.getProperties());\r
- }\r
- return context;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.utils;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class PrepareContextUtils {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(PrepareContextUtils.class);\r
-\r
- public Map<String, String> prepareContext(Map<String, String> context, String input, String serviceTemplateContent)\r
- throws Exception {\r
- if (StringUtils.isNotBlank(serviceTemplateContent)) {\r
-\r
- if (context == null) {\r
- context = new HashMap<>();\r
- }\r
- if (StringUtils.isNotBlank(input)) {\r
- TransformationUtils.convertJson2RootProperties(context, input);\r
- }\r
-\r
- String recipeName = context.get(ConfigModelConstant.PROPERTY_ACTION_NAME);\r
- if (StringUtils.isNotBlank(recipeName)) {\r
- String recipeInputName =\r
- recipeName.replace(ConfigModelConstant.PROPERTY_RECIPE, ConfigModelConstant.PROPERTY_REQUEST);\r
- String recipeInput = context.get(recipeInputName);\r
- if (StringUtils.isNotBlank(recipeInput)) {\r
- // Un necessary to hold the Recipe Request, It is already in input\r
- context.remove(recipeInputName);\r
- context.remove(ConfigModelConstant.PROPERTY_PAYLOAD);\r
- TransformationUtils.convertJson2RootProperties(context, recipeInput);\r
- logger.info("Converted recipe ({}) request inputs to context.", recipeName);\r
- }\r
- }\r
-\r
- ServiceTemplateUtils serviceTemplateUtils = new ServiceTemplateUtils();\r
- serviceTemplateUtils.convertServiceTemplate2Properties(serviceTemplateContent, context);\r
- }\r
- return context;\r
-\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.utils;\r
-\r
-import java.util.Date;\r
-import java.util.HashSet;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Set;\r
-import org.apache.commons.lang3.BooleanUtils;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.ConfigModelException;\r
-import org.onap.ccsdk.features.model.ValidTypes;\r
-import org.onap.ccsdk.features.model.data.ResourceAssignment;\r
-import org.onap.ccsdk.features.model.data.dict.ResourceDefinition;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-import com.fasterxml.jackson.databind.JsonNode;\r
-import com.fasterxml.jackson.databind.ObjectMapper;\r
-import com.fasterxml.jackson.databind.node.ArrayNode;\r
-import com.fasterxml.jackson.databind.node.NullNode;\r
-import com.fasterxml.jackson.databind.node.ObjectNode;\r
-import com.google.common.base.Preconditions;\r
-\r
-public class ResourceAssignmentUtils {\r
-\r
- private ResourceAssignmentUtils() {\r
-\r
- }\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceAssignmentUtils.class);\r
-\r
- public static String getArtifactNodeContent(String nodeTemplateName, Map<String, Object> context) {\r
- Preconditions.checkArgument(StringUtils.isNotBlank(nodeTemplateName),\r
- "getArtifactNodeContent missing template name");\r
- return (String) context.get(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + nodeTemplateName + ".content");\r
- }\r
-\r
- public static List<ResourceAssignment> getArtifactNodeMapping(String nodeTemplateName,\r
- Map<String, Object> context) {\r
- Preconditions.checkArgument(StringUtils.isNotBlank(nodeTemplateName),\r
- "getArtifactNodeMapping missing template name");\r
- List<ResourceAssignment> resourceAssignments = null;\r
- String resourceMappingContent =\r
- (String) context.get(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + nodeTemplateName + ".mapping");\r
- if (StringUtils.isNotBlank(resourceMappingContent)) {\r
- resourceAssignments = TransformationUtils.getListfromJson(resourceMappingContent, ResourceAssignment.class);\r
-\r
- } else {\r
- logger.warn("missing mapping content for node template ({})", nodeTemplateName);\r
- }\r
- return resourceAssignments;\r
- }\r
-\r
- // Not used Any whre\r
- public static synchronized void cleanContextTemplateNDictionaryKeys(Map<String, Object> componentContext) {\r
- String recipeName = (String) componentContext.get(ConfigModelConstant.PROPERTY_ACTION_NAME);\r
- Set<String> removeSet = new HashSet<>();\r
- componentContext.forEach((key, value) -> {\r
- if (StringUtils.isNotBlank(key)\r
- && (key.startsWith(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".")\r
- || key.startsWith(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + recipeName + "."))) {\r
- removeSet.add(key);\r
- }\r
- });\r
- componentContext.keySet().removeAll(removeSet);\r
- }\r
-\r
- public static synchronized Object getDictionaryKeyValue(Map<String, Object> componentContext,\r
- ResourceAssignment resourceMapping) {\r
- Object value = null;\r
- if (resourceMapping != null && componentContext != null) {\r
- String recipeName = (String) componentContext.get(ConfigModelConstant.PROPERTY_ACTION_NAME);\r
- String dictionaryKeyName = resourceMapping.getDictionaryName();\r
- value = componentContext\r
- .get(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + "." + dictionaryKeyName);\r
- }\r
- return value;\r
- }\r
-\r
- public static synchronized Object getDictionaryKeyValue(Map<String, Object> componentContext,\r
- ResourceDefinition resourceDictionary) {\r
- Object value = null;\r
- if (resourceDictionary != null && componentContext != null) {\r
- String recipeName = (String) componentContext.get(ConfigModelConstant.PROPERTY_ACTION_NAME);\r
- String dictionaryKeyName = resourceDictionary.getName();\r
- value = componentContext\r
- .get(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + "." + dictionaryKeyName);\r
- }\r
- return value;\r
- }\r
-\r
- public static synchronized Object getTemplateKeyValue(Map<String, Object> componentContext,\r
- ResourceAssignment resourceMapping) {\r
- Object value = null;\r
- if (resourceMapping != null && componentContext != null) {\r
- String recipeName = (String) componentContext.get(ConfigModelConstant.PROPERTY_ACTION_NAME);\r
- String templateKeyName = resourceMapping.getName();\r
- value = componentContext\r
- .get(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + recipeName + "." + templateKeyName);\r
- }\r
- return value;\r
- }\r
-\r
- public static synchronized void setResourceDataValue(Map<String, Object> componentContext,\r
- ResourceAssignment resourceAssignment, Object value) throws ConfigModelException {\r
-\r
- if (resourceAssignment != null && StringUtils.isNotBlank(resourceAssignment.getName())\r
- && resourceAssignment.getProperty() != null) {\r
-\r
- String recipeName = (String) componentContext.get(ConfigModelConstant.PROPERTY_ACTION_NAME);\r
- String templateKeyName = resourceAssignment.getName();\r
- String dictionaryKeyName = resourceAssignment.getDictionaryName();\r
-\r
- if (StringUtils.isBlank(dictionaryKeyName)) {\r
- resourceAssignment.setDictionaryName(templateKeyName);\r
- dictionaryKeyName = templateKeyName;\r
- logger.warn("Missing dictionary key, setting with template key ({}) as dictionary key ({})",\r
- templateKeyName, dictionaryKeyName);\r
- }\r
- String type = resourceAssignment.getProperty().getType();\r
- try {\r
- if (StringUtils.isNotBlank(type)) {\r
- Object convertedValue = convertResourceValue(type, value);\r
-\r
- componentContext.put(\r
- ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + "." + dictionaryKeyName,\r
- convertedValue);\r
- componentContext.put(\r
- ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + recipeName + "." + templateKeyName,\r
- convertedValue);\r
-\r
- logger.trace("Setting Resource Value ({}) for Resource Name ({}) of type ({}) ", convertedValue,\r
- dictionaryKeyName, type);\r
-\r
- resourceAssignment.getProperty().setValue(convertedValue);\r
- resourceAssignment.setUpdatedDate(new Date());\r
- resourceAssignment.setUpdatedBy(ConfigModelConstant.USER_SYSTEM);\r
- resourceAssignment.setStatus(ConfigModelConstant.STATUS_SUCCESS);\r
- }\r
- } catch (Exception e) {\r
- throw new ConfigModelException(String.format(\r
- "Failed in setting value for template key (%s) and dictionary key (%s) of type (%s) with error message (%s)",\r
- templateKeyName, dictionaryKeyName, type, e.getMessage()));\r
- }\r
- } else {\r
- throw new ConfigModelException(\r
- String.format("Failed in setting resource value for resource mapping (%s)", resourceAssignment));\r
- }\r
- }\r
-\r
- private static Object convertResourceValue(String type, Object value) {\r
- Object convertedValue = null;\r
-\r
- if (value == null || value instanceof NullNode) {\r
- logger.info("Returning {} value from convertResourceValue", value);\r
- return null;\r
- }\r
-\r
- if (ValidTypes.getPrimitivePropertType().contains(type)) {\r
- convertedValue = convertPrimitiveResourceValue(type, value);\r
- } else {\r
- // Case where Resource is non-primitive type\r
- if (value instanceof JsonNode || value instanceof ObjectNode || value instanceof ArrayNode) {\r
- convertedValue = value;\r
- } else if (value instanceof String) {\r
- convertedValue = TransformationUtils.getJsonNodeForString((String) value);\r
- } else {\r
- convertedValue = TransformationUtils.getJsonNodeForObject(value);\r
- }\r
- }\r
- return convertedValue;\r
- }\r
-\r
- @SuppressWarnings("squid:S3776")\r
- private static Object convertPrimitiveResourceValue(String type, Object value) {\r
- Object convertedValue = value;\r
-\r
- if (value instanceof ArrayNode) {\r
- if (ValidTypes.DATA_TYPE_BOOLEAN.equalsIgnoreCase(type)) {\r
- convertedValue = ((ArrayNode) value).asBoolean();\r
- } else if (ValidTypes.DATA_TYPE_INTEGER.equalsIgnoreCase(type)) {\r
- convertedValue = ((ArrayNode) value).asInt();\r
- } else if (ValidTypes.DATA_TYPE_FLOAT.equalsIgnoreCase(type)) {\r
- convertedValue = Float.valueOf(((ArrayNode) value).toString());\r
- } else {\r
- convertedValue = ((ArrayNode) value).toString();\r
- }\r
- } else if (value instanceof JsonNode) {\r
- if (ValidTypes.DATA_TYPE_BOOLEAN.equalsIgnoreCase(type)) {\r
- convertedValue = ((JsonNode) value).asBoolean();\r
- } else if (ValidTypes.DATA_TYPE_INTEGER.equalsIgnoreCase(type)) {\r
- convertedValue = ((JsonNode) value).asInt();\r
- } else if (ValidTypes.DATA_TYPE_FLOAT.equalsIgnoreCase(type)) {\r
- convertedValue = Float.valueOf(((JsonNode) value).asText());\r
- } else {\r
- convertedValue = ((JsonNode) value).asText();\r
- }\r
- } else if (value instanceof String) {\r
- if (ValidTypes.DATA_TYPE_BOOLEAN.equalsIgnoreCase(type)) {\r
- convertedValue = Boolean.valueOf((String) value);\r
- } else if (ValidTypes.DATA_TYPE_INTEGER.equalsIgnoreCase(type)) {\r
- convertedValue = Integer.valueOf((String) value);\r
- } else if (ValidTypes.DATA_TYPE_FLOAT.equalsIgnoreCase(type)) {\r
- convertedValue = Float.valueOf((String) value);\r
- }\r
- }\r
- logger.info("Returning value ({}) from convertPrimitiveResourceValue", convertedValue);\r
- return convertedValue;\r
- }\r
-\r
- @SuppressWarnings("squid:S1172")\r
- public static synchronized void setFailedResourceDataValue(Map<String, Object> componentContext,\r
- ResourceAssignment resourceAssignment, String message) {\r
- setFailedResourceDataValue(resourceAssignment, message);\r
- }\r
-\r
- public static synchronized void setFailedResourceDataValue(ResourceAssignment resourceAssignment, String message) {\r
- if (resourceAssignment != null && StringUtils.isNotBlank(resourceAssignment.getName())\r
- && resourceAssignment.getProperty() != null) {\r
- resourceAssignment.setUpdatedDate(new Date());\r
- resourceAssignment.setStatus(ConfigModelConstant.STATUS_FAILURE);\r
- resourceAssignment.setUpdatedBy(ConfigModelConstant.USER_SYSTEM);\r
- resourceAssignment.setMessage(message);\r
- }\r
- }\r
-\r
- public static synchronized void assertTemplateKeyValueNotNull(Map<String, Object> componentContext,\r
- ResourceAssignment resourceAssignment) throws ConfigModelException {\r
- if (resourceAssignment != null && resourceAssignment.getProperty() != null\r
- && BooleanUtils.isTrue(resourceAssignment.getProperty().getRequired())\r
- && getTemplateKeyValue(componentContext, resourceAssignment) == null) {\r
- logger.error("failed to populate mandatory resource mapping ({})", resourceAssignment);\r
- throw new ConfigModelException(\r
- String.format("failed to populate mandatory resource mapping (%s)", resourceAssignment));\r
- }\r
- }\r
-\r
- @SuppressWarnings({"squid:S3776", "squid:S1141"})\r
- public static synchronized String generateResourceDataForAssignments(List<ResourceAssignment> assignments)\r
- throws ConfigModelException {\r
- String result = "{}";\r
- try {\r
- ObjectMapper mapper = new ObjectMapper();\r
- JsonNode root = mapper.readTree(result);\r
- for (ResourceAssignment resourceMapping : assignments) {\r
- if (resourceMapping != null && resourceMapping.getName() != null\r
- && resourceMapping.getProperty() != null) {\r
-\r
- String type = resourceMapping.getProperty().getType();\r
- Object value = resourceMapping.getProperty().getValue();\r
- logger.info("Generating Resource name ({}), type ({}), value ({})", resourceMapping.getName(), type,\r
- value);\r
- if (value == null) {\r
- ((ObjectNode) root).set(resourceMapping.getName(), null);\r
- } else if (value instanceof JsonNode) {\r
- ((ObjectNode) root).put(resourceMapping.getName(), (JsonNode) value);\r
- } else if (ValidTypes.DATA_TYPE_STRING.equalsIgnoreCase(type)) {\r
- ((ObjectNode) root).put(resourceMapping.getName(), (String) value);\r
- } else if (ValidTypes.DATA_TYPE_BOOLEAN.equalsIgnoreCase(type)) {\r
- ((ObjectNode) root).put(resourceMapping.getName(), (Boolean) value);\r
- } else if (ValidTypes.DATA_TYPE_INTEGER.equalsIgnoreCase(type)) {\r
- ((ObjectNode) root).put(resourceMapping.getName(), (Integer) value);\r
- } else if (ValidTypes.DATA_TYPE_FLOAT.equalsIgnoreCase(type)) {\r
- ((ObjectNode) root).put(resourceMapping.getName(), (Float) value);\r
- } else if (ValidTypes.DATA_TYPE_TIMESTAMP.equalsIgnoreCase(type)) {\r
- ((ObjectNode) root).put(resourceMapping.getName(), (String) value);\r
- } else {\r
- JsonNode jsonNode = TransformationUtils.getJsonNodeForObject(value);\r
- if (jsonNode != null) {\r
- ((ObjectNode) root).put(resourceMapping.getName(), jsonNode);\r
- } else {\r
- ((ObjectNode) root).set(resourceMapping.getName(), null);\r
- }\r
- }\r
- }\r
- }\r
- result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(root);\r
- logger.info("Generated Resource Param Data ({})", result);\r
- } catch (Exception e) {\r
- throw new ConfigModelException(e.getMessage(), e);\r
- }\r
- return result;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.utils;\r
-\r
-import java.util.Map;\r
-import java.util.Optional;\r
-import java.util.function.Supplier;\r
-import org.apache.commons.collections.CollectionUtils;\r
-import org.apache.commons.collections.MapUtils;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.data.PropertyDefinition;\r
-import org.onap.ccsdk.features.model.data.ResourceAssignment;\r
-import org.onap.ccsdk.features.model.data.dict.ResourceDefinition;\r
-import org.onap.ccsdk.features.model.data.dict.SourcesDefinition;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-/**\r
- * ResourceDictionaryUtils.java Purpose to provide ResourceDictionaryUtils\r
- *\r
- * @version 1.0\r
- */\r
-public class ResourceDictionaryUtils {\r
-\r
- private ResourceDictionaryUtils() {\r
- // Do nothing\r
- }\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceDictionaryUtils.class);\r
-\r
- /**\r
- * This Method is to assign the source name to the Dictionary Definition Check to see if the source\r
- * definition is not present then assign, if more than one source then assign only one source.\r
- *\r
- * @param resourceAssignment\r
- * @param resourceDefinition\r
- */\r
- @SuppressWarnings("squid:S3776")\r
- public static void populateSourceMapping(ResourceAssignment resourceAssignment,\r
- ResourceDefinition resourceDefinition) {\r
-\r
- if (resourceAssignment != null && resourceDefinition != null\r
- && StringUtils.isBlank(resourceAssignment.getDictionarySource())) {\r
-\r
- setProperty(resourceAssignment, resourceDefinition);\r
- Map<String, SourcesDefinition> sourcesDefinition = resourceDefinition.getSources();\r
-\r
- if (sourcesDefinition != null && MapUtils.isNotEmpty(sourcesDefinition) && sourcesDefinition.size() == 1) {\r
- if (sourcesDefinition.get("input") != null) {\r
- resourceAssignment.setDictionarySource(ConfigModelConstant.SOURCE_INPUT);\r
- } else if (sourcesDefinition.get("default") != null) {\r
- resourceAssignment.setDictionarySource(ConfigModelConstant.SOURCE_DEFAULT);\r
- } else if (sourcesDefinition.get("db") != null) {\r
- resourceAssignment.setDictionarySource(ConfigModelConstant.SOURCE_DB);\r
- if (resolve(() -> sourcesDefinition.get("db").getProperties().getDependencies()).isPresent()\r
- && CollectionUtils\r
- .isNotEmpty(sourcesDefinition.get("db").getProperties().getDependencies())) {\r
- resourceAssignment\r
- .setDependencies(sourcesDefinition.get("db").getProperties().getDependencies());\r
- }\r
- } else if (sourcesDefinition.get("mdsal") != null) {\r
- resourceAssignment.setDictionarySource(ConfigModelConstant.SOURCE_MDSAL);\r
- if (resolve(() -> sourcesDefinition.get("mdsal").getProperties().getDependencies()).isPresent()\r
- && CollectionUtils\r
- .isNotEmpty(sourcesDefinition.get("mdsal").getProperties().getDependencies())) {\r
- resourceAssignment\r
- .setDependencies(sourcesDefinition.get("mdsal").getProperties().getDependencies());\r
- }\r
- }\r
- logger.info("automapped resourceAssignment : {}", resourceAssignment);\r
- }\r
- }\r
- }\r
-\r
- public static <T> Optional<T> resolve(Supplier<T> resolver) {\r
- try {\r
- T result = resolver.get();\r
- return Optional.ofNullable(result);\r
- } catch (NullPointerException e) {\r
- return Optional.empty();\r
- }\r
- }\r
-\r
- /**\r
- * Overriding ResourceAssignment Properties with properties defined in Dictionary\r
- */\r
- private static void setProperty(ResourceAssignment resourceAssignment, ResourceDefinition resourceDefinition) {\r
- if (StringUtils.isNotBlank(resourceDefinition.getProperty().getType())) {\r
- PropertyDefinition property = resourceAssignment.getProperty();\r
- if (property == null) {\r
- property = new PropertyDefinition();\r
- }\r
- if (resourceDefinition.getProperty() != null) {\r
- property.setType(resourceDefinition.getProperty().getType());\r
- if (resourceDefinition.getProperty().getEntrySchema() != null) {\r
- property.setEntrySchema(resourceDefinition.getProperty().getEntrySchema());\r
- }\r
- resourceAssignment.setProperty(property);\r
- }\r
- }\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.utils;\r
-\r
-import java.util.Map;\r
-import org.apache.commons.collections.MapUtils;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.data.InterfaceAssignment;\r
-import org.onap.ccsdk.features.model.data.InterfaceDefinition;\r
-import org.onap.ccsdk.features.model.data.NodeTemplate;\r
-import org.onap.ccsdk.features.model.data.NodeType;\r
-import org.onap.ccsdk.features.model.data.OperationAssignment;\r
-import org.onap.ccsdk.features.model.data.OperationDefinition;\r
-import org.onap.ccsdk.features.model.data.ServiceTemplate;\r
-import org.onap.ccsdk.features.model.data.TopologyTemplate;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class ServiceTemplateUtils {\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ServiceTemplateUtils.class);\r
-\r
- public Map<String, String> convertServiceTemplate2Properties(String serviceTemplateContent,\r
- final Map<String, String> context) {\r
- if (StringUtils.isNotBlank(serviceTemplateContent)) {\r
- ServiceTemplate serviceTemplate =\r
- TransformationUtils.readValue(serviceTemplateContent, ServiceTemplate.class);\r
- convertServiceTemplate2Properties(serviceTemplate, context);\r
- }\r
- return context;\r
- }\r
-\r
- public Map<String, String> convertServiceTemplate2Properties(ServiceTemplate serviceTemplate,\r
- final Map<String, String> context) {\r
- if (serviceTemplate != null) {\r
- convertServiceTemplateMetadata2Properties(serviceTemplate, context);\r
- convertServiceTemplateInputs2Properties(serviceTemplate, context);\r
- convertDataTypes2Properties(serviceTemplate, context);\r
- convertNode2Properties(serviceTemplate, context);\r
- }\r
- return context;\r
- }\r
-\r
- public Map<String, String> convertServiceTemplateMetadata2Properties(ServiceTemplate serviceTemplate,\r
- final Map<String, String> context) {\r
-\r
- if (serviceTemplate != null && serviceTemplate.getMetadata() != null) {\r
- serviceTemplate.getMetadata().forEach((metaDataKey, metadata) -> {\r
- context.put(metaDataKey, metadata);\r
- });\r
- }\r
- return context;\r
- }\r
-\r
- public Map<String, String> convertServiceTemplateInputs2Properties(ServiceTemplate serviceTemplate,\r
- final Map<String, String> context) {\r
-\r
- if (serviceTemplate != null && serviceTemplate.getTopologyTemplate() != null\r
- && serviceTemplate.getTopologyTemplate().getInputs() != null) {\r
-\r
- serviceTemplate.getTopologyTemplate().getInputs().forEach((paramKey, parameterDefinition) -> {\r
- if (parameterDefinition != null) {\r
- context.put(ConfigModelConstant.PROPERTY_INPUTS_DOT + paramKey + ".type",\r
- parameterDefinition.getType());\r
- if (parameterDefinition.getRequired()) {\r
- context.put(ConfigModelConstant.PROPERTY_INPUTS_DOT + paramKey + ".required",\r
- String.valueOf(parameterDefinition.getRequired()));\r
- }\r
- if (parameterDefinition.getDefaultValue() != null) {\r
- context.put(ConfigModelConstant.PROPERTY_INPUTS_DOT + paramKey + ".default",\r
- String.valueOf(parameterDefinition.getDefaultValue()));\r
- }\r
- }\r
- });\r
- }\r
- return context;\r
- }\r
-\r
- public Map<String, String> convertDataTypes2Properties(ServiceTemplate serviceTemplate,\r
- final Map<String, String> context) {\r
- if (serviceTemplate != null && serviceTemplate.getDataTypes() != null) {\r
- serviceTemplate.getDataTypes().forEach((dataTypeKey, dataType) -> {\r
- logger.trace("Populating Data Type Key : ({})", dataTypeKey);\r
- String dataTypeContent = TransformationUtils.getJson(dataType);\r
- context.put("data_types." + dataTypeKey, dataTypeContent);\r
- });\r
- }\r
- return context;\r
- }\r
-\r
- public Map<String, String> convertNode2Properties(ServiceTemplate serviceTemplate,\r
- final Map<String, String> context) {\r
-\r
- if (serviceTemplate != null && serviceTemplate.getNodeTypes() != null\r
- && serviceTemplate.getTopologyTemplate() != null\r
- && serviceTemplate.getTopologyTemplate().getNodeTemplates() != null) {\r
-\r
- serviceTemplate.getTopologyTemplate().getNodeTemplates().forEach((nodeTemplateKey, nodeTemplate) -> {\r
- if (nodeTemplate != null && StringUtils.isNotBlank(nodeTemplate.getType())) {\r
- String nodeTypeKey = nodeTemplate.getType();\r
- logger.trace("Populating Node Type Key : ({}) for Node Template : ({})", nodeTypeKey,\r
- nodeTemplateKey);\r
- String nodeTemplateContent = TransformationUtils.getJson(nodeTemplate);\r
- context.put("node_templates." + nodeTemplateKey, nodeTemplateContent);\r
- if (serviceTemplate.getNodeTypes().containsKey(nodeTypeKey)) {\r
- NodeType nodeType = serviceTemplate.getNodeTypes().get(nodeTypeKey);\r
- String nodeTypeContent = TransformationUtils.getJson(nodeType);\r
- context.put("node_types." + nodeTypeKey, nodeTypeContent);\r
- String nodeDerivedFrom = nodeType.getDerivedFrom();\r
- if (ConfigModelConstant.MODEL_TYPE_NODE_DG.equalsIgnoreCase(nodeDerivedFrom)) {\r
- populateDGNodeProperties(nodeTemplateKey, nodeTemplate, context, nodeDerivedFrom);\r
- }\r
- }\r
- // Populate the Artifact Definitions\r
- populateNodeTemplateArtifacts(nodeTemplateKey, nodeTemplate, context);\r
- }\r
- });\r
- }\r
- return context;\r
- }\r
-\r
- @SuppressWarnings("squid:S1172")\r
- public Map<String, String> populateVnfNodeProperties(String nodeTemplateKey, NodeTemplate nodeTemplate,\r
- final Map<String, String> context, String nodeDerivedFrom) {\r
- if (nodeTemplate != null && nodeTemplate.getCapabilities() != null) {\r
- nodeTemplate.getCapabilities().forEach((capabilityKey, capability) -> {\r
- capability.getProperties().forEach((propertyKey, property) -> {\r
- context.put(nodeTemplateKey + "." + capabilityKey + "." + propertyKey, String.valueOf(property));\r
- });\r
- });\r
- }\r
-\r
- return context;\r
- }\r
-\r
- public Map<String, String> populateNodeTemplateArtifacts(String nodeTemplateKey, NodeTemplate nodeTemplate,\r
- final Map<String, String> context) {\r
- if (MapUtils.isNotEmpty(nodeTemplate.getArtifacts())) {\r
- nodeTemplate.getArtifacts().forEach((artifactName, artifact) -> {\r
- if (StringUtils.isNotBlank(artifactName) && artifact != null) {\r
- logger.trace("Populating Node Template Artifacts ({}) for Node Template ({})", artifactName,\r
- nodeTemplateKey);\r
- String fileKeyName = ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + nodeTemplateKey + "."\r
- + ConfigModelConstant.PROPERTY_ARTIFACTS_DOT + artifactName + ".file";\r
- String deployKeyName = ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + nodeTemplateKey + "."\r
- + ConfigModelConstant.PROPERTY_ARTIFACTS_DOT + artifactName + ".deploy_path";\r
- String contentKeyName = ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + nodeTemplateKey + "."\r
- + ConfigModelConstant.PROPERTY_ARTIFACTS_DOT + artifactName + ".content";\r
- context.put(fileKeyName, artifact.getFile());\r
- context.put(deployKeyName, artifact.getDeployPath());\r
- context.put(contentKeyName, artifact.getContent());\r
- }\r
- });\r
- }\r
- return context;\r
- }\r
-\r
- public Map<String, String> populateDGNodeProperties(String nodeTemplateKey, NodeTemplate nodeTemplate,\r
- final Map<String, String> context, String nodeDerivedFrom) {\r
- if (nodeTemplate != null && nodeTemplate.getInterfaces() != null) {\r
-\r
- if (nodeTemplate.getProperties() != null) {\r
- nodeTemplate.getProperties().forEach((propKey, propValue) -> {\r
- if (propKey != null && propValue != null) {\r
- context.put("dg." + nodeTemplateKey + "." + propKey, String.valueOf(propValue));\r
- }\r
- });\r
- }\r
-\r
- nodeTemplate.getInterfaces().forEach((interfaceKey, interfaceDefinition) -> {\r
-\r
- interfaceDefinition.getOperations().forEach((operationKey, operation) -> {\r
- if (ConfigModelConstant.MODEL_TYPE_NODE_DG.equalsIgnoreCase(nodeDerivedFrom)) {\r
- context.put("dg." + nodeTemplateKey + ".module", interfaceKey);\r
- context.put("dg." + nodeTemplateKey + ".flow", operationKey);\r
- }\r
- });\r
- });\r
- }\r
- return context;\r
- }\r
-\r
- public SvcLogicContext getInterfaceOpertationDefinition(ServiceTemplate serviceTemplate,\r
- final SvcLogicContext context) {\r
-\r
- if (serviceTemplate != null && serviceTemplate.getNodeTypes() != null\r
- && serviceTemplate.getTopologyTemplate() != null\r
- && serviceTemplate.getTopologyTemplate().getNodeTemplates() != null) {\r
-\r
- TopologyTemplate topologyTemplates = serviceTemplate.getTopologyTemplate();\r
- // Copy Definition to Template\r
- copyNodeType2Template(serviceTemplate.getNodeTypes(), topologyTemplates.getNodeTemplates());\r
-\r
- topologyTemplates.getNodeTemplates().forEach((templateKey, nodeTemplate) -> {\r
-\r
- if (StringUtils.isNotBlank(templateKey) && nodeTemplate != null\r
- && nodeTemplate.getInterfaces() != null) {\r
-\r
- nodeTemplate.getInterfaces().forEach((interfaceKey, interfaceDefinition) -> {\r
- if (StringUtils.isNotBlank(interfaceKey) && interfaceDefinition != null) {\r
- interfaceDefinition.getOperations().forEach((operationKey, operation) -> {\r
- String definitionKey = interfaceKey + "." + operationKey;\r
- String definitionContent = TransformationUtils.getJson(operation);\r
- context.setAttribute(definitionKey, definitionContent);\r
- // Set the Operation & Method Params\r
- });\r
- }\r
- });\r
- }\r
- });\r
- }\r
- return context;\r
- }\r
-\r
- public void copyNodeType2Template(Map<String, NodeType> nodeTypes, Map<String, NodeTemplate> nodeTemplates) {\r
- if (nodeTypes != null && nodeTemplates != null) {\r
-\r
- nodeTemplates.forEach((templateKey, nodeTemplate) -> {\r
- if (StringUtils.isNotBlank(templateKey) && nodeTemplate != null) {\r
- String type = nodeTemplate.getType();\r
- // Check the Node Template Type is Present\r
- if (StringUtils.isNotBlank(type) && nodeTypes.containsKey(type)) {\r
- NodeType nodeType = nodeTypes.get(type);\r
- logger.trace("Checking Node Type Content : ({})", TransformationUtils.getJson(nodeType));\r
- copyNodeTypeInterface2Template(nodeType.getInterfaces(), nodeTemplate.getInterfaces());\r
- }\r
- }\r
- });\r
- }\r
- }\r
-\r
- public void copyNodeTypeInterface2Template(Map<String, InterfaceDefinition> nodeTypeInterfaces,\r
- Map<String, InterfaceAssignment> nodeTemplateInterfaces) {\r
- if (nodeTypeInterfaces != null && nodeTemplateInterfaces != null) {\r
-\r
- nodeTemplateInterfaces.forEach((interfaceKey, nodeTemplateinterface) -> {\r
- InterfaceDefinition nodeTypeInterface = nodeTypeInterfaces.get(interfaceKey);\r
- logger.trace("Checking Interface Type Content : ({})", TransformationUtils.getJson(nodeTypeInterface));\r
- if (nodeTypeInterface != null && nodeTemplateinterface != null) {\r
- copyNodeTypeOperation2Template(nodeTypeInterface.getOperations(),\r
- nodeTemplateinterface.getOperations());\r
- }\r
- });\r
- }\r
- }\r
-\r
- public void copyNodeTypeOperation2Template(Map<String, OperationDefinition> nodeTypeOperations,\r
- Map<String, OperationAssignment> nodeTemplateOperations) {\r
- if (nodeTypeOperations != null && nodeTemplateOperations != null) {\r
-\r
- nodeTemplateOperations.forEach((operationKey, nodeTemplateOperation) -> {\r
- OperationDefinition nodeTypeInterfaceOperation = nodeTypeOperations.get(operationKey);\r
- if (nodeTypeInterfaceOperation != null && nodeTemplateOperation != null) {\r
- logger.info("Checking Operation Type Content : " + operationKey + " : "\r
- + TransformationUtils.getJson(nodeTypeInterfaceOperation));\r
- }\r
- });\r
- }\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.utils;\r
-\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-import java.util.LinkedList;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Queue;\r
-import java.util.Stack;\r
-\r
-public class TopologicalSortingUtils<V> {\r
-\r
- /**\r
- * The implementation here is basically an adjacency list, but instead of an array of lists, a Map\r
- * is used to map each vertex to its list of adjacent vertices.\r
- */\r
- private Map<V, List<V>> neighbors = new HashMap<>();\r
-\r
- /**\r
- * String representation of graph.\r
- */\r
- @Override\r
- public String toString() {\r
- StringBuilder s = new StringBuilder();\r
- neighbors.forEach((v, vs) -> s.append("\n " + v + " -> " + vs));\r
- return s.toString();\r
- }\r
-\r
- public Map<V, List<V>> getNeighbors() {\r
- return neighbors;\r
- }\r
-\r
- /**\r
- * Add a vertex to the graph. Nothing happens if vertex is already in graph.\r
- */\r
- public void add(V vertex) {\r
- if (neighbors.containsKey(vertex))\r
- return;\r
- neighbors.put(vertex, new ArrayList<V>());\r
- }\r
-\r
- /**\r
- * True iff graph contains vertex.\r
- */\r
- public boolean contains(V vertex) {\r
- return neighbors.containsKey(vertex);\r
- }\r
-\r
- /**\r
- * Add an edge to the graph; if either vertex does not exist, it's added. This implementation allows\r
- * the creation of multi-edges and self-loops.\r
- */\r
- public void add(V from, V to) {\r
- this.add(from);\r
- this.add(to);\r
- neighbors.get(from).add(to);\r
- }\r
-\r
- /**\r
- * Remove an edge from the graph. Nothing happens if no such edge.\r
- *\r
- * @throws IllegalArgumentException if either vertex doesn't exist.\r
- */\r
- public void remove(V from, V to) {\r
- if (!(this.contains(from) && this.contains(to)))\r
- throw new IllegalArgumentException("Nonexistent vertex");\r
- neighbors.get(from).remove(to);\r
- }\r
-\r
- /**\r
- * Report (as a Map) the out-degree of each vertex.\r
- */\r
- public Map<V, Integer> outDegree() {\r
- Map<V, Integer> result = new HashMap<>();\r
- neighbors.forEach((v, vs) -> result.put(v, vs.size()));\r
- return result;\r
- }\r
-\r
- /**\r
- * Report (as a Map) the in-degree of each vertex.\r
- */\r
- public Map<V, Integer> inDegree() {\r
- Map<V, Integer> result = new HashMap<>();\r
- for (V v : neighbors.keySet())\r
- result.put(v, 0); // All in-degrees are 0\r
-\r
- neighbors.forEach((from, vs) -> vs.forEach(to -> result.put(to, result.get(to) + 1) // Increment in-degree\r
- ));\r
-\r
- return result;\r
- }\r
-\r
- /**\r
- * Report (as a List) the topological sort of the vertices; null for no such sort.\r
- */\r
- @SuppressWarnings({"squid:S1149", "squid:S1168"})\r
- public List<V> topSort() {\r
- Map<V, Integer> degree = inDegree();\r
- // Determine all vertices with zero in-degree\r
- Stack<V> zeroVerts = new Stack<>(); // Stack as good as any here\r
-\r
- degree.forEach((v, vs) -> {\r
- if (vs == 0)\r
- zeroVerts.push(v);\r
- });\r
-\r
- // Determine the topological order\r
- List<V> result = new ArrayList<>();\r
- while (!zeroVerts.isEmpty()) {\r
- V v = zeroVerts.pop(); // Choose a vertex with zero in-degree\r
- result.add(v); // Vertex v is next in topol order\r
- // "Remove" vertex v by updating its neighbors\r
- for (V neighbor : neighbors.get(v)) {\r
- degree.put(neighbor, degree.get(neighbor) - 1);\r
- // Remember any vertices that now have zero in-degree\r
- if (degree.get(neighbor) == 0)\r
- zeroVerts.push(neighbor);\r
- }\r
- }\r
- // Check that we have used the entire graph (if not, there was a cycle)\r
- if (result.size() != neighbors.size())\r
- return null;\r
- return result;\r
- }\r
-\r
- /**\r
- * True iff graph is a dag (directed acyclic graph).\r
- */\r
- public boolean isDag() {\r
- return topSort() != null;\r
- }\r
-\r
- /**\r
- * Report (as a Map) the bfs distance to each vertex from the start vertex. The distance is an\r
- * Integer; the value null is used to represent infinity (implying that the corresponding node\r
- * cannot be reached).\r
- */\r
- public Map bfsDistance(V start) {\r
- Map<V, Integer> distance = new HashMap<>();\r
- // Initially, all distance are infinity, except start node\r
- for (V v : neighbors.keySet())\r
- distance.put(v, null);\r
- distance.put(start, 0);\r
- // Process nodes in queue order\r
- Queue<V> queue = new LinkedList<>();\r
- queue.offer(start); // Place start node in queue\r
- while (!queue.isEmpty()) {\r
- V v = queue.remove();\r
- int vDist = distance.get(v);\r
- // Update neighbors\r
- for (V neighbor : neighbors.get(v)) {\r
- if (distance.get(neighbor) != null)\r
- continue; // Ignore if already done\r
- distance.put(neighbor, vDist + 1);\r
- queue.offer(neighbor);\r
- }\r
- }\r
- return distance;\r
- }\r
-\r
- /**\r
- * Main program (for testing). public static void main (String[] args) { // Create a Graph with\r
- * Integer nodes TopologicalSortingUtils<String> graph = new TopologicalSortingUtils<String>();\r
- * graph.add("bundle-id", "bundle-mac"); graph.add("bundle-id", "bundle-ip");\r
- * graph.add("bundle-mac", "bundle-ip"); graph.add("bundle-ip", "bundle-mac");\r
- * System.out.println("The current graph: " + graph); System.out.println("In-degrees: " +\r
- * graph.inDegree()); System.out.println("Out-degrees: " + graph.outDegree()); System.out.println("A\r
- * topological sort of the vertices: " + graph.topSort()); System.out.println("The graph " +\r
- * (graph.isDag()?"is":"is not") + " a dag"); }\r
- */\r
-}\r
+++ /dev/null
-/*\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.features.model.utils;\r
-\r
-import java.io.IOException;\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Properties;\r
-import java.util.TreeMap;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-import com.fasterxml.jackson.annotation.JsonInclude.Include;\r
-import com.fasterxml.jackson.core.JsonProcessingException;\r
-import com.fasterxml.jackson.core.type.TypeReference;\r
-import com.fasterxml.jackson.databind.JsonNode;\r
-import com.fasterxml.jackson.databind.ObjectMapper;\r
-import com.fasterxml.jackson.databind.SerializationFeature;\r
-import com.fasterxml.jackson.databind.node.ArrayNode;\r
-import com.fasterxml.jackson.databind.type.CollectionType;\r
-import com.fasterxml.jackson.module.jsonSchema.JsonSchema;\r
-import com.fasterxml.jackson.module.jsonSchema.JsonSchemaGenerator;\r
-\r
-/**\r
- * TransformationUtils.java Purpose: Provide Configuration Generator TransformationUtils Information\r
- *\r
- * @version 1.0\r
- */\r
-public class TransformationUtils {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(TransformationUtils.class);\r
-\r
- private TransformationUtils() {\r
-\r
- }\r
-\r
- /**\r
- * This is a getJson method\r
- *\r
- * @param configparameters\r
- * @return String\r
- */\r
- public static String getJson(Map<String, Object> configparameters) {\r
- String jsonContent = null;\r
- try {\r
- ObjectMapper mapper = new ObjectMapper();\r
- jsonContent = mapper.writeValueAsString(configparameters);\r
- } catch (JsonProcessingException e) {\r
- logger.warn(e.getMessage());\r
- }\r
- return jsonContent;\r
- }\r
-\r
- /**\r
- * This is a getJsonNode method\r
- *\r
- * @param configparameters\r
- * @return String\r
- */\r
- public static JsonNode getJsonNode(Map<String, String> configparameters) {\r
- JsonNode jsonContent = null;\r
- try {\r
- ObjectMapper mapper = new ObjectMapper();\r
- jsonContent = mapper.valueToTree(configparameters);\r
- } catch (Exception e) {\r
- logger.warn(e.getMessage());\r
- }\r
- return jsonContent;\r
- }\r
-\r
- /**\r
- * This is a getJson method\r
- *\r
- * @param instance\r
- * @param pretty\r
- * @return Map<String , Object>\r
- */\r
- public static String getJson(Object instance, boolean pretty) {\r
- try {\r
- ObjectMapper mapper = new ObjectMapper();\r
- mapper.setSerializationInclusion(Include.NON_NULL);\r
- if (pretty) {\r
- mapper.enable(SerializationFeature.INDENT_OUTPUT);\r
- }\r
- return mapper.writeValueAsString(instance);\r
- } catch (JsonProcessingException e) {\r
- logger.warn(e.getMessage());\r
- }\r
- return null;\r
- }\r
-\r
- /**\r
- * This is a getJson method\r
- *\r
- * @param instance\r
- * @return String\r
- */\r
- public static String getJson(Object instance) {\r
- return getJson(instance, false);\r
- }\r
-\r
- /**\r
- * This is a getJsonNodeForobject method\r
- *\r
- * @param instance\r
- * @return JsonNode\r
- */\r
- public static JsonNode getJsonNodeForObject(Object instance) {\r
- try {\r
- ObjectMapper mapper = new ObjectMapper();\r
- mapper.setSerializationInclusion(Include.NON_NULL);\r
- return mapper.convertValue(instance, JsonNode.class);\r
- } catch (Exception e) {\r
- logger.warn(e.getMessage());\r
- }\r
- return null;\r
- }\r
-\r
- /**\r
- * This is a getJsonNodeForString method\r
- *\r
- * @param content\r
- * @return JsonNode\r
- */\r
- public static JsonNode getJsonNodeForString(String content) {\r
- try {\r
- ObjectMapper mapper = new ObjectMapper();\r
- mapper.setSerializationInclusion(Include.NON_NULL);\r
- return mapper.readTree(content);\r
- } catch (Exception e) {\r
- logger.warn(e.getMessage());\r
- }\r
- return null;\r
- }\r
-\r
- /**\r
- * This is a getMapfromJson method\r
- *\r
- * @param content\r
- * @return Map<String , Object>\r
- */\r
- public static Map<String, Object> getMapfromJson(String content) {\r
- try {\r
- ObjectMapper mapper = new ObjectMapper();\r
- return mapper.readValue(content, new TypeReference<Map<String, String>>() {});\r
- } catch (Exception e) {\r
- logger.warn("failed in getMapfromJson for the content ({}) with error message ({}).", content,\r
- e.getMessage());\r
- }\r
- return null;\r
- }\r
-\r
- /**\r
- * This is a getMapfromJson method\r
- *\r
- * @param content\r
- * @return Map<String , Object>\r
- */\r
- public static Map<String, Object> getMapfromJsonString(String content) {\r
- try {\r
- ObjectMapper mapper = new ObjectMapper();\r
- return mapper.readValue(content, new TypeReference<Map<String, Object>>() {});\r
- } catch (Exception e) {\r
- logger.warn("failed in getMapfromJson for the content ({}) with error message ({}).", content,\r
- e.getMessage());\r
- }\r
- return null;\r
- }\r
-\r
- /**\r
- * This is a getListfromJson method\r
- *\r
- * @param content\r
- * @return Map<String , Object>\r
- */\r
- @SuppressWarnings("squid:S1168")\r
- public static <T> List<T> getListfromJson(String content, Class<T> valueType) {\r
- try {\r
- ObjectMapper mapper = new ObjectMapper();\r
- CollectionType javaType = mapper.getTypeFactory().constructCollectionType(List.class, valueType);\r
- return mapper.readValue(content, javaType);\r
- } catch (Exception e) {\r
- logger.warn("failed in getListfromJson for the content ({}) with error message ({}).", content,\r
- e.getMessage());\r
- }\r
- return null;\r
- }\r
-\r
- /**\r
- * This is a getJsonSchema method\r
- *\r
- * @param valueType\r
- * @return String\r
- */\r
- public static String getJsonSchema(Class clazz) {\r
- try {\r
- ObjectMapper mapper = new ObjectMapper();\r
- JsonSchemaGenerator schemaGen = new JsonSchemaGenerator(mapper);\r
- JsonSchema schema = schemaGen.generateSchema(clazz);\r
- return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(schema);\r
-\r
- } catch (Exception e) {\r
- logger.warn("failed in getJsonSchema with error message ({}).", e.getMessage());\r
- }\r
- return null;\r
- }\r
-\r
- /**\r
- * This is a readValue method\r
- *\r
- * @param content\r
- * @param valueType\r
- * @return <T>\r
- */\r
-\r
- public static <T> T readValue(String content, Class<T> valueType) {\r
- try {\r
- ObjectMapper mapper = new ObjectMapper();\r
- return mapper.readValue(content, valueType);\r
- } catch (Exception e) {\r
- logger.warn("failed in readValue for the content ({}) with error message ({}).", content, e.getMessage());\r
- }\r
- return null;\r
- }\r
-\r
- /**\r
- * @param node\r
- * @param valueType\r
- * @param <T>\r
- * @return\r
- */\r
- public static <T> T treeToValue(JsonNode node, Class<T> valueType) {\r
- try {\r
- ObjectMapper mapper = new ObjectMapper();\r
- return mapper.treeToValue(node, valueType);\r
- } catch (Exception e) {\r
- logger.warn("failed in readValue for the content ({}) with error message ({}).", node, e.getMessage());\r
- }\r
- return null;\r
- }\r
-\r
- /**\r
- * @param node\r
- * @param valueType\r
- * @param <T>\r
- * @return List<T>\r
- */\r
- public static <T> List<T> treeToListValue(JsonNode node, Class<T> valueType) {\r
- List<T> resultList = new ArrayList<>();\r
- if (node instanceof ArrayNode) {\r
- for (JsonNode subnode : node) {\r
- if (subnode != null) {\r
- resultList.add(treeToValue(subnode, valueType));\r
- }\r
- }\r
- }\r
- return resultList;\r
- }\r
-\r
- /**\r
- * This is a removeJsonNullNode method\r
- *\r
- * @param node\r
- */\r
- public static void removeJsonNullNode(JsonNode node) {\r
- Iterator<JsonNode> it = node.iterator();\r
- while (it.hasNext()) {\r
- JsonNode child = it.next();\r
- if (child.isNull()) {\r
- it.remove();\r
- } else {\r
- removeJsonNullNode(child);\r
- }\r
- }\r
- }\r
-\r
- public static void printProperty(Properties property) {\r
- if (property != null) {\r
- Map<String, String> sortedMap = new TreeMap(property);\r
- StringBuilder buffer = new StringBuilder();\r
- sortedMap.entrySet().forEach(message -> {\r
- buffer.append("\n" + message.toString());\r
- });\r
- logger.debug("Property : ({})", buffer);\r
- }\r
- }\r
-\r
- public static void printMap(Map<String, String> map) {\r
- if (map != null) {\r
- Map<String, String> sortedMap = new TreeMap(map);\r
- StringBuilder buffer = new StringBuilder();\r
- sortedMap.entrySet().forEach(message -> {\r
- buffer.append("\n" + message.toString());\r
- });\r
- logger.debug("Map: ({})", buffer);\r
- }\r
- }\r
-\r
- @SuppressWarnings("squid:S00112")\r
- public static Map<String, String> convertJson2RootProperties(Map<String, String> context, String jsonContent)\r
- throws Exception {\r
- if (context == null) {\r
- context = new HashMap<>();\r
- }\r
-\r
- ObjectMapper mapper = new ObjectMapper();\r
- JsonNode rootArray = mapper.readTree(jsonContent);\r
- return convertJson2RootProperties(context, rootArray);\r
- }\r
-\r
- public static Map<String, String> convertJson2RootProperties(Map<String, String> context, JsonNode rootArray) {\r
- Map<String, String> sortedMap = null;\r
-\r
- if (context == null) {\r
- context = new HashMap<>();\r
- }\r
- if (rootArray != null) {\r
- Iterator<Map.Entry<String, JsonNode>> fields = rootArray.fields();\r
- while (fields.hasNext()) {\r
- Map.Entry<String, JsonNode> entry = fields.next();\r
- if (entry != null && entry.getValue() != null) {\r
- if (entry.getValue().isTextual()) {\r
- context.put(entry.getKey(), entry.getValue().textValue());\r
- } else {\r
- context.put(entry.getKey(), entry.getValue().toString());\r
- }\r
- }\r
- }\r
- }\r
- sortedMap = new TreeMap<>(context);\r
- return sortedMap;\r
- }\r
-\r
- @SuppressWarnings("squid:S00112")\r
- public static Map<String, String> convertJson2Properties(Map<String, String> context, String jsonContent,\r
- List<String> blockKeys) throws Exception {\r
- Map<String, String> sortedMap = null;\r
-\r
- if (context == null) {\r
- context = new HashMap<>();\r
- }\r
-\r
- ObjectMapper mapper = new ObjectMapper();\r
- JsonNode rootArray = mapper.readTree(jsonContent);\r
-\r
- if (rootArray != null) {\r
- Iterator<Map.Entry<String, JsonNode>> fields = rootArray.fields();\r
- while (fields.hasNext()) {\r
- Map.Entry<String, JsonNode> entry = fields.next();\r
- processJsonNode(context, blockKeys, entry.getKey(), entry.getValue());\r
- }\r
- }\r
- sortedMap = new TreeMap<>(context);\r
- return sortedMap;\r
- }\r
-\r
- public static Map<String, String> convertJson2Properties(Map<String, String> context, JsonNode rootArray,\r
- List<String> blockKeys) throws IOException {\r
- Map<String, String> sortedMap = null;\r
-\r
- if (context == null) {\r
- context = new HashMap<>();\r
- }\r
-\r
- if (blockKeys == null) {\r
- blockKeys = new ArrayList<>();\r
- }\r
-\r
- if (rootArray != null) {\r
- Iterator<Map.Entry<String, JsonNode>> fields = rootArray.fields();\r
- while (fields.hasNext()) {\r
- Map.Entry<String, JsonNode> entry = fields.next();\r
- processJsonNode(context, blockKeys, entry.getKey(), entry.getValue());\r
- }\r
- }\r
- sortedMap = new TreeMap<>(context);\r
- return sortedMap;\r
- }\r
-\r
- private static void processJsonNode(Map<String, String> propertyMap, List<String> blockKeys, String nodeName,\r
- JsonNode node) throws IOException {\r
-\r
- logger.trace("Block Key ({})", nodeName);\r
- if (node == null) {\r
- return;\r
- }\r
-\r
- String keyName = null;\r
- if (blockKeys != null && blockKeys.contains(nodeName)) {\r
- if (node.isArray() || node.isObject()) {\r
- propertyMap.put(nodeName, node.toString());\r
- } else {\r
- propertyMap.put(nodeName, node.asText());\r
- }\r
- } else if (node.isArray()) {\r
- for (int i = 0; i < node.size(); i++) {\r
- keyName = nodeName + "[" + i + "]";\r
- processJsonNode(propertyMap, blockKeys, keyName, node.get(i));\r
- }\r
- } else if (node.isObject()) {\r
- Iterator<Map.Entry<String, JsonNode>> fields = node.fields();\r
- while (fields.hasNext()) {\r
- Map.Entry<String, JsonNode> entry = fields.next();\r
- keyName = nodeName + "." + entry.getKey();\r
- processJsonNode(propertyMap, blockKeys, keyName, entry.getValue());\r
- }\r
- } else {\r
- propertyMap.put(nodeName, node.asText());\r
- }\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.validator;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.model.ConfigModelException;\r
-import org.onap.ccsdk.features.model.ValidTypes;\r
-import org.onap.ccsdk.features.model.data.DataType;\r
-import org.onap.ccsdk.features.model.data.PropertyDefinition;\r
-import org.onap.ccsdk.features.model.data.ServiceTemplate;\r
-\r
-/**\r
- * DataTypeValidator.java Purpose: Provide Configuration Generator DataTypeValidator\r
- *\r
- * @version 1.0\r
- */\r
-public class DataTypeValidator {\r
-\r
- private StringBuilder message;\r
- private Map<String, DataType> stDataTypes;\r
- private ServiceTemplate serviceTemplate;\r
- private PropertyDefinitionValidator propertyDefinitionValidator;\r
-\r
- /**\r
- * This is a DataTypeValidator\r
- *\r
- * @param serviceTemplate\r
- * @throws ConfigModelException\r
- */\r
- public DataTypeValidator(ServiceTemplate serviceTemplate, StringBuilder message) throws ConfigModelException {\r
- this.serviceTemplate = serviceTemplate;\r
- this.message = message;\r
- propertyDefinitionValidator = new PropertyDefinitionValidator(this.message);\r
- stDataTypes = new HashMap<>();\r
- loadInitial();\r
-\r
- }\r
-\r
- private void loadInitial() {\r
- if (serviceTemplate != null && serviceTemplate.getDataTypes() != null) {\r
- message.append("\n DataTypes" + serviceTemplate.getDataTypes());\r
- serviceTemplate.getDataTypes().forEach((dataTypeKey, dataType) -> {\r
- stDataTypes.put(dataTypeKey, dataType);\r
- message.append("\n Data Type (" + dataTypeKey + ") loaded successfully.");\r
- });\r
- }\r
- }\r
-\r
- /**\r
- * This is a validateDataTypes\r
- *\r
- * @return boolean\r
- * @throws ConfigModelException\r
- */\r
- @SuppressWarnings("squid:S00112")\r
- public boolean validateDataTypes() {\r
- if (serviceTemplate != null && serviceTemplate.getDataTypes() != null) {\r
-\r
- serviceTemplate.getDataTypes().forEach((dataTypeKey, dataType) -> {\r
- if (dataType != null) {\r
- try {\r
- String derivedFrom = dataType.getDerivedFrom();\r
- checkValidDerivedType(dataTypeKey, derivedFrom);\r
- checkValidProperties(dataTypeKey, dataType.getProperties());\r
- } catch (ConfigModelException e) {\r
- throw new RuntimeException(e);\r
- }\r
-\r
- }\r
-\r
- });\r
- }\r
- return true;\r
- }\r
-\r
- private boolean checkValidDerivedType(String dataTypeName, String derivedFrom) throws ConfigModelException {\r
-\r
- if (StringUtils.isBlank(derivedFrom) || !ValidTypes.getValidDataTypeDerivedFrom().contains(derivedFrom)) {\r
- throw new ConfigModelException(derivedFrom + " is not a valid derived type for Data type " + dataTypeName);\r
- }\r
- return true;\r
- }\r
-\r
- private boolean checkValidProperties(String dataTypeName, Map<String, PropertyDefinition> properties) {\r
- if (properties != null) {\r
- message.append("\n validation Data Type (" + dataTypeName + ") Property.");\r
- propertyDefinitionValidator.validatePropertyDefinition(stDataTypes, properties);\r
- }\r
- return true;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.validator;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.ConfigModelException;\r
-import org.onap.ccsdk.features.model.ValidTypes;\r
-import org.onap.ccsdk.features.model.data.CapabilityDefinition;\r
-import org.onap.ccsdk.features.model.data.DataType;\r
-import org.onap.ccsdk.features.model.data.InterfaceDefinition;\r
-import org.onap.ccsdk.features.model.data.NodeType;\r
-import org.onap.ccsdk.features.model.data.OperationDefinition;\r
-import org.onap.ccsdk.features.model.data.PropertyDefinition;\r
-import org.onap.ccsdk.features.model.data.RequirementDefinition;\r
-import org.onap.ccsdk.features.model.data.ServiceTemplate;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-/**\r
- * NodeTypeValidator.java Purpose: Provide Configuration Generator NodeTypeValidator\r
- *\r
- * @version 1.0\r
- */\r
-public class NodeTypeValidator {\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(NodeTypeValidator.class);\r
- private StringBuilder message;\r
- private Map<String, DataType> stDataTypes;\r
- private Map<String, NodeType> stNodeTypes;\r
- private ServiceTemplate serviceTemplate;\r
- private PropertyDefinitionValidator propertyDefinitionValidator;\r
-\r
- /**\r
- * This is a NodeTypeValidator\r
- *\r
- * @param serviceTemplate\r
- * @throws ConfigModelException\r
- */\r
- public NodeTypeValidator(ServiceTemplate serviceTemplate, StringBuilder message) throws ConfigModelException {\r
- this.serviceTemplate = serviceTemplate;\r
- this.message = message;\r
- propertyDefinitionValidator = new PropertyDefinitionValidator(this.message);\r
- stDataTypes = new HashMap<>();\r
- stNodeTypes = new HashMap<>();\r
- loadInitial();\r
-\r
- }\r
-\r
- private void loadInitial() {\r
- if (serviceTemplate != null) {\r
-\r
- if (serviceTemplate.getDataTypes() != null) {\r
- serviceTemplate.getDataTypes().forEach((dataTypeKey, dataType) -> {\r
- stDataTypes.put(dataTypeKey, dataType);\r
- logger.trace("Data Type ({}) loaded successfully.", dataTypeKey);\r
- });\r
- }\r
-\r
- if (serviceTemplate.getNodeTypes() != null) {\r
- serviceTemplate.getNodeTypes().forEach((nodeTypeKey, nodeType) -> {\r
- stNodeTypes.put(nodeTypeKey, nodeType);\r
- logger.trace("NodeType Type ({}) loaded successfully.", nodeTypeKey);\r
- });\r
- }\r
-\r
- }\r
-\r
- }\r
-\r
- /**\r
- * This is a validateNodeTypes to validate the Node Type\r
- *\r
- * @return boolean\r
- * @throws ConfigModelException\r
- */\r
- @SuppressWarnings({"squid:S00112", "squid:S3776"})\r
- public boolean validateNodeTypes() {\r
- if (serviceTemplate != null && serviceTemplate.getNodeTypes() != null) {\r
- serviceTemplate.getNodeTypes().forEach((nodeTypeKey, nodeType) -> {\r
- if (nodeType != null) {\r
- message.append("\n ***** Validation Node Type (" + nodeTypeKey + "), derived from ("\r
- + nodeType.getDerivedFrom() + ")");\r
- try {\r
- validateNodeType(ConfigModelConstant.MODEL_DEFINITION_TYPE_NODE_TYPE,\r
- nodeType.getDerivedFrom());\r
-\r
- if (nodeType.getProperties() != null) {\r
- checkValidProperties(nodeType.getProperties());\r
- }\r
-\r
- if (nodeType.getCapabilities() != null) {\r
- validateNodeTypeCapabilities(nodeType.getCapabilities());\r
- }\r
-\r
- if (nodeType.getInterfaces() != null) {\r
- validateNodeTypeInterface(nodeType.getInterfaces());\r
- }\r
-\r
- if (nodeType.getRequirements() != null) {\r
- validateNodeTypeRequirement(nodeType.getRequirements());\r
- }\r
-\r
- } catch (ConfigModelException e) {\r
- logger.error(e.getMessage());\r
- throw new RuntimeException(e.getMessage());\r
- }\r
-\r
- }\r
- });\r
- }\r
- return true;\r
- }\r
-\r
- private boolean validateNodeType(String definitionType, String derivedFrom) throws ConfigModelException {\r
- boolean valid = true;\r
- if (!ConfigModelConstant.MODEL_DEFINITION_TYPE_DATA_TYPE.equalsIgnoreCase(definitionType)\r
- && !ValidTypes.getValidNodeTypes().contains(derivedFrom)) {\r
- throw new ConfigModelException("Not Valid Model Type (" + derivedFrom + ")");\r
- }\r
- return valid;\r
- }\r
-\r
- private boolean checkValidProperties(Map<String, PropertyDefinition> properties) {\r
- if (properties != null) {\r
- propertyDefinitionValidator.validatePropertyDefinition(stDataTypes, properties);\r
- }\r
- return true;\r
- }\r
-\r
- @SuppressWarnings("squid:S00112")\r
- private boolean validateNodeTypeCapabilities(Map<String, CapabilityDefinition> capabilities) {\r
- if (capabilities != null) {\r
- capabilities.forEach((capabilityKey, capability) -> {\r
- if (capability != null) {\r
- Map<String, PropertyDefinition> properties = capability.getProperties();\r
- message.append("\n Validation Capability (" + capabilityKey + ") properties :");\r
- propertyDefinitionValidator.validatePropertyDefinition(stDataTypes, properties);\r
- }\r
- });\r
- }\r
- return true;\r
- }\r
-\r
- @SuppressWarnings("squid:S00112")\r
- private boolean validateNodeTypeInterface(Map<String, InterfaceDefinition> interfaces) {\r
- if (interfaces != null) {\r
- interfaces.forEach((interfaceKey, interfaceDefinition) -> {\r
- if (interfaceDefinition != null && interfaceDefinition.getOperations() != null) {\r
- validateNodeTypeInterfaceOperation(interfaceDefinition.getOperations());\r
- }\r
- });\r
- }\r
- return true;\r
- }\r
-\r
- @SuppressWarnings("squid:S00112")\r
- private boolean validateNodeTypeInterfaceOperation(Map<String, OperationDefinition> operations) {\r
- if (operations != null) {\r
- operations.forEach((operationKey, operation) -> {\r
- if (operation != null) {\r
- Map<String, PropertyDefinition> inputs = operation.getInputs();\r
- message.append("\n Validation Operation (" + operationKey + ") Inputs :");\r
- propertyDefinitionValidator.validatePropertyDefinition(stDataTypes, inputs);\r
- message.append("\n Validation Operation (" + operationKey + ") output :");\r
- Map<String, PropertyDefinition> outputs = operation.getOutputs();\r
- propertyDefinitionValidator.validatePropertyDefinition(stDataTypes, outputs);\r
- }\r
- });\r
- }\r
- return true;\r
- }\r
-\r
- @SuppressWarnings("squid:S00112")\r
- private boolean validateNodeTypeRequirement(Map<String, RequirementDefinition> requirements) {\r
- if (requirements != null) {\r
- requirements.forEach((requirementKey, requirement) -> {\r
- if (requirement != null) {\r
- String nodeTypeName = requirement.getNode();\r
- String capabilityName = requirement.getCapability();\r
- try {\r
- checkCapabilityPresentInNodeType(nodeTypeName, capabilityName);\r
- } catch (ConfigModelException e) {\r
- throw new RuntimeException(e);\r
- }\r
- }\r
- });\r
- }\r
- return true;\r
- }\r
-\r
- private boolean checkCapabilityPresentInNodeType(String nodeTypeName, String capabilityName)\r
- throws ConfigModelException {\r
- if (StringUtils.isNotBlank(nodeTypeName) && StringUtils.isNotBlank(capabilityName)) {\r
-\r
- if (!stNodeTypes.containsKey(nodeTypeName)) {\r
- throw new ConfigModelException(nodeTypeName + " Node Type not Defined.");\r
- } else {\r
- message.append("\n Node Type (" + nodeTypeName + ") Defined.");\r
- }\r
-\r
- NodeType relationalNodeType = stNodeTypes.get(nodeTypeName);\r
-\r
- if (relationalNodeType.getCapabilities() == null) {\r
- throw new ConfigModelException(\r
- "Node Type (" + nodeTypeName + "), doesn't have Capability Definitions.");\r
- }\r
-\r
- if (!relationalNodeType.getCapabilities().containsKey(capabilityName)) {\r
- throw new ConfigModelException("Node Type (" + nodeTypeName + ") doesn't have (" + capabilityName\r
- + ") Capability Definitions.");\r
- } else {\r
- message.append(\r
- "\n Node Type (" + nodeTypeName + ") has (" + capabilityName + ") Capability Definitions.");\r
- }\r
-\r
- }\r
- return true;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.validator;\r
-\r
-import java.util.Map;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.model.ConfigModelException;\r
-import org.onap.ccsdk.features.model.ValidTypes;\r
-import org.onap.ccsdk.features.model.data.DataType;\r
-import org.onap.ccsdk.features.model.data.PropertyDefinition;\r
-\r
-/**\r
- * PropertyDefinitionValidator.java Purpose: Provide Configuration Generator\r
- * PropertyDefinitionValidator\r
- *\r
- * @version 1.0\r
- */\r
-public class PropertyDefinitionValidator {\r
-\r
- StringBuilder message = new StringBuilder();\r
-\r
- public PropertyDefinitionValidator(StringBuilder message) {\r
- this.message = message;\r
-\r
- }\r
-\r
- /**\r
- * This is a validatePropertyDefinition stored in database\r
- *\r
- * @param stDataTypes\r
- * @param properties\r
- * @return boolean\r
- * @throws ConfigModelException\r
- */\r
- @SuppressWarnings({"squid:S00112", "squid:S3776", "squid:S1192"})\r
- public boolean validatePropertyDefinition(Map<String, DataType> stDataTypes,\r
- Map<String, PropertyDefinition> properties) {\r
-\r
- if (stDataTypes != null && properties != null) {\r
- properties.forEach((propertyKey, prop) -> {\r
- if (propertyKey != null && prop != null) {\r
- try {\r
- String propertType = prop.getType();\r
- message.append("\n Validating (" + propertyKey + ") " + prop);\r
-\r
- if (!ValidTypes.getValidPropertType().contains(propertType)\r
- && !stDataTypes.containsKey(propertType)) {\r
- throw new ConfigModelException("Data Type (" + propertyKey + ") -> type(" + propertType\r
- + ") is not a valid type.");\r
- } else if (ValidTypes.getListPropertType().contains(propertType)) {\r
- if (prop.getEntrySchema() == null || StringUtils.isBlank(prop.getEntrySchema().getType())) {\r
- throw new ConfigModelException("Data Type (" + propertyKey + ") -> type (" + propertType\r
- + ") Entity Schema is not defined.");\r
- }\r
-\r
- String entitySchemaType = prop.getEntrySchema().getType();\r
-\r
- if (!ValidTypes.getValidPropertType().contains(entitySchemaType)\r
- && !stDataTypes.containsKey(entitySchemaType)) {\r
- message.append("\n Present Data Type " + stDataTypes);\r
- throw new ConfigModelException("Data Type (" + propertyKey + ") -> type(" + propertType\r
- + ") -> entitySchema(" + entitySchemaType + ") is not defined.");\r
- }\r
- }\r
- } catch (ConfigModelException e) {\r
- throw new RuntimeException(e);\r
- }\r
- }\r
- });\r
- }\r
- return true;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.validator;\r
-\r
-import java.util.HashMap;\r
-import java.util.HashSet;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Set;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.ConfigModelException;\r
-import org.onap.ccsdk.features.model.data.CapabilityAssignment;\r
-import org.onap.ccsdk.features.model.data.NodeTemplate;\r
-import org.onap.ccsdk.features.model.data.ResourceAssignment;\r
-import org.onap.ccsdk.features.model.utils.TopologicalSortingUtils;\r
-import org.onap.ccsdk.features.model.utils.TransformationUtils;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class ResourceAssignmentValidator {\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceAssignmentValidator.class);\r
- private List<ResourceAssignment> assignments;\r
- private Map<String, ResourceAssignment> resourceAssignmentMap = new HashMap<>();\r
- private StringBuilder validationMessage = new StringBuilder();\r
-\r
- public ResourceAssignmentValidator(NodeTemplate nodeTemplate) throws ConfigModelException {\r
-\r
- if (nodeTemplate != null && nodeTemplate.getCapabilities() != null) {\r
- CapabilityAssignment capabilityAssignment =\r
- nodeTemplate.getCapabilities().get(ConfigModelConstant.CAPABILITY_PROPERTY_MAPPING);\r
- if (capabilityAssignment != null && capabilityAssignment.getProperties() != null) {\r
- Object mappingObject =\r
- capabilityAssignment.getProperties().get(ConfigModelConstant.CAPABILITY_PROPERTY_MAPPING);\r
- if (mappingObject != null) {\r
- String mappingContent = TransformationUtils.getJson(mappingObject);\r
- if (StringUtils.isNotBlank(mappingContent)) {\r
- this.assignments =\r
- TransformationUtils.getListfromJson(mappingContent, ResourceAssignment.class);\r
- } else {\r
- validationMessage\r
- .append(String.format("Failed to transform Mapping Content (%s) ", mappingContent));\r
- throw new ConfigModelException(\r
- String.format("Failed to transform Mapping Content (%s) ", mappingContent));\r
- }\r
- }\r
- }\r
- }\r
- }\r
-\r
- public ResourceAssignmentValidator(List<ResourceAssignment> assignments) {\r
- this.assignments = assignments;\r
- }\r
-\r
- /**\r
- * This is a validateResourceAssignment to validate the Topology Template\r
- *\r
- * @return boolean\r
- * @throws ConfigModelException\r
- */\r
- public boolean validateResourceAssignment() throws ConfigModelException {\r
- if (assignments != null && !assignments.isEmpty()) {\r
- validateDuplicateDictionaryKeys();\r
- validateCyclicDependencty();\r
- if (validationMessage.length() > 0) {\r
- logger.error("Resourece Assignment Validation : {}", validationMessage);\r
- throw new ConfigModelException("Resourece Assignment Validation :" + validationMessage.toString());\r
- }\r
- }\r
- return true;\r
- }\r
-\r
- @SuppressWarnings("squid:S3776")\r
- private void validateDuplicateDictionaryKeys() {\r
- this.assignments.forEach(resourceMapping -> {\r
- if (resourceMapping != null) {\r
- if (!resourceAssignmentMap.containsKey(resourceMapping.getName())) {\r
- resourceAssignmentMap.put(resourceMapping.getName(), resourceMapping);\r
- } else {\r
- validationMessage.append(String.format("Duplicate Assignment Template Key (%s) is Present",\r
- resourceMapping.getName()));\r
- }\r
- }\r
- });\r
-\r
- if (!assignments.isEmpty()) {\r
- Set<String> uniqueSet = new HashSet<>();\r
- for (ResourceAssignment resourceAssignment : assignments) {\r
- if (resourceAssignment != null) {\r
- boolean added = uniqueSet.add(resourceAssignment.getDictionaryName());\r
- if (!added) {\r
- validationMessage.append(\r
- String.format("Duplicate Assignment Dictionary Key (%s) present with Template Key (%s)",\r
- resourceAssignment.getDictionaryName(), resourceAssignment.getName()));\r
- }\r
- }\r
- }\r
- }\r
- }\r
-\r
- private void validateCyclicDependencty() {\r
- TopologicalSortingUtils<ResourceAssignment> topologySorting = new TopologicalSortingUtils<>();\r
- this.resourceAssignmentMap.forEach((mappingKey, mapping) -> {\r
- if (mapping != null) {\r
- if (mapping.getDependencies() != null && !mapping.getDependencies().isEmpty()) {\r
- for (String dependency : mapping.getDependencies()) {\r
- topologySorting.add(resourceAssignmentMap.get(dependency), mapping);\r
- }\r
- } else {\r
- topologySorting.add(null, mapping);\r
- }\r
- }\r
- });\r
-\r
- if (!topologySorting.isDag()) {\r
- String graph = getTopologicalGraph(topologySorting);\r
- validationMessage.append("Cyclic Dependency :" + graph);\r
- }\r
- }\r
-\r
- public String getTopologicalGraph(TopologicalSortingUtils<ResourceAssignment> topologySorting) {\r
- StringBuilder s = new StringBuilder();\r
- if (topologySorting != null) {\r
- Map<ResourceAssignment, List<ResourceAssignment>> neighbors = topologySorting.getNeighbors();\r
-\r
- neighbors.forEach((v, vs) -> {\r
- if (v == null) {\r
- s.append("\n * -> [");\r
- List<ResourceAssignment> links = vs;\r
- for (ResourceAssignment resourceAssignment : links) {\r
- s.append("(" + resourceAssignment.getDictionaryName() + ":" + resourceAssignment.getName()\r
- + "),");\r
- }\r
- s.append("]");\r
- } else {\r
- s.append("\n (" + v.getDictionaryName() + ":" + v.getName() + ") -> [");\r
- List<ResourceAssignment> links = vs;\r
- for (ResourceAssignment resourceAssignment : links) {\r
- s.append("(" + resourceAssignment.getDictionaryName() + ":" + resourceAssignment.getName()\r
- + "),");\r
- }\r
- s.append("]");\r
- }\r
- });\r
- }\r
- return s.toString();\r
- }\r
-}\r
+++ /dev/null
-/*\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.features.model.validator;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.ConfigModelException;\r
-import org.onap.ccsdk.features.model.data.ServiceTemplate;\r
-import org.onap.ccsdk.features.model.utils.TransformationUtils;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-/**\r
- * ServiceTemplateValidator.java Purpose: Provide Configuration Generator ServiceTemplateValidator\r
- *\r
- * @version 1.0\r
- */\r
-\r
-public class ServiceTemplateValidator {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ServiceTemplateValidator.class);\r
-\r
- private Map<String, String> metaData = new HashMap<>();\r
-\r
- StringBuilder message = new StringBuilder();\r
-\r
- /**\r
- * This is a validateServiceTemplate\r
- *\r
- * @param serviceTemplateContent\r
- * @return boolean\r
- * @throws ConfigModelException\r
- */\r
- @SuppressWarnings("squid:S00112")\r
- public boolean validateServiceTemplate(String serviceTemplateContent) throws ConfigModelException {\r
- if (StringUtils.isNotBlank(serviceTemplateContent)) {\r
- ServiceTemplate serviceTemplate =\r
- TransformationUtils.readValue(serviceTemplateContent, ServiceTemplate.class);\r
- return validateServiceTemplate(serviceTemplate);\r
- } else {\r
- throw new ConfigModelException(\r
- "Service Template Content is (" + serviceTemplateContent + ") not Defined.");\r
- }\r
- }\r
-\r
- /**\r
- * This is a validateServiceTemplate\r
- *\r
- * @param serviceTemplate\r
- * @return boolean\r
- * @throws ConfigModelException\r
- */\r
- @SuppressWarnings("squid:S00112")\r
- public boolean validateServiceTemplate(ServiceTemplate serviceTemplate) throws ConfigModelException {\r
- if (serviceTemplate != null) {\r
- try {\r
- validateMetaData(serviceTemplate);\r
- (new DataTypeValidator(serviceTemplate, message)).validateDataTypes();\r
- (new NodeTypeValidator(serviceTemplate, message)).validateNodeTypes();\r
- (new TopologyTemplateValidator(serviceTemplate, message)).validateTopologyTemplate();\r
- logger.debug("Validation Message : {}", message);\r
- } catch (Exception e) {\r
- throw new ConfigModelException(\r
- "Validation Failed " + e.toString() + ",Message Trace : \n" + message.toString());\r
- }\r
-\r
- } else {\r
- throw new ConfigModelException("Service Template is not defined.");\r
- }\r
- return true;\r
- }\r
-\r
- /**\r
- * This is a getMetaData to get the key information during the\r
- *\r
- * @return Map<String , String>\r
- */\r
- public Map<String, String> getMetaData() {\r
- return metaData;\r
- }\r
-\r
- private void validateMetaData(ServiceTemplate serviceTemplate) throws ConfigModelException {\r
- if (serviceTemplate.getMetadata() != null) {\r
- this.metaData.putAll(serviceTemplate.getMetadata());\r
-\r
- String author = serviceTemplate.getMetadata().get(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_AUTHOR);\r
- String serviceTemplateName =\r
- serviceTemplate.getMetadata().get(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_NAME);\r
- String serviceTemplateVersion =\r
- serviceTemplate.getMetadata().get(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_VERSION);\r
-\r
- if (StringUtils.isBlank(author)) {\r
- throw new ConfigModelException("Service Template Metadata (author) Information is missing.");\r
- }\r
-\r
- if (StringUtils.isBlank(serviceTemplateName)) {\r
- throw new ConfigModelException(\r
- "Service Template Metadata (service-template-name) Information is missing.");\r
- }\r
-\r
- if (StringUtils.isBlank(serviceTemplateVersion)) {\r
- throw new ConfigModelException(\r
- "Service Template Metadata (service-template-version) Information is missing.");\r
- }\r
-\r
- } else {\r
- throw new ConfigModelException("Service Template Metadata Information is missing.");\r
- }\r
-\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.validator;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.ConfigModelException;\r
-import org.onap.ccsdk.features.model.data.DataType;\r
-import org.onap.ccsdk.features.model.data.NodeTemplate;\r
-import org.onap.ccsdk.features.model.data.NodeType;\r
-import org.onap.ccsdk.features.model.data.PropertyDefinition;\r
-import org.onap.ccsdk.features.model.data.RequirementAssignment;\r
-import org.onap.ccsdk.features.model.data.ServiceTemplate;\r
-import org.onap.ccsdk.features.model.data.TopologyTemplate;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-/**\r
- * TopologyTemplateValidator.java Purpose: Provide Configuration Generator TopologyTemplateValidator\r
- *\r
- * @version 1.0\r
- */\r
-public class TopologyTemplateValidator {\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(TopologyTemplateValidator.class);\r
- private StringBuilder message;\r
- private Map<String, DataType> stDataTypes;\r
- private Map<String, NodeType> stNodeTypes;\r
- private Map<String, NodeTemplate> stNodeTemplates;\r
- private ServiceTemplate serviceTemplate;\r
- private PropertyDefinitionValidator propertyDefinitionValidator;\r
-\r
- /**\r
- * This is a TopologyTemplateValidator\r
- *\r
- * @param serviceTemplate\r
- * @throws ConfigModelException\r
- */\r
- public TopologyTemplateValidator(ServiceTemplate serviceTemplate, StringBuilder message) {\r
- this.serviceTemplate = serviceTemplate;\r
- this.message = message;\r
- propertyDefinitionValidator = new PropertyDefinitionValidator(this.message);\r
- stDataTypes = new HashMap<>();\r
- stNodeTypes = new HashMap<>();\r
- stNodeTemplates = new HashMap<>();\r
- loadInitial();\r
- }\r
-\r
- private void loadInitial() {\r
- if (serviceTemplate != null) {\r
-\r
- if (serviceTemplate.getDataTypes() != null) {\r
- serviceTemplate.getDataTypes().forEach((dataTypeKey, dataType) -> {\r
- stDataTypes.put(dataTypeKey, dataType);\r
- logger.trace("Data Type ({}) loaded successfully.", dataTypeKey);\r
- });\r
- }\r
-\r
- if (serviceTemplate.getNodeTypes() != null) {\r
- serviceTemplate.getNodeTypes().forEach((nodeTypeKey, nodeType) -> {\r
- stNodeTypes.put(nodeTypeKey, nodeType);\r
- logger.trace("Node Type ({}) loaded successfully.", nodeTypeKey);\r
- });\r
- }\r
-\r
- if (serviceTemplate.getTopologyTemplate() != null) {\r
- TopologyTemplate topologyTemplate = serviceTemplate.getTopologyTemplate();\r
-\r
- if (topologyTemplate.getNodeTemplates() != null) {\r
- topologyTemplate.getNodeTemplates().forEach((nodeTemplateKey, nodeTemplate) -> {\r
- stNodeTemplates.put(nodeTemplateKey, nodeTemplate);\r
- logger.trace("Node Template ({}) Type loaded successfully.", nodeTemplateKey);\r
- });\r
- }\r
- }\r
- }\r
-\r
- }\r
-\r
- /**\r
- * This is a validateTopologyTemplate to validate the Topology Template\r
- *\r
- * @return boolean\r
- * @throws ConfigModelException\r
- */\r
- public boolean validateTopologyTemplate() {\r
- if (serviceTemplate != null && serviceTemplate.getTopologyTemplate() != null) {\r
-\r
- checkValidInputProperties(serviceTemplate.getTopologyTemplate().getInputs());\r
-\r
- validateNodeTemplates(serviceTemplate.getTopologyTemplate().getNodeTemplates());\r
- }\r
- return true;\r
- }\r
-\r
- private boolean checkValidInputProperties(Map<String, PropertyDefinition> properties) {\r
- if (properties != null) {\r
- message.append("\n Validation topology template input properties :");\r
- propertyDefinitionValidator.validatePropertyDefinition(stDataTypes, properties);\r
- }\r
- return true;\r
- }\r
-\r
- @SuppressWarnings({"squid:S00112", "squid:S3776"})\r
- private boolean validateNodeTemplates(Map<String, NodeTemplate> nodeTemplates) {\r
- if (nodeTemplates != null) {\r
- nodeTemplates.forEach((nodeTemplateKey, nodeTemplate) -> {\r
- if (nodeTemplate != null) {\r
- message.append("\n ##### Validation Node Template (" + nodeTemplateKey + "), of type ("\r
- + nodeTemplate.getType() + ")");\r
-\r
- String nodeTypeName = nodeTemplate.getType();\r
- if (!stNodeTypes.containsKey(nodeTypeName)) {\r
- throw new RuntimeException("Node Type (" + nodeTypeName + ")not Defined.");\r
- }\r
-\r
- if (nodeTemplate.getRequirements() != null) {\r
- validateNodeTemplateRequirement(nodeTemplate.getRequirements());\r
- }\r
-\r
- // Validate Resource Assignments\r
- NodeType nodeType = stNodeTypes.get(nodeTypeName);\r
- if (nodeType != null\r
- && ConfigModelConstant.MODEL_TYPE_NODE_ARTIFACT.equals(nodeType.getDerivedFrom())) {\r
- logger.info("Validating Resource Assignment NodeTemplate ({}).", nodeTemplateKey);\r
- ResourceAssignmentValidator resourceAssignmentValidator;\r
- try {\r
- resourceAssignmentValidator = new ResourceAssignmentValidator(nodeTemplate);\r
- resourceAssignmentValidator.validateResourceAssignment();\r
- } catch (ConfigModelException e) {\r
- throw new RuntimeException(e);\r
- }\r
-\r
- }\r
- }\r
- });\r
- }\r
- return true;\r
- }\r
-\r
- @SuppressWarnings("squid:S00112")\r
- private boolean validateNodeTemplateRequirement(Map<String, RequirementAssignment> requirements) {\r
- if (requirements != null) {\r
- requirements.forEach((requirementKey, requirement) -> {\r
- if (requirement != null) {\r
- String requirementnodeTypeName = requirement.getNode();\r
- String capabilityName = requirement.getCapability();\r
- try {\r
- checkCapabilityPresentInNodeTemplate(requirementnodeTypeName, capabilityName);\r
- } catch (ConfigModelException e) {\r
- throw new RuntimeException(e);\r
- }\r
- }\r
- });\r
- }\r
- return true;\r
- }\r
-\r
- private boolean checkCapabilityPresentInNodeTemplate(String nodeTemplateName, String capabilityName)\r
- throws ConfigModelException {\r
- if (StringUtils.isNotBlank(nodeTemplateName) && StringUtils.isNotBlank(capabilityName)) {\r
-\r
- if (!stNodeTemplates.containsKey(nodeTemplateName)) {\r
- throw new ConfigModelException(nodeTemplateName + " Node Template not Defined.");\r
- } else {\r
- message.append("\n Node Template (" + nodeTemplateName + ") Defined.");\r
- }\r
-\r
- NodeTemplate relationalNodeType = stNodeTemplates.get(nodeTemplateName);\r
-\r
- if (relationalNodeType.getCapabilities() == null) {\r
- throw new ConfigModelException(\r
- "Node Template (" + nodeTemplateName + "), doesn't have Capability Definitions.");\r
- }\r
-\r
- if (!relationalNodeType.getCapabilities().containsKey(capabilityName)) {\r
- throw new ConfigModelException("Node Type (" + nodeTemplateName + ") doesn't have (" + capabilityName\r
- + ") Capability Definitions.");\r
- } else {\r
- message.append("\n Node Template (" + nodeTemplateName + ") has (" + capabilityName\r
- + ") Capability Definitions.");\r
- }\r
-\r
- }\r
- return true;\r
- }\r
-}\r
+++ /dev/null
-<?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
- 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
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"\r
- xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"\r
- odl:use-default-for-reference-types="true">\r
-\r
- <!-- Dependency -->\r
-\r
- <reference id="configResourceService"\r
- interface="org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService" />\r
-\r
- <reference id="configRestAdaptorService"\r
- interface="org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService" />\r
-\r
- <!-- Expose the Common Component Bean -->\r
- <bean id="configModelNode"\r
- class="org.onap.ccsdk.features.model.service.ConfigModelNode">\r
- </bean>\r
-\r
- <service ref="configModelNode"\r
- interface="org.onap.ccsdk.features.model.service.ConfigModelNode" />\r
-\r
- <bean id="configModelService"\r
- class="org.onap.ccsdk.features.model.service.ConfigModelServiceImpl">\r
- <argument ref="configRestAdaptorService" />\r
- </bean>\r
-\r
- <service ref="configModelService"\r
- interface="org.onap.ccsdk.features.model.service.ConfigModelService" />\r
-\r
-\r
- <!-- ComponentNode -->\r
-\r
- <bean id="componentNodeService"\r
- class="org.onap.ccsdk.features.model.service.ComponentNodeServiceImpl">\r
- <argument ref="blueprintBundleContext" />\r
- <argument ref="configResourceService" />\r
- <argument ref="configRestAdaptorService" />\r
- </bean>\r
-\r
- <service ref="componentNodeService"\r
- interface="org.onap.ccsdk.features.model.service.ComponentNodeService" />\r
-\r
- <bean id="componentNodeDelegate"\r
- class="org.onap.ccsdk.features.model.service.ComponentNodeDelegate">\r
- <argument ref="componentNodeService" />\r
- </bean>\r
-\r
- <service ref="componentNodeDelegate"\r
- interface="org.onap.ccsdk.features.model.service.ComponentNodeDelegate" />\r
-\r
-</blueprint>\r
+++ /dev/null
-<?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
- 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
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"\r
- xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"\r
- odl:use-default-for-reference-types="true">\r
-\r
- <!-- Dependency -->\r
-\r
- <reference id="configResourceService"\r
- interface="org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService" />\r
-\r
- <reference id="configRestAdaptorService"\r
- interface="org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService" />\r
-\r
- <!-- Expose the Common Component Bean -->\r
- <bean id="configModelNode"\r
- class="org.onap.ccsdk.features.model.service.ConfigModelNode">\r
- </bean>\r
-\r
- <service ref="configModelNode"\r
- interface="org.onap.ccsdk.features.model.service.ConfigModelNode" />\r
-\r
- <bean id="configModelService"\r
- class="org.onap.ccsdk.features.model.service.ConfigModelServiceImpl">\r
- <argument ref="configRestAdaptorService" />\r
- </bean>\r
-\r
- <service ref="configModelService"\r
- interface="org.onap.ccsdk.features.model.service.ConfigModelService" />\r
-\r
-\r
- <!-- ComponentNode -->\r
-\r
- <bean id="componentNodeService"\r
- class="org.onap.ccsdk.features.model.service.ComponentNodeServiceImpl">\r
- <argument ref="blueprintBundleContext" />\r
- <argument ref="configResourceService" />\r
- <argument ref="configRestAdaptorService" />\r
- </bean>\r
-\r
- <service ref="componentNodeService"\r
- interface="org.onap.ccsdk.features.model.service.ComponentNodeService" />\r
-\r
- <bean id="componentNodeDelegate"\r
- class="org.onap.ccsdk.features.model.service.ComponentNodeDelegate">\r
- <argument ref="componentNodeService" />\r
- </bean>\r
-\r
- <service ref="componentNodeDelegate"\r
- interface="org.onap.ccsdk.features.model.service.ComponentNodeDelegate" />\r
-\r
-</blueprint>\r
+++ /dev/null
-/*\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.features.model;\r
-\r
-import java.util.Arrays;\r
-import java.util.HashMap;\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.onap.ccsdk.features.model.data.PropertyDefinition;\r
-import org.onap.ccsdk.features.model.data.ResourceAssignment;\r
-import org.onap.ccsdk.features.model.data.dict.ResourceDefinition;\r
-import org.onap.ccsdk.features.model.data.dict.SourcesDefinition;\r
-import org.onap.ccsdk.features.model.data.dict.SourcesProperties;\r
-import org.onap.ccsdk.features.model.utils.ResourceDictionaryUtils;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class ResourceDictionaryUtilsTest {\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceDictionaryUtilsTest.class);\r
-\r
- @Test\r
- public void validateSingleInputSource() {\r
- try {\r
- logger.info(" **************** Validating validateSingleInputSource *****************");\r
- ResourceAssignment resourceAssignment = new ResourceAssignment();\r
- resourceAssignment.setName("test-input-key");\r
-\r
- PropertyDefinition propertyDefinition = new PropertyDefinition();\r
- propertyDefinition.setType(ValidTypes.DATA_TYPE_STRING);\r
-\r
- SourcesProperties sourcesProp = new SourcesProperties();\r
- sourcesProp.setDependencies(Arrays.asList(new String[] {"vnf-id", "vnf-name"}));\r
-\r
- SourcesDefinition sourceDef = new SourcesDefinition();\r
- sourceDef.setProperties(sourcesProp);\r
-\r
- HashMap<String, SourcesDefinition> sources = new HashMap<>();\r
- sources.put("input", sourceDef);\r
-\r
- ResourceDefinition resourceDefinition = new ResourceDefinition();\r
- resourceDefinition.setProperty(propertyDefinition);\r
- resourceDefinition.setSources(sources);\r
-\r
- ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition);\r
-\r
- Assert.assertNotNull("Resource assignment input sourceName is missing ",\r
- resourceAssignment.getDictionarySource());\r
- Assert.assertNotNull("Resource assignment input sourceName property is missing ",\r
- resourceAssignment.getProperty());\r
- Assert.assertNotNull("Resource assignment input sourceName property type is missing ",\r
- resourceAssignment.getProperty().getType());\r
-\r
- } catch (Exception e) {\r
- e.printStackTrace();\r
- }\r
- }\r
-\r
- @Test\r
- public void validateSingleDbSource() {\r
- try {\r
- logger.info(" **************** Validating validateSingleDbSource *****************");\r
- ResourceAssignment resourceAssignment = new ResourceAssignment();\r
- resourceAssignment.setName("test-db-key");\r
-\r
- PropertyDefinition propertyDefinition = new PropertyDefinition();\r
- propertyDefinition.setType(ValidTypes.DATA_TYPE_STRING);\r
-\r
- SourcesProperties sourcesProp = new SourcesProperties();\r
- sourcesProp.setDependencies(Arrays.asList(new String[] {"vnf-id", "vnf-name"}));\r
-\r
- SourcesDefinition sourceDef = new SourcesDefinition();\r
- sourceDef.setProperties(sourcesProp);\r
-\r
- HashMap<String, SourcesDefinition> sources = new HashMap<>();\r
- sources.put("db", sourceDef);\r
-\r
- ResourceDefinition resourceDefinition = new ResourceDefinition();\r
- resourceDefinition.setProperty(propertyDefinition);\r
- resourceDefinition.setSources(sources);\r
-\r
- ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition);\r
- Assert.assertNotNull("Resource assignment db sourceName sourceName is missing ",\r
- resourceAssignment.getDictionarySource());\r
- Assert.assertNotNull("Resource assignment db sourceName sourceName property is missing ",\r
- resourceAssignment.getProperty());\r
- Assert.assertNotNull("Resource assignment db sourceName sourceName property type is missing ",\r
- resourceAssignment.getProperty().getType());\r
-\r
- Assert.assertNotNull("Resource assignment db dependecy is missing ", resourceAssignment.getDependencies());\r
- Assert.assertEquals("Resource assignment db dependecy count mismatch ", 2,\r
- resourceAssignment.getDependencies().size());\r
-\r
- } catch (Exception e) {\r
- e.printStackTrace();\r
- }\r
- }\r
-\r
- @Test\r
- public void validateMultiSource() {\r
- try {\r
- logger.info(" **************** Validating validateMultiSource *****************");\r
- ResourceAssignment resourceAssignment = new ResourceAssignment();\r
- resourceAssignment.setName("test-multi-key");\r
-\r
- PropertyDefinition propertyDefinition = new PropertyDefinition();\r
- propertyDefinition.setType(ValidTypes.DATA_TYPE_STRING);\r
-\r
- SourcesProperties sourcesProp = new SourcesProperties();\r
- sourcesProp.setDependencies(Arrays.asList(new String[] {"vnf-id", "vnf-name"}));\r
-\r
- SourcesDefinition sourceDef = new SourcesDefinition();\r
- sourceDef.setProperties(sourcesProp);\r
-\r
- HashMap<String, SourcesDefinition> sources = new HashMap<>();\r
- sources.put("input", sourceDef);\r
- sources.put("mdsal", sourceDef);\r
-\r
- ResourceDefinition resourceDefinition = new ResourceDefinition();\r
- resourceDefinition.setProperty(propertyDefinition);\r
- resourceDefinition.setSources(sources);\r
-\r
- ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition);\r
- Assert.assertNotNull("Resource assignment db sourceName sourceName property is missing ",\r
- resourceAssignment.getProperty());\r
- Assert.assertNotNull("Resource assignment db sourceName sourceName property type is missing ",\r
- resourceAssignment.getProperty().getType());\r
- Assert.assertNull("Resource assignment multi sourceName sourceName definition is present ",\r
- resourceAssignment.getDictionarySource());\r
- Assert.assertNull("Resource assignment multi sourceName dependecy is present ",\r
- resourceAssignment.getDependencies());\r
-\r
- } catch (Exception e) {\r
- e.printStackTrace();\r
- }\r
- }\r
-\r
- @Test\r
- public void testSourceDefault() {\r
- logger.info(" **************** Validating testSourceDefault *****************");\r
- ResourceAssignment resourceAssignment = new ResourceAssignment();\r
- resourceAssignment.setName("test-input-key");\r
-\r
- PropertyDefinition propertyDefinition = new PropertyDefinition();\r
- propertyDefinition.setType(ValidTypes.DATA_TYPE_STRING);\r
-\r
- SourcesProperties sourcesProp = new SourcesProperties();\r
- sourcesProp.setDependencies(Arrays.asList(new String[] {"vnf-id", "vnf-name"}));\r
-\r
- SourcesDefinition sourceDef = new SourcesDefinition();\r
- sourceDef.setProperties(sourcesProp);\r
-\r
- HashMap<String, SourcesDefinition> sources = new HashMap<>();\r
- sources.put("default", sourceDef);\r
-\r
- ResourceDefinition resourceDefinition = new ResourceDefinition();\r
- resourceDefinition.setProperty(propertyDefinition);\r
- resourceDefinition.setSources(sources);\r
-\r
- ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition);\r
-\r
- Assert.assertNotNull("Resource assignment default sourceName is missing ",\r
- resourceAssignment.getDictionarySource());\r
- Assert.assertNotNull("Resource assignment default sourceName property is missing ",\r
- resourceAssignment.getProperty());\r
- Assert.assertNotNull("Resource assignment default sourceName property type is missing ",\r
- resourceAssignment.getProperty().getType());\r
- }\r
-\r
- @Test\r
- public void testSourceMdsal() {\r
- logger.info(" **************** Validating testSourceMdsal *****************");\r
- ResourceAssignment resourceAssignment = new ResourceAssignment();\r
- resourceAssignment.setName("test-input-key");\r
-\r
- PropertyDefinition propertyDefinition = new PropertyDefinition();\r
- propertyDefinition.setType(ValidTypes.DATA_TYPE_STRING);\r
-\r
- SourcesProperties sourcesProp = new SourcesProperties();\r
- sourcesProp.setDependencies(Arrays.asList(new String[] {"vnf-id", "vnf-name"}));\r
-\r
- SourcesDefinition sourceDef = new SourcesDefinition();\r
- sourceDef.setProperties(sourcesProp);\r
-\r
- HashMap<String, SourcesDefinition> sources = new HashMap<>();\r
- sources.put("mdsal", sourceDef);\r
-\r
- ResourceDefinition resourceDefinition = new ResourceDefinition();\r
- resourceDefinition.setProperty(propertyDefinition);\r
- resourceDefinition.setSources(sources);\r
-\r
- ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition);\r
-\r
- Assert.assertNotNull("Resource assignment mdsal sourceName is missing ",\r
- resourceAssignment.getDictionarySource());\r
- Assert.assertNotNull("Resource assignment mdsal sourceName property is missing ",\r
- resourceAssignment.getProperty());\r
- Assert.assertNotNull("Resource assignment mdsal sourceName property type is missing ",\r
- resourceAssignment.getProperty().getType());\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.utils;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import com.fasterxml.jackson.databind.JsonNode;\r
-\r
-public class JsonParserUtilsTest {\r
-\r
- @Test\r
- public void testParse() {\r
- final String jsonExample = "{\"key\":\"value\"}";\r
-\r
- JsonNode rootJsonNode = JsonParserUtils.parse(jsonExample, "$");\r
- Assert.assertEquals(jsonExample, rootJsonNode.toString());\r
-\r
- JsonNode keyJsonNode = JsonParserUtils.parse(rootJsonNode, "$['key']");\r
- Assert.assertEquals("value", keyJsonNode.asText());\r
-\r
- Assert.assertEquals(jsonExample,\r
- JsonParserUtils.parseNSet("{\"key\":\"NOT_VALUE\"}", "$['key']", keyJsonNode).toString());\r
-\r
- rootJsonNode = JsonParserUtils.parse("{\"key\":\"NOT_VALUE\"}", "$");\r
- Assert.assertEquals(jsonExample, JsonParserUtils.parseNSet(rootJsonNode, "$['key']", keyJsonNode).toString());\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.utils;\r
-\r
-import static org.junit.Assert.assertTrue;\r
-import org.junit.Test;\r
-import org.onap.ccsdk.features.model.ValidTypes;\r
-import com.fasterxml.jackson.databind.node.ArrayNode;\r
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;\r
-import com.fasterxml.jackson.databind.node.ObjectNode;\r
-\r
-public class JsonUtilsTest {\r
-\r
- @Test\r
- public void testPopulatePrimitiveValues() {\r
- ObjectNode objectNode = JsonNodeFactory.instance.objectNode();\r
- JsonUtils.populatePrimitiveValues("key1", "value", "", objectNode);\r
- JsonUtils.populatePrimitiveValues("key2", true, ValidTypes.DATA_TYPE_BOOLEAN, objectNode);\r
- JsonUtils.populatePrimitiveValues("key3", 1, ValidTypes.DATA_TYPE_INTEGER, objectNode);\r
- JsonUtils.populatePrimitiveValues("key4", 1.1f, ValidTypes.DATA_TYPE_FLOAT, objectNode);\r
- JsonUtils.populatePrimitiveValues("key5", "13213123131", ValidTypes.DATA_TYPE_TIMESTAMP, objectNode);\r
-\r
- assertTrue("value".equals(objectNode.get("key1").asText()));\r
- assertTrue(objectNode.get("key2").asBoolean());\r
- assertTrue(objectNode.get("key3").asInt() == 1);\r
- assertTrue(objectNode.get("key4").floatValue() == 1.1f);\r
- assertTrue("13213123131".equals(objectNode.get("key5").asText()));\r
- }\r
-\r
- @Test\r
- public void testPopulatePrimitiveValuesArrayNode() {\r
- ArrayNode objectNode = JsonNodeFactory.instance.arrayNode();\r
- JsonUtils.populatePrimitiveValues("value", "", objectNode);\r
- JsonUtils.populatePrimitiveValues(true, ValidTypes.DATA_TYPE_BOOLEAN, objectNode);\r
- JsonUtils.populatePrimitiveValues(1, ValidTypes.DATA_TYPE_INTEGER, objectNode);\r
- JsonUtils.populatePrimitiveValues(1.1f, ValidTypes.DATA_TYPE_FLOAT, objectNode);\r
- JsonUtils.populatePrimitiveValues("13213123131", ValidTypes.DATA_TYPE_TIMESTAMP, objectNode);\r
-\r
- assertTrue(objectNode.size() == 5);\r
- }\r
-\r
- @Test\r
- public void testPopulatePrimitiveDefaultValues() {\r
- ObjectNode objectNode = JsonNodeFactory.instance.objectNode();\r
- JsonUtils.populatePrimitiveDefaultValues("key1", "", objectNode);\r
- JsonUtils.populatePrimitiveDefaultValues("key2", ValidTypes.DATA_TYPE_BOOLEAN, objectNode);\r
- JsonUtils.populatePrimitiveDefaultValues("key3", ValidTypes.DATA_TYPE_INTEGER, objectNode);\r
- JsonUtils.populatePrimitiveDefaultValues("key4", ValidTypes.DATA_TYPE_FLOAT, objectNode);\r
-\r
- assertTrue("".equals(objectNode.get("key1").asText()));\r
- assertTrue(objectNode.get("key2").asBoolean() == false);\r
- assertTrue(objectNode.get("key3").asInt() == 0);\r
- assertTrue(objectNode.get("key4").floatValue() == 0.0f);\r
- }\r
-\r
- @Test\r
- public void testPopulatePrimitiveDefaultValuesForArrayNode() {\r
- ArrayNode objectNode = JsonNodeFactory.instance.arrayNode();\r
- JsonUtils.populatePrimitiveDefaultValuesForArrayNode("", objectNode);\r
- JsonUtils.populatePrimitiveDefaultValuesForArrayNode(ValidTypes.DATA_TYPE_BOOLEAN, objectNode);\r
- JsonUtils.populatePrimitiveDefaultValuesForArrayNode(ValidTypes.DATA_TYPE_INTEGER, objectNode);\r
- JsonUtils.populatePrimitiveDefaultValuesForArrayNode(ValidTypes.DATA_TYPE_FLOAT, objectNode);\r
-\r
- assertTrue(objectNode.size() == 4);\r
- }\r
-\r
- @Test\r
- public void testPopulateJsonNodeValues() {\r
- ObjectNode objectNode = JsonNodeFactory.instance.objectNode();\r
- JsonUtils.populateJsonNodeValues("key1", JsonNodeFactory.instance.textNode("value"),\r
- ValidTypes.DATA_TYPE_STRING, objectNode);\r
- JsonUtils.populateJsonNodeValues("key2", JsonNodeFactory.instance.booleanNode(true),\r
- ValidTypes.DATA_TYPE_BOOLEAN, objectNode);\r
- JsonUtils.populateJsonNodeValues("key3", JsonNodeFactory.instance.numberNode(1), ValidTypes.DATA_TYPE_INTEGER,\r
- objectNode);\r
- JsonUtils.populateJsonNodeValues("key4", JsonNodeFactory.instance.numberNode(1.1f), ValidTypes.DATA_TYPE_FLOAT,\r
- objectNode);\r
- JsonUtils.populateJsonNodeValues("key5", JsonNodeFactory.instance.textNode("13213123131"),\r
- ValidTypes.DATA_TYPE_TIMESTAMP, objectNode);\r
- assertTrue(objectNode.get("key2").asBoolean());\r
-\r
- assertTrue("value".equals(objectNode.get("key1").asText()));\r
- assertTrue(objectNode.get("key2").asBoolean());\r
- assertTrue(objectNode.get("key3").asInt() == 1);\r
- assertTrue(objectNode.get("key4").floatValue() == 1.1f);\r
- assertTrue("13213123131".equals(objectNode.get("key5").asText()));\r
- }\r
-}\r
+++ /dev/null
-/*\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.features.model.utils;\r
-\r
-import static org.junit.Assert.assertTrue;\r
-import java.io.File;\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.junit.Test;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.ConfigModelException;\r
-import org.onap.ccsdk.features.model.ValidTypes;\r
-import org.onap.ccsdk.features.model.data.PropertyDefinition;\r
-import org.onap.ccsdk.features.model.data.ResourceAssignment;\r
-import org.onap.ccsdk.features.model.data.dict.ResourceDefinition;\r
-import com.fasterxml.jackson.core.type.TypeReference;\r
-import com.fasterxml.jackson.databind.JsonNode;\r
-import com.fasterxml.jackson.databind.ObjectMapper;\r
-\r
-public class ResourceAssignmentUtilsTest {\r
-\r
- @Test\r
- public void testGetArtifactNodeContent() {\r
- String nodeTemplateName = "nodeTemplateNmae";\r
- String templateContent = "content";\r
- Map<String, Object> context = new HashMap<String, Object>();\r
- context.put(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + nodeTemplateName + ".content", templateContent);\r
-\r
- String retrievedContent = ResourceAssignmentUtils.getArtifactNodeContent(nodeTemplateName, context);\r
-\r
- assertTrue(templateContent.equals(retrievedContent));\r
- }\r
-\r
- @Test\r
- public void testGetArtifactNodeMapping() {\r
- String nodeTemplateName = "nodeTemplateNmae";\r
- String templateContent = "[]";\r
- Map<String, Object> context = new HashMap<String, Object>();\r
- context.put(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + nodeTemplateName + ".mapping", templateContent);\r
-\r
- List<ResourceAssignment> map = ResourceAssignmentUtils.getArtifactNodeMapping(nodeTemplateName, context);\r
- assertTrue(map.size() == 0);\r
- }\r
-\r
- @Test\r
- public void testCleanContextTemplateNDictionaryKeys() {\r
- String recipeName = "recipe";\r
- Map<String, Object> componentContext = new HashMap<String, Object>();\r
- componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName);\r
- componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".", "value1");\r
- componentContext.put(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + recipeName + ".", "value2");\r
- ResourceAssignmentUtils.cleanContextTemplateNDictionaryKeys(componentContext);\r
-\r
- assertTrue(componentContext.size() == 1);\r
- }\r
-\r
- @Test\r
- public void testGetDictionaryKeyValue() {\r
- String recipeName = "recipe";\r
- String dictionaryName = "dictionaryKey";\r
- Map<String, Object> componentContext = new HashMap<String, Object>();\r
- componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName);\r
- componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + "." + dictionaryName,\r
- "value1");\r
- ResourceAssignment resourceAssignment = new ResourceAssignment();\r
- resourceAssignment.setDictionaryName(dictionaryName);\r
-\r
- String value = (String) ResourceAssignmentUtils.getDictionaryKeyValue(componentContext, resourceAssignment);\r
- assertTrue("value1".equals(value));\r
- }\r
-\r
- @Test\r
- public void testGetDictionaryKeyValueWithDictionaryDefinition() {\r
- String recipeName = "recipe";\r
- String dictionaryName = "dictionaryKey";\r
- Map<String, Object> componentContext = new HashMap<String, Object>();\r
- componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName);\r
- componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + "." + dictionaryName,\r
- "value1");\r
- ResourceDefinition resourceDefinition = new ResourceDefinition();\r
- resourceDefinition.setName(dictionaryName);\r
-\r
- String value = (String) ResourceAssignmentUtils.getDictionaryKeyValue(componentContext, resourceDefinition);\r
- assertTrue("value1".equals(value));\r
- }\r
-\r
- @Test\r
- public void testGetTemplateKeyValue() {\r
- String recipeName = "recipe";\r
- String templateKeyName = "templateKey";\r
- Map<String, Object> componentContext = new HashMap<String, Object>();\r
- componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName);\r
- componentContext.put(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + recipeName + "." + templateKeyName,\r
- "value1");\r
- ResourceAssignment resourceAssignment = new ResourceAssignment();\r
- resourceAssignment.setName(templateKeyName);\r
-\r
- String value = (String) ResourceAssignmentUtils.getTemplateKeyValue(componentContext, resourceAssignment);\r
- assertTrue("value1".equals(value));\r
- }\r
-\r
- @Test\r
- public void testSetResourceDataValue() throws Exception {\r
- String recipeName = "recipe";\r
- Map<String, Object> componentContext = new HashMap<String, Object>();\r
- componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName);\r
-\r
- ResourceAssignment resourceAssignment = createResourceAssignment("name1", ValidTypes.DATA_TYPE_STRING, null);\r
- Object value = "value";\r
- ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, value);\r
- assertTrue(value.equals(resourceAssignment.getProperty().getValue()));\r
-\r
- resourceAssignment = createResourceAssignment("name1", ValidTypes.DATA_TYPE_INTEGER, null);\r
- value = "1";\r
- ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, value);\r
- assertTrue((int) resourceAssignment.getProperty().getValue() == 1);\r
-\r
- resourceAssignment = createResourceAssignment("name1", ValidTypes.DATA_TYPE_BOOLEAN, null);\r
- value = "true";\r
- ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, value);\r
- assertTrue((boolean) resourceAssignment.getProperty().getValue());\r
-\r
- resourceAssignment = createResourceAssignment("name1", ValidTypes.DATA_TYPE_FLOAT, null);\r
- value = "1.1";\r
- ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, value);\r
- assertTrue((float) resourceAssignment.getProperty().getValue() == 1.1f);\r
- }\r
-\r
- @Test\r
- public void testSetFailedResourceDataValue() throws Exception {\r
- ResourceAssignment resourceAssignment = createResourceAssignment("name1", ValidTypes.DATA_TYPE_STRING, "value");\r
- String message = "message";\r
- ResourceAssignmentUtils.setFailedResourceDataValue(null, resourceAssignment, message);\r
-\r
- assertTrue(message.equals(resourceAssignment.getMessage()));\r
- assertTrue(ConfigModelConstant.STATUS_FAILURE.equals(resourceAssignment.getStatus()));\r
- }\r
-\r
- @Test(expected = ConfigModelException.class)\r
- public void testAssertTemplateKeyValueNotNull() throws Exception {\r
- Map<String, Object> componentContext = null;\r
- ResourceAssignment resourceAssignment = createResourceAssignment("name1", ValidTypes.DATA_TYPE_STRING, "value");\r
- ResourceAssignmentUtils.assertTemplateKeyValueNotNull(componentContext, resourceAssignment);\r
- }\r
-\r
- @Test\r
- public void testGenerateResourceDataForAssignments() throws Exception {\r
- List<ResourceAssignment> assignments = new ArrayList<ResourceAssignment>();\r
- assignments.add(createResourceAssignment("name1", ValidTypes.DATA_TYPE_STRING, "string"));\r
- assignments.add(createResourceAssignment("name2", ValidTypes.DATA_TYPE_BOOLEAN, true));\r
- assignments.add(createResourceAssignment("name3", ValidTypes.DATA_TYPE_INTEGER, 1));\r
- assignments.add(createResourceAssignment("name4", ValidTypes.DATA_TYPE_FLOAT, 1.1f));\r
- assignments.add(createResourceAssignment("name5", ValidTypes.DATA_TYPE_TIMESTAMP, "1523908097735"));\r
- assignments.add(createResourceAssignment("name6", "", new HashMap<String, String>()));\r
- ResourceAssignmentUtils.generateResourceDataForAssignments(assignments);\r
- }\r
-\r
- public void testResourceAssignmentForNullEmptyValues() throws Exception {\r
-\r
- ObjectMapper mapper = new ObjectMapper();\r
- JsonNode raContent =\r
- mapper.readTree(new File("src/test/resources/service_templates/ra-content-with-mising-value.json"));\r
-\r
- List<ResourceAssignment> assignments =\r
- mapper.readValue(raContent.toString(), new TypeReference<List<ResourceAssignment>>() {});\r
-\r
- ResourceAssignmentUtils.generateResourceDataForAssignments(assignments);\r
- }\r
-\r
- private ResourceAssignment createResourceAssignment(String name, String dataType, Object value) {\r
- PropertyDefinition property = new PropertyDefinition();\r
- property.setType(dataType);\r
- property.setValue(value);\r
- property.setRequired(true);\r
- ResourceAssignment ra = new ResourceAssignment();\r
- ra.setName(name);\r
- ra.setProperty(property);\r
- return ra;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.model.utils;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.onap.ccsdk.features.model.data.ArtifactDefinition;\r
-import org.onap.ccsdk.features.model.data.CapabilityAssignment;\r
-import org.onap.ccsdk.features.model.data.NodeTemplate;\r
-\r
-public class ServiceTemplateUtilsTest {\r
-\r
- ServiceTemplateUtils serviceTemplateUtils = new ServiceTemplateUtils();\r
-\r
- @Test\r
- public void testPopulateVnfNodeProperties() {\r
- NodeTemplate nodeTemplate = createNodeTemplate();\r
-\r
- String nodeTemplateKey = "nodeTemplateKey";\r
- Map<String, String> context = new HashMap<String, String>();\r
-\r
- Map<String, String> result =\r
- serviceTemplateUtils.populateVnfNodeProperties(nodeTemplateKey, nodeTemplate, context, null);\r
-\r
- Assert.assertTrue(result.size() > 0);\r
- }\r
-\r
- @Test\r
- public void testPopulateNodeTemplateArtifacts() {\r
- String nodeTemplateKey = "nodeTemplateKey";\r
- NodeTemplate nodeTemplate = createNodeTemplate();\r
- Map<String, String> context = new HashMap<String, String>();\r
-\r
- Map<String, String> result =\r
- serviceTemplateUtils.populateNodeTemplateArtifacts(nodeTemplateKey, nodeTemplate, context);\r
-\r
- Assert.assertTrue(result.size() > 0);\r
- }\r
-\r
- private NodeTemplate createNodeTemplate() {\r
- NodeTemplate nodeTemplate = new NodeTemplate();\r
- Map<String, Object> properties = new HashMap<String, Object>();\r
- properties.put("prop1", "value");\r
- CapabilityAssignment capabilityAssignment = new CapabilityAssignment();\r
- capabilityAssignment.setProperties(properties);\r
- Map<String, CapabilityAssignment> capabilities = new HashMap<String, CapabilityAssignment>();\r
- capabilities.put("key", capabilityAssignment);\r
- nodeTemplate.setCapabilities(capabilities);\r
-\r
- ArtifactDefinition artifactDefinition = new ArtifactDefinition();\r
- artifactDefinition.setFile("file");\r
- artifactDefinition.setDeployPath("deployPath");\r
- artifactDefinition.setContent("content");\r
- Map<String, ArtifactDefinition> artifacts = new HashMap<String, ArtifactDefinition>();\r
- artifacts.put("artifactName1", artifactDefinition);\r
- nodeTemplate.setArtifacts(artifacts);\r
-\r
- return nodeTemplate;\r
- }\r
-}\r
+++ /dev/null
-/*\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.features.model.utils;\r
-\r
-import static org.junit.Assert.assertNotNull;\r
-import static org.junit.Assert.assertTrue;\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-import org.junit.Test;\r
-import com.fasterxml.jackson.databind.JsonNode;\r
-\r
-public class TransformationUtilsTest {\r
-\r
- @Test\r
- public void testGetJson() {\r
- Map<String, Object> configparameters = new HashMap<String, Object>();\r
- configparameters.put("key", "value");\r
- String json = TransformationUtils.getJson(configparameters);\r
- assertTrue("{\"key\":\"value\"}".equals(json));\r
- }\r
-\r
- @Test\r
- public void testGetJsonNodeForString() {\r
- String content = "{\"key\":\"value\"}";\r
- JsonNode jsonNodeForString = TransformationUtils.getJsonNodeForString(content);\r
- assertNotNull(jsonNodeForString);\r
- }\r
-\r
- @Test\r
- public void testGetMapfromJson() {\r
- String content = "{\"key\":\"value\"}";\r
- Map<String, Object> mapfromJson = TransformationUtils.getMapfromJson(content);\r
- assertTrue(mapfromJson.size() == 1);\r
- assertTrue("value".equals(mapfromJson.get("key")));\r
- }\r
-\r
- @Test\r
- public void testGetMapfromJsonString() {\r
- String content = "{\"key\":\"value\"}";\r
- Map<String, Object> mapfromJson = TransformationUtils.getMapfromJsonString(content);\r
- assertTrue(mapfromJson.size() == 1);\r
- assertTrue("value".equals(mapfromJson.get("key")));\r
- }\r
-\r
- @Test\r
- public void testConvertJson2RootProperties() throws Exception {\r
- Map<String, String> context = new HashMap<String, String>();\r
- String jsonContent = "{\"key\":\"value\"}";\r
- Map<String, String> convertJson2RootProperties =\r
- TransformationUtils.convertJson2RootProperties(context, jsonContent);\r
- assertTrue(convertJson2RootProperties.size() == 1);\r
- assertTrue("value".equals(convertJson2RootProperties.get("key")));\r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- @Test\r
- public void testGetJsonNodeAndTreeToValueAndConvertJson2Properties() throws Exception {\r
- Map<String, String> configparameters = new HashMap<String, String>();\r
- configparameters.put("key", "value");\r
- JsonNode jsonNode = TransformationUtils.getJsonNode(configparameters);\r
- assertNotNull(jsonNode);\r
-\r
- Map<String, String> result = TransformationUtils.treeToValue(jsonNode, HashMap.class);\r
- assertTrue("value".equals(result.get("key")));\r
-\r
- result = TransformationUtils.convertJson2Properties(null, jsonNode, null);\r
- assertTrue("value".equals(result.get("key")));\r
- }\r
-\r
- @Test\r
- public void testGetJsonSchema() {\r
- String jsonSchema = TransformationUtils.getJsonSchema(String.class);\r
- assertNotNull(jsonSchema);\r
- }\r
-}\r
+++ /dev/null
-/*\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.features.model.validator;\r
-\r
-import java.nio.charset.Charset;\r
-import org.apache.commons.io.IOUtils;\r
-import org.junit.Test;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class ServiceTemplateValidationTest {\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ServiceTemplateValidationTest.class);\r
-\r
- @Test\r
- public void validateServiceTemplate() {\r
- try {\r
- logger.info(" **************** Validating Default *****************");\r
- String serviceTemplateContent = IOUtils.toString(ServiceTemplateValidationTest.class.getClassLoader()\r
- .getResourceAsStream("service_templates/default.json"), Charset.defaultCharset());\r
- ServiceTemplateValidator serviceTemplateValidator = new ServiceTemplateValidator();\r
- serviceTemplateValidator.validateServiceTemplate(serviceTemplateContent);\r
- logger.info(" **************** Reqource Assignment *****************");\r
- serviceTemplateContent = IOUtils.toString(ServiceTemplateValidationTest.class.getClassLoader()\r
- .getResourceAsStream("service_templates/resource_assignment.json"), Charset.defaultCharset());\r
- serviceTemplateValidator.validateServiceTemplate(serviceTemplateContent);\r
- } catch (Exception e) {\r
- e.printStackTrace();\r
- }\r
-\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.params.service;\r
-\r
-import static org.mockito.Matchers.any;\r
-import java.io.File;\r
-import java.nio.charset.Charset;\r
-import java.util.Arrays;\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-import org.apache.commons.io.FileUtils;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.apache.sling.testing.mock.osgi.MockOsgi;\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mock;\r
-import org.mockito.Mockito;\r
-import org.mockito.MockitoAnnotations;\r
-import org.mockito.invocation.InvocationOnMock;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.mockito.stubbing.Answer;\r
-import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog;\r
-import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.service.ComponentNodeDelegate;\r
-import org.onap.ccsdk.features.model.service.ComponentNodeServiceImpl;\r
-import org.onap.ccsdk.features.model.service.ConfigModelService;\r
-import org.onap.ccsdk.features.model.service.ConfigModelServiceImpl;\r
-import org.onap.ccsdk.features.model.utils.TransformationUtils;\r
-import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import org.osgi.framework.BundleContext;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class ComponentNodeTest {\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ComponentNodeTest.class);\r
- @Mock\r
- private ConfigResourceService configResourceService;\r
-\r
- @Mock\r
- private ConfigRestAdaptorService configRestAdaptorService;\r
-\r
- BundleContext bundleContext = MockOsgi.newBundleContext();\r
-\r
- @Before\r
- public void before() {\r
- MockitoAnnotations.initMocks(this);\r
-\r
- MockComponentNode mockSvcLogicPlugin = new MockComponentNode();\r
- bundleContext.registerService(MockComponentNode.class, mockSvcLogicPlugin, null);\r
-\r
- try {\r
- Mockito.doAnswer(new Answer<Void>() {\r
- @Override\r
- public Void answer(InvocationOnMock invocationOnMock) throws Throwable {\r
- Object[] args = invocationOnMock.getArguments();\r
- if (args != null) {\r
- logger.trace("Transaction info " + Arrays.asList(args));\r
- }\r
- return null;\r
- }\r
- }).when(configResourceService).save(any(TransactionLog.class));\r
- } catch (SvcLogicException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-\r
- @After\r
- public void after() {\r
-\r
- }\r
-\r
- @Test\r
- public void testProcess() {\r
-\r
- try {\r
- String serviceTemplateContent = FileUtils.readFileToString(\r
- new File("src/test/resources/componentnode/default.json"), Charset.defaultCharset());\r
- ConfigModelService configModelService = new ConfigModelServiceImpl(configRestAdaptorService);\r
-\r
- Map<String, String> map = new HashMap<>();\r
- configModelService.convertServiceTemplate2Properties(serviceTemplateContent, map);\r
-\r
- SvcLogicContext ctx = new SvcLogicContext();\r
- map.forEach((name, value) -> {\r
- if (StringUtils.isNotBlank(name) && StringUtils.isNotBlank(value)) {\r
- ctx.setAttribute(name, value);\r
- }\r
- });\r
- ctx.setAttribute("vnf-id", "1234");\r
-\r
- ComponentNodeServiceImpl componentNodeService =\r
- new ComponentNodeServiceImpl(bundleContext, configResourceService, configRestAdaptorService);\r
-\r
- ComponentNodeDelegate componentNodeDelegate = new ComponentNodeDelegate(componentNodeService);\r
- Map<String, String> inParams = new HashMap<>();\r
- inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "generate-configuration");\r
-\r
- componentNodeDelegate.process(inParams, ctx);\r
- TransformationUtils.printMap(inParams);\r
-\r
- } catch (Exception e) {\r
- e.printStackTrace();\r
- }\r
-\r
- }\r
-\r
- @Test(expected = SvcLogicException.class)\r
- public void testFailure() throws Exception {\r
- ComponentNodeServiceImpl componentNodeService =\r
- new ComponentNodeServiceImpl(bundleContext, configResourceService, configRestAdaptorService);\r
- ComponentNodeDelegate componentNodeDelegate = new ComponentNodeDelegate(componentNodeService);\r
-\r
- Map<String, String> inParams = new HashMap<String, String>();\r
- inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "generate-configuration");\r
- SvcLogicContext ctx = new SvcLogicContext();\r
- componentNodeDelegate.process(inParams, ctx);\r
- }\r
-}\r
+++ /dev/null
-/*\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.features.params.service;\r
-\r
-import static org.junit.Assert.fail;\r
-import java.io.File;\r
-import java.nio.charset.Charset;\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.apache.commons.io.FileUtils;\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Matchers;\r
-import org.mockito.Mock;\r
-import org.mockito.Mockito;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.data.ServiceTemplate;\r
-import org.onap.ccsdk.features.model.domain.ConfigModel;\r
-import org.onap.ccsdk.features.model.domain.ConfigModelContent;\r
-import org.onap.ccsdk.features.model.service.ConfigModelService;\r
-import org.onap.ccsdk.features.model.service.ConfigModelServiceImpl;\r
-import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class ConfigModelServiceTest {\r
-\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigModelServiceTest.class);\r
-\r
- @Mock\r
- private ConfigRestAdaptorService configRestAdaptorService;\r
-\r
- @Test\r
- public void testConfigAssignmentInputOutputParams() throws Exception {\r
-\r
- String fileContent = FileUtils.readFileToString(\r
- new File("src/test/resources/service_templates/resource_assignment.json"), Charset.defaultCharset());\r
-\r
- Map<String, String> context = new HashMap<>();\r
- ConfigModelServiceImpl configModelServiceImpl = new ConfigModelServiceImpl(configRestAdaptorService);\r
- context = configModelServiceImpl.convertServiceTemplate2Properties(fileContent, context);\r
-\r
- Assert.assertNotNull("Failed to Prepare Context : ", context);\r
-\r
- context.put("request-id", "12345");\r
- context.put("vnf-id", "vnf12345");\r
-\r
- Map<String, String> inparams = new HashMap<String, String>();\r
- inparams.put(ConfigModelConstant.PROPERTY_SELECTOR, "resource-assignment");\r
-\r
- SvcLogicContext inputContext = new SvcLogicContext();\r
- context.forEach((name, value) -> {\r
- inputContext.setAttribute(name, value);\r
- });\r
-\r
- // TransformationUtils.printProperty(inputContext.toProperties());\r
-\r
- configModelServiceImpl.assignInParamsFromModel(inputContext, inparams);\r
- Assert.assertNotNull("In Param is Null : ", inparams);\r
- Assert.assertNotNull("Failed to get entity-id in Inparms : ", inparams.get("resource-id"));\r
- Assert.assertEquals("Failed to get entity-id vlaue in Inparms ", String.valueOf("vnf12345"),\r
- inparams.get("resource-id"));\r
- Assert.assertNotNull("Failed to get request-id in Inparms : ", inparams.get("request-id"));\r
- Assert.assertEquals("Failed to get request-id vlaue in Inparms ", String.valueOf("12345"),\r
- inparams.get("request-id"));\r
-\r
- configModelServiceImpl.assignOutParamsFromModel(inputContext, inparams);\r
- logger.info("*************** Output Params *************");\r
- // TransformationUtils.printProperty(inputContext.toProperties());\r
-\r
- }\r
-\r
- @Test\r
- public void testConvertServiceTemplate2PropertiesComplex() throws Exception {\r
- String fileContent = FileUtils.readFileToString(\r
- new File("src/test/resources/service_templates/resource_assignment.json"), Charset.defaultCharset());\r
-\r
- Map<String, String> context = new HashMap<>();\r
- context.put("host-password", "1234");\r
- context.put("host-ip-address", "[123.23.34.45, 123.23.34.45]");\r
-\r
- ConfigModelServiceImpl configModelServiceImpl = new ConfigModelServiceImpl(configRestAdaptorService);\r
- configModelServiceImpl.convertServiceTemplate2Properties(fileContent, context);\r
-\r
- // TransformationUtils.printMap(context);\r
-\r
- Map<String, String> inparams = new HashMap<String, String>();\r
- inparams.put(ConfigModelConstant.PROPERTY_SELECTOR, "resource-assignment");\r
- logger.info("Before Input Result: " + inparams);\r
-\r
- SvcLogicContext inputContext = new SvcLogicContext();\r
- context.forEach((name, value) -> {\r
- inputContext.setAttribute(name, value);\r
- });\r
-\r
- configModelServiceImpl.assignInParamsFromModel(inputContext, inparams);\r
- logger.info("----------Input Result: " + inparams);\r
-\r
- inputContext.setAttribute("assignment-params", "default-assigned");\r
- configModelServiceImpl.assignOutParamsFromModel(inputContext, inparams);\r
-\r
- // TransformationUtils.printProperty(inputContext.toProperties());\r
-\r
- }\r
-\r
- @Test\r
- public void testGetNodeTemplateContent() throws Exception {\r
- String templateContent = "{\"id\":\"id\"}";\r
- SvcLogicContext context = new SvcLogicContext();\r
- context.setAttribute(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + templateContent + ".content",\r
- templateContent);\r
-\r
- ConfigModelServiceImpl configModelServiceImpl = new ConfigModelServiceImpl(configRestAdaptorService);\r
- String content = configModelServiceImpl.getNodeTemplateContent(context, templateContent);\r
-\r
- Assert.assertEquals(content, templateContent);\r
- }\r
-\r
- @Test\r
- public void testGetNodeTemplateMapping() throws Exception {\r
- String templateContent = "{\"capabilities\":{\"mapping\":{\"properties\":{\"mapping\":[\"test\"]}}}}";\r
- SvcLogicContext context = new SvcLogicContext();\r
- context.setAttribute(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + templateContent, templateContent);\r
-\r
- ConfigModelServiceImpl configModelServiceImpl = new ConfigModelServiceImpl(configRestAdaptorService);\r
- configModelServiceImpl.getNodeTemplateMapping(context, templateContent);\r
- // Assert.assertEquals(content, templateContent);\r
- }\r
-\r
- @Test\r
- public void testValidateServiceTemplate() throws Exception {\r
- ConfigModelServiceImpl configModelServiceImpl = new ConfigModelServiceImpl(configRestAdaptorService);\r
- ServiceTemplate serviceTemplate = new ServiceTemplate();\r
-\r
- try {\r
- configModelServiceImpl.validateServiceTemplate(null);\r
- fail("Should have thrown exception");\r
- } catch (SvcLogicException e) {\r
- }\r
-\r
- try {\r
- configModelServiceImpl.validateServiceTemplate(serviceTemplate);\r
- fail("Should have thrown exception");\r
- } catch (SvcLogicException e) {\r
- }\r
-\r
- Map<String, String> metadata = new HashMap<String, String>();\r
- metadata.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_AUTHOR, "author");\r
- metadata.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_NAME, "name");\r
- metadata.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_VERSION, "version");\r
- serviceTemplate.setMetadata(metadata);\r
-\r
- Assert.assertTrue(configModelServiceImpl.validateServiceTemplate(serviceTemplate));\r
- }\r
-\r
- @Test\r
- public void testPrepareContext() throws Exception {\r
- Mockito.when(configRestAdaptorService.getResource(Matchers.anyString(), Matchers.anyString(), Matchers.any()))\r
- .thenReturn(createConfigModel());\r
-\r
- String input = "{\"action-name\": \"resource-assignment-action\"}";\r
- ConfigModelService configModelService = new ConfigModelServiceImpl(configRestAdaptorService);\r
-\r
- Map<String, String> ctx =\r
- configModelService.prepareContext(null, input, "serviceTemplateName", "serviceTemplateVersion");\r
- Assert.assertEquals("resource-assignment-action", ctx.get(ConfigModelConstant.PROPERTY_ACTION_NAME));\r
-\r
- ctx = configModelService.prepareContext(null, input, "{}");\r
- Assert.assertEquals("resource-assignment-action", ctx.get(ConfigModelConstant.PROPERTY_ACTION_NAME));\r
- }\r
-\r
- @Test\r
- public void testConvertServiceTemplate2Properties() throws Exception {\r
- Map<String, String> metadata = new HashMap<String, String>();\r
- metadata.put("key", "value");\r
- ServiceTemplate serviceTemplate = new ServiceTemplate();\r
- serviceTemplate.setMetadata(metadata);\r
- Map<String, String> context = new HashMap<String, String>();\r
-\r
- ConfigModelService configModelService = new ConfigModelServiceImpl(configRestAdaptorService);\r
- Map<String, String> ctx = configModelService.convertServiceTemplate2Properties(serviceTemplate, context);\r
-\r
- Assert.assertEquals("value", ctx.get("key"));\r
- }\r
-\r
- private ConfigModel createConfigModel() {\r
- ConfigModel configModel = new ConfigModel();\r
- List<ConfigModelContent> configModelContents = new ArrayList<ConfigModelContent>();\r
- ConfigModelContent configModelContent = new ConfigModelContent();\r
- configModelContent.setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON);\r
- configModelContent.setContent("{\"description\": \"description\"}");\r
- configModelContents.add(configModelContent);\r
- configModel.setConfigModelContents(configModelContents);\r
- configModel.setPublished("Y");\r
- return configModel;\r
- }\r
-}\r
+++ /dev/null
-/*\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.features.params.service;\r
-\r
-import java.io.File;\r
-import java.nio.charset.Charset;\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import org.apache.commons.io.FileUtils;\r
-import org.junit.Test;\r
-import org.onap.ccsdk.features.model.utils.ExpressionUtils;\r
-import org.onap.ccsdk.features.model.utils.TransformationUtils;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-import com.fasterxml.jackson.databind.JsonNode;\r
-import com.fasterxml.jackson.databind.ObjectMapper;\r
-\r
-public class ExpressionUtilsTest {\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(ExpressionUtilsTest.class);\r
-\r
- @Test\r
- public void testProcessJsonExpression() throws Exception {\r
- String fileContent = FileUtils.readFileToString(new File("src/test/resources/properties/default.json"),\r
- Charset.defaultCharset());\r
-\r
- SvcLogicContext context = new SvcLogicContext();\r
- context.setAttribute("host-password", "1234");\r
- context.setAttribute("host-ip-address", "[\"123.23.34.45\", \"123.23.34.45\"]");\r
- context.setAttribute("loopback-default", "[\"Sample\", \"Brinda\"]");\r
-\r
- Map<String, String> inparams = new HashMap<String, String>();\r
- ExpressionUtils jsonExpressionUtils = new ExpressionUtils(context, inparams);\r
- ObjectMapper mapper = new ObjectMapper();\r
- JsonNode rootArray = mapper.readTree(fileContent);\r
- jsonExpressionUtils.processJsonExpression(rootArray);\r
-\r
- }\r
-\r
- @Test\r
- public void testJson2Property() throws Exception {\r
- String fileContent = FileUtils.readFileToString(new File("src/test/resources/properties/convert.json"),\r
- Charset.defaultCharset());\r
-\r
- List<String> blockKeys = new ArrayList<String>();\r
- blockKeys.add(\r
- "interfaces.ResourceAssignmentService.operations.getResourceAssignment.inputs.assignment-mappings");\r
- blockKeys.add("interfaces.ResourceAssignmentService.operations.getResourceAssignment.outputs");\r
- blockKeys.add("type");\r
-\r
- Map<String, String> workflowMap = new HashMap<>();\r
- Map<String, String> propertyMap =\r
- TransformationUtils.convertJson2Properties(workflowMap, fileContent, blockKeys);\r
-\r
- TransformationUtils.printMap(propertyMap);\r
-\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.params.service;\r
-\r
-import java.util.Map;\r
-import org.onap.ccsdk.features.model.service.ComponentNode;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-public class MockComponentNode implements ComponentNode {\r
- private static EELFLogger logger = EELFManager.getInstance().getLogger(MockComponentNode.class);\r
-\r
- @Override\r
- public Boolean preCondition(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- logger.info("Received preCondition ");\r
- componentContext.put("test-key", "test");\r
- return true;\r
- }\r
-\r
- @Override\r
- public void process(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {\r
-\r
- }\r
-\r
- @Override\r
- public void process(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- logger.info("Received Request " + componentContext);\r
- }\r
-\r
- @Override\r
- public void preProcess(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- logger.info("Received preProcess ");\r
-\r
- }\r
-\r
- @Override\r
- public void postProcess(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
- throws SvcLogicException {\r
- logger.info("Received postProcess ");\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\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.features.params.service;\r
-\r
-import java.io.File;\r
-import java.io.IOException;\r
-import java.nio.charset.Charset;\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-import org.apache.commons.io.FileUtils;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.features.model.ConfigModelConstant;\r
-import org.onap.ccsdk.features.model.data.DataType;\r
-import org.onap.ccsdk.features.model.data.NodeTemplate;\r
-import org.onap.ccsdk.features.model.data.NodeType;\r
-import org.onap.ccsdk.features.model.data.ServiceTemplate;\r
-import org.onap.ccsdk.features.model.data.TopologyTemplate;\r
-import org.onap.ccsdk.features.model.data.dict.ResourceDefinition;\r
-import org.onap.ccsdk.features.model.utils.TransformationUtils;\r
-\r
-public class ServiceTemplateCreateUtils {\r
-\r
- public void createNodeTypes(String serviceTemplateFileName) throws IOException {\r
- if (StringUtils.isNotBlank(serviceTemplateFileName)) {\r
- String fileContent =\r
- FileUtils.readFileToString(new File(serviceTemplateFileName), Charset.defaultCharset());\r
- if (StringUtils.isNotBlank(fileContent)) {\r
- // System.out.println("NodeTypeCreateUtils.createNodeTypes()" +fileContent );\r
- ServiceTemplate serviceTemplate = TransformationUtils.readValue(fileContent, ServiceTemplate.class);\r
-\r
- String formattedServiceTemplateContent = TransformationUtils.getJson(serviceTemplate, true);\r
-\r
- FileUtils.writeStringToFile(new File("src/test/resources/service_templates/default.json"),\r
- formattedServiceTemplateContent, Charset.defaultCharset());\r
-\r
- createVrrNodeTemplate(serviceTemplate);\r
- createDictionarySchema();\r
-\r
- }\r
- }\r
- }\r
-\r
- public void createNodeTypes(ServiceTemplate serviceTemplate) throws IOException {\r
-\r
- if (serviceTemplate != null && serviceTemplate.getNodeTypes() != null) {\r
- serviceTemplate.getNodeTypes().forEach((nodeTypeKey, node_types) -> {\r
-\r
- if (node_types != null && StringUtils.isNotBlank(node_types.getDerivedFrom())) {\r
-\r
- try {\r
- String fileName = "src/test/resources/node_types/";\r
- if (ConfigModelConstant.MODEL_TYPE_NODE_VNF.equalsIgnoreCase(node_types.getDerivedFrom())) {\r
- fileName = fileName + "vnf/" + nodeTypeKey + ".json";\r
- }\r
- if (ConfigModelConstant.MODEL_TYPE_NODE_DG.equalsIgnoreCase(node_types.getDerivedFrom())) {\r
- fileName = fileName + "dg/" + nodeTypeKey + ".json";\r
- }\r
- if (ConfigModelConstant.MODEL_TYPE_NODE_COMPONENT\r
- .equalsIgnoreCase(node_types.getDerivedFrom())) {\r
- fileName = fileName + "component/" + nodeTypeKey + ".json";\r
- }\r
- String content = TransformationUtils.getJson(node_types, true);\r
- FileUtils.write(new File(fileName), content, Charset.defaultCharset());\r
- } catch (IOException e) {\r
- e.printStackTrace();\r
- }\r
-\r
- }\r
- System.out.println("NodeTypeCreateUtils.createNodeTypes()" + nodeTypeKey);\r
- });\r
- }\r
-\r
- }\r
-\r
- public void createResourceAssignmentNodeTemplate(ServiceTemplate serviceTemplate) throws IOException {\r
- if (serviceTemplate != null) {\r
- ServiceTemplate workingServiceTemplate = new ServiceTemplate();\r
- workingServiceTemplate.setMetadata(serviceTemplate.getMetadata());\r
-\r
- Map<String, DataType> data_types = new HashMap<String, DataType>();\r
- data_types.put("datatype-property", serviceTemplate.getDataTypes().get("datatype-property"));\r
- data_types.put("datatype-resource-assignment",\r
- serviceTemplate.getDataTypes().get("datatype-resource-assignment"));\r
-\r
- workingServiceTemplate.setDataTypes(data_types);\r
-\r
- TopologyTemplate topology_template = new TopologyTemplate();\r
- Map<String, NodeTemplate> node_templates = new HashMap<String, NodeTemplate>();\r
-\r
- Map<String, NodeTemplate> node_Templates = serviceTemplate.getTopologyTemplate().getNodeTemplates();\r
-\r
- node_templates.put("base-config-template", node_Templates.get("base-config-template"));\r
- node_templates.put("licence-template", node_Templates.get("licence-template"));\r
-\r
- node_templates.put("resource-assignment-action", node_Templates.get("resource-assignment-action"));\r
- node_templates.put("resource-assignment", node_Templates.get("resource-assignment"));\r
-\r
- topology_template.setNodeTemplates(node_templates);\r
- topology_template.setInputs(serviceTemplate.getTopologyTemplate().getInputs());\r
-\r
- Map<String, NodeType> node_types = new HashMap<String, NodeType>();\r
- node_types.put("artifact-config-template", serviceTemplate.getNodeTypes().get("artifact-config-template"));\r
- node_types.put("dg-resource-assignment", serviceTemplate.getNodeTypes().get("dg-resource-assignment"));\r
- node_types.put("component-resource-assignment",\r
- serviceTemplate.getNodeTypes().get("component-resource-assignment"));\r
-\r
- workingServiceTemplate.setNodeTypes(node_types);\r
- workingServiceTemplate.setTopologyTemplate(topology_template);\r
-\r
- String workingServiceTemplateConmtent = TransformationUtils.getJson(workingServiceTemplate, true);\r
-\r
- FileUtils.writeStringToFile(new File("src/test/resources/service_templates/resource_assignment.json"),\r
- workingServiceTemplateConmtent, Charset.defaultCharset());\r
-\r
- File lcmFile = new File(\r
- "../../../northbound/selfservice-api/provider/src/test/resources/service_templates/resource_assignment.json");\r
- FileUtils.writeStringToFile(lcmFile, workingServiceTemplateConmtent, Charset.defaultCharset());\r
-\r
- File resourceAssignmetFile = new File(\r
- "../../../plugin/assignment/provider/src/test/resources/service_templates/resource_assignment.json");\r
- FileUtils.writeStringToFile(resourceAssignmetFile, workingServiceTemplateConmtent,\r
- Charset.defaultCharset());\r
-\r
- System.out.println("NodeTypeCreateUtils.createNodeTemplate() :" + workingServiceTemplateConmtent);\r
- }\r
-\r
- }\r
-\r
- public void createVrrNodeTemplate(ServiceTemplate serviceTemplate) throws IOException {\r
- if (serviceTemplate != null) {\r
- ServiceTemplate workingServiceTemplate = new ServiceTemplate();\r
- workingServiceTemplate.setMetadata(serviceTemplate.getMetadata());\r
-\r
- TopologyTemplate topology_template = new TopologyTemplate();\r
- Map<String, NodeTemplate> node_templates = new HashMap<String, NodeTemplate>();\r
-\r
- Map<String, NodeTemplate> node_Templates = serviceTemplate.getTopologyTemplate().getNodeTemplates();\r
-\r
- node_templates.put("resource-assignment-action", node_Templates.get("resource-assignment-action"));\r
- node_templates.put("resource-assignment", node_Templates.get("resource-assignment"));\r
-\r
- node_templates.put("activate-action", node_Templates.get("activate-action"));\r
- node_templates.put("base-config-template", node_Templates.get("base-config-template"));\r
- node_templates.put("licence-template", node_Templates.get("licence-template"));\r
- node_templates.put("vrr-netconf-device", node_Templates.get("vrr-netconf-device"));\r
- node_templates.put("get-netconf-config", node_Templates.get("get-netconf-config"));\r
- node_templates.put("edit-netconf-config", node_Templates.get("edit-netconf-config"));\r
- node_templates.put("transaction-netconf-baseconfig", node_Templates.get("transaction-netconf-baseconfig"));\r
-\r
- topology_template.setNodeTemplates(node_templates);\r
- topology_template.setInputs(serviceTemplate.getTopologyTemplate().getInputs());\r
-\r
- workingServiceTemplate.setTopologyTemplate(topology_template);\r
-\r
- String workingServiceTemplateContent = TransformationUtils.getJson(workingServiceTemplate, true);\r
-\r
- FileUtils.writeStringToFile(new File("src/test/resources/service_templates/vrr_config.json"),\r
- workingServiceTemplateContent, Charset.defaultCharset());\r
-\r
- }\r
- }\r
-\r
- public void createDictionarySchema() throws IOException {\r
- String schema = TransformationUtils.getJsonSchema(ResourceDefinition.class);\r
- FileUtils.writeStringToFile(new File("src/test/resources/dictionary/dictionary_schema.json"), schema,\r
- Charset.defaultCharset());\r
- }\r
-\r
- public static void main(String[] args) {\r
- try {\r
- ServiceTemplateCreateUtils utils = new ServiceTemplateCreateUtils();\r
- utils.createNodeTypes("src/test/resources/service_templates/default.json");\r
- } catch (Exception e) {\r
- // TODO: handle exception\r
- }\r
- }\r
-\r
-}\r
+++ /dev/null
-{\r
- "metadata": {\r
- "author": "ks220y@att.com",\r
- "vendor": "Juniper",\r
- "os": "XXX",\r
- "service-type": "AVPN",\r
- "vnf-type": "VRR",\r
- "action": "Base Configuration",\r
- "sub-action": "Generate Configuration",\r
- "service-template-name": "VRR-baseconfiguration",\r
- "service-template-version": "1.0.0"\r
- },\r
- "topology_template": {\r
- "inputs": {\r
- "service-instance-id": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "vnf-id": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "service": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "region": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "bundle-id": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "bundle-mac": {\r
- "required": true,\r
- "type": "string"\r
- }\r
- },\r
- "node_templates": {\r
- "generate-configuration": {\r
- "type": "mock-component-generateConfig",\r
- "interfaces": {\r
- "org-onap-ccsdk-features-params-service-MockComponentNode": {\r
- "operations": {\r
- "process": {\r
- "inputs": {\r
- "entity-type": "vnf-type",\r
- "template-content": "sample-template",\r
- "entity-id": "{ \"get_input\" : \"vnf-id\" }"\r
- },\r
- "outputs": {\r
- "mergedData": "merged Data",\r
- "status": "status"\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "node_types": {\r
- "mock-component-generateConfig": {\r
- "interfaces": {\r
- "org-onap-ccsdk-features-params-service-MockComponentNode": {\r
- "operations": {\r
- "process": {\r
- "inputs": {\r
- "entity-type": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "template-content": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "entity-id": {\r
- "required": true,\r
- "type": "string"\r
- }\r
- },\r
- "outputs": {\r
- "generated-config": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "status": {\r
- "required": true,\r
- "type": "string"\r
- }\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "derived_from": "tosca.nodes.Component"\r
- }\r
- }\r
-}\r
+++ /dev/null
-{\r
- "type": "object",\r
- "properties": {\r
- "resource-path": {\r
- "tags": {\r
- "type": "string"\r
- },\r
- "name": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "type": "string",\r
- "required": true\r
- },\r
- "property": {\r
- "type": "object",\r
- "properties": {\r
- "default": {\r
- "type": "any"\r
- },\r
- "entry_schema": {\r
- "type": "object",\r
- "properties": {\r
- "type": {\r
- "type": "string"\r
- }\r
- }\r
- },\r
- "description": {\r
- "type": "string"\r
- },\r
- "type": {\r
- "type": "string"\r
- },\r
- "constraints": {\r
- "type": "array",\r
- "items": {\r
- "type": "object",\r
- "additionalProperties": {\r
- "type": "any"\r
- }\r
- }\r
- },\r
- "value": {\r
- "type": "any"\r
- },\r
- "required": {\r
- "type": "boolean"\r
- },\r
- "status": {\r
- "type": "string"\r
- }\r
- }\r
- },\r
- "resource-type": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "updated-by": {\r
- "type": "string"\r
- },\r
- "sources": {\r
- "type": "object",\r
- "required": true,\r
- "additionalProperties": {\r
- "type": "object",\r
- "properties": {\r
- "type": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "properties": {\r
- "type": "object",\r
- "required": true,\r
- "properties": {\r
- "type": {\r
- "type": "string"\r
- },\r
- "name": {\r
- "type": "string"\r
- },\r
- "key": {\r
- "type": "string"\r
- },\r
- "path": {\r
- "type": "string"\r
- },\r
- "url-path": {\r
- "type": "string"\r
- },\r
- "query": {\r
- "type": "string"\r
- },\r
- "input-key-mapping": {\r
- "type": "object",\r
- "additionalProperties": {\r
- "type": "string"\r
- }\r
- },\r
- "output-key-mapping": {\r
- "type": "object",\r
- "additionalProperties": {\r
- "type": "string"\r
- }\r
- },\r
- "key-dependencies": {\r
- "type": "array",\r
- "items": {\r
- "type": "string"\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
-}
\ No newline at end of file
+++ /dev/null
-{\r
- "type": "sdnc-component-getResourceAssignment",\r
- "interfaces": {\r
- "ResourceAssignmentService": {\r
- "operations": {\r
- "getResourceAssignment": {\r
- "inputs": {\r
- "assignment-mappings": [\r
- {\r
- "name": "service-name",\r
- "mapping-field": "service",\r
- "mapping-category": "SDN",\r
- "required": true\r
- },\r
- {\r
- "name": "region-name",\r
- "mapping-field": "region",\r
- "mapping-category": "SDN",\r
- "required": true\r
- }\r
- ],\r
- "pre-data": "{ \"get_attribute\" : \"get-resource-assignment.config-params\" }",\r
- "prifix": "get-resource-assignment"\r
- },\r
- "outputs": {\r
- "resource-assignment-status": "success",\r
- "resource-assignment-params": "{ \"set_value\" : \"get-resource-assignment.config-params\" }"\r
- }\r
- }\r
- }\r
- }\r
- }\r
-}\r
+++ /dev/null
-{\r
- "default": "{ \"get_input\" : \"loopback-default\" }",\r
- "domain": "ethernet",\r
- "criteria": [\r
- {\r
- "value": "dummy301me1",\r
- "type": "complex",\r
- "nodeString": "layer3-service-list[].service-data.l3sdn-vnf-fields.vnf-name"\r
- },\r
- {\r
- "value": "{ \"get_input\" : \"host-ip-address\" }",\r
- "type": "simple",\r
- "nodeString": "layer3-service-list[].service-data.l3sdn-vnf-fields.vnf-name"\r
- }\r
- ]\r
-}\r
+++ /dev/null
-{\r
- "metadata" : {\r
- "author" : "ks220y@att.com",\r
- "service-template-name" : "VRR-baseconfiguration",\r
- "service-template-version" : "1.0.0",\r
- "release" : "1802",\r
- "service-type" : "AVPN",\r
- "vnf-type" : "VRR"\r
- },\r
- "tosca_definitions_version" : "sdn_config_1_0_0",\r
- "topology_template" : {\r
- "inputs" : {\r
- "request-id" : {\r
- "required" : true,\r
- "type" : "string"\r
- },\r
- "service-instance-id" : {\r
- "required" : true,\r
- "type" : "string"\r
- },\r
- "action-name" : {\r
- "required" : true,\r
- "type" : "string"\r
- },\r
- "scope-type" : {\r
- "required" : true,\r
- "type" : "string"\r
- },\r
- "hostname" : {\r
- "required" : true,\r
- "type" : "string"\r
- }\r
- },\r
- "node_templates" : {\r
- "base-config-template" : {\r
- "type" : "artifact-config-template",\r
- "properties" : {\r
- "action-names" : [ "resource-assignment-action" ]\r
- },\r
- "capabilities" : {\r
- "content" : {\r
- "properties" : {\r
- "content" : "db://base-config-template"\r
- }\r
- },\r
- "mapping" : {\r
- "properties" : {\r
- "mapping" : [ {\r
- "name" : "vnf-id",\r
- "input-param" : true,\r
- "property" : {\r
- "type" : "string",\r
- "required" : true\r
- },\r
- "dictionary-name" : "vnf-id",\r
- "dictionary-source" : "input"\r
- }, {\r
- "name" : "group-name",\r
- "input-param" : true,\r
- "property" : {\r
- "type" : "string",\r
- "required" : true\r
- },\r
- "dictionary-name" : "group-name",\r
- "dictionary-source" : "input"\r
- } ]\r
- }\r
- }\r
- }\r
- },\r
- "licence-template" : {\r
- "type" : "artifact-config-template",\r
- "properties" : {\r
- "action-names" : [ "resource-assignment-action" ]\r
- },\r
- "capabilities" : {\r
- "content" : {\r
- "properties" : {\r
- "content" : "db://licence-template"\r
- }\r
- },\r
- "mapping" : {\r
- "properties" : {\r
- "mapping" : [ {\r
- "name" : "bundle-id",\r
- "input-param" : true,\r
- "property" : {\r
- "type" : "string"\r
- },\r
- "dictionary-name" : "bundle-id",\r
- "dictionary-source" : "input"\r
- }, {\r
- "name" : "bundle-mac",\r
- "input-param" : true,\r
- "property" : {\r
- "type" : "string",\r
- "required" : true\r
- },\r
- "dictionary-name" : "bundle-mac",\r
- "dictionary-source" : "input"\r
- } ]\r
- }\r
- }\r
- }\r
- },\r
- "resource-assignment-action" : {\r
- "type" : "dg-resource-assignment",\r
- "interfaces" : {\r
- "CONFIG" : {\r
- "operations" : {\r
- "ResourceAssignment" : { }\r
- }\r
- }\r
- },\r
- "capabilities" : {\r
- "dg-node" : { }\r
- },\r
- "requirements" : {\r
- "component-dependency" : {\r
- "capability" : "component-node",\r
- "node" : "resource-assignment",\r
- "relationship" : "tosca.relationships.DependsOn"\r
- }\r
- }\r
- },\r
- "config-generator-action" : {\r
- "type" : "dg-config-generator",\r
- "interfaces" : {\r
- "CONFIG" : {\r
- "operations" : {\r
- "GenerateConfiguration" : { }\r
- }\r
- }\r
- },\r
- "capabilities" : {\r
- "dg-node" : { }\r
- },\r
- "requirements" : {\r
- "component-dependency" : {\r
- "capability" : "component-node",\r
- "node" : "generate-configuration",\r
- "relationship" : "tosca.relationships.DependsOn"\r
- }\r
- }\r
- },\r
- "resource-assignment" : {\r
- "type" : "component-resource-assignment",\r
- "interfaces" : {\r
- "org-onap-ccsdk-features-assignment-service-ConfigAssignmentNode" : {\r
- "operations" : {\r
- "process" : {\r
- "inputs" : {\r
- "action-name" : "{ \"get_input\" : \"action-name\" }",\r
- "resource-type" : "vnf-type",\r
- "template-names" : [ "base-config-template", "licence-template" ],\r
- "request-id" : "{ \"get_input\" : \"request-id\" }",\r
- "resource-id" : "{ \"get_input\" : \"vnf-id\" }"\r
- },\r
- "outputs" : {\r
- "resource-assignment-params" : "",\r
- "status" : ""\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "capabilities" : {\r
- "component-node" : { }\r
- }\r
- },\r
- "generate-configuration" : {\r
- "type" : "component-config-generator",\r
- "interfaces" : {\r
- "org-onap-ccsdk-features-generator-service-ConfigGeneratorNode" : {\r
- "operations" : {\r
- "process" : {\r
- "inputs" : {\r
- "action-name" : "{ \"get_input\" : \"action-name\" }",\r
- "resource-type" : "vnf-type",\r
- "request-id" : "{ \"get_input\" : \"request-id\" }",\r
- "resource-id" : "{ \"get_input\" : \"vnf-id\" }",\r
- "template-name" : "base-config-template"\r
- },\r
- "outputs" : {\r
- "generated-config" : "",\r
- "status" : ""\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "capabilities" : {\r
- "component-node" : { }\r
- }\r
- }\r
- }\r
- },\r
- "artifact_types" : {\r
- "artifact-template-velocity" : {\r
- "description" : " Velocity Template used for Configuration",\r
- "version" : "1.0.0",\r
- "derived_from" : "tosca.artifacts.Implementation",\r
- "file_ext" : [ "vtl" ]\r
- },\r
- "artifact-mapping-resource" : {\r
- "description" : " Velocity Template Resource Mapping File used along with Configuration template",\r
- "version" : "1.0.0",\r
- "derived_from" : "tosca.artifacts.Implementation",\r
- "file_ext" : [ "json" ]\r
- },\r
- "artifact-script-python" : {\r
- "description" : " Python Script Template used for Configuration",\r
- "version" : "1.0.0",\r
- "derived_from" : "tosca.artifacts.Implementation",\r
- "file_ext" : [ "py" ]\r
- }\r
- },\r
- "node_types" : {\r
- "dg-resource-assignment" : {\r
- "description" : "This is Resource Assignment Directed Graph",\r
- "version" : "1.0.0",\r
- "properties" : {\r
- "mode" : {\r
- "required" : false,\r
- "type" : "string",\r
- "default" : "sync"\r
- },\r
- "version" : {\r
- "required" : false,\r
- "type" : "string",\r
- "default" : "LATEST"\r
- },\r
- "is-start-flow" : {\r
- "required" : false,\r
- "type" : "boolean",\r
- "default" : "false"\r
- }\r
- },\r
- "capabilities" : {\r
- "dg-node" : {\r
- "type" : "tosca.capabilities.Node"\r
- },\r
- "content" : {\r
- "type" : "tosca.capabilities.Content",\r
- "properties" : {\r
- "type" : {\r
- "required" : false,\r
- "type" : "string",\r
- "default" : "json"\r
- },\r
- "content" : {\r
- "required" : true,\r
- "type" : "string"\r
- }\r
- }\r
- }\r
- },\r
- "requirements" : {\r
- "component-dependency" : {\r
- "capability" : "component-node",\r
- "node" : "component-resource-assignment",\r
- "relationship" : "tosca.relationships.DependsOn"\r
- }\r
- },\r
- "interfaces" : {\r
- "CONFIG" : {\r
- "operations" : {\r
- "ResourceAssignment" : {\r
- "inputs" : {\r
- "params" : {\r
- "required" : false,\r
- "type" : "list",\r
- "entry_schema" : {\r
- "type" : "datatype-property"\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "derived_from" : "tosca.nodes.DG"\r
- },\r
- "dg-config-generator" : {\r
- "description" : "This is Activate DG for Config Generator Directed Graph",\r
- "version" : "1.0.0",\r
- "properties" : {\r
- "mode" : {\r
- "required" : false,\r
- "type" : "string",\r
- "default" : "sync"\r
- },\r
- "version" : {\r
- "required" : false,\r
- "type" : "string",\r
- "default" : "LATEST"\r
- },\r
- "is-start-flow" : {\r
- "required" : false,\r
- "type" : "boolean",\r
- "default" : "false"\r
- }\r
- },\r
- "capabilities" : {\r
- "dg-node" : {\r
- "type" : "tosca.capabilities.Node"\r
- },\r
- "content" : {\r
- "type" : "tosca.capabilities.Content",\r
- "properties" : {\r
- "type" : {\r
- "required" : false,\r
- "type" : "string",\r
- "default" : "json"\r
- },\r
- "content" : {\r
- "required" : true,\r
- "type" : "string"\r
- }\r
- }\r
- }\r
- },\r
- "requirements" : {\r
- "component-dependency" : {\r
- "capability" : "component-node",\r
- "node" : "component-config-generator",\r
- "relationship" : "tosca.relationships.DependsOn"\r
- }\r
- },\r
- "interfaces" : {\r
- "CONFIG" : {\r
- "operations" : {\r
- "GenerateConfiguration" : {\r
- "inputs" : {\r
- "params" : {\r
- "required" : false,\r
- "type" : "list",\r
- "entry_schema" : {\r
- "type" : "datatype-property"\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "derived_from" : "tosca.nodes.DG"\r
- },\r
- "artifact-config-template" : {\r
- "description" : "This is Configuration Velocity Template",\r
- "version" : "1.0.0",\r
- "properties" : {\r
- "action-names" : {\r
- "required" : true,\r
- "type" : "list",\r
- "entry_schema" : {\r
- "type" : "string"\r
- }\r
- },\r
- "content" : {\r
- "required" : false,\r
- "type" : "string"\r
- },\r
- "mapping" : {\r
- "required" : false,\r
- "type" : "list",\r
- "entry_schema" : {\r
- "type" : "datatype-resource-assignment"\r
- }\r
- }\r
- },\r
- "capabilities" : {\r
- "content" : {\r
- "type" : "tosca.capabilities.Content",\r
- "properties" : {\r
- "content" : {\r
- "required" : true,\r
- "type" : "string"\r
- }\r
- }\r
- },\r
- "mapping" : {\r
- "type" : "tosca.capabilities.Mapping",\r
- "properties" : {\r
- "mapping" : {\r
- "required" : false,\r
- "type" : "list",\r
- "entry_schema" : {\r
- "type" : "datatype-resource-assignment"\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "derived_from" : "tosca.nodes.Artifact"\r
- },\r
- "component-resource-assignment" : {\r
- "description" : "This is Resource Assignment Component API",\r
- "version" : "1.0.0",\r
- "capabilities" : {\r
- "component-node" : {\r
- "type" : "tosca.capabilities.Node"\r
- }\r
- },\r
- "interfaces" : {\r
- "org-onap-ccsdk-features-assignment-service-ConfigAssignmentNode" : {\r
- "operations" : {\r
- "process" : {\r
- "inputs" : {\r
- "action-name" : {\r
- "description" : "Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",\r
- "required" : false,\r
- "type" : "string"\r
- },\r
- "handler-name" : {\r
- "description" : "Name of the Artifact Node Template, to get the template Content. If template-content is present, then content wont be reterived from the Artifact Node Template.",\r
- "required" : true,\r
- "type" : "string"\r
- },\r
- "resource-type" : {\r
- "required" : false,\r
- "type" : "string"\r
- },\r
- "template-names" : {\r
- "description" : "Name of the Artifact Node Templates, to get the template Content.",\r
- "required" : true,\r
- "type" : "list",\r
- "entry_schema" : {\r
- "type" : "string"\r
- }\r
- },\r
- "request-id" : {\r
- "description" : "Request Id used to store the generated configuration, in the database along with the template-name",\r
- "required" : true,\r
- "type" : "string"\r
- },\r
- "resource-id" : {\r
- "description" : "Id used to pull the data content from the data base. Either template-data or resource-id should be present",\r
- "required" : true,\r
- "type" : "string"\r
- }\r
- },\r
- "outputs" : {\r
- "resource-assignment-params" : {\r
- "required" : true,\r
- "type" : "string"\r
- },\r
- "status" : {\r
- "required" : true,\r
- "type" : "string"\r
- }\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "derived_from" : "tosca.nodes.Component"\r
- },\r
- "component-config-generator" : {\r
- "description" : "This is Generate Configuration Component API",\r
- "version" : "1.0.0",\r
- "capabilities" : {\r
- "component-node" : {\r
- "type" : "tosca.capabilities.Node"\r
- }\r
- },\r
- "interfaces" : {\r
- "org-onap-ccsdk-features-generator-service-ConfigGeneratorNode" : {\r
- "operations" : {\r
- "process" : {\r
- "inputs" : {\r
- "template-data" : {\r
- "description" : "Conditional : JSON string which is used to mash with template. Either template-data or ( resource-id and resource-type ) should be present",\r
- "required" : false,\r
- "type" : "string"\r
- },\r
- "action-name" : {\r
- "description" : "Conditional : Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",\r
- "required" : false,\r
- "type" : "string"\r
- },\r
- "template-content" : {\r
- "description" : "Conditional : Dynamic Template used to generate Configuration.",\r
- "required" : false,\r
- "type" : "string"\r
- },\r
- "resource-type" : {\r
- "description" : "Conditional : resource-type used to pull the data content from the data base. Either template-data or ( resource-id and resource-type ) should be present",\r
- "required" : false,\r
- "type" : "string"\r
- },\r
- "request-id" : {\r
- "description" : "Request Id used to store the generated configuration, in the database along with the template-name",\r
- "required" : true,\r
- "type" : "string"\r
- },\r
- "resource-id" : {\r
- "description" : "Conditional : Id used to pull the data content from the data base. Either template-data or ( resource-id and resource-type ) should be present",\r
- "required" : false,\r
- "type" : "string"\r
- },\r
- "template-name" : {\r
- "description" : "Conditional : Name of the Artifact Node Template, to get the template Content. If template-content is present, then content wont be reterived from the Artifact Node Template.",\r
- "required" : true,\r
- "type" : "string"\r
- }\r
- },\r
- "outputs" : {\r
- "generated-config" : {\r
- "description" : "Generated Configuration for the Template adn Resource Data",\r
- "required" : true,\r
- "type" : "string"\r
- },\r
- "mask-info" : {\r
- "description" : "If template contains mask encription keys, then this mask-info field will be generated, This JSON Content alligns to the bean org.onap.ccsdk.features.model.data.custom.MaskInfo ",\r
- "required" : false,\r
- "type" : "string"\r
- },\r
- "status" : {\r
- "description" : "Status of the Component Execution ( success or failure )",\r
- "required" : true,\r
- "type" : "string"\r
- }\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "derived_from" : "tosca.nodes.Component"\r
- }\r
- },\r
- "data_types" : {\r
- "datatype-resource-assignment" : {\r
- "version" : "1.0.0",\r
- "description" : "This is Resource Assignment Data Type",\r
- "properties" : {\r
- "property" : {\r
- "required" : true,\r
- "type" : "datatype-property"\r
- },\r
- "input-param" : {\r
- "required" : true,\r
- "type" : "boolean"\r
- },\r
- "dictionary-name" : {\r
- "required" : false,\r
- "type" : "string"\r
- },\r
- "dictionary-source" : {\r
- "required" : false,\r
- "type" : "string"\r
- },\r
- "dependencies" : {\r
- "required" : true,\r
- "type" : "list",\r
- "entry_schema" : {\r
- "type" : "string"\r
- }\r
- }\r
- },\r
- "derived_from" : "tosca.datatypes.Root"\r
- },\r
- "datatype-property" : {\r
- "version" : "1.0.0",\r
- "description" : "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs",\r
- "properties" : {\r
- "type" : {\r
- "required" : true,\r
- "type" : "string"\r
- },\r
- "description" : {\r
- "required" : false,\r
- "type" : "string"\r
- },\r
- "required" : {\r
- "required" : false,\r
- "type" : "boolean"\r
- },\r
- "default" : {\r
- "required" : false,\r
- "type" : "string"\r
- },\r
- "entry_schema" : {\r
- "required" : false,\r
- "type" : "string"\r
- }\r
- },\r
- "derived_from" : "tosca.datatypes.Root"\r
- }\r
- }\r
-}
\ No newline at end of file
+++ /dev/null
-[\r
- {\r
- "name": "security-manager-resource-key",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "security-manager-resource-key",\r
- "dictionary-source": "input"\r
- },\r
- {\r
- "name": "security-manager-resource-name",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "security-manager-resource-name",\r
- "dictionary-source": "input"\r
- },\r
- {\r
- "name": "snmp-server-ipv4-addresses",\r
- "input-param": true,\r
- "property": {\r
- "type": "list",\r
- "required": true,\r
- "entry_schema": {\r
- "type": "string"\r
- }\r
- },\r
- "dictionary-name": "snmp-server-ipv4-addresses",\r
- "dictionary-source": "network-resource-discovery",\r
- "dependencies": [\r
- "asn-region",\r
- "complex-code"\r
- ]\r
- },\r
- {\r
- "name": "snmp-community",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "snmp-community",\r
- "dictionary-source": "nsm",\r
- "dependencies": [\r
- "security-manager-resource-name",\r
- "security-manager-resource-key"\r
- ],\r
- "version": 0\r
- },\r
- {\r
- "name": "lo0-local-ipv4-address",\r
- "property": {\r
- "description": "",\r
- "required": true,\r
- "type": "string",\r
- "status": "",\r
- "constraints": [\r
- {\r
- \r
- }\r
- ],\r
- "value": {\r
- \r
- },\r
- "entry_schema": {\r
- "type": ""\r
- }\r
- },\r
- "input-param": false,\r
- "dictionary-name": "lo0-local-ipv4-address",\r
- "dictionary-source": "network-resource-discovery",\r
- "dependencies": [\r
- "hostname"\r
- ],\r
- "version": 0\r
- },\r
- {\r
- "name": "adig-urlb-route-reflectors",\r
- "property": {\r
- "description": "",\r
- "required": true,\r
- "type": "list",\r
- "status": "",\r
- "constraints": [\r
- {\r
- \r
- }\r
- ],\r
- "value": {\r
- \r
- },\r
- "entry_schema": {\r
- "type": "dt-adig-urlb-route-reflectors"\r
- }\r
- },\r
- "input-param": false,\r
- "dictionary-name": "adig-urlb-route-reflectors",\r
- "dictionary-source": "network-resource-discovery",\r
- "dependencies": [\r
- "region"\r
- ],\r
- "version": 0\r
- },\r
- {\r
- "name": "bundle-id",\r
- "property": {\r
- "description": "",\r
- "required": true,\r
- "type": "string",\r
- "status": "",\r
- "constraints": [\r
- {\r
- \r
- }\r
- ],\r
- "value": {\r
- \r
- },\r
- "entry_schema": {\r
- "type": ""\r
- }\r
- },\r
- "input-param": false,\r
- "dictionary-name": "bundle-id",\r
- "dictionary-source": "network-resource-discovery",\r
- "dependencies": [\r
- "hostname"\r
- ],\r
- "version": 0\r
- },\r
- {\r
- "name": "uplink-1-unit",\r
- "property": {\r
- "description": "",\r
- "required": true,\r
- "type": "integer",\r
- "status": "",\r
- "constraints": [\r
- {\r
- \r
- }\r
- ],\r
- "value": {\r
- \r
- },\r
- "entry_schema": {\r
- "type": ""\r
- }\r
- },\r
- "input-param": false,\r
- "dictionary-name": "uplink-1-unit",\r
- "dictionary-source": "network-resource-discovery",\r
- "dependencies": [\r
- "hostname"\r
- ],\r
- "version": 0\r
- },\r
- {\r
- "name": "uplink-2-unit",\r
- "property": {\r
- "description": "",\r
- "required": true,\r
- "type": "integer",\r
- "status": "",\r
- "constraints": [\r
- {\r
- \r
- }\r
- ],\r
- "value": {\r
- \r
- },\r
- "entry_schema": {\r
- "type": ""\r
- }\r
- },\r
- "input-param": false,\r
- "dictionary-name": "uplink-2-unit",\r
- "dictionary-source": "network-resource-discovery",\r
- "dependencies": [\r
- "hostname"\r
- ],\r
- "version": 0\r
- },\r
- {\r
- "name": "lo10-local-ipv4-address",\r
- "property": {\r
- "description": "",\r
- "required": true,\r
- "type": "string",\r
- "status": "",\r
- "constraints": [\r
- {\r
- \r
- }\r
- ],\r
- "value": {\r
- \r
- },\r
- "entry_schema": {\r
- "type": ""\r
- }\r
- },\r
- "input-param": false,\r
- "dictionary-name": "lo10-local-ipv4-address",\r
- "dictionary-source": "network-resource-discovery",\r
- "dependencies": [\r
- "hostname"\r
- ],\r
- "version": 0\r
- },\r
- {\r
- "name": "complex-code",\r
- "property": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "dictionary-name": "complex-code",\r
- "dictionary-source": "network-resource-discovery",\r
- "dependencies": [\r
- "hostname"\r
- ],\r
- "version": 0\r
- },\r
- {\r
- "name": "country-code",\r
- "property": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "dictionary-name": "country-code",\r
- "dictionary-source": "network-resource-discovery",\r
- "dependencies": [\r
- "hostname"\r
- ],\r
- "version": 0\r
- },\r
- {\r
- "name": "hostname",\r
- "property": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "dictionary-name": "hostname",\r
- "dictionary-source": "input",\r
- "version": 0\r
- },\r
- {\r
- "name": "region",\r
- "property": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "dictionary-name": "region",\r
- "dictionary-source": "network-resource-discovery",\r
- "dependencies": [\r
- "hostname"\r
- ],\r
- "version": 0\r
- }\r
-]
\ No newline at end of file
+++ /dev/null
-{\r
- "metadata": {\r
- "author": "ks220y@att.com",\r
- "service-template-name": "VRR-baseconfiguration",\r
- "service-template-version": "1.0.0",\r
- "release": "1802",\r
- "service-type": "AVPN",\r
- "vnf-type": "VRR"\r
- },\r
- "topology_template": {\r
- "inputs": {\r
- "request-id": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "service-instance-id": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "action-name": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "scope-type": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "hostname": {\r
- "required": true,\r
- "type": "string"\r
- }\r
- },\r
- "node_templates": {\r
- "base-config-template": {\r
- "type": "artifact-config-template",\r
- "properties": {\r
- "action-names": [\r
- "resource-assignment-action"\r
- ]\r
- },\r
- "capabilities": {\r
- "content": {\r
- "properties": {\r
- "content": "db://base-config-template"\r
- }\r
- },\r
- "mapping": {\r
- "properties": {\r
- "mapping": [\r
- {\r
- "name": "vnf-id",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "vnf-id",\r
- "dictionary-source": "input"\r
- },\r
- {\r
- "name": "group-name",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "group-name",\r
- "dictionary-source": "input"\r
- }\r
- ]\r
- }\r
- }\r
- }\r
- },\r
- "resource-assignment-action": {\r
- "type": "dg-resource-assignment",\r
- "interfaces": {\r
- "CONFIG": {\r
- "operations": {\r
- "ResourceAssignment": {\r
- \r
- }\r
- }\r
- }\r
- },\r
- "capabilities": {\r
- "dg-node": {\r
- \r
- }\r
- },\r
- "requirements": {\r
- "component-dependency": {\r
- "capability": "component-node",\r
- "node": "resource-assignment",\r
- "relationship": "tosca.relationships.DependsOn"\r
- }\r
- }\r
- },\r
- "licence-template": {\r
- "type": "artifact-config-template",\r
- "properties": {\r
- "action-names": [\r
- "resource-assignment-action"\r
- ]\r
- },\r
- "capabilities": {\r
- "content": {\r
- "properties": {\r
- "content": "db://licence-template"\r
- }\r
- },\r
- "mapping": {\r
- "properties": {\r
- "mapping": [\r
- {\r
- "name": "bundle-id",\r
- "input-param": true,\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "bundle-id",\r
- "dictionary-source": "input"\r
- },\r
- {\r
- "name": "bundle-mac",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "bundle-mac",\r
- "dictionary-source": "input"\r
- }\r
- ]\r
- }\r
- }\r
- }\r
- },\r
- "resource-assignment": {\r
- "type": "component-resource-assignment",\r
- "interfaces": {\r
- "org-onap-ccsdk-features-assignment-service-ConfigAssignmentNode": {\r
- "operations": {\r
- "process": {\r
- "inputs": {\r
- "action-name": "{ \"get_input\" : \"action-name\" }",\r
- "resource-type": "vnf-type",\r
- "template-names": [\r
- "base-config-template",\r
- "licence-template"\r
- ],\r
- "request-id": "{ \"get_input\" : \"request-id\" }",\r
- "resource-id": "{ \"get_input\" : \"vnf-id\" }"\r
- },\r
- "outputs": {\r
- "resource-assignment-params": "",\r
- "status": ""\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "capabilities": {\r
- "component-node": {\r
- \r
- }\r
- }\r
- }\r
- }\r
- },\r
- "node_types": {\r
- "dg-resource-assignment": {\r
- "description": "This is Resource Assignment Directed Graph",\r
- "version": "1.0.0",\r
- "properties": {\r
- "mode": {\r
- "required": false,\r
- "type": "string",\r
- "default": "sync"\r
- },\r
- "version": {\r
- "required": false,\r
- "type": "string",\r
- "default": "LATEST"\r
- },\r
- "is-start-flow": {\r
- "required": false,\r
- "type": "boolean",\r
- "default": "false"\r
- }\r
- },\r
- "capabilities": {\r
- "dg-node": {\r
- "type": "tosca.capabilities.Node"\r
- },\r
- "content": {\r
- "type": "tosca.capabilities.Content",\r
- "properties": {\r
- "type": {\r
- "required": false,\r
- "type": "string",\r
- "default": "json"\r
- },\r
- "content": {\r
- "required": true,\r
- "type": "string"\r
- }\r
- }\r
- }\r
- },\r
- "requirements": {\r
- "component-dependency": {\r
- "capability": "component-node",\r
- "node": "component-resource-assignment",\r
- "relationship": "tosca.relationships.DependsOn"\r
- }\r
- },\r
- "interfaces": {\r
- "CONFIG": {\r
- "operations": {\r
- "ResourceAssignment": {\r
- "inputs": {\r
- "params": {\r
- "required": false,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "datatype-property"\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "derived_from": "tosca.nodes.DG"\r
- },\r
- "component-resource-assignment": {\r
- "description": "This is Resource Assignment Component API",\r
- "version": "1.0.0",\r
- "capabilities": {\r
- "component-node": {\r
- "type": "tosca.capabilities.Node"\r
- }\r
- },\r
- "interfaces": {\r
- "org-onap-ccsdk-features-assignment-service-ConfigAssignmentNode": {\r
- "operations": {\r
- "process": {\r
- "inputs": {\r
- "action-name": {\r
- "description": "Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",\r
- "required": false,\r
- "type": "string"\r
- },\r
- "handler-name": {\r
- "description": "Name of the Artifact Node Template, to get the template Content. If template-content is present, then content wont be reterived from the Artifact Node Template.",\r
- "required": true,\r
- "type": "string"\r
- },\r
- "resource-type": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "template-names": {\r
- "description": "Name of the Artifact Node Templates, to get the template Content.",\r
- "required": true,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "string"\r
- }\r
- },\r
- "request-id": {\r
- "description": "Request Id used to store the generated configuration, in the database along with the template-name",\r
- "required": true,\r
- "type": "string"\r
- },\r
- "resource-id": {\r
- "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present",\r
- "required": true,\r
- "type": "string"\r
- }\r
- },\r
- "outputs": {\r
- "resource-assignment-params": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "status": {\r
- "required": true,\r
- "type": "string"\r
- }\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "derived_from": "tosca.nodes.Component"\r
- },\r
- "artifact-config-template": {\r
- "description": "This is Configuration Velocity Template",\r
- "version": "1.0.0",\r
- "properties": {\r
- "action-names": {\r
- "required": true,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "string"\r
- }\r
- },\r
- "content": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "mapping": {\r
- "required": false,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "datatype-resource-assignment"\r
- }\r
- }\r
- },\r
- "capabilities": {\r
- "content": {\r
- "type": "tosca.capabilities.Content",\r
- "properties": {\r
- "content": {\r
- "required": true,\r
- "type": "string"\r
- }\r
- }\r
- },\r
- "mapping": {\r
- "type": "tosca.capabilities.Mapping",\r
- "properties": {\r
- "mapping": {\r
- "required": false,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "datatype-resource-assignment"\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "derived_from": "tosca.nodes.Artifact"\r
- }\r
- },\r
- "data_types": {\r
- "datatype-resource-assignment": {\r
- "version": "1.0.0",\r
- "description": "This is Resource Assignment Data Type",\r
- "properties": {\r
- "property": {\r
- "required": true,\r
- "type": "datatype-property"\r
- },\r
- "input-param": {\r
- "required": true,\r
- "type": "boolean"\r
- },\r
- "dictionary-name": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "dictionary-source": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "dependencies": {\r
- "required": true,\r
- "type": "list",\r
- "entry_schema": {\r
- "type": "string"\r
- }\r
- }\r
- },\r
- "derived_from": "tosca.datatypes.Root"\r
- },\r
- "datatype-property": {\r
- "version": "1.0.0",\r
- "description": "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs",\r
- "properties": {\r
- "type": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "description": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "required": {\r
- "required": false,\r
- "type": "boolean"\r
- },\r
- "default": {\r
- "required": false,\r
- "type": "string"\r
- },\r
- "entry_schema": {\r
- "required": false,\r
- "type": "string"\r
- }\r
- },\r
- "derived_from": "tosca.datatypes.Root"\r
- }\r
- }\r
-}\r
+++ /dev/null
-This is sample Base Configuration for ${bundle-id} for ${bundle-mac}
\ No newline at end of file
+++ /dev/null
-{\r
- "metadata": {\r
- "author": "ks220y@att.com",\r
- "service-template-name": "VRR-baseconfiguration",\r
- "service-template-version": "1.0.0",\r
- "release": "1802",\r
- "service-type": "AVPN",\r
- "vnf-type": "VRR"\r
- },\r
- "topology_template": {\r
- "inputs": {\r
- "request-id": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "service-instance-id": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "action-name": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "scope-type": {\r
- "required": true,\r
- "type": "string"\r
- },\r
- "hostname": {\r
- "required": true,\r
- "type": "string"\r
- }\r
- },\r
- "node_templates": {\r
- "base-config-template": {\r
- "type": "artifact-config-template",\r
- "properties": {\r
- "action-names": [\r
- "resource-assignment-action"\r
- ]\r
- },\r
- "capabilities": {\r
- "content": {\r
- "properties": {\r
- "content": "db://base-config-template"\r
- }\r
- },\r
- "mapping": {\r
- "properties": {\r
- "mapping": [\r
- {\r
- "name": "vnf-id",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "vnf-id",\r
- "dictionary-source": "input"\r
- },\r
- {\r
- "name": "group-name",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "group-name",\r
- "dictionary-source": "input"\r
- }\r
- ]\r
- }\r
- }\r
- }\r
- },\r
- "resource-assignment-action": {\r
- "type": "dg-resource-assignment",\r
- "interfaces": {\r
- "CONFIG": {\r
- "operations": {\r
- "ResourceAssignment": {\r
- \r
- }\r
- }\r
- }\r
- },\r
- "capabilities": {\r
- "dg-node": {\r
- \r
- }\r
- },\r
- "requirements": {\r
- "component-dependency": {\r
- "capability": "component-node",\r
- "node": "resource-assignment",\r
- "relationship": "tosca.relationships.DependsOn"\r
- }\r
- }\r
- },\r
- "licence-template": {\r
- "type": "artifact-config-template",\r
- "properties": {\r
- "action-names": [\r
- "resource-assignment-action"\r
- ]\r
- },\r
- "capabilities": {\r
- "content": {\r
- "properties": {\r
- "content": "db://licence-template"\r
- }\r
- },\r
- "mapping": {\r
- "properties": {\r
- "mapping": [\r
- {\r
- "name": "bundle-id",\r
- "input-param": true,\r
- "property": {\r
- "type": "string"\r
- },\r
- "dictionary-name": "bundle-id",\r
- "dictionary-source": "input"\r
- },\r
- {\r
- "name": "bundle-mac",\r
- "input-param": true,\r
- "property": {\r
- "type": "string",\r
- "required": true\r
- },\r
- "dictionary-name": "bundle-mac",\r
- "dictionary-source": "input"\r
- }\r
- ]\r
- }\r
- }\r
- }\r
- },\r
- "resource-assignment": {\r
- "type": "component-resource-assignment",\r
- "interfaces": {\r
- "org-onap-ccsdk-features-assignment-service-ConfigAssignmentNode": {\r
- "operations": {\r
- "process": {\r
- "inputs": {\r
- "action-name": "{ \"get_input\" : \"action-name\" }",\r
- "resource-type": "vnf-type",\r
- "template-names": [\r
- "base-config-template",\r
- "licence-template"\r
- ],\r
- "request-id": "{ \"get_input\" : \"request-id\" }",\r
- "resource-id": "{ \"get_input\" : \"vnf-id\" }"\r
- },\r
- "outputs": {\r
- "resource-assignment-params": "",\r
- "status": ""\r
- }\r
- }\r
- }\r
- }\r
- },\r
- "capabilities": {\r
- "component-node": {\r
- \r
- }\r
- }\r
- }\r
- }\r
- }\r
-}
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright © 2017-2018 AT&T Intellectual Property.
- Modifications Copyright © 2018 IBM.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onap.ccsdk.parent</groupId>
- <artifactId>odlparent-lite</artifactId>
- <version>1.5.2-SNAPSHOT</version>
- <relativePath/>
- </parent>
-
- <groupId>org.onap.ccsdk.features</groupId>
- <artifactId>blueprints-processor-plugin</artifactId>
- <version>0.7.1-SNAPSHOT</version>
- <packaging>pom</packaging>
-
- <name>ccsdk-features :: ${project.artifactId}</name>
- <description>Blueprints Processor Plugins - POM</description>
-
- <modules>
- <module>model-provider</module>
- <module>assignment-provider</module>
- <module>generator-provider</module>
- </modules>
-</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright © 2017-2018 AT&T Intellectual Property.
- Modifications Copyright © 2018 IBM.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onap.ccsdk.parent</groupId>
- <artifactId>odlparent-lite</artifactId>
- <version>1.5.2-SNAPSHOT</version>
- <relativePath/>
- </parent>
-
- <groupId>org.onap.ccsdk.features</groupId>
- <artifactId>blueprints-processor</artifactId>
- <version>0.7.1-SNAPSHOT</version>
- <packaging>pom</packaging>
-
- <name>ccsdk-features :: ${project.artifactId}</name>
- <description>Blueprints Processor Blueprints Processor</description>
-
- <modules>
- <module>adaptors</module>
- <module>plugin</module>
- <module>features</module>
- <module>installer</module>
- </modules>
-</project>
<name>ccsdk-features :: features :: ${project.artifactId}</name>
<dependencies>
- <dependency>
- <groupId>org.onap.ccsdk.features</groupId>
- <artifactId>ccsdk-blueprints-processor</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
<dependency>
<groupId>org.onap.ccsdk.features</groupId>
<artifactId>ccsdk-aafshiro</artifactId>
<module>features</module>
<module>sdnr/wt</module>
<module>sdnr/northbound</module>
- <module>blueprints-processor</module>
<module>aafshiro</module>
</modules>