diff options
author | Brinda Santh <brindasanth@in.ibm.com> | 2018-08-26 22:10:50 -0400 |
---|---|---|
committer | Brinda Santh <brindasanth@in.ibm.com> | 2018-08-26 22:10:50 -0400 |
commit | 380790370ba573e0b0e0829b4fa1b38a79581a0e (patch) | |
tree | 451873185f9d51b8770342d5c55a120235787d51 /ms/controllerblueprints/modules/service/src | |
parent | ca395c635569bc70c16397a25dc46d7a9f0629a4 (diff) |
Controller Blueprints Microservice
Add resource dictionary validation implementation services, validation repository services and Junit Test cases.
Change-Id: Ia746b86b7d9098eabe5e643dcba558ef9aa7160f
Issue-ID: CCSDK-487
Signed-off-by: Brinda Santh <brindasanth@in.ibm.com>
Diffstat (limited to 'ms/controllerblueprints/modules/service/src')
-rw-r--r-- | ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java | 5 | ||||
-rw-r--r-- | ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java (renamed from ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerRepoDBService.java) | 9 | ||||
-rw-r--r-- | ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java | 26 | ||||
-rw-r--r-- | ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryValidationService.java | 31 | ||||
-rw-r--r-- | ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java | 52 |
5 files changed, 56 insertions, 67 deletions
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 afd12f21..0cf846c7 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 @@ -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.
@@ -24,7 +25,7 @@ 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.service.BluePrintRepoService;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
import org.slf4j.Logger;
@@ -48,7 +49,7 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService { private HashMap<String, DataType> recipeDataTypes = new HashMap<>();
- public BluePrintEnhancerService(BluePrintEnhancerRepoService bluePrintEnhancerRepoDBService) {
+ public BluePrintEnhancerService(BluePrintRepoService bluePrintEnhancerRepoDBService) {
super(bluePrintEnhancerRepoDBService);
}
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/BluePrintRepoDBService.java index a2e5b104..4a26119c 100644 --- 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/BluePrintRepoDBService.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.
@@ -20,7 +21,7 @@ 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.service.BluePrintRepoService;
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;
@@ -29,16 +30,16 @@ import org.springframework.stereotype.Service; import java.util.Optional;
/**
- * BluePrintEnhancerRepoDBService
+ * BluePrintRepoDBService
*
* @author Brinda Santh
*/
@Service
-public class BluePrintEnhancerRepoDBService implements BluePrintEnhancerRepoService {
+public class BluePrintRepoDBService implements BluePrintRepoService {
private ModelTypeRepository modelTypeRepository;
- public BluePrintEnhancerRepoDBService(ModelTypeRepository modelTypeRepository) {
+ public BluePrintRepoDBService(ModelTypeRepository modelTypeRepository) {
this.modelTypeRepository = modelTypeRepository;
}
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 4bb87d7f..5420dd39 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 @@ -43,19 +43,23 @@ public class ResourceDictionaryService { private ResourceDictionaryRepository resourceDictionaryRepository;
+ private ResourceDictionaryValidationService resourceDictionaryValidationService;
+
/**
* This is a DataDictionaryService, used to save and get the Resource Mapping stored in database
- *
+ *
* @param dataDictionaryRepository
- *
+ * @param resourceDictionaryValidationService
*/
- public ResourceDictionaryService(ResourceDictionaryRepository dataDictionaryRepository) {
+ public ResourceDictionaryService(ResourceDictionaryRepository dataDictionaryRepository,
+ ResourceDictionaryValidationService resourceDictionaryValidationService) {
this.resourceDictionaryRepository = dataDictionaryRepository;
+ this.resourceDictionaryValidationService = resourceDictionaryValidationService;
}
/**
* This is a getDataDictionaryByName service
- *
+ *
* @param name
* @return DataDictionary
* @throws BluePrintException
@@ -70,7 +74,7 @@ public class ResourceDictionaryService { /**
* This is a searchResourceDictionaryByNames service
- *
+ *
* @param names
* @return List<ResourceDictionary>
* @throws BluePrintException
@@ -86,7 +90,7 @@ public class ResourceDictionaryService { /**
* This is a searchResourceDictionaryByTags service
- *
+ *
* @param tags
* @return List<ResourceDictionary>
* @throws BluePrintException
@@ -101,7 +105,7 @@ public class ResourceDictionaryService { /**
* This is a saveDataDictionary service
- *
+ *
* @param resourceDictionary
* @return DataDictionary
* @throws BluePrintException
@@ -113,6 +117,8 @@ public class ResourceDictionaryService { ResourceDefinition resourceDefinition =
JacksonUtils.readValue(resourceDictionary.getDefinition(), ResourceDefinition.class);
+ // Check the Source already Present
+ resourceDictionaryValidationService.validate(resourceDefinition);
if (resourceDefinition == null) {
throw new BluePrintException(
@@ -126,11 +132,11 @@ public class ResourceDictionaryService { PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType(resourceDictionary.getDataType());
propertyDefinition.setDescription(resourceDictionary.getDescription());
- if(StringUtils.isNotBlank(resourceDictionary.getEntrySchema())){
+ if (StringUtils.isNotBlank(resourceDictionary.getEntrySchema())) {
EntrySchema entrySchema = new EntrySchema();
entrySchema.setType(resourceDictionary.getEntrySchema());
propertyDefinition.setEntrySchema(entrySchema);
- }else{
+ } else {
propertyDefinition.setEntrySchema(null);
}
resourceDefinition.setTags(resourceDictionary.getTags());
@@ -165,7 +171,7 @@ public class ResourceDictionaryService { /**
* This is a deleteResourceDictionary service
- *
+ *
* @param name
* @throws BluePrintException
*/
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryValidationService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryValidationService.java new file mode 100644 index 00000000..7de7fc4c --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryValidationService.java @@ -0,0 +1,31 @@ +/* + * Copyright © 2018 IBM. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.service; + +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDictionaryDefaultValidationService; +import org.springframework.stereotype.Service; + +@Service +public class ResourceDictionaryValidationService extends ResourceDictionaryDefaultValidationService { + + private BluePrintRepoService bluePrintRepoService; + + public ResourceDictionaryValidationService(BluePrintRepoService bluePrintRepoService) { + super(bluePrintRepoService); + } +} 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 index 85f256ea..1201f6b4 100644 --- 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 @@ -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.
@@ -19,7 +20,6 @@ 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;
@@ -53,54 +53,6 @@ public class ModelTypeValidator { 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
*
@@ -187,8 +139,6 @@ public class ModelTypeValidator { validateModelTypeDefinition(modelType.getDefinitionType(), modelType.getDefinition());
- validateNodeType(modelType.getDefinitionType(), modelType.getDerivedFrom());
-
} else {
throw new BluePrintException("Model Type Information is missing.");
}
|