aboutsummaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules/service
diff options
context:
space:
mode:
authorBrinda Santh <brindasanth@in.ibm.com>2018-08-28 22:46:02 -0400
committerBrinda Santh <brindasanth@in.ibm.com>2018-08-28 22:52:52 -0400
commit382e72538c5df057328b3cf790daaa873849c362 (patch)
tree5564c87b8719f3b9557ac01333d7738929b0b90e /ms/controllerblueprints/modules/service
parentc0e77765214b94cc493b181bcc1d58165ac8b09f (diff)
Controller Blueprints Microservice
Add resource assignment json data to input property convertor utlity and their test cases. Change-Id: Ie4557048e85df38c75ac3d31ff62d4fce0662d9f 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/ResourceDefinitionValidationService.java (renamed from ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryValidationService.java)8
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java67
2 files changed, 30 insertions, 45 deletions
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/ResourceDefinitionValidationService.java
index 7de7fc4c..d3bf4230 100644
--- 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/ResourceDefinitionValidationService.java
@@ -17,15 +17,13 @@
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.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionDefaultValidationService;
import org.springframework.stereotype.Service;
@Service
-public class ResourceDictionaryValidationService extends ResourceDictionaryDefaultValidationService {
+public class ResourceDefinitionValidationService extends ResourceDefinitionDefaultValidationService {
- private BluePrintRepoService bluePrintRepoService;
-
- public ResourceDictionaryValidationService(BluePrintRepoService bluePrintRepoService) {
+ public ResourceDefinitionValidationService(BluePrintRepoService bluePrintRepoService) {
super(bluePrintRepoService);
}
}
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 85e701b4..ccf4ffcc 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
@@ -18,6 +18,7 @@
package org.onap.ccsdk.apps.controllerblueprints.service;
import com.google.common.base.Preconditions;
+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;
@@ -43,16 +44,16 @@ public class ResourceDictionaryService {
private ResourceDictionaryRepository resourceDictionaryRepository;
- private ResourceDictionaryValidationService resourceDictionaryValidationService;
+ private ResourceDefinitionValidationService resourceDictionaryValidationService;
/**
* This is a DataDictionaryService, used to save and get the Resource Mapping stored in database
*
- * @param dataDictionaryRepository
- * @param resourceDictionaryValidationService
+ * @param dataDictionaryRepository dataDictionaryRepository
+ * @param resourceDictionaryValidationService resourceDictionaryValidationService
*/
public ResourceDictionaryService(ResourceDictionaryRepository dataDictionaryRepository,
- ResourceDictionaryValidationService resourceDictionaryValidationService) {
+ ResourceDefinitionValidationService resourceDictionaryValidationService) {
this.resourceDictionaryRepository = dataDictionaryRepository;
this.resourceDictionaryValidationService = resourceDictionaryValidationService;
}
@@ -60,58 +61,49 @@ public class ResourceDictionaryService {
/**
* This is a getDataDictionaryByName service
*
- * @param name
+ * @param name name
* @return DataDictionary
- * @throws BluePrintException
+ * @throws BluePrintException BluePrintException
*/
public ResourceDictionary getResourceDictionaryByName(String name) throws BluePrintException {
- if (StringUtils.isNotBlank(name)) {
- return resourceDictionaryRepository.findByName(name).get();
+ Preconditions.checkArgument(StringUtils.isNotBlank(name), "Resource dictionary Name Information is missing.");
+ Optional<ResourceDictionary> resourceDictionaryDb = resourceDictionaryRepository.findByName(name);
+ if (resourceDictionaryDb.isPresent()) {
+ return resourceDictionaryDb.get();
} else {
- throw new BluePrintException("Resource Mapping Name Information is missing.");
+ throw new BluePrintException(String.format("couldn't get resource dictionary for name (%s)", name));
}
}
/**
* This is a searchResourceDictionaryByNames service
*
- * @param names
+ * @param names 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");
- }
+ public List<ResourceDictionary> searchResourceDictionaryByNames(List<String> names) {
+ Preconditions.checkArgument(CollectionUtils.isNotEmpty(names), "No Search Information provide");
+ return resourceDictionaryRepository.findByNameIn(names);
}
/**
* This is a searchResourceDictionaryByTags service
*
- * @param tags
+ * @param tags 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");
- }
+ public List<ResourceDictionary> searchResourceDictionaryByTags(String tags) {
+ Preconditions.checkArgument(StringUtils.isNotBlank(tags), "No search tag information provide");
+ return resourceDictionaryRepository.findByTagsContainingIgnoreCase(tags);
}
/**
* This is a saveDataDictionary service
*
- * @param resourceDictionary
+ * @param resourceDictionary resourceDictionary
* @return DataDictionary
- * @throws BluePrintException
*/
- public ResourceDictionary saveResourceDictionary(ResourceDictionary resourceDictionary)
- throws BluePrintException {
+ public ResourceDictionary saveResourceDictionary(ResourceDictionary resourceDictionary) {
Preconditions.checkNotNull(resourceDictionary, "Resource Dictionary information is missing");
Preconditions.checkArgument(StringUtils.isNotBlank(resourceDictionary.getDefinition()),
"Resource Dictionary definition information is missing");
@@ -130,7 +122,7 @@ public class ResourceDictionaryService {
PropertyDefinition propertyDefinition = resourceDefinition.getProperty();
resourceDictionary.setDescription(propertyDefinition.getDescription());
resourceDictionary.setDataType(propertyDefinition.getType());
- if(propertyDefinition.getEntrySchema() != null){
+ if (propertyDefinition.getEntrySchema() != null) {
resourceDictionary.setEntrySchema(propertyDefinition.getEntrySchema().getType());
}
@@ -164,15 +156,10 @@ public class ResourceDictionaryService {
/**
* This is a deleteResourceDictionary service
*
- * @param name
- * @throws BluePrintException
+ * @param name name
*/
- public void deleteResourceDictionary(String name) throws BluePrintException {
- if (name != null) {
- resourceDictionaryRepository.deleteByName(name);
- } else {
- throw new BluePrintException("Resource Mapping Id Information is missing.");
- }
-
+ public void deleteResourceDictionary(String name) {
+ Preconditions.checkArgument(StringUtils.isNotBlank(name), "Resource dictionary Name Information is missing.");
+ resourceDictionaryRepository.deleteByName(name);
}
}