summaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules/service
diff options
context:
space:
mode:
authorBrinda Santh <brindasanth@in.ibm.com>2018-08-27 23:16:39 -0400
committerBrinda Santh <brindasanth@in.ibm.com>2018-08-27 23:16:39 -0400
commit2ae44709f7e3b04d2150e6c15182fae2a39adc45 (patch)
tree72544c81a4731bd55b8a8dda25ee98d4529fd251 /ms/controllerblueprints/modules/service
parente2f01ca57072a4685c957ce9aec0ab3cf51c7a4e (diff)
Controller Blueprints Microservice
Add resource dictionary node template property assignments validation for primitive and complex types. Change-Id: Ic6f3a521310c8e15ebb5b5b5d6ad3edb0ede9ecb Issue-ID: CCSDK-488 Signed-off-by: Brinda Santh <brindasanth@in.ibm.com>
Diffstat (limited to 'ms/controllerblueprints/modules/service')
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java2
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelCreateService.java3
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelService.java5
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java20
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java2
5 files changed, 17 insertions, 15 deletions
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java
index 4c11d8c6..ae4fed9f 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java
@@ -82,7 +82,7 @@ public class BluePrintRepoDBService implements BluePrintRepoService {
}
private Mono<String> getModelDefinitions(String modelName) throws BluePrintException {
- String modelDefinition = null;
+ String modelDefinition;
Optional<ModelType> modelTypeDb = modelTypeRepository.findByModelName(modelName);
if (modelTypeDb.isPresent()) {
modelDefinition = modelTypeDb.get().getDefinition();
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 7e96f2f8..e40c2cf4 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
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -138,7 +139,7 @@ public class ConfigModelCreateService {
if (StringUtils.isBlank(artifactVersion)) {
throw new BluePrintException("Artifact Version is missing in the Service Template");
}
- ConfigModel updateConfigModel = null;
+ ConfigModel updateConfigModel;
Optional<ConfigModel> dbConfigModelOptional = Optional.empty();
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 feee3a3e..b729e3e6 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
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -144,7 +145,7 @@ public class ConfigModelService {
*/
public ConfigModel getConfigModelByNameAndVersion(String name, String version) {
ConfigModel configModel = null;
- Optional<ConfigModel> dbConfigModel = null;
+ Optional<ConfigModel> dbConfigModel;
if (StringUtils.isNotBlank(version)) {
dbConfigModel = configModelRepository.findByArtifactNameAndArtifactVersion(name, version);
} else {
@@ -182,7 +183,7 @@ public class ConfigModelService {
public ConfigModel getCloneConfigModel(Long id) {
- ConfigModel configModel = null;
+ ConfigModel configModel;
ConfigModel cloneConfigModel = null;
if (id != null) {
Optional<ConfigModel> dbConfigModel = configModelRepository.findById(id);
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 3a5c4fde..4b732cc3 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
@@ -115,31 +115,28 @@ public class DataBaseInitService {
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) {
+ 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());
@@ -154,9 +151,9 @@ public class DataBaseInitService {
" *************************** loadResourceDictionary **********************");
try {
Resource[] dataTypefiles = getPathResources(resourceDictionaryPath, ".json");
- if (dataTypefiles != null) {
+
StrBuilder errorBuilder = new StrBuilder();
- String fileName = null;
+ String fileName;
for (Resource file : dataTypefiles) {
try {
fileName = file.getFilename();
@@ -201,7 +198,7 @@ public class DataBaseInitService {
log.error(errorBuilder.toString());
}
- }
+
} catch (Exception e) {
log.error(
"Failed in Resource dictionary loading", e);
@@ -248,6 +245,7 @@ public class DataBaseInitService {
String nodeKey = file.getFilename().replace(".json", "");
String definitionContent = getResourceContent(file);
NodeType nodeType = JacksonUtils.readValue(definitionContent, NodeType.class);
+ Preconditions.checkNotNull(nodeType, String.format("failed to get node type from file : %s", file.getFilename()));
ModelType modelType = new ModelType();
modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE);
modelType.setDerivedFrom(nodeType.getDerivedFrom());
@@ -271,6 +269,7 @@ public class DataBaseInitService {
String dataKey = file.getFilename().replace(".json", "");
String definitionContent = getResourceContent(file);
DataType dataType = JacksonUtils.readValue(definitionContent, DataType.class);
+ Preconditions.checkNotNull(dataType, String.format("failed to get data type from file : %s", file.getFilename()));
ModelType modelType = new ModelType();
modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
modelType.setDerivedFrom(dataType.getDerivedFrom());
@@ -294,6 +293,7 @@ public class DataBaseInitService {
String dataKey = file.getFilename().replace(".json", "");
String definitionContent = getResourceContent(file);
ArtifactType artifactType = JacksonUtils.readValue(definitionContent, ArtifactType.class);
+ Preconditions.checkNotNull(artifactType, String.format("failed to get artifact type from file : %s", file.getFilename()));
ModelType modelType = new ModelType();
modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE);
modelType.setDerivedFrom(artifactType.getDerivedFrom());
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
index 629b94c0..85e701b4 100644
--- 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
@@ -20,7 +20,6 @@ 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.EntrySchema;
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.ResourceDefinition;
@@ -119,6 +118,7 @@ public class ResourceDictionaryService {
ResourceDefinition resourceDefinition =
JacksonUtils.readValue(resourceDictionary.getDefinition(), ResourceDefinition.class);
+ Preconditions.checkNotNull(resourceDefinition, "failed to get resource definition from content");
// Validate the Resource Definitions
resourceDictionaryValidationService.validate(resourceDefinition);