aboutsummaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules/service/src/main/java
diff options
context:
space:
mode:
authorSingal, Kapil (ks220y) <ks220y@att.com>2018-08-09 20:47:29 +0000
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-08-10 18:48:54 +0000
commitaa7486577fb66e85a5bb220438946579695b27b8 (patch)
treefe93c4ce0441b82d9b185b5be4e93255cc2cdbac /ms/controllerblueprints/modules/service/src/main/java
parent3db41eeb5c71efe3153ab5761a7b0ad091a56399 (diff)
Controller Blueprints MS
Creating the base directory structure for Controller Blueprints MicroService Change-Id: I1ccf7fc76446048af3b2822f9155bb634657aee3 Issue-ID: CCSDK-410 Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com>
Diffstat (limited to 'ms/controllerblueprints/modules/service/src/main/java')
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/AutoResourceMappingService.java211
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerRepoDBService.java100
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java207
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelCreateService.java339
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelService.java247
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelValidatorService.java67
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java325
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeService.java178
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java169
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java116
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ServiceTemplateService.java140
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ApplicationConstants.java33
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ErrorMessage.java63
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ServiceExceptionMapper.java42
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SwaggerGenerator.java187
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java291
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java175
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelSearch.java171
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java170
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java207
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/model/AutoMapResponse.java53
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelContentRepository.java95
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelRepository.java90
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelSearchRepository.java43
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java98
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryRepository.java68
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java179
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestImpl.java116
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java125
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestImpl.java87
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java126
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestImpl.java91
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java134
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestImpl.java94
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java124
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java200
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ResourceDictionaryValidator.java88
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java123
38 files changed, 5372 insertions, 0 deletions
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/AutoResourceMappingService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/AutoResourceMappingService.java
new file mode 100644
index 00000000..6b09c81f
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/AutoResourceMappingService.java
@@ -0,0 +1,211 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DictionaryDefinition;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryUtils;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
+import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * AutoResourceMappingService.java Purpose: Provide Automapping of Resource Assignments AutoResourceMappingService
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+
+@Service
+public class AutoResourceMappingService {
+
+ private static Logger log = LoggerFactory.getLogger(AutoResourceMappingService.class);
+
+ private ResourceDictionaryRepository dataDictionaryRepository;
+
+ /**
+ * This is a AutoResourceMappingService constructor
+ *
+ * @param dataDictionaryRepository
+ *
+ */
+ public AutoResourceMappingService(ResourceDictionaryRepository dataDictionaryRepository) {
+ this.dataDictionaryRepository = dataDictionaryRepository;
+ }
+
+ /**
+ * This is a autoMap service to map the template keys automatically to Dictionary fields.
+ *
+ * @param resourceAssignments
+ * @return AutoMapResponse
+ */
+ public AutoMapResponse autoMap(List<ResourceAssignment> resourceAssignments) throws BluePrintException {
+ AutoMapResponse autoMapResponse = new AutoMapResponse();
+ try {
+ if (CollectionUtils.isNotEmpty(resourceAssignments)) {
+
+ // Create the Dictionary definitions for the ResourceAssignment Names
+ Map<String, ResourceDictionary> dictionaryMap = getDictionaryDefinitions(resourceAssignments);
+
+ for (ResourceAssignment resourceAssignment : resourceAssignments) {
+ if (resourceAssignment != null && StringUtils.isNotBlank(resourceAssignment.getName())
+ && StringUtils.isBlank(resourceAssignment.getDictionaryName())) {
+
+ populateDictionaryMapping(dictionaryMap, resourceAssignment);
+
+ log.info("Mapped Resource : {}", resourceAssignment);
+
+ } else {
+ // Do nothins
+ }
+ }
+ }
+ List<ResourceDictionary> dictionaries = getDictionaryDefinitionsList(resourceAssignments);
+ List<ResourceAssignment> resourceAssignmentsFinal = getAllAutomapResourceAssignments(resourceAssignments);
+ autoMapResponse.setDataDictionaries(dictionaries);
+ autoMapResponse.setResourceAssignments(resourceAssignmentsFinal);
+ } catch (Exception e) {
+ log.error(String.format("Failed in auto process %s", e.getMessage()));
+ throw new BluePrintException(e.getMessage(), e);
+ }
+ return autoMapResponse;
+ }
+
+ private void populateDictionaryMapping(Map<String, ResourceDictionary> dictionaryMap, ResourceAssignment resourceAssignment) {
+ ResourceDictionary dbDataDictionary = dictionaryMap.get(resourceAssignment.getName());
+ if (dbDataDictionary != null && StringUtils.isNotBlank(dbDataDictionary.getDefinition())) {
+
+ DictionaryDefinition dictionaryDefinition = JacksonUtils.readValue(dbDataDictionary.getDefinition(), DictionaryDefinition.class);
+
+ if (dictionaryDefinition != null && StringUtils.isNotBlank(dictionaryDefinition.getName())
+ && StringUtils.isBlank(resourceAssignment.getDictionaryName())) {
+
+ resourceAssignment.setDictionaryName(dbDataDictionary.getName());
+ ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition);
+ }
+ }
+ }
+
+ private Map<String, ResourceDictionary> getDictionaryDefinitions(List<ResourceAssignment> resourceAssignments) {
+ Map<String, ResourceDictionary> dictionaryMap = new HashMap<>();
+ List<String> names = new ArrayList<>();
+ for (ResourceAssignment resourceAssignment : resourceAssignments) {
+ if (resourceAssignment != null && StringUtils.isNotBlank(resourceAssignment.getName())) {
+ names.add(resourceAssignment.getName());
+ }
+ }
+ if (CollectionUtils.isNotEmpty(names)) {
+
+ List<ResourceDictionary> dictionaries = dataDictionaryRepository.findByNameIn(names);
+ if (CollectionUtils.isNotEmpty( dictionaries)) {
+ for (ResourceDictionary dataDictionary : dictionaries) {
+ if (dataDictionary != null && StringUtils.isNotBlank(dataDictionary.getName())) {
+ dictionaryMap.put(dataDictionary.getName(), dataDictionary);
+ }
+ }
+ }
+ }
+ return dictionaryMap;
+
+ }
+
+ private List<ResourceDictionary> getDictionaryDefinitionsList(List<ResourceAssignment> resourceAssignments) {
+ List<ResourceDictionary> dictionaries = null;
+ List<String> names = new ArrayList<>();
+ for (ResourceAssignment resourceAssignment : resourceAssignments) {
+ if (resourceAssignment != null && StringUtils.isNotBlank(resourceAssignment.getDictionaryName())) {
+
+ if (!names.contains(resourceAssignment.getDictionaryName())) {
+ names.add(resourceAssignment.getDictionaryName());
+ }
+
+ if (resourceAssignment.getDependencies() != null && !resourceAssignment.getDependencies().isEmpty()) {
+ List<String> dependencyNames = resourceAssignment.getDependencies();
+ for (String dependencyName : dependencyNames) {
+ if (StringUtils.isNotBlank(dependencyName) && !names.contains(dependencyName)) {
+ names.add(dependencyName);
+ }
+ }
+ }
+ }
+ }
+ if (CollectionUtils.isNotEmpty(names)) {
+ dictionaries = dataDictionaryRepository.findByNameIn(names);
+ }
+ return dictionaries;
+
+ }
+
+ private List<ResourceAssignment> getAllAutomapResourceAssignments(List<ResourceAssignment> resourceAssignments) {
+ List<ResourceDictionary> dictionaries = null;
+ List<String> names = new ArrayList<>();
+ List<ResourceAssignment> resourceAssignmentsWithDepencies = resourceAssignments;
+ for (ResourceAssignment resourceAssignment : resourceAssignments) {
+ if (resourceAssignment != null && StringUtils.isNotBlank(resourceAssignment.getDictionaryName())) {
+ if (resourceAssignment.getDependencies() != null && !resourceAssignment.getDependencies().isEmpty()) {
+ List<String> dependencieNames = resourceAssignment.getDependencies();
+ for (String dependencieName : dependencieNames) {
+ if (StringUtils.isNotBlank(dependencieName) && !names.contains(dependencieName)
+ && !checkAssignmentsExists(resourceAssignmentsWithDepencies, dependencieName)) {
+ names.add(dependencieName);
+ }
+ }
+ }
+ }
+ }
+
+ if (!names.isEmpty()) {
+ dictionaries = dataDictionaryRepository.findByNameIn(names);
+ }
+ if (dictionaries != null) {
+ for (ResourceDictionary resourcedictionary : dictionaries) {
+ DictionaryDefinition dictionaryDefinition = JacksonUtils.readValue(resourcedictionary.getDefinition(), DictionaryDefinition.class);
+ PropertyDefinition property = new PropertyDefinition();
+ property.setRequired(true);
+ ResourceAssignment resourceAssignment = new ResourceAssignment();
+ resourceAssignment.setName(resourcedictionary.getName());
+ resourceAssignment.setDictionaryName(resourcedictionary
+ .getName());
+ resourceAssignment.setVersion(0);
+ resourceAssignment.setProperty(property);
+ ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition);
+ resourceAssignmentsWithDepencies.add(resourceAssignment);
+ }
+ }
+ return resourceAssignmentsWithDepencies;
+
+ }
+
+
+ public boolean checkAssignmentsExists(List<ResourceAssignment> resourceAssignmentsWithDepencies, String resourceName) {
+ return resourceAssignmentsWithDepencies.stream().anyMatch(names -> names.getName().equalsIgnoreCase(resourceName));
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerRepoDBService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerRepoDBService.java
new file mode 100644
index 00000000..a2e5b104
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerRepoDBService.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service;
+
+import com.google.common.base.Preconditions;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.*;
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerRepoService;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ModelTypeRepository;
+import org.springframework.stereotype.Service;
+
+import java.util.Optional;
+
+/**
+ * BluePrintEnhancerRepoDBService
+ *
+ * @author Brinda Santh
+ */
+@Service
+public class BluePrintEnhancerRepoDBService implements BluePrintEnhancerRepoService {
+
+ private ModelTypeRepository modelTypeRepository;
+
+ public BluePrintEnhancerRepoDBService(ModelTypeRepository modelTypeRepository) {
+ this.modelTypeRepository = modelTypeRepository;
+ }
+
+
+ @Override
+ public NodeType getNodeType(String nodeTypeName) throws BluePrintException {
+ Preconditions.checkArgument(StringUtils.isNotBlank(nodeTypeName), "NodeType name is missing");
+ String content = getModelDefinitions(nodeTypeName);
+ Preconditions.checkArgument(StringUtils.isNotBlank(content), "NodeType content is missing");
+ return JacksonUtils.readValue(content, NodeType.class);
+ }
+
+
+ @Override
+ public DataType getDataType(String dataTypeName) throws BluePrintException {
+ Preconditions.checkArgument(StringUtils.isNotBlank(dataTypeName), "DataType name is missing");
+ String content = getModelDefinitions(dataTypeName);
+ Preconditions.checkArgument(StringUtils.isNotBlank(content), "DataType content is missing");
+ return JacksonUtils.readValue(content, DataType.class);
+ }
+
+
+ @Override
+ public ArtifactType getArtifactType(String artifactTypeName) throws BluePrintException {
+ Preconditions.checkArgument(StringUtils.isNotBlank(artifactTypeName), "ArtifactType name is missing");
+ String content = getModelDefinitions(artifactTypeName);
+ Preconditions.checkArgument(StringUtils.isNotBlank(content), "ArtifactType content is missing");
+ return JacksonUtils.readValue(content, ArtifactType.class);
+ }
+
+
+ @Override
+ public RelationshipType getRelationshipType(String relationshipTypeName) throws BluePrintException {
+ Preconditions.checkArgument(StringUtils.isNotBlank(relationshipTypeName), "RelationshipType name is missing");
+ String content = getModelDefinitions(relationshipTypeName);
+ Preconditions.checkArgument(StringUtils.isNotBlank(content), "RelationshipType content is missing");
+ return JacksonUtils.readValue(content, RelationshipType.class);
+ }
+
+
+ @Override
+ public CapabilityDefinition getCapabilityDefinition(String capabilityDefinitionName) throws BluePrintException {
+ Preconditions.checkArgument(StringUtils.isNotBlank(capabilityDefinitionName), "CapabilityDefinition name is missing");
+ String content = getModelDefinitions(capabilityDefinitionName);
+ Preconditions.checkArgument(StringUtils.isNotBlank(content), "CapabilityDefinition content is missing");
+ return JacksonUtils.readValue(content, CapabilityDefinition.class);
+ }
+
+ private String getModelDefinitions(String modelName) throws BluePrintException {
+ String modelDefinition = null;
+ Optional<ModelType> modelTypedb = modelTypeRepository.findByModelName(modelName);
+ if (modelTypedb.isPresent()) {
+ modelDefinition = modelTypedb.get().getDefinition();
+ } else {
+ throw new BluePrintException(String.format("failed to get model definition (%s) from repo", modelName));
+ }
+ return modelDefinition;
+ }
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java
new file mode 100644
index 00000000..afd12f21
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java
@@ -0,0 +1,207 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.base.Preconditions;
+import org.apache.commons.lang3.StringUtils;
+import org.jetbrains.annotations.NotNull;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.*;
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerDefaultService;
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerRepoService;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * BluePrintEnhancerService
+ *
+ * @author Brinda Santh DATE : 8/8/2018
+ */
+
+@Service
+public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService {
+
+ private static Logger log = LoggerFactory.getLogger(BluePrintEnhancerService.class);
+
+ private HashMap<String, DataType> recipeDataTypes = new HashMap<>();
+
+ public BluePrintEnhancerService(BluePrintEnhancerRepoService bluePrintEnhancerRepoDBService) {
+ super(bluePrintEnhancerRepoDBService);
+ }
+
+ @Override
+ public void enrichTopologyTemplate(@NotNull ServiceTemplate serviceTemplate) {
+ super.enrichTopologyTemplate(serviceTemplate);
+
+ // Update the Recipe Inputs and DataTypes
+ populateRecipeInputs(serviceTemplate);
+ }
+
+
+ @Override
+ public void enrichNodeTemplate(@NotNull String nodeTemplateName, @NotNull NodeTemplate nodeTemplate) throws BluePrintException {
+ super.enrichNodeTemplate(nodeTemplateName, nodeTemplate);
+
+ String nodeTypeName = nodeTemplate.getType();
+ log.info("*** Enriching NodeType: {}", nodeTypeName);
+ // Get NodeType from Repo and Update Service Template
+ NodeType nodeType = super.populateNodeType(nodeTypeName);
+
+ // Enrich NodeType
+ super.enrichNodeType(nodeTypeName, nodeType);
+
+ // Custom for Artifact Population
+ if (StringUtils.isNotBlank(nodeType.getDerivedFrom())
+ && ConfigModelConstant.MODEL_TYPE_NODE_ARTIFACT.equalsIgnoreCase(nodeType.getDerivedFrom())) {
+ populateArtifactTemplateMappingDataType(nodeTemplateName, nodeTemplate);
+ }
+
+ //Enrich Node Template Artifacts
+ super.enrichNodeTemplateArtifactDefinition(nodeTemplateName, nodeTemplate);
+
+ }
+
+
+ private void populateArtifactTemplateMappingDataType(@NotNull String nodeTemplateName, @NotNull NodeTemplate nodeTemplate)
+ throws BluePrintException {
+ log.info("****** Processing Artifact Node Template : {}", nodeTemplateName);
+
+ if (nodeTemplate.getProperties() != null) {
+
+ if (!nodeTemplate.getProperties().containsKey(ConfigModelConstant.PROPERTY_RECIPE_NAMES)) {
+ throw new BluePrintException("Node Template (" + nodeTemplateName + ") doesn't have "
+ + ConfigModelConstant.PROPERTY_RECIPE_NAMES + " property.");
+ }
+
+ // Modified for ONAP converted Object to JsonNode
+ JsonNode recipeNames = nodeTemplate.getProperties().get(ConfigModelConstant.PROPERTY_RECIPE_NAMES);
+
+ log.info("Processing Receipe Names : {} ", recipeNames);
+
+ if (recipeNames != null && recipeNames.isArray() && recipeNames.size() > 0) {
+
+ Map<String, PropertyDefinition> mappingProperties =
+ getCapabilityMappingProperties(nodeTemplateName, nodeTemplate);
+
+ for (JsonNode recipeNameNode : recipeNames) {
+ String recipeName = recipeNameNode.textValue();
+ processRecipe(nodeTemplateName, mappingProperties, recipeName);
+ }
+ }
+ }
+ }
+
+ private void processRecipe(@NotNull String nodeTemplateName, Map<String, PropertyDefinition> mappingProperties, String recipeName) {
+ if (StringUtils.isNotBlank(recipeName)) {
+ DataType recipeDataType = this.recipeDataTypes.get(recipeName);
+ if (recipeDataType == null) {
+ log.info("DataType not present for the recipe({})" , recipeName);
+ recipeDataType = new DataType();
+ recipeDataType.setVersion("1.0.0");
+ recipeDataType.setDescription(
+ "This is Dynamic Data type definition generated from resource mapping for the config template name "
+ + nodeTemplateName + ".");
+ recipeDataType.setDerivedFrom(ConfigModelConstant.MODEL_TYPE_DATA_TYPE_DYNAMIC);
+ Map<String, PropertyDefinition> dataTypeProperties = new HashMap<>();
+ recipeDataType.setProperties(dataTypeProperties);
+ } else {
+ log.info("DataType Already present for the recipe({})" , recipeName);
+ }
+
+ // Merge all the Recipe Properties
+ mergeDataTypeProperties(recipeDataType, mappingProperties);
+
+ // Overwrite Recipe DataType
+ this.recipeDataTypes.put(recipeName, recipeDataType);
+
+ }
+ }
+
+ private Map<String, PropertyDefinition> getCapabilityMappingProperties(String nodeTemplateName,
+ NodeTemplate nodeTemplate) {
+
+ Map<String, PropertyDefinition> dataTypeProperties = null;
+ if (nodeTemplate != null) {
+ CapabilityAssignment capability =
+ nodeTemplate.getCapabilities().get(ConfigModelConstant.CAPABILITY_PROPERTY_MAPPING);
+
+ if (capability != null && capability.getProperties() != null) {
+
+ String resourceAssignmentContent = JacksonUtils
+ .getJson(capability.getProperties().get(ConfigModelConstant.CAPABILITY_PROPERTY_MAPPING));
+
+ List<ResourceAssignment> resourceAssignments =
+ JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment.class);
+
+ Preconditions.checkNotNull(resourceAssignments, "Failed to Processing Resource Mapping " + resourceAssignmentContent);
+ dataTypeProperties = new HashMap<>();
+
+ for (ResourceAssignment resourceAssignment : resourceAssignments) {
+ if (resourceAssignment != null
+ // && Boolean.valueOf(resourceAssignment.getInputParameter())
+ && resourceAssignment.getProperty() != null
+ && StringUtils.isNotBlank(resourceAssignment.getName())) {
+
+ // Enrich the Property Definition
+ super.enrichPropertyDefinition(resourceAssignment.getName(), resourceAssignment.getProperty());
+
+ dataTypeProperties.put(resourceAssignment.getName(), resourceAssignment.getProperty());
+
+ }
+ }
+
+ }
+ }
+ return dataTypeProperties;
+ }
+
+ private void mergeDataTypeProperties(DataType dataType, Map<String, PropertyDefinition> mergeProperties) {
+ if (dataType != null && dataType.getProperties() != null && mergeProperties != null) {
+ // Add the Other Template Properties
+ mergeProperties.forEach((mappingKey, propertyDefinition) -> {
+ dataType.getProperties().put(mappingKey, propertyDefinition);
+ });
+ }
+ }
+
+ private void populateRecipeInputs(ServiceTemplate serviceTemplate) {
+ if (this.recipeDataTypes != null && !this.recipeDataTypes.isEmpty()) {
+ this.recipeDataTypes.forEach((recipeName, recipeDataType) -> {
+ String dataTypePrifix = recipeName.replace("-action", "") + "-request";
+ String dataTypeName = "dt-" + dataTypePrifix;
+
+ serviceTemplate.getDataTypes().put(dataTypeName, recipeDataType);
+
+ PropertyDefinition customInputProperty = new PropertyDefinition();
+ customInputProperty.setDescription("This is Dynamic Data type for the receipe " + recipeName + ".");
+ customInputProperty.setRequired(Boolean.FALSE);
+ customInputProperty.setType(dataTypeName);
+ serviceTemplate.getTopologyTemplate().getInputs().put(dataTypePrifix, customInputProperty);
+
+ });
+ }
+ }
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelCreateService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelCreateService.java
new file mode 100644
index 00000000..7e96f2f8
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelCreateService.java
@@ -0,0 +1,339 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service;
+
+import com.google.common.base.Preconditions;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.service.common.ApplicationConstants;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ConfigModelRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * ServiceTemplateCreateService.java Purpose: Provide Service Template Create Service processing
+ * ServiceTemplateCreateService
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+
+@Service
+public class ConfigModelCreateService {
+
+ private static Logger log = LoggerFactory.getLogger(ConfigModelCreateService.class);
+
+ private ConfigModelRepository configModelRepository;
+ private ConfigModelValidatorService configModelValidatorService;
+
+ /**
+ * This is a ConfigModelCreateService
+ *
+ * @param configModelRepository ConfigModelRepository
+ * @param configModelValidatorService ConfigModelValidatorService
+ */
+ public ConfigModelCreateService(ConfigModelRepository configModelRepository,
+ ConfigModelValidatorService configModelValidatorService) {
+ this.configModelRepository = configModelRepository;
+ this.configModelValidatorService = configModelValidatorService;
+ }
+
+ /**
+ * This is a createInitialServiceTemplateContent method
+ *
+ * @param templateName templateName
+ * @return String
+ * @throws BluePrintException BluePrintException
+ */
+ public String createInitialServiceTemplateContent(String templateName) throws BluePrintException {
+ String serviceTemplateContent = null;
+ if (StringUtils.isNotBlank(templateName)) {
+ try {
+ serviceTemplateContent = IOUtils.toString(ConfigModelCreateService.class.getClassLoader()
+ .getResourceAsStream("service_template/" + templateName + ".json"), Charset.defaultCharset());
+ } catch (IOException e) {
+ throw new BluePrintException(e.getMessage(), e);
+ }
+
+ }
+ return serviceTemplateContent;
+ }
+
+ /**
+ * This is a createInitialServiceTemplate method
+ *
+ * @param templateName templateName
+ * @return ServiceTemplate
+ * @throws BluePrintException BluePrintException
+ */
+ public ServiceTemplate createInitialServiceTemplate(String templateName) throws BluePrintException {
+ ServiceTemplate serviceTemplate = null;
+ if (StringUtils.isNotBlank(templateName)) {
+ try {
+ String serviceTemplateContent = IOUtils.toString(ConfigModelCreateService.class.getClassLoader()
+ .getResourceAsStream("service_template/" + templateName + ".json"), Charset.defaultCharset());
+ if (StringUtils.isNotBlank(serviceTemplateContent)) {
+ serviceTemplate = JacksonUtils.readValue(serviceTemplateContent, ServiceTemplate.class);
+ }
+ } catch (IOException e) {
+ throw new BluePrintException(e.getMessage(), e);
+ }
+
+ }
+ return serviceTemplate;
+ }
+
+ /**
+ * This is a saveConfigModel method
+ *
+ * @param configModel configModel
+ * @return ConfigModel
+ * @throws BluePrintException BluePrintException
+ */
+ public ConfigModel saveConfigModel(ConfigModel configModel) throws BluePrintException {
+
+ if (configModel != null) {
+ String artifactName = configModel.getArtifactName();
+ String artifactVersion = configModel.getArtifactVersion();
+ String author = configModel.getUpdatedBy();
+ // configModel.setTags(artifactName);
+
+ if (StringUtils.isBlank(author)) {
+ throw new BluePrintException("Artifact Author is missing in the Service Template");
+ }
+
+ if (StringUtils.isBlank(artifactName)) {
+ throw new BluePrintException("Artifact Name is missing in the Service Template");
+ }
+
+ if (StringUtils.isBlank(artifactVersion)) {
+ throw new BluePrintException("Artifact Version is missing in the Service Template");
+ }
+ ConfigModel updateConfigModel = null;
+
+ Optional<ConfigModel> dbConfigModelOptional = Optional.empty();
+
+ if (configModel.getId() != null) {
+ log.info("Searching for config model id : {}", configModel.getId());
+ dbConfigModelOptional = configModelRepository.findById(configModel.getId());
+ }
+
+ if (!dbConfigModelOptional.isPresent()) {
+ log.info("Searching for config model name :"
+ + configModel.getArtifactName() + ", version " + configModel.getArtifactVersion());
+ dbConfigModelOptional = configModelRepository.findByArtifactNameAndArtifactVersion(
+ configModel.getArtifactName(), configModel.getArtifactVersion());
+ }
+
+ if (dbConfigModelOptional.isPresent()) {
+ updateConfigModel = dbConfigModelOptional.get();
+ log.info("Processing for config model id : {} with config model content count : {}"
+ , updateConfigModel.getId(), updateConfigModel.getConfigModelContents().size());
+ } else {
+ ConfigModel tempConfigModel = new ConfigModel();
+ tempConfigModel.setArtifactType(ApplicationConstants.ASDC_ARTIFACT_TYPE_SDNC_MODEL);
+ tempConfigModel.setArtifactName(artifactName);
+ tempConfigModel.setArtifactVersion(artifactVersion);
+ tempConfigModel.setUpdatedBy(author);
+ tempConfigModel.setPublished(ApplicationConstants.ACTIVE_N);
+ tempConfigModel.setTags(artifactName);
+ configModelRepository.saveAndFlush(tempConfigModel);
+ updateConfigModel = tempConfigModel;
+ }
+
+ Long dbConfigModelId = updateConfigModel.getId();
+
+ if (dbConfigModelId == null) {
+ throw new BluePrintException("failed to get the initial saved config model id.");
+ }
+
+ log.info("Processing for config model id : {}", dbConfigModelId);
+
+ deleteConfigModelContent(dbConfigModelId);
+
+ addConfigModelContent(dbConfigModelId, configModel);
+
+ // Populate Content model types
+ updateConfigModel = updateConfigModel(dbConfigModelId, artifactName, artifactVersion, author);
+
+
+ return updateConfigModel;
+ } else {
+ throw new BluePrintException("Config model information is missing");
+ }
+
+ }
+
+ private void deleteConfigModelContent(Long dbConfigModelId) {
+ if (dbConfigModelId != null) {
+ ConfigModel dbConfigModel = configModelRepository.getOne(dbConfigModelId);
+ if (dbConfigModel != null && CollectionUtils.isNotEmpty(dbConfigModel.getConfigModelContents())) {
+ dbConfigModel.getConfigModelContents().clear();
+ log.debug("Configuration Model content deleting : {}", dbConfigModel.getConfigModelContents());
+ configModelRepository.saveAndFlush(dbConfigModel);
+ }
+
+ }
+ }
+
+ private void addConfigModelContent(Long dbConfigModelId, ConfigModel configModel) {
+ if (dbConfigModelId != null && configModel != null
+ && CollectionUtils.isNotEmpty(configModel.getConfigModelContents())) {
+ ConfigModel dbConfigModel = configModelRepository.getOne(dbConfigModelId);
+ if (dbConfigModel != null) {
+ for (ConfigModelContent configModelContent : configModel.getConfigModelContents()) {
+ if (configModelContent != null) {
+ configModelContent.setId(null);
+ configModelContent.setConfigModel(dbConfigModel);
+ dbConfigModel.getConfigModelContents().add(configModelContent);
+ log.debug("Configuration Model content adding : {}", configModelContent);
+ }
+ }
+ configModelRepository.saveAndFlush(dbConfigModel);
+ }
+
+ }
+ }
+
+ private ConfigModel updateConfigModel(Long dbConfigModelId, String artifactName, String artifactVersion,
+ String author) throws BluePrintException {
+
+ ConfigModel dbConfigModel = configModelRepository.getOne(dbConfigModelId);
+ if (dbConfigModel != null) {
+ // Populate tags from metadata
+ String tags = getConfigModelTags(dbConfigModel);
+ if (StringUtils.isBlank(tags)) {
+ throw new BluePrintException("Failed to populate tags for the config model name " + artifactName);
+ }
+ dbConfigModel.setArtifactType(ApplicationConstants.ASDC_ARTIFACT_TYPE_SDNC_MODEL);
+ dbConfigModel.setArtifactName(artifactName);
+ dbConfigModel.setArtifactVersion(artifactVersion);
+ dbConfigModel.setUpdatedBy(author);
+ dbConfigModel.setPublished(ApplicationConstants.ACTIVE_N);
+ dbConfigModel.setTags(tags);
+ configModelRepository.saveAndFlush(dbConfigModel);
+
+ log.info("Config model ({}) saved successfully.", dbConfigModel.getId());
+ }
+ return dbConfigModel;
+ }
+
+ private List<String> getValidContentTypes() {
+ List<String> valids = new ArrayList<>();
+ valids.add(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON);
+ valids.add(ConfigModelConstant.MODEL_CONTENT_TYPE_TEMPLATE);
+ return valids;
+
+ }
+
+ private String getConfigModelTags(ConfigModel configModel) throws BluePrintException {
+ String tags = null;
+ if (CollectionUtils.isNotEmpty(configModel.getConfigModelContents())) {
+
+ for (ConfigModelContent configModelContent : configModel.getConfigModelContents()) {
+ if (configModelContent != null && StringUtils.isNotBlank(configModelContent.getContentType())) {
+
+ if (!getValidContentTypes().contains(configModelContent.getContentType())) {
+ throw new BluePrintException(configModelContent.getContentType()
+ + " is not a valid content type, It should be any one of this "
+ + getValidContentTypes());
+ }
+
+ if (configModelContent.getContentType().equals(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON)) {
+ ServiceTemplate serviceTemplate =
+ JacksonUtils.readValue(configModelContent.getContent(), ServiceTemplate.class);
+ Preconditions.checkNotNull(serviceTemplate, "failed to transform service template content");
+ if (serviceTemplate.getMetadata() != null) {
+ serviceTemplate.getMetadata().put(BluePrintConstants.METADATA_TEMPLATE_AUTHOR,
+ configModel.getUpdatedBy());
+ serviceTemplate.getMetadata().put(BluePrintConstants.METADATA_TEMPLATE_VERSION,
+ configModel.getArtifactVersion());
+ serviceTemplate.getMetadata().put(BluePrintConstants.METADATA_TEMPLATE_NAME,
+ configModel.getArtifactName());
+ }
+ tags = String.valueOf(serviceTemplate.getMetadata());
+ } else {
+ // Do Nothing
+ }
+ }
+ }
+ }
+ return tags;
+ }
+
+ /**
+ * This is a publishConfigModel method
+ *
+ * @param id id
+ * @return ConfigModel
+ * @throws BluePrintException BluePrintException
+ */
+ public ConfigModel publishConfigModel(Long id) throws BluePrintException {
+ ConfigModel dbConfigModel = null;
+ if (id != null) {
+ Optional<ConfigModel> dbConfigModelOptional = configModelRepository.findById(id);
+ if (dbConfigModelOptional.isPresent()) {
+ dbConfigModel = dbConfigModelOptional.get();
+ List<ConfigModelContent> configModelContents = dbConfigModel.getConfigModelContents();
+ if (configModelContents != null && !configModelContents.isEmpty()) {
+ for (ConfigModelContent configModelContent : configModelContents) {
+ if (configModelContent.getContentType()
+ .equals(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON)) {
+ ServiceTemplate serviceTemplate = JacksonUtils
+ .readValue(configModelContent.getContent(), ServiceTemplate.class);
+ if (serviceTemplate != null) {
+ validateServiceTemplate(serviceTemplate);
+ }
+ }
+ }
+ }
+ dbConfigModel.setPublished(ApplicationConstants.ACTIVE_Y);
+ configModelRepository.save(dbConfigModel);
+ log.info("Config model ({}) published successfully.", id);
+
+ }
+
+ }
+ return dbConfigModel;
+ }
+
+ /**
+ * This is a validateServiceTemplate method
+ *
+ * @param serviceTemplate Service Template
+ * @return ServiceTemplate
+ * @throws BluePrintException BluePrintException
+ */
+ public ServiceTemplate validateServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {
+ return this.configModelValidatorService.validateServiceTemplate(serviceTemplate);
+ }
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelService.java
new file mode 100644
index 00000000..feee3a3e
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelService.java
@@ -0,0 +1,247 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.service.common.ApplicationConstants;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ConfigModelContentRepository;
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ConfigModelRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * ConfigModelService.java Purpose: Provide Service Template Service processing ConfigModelService
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+
+@Service
+public class ConfigModelService {
+
+ private static Logger log = LoggerFactory.getLogger(ConfigModelService.class);
+
+ private ConfigModelRepository configModelRepository;
+ private ConfigModelContentRepository configModelContentRepository;
+ private ConfigModelCreateService configModelCreateService;
+
+ /**
+ * This is a ConfigModelService constructor.
+ *
+ * @param configModelRepository
+ * @param configModelContentRepository
+ * @param configModelCreateService
+ */
+ public ConfigModelService(ConfigModelRepository configModelRepository,
+ ConfigModelContentRepository configModelContentRepository,
+ ConfigModelCreateService configModelCreateService) {
+ this.configModelRepository = configModelRepository;
+ this.configModelContentRepository = configModelContentRepository;
+ this.configModelCreateService = configModelCreateService;
+ }
+
+ /**
+ * This is a getInitialConfigModel method
+ *
+ * @param templateName
+ * @return ConfigModel
+ * @throws BluePrintException
+ */
+ public ConfigModel getInitialConfigModel(String templateName) throws BluePrintException {
+ ConfigModel configModel = null;
+ if (StringUtils.isNotBlank(templateName)) {
+ configModel = new ConfigModel();
+ configModel.setArtifactName(templateName);
+ configModel.setArtifactType(ApplicationConstants.ASDC_ARTIFACT_TYPE_SDNC_MODEL);
+ configModel.setUpdatedBy("xxxxx@xxx.com");
+ ConfigModelContent configModelContent = new ConfigModelContent();
+ configModelContent.setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON);
+ configModelContent.setName(templateName);
+ String content = this.configModelCreateService.createInitialServiceTemplateContent(templateName);
+ configModelContent.setContent(content);
+
+ List<ConfigModelContent> configModelContents = new ArrayList<>();
+ configModelContents.add(configModelContent);
+
+ configModel.setConfigModelContents(configModelContents);
+ }
+ return configModel;
+ }
+
+ /**
+ * This is a saveConfigModel method
+ *
+ * @param configModel
+ * @return ConfigModel
+ * @throws BluePrintException
+ */
+ public ConfigModel saveConfigModel(ConfigModel configModel) throws BluePrintException {
+ return this.configModelCreateService.saveConfigModel(configModel);
+ }
+
+ /**
+ * This is a publishConfigModel method
+ *
+ * @param id
+ * @return ConfigModel
+ * @throws BluePrintException
+ */
+ public ConfigModel publishConfigModel(Long id) throws BluePrintException {
+ return this.configModelCreateService.publishConfigModel(id);
+ }
+
+ /**
+ * This is a searchConfigModels method
+ *
+ * @param tags
+ * @return ConfigModel
+ */
+ public List<ConfigModel> searchConfigModels(String tags) {
+ List<ConfigModel> models = configModelRepository.findByTagsContainingIgnoreCase(tags);
+ if (models != null) {
+ for (ConfigModel configModel : models) {
+ configModel.setConfigModelContents(null);
+ }
+ }
+ return models;
+ }
+
+ /**
+ * This is a getConfigModelByNameAndVersion method
+ *
+ * @param name
+ * @param version
+ * @return ConfigModel
+ */
+ public ConfigModel getConfigModelByNameAndVersion(String name, String version) {
+ ConfigModel configModel = null;
+ Optional<ConfigModel> dbConfigModel = null;
+ if (StringUtils.isNotBlank(version)) {
+ dbConfigModel = configModelRepository.findByArtifactNameAndArtifactVersion(name, version);
+ } else {
+ dbConfigModel = configModelRepository.findTopByArtifactNameOrderByArtifactVersionDesc(name);
+ }
+ if (dbConfigModel.isPresent()) {
+ configModel = dbConfigModel.get();
+ }
+ return configModel;
+ }
+
+ /**
+ * This is a getConfigModel method
+ *
+ * @param id
+ * @return ConfigModel
+ */
+ public ConfigModel getConfigModel(Long id) {
+ ConfigModel configModel = null;
+ if (id != null) {
+ Optional<ConfigModel> dbConfigModel = configModelRepository.findById(id);
+ if (dbConfigModel.isPresent()) {
+ configModel = dbConfigModel.get();
+ }
+ }
+ return configModel;
+ }
+
+ /**
+ * This method returns clone of the given model id, by masking the other unrelated fields
+ *
+ * @param id
+ * @return
+ */
+
+ public ConfigModel getCloneConfigModel(Long id) {
+
+ ConfigModel configModel = null;
+ ConfigModel cloneConfigModel = null;
+ if (id != null) {
+ Optional<ConfigModel> dbConfigModel = configModelRepository.findById(id);
+ if (dbConfigModel.isPresent()) {
+ configModel = dbConfigModel.get();
+ cloneConfigModel = configModel;
+ cloneConfigModel.setUpdatedBy("xxxxx@xxx.com");
+ cloneConfigModel.setArtifactName("XXXX");
+ cloneConfigModel.setPublished("XXXX");
+ cloneConfigModel.setPublished("XXXX");
+ cloneConfigModel.setUpdatedBy("XXXX");
+ cloneConfigModel.setId(null);
+ cloneConfigModel.setTags(null);
+ cloneConfigModel.setCreatedDate(new Date());
+ List<ConfigModelContent> configModelContents = cloneConfigModel.getConfigModelContents();
+
+ if (CollectionUtils.isNotEmpty(configModelContents)) {
+ for (ConfigModelContent configModelContent : configModelContents) {
+ if (configModelContent != null && StringUtils.isNotBlank(configModelContent.getContentType())) {
+ configModelContent.setId(null);
+ configModelContent.setCreationDate(new Date());
+
+ if (ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON
+ .equalsIgnoreCase(configModelContent.getContentType())) {
+ ServiceTemplate serviceTemplate = JacksonUtils
+ .readValue(configModelContent.getContent(), ServiceTemplate.class);
+ if (serviceTemplate != null && serviceTemplate.getMetadata() != null) {
+ serviceTemplate.getMetadata()
+ .put(BluePrintConstants.METADATA_TEMPLATE_AUTHOR, "XXXX");
+ serviceTemplate.getMetadata()
+ .put(BluePrintConstants.METADATA_TEMPLATE_VERSION, "1.0.0");
+ serviceTemplate.getMetadata()
+ .put(BluePrintConstants.METADATA_TEMPLATE_NAME, "XXXXXX");
+
+ configModelContent.setContent(JacksonUtils.getJson(serviceTemplate));
+ }
+ }
+ }
+
+ }
+ }
+ }
+ }
+ return cloneConfigModel;
+ }
+
+ /**
+ * This is a deleteConfigModel method
+ *
+ * @param id
+ */
+
+ @Transactional
+ public void deleteConfigModel(Long id) {
+ Optional<ConfigModel> dbConfigModel = configModelRepository.findById(id);
+ if (dbConfigModel.isPresent()) {
+ configModelContentRepository.deleteByConfigModel(dbConfigModel.get());
+ configModelRepository.delete(dbConfigModel.get());
+ }
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelValidatorService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelValidatorService.java
new file mode 100644
index 00000000..21b00f8c
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelValidatorService.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service;
+
+import com.google.common.base.Preconditions;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.service.validator.ServiceTemplateValidator;
+import org.springframework.stereotype.Service;
+
+/**
+ * ServiceTemplateValidatorService.java Purpose: Provide Service to Validate Service Model Template
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+
+@Service
+public class ConfigModelValidatorService {
+
+ /**
+ * This is a validateServiceTemplate
+ *
+ * @param serviceTemplateContent
+ * @return ServiceTemplate
+ * @throws BluePrintException
+ */
+ public ServiceTemplate validateServiceTemplate(String serviceTemplateContent) throws BluePrintException {
+ Preconditions.checkArgument(StringUtils.isNotBlank(serviceTemplateContent), "Service Template Content is (" + serviceTemplateContent + ") not Defined.");
+ ServiceTemplate serviceTemplate =
+ JacksonUtils.readValue(serviceTemplateContent, ServiceTemplate.class);
+ return validateServiceTemplate(serviceTemplate);
+ }
+
+ /**
+ * This is a enhanceServiceTemplate
+ *
+ * @param serviceTemplate
+ * @return ServiceTemplate
+ * @throws BluePrintException
+ */
+ @SuppressWarnings("squid:S00112")
+ public ServiceTemplate validateServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {
+ Preconditions.checkNotNull(serviceTemplate, "Service Template is not defined.");
+ ServiceTemplateValidator validator = new ServiceTemplateValidator();
+ validator.validateServiceTemplate(serviceTemplate);
+ return serviceTemplate;
+ }
+
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java
new file mode 100644
index 00000000..9ab319cb
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java
@@ -0,0 +1,325 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.text.StrBuilder;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DictionaryDefinition;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
+import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.support.ResourcePatternResolver;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.util.List;
+
+/**
+ * DataBaseInitService.java Purpose: Provide DataBaseInitService Service
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+
+@Component
+@ConditionalOnProperty(name = "blueprints.load.initial-data", havingValue = "true", matchIfMissing = false)
+public class DataBaseInitService {
+
+ private static Logger log = LoggerFactory.getLogger(DataBaseInitService.class);
+ @Value("${blueprints.load.path}")
+ private String modelLoadPath;
+ private ModelTypeService modelTypeService;
+ private ResourceDictionaryService resourceDictionaryService;
+ private ConfigModelService configModelService;
+
+ private String dataTypePath;
+ private String nodeTypePath;
+ private String artifactTypePath;
+ private String resourceDictionaryPath;
+ private String bluePrintsPath;
+
+ @Autowired
+ private ResourcePatternResolver resourceLoader;
+
+ /**
+ * This is a DataBaseInitService, used to load the initial data
+ *
+ * @param modelTypeService
+ * @param resourceDictionaryService
+ * @param configModelService
+ */
+ public DataBaseInitService(ModelTypeService modelTypeService, ResourceDictionaryService resourceDictionaryService,
+ ConfigModelService configModelService) {
+ this.modelTypeService = modelTypeService;
+ this.resourceDictionaryService = resourceDictionaryService;
+ this.configModelService = configModelService;
+ log.info("DataBaseInitService started...");
+
+ }
+
+ @PostConstruct
+ private void initDatabase() {
+ log.info("loading Blueprints from DIR : {}", modelLoadPath);
+ dataTypePath = modelLoadPath + "/model_type/data_type";
+ nodeTypePath = modelLoadPath + "/model_type/node_type";
+ artifactTypePath = modelLoadPath + "/model_type/artifact_type";
+ resourceDictionaryPath = modelLoadPath + "/resource_dictionary";
+ bluePrintsPath = modelLoadPath + "/blueprints";
+
+ log.info("loading dataTypePath from DIR : {}", dataTypePath);
+ log.info("loading nodeTypePath from DIR : {}", nodeTypePath);
+ log.info("loading artifactTypePath from DIR : {}", artifactTypePath);
+ log.info("loading resourceDictionaryPath from DIR : {}", resourceDictionaryPath);
+ log.info("loading bluePrintsPath from DIR : {}", bluePrintsPath);
+
+ loadModelType();
+ loadResourceDictionary();
+ loadBlueprints();
+ }
+
+ private void loadModelType() {
+ log.info(" *************************** loadModelType **********************");
+ try {
+ Resource[] dataTypefiles = getPathResources(dataTypePath, ".json");
+ StrBuilder errorBuilder = new StrBuilder();
+ if (dataTypefiles != null) {
+ for (Resource file : dataTypefiles) {
+ if (file != null) {
+ loadDataType(file, errorBuilder);
+ }
+ }
+ }
+
+ Resource[] nodeTypefiles = getPathResources(nodeTypePath, ".json");
+ if (nodeTypefiles != null) {
+ for (Resource file : nodeTypefiles) {
+ if (file != null) {
+ loadNodeType(file, errorBuilder);
+ }
+ }
+ }
+
+ Resource[] artifactTypefiles = getPathResources(artifactTypePath, ".json");
+ if (artifactTypefiles != null) {
+ for (Resource file : artifactTypefiles) {
+ if (file != null) {
+ loadArtifactType(file, errorBuilder);
+ }
+ }
+ }
+
+ if (!errorBuilder.isEmpty()) {
+ log.error(errorBuilder.toString());
+ }
+ } catch (Exception e) {
+ log.error("Failed in Data type loading", e);
+ }
+ }
+
+ private void loadResourceDictionary() {
+ log.info(
+ " *************************** loadResourceDictionary **********************");
+ try {
+ Resource[] dataTypefiles = getPathResources(resourceDictionaryPath, ".json");
+ if (dataTypefiles != null) {
+ StrBuilder errorBuilder = new StrBuilder();
+ String fileName = null;
+ for (Resource file : dataTypefiles) {
+ try {
+ fileName = file.getFilename();
+ log.trace("Loading : {}", fileName);
+ String definitionContent = getResourceContent(file);
+ DictionaryDefinition dictionaryDefinition =
+ JacksonUtils.readValue(definitionContent, DictionaryDefinition.class);
+ if (dictionaryDefinition != null) {
+ ResourceDictionary resourceDictionary = new ResourceDictionary();
+ resourceDictionary.setResourcePath(dictionaryDefinition.getResourcePath());
+ resourceDictionary.setName(dictionaryDefinition.getName());
+ resourceDictionary.setDefinition(definitionContent);
+
+ if (dictionaryDefinition.getValidValues() != null)
+ resourceDictionary
+ .setValidValues(String.valueOf(dictionaryDefinition.getValidValues()));
+
+ if (dictionaryDefinition.getSampleValue() != null)
+ resourceDictionary
+ .setValidValues(String.valueOf(dictionaryDefinition.getSampleValue()));
+
+ resourceDictionary.setResourceType(dictionaryDefinition.getResourceType());
+ resourceDictionary.setDataType(dictionaryDefinition.getDataType());
+ resourceDictionary.setEntrySchema(dictionaryDefinition.getEntrySchema());
+ resourceDictionary.setDescription(dictionaryDefinition.getDescription());
+ resourceDictionary.setUpdatedBy(dictionaryDefinition.getUpdatedBy());
+ if (StringUtils.isBlank(dictionaryDefinition.getTags())) {
+ resourceDictionary.setTags(
+ dictionaryDefinition.getName() + ", " + dictionaryDefinition.getUpdatedBy()
+ + ", " + dictionaryDefinition.getResourceType() + ", "
+ + dictionaryDefinition.getUpdatedBy());
+
+ } else {
+ resourceDictionary.setTags(dictionaryDefinition.getTags());
+ }
+ resourceDictionaryService.saveResourceDictionary(resourceDictionary);
+
+ log.trace(" Loaded successfully : {}", file.getFilename());
+ } else {
+ throw new BluePrintException("couldn't get dictionary from content information");
+ }
+ } catch (Exception e) {
+ errorBuilder.appendln("Dictionary loading Errors : " + file.getFilename() + ":" + e.getMessage());
+ }
+ }
+ if (!errorBuilder.isEmpty()) {
+ log.error(errorBuilder.toString());
+ }
+
+ }
+ } catch (Exception e) {
+ log.error(
+ "Failed in Resource dictionary loading", e);
+ }
+ }
+
+ private void loadBlueprints() {
+ log.info("*************************** loadServiceTemplate **********************");
+ try {
+ List<String> serviceTemplateDirs = ConfigModelUtils.getBlueprintNames(bluePrintsPath);
+ if (CollectionUtils.isNotEmpty(serviceTemplateDirs)) {
+ StrBuilder errorBuilder = new StrBuilder();
+ for (String fileName : serviceTemplateDirs) {
+ try {
+ String bluePrintPath = this.bluePrintsPath.concat("/").concat(fileName);
+ log.debug("***** Loading service template : {}", bluePrintPath);
+ ConfigModel configModel = ConfigModelUtils.getConfigModel(bluePrintPath);
+
+ configModel = this.configModelService.saveConfigModel(configModel);
+
+ log.info("Publishing : {}", configModel.getId());
+
+ this.configModelService.publishConfigModel(configModel.getId());
+
+ log.info("Loaded service template successfully: {}", fileName);
+
+ } catch (Exception e) {
+ errorBuilder.appendln("load config model " + fileName + " error : " + e.getMessage());
+ }
+ }
+
+ if (!errorBuilder.isEmpty()) {
+ log.error(errorBuilder.toString());
+ }
+ }
+ } catch (Exception e) {
+ log.error("Failed in Service Template loading", e);
+ }
+ }
+
+ private void loadNodeType(Resource file, StrBuilder errorBuilder) {
+ try {
+ log.trace("Loading Node Type : {}", file.getFilename());
+ String nodeKey = file.getFilename().replace(".json", "");
+ String definitionContent = getResourceContent(file);
+ NodeType nodeType = JacksonUtils.readValue(definitionContent, NodeType.class);
+ ModelType modelType = new ModelType();
+ modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE);
+ modelType.setDerivedFrom(nodeType.getDerivedFrom());
+ modelType.setDescription(nodeType.getDescription());
+ modelType.setDefinition(definitionContent);
+ modelType.setModelName(nodeKey);
+ modelType.setVersion(nodeType.getVersion());
+ modelType.setUpdatedBy("System");
+ modelType.setTags(nodeKey + "," + BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE + ","
+ + nodeType.getDerivedFrom());
+ modelTypeService.saveModel(modelType);
+ log.trace("Loaded Node Type successfully : {}", file.getFilename());
+ } catch (Exception e) {
+ errorBuilder.appendln("Node type loading error : " + file.getFilename() + ":" + e.getMessage());
+ }
+ }
+
+ private void loadDataType(Resource file, StrBuilder errorBuilder) {
+ try {
+ log.trace("Loading Data Type: {}", file.getFilename());
+ String dataKey = file.getFilename().replace(".json", "");
+ String definitionContent = getResourceContent(file);
+ DataType dataType = JacksonUtils.readValue(definitionContent, DataType.class);
+ ModelType modelType = new ModelType();
+ modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
+ modelType.setDerivedFrom(dataType.getDerivedFrom());
+ modelType.setDescription(dataType.getDescription());
+ modelType.setDefinition(definitionContent);
+ modelType.setModelName(dataKey);
+ modelType.setVersion(dataType.getVersion());
+ modelType.setUpdatedBy("System");
+ modelType.setTags(dataKey + "," + dataType.getDerivedFrom() + ","
+ + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
+ modelTypeService.saveModel(modelType);
+ log.trace(" Loaded Data Type successfully : {}", file.getFilename());
+ } catch (Exception e) {
+ errorBuilder.appendln("Data type loading error : " + file.getFilename() + ":" + e.getMessage());
+ }
+ }
+
+ private void loadArtifactType(Resource file, StrBuilder errorBuilder) {
+ try {
+ log.trace("Loading Artifact Type: {}", file.getFilename());
+ String dataKey = file.getFilename().replace(".json", "");
+ String definitionContent = getResourceContent(file);
+ ArtifactType artifactType = JacksonUtils.readValue(definitionContent, ArtifactType.class);
+ ModelType modelType = new ModelType();
+ modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE);
+ modelType.setDerivedFrom(artifactType.getDerivedFrom());
+ modelType.setDescription(artifactType.getDescription());
+ modelType.setDefinition(definitionContent);
+ modelType.setModelName(dataKey);
+ modelType.setVersion(artifactType.getVersion());
+ modelType.setUpdatedBy("System");
+ modelType.setTags(dataKey + "," + artifactType.getDerivedFrom() + ","
+ + BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE);
+ modelTypeService.saveModel(modelType);
+ log.trace("Loaded Artifact Type successfully : {}", file.getFilename());
+ } catch (Exception e) {
+ errorBuilder.appendln("Artifact type loading error : " + file.getFilename() + ":" + e.getMessage());
+ }
+ }
+
+ private Resource[] getPathResources(String path, String extension) throws IOException {
+ return resourceLoader.getResources("file:" + path + "/*" + extension);
+ }
+
+ private String getResourceContent(Resource resource) throws IOException {
+ return IOUtils.toString(resource.getInputStream(), Charset.defaultCharset());
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeService.java
new file mode 100644
index 00000000..2bc2963b
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeService.java
@@ -0,0 +1,178 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service;
+
+import org.apache.commons.lang3.StringUtils;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ModelTypeRepository;
+import org.onap.ccsdk.apps.controllerblueprints.service.validator.ModelTypeValidator;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * ModelTypeService.java Purpose: Provide ModelTypeService Service ModelTypeService
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+
+@Service
+@Transactional
+public class ModelTypeService {
+
+ private ModelTypeRepository modelTypeRepository;
+
+ /**
+ * This is a ModelTypeService, used to save and get the model types stored in database
+ *
+ * @param modelTypeRepository
+ */
+ public ModelTypeService(ModelTypeRepository modelTypeRepository) {
+ this.modelTypeRepository = modelTypeRepository;
+ }
+
+
+ /**
+ * This is a getModelTypeByName service
+ *
+ * @param modelTypeName
+ * @return ModelType
+ * @throws BluePrintException
+ */
+ public ModelType getModelTypeByName(String modelTypeName) throws BluePrintException {
+ ModelType modelType = null;
+ if (StringUtils.isNotBlank(modelTypeName)) {
+ Optional<ModelType> modelTypeOption = modelTypeRepository.findByModelName(modelTypeName);
+ if (modelTypeOption.isPresent()) {
+ modelType = modelTypeOption.get();
+ }
+ } else {
+ throw new BluePrintException("Model Name Information is missing.");
+ }
+ return modelType;
+ }
+
+
+ /**
+ * This is a searchModelTypes service
+ *
+ * @param tags
+ * @return List<ModelType>
+ * @throws BluePrintException
+ */
+ public List<ModelType> searchModelTypes(String tags) throws BluePrintException {
+ if (tags != null) {
+ return modelTypeRepository.findByTagsContainingIgnoreCase(tags);
+ } else {
+ throw new BluePrintException("No Search Information provide");
+ }
+ }
+
+ /**
+ * This is a saveModel service
+ *
+ * @param modelType
+ * @return ModelType
+ * @throws BluePrintException
+ */
+ public ModelType saveModel(ModelType modelType) throws BluePrintException {
+
+ ModelTypeValidator.validateModelType(modelType);
+
+ Optional<ModelType> dbModelType = modelTypeRepository.findByModelName(modelType.getModelName());
+ if (dbModelType.isPresent()) {
+ ModelType dbModel = dbModelType.get();
+ dbModel.setDescription(modelType.getDescription());
+ dbModel.setDefinition(modelType.getDefinition());
+ dbModel.setDefinitionType(modelType.getDefinitionType());
+ dbModel.setDerivedFrom(modelType.getDerivedFrom());
+ dbModel.setTags(modelType.getTags());
+ dbModel.setVersion(modelType.getVersion());
+ dbModel.setUpdatedBy(modelType.getUpdatedBy());
+ modelType = modelTypeRepository.save(dbModel);
+ } else {
+ modelType = modelTypeRepository.save(modelType);
+ }
+ return modelType;
+ }
+
+
+ /**
+ * This is a deleteByModelName service
+ *
+ * @param modelName
+ * @throws BluePrintException
+ */
+ public void deleteByModelName(String modelName) throws BluePrintException {
+ if (modelName != null) {
+ modelTypeRepository.deleteByModelName(modelName);
+ } else {
+ throw new BluePrintException("Model Name Information is missing.");
+ }
+ }
+
+ /**
+ * This is a getModelTypeByTags service
+ *
+ * @param tags
+ * @return List<ModelType>
+ * @throws BluePrintException
+ */
+ public List<ModelType> getModelTypeByTags(String tags) throws BluePrintException {
+ if (StringUtils.isNotBlank(tags)) {
+ return modelTypeRepository.findByTagsContainingIgnoreCase(tags);
+ } else {
+ throw new BluePrintException("Model Tag Information is missing.");
+ }
+ }
+
+ /**
+ * This is a getModelTypeByDefinitionType service
+ *
+ * @param definitionType
+ * @return List<ModelType>
+ * @throws BluePrintException
+ */
+ public List<ModelType> getModelTypeByDefinitionType(String definitionType) throws BluePrintException {
+ if (StringUtils.isNotBlank(definitionType)) {
+ return modelTypeRepository.findByDefinitionType(definitionType);
+ } else {
+ throw new BluePrintException("Model definitionType Information is missing.");
+ }
+ }
+
+ /**
+ * This is a getModelTypeByDerivedFrom service
+ *
+ * @param derivedFrom
+ * @return List<ModelType>
+ * @throws BluePrintException
+ */
+ public List<ModelType> getModelTypeByDerivedFrom(String derivedFrom) throws BluePrintException {
+ if (StringUtils.isNotBlank(derivedFrom)) {
+ return modelTypeRepository.findByDerivedFrom(derivedFrom);
+ } else {
+ throw new BluePrintException("Model derivedFrom Information is missing.");
+ }
+ }
+
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java
new file mode 100644
index 00000000..b9567db1
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java
@@ -0,0 +1,169 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service;
+
+import org.apache.commons.lang3.StringUtils;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DictionaryDefinition;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository;
+import org.onap.ccsdk.apps.controllerblueprints.service.validator.ResourceDictionaryValidator;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * ResourceDictionaryService.java Purpose: Provide DataDictionaryService Service
+ * DataDictionaryService
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Service
+public class ResourceDictionaryService {
+
+ private ResourceDictionaryRepository resourceDictionaryRepository;
+
+ /**
+ * This is a DataDictionaryService, used to save and get the Resource Mapping stored in database
+ *
+ * @param dataDictionaryRepository
+ *
+ */
+ public ResourceDictionaryService(ResourceDictionaryRepository dataDictionaryRepository) {
+ this.resourceDictionaryRepository = dataDictionaryRepository;
+ }
+
+ /**
+ * This is a getDataDictionaryByName service
+ *
+ * @param name
+ * @return DataDictionary
+ * @throws BluePrintException
+ */
+ public ResourceDictionary getResourceDictionaryByName(String name) throws BluePrintException {
+ if (StringUtils.isNotBlank(name)) {
+ return resourceDictionaryRepository.findByName(name).get();
+ } else {
+ throw new BluePrintException("Resource Mapping Name Information is missing.");
+ }
+ }
+
+ /**
+ * This is a searchResourceDictionaryByNames service
+ *
+ * @param names
+ * @return List<ResourceDictionary>
+ * @throws BluePrintException
+ */
+ public List<ResourceDictionary> searchResourceDictionaryByNames(List<String> names)
+ throws BluePrintException {
+ if (names != null && !names.isEmpty()) {
+ return resourceDictionaryRepository.findByNameIn(names);
+ } else {
+ throw new BluePrintException("No Search Information provide");
+ }
+ }
+
+ /**
+ * This is a searchResourceDictionaryByTags service
+ *
+ * @param tags
+ * @return List<ResourceDictionary>
+ * @throws BluePrintException
+ */
+ public List<ResourceDictionary> searchResourceDictionaryByTags(String tags) throws BluePrintException {
+ if (StringUtils.isNotBlank(tags)) {
+ return resourceDictionaryRepository.findByTagsContainingIgnoreCase(tags);
+ } else {
+ throw new BluePrintException("No Search Information provide");
+ }
+ }
+
+ /**
+ * This is a saveDataDictionary service
+ *
+ * @param resourceDictionary
+ * @return DataDictionary
+ * @throws BluePrintException
+ */
+ public ResourceDictionary saveResourceDictionary(ResourceDictionary resourceDictionary)
+ throws BluePrintException {
+ if (resourceDictionary != null) {
+ ResourceDictionaryValidator.validateResourceDictionary(resourceDictionary);
+
+ DictionaryDefinition dictionaryDefinition =
+ JacksonUtils.readValue(resourceDictionary.getDefinition(), DictionaryDefinition.class);
+
+ if (dictionaryDefinition == null) {
+ throw new BluePrintException(
+ "Resource dictionary definition is not valid content " + resourceDictionary.getDefinition());
+ }
+
+ dictionaryDefinition.setName(resourceDictionary.getName());
+ dictionaryDefinition.setResourcePath(resourceDictionary.getResourcePath());
+ dictionaryDefinition.setResourceType(resourceDictionary.getResourceType());
+ dictionaryDefinition.setDataType(resourceDictionary.getDataType());
+ dictionaryDefinition.setEntrySchema(resourceDictionary.getEntrySchema());
+ dictionaryDefinition.setTags(resourceDictionary.getTags());
+ dictionaryDefinition.setDescription(resourceDictionary.getDescription());
+ dictionaryDefinition.setUpdatedBy(resourceDictionary.getUpdatedBy());
+
+ String definitionContent = JacksonUtils.getJson(dictionaryDefinition, true);
+ resourceDictionary.setDefinition(definitionContent);
+
+ Optional<ResourceDictionary> dbResourceDictionaryData =
+ resourceDictionaryRepository.findByName(resourceDictionary.getName());
+ if (dbResourceDictionaryData.isPresent()) {
+ ResourceDictionary dbResourceDictionary = dbResourceDictionaryData.get();
+
+ dbResourceDictionary.setName(resourceDictionary.getName());
+ dbResourceDictionary.setDefinition(resourceDictionary.getDefinition());
+ dbResourceDictionary.setDescription(resourceDictionary.getDescription());
+ dbResourceDictionary.setResourceType(resourceDictionary.getResourceType());
+ dbResourceDictionary.setResourcePath(resourceDictionary.getResourcePath());
+ dbResourceDictionary.setDataType(resourceDictionary.getDataType());
+ dbResourceDictionary.setEntrySchema(resourceDictionary.getEntrySchema());
+ dbResourceDictionary.setTags(resourceDictionary.getTags());
+ dbResourceDictionary.setValidValues(resourceDictionary.getValidValues());
+ resourceDictionary = resourceDictionaryRepository.save(dbResourceDictionary);
+ } else {
+ resourceDictionary = resourceDictionaryRepository.save(resourceDictionary);
+ }
+ } else {
+ throw new BluePrintException("Resource Dictionary information is missing");
+ }
+ return resourceDictionary;
+ }
+
+ /**
+ * This is a deleteResourceDictionary service
+ *
+ * @param name
+ * @throws BluePrintException
+ */
+ public void deleteResourceDictionary(String name) throws BluePrintException {
+ if (name != null) {
+ resourceDictionaryRepository.deleteByName(name);
+ } else {
+ throw new BluePrintException("Resource Mapping Id Information is missing.");
+ }
+
+ }
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java
new file mode 100644
index 00000000..a75651f1
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service;
+
+import com.google.common.base.Preconditions;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.service.common.SwaggerGenerator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * SchemaGeneratorService.java Purpose: Provide Service to generate service template input schema definition and Sample
+ * Json generation.
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+
+public class SchemaGeneratorService {
+ private static Logger log = LoggerFactory.getLogger(SchemaGeneratorService.class);
+
+ private Map<String, DataType> dataTypes;
+
+ /**
+ * This is a SchemaGeneratorService constructor
+ */
+ public SchemaGeneratorService() {
+ dataTypes = new HashMap<>();
+ }
+
+ /**
+ * This is a generateSchema
+ *
+ * @param serviceTemplateContent service template content
+ * @return String
+ * @throws BluePrintException Blueprint Exception
+ */
+ public String generateSchema(String serviceTemplateContent) throws BluePrintException {
+ if (StringUtils.isNotBlank(serviceTemplateContent)) {
+ ServiceTemplate serviceTemplate = JacksonUtils.readValue(serviceTemplateContent,
+ ServiceTemplate.class);
+ return generateSchema(serviceTemplate);
+ } else {
+ throw new BluePrintException(
+ "Service Template Content is (" + serviceTemplateContent + ") not Defined.");
+ }
+ }
+
+ /**
+ * This is a generateSchema
+ *
+ * @param serviceTemplate service template content
+ * @return String
+ * @throws BluePrintException Blueprint Exception
+ */
+ public String generateSchema(ServiceTemplate serviceTemplate) throws BluePrintException {
+ String schemaContent = null;
+ Preconditions.checkNotNull(serviceTemplate, "Service Template is not defined.");
+ try {
+ if (serviceTemplate.getTopologyTemplate() != null
+ && serviceTemplate.getTopologyTemplate().getInputs() != null) {
+ SwaggerGenerator swaggerGenerator = new SwaggerGenerator(serviceTemplate);
+ schemaContent = swaggerGenerator.generateSwagger();
+ }
+ } catch (Exception e) {
+ throw new BluePrintException(e.getMessage(), e);
+ }
+
+ return schemaContent;
+ }
+
+ private void manageServiceTemplateActions(ServiceTemplate serviceTemplate, String actionName) {
+ if (serviceTemplate != null && serviceTemplate.getTopologyTemplate() != null
+ && StringUtils.isNotBlank(actionName)) {
+
+ if (MapUtils.isNotEmpty(serviceTemplate.getTopologyTemplate().getInputs())) {
+
+ serviceTemplate.getTopologyTemplate().getInputs().entrySet().removeIf(entity -> {
+ String keyName = entity.getKey();
+ String replacedAction = actionName.replace("-action", "-request");
+ log.debug("Key name : " + keyName + ", actionName "
+ + actionName + ", replacedAction :" + replacedAction);
+ if (keyName.endsWith("-request") && !keyName.equals(replacedAction)) {
+ log.info("deleting input property {} ", keyName);
+ return true;
+ }
+ return false;
+ });
+ }
+
+ }
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ServiceTemplateService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ServiceTemplateService.java
new file mode 100644
index 00000000..70b7917a
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ServiceTemplateService.java
@@ -0,0 +1,140 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service;
+
+import org.apache.commons.lang3.StringUtils;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.validator.ResourceAssignmentValidator;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
+import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * ServiceTemplateService.java Purpose: Provide Service Template Create Service processing ServiceTemplateService
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+
+@Service
+public class ServiceTemplateService {
+
+ private ResourceDictionaryRepository dataDictionaryRepository;
+
+ private ConfigModelCreateService configModelCreateService;
+ private BluePrintEnhancerService bluePrintEnhancerService;
+
+ /**
+ * This is a SchemaGeneratorService constructor
+ *
+ * @param dataDictionaryRepository
+ * @param configModelCreateService
+ * @param bluePrintEnhancerService
+ */
+ public ServiceTemplateService(ResourceDictionaryRepository dataDictionaryRepository,
+ ConfigModelCreateService configModelCreateService,
+ BluePrintEnhancerService bluePrintEnhancerService) {
+ this.dataDictionaryRepository = dataDictionaryRepository;
+ this.configModelCreateService = configModelCreateService;
+ this.bluePrintEnhancerService = bluePrintEnhancerService;
+
+ }
+
+ /**
+ * This is a validateServiceTemplate method
+ *
+ * @param serviceTemplate
+ * @return ServiceTemplate
+ * @throws BluePrintException
+ */
+ public ServiceTemplate validateServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {
+ return this.configModelCreateService.validateServiceTemplate(serviceTemplate);
+ }
+
+ /**
+ * This is a enrichServiceTemplate method
+ *
+ * @param serviceTemplate
+ * @return ServiceTemplate
+ * @throws BluePrintException
+ */
+ public ServiceTemplate enrichServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {
+ this.bluePrintEnhancerService.enhance(serviceTemplate);
+ return serviceTemplate;
+ }
+
+ /**
+ * This is a autoMap method to map the template keys
+ *
+ * @param resourceAssignments
+ * @return AutoMapResponse
+ * @throws BluePrintException
+ */
+ public AutoMapResponse autoMap(List<ResourceAssignment> resourceAssignments) throws BluePrintException {
+ AutoResourceMappingService autoMappingService = new AutoResourceMappingService(dataDictionaryRepository);
+ AutoMapResponse autoMapResponse = autoMappingService.autoMap(resourceAssignments);
+ return autoMapResponse;
+ }
+
+ /**
+ * This is a validateResourceAssignments method
+ *
+ * @param resourceAssignments
+ * @return List<ResourceAssignment>
+ * @throws BluePrintException
+ */
+ public List<ResourceAssignment> validateResourceAssignments(List<ResourceAssignment> resourceAssignments)
+ throws BluePrintException {
+ try {
+ ResourceAssignmentValidator resourceAssignmentValidator =
+ new ResourceAssignmentValidator(resourceAssignments);
+ resourceAssignmentValidator.validateResourceAssignment();
+ } catch (BluePrintException e) {
+ throw new BluePrintException(e.getMessage(), e);
+ }
+ return resourceAssignments;
+ }
+
+ /**
+ * This is a generateResourceAssignments method
+ *
+ * @param templateContent
+ * @return List<ResourceAssignment>
+ */
+ public List<ResourceAssignment> generateResourceAssignments(ConfigModelContent templateContent) {
+ List<ResourceAssignment> resourceAssignments = new ArrayList<>();
+ if (templateContent != null && StringUtils.isNotBlank(templateContent.getContent())) {
+ Pattern p = Pattern.compile("(?<=\\$\\{)([^\\}]+)(?=\\})");
+ Matcher m = p.matcher(templateContent.getContent());
+ while (m.find()) {
+ ResourceAssignment resourceAssignment = new ResourceAssignment();
+ resourceAssignment.setName(m.group());
+ resourceAssignments.add(resourceAssignment);
+ }
+ }
+ return resourceAssignments;
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ApplicationConstants.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ApplicationConstants.java
new file mode 100644
index 00000000..8dd74840
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ApplicationConstants.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.common;
+
+/**
+ * ApplicationConstants.java Purpose: Provide ControllerBluprintsApplication Constant Information
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+public final class ApplicationConstants {
+ private ApplicationConstants() {
+
+ }
+ public static final String ACTIVE_Y = "Y";
+ public static final String ACTIVE_N = "N";
+ public static final String ASDC_ARTIFACT_TYPE_SDNC_MODEL = "SDNC_MODEL";
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ErrorMessage.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ErrorMessage.java
new file mode 100644
index 00000000..f7a802e4
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ErrorMessage.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.common;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+
+import java.io.Serializable;
+
+@JsonInclude(Include.NON_NULL)
+public class ErrorMessage implements Serializable {
+ private Integer httpStatus;
+ private String message;
+ private Integer code;
+ private String developerMessage;
+
+ public Integer getHttpStatus() {
+ return httpStatus;
+ }
+
+ public void setHttpStatus(Integer httpStatus) {
+ this.httpStatus = httpStatus;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public Integer getCode() {
+ return code;
+ }
+
+ public void setCode(Integer code) {
+ this.code = code;
+ }
+
+ public String getDeveloperMessage() {
+ return developerMessage;
+ }
+
+ public void setDeveloperMessage(String developerMessage) {
+ this.developerMessage = developerMessage;
+ }
+
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ServiceExceptionMapper.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ServiceExceptionMapper.java
new file mode 100644
index 00000000..f223dccb
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ServiceExceptionMapper.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.common;
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+@Provider
+public class ServiceExceptionMapper implements ExceptionMapper<BluePrintException> {
+
+ @Override
+ public Response toResponse(BluePrintException ex) {
+ ErrorMessage errorMessage = new ErrorMessage();
+ errorMessage.setCode(ex.getCode());
+ errorMessage.setMessage(ex.getMessage());
+ StringWriter errorStackTrace = new StringWriter();
+ ex.printStackTrace(new PrintWriter(errorStackTrace));
+ errorMessage.setDeveloperMessage(ex.toString());
+ return Response.status(500).entity(errorMessage).type(MediaType.APPLICATION_JSON).build();
+ }
+
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SwaggerGenerator.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SwaggerGenerator.java
new file mode 100644
index 00000000..e9080763
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SwaggerGenerator.java
@@ -0,0 +1,187 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.common;
+
+import io.swagger.models.*;
+import io.swagger.models.parameters.BodyParameter;
+import io.swagger.models.parameters.Parameter;
+import io.swagger.models.properties.*;
+import io.swagger.util.Json;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang3.BooleanUtils;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
+
+import java.util.*;
+
+/**
+ * SwaggerGenerator.java Purpose: Provide Service to generate service template input schema definition and Sample Json
+ * generation.
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Deprecated
+public class SwaggerGenerator {
+
+ private ServiceTemplate serviceTemplate;
+
+ /**
+ * This is a SwaggerGenerator constructor
+ */
+ public SwaggerGenerator(ServiceTemplate serviceTemplate) {
+ this.serviceTemplate = serviceTemplate;
+ }
+
+ /**
+ * This is a generateSwagger
+ *
+ * @return String
+ */
+ public String generateSwagger() {
+ String swaggerContent = null;
+
+ Swagger swagger = new Swagger().info(getInfo());
+
+ swagger.setPaths(getPaths());
+ swagger.setDefinitions(getDefinition());
+
+
+ swaggerContent = Json.pretty(swagger);
+ return swaggerContent;
+ }
+
+ private Info getInfo() {
+ Info info = new Info();
+ Contact contact = new Contact();
+ contact.setName(serviceTemplate.getMetadata().get(BluePrintConstants.METADATA_TEMPLATE_AUTHOR));
+ info.setContact(contact);
+ info.setTitle(serviceTemplate.getMetadata().get(BluePrintConstants.METADATA_TEMPLATE_NAME));
+ info.setDescription(serviceTemplate.getDescription());
+ info.setVersion(serviceTemplate.getMetadata().get(BluePrintConstants.METADATA_TEMPLATE_VERSION));
+ return info;
+ }
+
+ private Map<String, Path> getPaths() {
+ Map<String, Path> paths = new HashMap<>();
+ Path path = new Path();
+ Operation post = new Operation();
+ post.setOperationId("configure");
+ post.setConsumes(Arrays.asList("application/json", "application/xml"));
+ post.setProduces(Arrays.asList("application/json", "application/xml"));
+ List<Parameter> parameters = new ArrayList<>();
+ Parameter in = new BodyParameter().schema(new RefModel("#/definitions/inputs"));
+ in.setRequired(true);
+ in.setName("inputs");
+ parameters.add(in);
+ post.setParameters(parameters);
+
+ Map<String, Response> responses = new HashMap<>();
+ Response response = new Response().description("Success");
+ responses.put("200", response);
+
+ Response failureResponse = new Response().description("Failure");
+ responses.put("400", failureResponse);
+ post.setResponses(responses);
+
+ path.setPost(post);
+ paths.put("/operations/config-selfservice-api:configure", path);
+ return paths;
+ }
+
+ private Map<String, Model> getDefinition() {
+ Map<String, Model> models = new HashMap<>();
+
+ ModelImpl inputmodel = new ModelImpl();
+ inputmodel.setTitle("inputs");
+ serviceTemplate.getTopologyTemplate().getInputs().forEach((propertyName, property) -> {
+ Property defProperty = getPropery(propertyName, property);
+ inputmodel.property(propertyName, defProperty);
+ });
+ models.put("inputs", inputmodel);
+
+ if (MapUtils.isNotEmpty(serviceTemplate.getDataTypes())) {
+ serviceTemplate.getDataTypes().forEach((name, dataType) -> {
+ ModelImpl model = new ModelImpl();
+ model.setDescription(dataType.getDescription());
+ // model.setType("object");
+ if (dataType != null && MapUtils.isNotEmpty(dataType.getProperties())) {
+
+ dataType.getProperties().forEach((propertyName, property) -> {
+ Property defProperty = getPropery(propertyName, property);
+ model.addProperty(propertyName, defProperty);
+ });
+ }
+ models.put(name, model);
+ });
+ }
+ return models;
+
+ }
+
+ private Property getPropery(String name, PropertyDefinition propertyDefinition) {
+ Property defProperty = null;
+
+ if (BluePrintTypes.validPrimitiveTypes().contains(propertyDefinition.getType())) {
+ if (BluePrintConstants.DATA_TYPE_BOOLEAN.equals(propertyDefinition.getType())) {
+ defProperty = new BooleanProperty();
+ } else if (BluePrintConstants.DATA_TYPE_INTEGER.equals(propertyDefinition.getType())) {
+ StringProperty stringProperty = new StringProperty();
+ stringProperty.setType("integer");
+ defProperty = stringProperty;
+ } else if (BluePrintConstants.DATA_TYPE_FLOAT.equals(propertyDefinition.getType())) {
+ StringProperty stringProperty = new StringProperty();
+ stringProperty.setFormat("float");
+ defProperty = stringProperty;
+ } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP.equals(propertyDefinition.getType())) {
+ DateTimeProperty dateTimeProperty = new DateTimeProperty();
+ dateTimeProperty.setFormat("date-time");
+ defProperty = dateTimeProperty;
+ } else {
+ defProperty = new StringProperty();
+ }
+ } else if (BluePrintTypes.validCollectionTypes().contains(propertyDefinition.getType())) {
+ ArrayProperty arrayProperty = new ArrayProperty();
+ if (propertyDefinition.getEntrySchema() != null) {
+ String entrySchema = propertyDefinition.getEntrySchema().getType();
+ if (!BluePrintTypes.validPrimitiveTypes().contains(entrySchema)) {
+ Property innerType = new RefProperty("#/definitions/" + entrySchema);
+ arrayProperty.setItems(innerType);
+ } else {
+ Property innerType = new StringProperty();
+ arrayProperty.setItems(innerType);
+ }
+ defProperty = arrayProperty;
+ }
+
+ } else {
+ defProperty = new RefProperty("#/definitions/" + propertyDefinition.getType());
+ }
+ defProperty.setName(name);
+ if (propertyDefinition.getDefaultValue() != null) {
+ defProperty.setDefault(String.valueOf(propertyDefinition.getDefaultValue()));
+ }
+
+ defProperty.setRequired(BooleanUtils.isTrue(propertyDefinition.getRequired()));
+ defProperty.setDescription(propertyDefinition.getDescription());
+ return defProperty;
+ }
+
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java
new file mode 100644
index 00000000..224960fa
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java
@@ -0,0 +1,291 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonManagedReference;
+import org.hibernate.annotations.Proxy;
+import org.springframework.data.annotation.LastModifiedDate;
+import org.springframework.data.jpa.domain.support.AuditingEntityListener;
+
+import javax.persistence.*;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * ConfigModel.java Purpose: Provide Configuration Generator ConfigModel Entity
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+
+@EntityListeners({AuditingEntityListener.class})
+@Entity
+@Table(name = "CONFIG_MODEL")
+@Proxy(lazy=false)
+public class ConfigModel implements Serializable {
+ private static final long serialVersionUID = 1L;
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "config_model_id")
+ private Long id;
+
+ @Column(name = "service_uuid")
+ private String serviceUUID;
+
+ @Column(name = "distribution_id")
+ private String distributionId;
+
+ @Column(name = "service_name")
+ private String serviceName;
+
+ @Column(name = "service_description")
+ private String serviceDescription;
+
+ @Column(name = "resource_uuid")
+ private String resourceUUID;
+
+ @Column(name = "resource_instance_name")
+ private String resourceInstanceName;
+
+ @Column(name = "resource_name")
+ private String resourceName;
+
+ @Column(name = "resource_version")
+ private String resourceVersion;
+
+ @Column(name = "resource_type")
+ private String resourceType;
+
+ @Column(name = "artifact_uuid")
+ private String artifactUUId;
+
+ @Column(name = "artifact_type")
+ private String artifactType;
+
+ @NotNull
+ @Column(name = "artifact_version")
+ private String artifactVersion;
+
+ @Lob
+ @Column(name = "artifact_description")
+ private String artifactDescription;
+
+ @Column(name = "internal_version")
+ private Integer internalVersion;
+
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MM/dd/yyyy KK:mm:ss a Z")
+ @LastModifiedDate
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "creation_date")
+ private Date createdDate = new Date();
+
+ @NotNull
+ @Column(name = "artifact_name")
+ private String artifactName;
+
+ @NotNull
+ @Column(name = "published")
+ private String published;
+
+ @NotNull
+ @Column(name = "updated_by")
+ private String updatedBy;
+
+ @NotNull
+ @Lob
+ @Column(name = "tags")
+ private String tags;
+
+
+ @OneToMany(mappedBy = "configModel", fetch = FetchType.EAGER, orphanRemoval = true, cascade = CascadeType.ALL)
+ @Column(nullable = true)
+ @JsonManagedReference
+ private List<ConfigModelContent> configModelContents = new ArrayList<>();
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getServiceUUID() {
+ return serviceUUID;
+ }
+
+ public void setServiceUUID(String serviceUUID) {
+ this.serviceUUID = serviceUUID;
+ }
+
+ public String getDistributionId() {
+ return distributionId;
+ }
+
+ public void setDistributionId(String distributionId) {
+ this.distributionId = distributionId;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public String getServiceDescription() {
+ return serviceDescription;
+ }
+
+ public void setServiceDescription(String serviceDescription) {
+ this.serviceDescription = serviceDescription;
+ }
+
+ public String getResourceUUID() {
+ return resourceUUID;
+ }
+
+ public void setResourceUUID(String resourceUUID) {
+ this.resourceUUID = resourceUUID;
+ }
+
+ public String getResourceInstanceName() {
+ return resourceInstanceName;
+ }
+
+ public void setResourceInstanceName(String resourceInstanceName) {
+ this.resourceInstanceName = resourceInstanceName;
+ }
+
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ public void setResourceName(String resourceName) {
+ this.resourceName = resourceName;
+ }
+
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ public String getResourceType() {
+ return resourceType;
+ }
+
+ public void setResourceType(String resourceType) {
+ this.resourceType = resourceType;
+ }
+
+ public String getArtifactUUId() {
+ return artifactUUId;
+ }
+
+ public void setArtifactUUId(String artifactUUId) {
+ this.artifactUUId = artifactUUId;
+ }
+
+ public String getArtifactType() {
+ return artifactType;
+ }
+
+ public void setArtifactType(String artifactType) {
+ this.artifactType = artifactType;
+ }
+
+ public String getArtifactVersion() {
+ return artifactVersion;
+ }
+
+ public void setArtifactVersion(String artifactVersion) {
+ this.artifactVersion = artifactVersion;
+ }
+
+ public String getArtifactDescription() {
+ return artifactDescription;
+ }
+
+ public void setArtifactDescription(String artifactDescription) {
+ this.artifactDescription = artifactDescription;
+ }
+
+ public Integer getInternalVersion() {
+ return internalVersion;
+ }
+
+ public void setInternalVersion(Integer internalVersion) {
+ this.internalVersion = internalVersion;
+ }
+
+ public Date getCreatedDate() {
+ return createdDate;
+ }
+
+ public void setCreatedDate(Date createdDate) {
+ this.createdDate = createdDate;
+ }
+
+ public String getArtifactName() {
+ return artifactName;
+ }
+
+ public void setArtifactName(String artifactName) {
+ this.artifactName = artifactName;
+ }
+
+ public String getPublished() {
+ return published;
+ }
+
+ public void setPublished(String published) {
+ this.published = published;
+ }
+
+ public String getUpdatedBy() {
+ return updatedBy;
+ }
+
+ public void setUpdatedBy(String updatedBy) {
+ this.updatedBy = updatedBy;
+ }
+
+ public String getTags() {
+ return tags;
+ }
+
+ public void setTags(String tags) {
+ this.tags = tags;
+ }
+
+ public List<ConfigModelContent> getConfigModelContents() {
+ return configModelContents;
+ }
+
+ public void setConfigModelContents(List<ConfigModelContent> configModelContents) {
+ this.configModelContents = configModelContents;
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java
new file mode 100644
index 00000000..f7bd554d
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java
@@ -0,0 +1,175 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.domain;
+
+import com.fasterxml.jackson.annotation.JsonBackReference;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.data.annotation.LastModifiedDate;
+import org.springframework.data.jpa.domain.support.AuditingEntityListener;
+
+import javax.persistence.*;
+import javax.validation.constraints.NotNull;
+import java.util.Date;
+import java.util.Objects;
+
+/**
+ * DataDictionary.java Purpose: Provide Configuration Generator DataDictionary Entity
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@EntityListeners({AuditingEntityListener.class})
+@Entity
+@Table(name = "CONFIG_MODEL_CONTENT")
+public class ConfigModelContent {
+
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "config_model_content_id")
+ private Long id;
+
+ @NotNull
+ @Column(name = "name")
+ private String name;
+
+ @NotNull
+ @Column(name = "content_type")
+ private String contentType;
+
+
+ @ManyToOne
+ @JoinColumn(name = "config_model_id")
+ @JsonBackReference
+ private ConfigModel configModel;
+
+ @Lob
+ @Column(name = "description")
+ private String description;
+
+ @NotNull
+ @Lob
+ @Column(name = "content")
+ private String content;
+
+
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MM/dd/yyyy KK:mm:ss a Z")
+ @LastModifiedDate
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "updated_date")
+ private Date creationDate;
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder("[");
+ builder.append("id = " + id);
+ builder.append(", name = " + name);
+ builder.append(", contentType = " + contentType);
+ builder.append("]");
+ return builder.toString();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+
+ if (o == this) {
+ return true;
+ }
+ if (!(o instanceof ConfigModelContent)) {
+ return false;
+ }
+ ConfigModelContent configModelContent = (ConfigModelContent) o;
+ return Objects.equals(id, configModelContent.id) && Objects.equals(name, configModelContent.name)
+ && Objects.equals(contentType, configModelContent.contentType);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, name, contentType);
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+
+ public String getName() {
+ return name;
+ }
+
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+
+ public String getContentType() {
+ return contentType;
+ }
+
+
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+ }
+
+
+ public ConfigModel getConfigModel() {
+ return configModel;
+ }
+
+
+ public void setConfigModel(ConfigModel configModel) {
+ this.configModel = configModel;
+ }
+
+
+ public String getDescription() {
+ return description;
+ }
+
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+
+ public String getContent() {
+ return content;
+ }
+
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+
+ public Date getCreationDate() {
+ return creationDate;
+ }
+
+
+ public void setCreationDate(Date creationDate) {
+ this.creationDate = creationDate;
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelSearch.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelSearch.java
new file mode 100644
index 00000000..2e901883
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelSearch.java
@@ -0,0 +1,171 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.data.annotation.LastModifiedDate;
+
+import javax.persistence.*;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.Date;
+
+@Entity
+@Table(name = "CONFIG_MODEL")
+public class ConfigModelSearch implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "config_model_id")
+ private Long id;
+
+ @Column(name = "artifact_uuid")
+ private String artifactUUId;
+
+ @Column(name = "artifact_type")
+ private String artifactType;
+
+ @NotNull
+ @Column(name = "artifact_version")
+ private String artifactVersion;
+
+ @Lob
+ @Column(name = "artifact_description")
+ private String artifactDescription;
+
+ @Column(name = "internal_version")
+ private Integer internalVersion;
+
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MM/dd/yyyy KK:mm:ss a Z")
+ @LastModifiedDate
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "creation_date")
+ private Date createdDate = new Date();
+
+ @NotNull
+ @Column(name = "artifact_name")
+ private String artifactName;
+
+ @NotNull
+ @Column(name = "published")
+ private String published;
+
+ @NotNull
+ @Column(name = "updated_by")
+ private String updatedBy;
+
+ @NotNull
+ @Lob
+ @Column(name = "tags")
+ private String tags;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getArtifactUUId() {
+ return artifactUUId;
+ }
+
+ public void setArtifactUUId(String artifactUUId) {
+ this.artifactUUId = artifactUUId;
+ }
+
+ public String getArtifactType() {
+ return artifactType;
+ }
+
+ public void setArtifactType(String artifactType) {
+ this.artifactType = artifactType;
+ }
+
+ public String getArtifactVersion() {
+ return artifactVersion;
+ }
+
+ public void setArtifactVersion(String artifactVersion) {
+ this.artifactVersion = artifactVersion;
+ }
+
+ public String getArtifactDescription() {
+ return artifactDescription;
+ }
+
+ public void setArtifactDescription(String artifactDescription) {
+ this.artifactDescription = artifactDescription;
+ }
+
+ public Integer getInternalVersion() {
+ return internalVersion;
+ }
+
+ public void setInternalVersion(Integer internalVersion) {
+ this.internalVersion = internalVersion;
+ }
+
+ public Date getCreatedDate() {
+ return createdDate;
+ }
+
+ public void setCreatedDate(Date createdDate) {
+ this.createdDate = createdDate;
+ }
+
+ public String getArtifactName() {
+ return artifactName;
+ }
+
+ public void setArtifactName(String artifactName) {
+ this.artifactName = artifactName;
+ }
+
+ public String getPublished() {
+ return published;
+ }
+
+ public void setPublished(String published) {
+ this.published = published;
+ }
+
+ public String getUpdatedBy() {
+ return updatedBy;
+ }
+
+ public void setUpdatedBy(String updatedBy) {
+ this.updatedBy = updatedBy;
+ }
+
+ public String getTags() {
+ return tags;
+ }
+
+ public void setTags(String tags) {
+ this.tags = tags;
+ }
+
+ public static long getSerialversionuid() {
+ return serialVersionUID;
+ }
+
+
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java
new file mode 100644
index 00000000..ed6340a6
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java
@@ -0,0 +1,170 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.domain;
+
+import org.springframework.data.annotation.LastModifiedDate;
+import org.springframework.data.jpa.domain.support.AuditingEntityListener;
+
+import javax.persistence.*;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.Date;
+
+
+/**
+ * AsdcReference.java Purpose: Provide Configuration Generator AsdcReference Entity
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@EntityListeners({AuditingEntityListener.class})
+@Entity
+@Table(name = "MODEL_TYPE")
+public class ModelType implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @NotNull
+ @Column(name = "model_name", nullable = false)
+ private String modelName;
+
+ @NotNull
+ @Column(name = "derived_from")
+ private String derivedFrom;
+
+ @NotNull
+ @Column(name = "definition_type")
+ private String definitionType;
+
+ @NotNull
+ @Lob
+ @Column(name = "definition")
+ private String definition;
+
+ @NotNull
+ @Lob
+ @Column(name = "description")
+ private String description;
+
+ @NotNull
+ @Column(name = "version")
+ private String version;
+
+ @NotNull
+ @Lob
+ @Column(name = "tags")
+ private String tags;
+
+ // @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MM/dd/yyyy KK:mm:ss a Z")
+ @LastModifiedDate
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "creation_date")
+ private Date creationDate;
+
+ @NotNull
+ @Column(name = "updated_by")
+ private String updatedBy;
+
+ @Override
+ public String toString() {
+ StringBuilder buffer = new StringBuilder("[");
+ buffer.append(", modelName = " + modelName);
+ buffer.append(", derivedFrom = " + derivedFrom);
+ buffer.append(", definitionType = " + definitionType);
+ buffer.append(", description = " + description);
+ buffer.append(", creationDate = " + creationDate);
+ buffer.append(", version = " + version);
+ buffer.append(", updatedBy = " + updatedBy);
+ buffer.append(", tags = " + tags);
+ buffer.append("]");
+ return buffer.toString();
+ }
+
+ public String getModelName() {
+ return modelName;
+ }
+
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ public String getDerivedFrom() {
+ return derivedFrom;
+ }
+
+ public void setDerivedFrom(String derivedFrom) {
+ this.derivedFrom = derivedFrom;
+ }
+
+ public String getDefinitionType() {
+ return definitionType;
+ }
+
+ public void setDefinitionType(String definitionType) {
+ this.definitionType = definitionType;
+ }
+
+ public String getDefinition() {
+ return definition;
+ }
+
+ public void setDefinition(String definition) {
+ this.definition = definition;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getTags() {
+ return tags;
+ }
+
+ public void setTags(String tags) {
+ this.tags = tags;
+ }
+
+ public Date getCreationDate() {
+ return creationDate;
+ }
+
+ public void setCreationDate(Date creationDate) {
+ this.creationDate = creationDate;
+ }
+
+ public String getUpdatedBy() {
+ return updatedBy;
+ }
+
+ public void setUpdatedBy(String updatedBy) {
+ this.updatedBy = updatedBy;
+ }
+
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java
new file mode 100644
index 00000000..adb01884
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java
@@ -0,0 +1,207 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.domain;
+
+import org.springframework.data.annotation.LastModifiedDate;
+import org.springframework.data.jpa.domain.support.AuditingEntityListener;
+
+import javax.persistence.*;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * DataDictionary.java Purpose: Provide Configuration Generator DataDictionary Entity
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@EntityListeners({AuditingEntityListener.class})
+@Entity
+@Table(name = "RESOURCE_DICTIONARY")
+public class ResourceDictionary implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @NotNull
+ @Column(name = "name")
+ private String name;
+
+ @NotNull
+ @Column(name = "resource_path")
+ private String resourcePath;
+
+ @NotNull
+ @Column(name = "resource_type")
+ private String resourceType;
+
+ @NotNull
+ @Column(name = "data_type")
+ private String dataType;
+
+ @Column(name = "entry_schema")
+ private String entrySchema;
+
+ @Lob
+ @Column(name = "valid_values")
+ private String validValues;
+
+ @Lob
+ @Column(name = "sample_value")
+ private String sampleValue;
+
+ @NotNull
+ @Lob
+ @Column(name = "definition")
+ private String definition;
+
+ @NotNull
+ @Lob
+ @Column(name = "description")
+ private String description;
+
+ @NotNull
+ @Lob
+ @Column(name = "tags")
+ private String tags;
+
+ @LastModifiedDate
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "creation_date")
+ private Date creationDate;
+
+ @NotNull
+ @Column(name = "updated_by")
+ private String updatedBy;
+
+ @Override
+ public String toString() {
+ StringBuilder buffer = new StringBuilder("[");
+ buffer.append(", name = " + name);
+ buffer.append(", resourcePath = " + resourcePath);
+ buffer.append(", resourceType = " + resourceType);
+ buffer.append(", dataType = " + dataType);
+ buffer.append(", entrySchema = " + entrySchema);
+ buffer.append(", validValues = " + validValues);
+ buffer.append(", definition =" + definition);
+ buffer.append(", description = " + description);
+ buffer.append(", updatedBy = " + updatedBy);
+ buffer.append(", tags = " + tags);
+ buffer.append(", creationDate = " + creationDate);
+ buffer.append("]");
+ return buffer.toString();
+ }
+
+ public String getResourcePath() {
+ return resourcePath;
+ }
+
+ public void setResourcePath(String resourcePath) {
+ this.resourcePath = resourcePath;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getResourceType() {
+ return resourceType;
+ }
+
+ public void setResourceType(String resourceType) {
+ this.resourceType = resourceType;
+ }
+
+ public String getDataType() {
+ return dataType;
+ }
+
+ public void setDataType(String dataType) {
+ this.dataType = dataType;
+ }
+
+ public String getEntrySchema() {
+ return entrySchema;
+ }
+
+ public void setEntrySchema(String entrySchema) {
+ this.entrySchema = entrySchema;
+ }
+
+ public String getValidValues() {
+ return validValues;
+ }
+
+ public void setValidValues(String validValues) {
+ this.validValues = validValues;
+ }
+
+ public String getSampleValue() {
+ return sampleValue;
+ }
+
+ public void setSampleValue(String sampleValue) {
+ this.sampleValue = sampleValue;
+ }
+
+ public String getDefinition() {
+ return definition;
+ }
+
+ public void setDefinition(String definition) {
+ this.definition = definition;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getTags() {
+ return tags;
+ }
+
+ public void setTags(String tags) {
+ this.tags = tags;
+ }
+
+ public Date getCreationDate() {
+ return creationDate;
+ }
+
+ public void setCreationDate(Date creationDate) {
+ this.creationDate = creationDate;
+ }
+
+ public String getUpdatedBy() {
+ return updatedBy;
+ }
+
+ public void setUpdatedBy(String updatedBy) {
+ this.updatedBy = updatedBy;
+ }
+
+
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/model/AutoMapResponse.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/model/AutoMapResponse.java
new file mode 100644
index 00000000..2250828a
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/model/AutoMapResponse.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.model;
+
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
+
+import java.util.List;
+
+/**
+ * ArtifactRequest.java Purpose: Provide Configuration Generator ArtifactRequest Model
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+public class AutoMapResponse {
+
+ private List<ResourceAssignment> resourceAssignments;
+ private List<ResourceDictionary> dataDictionaries;
+
+ public List<ResourceAssignment> getResourceAssignments() {
+ return resourceAssignments;
+ }
+
+ public void setResourceAssignments(List<ResourceAssignment> resourceAssignments) {
+ this.resourceAssignments = resourceAssignments;
+ }
+
+ public List<ResourceDictionary> getDataDictionaries() {
+ return dataDictionaries;
+ }
+
+ public void setDataDictionaries(List<ResourceDictionary> dataDictionaries) {
+ this.dataDictionaries = dataDictionaries;
+ }
+
+
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelContentRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelContentRepository.java
new file mode 100644
index 00000000..ad2584a8
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelContentRepository.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.repository;
+
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * ConfigModelContentRepository.java Purpose: Provide ConfigModelContentRepository of Repository
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Repository
+public interface ConfigModelContentRepository extends JpaRepository<ConfigModelContent, Long> {
+
+ /**
+ * This is a findById method
+ *
+ * @param id
+ * @return Optional<AsdcArtifacts>
+ */
+ Optional<ConfigModelContent> findById(Long id);
+
+ /**
+ * This is a findTopByConfigModelAndContentType method
+ *
+ * @param configModel
+ * @param contentType
+ * @return Optional<ConfigModelContent>
+ */
+ Optional<ConfigModelContent> findTopByConfigModelAndContentType(ConfigModel configModel, String contentType);
+
+ /**
+ * This is a findByConfigModelAndContentType method
+ *
+ * @param configModel
+ * @param contentType
+ * @return Optional<ConfigModelContent>
+ */
+ List<ConfigModelContent> findByConfigModelAndContentType(ConfigModel configModel, String contentType);
+
+ /**
+ * This is a findByConfigModel method
+ *
+ * @param configModel
+ * @return Optional<ConfigModelContent>
+ */
+ List<ConfigModelContent> findByConfigModel(ConfigModel configModel);
+
+ /**
+ * This is a findByConfigModelAndContentTypeAndName method
+ *
+ * @param configModel
+ * @param contentType
+ * @param name
+ * @return Optional<ConfigModelContent>
+ */
+ Optional<ConfigModelContent> findByConfigModelAndContentTypeAndName(ConfigModel configModel,
+ String contentType, String name);
+
+ /**
+ * This is a deleteByMdeleteByConfigModelodelName method
+ *
+ * @param configModel
+ */
+ void deleteByConfigModel(ConfigModel configModel);
+
+ /**
+ * This is a deleteById method
+ *
+ * @param id
+ */
+ void deleteById(Long id);
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelRepository.java
new file mode 100644
index 00000000..4822ee97
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelRepository.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.repository;
+
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * AsdcArtifactsRepository.java Purpose: Provide Configuration Generator AsdcArtifactsRepository
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Repository
+public interface ConfigModelRepository extends JpaRepository<ConfigModel, Long> {
+ /**
+ * This is a findById method
+ *
+ * @param id
+ * @return Optional<AsdcArtifacts>
+ */
+ Optional<ConfigModel> findById(Long id);
+
+ /**
+ * This is a findByArtifactNameAndArtifactVersion method
+ *
+ * @param artifactName
+ * @param artifactVersion
+ * @return Optional<AsdcArtifacts>
+ */
+ Optional<ConfigModel> findByArtifactNameAndArtifactVersion(String artifactName, String artifactVersion);
+
+ /**
+ * This is a findTopByArtifactNameOrderByArtifactIdDesc method
+ *
+ * @param artifactName
+ * @return Optional<AsdcArtifacts>
+ */
+ Optional<ConfigModel> findTopByArtifactNameOrderByArtifactVersionDesc(String artifactName);
+
+ /**
+ * This is a findTopByArtifactName method
+ *
+ * @param artifactName
+ * @return Optional<AsdcArtifacts>
+ */
+ List<ConfigModel> findTopByArtifactName(String artifactName);
+
+ /**
+ * This is a findByTagsContainingIgnoreCase method
+ *
+ * @param tags
+ * @return Optional<ModelType>
+ */
+ List<ConfigModel> findByTagsContainingIgnoreCase(String tags);
+
+ /**
+ * This is a deleteByArtifactNameAndArtifactVersion method
+ *
+ * @param artifactName
+ * @param artifactVersion
+ */
+ void deleteByArtifactNameAndArtifactVersion(String artifactName, String artifactVersion);
+
+ /**
+ * This is a deleteById method
+ *
+ * @param id
+ */
+ void deleteById(Long id);
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelSearchRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelSearchRepository.java
new file mode 100644
index 00000000..bafc3aa8
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelSearchRepository.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.repository;
+
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelSearch;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * ConfigModelSearchRepository.java Purpose: Provide Configuration Generator AsdcArtifactsRepository
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Repository
+public interface ConfigModelSearchRepository extends JpaRepository<ConfigModelSearch, Long> {
+
+
+ /**
+ * This is a findByTagsContainingIgnoreCase method
+ *
+ * @param tags
+ * @return Optional<ModelType>
+ */
+ List<ConfigModel> findByTagsContainingIgnoreCase(String tags);
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java
new file mode 100644
index 00000000..51ae752f
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.repository;
+
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Optional;
+
+
+/**
+ * ModelTypeRepository.java Purpose: Provide Configuration Generator ModelTypeRepository
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Repository
+public interface ModelTypeRepository extends JpaRepository<ModelType, String> {
+
+
+ /**
+ * This is a findByModelName method
+ *
+ * @param modelName
+ * @return Optional<ModelType>
+ */
+ Optional<ModelType> findByModelName(String modelName);
+
+ /**
+ * This is a findByDerivedFrom method
+ *
+ * @param derivedFrom
+ * @return List<ModelType>
+ */
+ List<ModelType> findByDerivedFrom(String derivedFrom);
+
+
+ /**
+ * This is a findByDerivedFromIn method
+ *
+ * @param derivedFroms
+ * @return List<ModelType>
+ */
+ List<ModelType> findByDerivedFromIn(List<String> derivedFroms);
+
+ /**
+ * This is a findByDefinitionType method
+ *
+ * @param definitionType
+ * @return List<ModelType>
+ */
+ List<ModelType> findByDefinitionType(String definitionType);
+
+ /**
+ * This is a findByDefinitionTypeIn method
+ *
+ * @param definitionTypes
+ * @return List<ModelType>
+ */
+ List<ModelType> findByDefinitionTypeIn(List<String> definitionTypes);
+
+
+ /**
+ * This is a findByTagsContainingIgnoreCase method
+ *
+ * @param tags
+ * @return Optional<ModelType>
+ */
+ List<ModelType> findByTagsContainingIgnoreCase(String tags);
+
+
+ /**
+ * This is a deleteByModelName method
+ *
+ * @param modelName
+ * @return Optional<ModelType>
+ */
+ void deleteByModelName(String modelName);
+
+
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryRepository.java
new file mode 100644
index 00000000..279dcd1c
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryRepository.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.repository;
+
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * ResourceMappingRepository.java Purpose: Provide Configuration Generator ResourceMappingRepository
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Repository
+public interface ResourceDictionaryRepository extends JpaRepository<ResourceDictionary, String> {
+
+
+ /**
+ * This is a findByName method
+ *
+ * @param name
+ * @return Optional<ResourceMapping>
+ */
+ Optional<ResourceDictionary> findByName(String name);
+
+ /**
+ * This is a findByNameIn method
+ *
+ * @param names
+ * @return Optional<ResourceMapping>
+ */
+ List<ResourceDictionary> findByNameIn(List<String> names);
+
+ /**
+ * This is a findByTagsContainingIgnoreCase method
+ *
+ * @param tags
+ * @return Optional<ModelType>
+ */
+ List<ResourceDictionary> findByTagsContainingIgnoreCase(String tags);
+
+ /**
+ * This is a deleteByName method
+ *
+ * @param name
+ */
+ void deleteByName(String name);
+
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java
new file mode 100644
index 00000000..86c89bf9
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java
@@ -0,0 +1,179 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.rs;
+
+import io.swagger.annotations.*;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+import java.util.List;
+
+/**
+ * ConfigModelRest.java Purpose: Rest service controller for ConfigModelRest Management
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Api
+@Path("/service")
+@Produces({MediaType.APPLICATION_JSON})
+public interface ConfigModelRest {
+
+ /**
+ * This is a getConfigModel rest service
+ *
+ * @param id
+ * @return ConfigModel
+ * @throws BluePrintException
+ */
+ @GET
+ @Path("/configmodel/{id}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to Search Service Template", response = ConfigModel.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ @RequestMapping(value = "/configmodel/{id}", method = RequestMethod.GET)
+ @ResponseBody ConfigModel getConfigModel(@ApiParam(required = true) @PathParam("id") Long id)
+ throws BluePrintException;
+
+
+ /**
+ * This is a saveConfigModel rest service
+ *
+ * @param configModel
+ * @return ConfigModel
+ * @throws BluePrintException
+ */
+ @POST
+ @Path("/configmodel")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to get Model Type by Tags", response = ServiceTemplate.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ ConfigModel saveConfigModel(@ApiParam(required = true) ConfigModel configModel)
+ throws BluePrintException;
+
+ /**
+ * This is a deleteConfigModel rest service
+ *
+ * @param id
+ * @throws BluePrintException
+ */
+ @DELETE
+ @Path("/configmodel/{id}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to delete ConfigModel.")
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ void deleteConfigModel(@ApiParam(required = true) @PathParam("id") Long id) throws BluePrintException;
+
+ /**
+ * This is a getInitialConfigModel rest service
+ *
+ * @param name
+ * @return ConfigModel
+ * @throws BluePrintException
+ */
+ @GET
+ @Path("/configmodelinitial/{name}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to create default Service Template", response = ConfigModel.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ ConfigModel getInitialConfigModel(@ApiParam(required = true) @PathParam("name") String name)
+ throws BluePrintException;
+
+ /**
+ * This is a getCloneConfigModel rest service
+ *
+ * @param id
+ * @return ConfigModel
+ * @throws BluePrintException
+ */
+ @GET
+ @Path("/configmodelclone/{id}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to create default Service Template", response = ConfigModel.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ ConfigModel getCloneConfigModel(@ApiParam(required = true) @PathParam("id") Long id)
+ throws BluePrintException;
+
+ /**
+ * This is a publishConfigModel rest service
+ *
+ * @param id
+ * @return ServiceTemplate
+ * @throws BluePrintException
+ */
+ @GET
+ @Path("/configmodelpublish/{id}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to get Model Type by Tags", response = ConfigModel.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ ConfigModel publishConfigModel(@ApiParam(required = true) @PathParam("id") Long id)
+ throws BluePrintException;
+
+ /**
+ * This is a getConfigModelByNameAndVersion rest service
+ *
+ * @param name
+ * @param version
+ * @return ConfigModel
+ * @throws BluePrintException
+ */
+ @GET
+ @Path("/configmodelbyname/{name}/version/{version}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to Search Service Template", response = ConfigModel.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ ConfigModel getConfigModelByNameAndVersion(@ApiParam(required = true) @PathParam("name") String name,
+ @ApiParam(required = true) @PathParam("version") String version) throws BluePrintException;
+
+ /**
+ * This is a searchServiceModels rest service
+ *
+ * @param tags
+ * @return List<ConfigModel>
+ * @throws BluePrintException
+ */
+ @GET
+ @Path("/configmodelsearch/{tags}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to Search Service Template", response = ConfigModel.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ List<ConfigModel> searchConfigModels(@ApiParam(required = true) @PathParam("tags") String tags)
+ throws BluePrintException;
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestImpl.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestImpl.java
new file mode 100644
index 00000000..a9abcd5f
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestImpl.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.rs;
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.service.ConfigModelService;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * {@inheritDoc}
+ */
+@Service
+public class ConfigModelRestImpl implements ConfigModelRest {
+
+ private ConfigModelService configModelService;
+
+ /**
+ * This is a ConfigModelRestImpl constructor.
+ *
+ * @param configModelService Config Model Service
+ */
+ public ConfigModelRestImpl(ConfigModelService configModelService) {
+ this.configModelService = configModelService;
+
+ }
+
+ @Override
+ public ConfigModel getInitialConfigModel(String name) throws BluePrintException {
+ try {
+ return this.configModelService.getInitialConfigModel(name);
+ } catch (Exception e) {
+ throw new BluePrintException(2000, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public ConfigModel saveConfigModel(ConfigModel configModel) throws BluePrintException {
+ try {
+ return this.configModelService.saveConfigModel(configModel);
+ } catch (Exception e) {
+ throw new BluePrintException(2200, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public void deleteConfigModel(Long id) throws BluePrintException {
+ try {
+ this.configModelService.deleteConfigModel(id);
+ } catch (Exception e) {
+ throw new BluePrintException(4000, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public ConfigModel publishConfigModel(Long id) throws BluePrintException {
+ try {
+ return this.configModelService.publishConfigModel(id);
+ } catch (Exception e) {
+ throw new BluePrintException(2500, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public ConfigModel getConfigModel(Long id) throws BluePrintException {
+ try {
+ return this.configModelService.getConfigModel(id);
+ } catch (Exception e) {
+ throw new BluePrintException(2001, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public ConfigModel getConfigModelByNameAndVersion(String name, String version) throws BluePrintException {
+ try {
+ return this.configModelService.getConfigModelByNameAndVersion(name, version);
+ } catch (Exception e) {
+ throw new BluePrintException(2002, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public List<ConfigModel> searchConfigModels(String tags) throws BluePrintException {
+ try {
+ return this.configModelService.searchConfigModels(tags);
+ } catch (Exception e) {
+ throw new BluePrintException(2003, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public ConfigModel getCloneConfigModel(Long id) throws BluePrintException {
+ try {
+ return this.configModelService.getCloneConfigModel(id);
+ } catch (Exception e) {
+ throw new BluePrintException(2004, e.getMessage(), e);
+ }
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java
new file mode 100644
index 00000000..59b73030
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.rs;
+
+import io.swagger.annotations.*;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+import java.util.List;
+
+/**
+ * ModelTypeRest.java Purpose: Rest service controller for Artifact Handling
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Api
+@Path("/service")
+@Produces({MediaType.APPLICATION_JSON})
+public interface ModelTypeRest {
+
+ /**
+ * This is a getModelTypeByName rest service
+ *
+ * @param name
+ * @return ModelType
+ * @throws BluePrintException
+ */
+ @GET
+ @Path("/modeltype/{name}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to get Model Type by id", response = ModelType.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ ModelType getModelTypeByName(@ApiParam(required = true) @PathParam("name") String name)
+ throws BluePrintException;
+
+ /**
+ * This is a saveModelType rest service
+ *
+ * @param modelType
+ * @return ModelType
+ * @throws BluePrintException
+ */
+
+ @POST
+ @Path("/modeltype")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to Save Model Type", response = ModelType.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ ModelType saveModelType(@ApiParam(required = true) ModelType modelType) throws BluePrintException;
+
+ /**
+ * This is a deleteModelType rest service
+ *
+ * @param name
+ * @throws BluePrintException
+ */
+ @DELETE
+ @Path("/modeltype/{name}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to delete Model Type")
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ void deleteModelTypeByName(@ApiParam(required = true) @PathParam("name") String name)
+ throws BluePrintException;
+
+ /**
+ * This is a searchModelType rest service
+ *
+ * @param tags
+ * @return List<ModelType>
+ * @throws BluePrintException
+ */
+ @GET
+ @Path("/modeltypesearch/{tags}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to get Model Type by tags", response = ModelType.class,
+ responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ List<ModelType> searchModelTypes(@ApiParam(required = true) @PathParam("tags") String tags)
+ throws BluePrintException;
+
+ /**
+ * This is a getModelTypeByDefinitionType rest service
+ *
+ * @param definitionType
+ * @return List<ModelType>
+ * @throws BluePrintException
+ */
+ @GET
+ @Path("/modeltypebydefinition/{definitionType}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to get Model Type by tags", response = ModelType.class,
+ responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ List<ModelType> getModelTypeByDefinitionType(
+ @ApiParam(required = true) @PathParam("definitionType") String definitionType)
+ throws BluePrintException;
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestImpl.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestImpl.java
new file mode 100644
index 00000000..6fbc6969
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestImpl.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.rs;
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.service.ModelTypeService;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * {@inheritDoc}
+ */
+@Service
+public class ModelTypeRestImpl implements ModelTypeRest {
+
+ private ModelTypeService modelTypeService;
+
+ /**
+ * This is a ModelTypeResourceImpl, used to save and get the model types stored in database
+ *
+ * @param modelTypeService Model Type Service
+ */
+ public ModelTypeRestImpl(ModelTypeService modelTypeService) {
+ this.modelTypeService = modelTypeService;
+ }
+
+ @Override
+ public ModelType getModelTypeByName(String modelName) throws BluePrintException {
+ try {
+ return modelTypeService.getModelTypeByName(modelName);
+ } catch (Exception e) {
+ throw new BluePrintException(1000, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public List<ModelType> searchModelTypes(String tags) throws BluePrintException {
+ try {
+ return modelTypeService.searchModelTypes(tags);
+ } catch (Exception e) {
+ throw new BluePrintException(1001, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public List<ModelType> getModelTypeByDefinitionType(String definitionType) throws BluePrintException {
+ try {
+ return modelTypeService.getModelTypeByDefinitionType(definitionType);
+ } catch (Exception e) {
+ throw new BluePrintException(1002, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public ModelType saveModelType(ModelType modelType) throws BluePrintException {
+ try {
+ return modelTypeService.saveModel(modelType);
+ } catch (Exception e) {
+ throw new BluePrintException(1100, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public void deleteModelTypeByName(String name) throws BluePrintException {
+ try {
+ modelTypeService.deleteByModelName(name);
+ } catch (Exception e) {
+ throw new BluePrintException(1400, e.getMessage(), e);
+ }
+ }
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java
new file mode 100644
index 00000000..5bc98336
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.rs;
+
+import io.swagger.annotations.*;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+import java.util.List;
+
+/**
+ * ResourceDictionaryRest.java Purpose: Rest service controller for Artifact Handling
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Api
+@Path("/service")
+@Produces({MediaType.APPLICATION_JSON})
+
+public interface ResourceDictionaryRest {
+
+ /**
+ * This is a getDataDictionaryByPath rest service
+ *
+ * @param name
+ * @return ResourceDictionary
+ * @throws BluePrintException
+ */
+ @GET
+ @Path("/dictionary/{name}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to get Resource dictionary", response = ResourceDictionary.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ ResourceDictionary getResourceDictionaryByName(@ApiParam(required = true) @PathParam("name") String name)
+ throws BluePrintException;
+
+ /**
+ * This is a saveDataDictionary rest service
+ *
+ * @param resourceMapping
+ * @return ResourceDictionary
+ * @throws BluePrintException
+ */
+
+ @POST
+ @Path("/dictionary")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to Save Resource dictionary Type", response = ResourceDictionary.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ ResourceDictionary saveResourceDictionary(@ApiParam(required = true) ResourceDictionary resourceMapping)
+ throws BluePrintException;
+
+ /**
+ * This is a deleteDataDictionaryByName rest service
+ *
+ * @param name
+ * @throws BluePrintException
+ */
+ @DELETE
+ @Path("/dictionary/{name}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to delete ResourceDictionary Type")
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ void deleteResourceDictionaryByName(@ApiParam(required = true) @PathParam("name") String name)
+ throws BluePrintException;
+
+ /**
+ * This is a searchResourceDictionaryByTags rest service
+ *
+ * @param tags
+ * @return ResourceDictionary
+ * @throws BluePrintException
+ */
+ @GET
+ @Path("/dictionarysearch/{tags}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to search Resource dictionary by tags",
+ response = ResourceDictionary.class, responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ List<ResourceDictionary> searchResourceDictionaryByTags(
+ @ApiParam(required = true) @PathParam("tags") String tags) throws BluePrintException;
+
+ /**
+ * This is a searchResourceDictionaryByNames rest service
+ *
+ * @param names
+ * @return List<ResourceDictionary>
+ * @throws BluePrintException
+ */
+ @POST
+ @Path("/dictionarybynames")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to get ResourceDictionary Type by names",
+ response = ResourceDictionary.class, responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ List<ResourceDictionary> searchResourceDictionaryByNames(@ApiParam(required = true) List<String> names)
+ throws BluePrintException;
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestImpl.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestImpl.java
new file mode 100644
index 00000000..e3448424
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestImpl.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.rs;
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.service.ResourceDictionaryService;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * {@inheritDoc}
+ */
+@Service
+public class ResourceDictionaryRestImpl implements ResourceDictionaryRest {
+
+
+ private ResourceDictionaryService resourceDictionaryService;
+
+ /**
+ * This is a DataDictionaryRestImpl, used to save and get the Resource Mapping stored in database
+ *
+ * @param dataDictionaryService Data Dictionary Service
+ */
+ public ResourceDictionaryRestImpl(ResourceDictionaryService dataDictionaryService) {
+ this.resourceDictionaryService = dataDictionaryService;
+ }
+
+ @Override
+ public ResourceDictionary saveResourceDictionary(ResourceDictionary dataDictionary)
+ throws BluePrintException {
+ try {
+ return resourceDictionaryService.saveResourceDictionary(dataDictionary);
+ } catch (Exception e) {
+ throw new BluePrintException(4100, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public void deleteResourceDictionaryByName(String name) throws BluePrintException {
+ try {
+ resourceDictionaryService.deleteResourceDictionary(name);
+ } catch (Exception e) {
+ throw new BluePrintException(4400, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public ResourceDictionary getResourceDictionaryByName(String resourcePath) throws BluePrintException {
+ try {
+ return resourceDictionaryService.getResourceDictionaryByName(resourcePath);
+ } catch (Exception e) {
+ throw new BluePrintException(4001, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public List<ResourceDictionary> searchResourceDictionaryByNames(List<String> names)
+ throws BluePrintException {
+ try {
+ return resourceDictionaryService.searchResourceDictionaryByNames(names);
+ } catch (Exception e) {
+ throw new BluePrintException(4002, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public List<ResourceDictionary> searchResourceDictionaryByTags(String tags) throws BluePrintException {
+ try {
+ return resourceDictionaryService.searchResourceDictionaryByTags(tags);
+ } catch (Exception e) {
+ throw new BluePrintException(4003, e.getMessage(), e);
+ }
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java
new file mode 100644
index 00000000..fcb8f311
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.rs;
+
+import io.swagger.annotations.*;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
+import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import java.util.List;
+
+
+/**
+ * ServiceTemplateRest.java Purpose: ServiceTemplateRest interface
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+
+@Api
+@Path("/service")
+@Produces({MediaType.APPLICATION_JSON})
+public interface ServiceTemplateRest {
+
+ /**
+ * This is a enrichServiceTemplate rest service
+ *
+ * @param serviceTemplate
+ * @return ServiceTemplate
+ * @throws BluePrintException
+ */
+ @POST
+ @Path("/servicetemplate/enrich")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to enrich service template", response = ServiceTemplate.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ ServiceTemplate enrichServiceTemplate(@ApiParam(required = true) ServiceTemplate serviceTemplate)
+ throws BluePrintException;
+
+ /**
+ * This is a validateServiceTemplate rest service
+ *
+ * @param serviceTemplate
+ * @return ServiceTemplate
+ * @throws BluePrintException
+ */
+ @POST
+ @Path("/servicetemplate/validate")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to validate service template", response = ServiceTemplate.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ ServiceTemplate validateServiceTemplate(@ApiParam(required = true) ServiceTemplate serviceTemplate)
+ throws BluePrintException;
+
+ /**
+ * This is a generateResourceAssignments rest service
+ *
+ * @param templateContent
+ * @return List<ResourceAssignment>
+ * @throws BluePrintException
+ */
+ @POST
+ @Path("/resourceassignment/generate")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to auto map for the Resource Mapping",
+ response = ResourceAssignment.class, responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ List<ResourceAssignment> generateResourceAssignments(
+ @ApiParam(required = true) ConfigModelContent templateContent) throws BluePrintException;
+
+ /**
+ * This is a autoMap rest service
+ *
+ * @param resourceAssignments
+ * @return AutoMapResponse
+ * @throws BluePrintException
+ */
+ @POST
+ @Path("/resourceassignment/automap")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to auto map for the Resource assignments",
+ response = AutoMapResponse.class)
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ AutoMapResponse autoMap(@ApiParam(required = true) List<ResourceAssignment> resourceAssignments)
+ throws BluePrintException;
+
+ /**
+ * This is a validateResourceAssignments rest service
+ *
+ * @param resourceAssignments
+ * @return List<ResourceAssignment>
+ * @throws BluePrintException
+ */
+ @POST
+ @Path("/resourceassignment/validate")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Provides Rest service to validate Resource assignments", response = ResourceAssignment.class,
+ responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ List<ResourceAssignment> validateResourceAssignments(
+ @ApiParam(required = true) List<ResourceAssignment> resourceAssignments) throws BluePrintException;
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestImpl.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestImpl.java
new file mode 100644
index 00000000..6c49d5c6
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestImpl.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.rs;
+
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
+import org.onap.ccsdk.apps.controllerblueprints.service.ServiceTemplateService;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
+import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * {@inheritDoc}
+ */
+@Service
+public class ServiceTemplateRestImpl implements ServiceTemplateRest {
+
+ private ServiceTemplateService serviceTemplateService;
+
+ /**
+ * This is a ServiceTemplateRestImpl constructor
+ *
+ * @param serviceTemplateService Service Template Service
+ */
+ public ServiceTemplateRestImpl(ServiceTemplateService serviceTemplateService) {
+ this.serviceTemplateService = serviceTemplateService;
+ }
+
+ @Override
+ public ServiceTemplate enrichServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {
+ try {
+ return serviceTemplateService.enrichServiceTemplate(serviceTemplate);
+ } catch (Exception e) {
+ throw new BluePrintException(3500, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public ServiceTemplate validateServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {
+ try {
+ return serviceTemplateService.validateServiceTemplate(serviceTemplate);
+ } catch (Exception e) {
+ throw new BluePrintException(3501, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public AutoMapResponse autoMap(List<ResourceAssignment> resourceAssignments) throws BluePrintException {
+ try {
+ return serviceTemplateService.autoMap(resourceAssignments);
+ } catch (Exception e) {
+ throw new BluePrintException(3502, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public List<ResourceAssignment> validateResourceAssignments(List<ResourceAssignment> resourceAssignments)
+ throws BluePrintException {
+ try {
+ return serviceTemplateService.validateResourceAssignments(resourceAssignments);
+ } catch (Exception e) {
+ throw new BluePrintException(3503, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public List<ResourceAssignment> generateResourceAssignments(ConfigModelContent templateContent)
+ throws BluePrintException {
+ try {
+ return serviceTemplateService.generateResourceAssignments(templateContent);
+ } catch (Exception e) {
+ throw new BluePrintException(3504, e.getMessage(), e);
+ }
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java
new file mode 100644
index 00000000..e31b04d1
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.utils;
+
+import com.google.common.base.Preconditions;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.filefilter.DirectoryFileFilter;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ToscaMetaData;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class ConfigModelUtils {
+
+ private ConfigModelUtils(){
+
+ }
+ private static Logger log = LoggerFactory.getLogger(ConfigModelUtils.class);
+
+ public static ConfigModel getConfigModel(String blueprintPath) throws Exception {
+ Preconditions.checkArgument(StringUtils.isNotBlank(blueprintPath), "Blueprint Path is missing");
+ ToscaMetaData toscaMetaData = BluePrintMetadataUtils.toscaMetaData(blueprintPath);
+
+ Preconditions.checkNotNull(toscaMetaData, "failed to get Blueprint Metadata information");
+ Preconditions.checkArgument(StringUtils.isNotBlank(toscaMetaData.getEntityDefinitions()), "failed to get Blueprint Definition file");
+ Preconditions.checkArgument(StringUtils.isNotBlank(toscaMetaData.getCreatedBy()), "failed to get Blueprint created by");
+ Preconditions.checkArgument(StringUtils.isNotBlank(toscaMetaData.getToscaMetaFileVersion()), "failed to get Blueprint package version");
+
+ String bluePrintName = FilenameUtils.getBaseName(toscaMetaData.getEntityDefinitions());
+ Preconditions.checkArgument(StringUtils.isNotBlank(bluePrintName), "failed to get Blueprint Definition Name");
+
+ // TODO - Update Rest of the Model
+ ConfigModel configModel = new ConfigModel();
+ configModel.setUpdatedBy(toscaMetaData.getCreatedBy());
+ configModel.setArtifactName(bluePrintName);
+ configModel.setArtifactVersion(toscaMetaData.getToscaMetaFileVersion());
+ configModel.setTags(toscaMetaData.getTemplateTags());
+ configModel.setArtifactType("SDNC_MODEL");
+
+ String blueprintContent =
+ getPathContent(blueprintPath + "/" + toscaMetaData.getEntityDefinitions());
+
+ Preconditions.checkArgument(StringUtils.isNotBlank(blueprintPath), "failed to get Blueprint content");
+
+ List<ConfigModelContent> configModelContents = new ArrayList<>();
+ ConfigModelContent stConfigModelContent = new ConfigModelContent();
+ stConfigModelContent.setName(configModel.getArtifactName());
+ stConfigModelContent.setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON);
+ stConfigModelContent.setContent(blueprintContent);
+ configModelContents.add(stConfigModelContent);
+
+ String velocityDir = blueprintPath + "/Templates";
+ List<File> velocityTemplateFiles = getFileOfExtension(velocityDir, new String[]{"vtl"});
+
+ if (CollectionUtils.isNotEmpty(velocityTemplateFiles)) {
+ for (File velocityTemplateFile : velocityTemplateFiles) {
+ if (velocityTemplateFile != null) {
+ String contentName = velocityTemplateFile.getName().replace(".vtl", "");
+ ConfigModelContent velocityConfigModelContent = new ConfigModelContent();
+ String velocityConfigContent = getPathContent(velocityTemplateFile);
+ velocityConfigModelContent.setName(contentName);
+ velocityConfigModelContent
+ .setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TEMPLATE);
+ velocityConfigModelContent.setContent(velocityConfigContent);
+ configModelContents.add(velocityConfigModelContent);
+ log.info("Loaded blueprint template successfully: {}", velocityTemplateFile.getName());
+ }
+ }
+ }
+ configModel.setConfigModelContents(configModelContents);
+
+ return configModel;
+
+ }
+
+ public static String getPathContent(String path) throws IOException {
+ Preconditions.checkArgument(StringUtils.isNotBlank(path), "Path is missing");
+ return FileUtils.readFileToString(new File(path), Charset.defaultCharset());
+ }
+
+ public static String getPathContent(File file) throws IOException {
+ Preconditions.checkNotNull(file, "File is missing");
+ return FileUtils.readFileToString(file, Charset.defaultCharset());
+ }
+
+ public static List<File> getFileOfExtension(String basePath, String[] extensions) {
+ Preconditions.checkArgument(StringUtils.isNotBlank(basePath), "Path is missing");
+ Preconditions.checkNotNull(extensions, "Extensions is missing");
+ return (List<File>) FileUtils.listFiles(new File(basePath), extensions, true);
+ }
+
+ public static List<String> getBlueprintNames(String pathName) {
+ File blueprintDir = new File(pathName);
+ Preconditions.checkNotNull(blueprintDir, "failed to find the blueprint pathName file");
+ return Arrays.asList(blueprintDir.list(DirectoryFileFilter.INSTANCE));
+ }
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java
new file mode 100644
index 00000000..85f256ea
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java
@@ -0,0 +1,200 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.validator;
+
+import org.apache.commons.lang3.StringUtils;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.CapabilityDefinition;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * ModelTypeValidation.java Purpose: Provide Validation Service for Model Type ModelTypeValidation
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+
+public class ModelTypeValidator {
+
+ private ModelTypeValidator() {
+
+ }
+
+ private static List<String> getValidModelDefinitionType() {
+ List<String> validTypes = new ArrayList<>();
+ validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
+ validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE);
+ validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE);
+ validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE);
+ validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE);
+ return validTypes;
+ }
+
+ @Deprecated
+ private static List<String> getValidModelDerivedFrom(String definitionType) {
+ List<String> validTypes = new ArrayList<>();
+ if (StringUtils.isNotBlank(definitionType)) {
+ if (BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE.equalsIgnoreCase(definitionType)) {
+ validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_DG);
+ validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_COMPONENT);
+ validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_VNF);
+ validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_ARTIFACT);
+ } else if (BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE.equalsIgnoreCase(definitionType)) {
+ validTypes.add(ConfigModelConstant.MODEL_TYPE_CAPABILITY_NETCONF);
+ validTypes.add(ConfigModelConstant.MODEL_TYPE_CAPABILITY_SSH);
+ validTypes.add(ConfigModelConstant.MODEL_TYPE_CAPABILITY_SFTP);
+ validTypes.add(ConfigModelConstant.MODEL_TYPE_CAPABILITY_CHEF);
+ validTypes.add(ConfigModelConstant.MODEL_TYPE_CAPABILITY_ANSIBLEF);
+ } else if (BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE.equalsIgnoreCase(definitionType)) {
+ validTypes.add(BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON);
+ validTypes.add(BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_HOSTED_ON);
+ validTypes.add(BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO);
+ validTypes.add(BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ATTACH_TO);
+ validTypes.add(BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROUTES_TO);
+ }
+
+ }
+ return validTypes;
+ }
+
+ /**
+ * This is a validateNodeType
+ *
+ * @param definitionType
+ * @param derivedFrom
+ * @return boolean
+ * @throws BluePrintException
+ */
+ public static boolean validateNodeType(String definitionType, String derivedFrom) throws BluePrintException {
+ boolean valid = true;
+ if (!BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE.equalsIgnoreCase(definitionType)
+ && !BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE.equalsIgnoreCase(definitionType)) {
+ List<String> validTypes = getValidModelDerivedFrom(definitionType);
+ if (!validTypes.contains(derivedFrom)) {
+ throw new BluePrintException(
+ "Not Valid Model Type (" + derivedFrom + "), It sould be " + validTypes);
+ }
+ }
+ return valid;
+ }
+
+ /**
+ * This is a validateModelTypeDefinition
+ *
+ * @param definitionType
+ * @param definitionContent
+ * @return boolean
+ * @throws BluePrintException
+ */
+ public static boolean validateModelTypeDefinition(String definitionType, String definitionContent)
+ throws BluePrintException {
+ boolean valid = true;
+ if (StringUtils.isNotBlank(definitionContent)) {
+ if (BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE.equalsIgnoreCase(definitionType)) {
+ DataType dataType = JacksonUtils.readValue(definitionContent, DataType.class);
+ if (dataType == null) {
+ throw new BluePrintException(
+ "Model type definition is not DataType valid content " + definitionContent);
+ }
+ } else if (BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE.equalsIgnoreCase(definitionType)) {
+ NodeType nodeType = JacksonUtils.readValue(definitionContent, NodeType.class);
+ if (nodeType == null) {
+ throw new BluePrintException(
+ "Model type definition is not NodeType valid content " + definitionContent);
+ }
+ } else if (BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE.equalsIgnoreCase(definitionType)) {
+ ArtifactType artifactType = JacksonUtils.readValue(definitionContent, ArtifactType.class);
+ if (artifactType == null) {
+ throw new BluePrintException(
+ "Model type definition is not ArtifactType valid content " + definitionContent);
+ }
+ }else if (BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE.equalsIgnoreCase(definitionType)) {
+ CapabilityDefinition capabilityDefinition =
+ JacksonUtils.readValue(definitionContent, CapabilityDefinition.class);
+ if (capabilityDefinition == null) {
+ throw new BluePrintException(
+ "Model type definition is not CapabilityDefinition valid content " + definitionContent);
+ }
+ }
+
+ }
+ return valid;
+ }
+
+ /**
+ * This is a validateModelType method
+ *
+ * @param modelType
+ * @return boolean
+ */
+ public static boolean validateModelType(ModelType modelType) throws BluePrintException {
+ if (modelType != null) {
+
+ if (StringUtils.isBlank(modelType.getModelName())) {
+ throw new BluePrintException("Model Name Information is missing.");
+ }
+
+ if (StringUtils.isBlank(modelType.getDefinitionType())) {
+ throw new BluePrintException("Model Root Type Information is missing.");
+ }
+ if (StringUtils.isBlank(modelType.getDerivedFrom())) {
+ throw new BluePrintException("Model Type Information is missing.");
+ }
+
+ if (StringUtils.isBlank(modelType.getDefinition())) {
+ throw new BluePrintException("Model Definition Information is missing.");
+ }
+ if (StringUtils.isBlank(modelType.getDescription())) {
+ throw new BluePrintException("Model Description Information is missing.");
+ }
+
+ if (StringUtils.isBlank(modelType.getVersion())) {
+ throw new BluePrintException("Model Version Information is missing.");
+ }
+
+ if (StringUtils.isBlank(modelType.getUpdatedBy())) {
+ throw new BluePrintException("Model Updated By Information is missing.");
+ }
+
+ List<String> validRootTypes = getValidModelDefinitionType();
+ if (!validRootTypes.contains(modelType.getDefinitionType())) {
+ throw new BluePrintException("Not Valid Model Root Type(" + modelType.getDefinitionType()
+ + "), It sould be " + validRootTypes);
+ }
+
+ validateModelTypeDefinition(modelType.getDefinitionType(), modelType.getDefinition());
+
+ validateNodeType(modelType.getDefinitionType(), modelType.getDerivedFrom());
+
+ } else {
+ throw new BluePrintException("Model Type Information is missing.");
+ }
+
+ return true;
+
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ResourceDictionaryValidator.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ResourceDictionaryValidator.java
new file mode 100644
index 00000000..eb2448e7
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ResourceDictionaryValidator.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.validator;
+
+import com.google.common.base.Preconditions;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DictionaryDefinition;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
+
+/**
+ * ResourceDictionaryValidator.java Purpose: Provide Validation Service for Model Type Resource
+ * Dictionary Validator
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+public class ResourceDictionaryValidator {
+
+ private ResourceDictionaryValidator() {}
+
+ /**
+ * This is a validateResourceDictionaryDefinition
+ *
+ * @param definitionContent
+ * @return boolean
+ * @throws BluePrintException
+ */
+ public static boolean validateResourceDictionaryDefinition(String definitionContent)
+ throws BluePrintException {
+ boolean valid = true;
+ if (StringUtils.isNotBlank(definitionContent)) {
+ DictionaryDefinition dictionaryDefinition =
+ JacksonUtils.readValue(definitionContent, DictionaryDefinition.class);
+ if (dictionaryDefinition == null) {
+ throw new BluePrintException(
+ "Resource dictionary definition is not valid content " + definitionContent);
+ }
+
+ }
+ return valid;
+ }
+
+ /**
+ * This is a validateResourceDictionary method
+ *
+ * @param resourceDictionary
+ * @return boolean
+ *
+ */
+ public static boolean validateResourceDictionary(ResourceDictionary resourceDictionary) {
+
+ Preconditions.checkNotNull(resourceDictionary,"ResourceDictionary Information is missing." );
+
+ Preconditions.checkArgument( StringUtils.isNotBlank(resourceDictionary.getName()),
+ "DataDictionary Alias Name Information is missing.");
+ Preconditions.checkArgument( StringUtils.isNotBlank(resourceDictionary.getResourcePath()),
+ "DataDictionary Resource Name Information is missing.");
+ Preconditions.checkArgument( StringUtils.isNotBlank(resourceDictionary.getResourceType()),
+ "DataDictionary Resource Type Information is missing.");
+ Preconditions.checkArgument( StringUtils.isNotBlank(resourceDictionary.getDefinition()),
+ "DataDictionary Definition Information is missing.");
+ Preconditions.checkArgument( StringUtils.isNotBlank(resourceDictionary.getDescription()),
+ "DataDictionary Description Information is missing.");
+ Preconditions.checkArgument( StringUtils.isNotBlank(resourceDictionary.getTags()),
+ "DataDictionary Tags Information is missing.");
+ Preconditions.checkArgument( StringUtils.isNotBlank(resourceDictionary.getUpdatedBy()),
+ "DataDictionary Updated By Information is missing.");
+ return true;
+
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java
new file mode 100644
index 00000000..ea46f3ad
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.validator;
+
+import com.google.common.base.Preconditions;
+import org.apache.commons.lang3.StringUtils;
+import org.jetbrains.annotations.NotNull;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintValidatorDefaultService;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.validator.ResourceAssignmentValidator;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * ServiceTemplateValidator.java Purpose: Provide Configuration Generator ServiceTemplateValidator
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+
+public class ServiceTemplateValidator extends BluePrintValidatorDefaultService {
+
+ StringBuilder message = new StringBuilder();
+ private Map<String, String> metaData = new HashMap();
+
+ /**
+ * This is a validateServiceTemplate
+ *
+ * @param serviceTemplateContent
+ * @return boolean
+ * @throws BluePrintException
+ */
+ public boolean validateServiceTemplate(String serviceTemplateContent) throws BluePrintException {
+ if (StringUtils.isNotBlank(serviceTemplateContent)) {
+ ServiceTemplate serviceTemplate =
+ JacksonUtils.readValue(serviceTemplateContent, ServiceTemplate.class);
+ return validateServiceTemplate(serviceTemplate);
+ } else {
+ throw new BluePrintException(
+ "Service Template Content is (" + serviceTemplateContent + ") not Defined.");
+ }
+ }
+
+ /**
+ * This is a validateServiceTemplate
+ *
+ * @param serviceTemplate
+ * @return boolean
+ * @throws BluePrintException
+ */
+ @SuppressWarnings("squid:S00112")
+ public boolean validateServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {
+ Map<String, Object> properties = new HashMap<>();
+ super.validateBlueprint(serviceTemplate, properties);
+ return true;
+ }
+
+ /**
+ * This is a getMetaData to get the key information during the
+ *
+ * @return Map<String ,
+ * String>
+ */
+ public Map<String, String> getMetaData() {
+ return metaData;
+ }
+
+ @Override
+ public void validateMetadata(@NotNull Map<String, String> metaDataMap) throws BluePrintException {
+
+ Preconditions.checkNotNull(serviceTemplate.getMetadata(), "Service Template Metadata Information is missing.");
+
+ this.metaData.putAll(serviceTemplate.getMetadata());
+
+ String author = serviceTemplate.getMetadata().get(BluePrintConstants.METADATA_TEMPLATE_AUTHOR);
+ String serviceTemplateName =
+ serviceTemplate.getMetadata().get(BluePrintConstants.METADATA_TEMPLATE_NAME);
+ String serviceTemplateVersion =
+ serviceTemplate.getMetadata().get(BluePrintConstants.METADATA_TEMPLATE_VERSION);
+
+ Preconditions.checkArgument(StringUtils.isNotBlank(author), "Template Metadata (author) Information is missing.");
+ Preconditions.checkArgument(StringUtils.isNotBlank(serviceTemplateName), "Template Metadata (service-template-name) Information is missing.");
+ Preconditions.checkArgument(StringUtils.isNotBlank(serviceTemplateVersion), "Template Metadata (service-template-version) Information is missing.");
+ }
+
+
+ @Override
+ public void validateNodeTemplate(@NotNull String nodeTemplateName, @NotNull NodeTemplate nodeTemplate)
+ throws BluePrintException {
+ super.validateNodeTemplate(nodeTemplateName, nodeTemplate);
+ validateNodeTemplateCustom(nodeTemplateName, nodeTemplate);
+
+ }
+
+ @Deprecated()
+ private void validateNodeTemplateCustom(@NotNull String nodeTemplateName, @NotNull NodeTemplate nodeTemplate)
+ throws BluePrintException {
+ String derivedFrom = getBluePrintContext().nodeTemplateNodeType(nodeTemplateName).getDerivedFrom();
+ if ("tosca.nodes.Artifact".equals(derivedFrom)) {
+ ResourceAssignmentValidator resourceAssignmentValidator = new ResourceAssignmentValidator(nodeTemplate);
+ resourceAssignmentValidator.validateResourceAssignment();
+ }
+ }
+}