summaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints
diff options
context:
space:
mode:
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-08-21 04:11:57 +0000
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-08-21 04:11:57 +0000
commit5285007a4e66bc18c69cef96aa32326a139d7642 (patch)
tree898fb3f81a7981c0dc2332dc5d42b87523d15162 /ms/controllerblueprints
parenta3c9519d6aa7eb8e1f450a7d041047f2c0a5cc07 (diff)
Controller Blueprints Microservice
Define Controllerblueprint API DataType and Error definitions for Config model, Service Template, Model Type and Resource Dictionary Services Change-Id: I12d8d87292ec101601b0cfb7ba9670730973e318 Issue-ID: CCSDK-469 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Diffstat (limited to 'ms/controllerblueprints')
-rwxr-xr-xms/controllerblueprints/README.md9
-rw-r--r--ms/controllerblueprints/application/load/model_type/artifact_type/artifact-bpmn-camunda.json8
-rw-r--r--ms/controllerblueprints/application/load/model_type/artifact_type/artifact-directed-graph.json9
-rw-r--r--ms/controllerblueprints/application/opt/app/onap/config/application.properties3
-rw-r--r--ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationExceptionHandler.java42
-rw-r--r--ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/CorsConfig.java27
-rw-r--r--ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java22
-rw-r--r--ms/controllerblueprints/application/src/test/resources/application.properties2
-rw-r--r--ms/controllerblueprints/application/src/test/resources/logback.xml3
-rw-r--r--ms/controllerblueprints/modules/core/load/model_type/artifact_type/artifact-bpmn-camunda.json8
-rw-r--r--ms/controllerblueprints/modules/core/load/model_type/artifact_type/artifact-directed-graph.json9
-rw-r--r--ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt5
-rw-r--r--ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt9
-rw-r--r--ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt7
-rw-r--r--ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/db-source.json31
-rw-r--r--ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json14
-rw-r--r--ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/input-source.json (renamed from ms/controllerblueprints/modules/service/load/resource_dictionary/action-name.json)2
-rw-r--r--ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json36
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignment.java6
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java24
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDefinition.java11
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/ResourceSource.java22
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDb.java2
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDefault.java2
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDeserializer.java67
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceInput.java3
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceMdsal.java3
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.java10
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/DictionaryDefinitionTest.java70
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDictionaryUtilsTest.java27
-rw-r--r--ms/controllerblueprints/modules/service/load/resource_dictionary/db-source.json (renamed from ms/controllerblueprints/modules/service/load/resource_dictionary/bundle-id.json)13
-rw-r--r--ms/controllerblueprints/modules/service/load/resource_dictionary/input-source.json17
-rw-r--r--ms/controllerblueprints/modules/service/load/resource_dictionary/v4-ip-type.json4
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ApplicationRegistrationService.java39
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ErrorMessage.java32
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java8
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java6
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java12
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java11
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java21
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java11
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java11
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java13
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java6
44 files changed, 584 insertions, 113 deletions
diff --git a/ms/controllerblueprints/README.md b/ms/controllerblueprints/README.md
index e69de29bb..070a54169 100755
--- a/ms/controllerblueprints/README.md
+++ b/ms/controllerblueprints/README.md
@@ -0,0 +1,9 @@
+Application VM Arguments :
+
+-Dlogging.config=etc/logback.xml
+-Dspring.config.location=opt/app/onap/config/
+-Dspring.datasource.url=jdbc:mysql://127.0.0.1:3306/sdnctl
+-Dspring.datasource.username=sdnctl
+-Dspring.datasource.password=sdnctl
+-Dblueprints.load.initial-data=true
+
diff --git a/ms/controllerblueprints/application/load/model_type/artifact_type/artifact-bpmn-camunda.json b/ms/controllerblueprints/application/load/model_type/artifact_type/artifact-bpmn-camunda.json
new file mode 100644
index 000000000..ac76b4f4f
--- /dev/null
+++ b/ms/controllerblueprints/application/load/model_type/artifact_type/artifact-bpmn-camunda.json
@@ -0,0 +1,8 @@
+{
+ "description": " Camunda BPM File",
+ "version": "1.0.0",
+ "file_ext": [
+ "bpmn"
+ ],
+ "derived_from": "tosca.artifacts.Implementation"
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/application/load/model_type/artifact_type/artifact-directed-graph.json b/ms/controllerblueprints/application/load/model_type/artifact_type/artifact-directed-graph.json
new file mode 100644
index 000000000..7ab3a5434
--- /dev/null
+++ b/ms/controllerblueprints/application/load/model_type/artifact_type/artifact-directed-graph.json
@@ -0,0 +1,9 @@
+{
+ "description": "Directed Graph File",
+ "version": "1.0.0",
+ "file_ext": [
+ "json",
+ "xml"
+ ],
+ "derived_from": "tosca.artifacts.Implementation"
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/application/opt/app/onap/config/application.properties b/ms/controllerblueprints/application/opt/app/onap/config/application.properties
index 9fa8e04cf..f075b578e 100644
--- a/ms/controllerblueprints/application/opt/app/onap/config/application.properties
+++ b/ms/controllerblueprints/application/opt/app/onap/config/application.properties
@@ -20,6 +20,9 @@ logging.level.org.springframework.web=INFO
logging.level.org.hibernate.SQL=warn
logging.level.org.hibernate.type.descriptor.sql=debug
+#To Remove Null in JSON API Response
+spring.jackson.default-property-inclusion=non_null
+
spring.jpa.properties.hibernate.show_sql=true
spring.jpa.properties.hibernate.use_sql_comments=true
spring.jpa.properties.hibernate.format_sql=true
diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationExceptionHandler.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationExceptionHandler.java
new file mode 100644
index 000000000..d02be5c26
--- /dev/null
+++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationExceptionHandler.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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;
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.service.common.ErrorMessage;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.context.request.WebRequest;
+
+@ControllerAdvice
+@RestController
+public class ApplicationExceptionHandler {
+ @ExceptionHandler(Exception.class)
+ public final ResponseEntity<ErrorMessage> handleAllExceptions(Exception ex, WebRequest request) {
+ ErrorMessage exceptionResponse = new ErrorMessage( ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR.value(), ex.getLocalizedMessage());
+ return new ResponseEntity<>(exceptionResponse, HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+
+ @ExceptionHandler(BluePrintException.class)
+ public final ResponseEntity<ErrorMessage> handleBlueprintException(BluePrintException ex, WebRequest request) {
+ ErrorMessage exceptionResponse = new ErrorMessage( ex.getMessage(), ex.getCode(), ex.getLocalizedMessage());
+ return new ResponseEntity<>(exceptionResponse, HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+}
diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/CorsConfig.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/CorsConfig.java
index 5d682ed50..d00d2c845 100644
--- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/CorsConfig.java
+++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/CorsConfig.java
@@ -20,8 +20,9 @@ package org.onap.ccsdk.apps.controllerblueprints;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
-import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
-import org.springframework.web.filter.CorsFilter;
+import org.springframework.web.cors.reactive.CorsWebFilter;
+import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
+import java.util.Arrays;
/**
* CorsConfig.java Purpose: Provide Configuration Generator CorsConfig Information
@@ -29,7 +30,7 @@ import org.springframework.web.filter.CorsFilter;
* @author Brinda Santh
* @version 1.0
*/
-//@Configuration
+@Configuration
public class CorsConfig {
/**
* This is a CORS Implementation for different Orgin GUI to access.
@@ -37,15 +38,17 @@ public class CorsConfig {
* @return CorsFilter
*/
@Bean
- public CorsFilter corsFilter() {
- UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
- CorsConfiguration config = new CorsConfiguration();
- config.setAllowCredentials(true);
- config.addAllowedOrigin("*");
- config.addAllowedHeader("*");
- config.addAllowedMethod("*");
- source.registerCorsConfiguration("/**", config);
- return new CorsFilter(source);
+ CorsWebFilter corsWebFilter() {
+ CorsConfiguration corsConfig = new CorsConfiguration();
+ corsConfig.setAllowedOrigins(Arrays.asList("*"));
+ corsConfig.setMaxAge(8000L);
+ corsConfig.addAllowedMethod("*");
+
+ UrlBasedCorsConfigurationSource source =
+ new UrlBasedCorsConfigurationSource();
+ source.registerCorsConfiguration("/**", corsConfig);
+
+ return new CorsWebFilter(source);
}
diff --git a/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java b/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java
index 95639bd32..26b943b61 100644
--- a/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java
+++ b/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java
@@ -16,17 +16,18 @@
package org.onap.ccsdk.apps.controllerblueprints;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
+import org.springframework.http.*;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
@@ -46,8 +47,21 @@ public class ControllerBluprintsApplicationTest {
@Test
public void testConfigModel() {
- ResponseEntity<String> entity = this.restTemplate
- .getForEntity("/api/v1/config-model/1", String.class);
+ HttpHeaders headers = new HttpHeaders();
+ headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
+ ResponseEntity<ConfigModel> entity = this.restTemplate
+ .exchange("/api/v1/config-model/1", HttpMethod.GET, new HttpEntity<>(headers),ConfigModel.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
+ Assert.assertNotNull("failed to get response Config model",entity.getBody());
+ }
+
+ @Test
+ public void testConfigModelFailure() {
+ HttpHeaders headers = new HttpHeaders();
+ headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
+ ResponseEntity<ConfigModel> entity = this.restTemplate
+ .exchange("/api/v1/config-model-not-found/1", HttpMethod.GET, new HttpEntity<>(headers),ConfigModel.class);
+ assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
+ Assert.assertNotNull("failed to get response Config model",entity.getBody());
}
}
diff --git a/ms/controllerblueprints/application/src/test/resources/application.properties b/ms/controllerblueprints/application/src/test/resources/application.properties
index 55ffeaf16..a147034f8 100644
--- a/ms/controllerblueprints/application/src/test/resources/application.properties
+++ b/ms/controllerblueprints/application/src/test/resources/application.properties
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
+spring.jackson.default-property-inclusion=non_null
#Load Blueprints
# blueprints.load.initial-data may be overridden by ENV variables
blueprints.load.initial-data=true
diff --git a/ms/controllerblueprints/application/src/test/resources/logback.xml b/ms/controllerblueprints/application/src/test/resources/logback.xml
index b9b97dc89..53388bc9e 100644
--- a/ms/controllerblueprints/application/src/test/resources/logback.xml
+++ b/ms/controllerblueprints/application/src/test/resources/logback.xml
@@ -24,8 +24,7 @@
</appender>
- <logger name="org.springframework" level="info"/>
- <logger name="org.springframework.web" level="debug"/>
+ <logger name="org.springframework" level="warn"/>
<logger name="org.hibernate" level="info"/>
<logger name="org.onap.ccsdk.apps.controllerblueprints" level="info"/>
diff --git a/ms/controllerblueprints/modules/core/load/model_type/artifact_type/artifact-bpmn-camunda.json b/ms/controllerblueprints/modules/core/load/model_type/artifact_type/artifact-bpmn-camunda.json
new file mode 100644
index 000000000..ac76b4f4f
--- /dev/null
+++ b/ms/controllerblueprints/modules/core/load/model_type/artifact_type/artifact-bpmn-camunda.json
@@ -0,0 +1,8 @@
+{
+ "description": " Camunda BPM File",
+ "version": "1.0.0",
+ "file_ext": [
+ "bpmn"
+ ],
+ "derived_from": "tosca.artifacts.Implementation"
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/core/load/model_type/artifact_type/artifact-directed-graph.json b/ms/controllerblueprints/modules/core/load/model_type/artifact_type/artifact-directed-graph.json
new file mode 100644
index 000000000..7ab3a5434
--- /dev/null
+++ b/ms/controllerblueprints/modules/core/load/model_type/artifact_type/artifact-directed-graph.json
@@ -0,0 +1,9 @@
+{
+ "description": "Directed Graph File",
+ "version": "1.0.0",
+ "file_ext": [
+ "json",
+ "xml"
+ ],
+ "derived_from": "tosca.artifacts.Implementation"
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt
index bb5a78fd9..978269125 100644
--- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt
+++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt
@@ -42,11 +42,6 @@ object ConfigModelConstant {
const val CAPABILITY_PROPERTY_MAPPING = "mapping"
- const val SOURCE_INPUT = "input"
- const val SOURCE_DEFAULT = "default"
- const val SOURCE_MDSAL = "mdsal"
- const val SOURCE_DB = "db"
-
const val PROPERTY_RECIPE_NAMES = "action-names"
}
diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt
index 6d677ffae..a10f6d30c 100644
--- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt
+++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt
@@ -155,7 +155,7 @@ class PropertyDefinition {
var id: String? = null
var description: String? = null
var required: Boolean? = null
- var type: String? = null
+ lateinit var type: String
@get:JsonProperty("default")
var defaultValue: Any? = null
var status: String? = null
@@ -202,7 +202,7 @@ class OperationDefinition {
}
class Implementation {
- var primary: String? = null
+ lateinit var primary: String
var dependencies: MutableList<String>? = null
}
@@ -240,6 +240,11 @@ class TriggerDefinition {
var description: String? = null
@get:JsonProperty("event_type")
lateinit var eventType: String
+ @get:JsonProperty("target_filter")
+ var targetFilter: EventFilterDefinition? = null
+ var condition: ConditionClause? = null
+ var constraint: ConditionClause? = null
+ var method: String? = null
lateinit var action: String
}
diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
index 95b2af7b7..9621382c3 100644
--- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
+++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
@@ -50,6 +50,13 @@ object JacksonUtils {
}
@JvmStatic
+ fun <T> readValueFromFile(fileName: String, valueType: Class<T>): T? {
+ val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())
+ ?: throw BluePrintException(format("Failed to read json file : {}", fileName))
+ return readValue(content, valueType)
+ }
+
+ @JvmStatic
fun jsonNodeFromObject(from: kotlin.Any): JsonNode = jacksonObjectMapper().convertValue(from, JsonNode::class.java)
@JvmStatic
diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/db-source.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/db-source.json
new file mode 100644
index 000000000..8b97cdeb7
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/db-source.json
@@ -0,0 +1,31 @@
+{
+ "name": "bundle-id",
+ "description": "name of the ",
+ "resource-type": "ONAP",
+ "resource-path": "vnf/bundle-id",
+ "updated-by": "brindasanth@onap.com",
+ "data-type": "String",
+ "tags": "bundle-id, brindasanth@onap.com",
+ "source": {
+ "db": {
+ "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name",
+ "input-key-mapping": {
+ "profile_name": "profile_name"
+ },
+ "output-key-mapping": {
+ "db-country": "country",
+ "db-state": "state"
+ }
+ }
+ },
+ "decryption-rules": [
+ {
+ "sources": [
+ "input"
+ ],
+ "path": "/.",
+ "rule": "LOCAL-Decrypt",
+ "decrypt-type": "AES128"
+ }
+ ]
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json
new file mode 100644
index 000000000..ac23292ed
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json
@@ -0,0 +1,14 @@
+{
+ "tags": "v4-ip-type, tosca.datatypes.Root, data_type, brindasanth@onap.com",
+ "name": "v4-ip-type",
+ "description": "To be provided",
+ "updated-by": "brindasanth@onap.com",
+ "resource-type": "ONAP",
+ "resource-path": "vnf/v4-ip-type",
+ "data-type": "string",
+ "source": {
+ "default": {
+
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/load/resource_dictionary/action-name.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/input-source.json
index 92b64e629..35736b663 100644
--- a/ms/controllerblueprints/modules/service/load/resource_dictionary/action-name.json
+++ b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/input-source.json
@@ -5,7 +5,7 @@
"description": "To be provided",
"valid-values": null,
"sample-value": null,
- "updated-by": "ym9479@onap.com",
+ "updated-by": "brindasanth@onap.com",
"tags": null,
"default": null,
"data-type": "string",
diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json
new file mode 100644
index 000000000..c103f94dc
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json
@@ -0,0 +1,36 @@
+{
+ "tags": "oam-local-ipv4-address, tosca.datatypes.Root, data_type, st1848@att.com",
+ "name": "oam-local-ipv4-address",
+ "description": "based on service-instance-id,network-role,v4-ip-type and vm-type get the ipv4-gateway-prefix from the SDN-GC mdsal",
+ "updated-by": "st1848@att.com",
+ "resource-type": "ATT",
+ "resource-path": "vnf/oam-local-ipv4-address",
+ "data-type": "string",
+ "source": {
+ "mdsal": {
+ "base": "sdnc-gc",
+ "type": "JSON",
+ "url-path": "config/L3VNF-API:services/service-list/$service-instance-id/service-data/vnf-topology-information/vnf-assignments/vnf-vms/$vm-type/vm-networks/$network-role/v4-assigned-ip-list/$v4-ip-type",
+ "path": "/v4-assigned-ip-list/0/v4-ip-prefix",
+ "input-key-mapping": {
+ "service-instance-id": "service-instance-id",
+ "network-role": "network-role",
+ "v4-ip-type": "v4-ip-type",
+ "vm-type": "vm-type"
+ },
+ "output-key-mapping": {
+ "oam-local-ipv4-address": "v4-ip-prefix"
+ }
+ }
+ },
+ "candidate-dependency": {
+ "mdsal": {
+ "names": [
+ "service-instance-id",
+ "network-role",
+ "v4-ip-type",
+ "vm-type"
+ ]
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignment.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignment.java
index 15576b906..f85e5ebcd 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignment.java
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignment.java
@@ -30,10 +30,10 @@ import java.util.List;
* @version 1.0
*/
public class ResourceAssignment {
-
+ @JsonProperty(value = "name", required = true)
private String name;
- @JsonProperty("property")
+ @JsonProperty(value = "property", required = true)
private PropertyDefinition property;
@JsonProperty("input-param")
@@ -58,7 +58,7 @@ public class ResourceAssignment {
private String message;
@JsonProperty("updated-date")
- @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy hh:mm:ss")
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
private Date updatedDate;
@JsonProperty("updated-by")
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java
new file mode 100644
index 000000000..1af42c590
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.resource.dict;
+
+public class ResourceDictionaryConstants {
+ public static final String SOURCE_INPUT= "input";
+ public static final String SOURCE_DEFAULT = "default";
+ public static final String SOURCE_DB = "db";
+ public static final String SOURCE_MDSAL = "mdsal";
+}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDefinition.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDefinition.java
index 4dc9c89a1..7c2d926f0 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDefinition.java
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDefinition.java
@@ -17,7 +17,7 @@
package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.List;
import java.util.Map;
@@ -29,6 +29,7 @@ import java.util.Map;
public class DictionaryDefinition {
@JsonProperty(value = "name", required = true)
private String name;
+
@JsonProperty(value = "description")
private String description;
@@ -39,6 +40,7 @@ public class DictionaryDefinition {
private String sampleValue;
private String tags;
+
@JsonProperty(value = "updated-by")
private String updatedBy;
@@ -58,7 +60,8 @@ public class DictionaryDefinition {
private Object defaultValue;
@JsonProperty(value = "source", required = true)
- private Map<String, JsonNode> source;
+ @JsonDeserialize(using = SourceDeserializer.class, keyAs = String.class, contentAs = ResourceSource.class)
+ private Map<String, ResourceSource> source;
@JsonProperty("candidate-dependency")
private Map<String, DictionaryDependency> dependency;
@@ -154,11 +157,11 @@ public class DictionaryDefinition {
this.defaultValue = defaultValue;
}
- public Map<String, JsonNode> getSource() {
+ public Map<String, ResourceSource> getSource() {
return source;
}
- public void setSource(Map<String, JsonNode> source) {
+ public void setSource(Map<String, ResourceSource> source) {
this.source = source;
}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/ResourceSource.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/ResourceSource.java
new file mode 100644
index 000000000..735832cb1
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/ResourceSource.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.resource.dict.data;
+
+import java.io.Serializable;
+
+public interface ResourceSource extends Serializable {
+}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDb.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDb.java
index 23d404605..724d0224e 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDb.java
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDb.java
@@ -24,7 +24,7 @@ import java.util.Map;
* SourceDb
* @author Brinda Santh
*/
-public class SourceDb {
+public class SourceDb implements ResourceSource{
@JsonProperty(value = "base", required = true)
private String base;
@JsonProperty(value = "type", required = true)
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDefault.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDefault.java
index 0a4351cca..d165192e9 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDefault.java
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDefault.java
@@ -20,7 +20,7 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data;
* SourceDefault
* @author Brinda Santh
*/
-public class SourceDefault {
+public class SourceDefault implements ResourceSource {
private String key;
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDeserializer.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDeserializer.java
new file mode 100644
index 000000000..86476e1c2
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDeserializer.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.resource.dict.data;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.*;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.base.Preconditions;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+public class SourceDeserializer extends JsonDeserializer<Map<String, ResourceSource>> {
+
+ private static final Logger log = LoggerFactory.getLogger(SourceDeserializer.class);
+
+ private Class<?> keyAs;
+
+ private Class<?> contentAs;
+
+ private static Map<String, Class<? extends ResourceSource>> registry = new HashMap<String, Class<? extends ResourceSource>>();
+
+ public static void registerSource(String uniqueAttribute, Class<? extends ResourceSource> sourceClass) {
+ registry.put(uniqueAttribute, sourceClass);
+ }
+
+ @Override
+ public Map<String, ResourceSource> deserialize(JsonParser p, DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ ObjectMapper mapper = (ObjectMapper) p.getCodec();
+ ObjectNode root = (ObjectNode) mapper.readTree(p);
+ Map<String, ResourceSource> sources = new HashMap();
+ root.fields().forEachRemaining((node) -> {
+ String key = node.getKey();
+ JsonNode valueNode = node.getValue();
+ Preconditions.checkArgument(StringUtils.isNotBlank(key), "missing source key");
+ Preconditions.checkArgument(registry.containsKey(key), key +" source not registered");
+ if (StringUtils.isNotBlank(key) && registry.containsKey(key)) {
+ Class<? extends ResourceSource> sourceClass = registry.get(key);
+ ResourceSource resourceSource = JacksonUtils.readValue(valueNode.toString(), sourceClass);
+ sources.put(key, resourceSource);
+ }
+ });
+ return sources;
+ }
+}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceInput.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceInput.java
index 82cb769da..87184f223 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceInput.java
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceInput.java
@@ -20,7 +20,7 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data;
* SourceInput
* @author Brinda Santh
*/
-public class SourceInput {
+public class SourceInput implements ResourceSource {
private String key;
@@ -33,5 +33,4 @@ public class SourceInput {
}
-
}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceMdsal.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceMdsal.java
index 9eb233e76..8a066e91a 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceMdsal.java
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceMdsal.java
@@ -24,7 +24,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Map;
-public class SourceMdsal {
+public class SourceMdsal implements ResourceSource {
@JsonProperty(value = "base", required = true)
private String base;
@@ -93,5 +93,4 @@ public class SourceMdsal {
}
-
}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.java
index 9d51d8213..4f9467f05 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.java
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.java
@@ -16,15 +16,15 @@
package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils;
-import com.fasterxml.jackson.databind.JsonNode;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
-import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
import org.onap.ccsdk.apps.controllerblueprints.core.data.EntrySchema;
import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DictionaryDefinition;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DictionaryDependency;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.ResourceSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -63,7 +63,7 @@ public class ResourceDictionaryUtils {
// Overwrite the Property Definitions from Dictionary
setProperty(resourceAssignment, dictionaryDefinition);
- Map<String, JsonNode> dictionarySource = dictionaryDefinition.getSource();
+ Map<String, ResourceSource> dictionarySource = dictionaryDefinition.getSource();
Map<String, DictionaryDependency> dictionaryDependencyMap = dictionaryDefinition.getDependency();
if (MapUtils.isNotEmpty(dictionarySource)) {
@@ -82,7 +82,7 @@ public class ResourceDictionaryUtils {
}
}
} else {
- resourceAssignment.setDictionarySource(ConfigModelConstant.SOURCE_INPUT);
+ resourceAssignment.setDictionarySource(ResourceDictionaryConstants.SOURCE_INPUT);
}
log.info("auto map resourceAssignment : {}", resourceAssignment);
}
@@ -98,7 +98,7 @@ public class ResourceDictionaryUtils {
}
}
- private static String findFirstSource(Map<String, JsonNode> dictionarySource) {
+ private static String findFirstSource(Map<String, ResourceSource> dictionarySource) {
String source = null;
if (MapUtils.isNotEmpty(dictionarySource)) {
source = dictionarySource.keySet().stream().findFirst().get();
diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/DictionaryDefinitionTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/DictionaryDefinitionTest.java
new file mode 100644
index 000000000..851ba1256
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/DictionaryDefinitionTest.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.resource.dict.util;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DictionaryDefinitionTest {
+ private Logger log = LoggerFactory.getLogger(DictionaryDefinitionTest.class);
+ String basePath = "load/resource_dictionary";
+
+ @Before
+ public void setup(){
+ SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_DB, SourceDb.class);
+ SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_INPUT, SourceInput.class);
+ SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_MDSAL, SourceMdsal.class);
+ SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_DEFAULT,SourceDefault.class);
+ }
+
+ @Test
+ public void testDictionaryDefinitionInputSource(){
+
+ String fileName = basePath + "/input-source.json";
+ DictionaryDefinition dictionaryDefinition = JacksonUtils.readValueFromFile(fileName, DictionaryDefinition.class);
+ Assert.assertNotNull("Failed to populate dictionaryDefinition for input type", dictionaryDefinition);
+ }
+
+ @Test
+ public void testDictionaryDefinitionDefaultSource(){
+
+ String fileName = basePath + "/default-source.json";
+ DictionaryDefinition dictionaryDefinition = JacksonUtils.readValueFromFile(fileName, DictionaryDefinition.class);
+ Assert.assertNotNull("Failed to populate dictionaryDefinition for default type", dictionaryDefinition);
+ }
+
+ @Test
+ public void testDictionaryDefinitionDBSource(){
+
+ String fileName = basePath + "/db-source.json";
+ DictionaryDefinition dictionaryDefinition = JacksonUtils.readValueFromFile(fileName, DictionaryDefinition.class);
+ Assert.assertNotNull("Failed to populate dictionaryDefinition for db type", dictionaryDefinition);
+ }
+
+ @Test
+ public void testDictionaryDefinitionMDSALSource(){
+ String fileName = basePath + "/mdsal-source.json";
+ DictionaryDefinition dictionaryDefinition = JacksonUtils.readValueFromFile(fileName, DictionaryDefinition.class);
+ Assert.assertNotNull("Failed to populate dictionaryDefinition for mdsal type", dictionaryDefinition);
+ }
+}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDictionaryUtilsTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDictionaryUtilsTest.java
index 22b01c4a8..0c9a1c5d8 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDictionaryUtilsTest.java
+++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDictionaryUtilsTest.java
@@ -17,13 +17,11 @@
package org.onap.ccsdk.apps.controllerblueprints.resource.dict.util;
-import com.fasterxml.jackson.databind.JsonNode;
import org.junit.Assert;
import org.junit.Test;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
-import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.*;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryUtils;
import org.slf4j.Logger;
@@ -45,9 +43,9 @@ public class ResourceDictionaryUtilsTest {
DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();
dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);
- Map<String, JsonNode> source = new HashMap<>();
+ Map<String, ResourceSource> source = new HashMap<>();
SourceInput sourceInput = new SourceInput();
- source.put(ConfigModelConstant.SOURCE_INPUT, JacksonUtils.jsonNodeFromObject(sourceInput));
+ source.put(ResourceDictionaryConstants.SOURCE_INPUT, sourceInput);
dictionaryDefinition.setSource(source);
ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition);
@@ -72,15 +70,16 @@ public class ResourceDictionaryUtilsTest {
DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();
dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);
- Map<String, JsonNode> source = new HashMap<>();
+ Map<String, ResourceSource> source = new HashMap<>();
SourceDb sourceDb = new SourceDb();
- source.put(ConfigModelConstant.SOURCE_DB, JacksonUtils.jsonNodeFromObject(sourceDb));
+ sourceDb.setBase("sdnc_connection");
+ source.put(ResourceDictionaryConstants.SOURCE_DB, sourceDb);
dictionaryDefinition.setSource(source);
Map<String, DictionaryDependency> dependency = new HashMap<>();
DictionaryDependency dependencyDb = new DictionaryDependency();
dependencyDb.setNames(Arrays.asList("vnf-id", "vnf-name"));
- dependency.put(ConfigModelConstant.SOURCE_DB, dependencyDb);
+ dependency.put(ResourceDictionaryConstants.SOURCE_DB, dependencyDb);
dictionaryDefinition.setDependency(dependency);
DecryptionRule decryptionRule = new DecryptionRule();
@@ -115,15 +114,15 @@ public class ResourceDictionaryUtilsTest {
DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();
dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);
- Map<String, JsonNode> source = new HashMap<>();
+ Map<String, ResourceSource> source = new HashMap<>();
SourceDefault sourceDefault = new SourceDefault();
- source.put(ConfigModelConstant.SOURCE_DEFAULT, JacksonUtils.jsonNodeFromObject(sourceDefault));
+ source.put(ResourceDictionaryConstants.SOURCE_DEFAULT, sourceDefault);
dictionaryDefinition.setSource(source);
Map<String, DictionaryDependency> dependency = new HashMap<>();
DictionaryDependency dependencyDefault = new DictionaryDependency();
dependencyDefault.setNames(Arrays.asList(new String[]{"vnf-id", "vnf-name"}));
- dependency.put(ConfigModelConstant.SOURCE_DEFAULT, dependencyDefault);
+ dependency.put(ResourceDictionaryConstants.SOURCE_DEFAULT, dependencyDefault);
dictionaryDefinition.setDependency(dependency);
ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition);
@@ -143,15 +142,15 @@ public class ResourceDictionaryUtilsTest {
DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();
dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);
- Map<String, JsonNode> source = new HashMap<>();
+ Map<String, ResourceSource> source = new HashMap<>();
SourceMdsal sourceMdsal = new SourceMdsal();
- source.put(ConfigModelConstant.SOURCE_MDSAL, JacksonUtils.jsonNodeFromObject(sourceMdsal));
+ source.put(ResourceDictionaryConstants.SOURCE_MDSAL,sourceMdsal);
dictionaryDefinition.setSource(source);
Map<String, DictionaryDependency> dependency = new HashMap<>();
DictionaryDependency dependencyMdsal = new DictionaryDependency();
dependencyMdsal.setNames(Arrays.asList(new String[]{"vnf-id", "vnf-name"}));
- dependency.put(ConfigModelConstant.SOURCE_MDSAL, dependencyMdsal);
+ dependency.put(ResourceDictionaryConstants.SOURCE_MDSAL, dependencyMdsal);
dictionaryDefinition.setDependency(dependency);
ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition);
diff --git a/ms/controllerblueprints/modules/service/load/resource_dictionary/bundle-id.json b/ms/controllerblueprints/modules/service/load/resource_dictionary/db-source.json
index f9678f5ff..862523544 100644
--- a/ms/controllerblueprints/modules/service/load/resource_dictionary/bundle-id.json
+++ b/ms/controllerblueprints/modules/service/load/resource_dictionary/db-source.json
@@ -3,20 +3,19 @@
"description": "name of the ",
"resource-type": "ONAP",
"resource-path": "vnf/bundle-id",
- "updated-by": "ym9479@onap.com",
+ "updated-by": "brindasanth@onap.com",
"data-type": "String",
- "tags": "bundle-id, ym9479@onap.com",
+ "tags": "bundle-id, brindasanth@onap.com",
"source": {
"db": {
- "path": "$key-value",
+ "query": "SELECT bundle-id FROM DEVICE_PROFILE WHERE profile_name = :profile_name",
"input-key-mapping": {
- "key-value": "$resource-group-key"
+ "profile_name": "profile_name"
},
"output-key-mapping": {
- "bundle-id": "bundle-id"
+ "db-country": "country",
+ "db-state": "state"
}
- },
- "input": {
}
},
"decryption-rules": [
diff --git a/ms/controllerblueprints/modules/service/load/resource_dictionary/input-source.json b/ms/controllerblueprints/modules/service/load/resource_dictionary/input-source.json
new file mode 100644
index 000000000..35736b663
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/load/resource_dictionary/input-source.json
@@ -0,0 +1,17 @@
+{
+ "name": "action-name",
+ "resource-path": "action-name",
+ "resource-type": "ONAP",
+ "description": "To be provided",
+ "valid-values": null,
+ "sample-value": null,
+ "updated-by": "brindasanth@onap.com",
+ "tags": null,
+ "default": null,
+ "data-type": "string",
+ "source": {
+ "input": {
+ "key": "action-name"
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/load/resource_dictionary/v4-ip-type.json b/ms/controllerblueprints/modules/service/load/resource_dictionary/v4-ip-type.json
index 03254b78a..c6c0f9851 100644
--- a/ms/controllerblueprints/modules/service/load/resource_dictionary/v4-ip-type.json
+++ b/ms/controllerblueprints/modules/service/load/resource_dictionary/v4-ip-type.json
@@ -1,8 +1,8 @@
{
- "tags": "v4-ip-type, tosca.datatypes.Root, data_type, ym9479@onap.com",
+ "tags": "v4-ip-type, tosca.datatypes.Root, data_type, brindasanth@onap.com",
"name": "v4-ip-type",
"description": "To be provided",
- "updated-by": "ym9479@onap.com",
+ "updated-by": "brindasanth@onap.com",
"resource-type": "ONAP",
"resource-path": "vnf/v4-ip-type",
"data-type": "string",
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
new file mode 100644
index 000000000..074f18d05
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ApplicationRegistrationService.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.resource.dict.ResourceDictionaryConstants;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.*;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+
+@Component
+public class ApplicationRegistrationService {
+
+ @PostConstruct
+ public void register(){
+ registerDictionarySources();
+ }
+
+ public void registerDictionarySources(){
+ SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_DB, SourceDb.class);
+ SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_INPUT, SourceInput.class);
+ SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_MDSAL, SourceMdsal.class);
+ SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_DEFAULT,SourceDefault.class);
+ }
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ErrorMessage.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ErrorMessage.java
index f7a802e46..431641265 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ErrorMessage.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ErrorMessage.java
@@ -16,24 +16,25 @@
package org.onap.ccsdk.apps.controllerblueprints.service.common;
+import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import java.io.Serializable;
+import java.util.Date;
@JsonInclude(Include.NON_NULL)
public class ErrorMessage implements Serializable {
- private Integer httpStatus;
private String message;
private Integer code;
- private String developerMessage;
+ private String debugMessage;
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
+ private Date timestamp = new Date();
- public Integer getHttpStatus() {
- return httpStatus;
- }
-
- public void setHttpStatus(Integer httpStatus) {
- this.httpStatus = httpStatus;
+ public ErrorMessage(String message, Integer code, String debugMessage){
+ this.message = message;
+ this.code = code;
+ this.debugMessage = debugMessage;
}
public String getMessage() {
@@ -52,12 +53,19 @@ public class ErrorMessage implements Serializable {
this.code = code;
}
- public String getDeveloperMessage() {
- return developerMessage;
+ public String getDebugMessage() {
+ return debugMessage;
}
- public void setDeveloperMessage(String developerMessage) {
- this.developerMessage = developerMessage;
+ public void setDebugMessage(String developerMessage) {
+ this.debugMessage = developerMessage;
}
+ public Date getTimestamp() {
+ return timestamp;
+ }
+
+ public void setTimestamp(Date timestamp) {
+ this.timestamp = timestamp;
+ }
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java
index 224960fa5..45382815c 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java
@@ -18,6 +18,7 @@ package org.onap.ccsdk.apps.controllerblueprints.service.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonManagedReference;
+import io.swagger.annotations.ApiModelProperty;
import org.hibernate.annotations.Proxy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
@@ -82,6 +83,7 @@ public class ConfigModel implements Serializable {
@NotNull
@Column(name = "artifact_version")
+ @ApiModelProperty(required=true)
private String artifactVersion;
@Lob
@@ -91,7 +93,7 @@ public class ConfigModel implements Serializable {
@Column(name = "internal_version")
private Integer internalVersion;
- @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MM/dd/yyyy KK:mm:ss a Z")
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
@LastModifiedDate
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "creation_date")
@@ -99,19 +101,23 @@ public class ConfigModel implements Serializable {
@NotNull
@Column(name = "artifact_name")
+ @ApiModelProperty(required=true)
private String artifactName;
@NotNull
@Column(name = "published")
+ @ApiModelProperty(required=true)
private String published;
@NotNull
@Column(name = "updated_by")
+ @ApiModelProperty(required=true)
private String updatedBy;
@NotNull
@Lob
@Column(name = "tags")
+ @ApiModelProperty(required=true)
private String tags;
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 f7bd554df..0c05ef959 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
@@ -18,6 +18,7 @@ package org.onap.ccsdk.apps.controllerblueprints.service.domain;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
@@ -46,10 +47,12 @@ public class ConfigModelContent {
@NotNull
@Column(name = "name")
+ @ApiModelProperty(required=true)
private String name;
@NotNull
@Column(name = "content_type")
+ @ApiModelProperty(required=true)
private String contentType;
@@ -65,10 +68,11 @@ public class ConfigModelContent {
@NotNull
@Lob
@Column(name = "content")
+ @ApiModelProperty(required=true)
private String content;
- @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MM/dd/yyyy KK:mm:ss a Z")
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
@LastModifiedDate
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "updated_date")
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 ed6340a65..61e4d1189 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
@@ -16,6 +16,8 @@
package org.onap.ccsdk.apps.controllerblueprints.service.domain;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
@@ -40,36 +42,43 @@ public class ModelType implements Serializable {
@Id
@NotNull
@Column(name = "model_name", nullable = false)
+ @ApiModelProperty(required=true)
private String modelName;
@NotNull
@Column(name = "derived_from")
+ @ApiModelProperty(required=true)
private String derivedFrom;
@NotNull
@Column(name = "definition_type")
+ @ApiModelProperty(required=true)
private String definitionType;
@NotNull
@Lob
@Column(name = "definition")
+ @ApiModelProperty(required=true)
private String definition;
@NotNull
@Lob
@Column(name = "description")
+ @ApiModelProperty(required=true)
private String description;
@NotNull
@Column(name = "version")
+ @ApiModelProperty(required=true)
private String version;
@NotNull
@Lob
@Column(name = "tags")
+ @ApiModelProperty(required=true)
private String tags;
- // @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MM/dd/yyyy KK:mm:ss a Z")
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
@LastModifiedDate
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "creation_date")
@@ -77,6 +86,7 @@ public class ModelType implements Serializable {
@NotNull
@Column(name = "updated_by")
+ @ApiModelProperty(required=true)
private String updatedBy;
@Override
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 adb018841..0d5879db8 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
@@ -16,6 +16,8 @@
package org.onap.ccsdk.apps.controllerblueprints.service.domain;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
@@ -39,18 +41,22 @@ public class ResourceDictionary implements Serializable {
@Id
@NotNull
@Column(name = "name")
+ @ApiModelProperty(required=true)
private String name;
@NotNull
@Column(name = "resource_path")
+ @ApiModelProperty(required=true)
private String resourcePath;
@NotNull
@Column(name = "resource_type")
+ @ApiModelProperty(required=true)
private String resourceType;
@NotNull
@Column(name = "data_type")
+ @ApiModelProperty(required=true)
private String dataType;
@Column(name = "entry_schema")
@@ -67,18 +73,22 @@ public class ResourceDictionary implements Serializable {
@NotNull
@Lob
@Column(name = "definition")
+ @ApiModelProperty(required=true)
private String definition;
@NotNull
@Lob
@Column(name = "description")
+ @ApiModelProperty(required=true)
private String description;
@NotNull
@Lob
@Column(name = "tags")
+ @ApiModelProperty(required=true)
private String tags;
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
@LastModifiedDate
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "creation_date")
@@ -86,6 +96,7 @@ public class ResourceDictionary implements Serializable {
@NotNull
@Column(name = "updated_by")
+ @ApiModelProperty(required=true)
private String updatedBy;
@Override
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java
index 94324a808..62b683032 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java
@@ -19,8 +19,7 @@ package org.onap.ccsdk.apps.controllerblueprints.service.rs;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
import org.onap.ccsdk.apps.controllerblueprints.service.ConfigModelService;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
+import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@@ -29,7 +28,7 @@ import java.util.List;
* {@inheritDoc}
*/
@RestController
-@RequestMapping("/api/v1/config-model")
+@RequestMapping(value = "/api/v1/config-model")
public class ConfigModelRest {
private ConfigModelService configModelService;
@@ -44,7 +43,7 @@ public class ConfigModelRest {
}
- @GetMapping(path = "/initial/{name}")
+ @GetMapping(path = "/initial/{name}", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
ConfigModel getInitialConfigModel(@PathVariable(value = "name") String name) throws BluePrintException {
try {
@@ -54,7 +53,7 @@ public class ConfigModelRest {
}
}
- @PostMapping(path = "/")
+ @PostMapping(path = "/", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
ConfigModel saveConfigModel(@RequestBody ConfigModel configModel) throws BluePrintException {
try {
@@ -69,11 +68,11 @@ public class ConfigModelRest {
try {
this.configModelService.deleteConfigModel(id);
} catch (Exception e) {
- throw new BluePrintException(4000, e.getMessage(), e);
+ throw new BluePrintException(2400, e.getMessage(), e);
}
}
- @GetMapping(path = "/publish/{id}")
+ @GetMapping(path = "/publish/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
ConfigModel publishConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {
try {
@@ -83,7 +82,7 @@ public class ConfigModelRest {
}
}
- @GetMapping(path = "/{id}")
+ @GetMapping(path = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
ConfigModel getConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {
try {
@@ -93,7 +92,7 @@ public class ConfigModelRest {
}
}
- @GetMapping(path = "/by-name/{name}/version/{version}")
+ @GetMapping(path = "/by-name/{name}/version/{version}", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
ConfigModel getConfigModelByNameAndVersion(@PathVariable(value = "name") String name,
@PathVariable(value = "version") String version) throws BluePrintException {
@@ -104,7 +103,7 @@ public class ConfigModelRest {
}
}
- @GetMapping(path = "/search/{tags}")
+ @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
List<ConfigModel> searchConfigModels(@PathVariable(value = "tags") String tags) throws BluePrintException {
try {
@@ -114,7 +113,7 @@ public class ConfigModelRest {
}
}
- @GetMapping(path = "/clone/{id}")
+ @GetMapping(path = "/clone/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
ConfigModel getCloneConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {
try {
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java
index 2fa64316f..f6e5c274f 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java
@@ -19,6 +19,7 @@ package org.onap.ccsdk.apps.controllerblueprints.service.rs;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
import org.onap.ccsdk.apps.controllerblueprints.service.ModelTypeService;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
+import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;
@@ -29,7 +30,7 @@ import java.util.List;
* {@inheritDoc}
*/
@RestController
-@RequestMapping("/api/v1/model-type")
+@RequestMapping(value = "/api/v1/model-type")
public class ModelTypeRest {
private ModelTypeService modelTypeService;
@@ -43,7 +44,7 @@ public class ModelTypeRest {
this.modelTypeService = modelTypeService;
}
- @GetMapping(path = "/{name}")
+ @GetMapping(path = "/{name}", produces = MediaType.APPLICATION_JSON_VALUE)
public ModelType getModelTypeByName(@PathVariable(value = "name") String name) throws BluePrintException {
try {
return modelTypeService.getModelTypeByName(name);
@@ -52,7 +53,7 @@ public class ModelTypeRest {
}
}
- @GetMapping(path = "/search/{tags}")
+ @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)
public List<ModelType> searchModelTypes(@PathVariable(value = "tags") String tags) throws BluePrintException {
try {
return modelTypeService.searchModelTypes(tags);
@@ -61,7 +62,7 @@ public class ModelTypeRest {
}
}
- @GetMapping(path = "/by-definition/{definitionType}")
+ @GetMapping(path = "/by-definition/{definitionType}", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
List<ModelType> getModelTypeByDefinitionType(@PathVariable(value = "definitionType") String definitionType) throws BluePrintException {
try {
@@ -71,7 +72,7 @@ public class ModelTypeRest {
}
}
- @PostMapping(path = "/")
+ @PostMapping(path = "/", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
ModelType saveModelType(@RequestBody ModelType modelType) throws BluePrintException {
try {
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 dfb06bba5..795738cb1 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
@@ -19,8 +19,7 @@ package org.onap.ccsdk.apps.controllerblueprints.service.rs;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
import org.onap.ccsdk.apps.controllerblueprints.service.ResourceDictionaryService;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
+import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@@ -44,7 +43,7 @@ public class ResourceDictionaryRest {
this.resourceDictionaryService = dataDictionaryService;
}
- @PostMapping(path = "/")
+ @PostMapping(path = "/", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
ResourceDictionary saveResourceDictionary(@RequestBody ResourceDictionary dataDictionary)
throws BluePrintException {
@@ -64,7 +63,7 @@ public class ResourceDictionaryRest {
}
}
- @GetMapping(path = "/{name}")
+ @GetMapping(path = "/{name}", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
ResourceDictionary getResourceDictionaryByName(@PathVariable(value = "name") String name) throws BluePrintException {
try {
@@ -74,7 +73,7 @@ public class ResourceDictionaryRest {
}
}
- @PostMapping(path = "/by-names")
+ @PostMapping(path = "/by-names", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
List<ResourceDictionary> searchResourceDictionaryByNames(@RequestBody List<String> names)
throws BluePrintException {
@@ -85,7 +84,7 @@ public class ResourceDictionaryRest {
}
}
- @GetMapping(path = "/search/{tags}")
+ @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
List<ResourceDictionary> searchResourceDictionaryByTags(@PathVariable(value = "tags") String tags) throws BluePrintException {
try {
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java
index d8ea1941b..a22285b88 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java
@@ -23,8 +23,7 @@ import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.service.ServiceTemplateService;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
+import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@@ -47,7 +46,7 @@ public class ServiceTemplateRest {
this.serviceTemplateService = serviceTemplateService;
}
- @PostMapping(path = "/enrich")
+ @PostMapping(path = "/enrich", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
ServiceTemplate enrichServiceTemplate(@RequestBody ServiceTemplate serviceTemplate) throws BluePrintException {
try {
@@ -57,7 +56,7 @@ public class ServiceTemplateRest {
}
}
- @PostMapping(path = "/validate")
+ @PostMapping(path = "/validate", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
ServiceTemplate validateServiceTemplate(@RequestBody ServiceTemplate serviceTemplate) throws BluePrintException {
try {
@@ -67,7 +66,7 @@ public class ServiceTemplateRest {
}
}
- @PostMapping(path = "/resource-assignment/auto-map")
+ @PostMapping(path = "/resource-assignment/auto-map", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
AutoMapResponse autoMap(@RequestBody List<ResourceAssignment> resourceAssignments) throws BluePrintException {
try {
@@ -77,7 +76,7 @@ public class ServiceTemplateRest {
}
}
- @PostMapping(path = "/resource-assignment/validate")
+ @PostMapping(path = "/resource-assignment/validate", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
List<ResourceAssignment> validateResourceAssignments(@RequestBody List<ResourceAssignment> resourceAssignments)
throws BluePrintException {
@@ -88,7 +87,7 @@ public class ServiceTemplateRest {
}
}
- @PostMapping(path = "/resource-assignment/generate")
+ @PostMapping(path = "/resource-assignment/generate", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
List<ResourceAssignment> generateResourceAssignments(@RequestBody ConfigModelContent templateContent)
throws BluePrintException {
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java
index afe9b426f..73d6eca99 100644
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java
@@ -24,6 +24,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.onap.ccsdk.apps.controllerblueprints.TestApplication;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.*;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,7 +52,10 @@ public class ResourceDictionaryRestTest {
@Before
public void setUp() {
-
+ SourceDeserializer.registerSource("db", SourceDb.class);
+ SourceDeserializer.registerSource("input", SourceInput.class);
+ SourceDeserializer.registerSource("mdsal", SourceMdsal.class);
+ SourceDeserializer.registerSource("default", SourceDefault.class);
}
@Test