aboutsummaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules/service/src/main/java
diff options
context:
space:
mode:
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-09-12 16:26:31 +0000
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-09-12 16:26:31 +0000
commit5a992c7645fd3488382e736e8ce913aa6721e862 (patch)
tree775de56b0c6d0fde0f21fd8c3a61c2a0ff2f92d5 /ms/controllerblueprints/modules/service/src/main/java
parent14494258aa1648da961a065c4379761e505f915e (diff)
Controller Blueprints Microservice
Add dynamic resource source mapping rest service. Change-Id: I59274a4c0162bc6718c4248788c0e7f36830a129 Issue-ID: CCSDK-556 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@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/ApplicationRegistrationService.java26
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java13
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java7
3 files changed, 41 insertions, 5 deletions
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ApplicationRegistrationService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ApplicationRegistrationService.java
index 5a4a2877..fc7410f9 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ApplicationRegistrationService.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ApplicationRegistrationService.java
@@ -17,20 +17,40 @@
package org.onap.ccsdk.apps.controllerblueprints.service;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.apache.commons.collections.CollectionUtils;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
+import java.util.List;
@Component
@SuppressWarnings("unused")
public class ApplicationRegistrationService {
+ private static EELFLogger log = EELFManager.getInstance().getLogger(ApplicationRegistrationService.class);
+
+ @Value("#{'${resourceSourceMappings}'.split(',')}")
+ private List<String> resourceSourceMappings;
@PostConstruct
- public void register(){
+ public void register() {
registerDictionarySources();
}
- public void registerDictionarySources(){
-
+ public void registerDictionarySources() {
+ log.info("Registering Dictionary Sources : {}", resourceSourceMappings);
+ if (CollectionUtils.isNotEmpty(resourceSourceMappings)) {
+ resourceSourceMappings.forEach(resourceSourceMapping -> {
+ String[] mappingKeyValue = resourceSourceMapping.split("=");
+ if (mappingKeyValue != null && mappingKeyValue.length == 2) {
+ ResourceSourceMappingFactory.INSTANCE.registerSourceMapping(mappingKeyValue[0].trim(), mappingKeyValue[1].trim());
+ } else {
+ log.warn("failed to get resource source mapping {}", resourceSourceMapping);
+ }
+ });
+ }
}
}
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 62aa0e29..fd73db3b 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
@@ -22,8 +22,9 @@ 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.ResourceDefinition;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory;
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;
@@ -105,7 +106,7 @@ public class ResourceDictionaryService {
*/
public ResourceDictionary saveResourceDictionary(ResourceDictionary resourceDictionary) {
Preconditions.checkNotNull(resourceDictionary, "Resource Dictionary information is missing");
- Preconditions.checkNotNull(resourceDictionary.getDefinition(),"Resource Dictionary definition information is missing");
+ Preconditions.checkNotNull(resourceDictionary.getDefinition(), "Resource Dictionary definition information is missing");
ResourceDefinition resourceDefinition = resourceDictionary.getDefinition();
Preconditions.checkNotNull(resourceDefinition, "failed to get resource definition from content");
@@ -153,4 +154,12 @@ public class ResourceDictionaryService {
Preconditions.checkArgument(StringUtils.isNotBlank(name), "Resource dictionary Name Information is missing.");
resourceDictionaryRepository.deleteByName(name);
}
+
+ /**
+ * This is a getResourceSourceMapping service
+ *
+ */
+ public ResourceSourceMapping getResourceSourceMapping() {
+ return ResourceSourceMappingFactory.INSTANCE.getRegisterSourceMapping();
+ }
}
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
index e0cf6c69..287d413c 100644
--- 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
@@ -18,6 +18,7 @@
package org.onap.ccsdk.apps.controllerblueprints.service.rs;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping;
import org.onap.ccsdk.apps.controllerblueprints.service.ResourceDictionaryService;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
import org.springframework.http.MediaType;
@@ -76,4 +77,10 @@ public class ResourceDictionaryRest {
}
+ @GetMapping(path = "/source-mapping", produces = MediaType.APPLICATION_JSON_VALUE)
+ public @ResponseBody
+ ResourceSourceMapping getResourceSourceMapping() {
+ return resourceDictionaryService.getResourceSourceMapping();
+ }
+
}