From 5dbc79162b53a0e97be4561719ae0e181944d2c8 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Fri, 31 Aug 2018 19:52:48 +0000 Subject: Controller Blueprints Microservice Add resource assignment enhancer, resource definition repo functions and code improvements. Change-Id: I751bf8149a36f80c20d48b86344cd6bd3054ed21 Issue-ID: CCSDK-431 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../service/AutoResourceMappingService.java | 6 +-- .../service/BluePrintEnhancerService.java | 10 ++-- .../service/ConfigModelCreateService.java | 6 +-- .../service/ConfigModelService.java | 60 +++++++++++----------- .../service/DataBaseInitService.java | 10 ++-- .../service/SchemaGeneratorService.java | 6 +-- .../service/ServiceTemplateService.java | 2 +- .../service/domain/ConfigModelContent.java | 11 ++-- .../service/domain/ModelType.java | 21 ++++---- .../service/domain/ResourceDictionary.java | 27 +++++----- .../service/utils/ConfigModelUtils.java | 6 +-- 11 files changed, 82 insertions(+), 83 deletions(-) (limited to 'ms/controllerblueprints/modules/service/src/main') 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 index 5eba4fc7f..428c52451 100644 --- 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 @@ -29,8 +29,8 @@ import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDict 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 com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import org.springframework.stereotype.Service; import java.util.ArrayList; @@ -49,7 +49,7 @@ import java.util.Map; @SuppressWarnings("unused") public class AutoResourceMappingService { - private static Logger log = LoggerFactory.getLogger(AutoResourceMappingService.class); + private static EELFLogger log = EELFManager.getInstance().getLogger(AutoResourceMappingService.class); private ResourceDictionaryRepository dataDictionaryRepository; 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 index 28be75e66..8e98f9477 100644 --- 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 @@ -29,8 +29,8 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerDe import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService; 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 com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import org.springframework.stereotype.Service; import java.util.HashMap; @@ -46,7 +46,7 @@ import java.util.Map; @Service public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService { - private static Logger log = LoggerFactory.getLogger(BluePrintEnhancerService.class); + private static EELFLogger log = EELFManager.getInstance().getLogger(BluePrintEnhancerService.class); private Map recipeDataTypes = new HashMap<>(); @@ -55,7 +55,7 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService { } @Override - public void enrichTopologyTemplate(@NotNull ServiceTemplate serviceTemplate) { + public void enrichTopologyTemplate(@NotNull ServiceTemplate serviceTemplate) throws BluePrintException{ super.enrichTopologyTemplate(serviceTemplate); // Update the Recipe Inputs and DataTypes @@ -143,7 +143,7 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService { } private Map getCapabilityMappingProperties(String nodeTemplateName, - NodeTemplate nodeTemplate) { + NodeTemplate nodeTemplate) throws BluePrintException { Map dataTypeProperties = null; if (nodeTemplate != null && MapUtils.isNotEmpty(nodeTemplate.getCapabilities())) { 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 index 9c1a045cd..3c92f7e94 100644 --- 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 @@ -31,8 +31,8 @@ import org.onap.ccsdk.apps.controllerblueprints.service.common.ApplicationConsta 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 com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import org.springframework.stereotype.Service; import java.io.IOException; @@ -52,7 +52,7 @@ import java.util.Optional; @Service public class ConfigModelCreateService { - private static Logger log = LoggerFactory.getLogger(ConfigModelCreateService.class); + private static EELFLogger log = EELFManager.getInstance().getLogger(ConfigModelCreateService.class); private ConfigModelRepository configModelRepository; private ConfigModelValidatorService configModelValidatorService; 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 index b729e3e6d..534394a3e 100644 --- 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 @@ -29,8 +29,8 @@ 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 com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -49,7 +49,7 @@ import java.util.Optional; @Service public class ConfigModelService { - private static Logger log = LoggerFactory.getLogger(ConfigModelService.class); + private static EELFLogger log = EELFManager.getInstance().getLogger(ConfigModelService.class); private ConfigModelRepository configModelRepository; private ConfigModelContentRepository configModelContentRepository; @@ -57,14 +57,14 @@ public class ConfigModelService { /** * This is a ConfigModelService constructor. - * - * @param configModelRepository - * @param configModelContentRepository - * @param configModelCreateService + * + * @param configModelRepository configModelRepository + * @param configModelContentRepository configModelContentRepository + * @param configModelCreateService configModelCreateService */ public ConfigModelService(ConfigModelRepository configModelRepository, - ConfigModelContentRepository configModelContentRepository, - ConfigModelCreateService configModelCreateService) { + ConfigModelContentRepository configModelContentRepository, + ConfigModelCreateService configModelCreateService) { this.configModelRepository = configModelRepository; this.configModelContentRepository = configModelContentRepository; this.configModelCreateService = configModelCreateService; @@ -72,10 +72,10 @@ public class ConfigModelService { /** * This is a getInitialConfigModel method - * - * @param templateName + * + * @param templateName templateName * @return ConfigModel - * @throws BluePrintException + * @throws BluePrintException BluePrintException */ public ConfigModel getInitialConfigModel(String templateName) throws BluePrintException { ConfigModel configModel = null; @@ -100,10 +100,10 @@ public class ConfigModelService { /** * This is a saveConfigModel method - * - * @param configModel + * + * @param configModel configModel * @return ConfigModel - * @throws BluePrintException + * @throws BluePrintException BluePrintException */ public ConfigModel saveConfigModel(ConfigModel configModel) throws BluePrintException { return this.configModelCreateService.saveConfigModel(configModel); @@ -111,10 +111,10 @@ public class ConfigModelService { /** * This is a publishConfigModel method - * - * @param id + * + * @param id id * @return ConfigModel - * @throws BluePrintException + * @throws BluePrintException BluePrintException */ public ConfigModel publishConfigModel(Long id) throws BluePrintException { return this.configModelCreateService.publishConfigModel(id); @@ -122,8 +122,8 @@ public class ConfigModelService { /** * This is a searchConfigModels method - * - * @param tags + * + * @param tags tags * @return ConfigModel */ public List searchConfigModels(String tags) { @@ -138,9 +138,9 @@ public class ConfigModelService { /** * This is a getConfigModelByNameAndVersion method - * - * @param name - * @param version + * + * @param name name + * @param version version * @return ConfigModel */ public ConfigModel getConfigModelByNameAndVersion(String name, String version) { @@ -159,8 +159,8 @@ public class ConfigModelService { /** * This is a getConfigModel method - * - * @param id + * + * @param id id * @return ConfigModel */ public ConfigModel getConfigModel(Long id) { @@ -176,9 +176,9 @@ public class ConfigModelService { /** * This method returns clone of the given model id, by masking the other unrelated fields - * - * @param id - * @return + * + * @param id id + * @return ConfigModel */ public ConfigModel getCloneConfigModel(Long id) { @@ -232,8 +232,8 @@ public class ConfigModelService { /** * This is a deleteConfigModel method - * - * @param id + * + * @param id id */ @Transactional 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 index 89d482962..4e7c3911c 100644 --- 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 @@ -22,6 +22,7 @@ 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.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.ArtifactType; @@ -33,8 +34,8 @@ 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 com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -58,7 +59,7 @@ import java.util.List; @ConditionalOnProperty(name = "blueprints.load.initial-data", havingValue = "true") public class DataBaseInitService { - private static Logger log = LoggerFactory.getLogger(DataBaseInitService.class); + private static EELFLogger log = EELFManager.getInstance().getLogger(DataBaseInitService.class); @Value("${blueprints.load.path}") private String modelLoadPath; private ModelTypeService modelTypeService; @@ -91,6 +92,7 @@ public class DataBaseInitService { } @PostConstruct + @SuppressWarnings("unused") private void initDatabase() { log.info("loading Blueprints from DIR : {}", modelLoadPath); dataTypePath = modelLoadPath + "/model_type/data_type"; @@ -263,7 +265,7 @@ public class DataBaseInitService { } } - private void loadDataType(Resource file, StrBuilder errorBuilder) { + private void loadDataType(@NotNull Resource file, StrBuilder errorBuilder) { try { log.trace("Loading Data Type: {}", file.getFilename()); String dataKey = file.getFilename().replace(".json", ""); 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 index a75651f19..04a95fd12 100644 --- 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 @@ -24,8 +24,8 @@ 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 com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import java.util.HashMap; import java.util.Map; @@ -39,7 +39,7 @@ import java.util.Map; */ public class SchemaGeneratorService { - private static Logger log = LoggerFactory.getLogger(SchemaGeneratorService.class); + private static EELFLogger log = EELFManager.getInstance().getLogger(SchemaGeneratorService.class); private Map dataTypes; 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 index 3e3c8e286..898647eaa 100644 --- 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 @@ -81,7 +81,7 @@ public class ServiceTemplateService { * @param serviceTemplate serviceTemplate * @return ServiceTemplate */ - public ServiceTemplate enrichServiceTemplate(ServiceTemplate serviceTemplate) { + public ServiceTemplate enrichServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException { this.bluePrintEnhancerService.enhance(serviceTemplate); return serviceTemplate; } 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 index 60b3ed6b0..ae374a786 100644 --- 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 @@ -76,12 +76,11 @@ public class ConfigModelContent { @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(); + String builder = "[" + "id = " + id + + ", name = " + name + + ", contentType = " + contentType + + "]"; + return builder; } @Override 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 index eaa335b3e..cb8d229f3 100644 --- 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 @@ -82,17 +82,16 @@ public class ModelType implements Serializable { @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(); + String buffer = "[" + ", modelName = " + modelName + + ", derivedFrom = " + derivedFrom + + ", definitionType = " + definitionType + + ", description = " + description + + ", creationDate = " + creationDate + + ", version = " + version + + ", updatedBy = " + updatedBy + + ", tags = " + tags + + "]"; + return buffer; } public String getModelName() { 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 index 487586842..c88462202 100644 --- 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 @@ -92,20 +92,19 @@ public class ResourceDictionary implements Serializable { @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(); + String buffer = "[" + ", name = " + name + + ", resourcePath = " + resourcePath + + ", resourceType = " + resourceType + + ", dataType = " + dataType + + ", entrySchema = " + entrySchema + + ", validValues = " + validValues + + ", definition =" + definition + + ", description = " + description + + ", updatedBy = " + updatedBy + + ", tags = " + tags + + ", creationDate = " + creationDate + + "]"; + return buffer; } public String getResourcePath() { 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 index bfc89b4ee..dc24c3bfe 100644 --- 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 @@ -27,8 +27,8 @@ 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 com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import java.io.File; import java.io.IOException; @@ -43,7 +43,7 @@ public class ConfigModelUtils { } - private static Logger log = LoggerFactory.getLogger(ConfigModelUtils.class); + private static EELFLogger log = EELFManager.getInstance().getLogger(ConfigModelUtils.class); public static ConfigModel getConfigModel(String blueprintPath) throws Exception { Preconditions.checkArgument(StringUtils.isNotBlank(blueprintPath), "Blueprint Path is missing"); -- cgit 1.2.3-korg