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>
+Application VM Arguments :\r
+\r
+-Dlogging.config=etc/logback.xml\r
+-Dspring.config.location=opt/app/onap/config/\r
+-Dspring.datasource.url=jdbc:mysql://127.0.0.1:3306/sdnctl\r
+-Dspring.datasource.username=sdnctl\r
+-Dspring.datasource.password=sdnctl\r
+-Dblueprints.load.initial-data=true\r
+\r
--- /dev/null
+{\r
+ "description": " Camunda BPM File",\r
+ "version": "1.0.0",\r
+ "file_ext": [\r
+ "bpmn"\r
+ ],\r
+ "derived_from": "tosca.artifacts.Implementation"\r
+}
\ No newline at end of file
--- /dev/null
+{\r
+ "description": "Directed Graph File",\r
+ "version": "1.0.0",\r
+ "file_ext": [\r
+ "json",\r
+ "xml"\r
+ ],\r
+ "derived_from": "tosca.artifacts.Implementation"\r
+}
\ No newline at end of file
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
--- /dev/null
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints;\r
+\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
+import org.onap.ccsdk.apps.controllerblueprints.service.common.ErrorMessage;\r
+import org.springframework.http.HttpStatus;\r
+import org.springframework.http.ResponseEntity;\r
+import org.springframework.web.bind.annotation.ControllerAdvice;\r
+import org.springframework.web.bind.annotation.ExceptionHandler;\r
+import org.springframework.web.bind.annotation.RestController;\r
+import org.springframework.web.context.request.WebRequest;\r
+\r
+@ControllerAdvice\r
+@RestController\r
+public class ApplicationExceptionHandler {\r
+ @ExceptionHandler(Exception.class)\r
+ public final ResponseEntity<ErrorMessage> handleAllExceptions(Exception ex, WebRequest request) {\r
+ ErrorMessage exceptionResponse = new ErrorMessage( ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR.value(), ex.getLocalizedMessage());\r
+ return new ResponseEntity<>(exceptionResponse, HttpStatus.INTERNAL_SERVER_ERROR);\r
+ }\r
+\r
+ @ExceptionHandler(BluePrintException.class)\r
+ public final ResponseEntity<ErrorMessage> handleBlueprintException(BluePrintException ex, WebRequest request) {\r
+ ErrorMessage exceptionResponse = new ErrorMessage( ex.getMessage(), ex.getCode(), ex.getLocalizedMessage());\r
+ return new ResponseEntity<>(exceptionResponse, HttpStatus.INTERNAL_SERVER_ERROR);\r
+ }\r
+}\r
import org.springframework.context.annotation.Bean;\r
import org.springframework.context.annotation.Configuration;\r
import org.springframework.web.cors.CorsConfiguration;\r
-import org.springframework.web.cors.UrlBasedCorsConfigurationSource;\r
-import org.springframework.web.filter.CorsFilter;\r
+import org.springframework.web.cors.reactive.CorsWebFilter;\r
+import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;\r
+import java.util.Arrays;\r
\r
/**\r
* CorsConfig.java Purpose: Provide Configuration Generator CorsConfig Information\r
* @author Brinda Santh\r
* @version 1.0\r
*/\r
-//@Configuration\r
+@Configuration\r
public class CorsConfig {\r
/**\r
* This is a CORS Implementation for different Orgin GUI to access.\r
* @return CorsFilter\r
*/\r
@Bean\r
- public CorsFilter corsFilter() {\r
- UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();\r
- CorsConfiguration config = new CorsConfiguration();\r
- config.setAllowCredentials(true);\r
- config.addAllowedOrigin("*");\r
- config.addAllowedHeader("*");\r
- config.addAllowedMethod("*");\r
- source.registerCorsConfiguration("/**", config);\r
- return new CorsFilter(source);\r
+ CorsWebFilter corsWebFilter() {\r
+ CorsConfiguration corsConfig = new CorsConfiguration();\r
+ corsConfig.setAllowedOrigins(Arrays.asList("*"));\r
+ corsConfig.setMaxAge(8000L);\r
+ corsConfig.addAllowedMethod("*");\r
+\r
+ UrlBasedCorsConfigurationSource source =\r
+ new UrlBasedCorsConfigurationSource();\r
+ source.registerCorsConfiguration("/**", corsConfig);\r
+\r
+ return new CorsWebFilter(source);\r
}\r
\r
\r
\r
package org.onap.ccsdk.apps.controllerblueprints;\r
\r
+import org.junit.Assert;\r
import org.junit.Before;\r
import org.junit.Test;\r
import org.junit.runner.RunWith;\r
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;\r
import org.slf4j.Logger;\r
import org.slf4j.LoggerFactory;\r
import org.springframework.beans.factory.annotation.Autowired;\r
import org.springframework.boot.test.context.SpringBootTest;\r
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;\r
import org.springframework.boot.test.web.client.TestRestTemplate;\r
-import org.springframework.http.HttpStatus;\r
-import org.springframework.http.ResponseEntity;\r
+import org.springframework.http.*;\r
import org.springframework.test.context.junit4.SpringRunner;\r
\r
import static org.assertj.core.api.Assertions.assertThat;\r
\r
@Test\r
public void testConfigModel() {\r
- ResponseEntity<String> entity = this.restTemplate\r
- .getForEntity("/api/v1/config-model/1", String.class);\r
+ HttpHeaders headers = new HttpHeaders();\r
+ headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);\r
+ ResponseEntity<ConfigModel> entity = this.restTemplate\r
+ .exchange("/api/v1/config-model/1", HttpMethod.GET, new HttpEntity<>(headers),ConfigModel.class);\r
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);\r
+ Assert.assertNotNull("failed to get response Config model",entity.getBody());\r
+ }\r
+\r
+ @Test\r
+ public void testConfigModelFailure() {\r
+ HttpHeaders headers = new HttpHeaders();\r
+ headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);\r
+ ResponseEntity<ConfigModel> entity = this.restTemplate\r
+ .exchange("/api/v1/config-model-not-found/1", HttpMethod.GET, new HttpEntity<>(headers),ConfigModel.class);\r
+ assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);\r
+ Assert.assertNotNull("failed to get response Config model",entity.getBody());\r
}\r
}\r
# See the License for the specific language governing permissions and\r
# limitations under the License.\r
#\r
-\r
+spring.jackson.default-property-inclusion=non_null\r
#Load Blueprints\r
# blueprints.load.initial-data may be overridden by ENV variables\r
blueprints.load.initial-data=true\r
</appender>\r
\r
\r
- <logger name="org.springframework" level="info"/>\r
- <logger name="org.springframework.web" level="debug"/>\r
+ <logger name="org.springframework" level="warn"/>\r
<logger name="org.hibernate" level="info"/>\r
<logger name="org.onap.ccsdk.apps.controllerblueprints" level="info"/>\r
\r
--- /dev/null
+{\r
+ "description": " Camunda BPM File",\r
+ "version": "1.0.0",\r
+ "file_ext": [\r
+ "bpmn"\r
+ ],\r
+ "derived_from": "tosca.artifacts.Implementation"\r
+}
\ No newline at end of file
--- /dev/null
+{\r
+ "description": "Directed Graph File",\r
+ "version": "1.0.0",\r
+ "file_ext": [\r
+ "json",\r
+ "xml"\r
+ ],\r
+ "derived_from": "tosca.artifacts.Implementation"\r
+}
\ No newline at end of file
\r
const val CAPABILITY_PROPERTY_MAPPING = "mapping"\r
\r
- const val SOURCE_INPUT = "input"\r
- const val SOURCE_DEFAULT = "default"\r
- const val SOURCE_MDSAL = "mdsal"\r
- const val SOURCE_DB = "db"\r
-\r
const val PROPERTY_RECIPE_NAMES = "action-names"\r
\r
}\r
var id: String? = null\r
var description: String? = null\r
var required: Boolean? = null\r
- var type: String? = null\r
+ lateinit var type: String\r
@get:JsonProperty("default")\r
var defaultValue: Any? = null\r
var status: String? = null\r
}\r
\r
class Implementation {\r
- var primary: String? = null\r
+ lateinit var primary: String\r
var dependencies: MutableList<String>? = null\r
}\r
\r
var description: String? = null\r
@get:JsonProperty("event_type")\r
lateinit var eventType: String\r
+ @get:JsonProperty("target_filter")\r
+ var targetFilter: EventFilterDefinition? = null\r
+ var condition: ConditionClause? = null\r
+ var constraint: ConditionClause? = null\r
+ var method: String? = null\r
lateinit var action: String\r
}\r
\r
return jacksonObjectMapper().readValue(content, valueType)\r
}\r
\r
+ @JvmStatic\r
+ fun <T> readValueFromFile(fileName: String, valueType: Class<T>): T? {\r
+ val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())\r
+ ?: throw BluePrintException(format("Failed to read json file : {}", fileName))\r
+ return readValue(content, valueType)\r
+ }\r
+\r
@JvmStatic\r
fun jsonNodeFromObject(from: kotlin.Any): JsonNode = jacksonObjectMapper().convertValue(from, JsonNode::class.java)\r
\r
--- /dev/null
+{\r
+ "name": "bundle-id",\r
+ "description": "name of the ",\r
+ "resource-type": "ONAP",\r
+ "resource-path": "vnf/bundle-id",\r
+ "updated-by": "brindasanth@onap.com",\r
+ "data-type": "String",\r
+ "tags": "bundle-id, brindasanth@onap.com",\r
+ "source": {\r
+ "db": {\r
+ "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name",\r
+ "input-key-mapping": {\r
+ "profile_name": "profile_name"\r
+ },\r
+ "output-key-mapping": {\r
+ "db-country": "country",\r
+ "db-state": "state"\r
+ }\r
+ }\r
+ },\r
+ "decryption-rules": [\r
+ {\r
+ "sources": [\r
+ "input"\r
+ ],\r
+ "path": "/.",\r
+ "rule": "LOCAL-Decrypt",\r
+ "decrypt-type": "AES128"\r
+ }\r
+ ]\r
+}
\ No newline at end of file
--- /dev/null
+{\r
+ "tags": "v4-ip-type, tosca.datatypes.Root, data_type, brindasanth@onap.com",\r
+ "name": "v4-ip-type",\r
+ "description": "To be provided",\r
+ "updated-by": "brindasanth@onap.com",\r
+ "resource-type": "ONAP",\r
+ "resource-path": "vnf/v4-ip-type",\r
+ "data-type": "string",\r
+ "source": {\r
+ "default": {\r
+ \r
+ }\r
+ }\r
+}
\ No newline at end of file
"description": "To be provided",\r
"valid-values": null,\r
"sample-value": null,\r
- "updated-by": "ym9479@onap.com",\r
+ "updated-by": "brindasanth@onap.com",\r
"tags": null,\r
"default": null,\r
"data-type": "string",\r
--- /dev/null
+{\r
+ "tags": "oam-local-ipv4-address, tosca.datatypes.Root, data_type, st1848@att.com",\r
+ "name": "oam-local-ipv4-address",\r
+ "description": "based on service-instance-id,network-role,v4-ip-type and vm-type get the ipv4-gateway-prefix from the SDN-GC mdsal",\r
+ "updated-by": "st1848@att.com",\r
+ "resource-type": "ATT",\r
+ "resource-path": "vnf/oam-local-ipv4-address",\r
+ "data-type": "string",\r
+ "source": {\r
+ "mdsal": {\r
+ "base": "sdnc-gc",\r
+ "type": "JSON",\r
+ "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",\r
+ "path": "/v4-assigned-ip-list/0/v4-ip-prefix",\r
+ "input-key-mapping": {\r
+ "service-instance-id": "service-instance-id",\r
+ "network-role": "network-role",\r
+ "v4-ip-type": "v4-ip-type",\r
+ "vm-type": "vm-type"\r
+ },\r
+ "output-key-mapping": {\r
+ "oam-local-ipv4-address": "v4-ip-prefix"\r
+ }\r
+ }\r
+ },\r
+ "candidate-dependency": {\r
+ "mdsal": {\r
+ "names": [\r
+ "service-instance-id",\r
+ "network-role",\r
+ "v4-ip-type",\r
+ "vm-type"\r
+ ]\r
+ }\r
+ }\r
+}
\ No newline at end of file
* @version 1.0\r
*/\r
public class ResourceAssignment {\r
-\r
+ @JsonProperty(value = "name", required = true)\r
private String name;\r
\r
- @JsonProperty("property")\r
+ @JsonProperty(value = "property", required = true)\r
private PropertyDefinition property;\r
\r
@JsonProperty("input-param")\r
private String message;\r
\r
@JsonProperty("updated-date")\r
- @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy hh:mm:ss")\r
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")\r
private Date updatedDate;\r
\r
@JsonProperty("updated-by")\r
--- /dev/null
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict;\r
+\r
+public class ResourceDictionaryConstants {\r
+ public static final String SOURCE_INPUT= "input";\r
+ public static final String SOURCE_DEFAULT = "default";\r
+ public static final String SOURCE_DB = "db";\r
+ public static final String SOURCE_MDSAL = "mdsal";\r
+}\r
package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data;\r
\r
import com.fasterxml.jackson.annotation.JsonProperty;\r
-import com.fasterxml.jackson.databind.JsonNode;\r
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;\r
\r
import java.util.List;\r
import java.util.Map;\r
public class DictionaryDefinition {\r
@JsonProperty(value = "name", required = true)\r
private String name;\r
+\r
@JsonProperty(value = "description")\r
private String description;\r
\r
private String sampleValue;\r
\r
private String tags;\r
+\r
@JsonProperty(value = "updated-by")\r
private String updatedBy;\r
\r
private Object defaultValue;\r
\r
@JsonProperty(value = "source", required = true)\r
- private Map<String, JsonNode> source;\r
+ @JsonDeserialize(using = SourceDeserializer.class, keyAs = String.class, contentAs = ResourceSource.class)\r
+ private Map<String, ResourceSource> source;\r
\r
@JsonProperty("candidate-dependency")\r
private Map<String, DictionaryDependency> dependency;\r
this.defaultValue = defaultValue;\r
}\r
\r
- public Map<String, JsonNode> getSource() {\r
+ public Map<String, ResourceSource> getSource() {\r
return source;\r
}\r
\r
- public void setSource(Map<String, JsonNode> source) {\r
+ public void setSource(Map<String, ResourceSource> source) {\r
this.source = source;\r
}\r
\r
--- /dev/null
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data;\r
+\r
+import java.io.Serializable;\r
+\r
+public interface ResourceSource extends Serializable {\r
+}\r
* SourceDb\r
* @author Brinda Santh\r
*/\r
-public class SourceDb {\r
+public class SourceDb implements ResourceSource{\r
@JsonProperty(value = "base", required = true)\r
private String base;\r
@JsonProperty(value = "type", required = true)\r
* SourceDefault\r
* @author Brinda Santh\r
*/\r
-public class SourceDefault {\r
+public class SourceDefault implements ResourceSource {\r
\r
private String key;\r
\r
--- /dev/null
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data;\r
+\r
+import com.fasterxml.jackson.core.JsonParser;\r
+import com.fasterxml.jackson.core.JsonProcessingException;\r
+import com.fasterxml.jackson.databind.*;\r
+import com.fasterxml.jackson.databind.node.ObjectNode;\r
+import com.google.common.base.Preconditions;\r
+import org.apache.commons.lang3.StringUtils;\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+import java.io.IOException;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+public class SourceDeserializer extends JsonDeserializer<Map<String, ResourceSource>> {\r
+\r
+ private static final Logger log = LoggerFactory.getLogger(SourceDeserializer.class);\r
+\r
+ private Class<?> keyAs;\r
+\r
+ private Class<?> contentAs;\r
+\r
+ private static Map<String, Class<? extends ResourceSource>> registry = new HashMap<String, Class<? extends ResourceSource>>();\r
+\r
+ public static void registerSource(String uniqueAttribute, Class<? extends ResourceSource> sourceClass) {\r
+ registry.put(uniqueAttribute, sourceClass);\r
+ }\r
+\r
+ @Override\r
+ public Map<String, ResourceSource> deserialize(JsonParser p, DeserializationContext ctxt)\r
+ throws IOException, JsonProcessingException {\r
+\r
+ ObjectMapper mapper = (ObjectMapper) p.getCodec();\r
+ ObjectNode root = (ObjectNode) mapper.readTree(p);\r
+ Map<String, ResourceSource> sources = new HashMap();\r
+ root.fields().forEachRemaining((node) -> {\r
+ String key = node.getKey();\r
+ JsonNode valueNode = node.getValue();\r
+ Preconditions.checkArgument(StringUtils.isNotBlank(key), "missing source key");\r
+ Preconditions.checkArgument(registry.containsKey(key), key +" source not registered");\r
+ if (StringUtils.isNotBlank(key) && registry.containsKey(key)) {\r
+ Class<? extends ResourceSource> sourceClass = registry.get(key);\r
+ ResourceSource resourceSource = JacksonUtils.readValue(valueNode.toString(), sourceClass);\r
+ sources.put(key, resourceSource);\r
+ }\r
+ });\r
+ return sources;\r
+ }\r
+}\r
* SourceInput\r
* @author Brinda Santh\r
*/\r
-public class SourceInput {\r
+public class SourceInput implements ResourceSource {\r
\r
private String key;\r
\r
}\r
\r
\r
-\r
}\r
\r
import java.util.Map;\r
\r
-public class SourceMdsal {\r
+public class SourceMdsal implements ResourceSource {\r
\r
@JsonProperty(value = "base", required = true)\r
private String base;\r
}\r
\r
\r
-\r
}\r
\r
package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils;\r
\r
-import com.fasterxml.jackson.databind.JsonNode;\r
import org.apache.commons.collections.MapUtils;\r
import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;\r
import org.onap.ccsdk.apps.controllerblueprints.core.data.EntrySchema;\r
import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition;\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants;\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DictionaryDefinition;\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DictionaryDependency;\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.ResourceSource;\r
import org.slf4j.Logger;\r
import org.slf4j.LoggerFactory;\r
\r
// Overwrite the Property Definitions from Dictionary\r
setProperty(resourceAssignment, dictionaryDefinition);\r
\r
- Map<String, JsonNode> dictionarySource = dictionaryDefinition.getSource();\r
+ Map<String, ResourceSource> dictionarySource = dictionaryDefinition.getSource();\r
Map<String, DictionaryDependency> dictionaryDependencyMap = dictionaryDefinition.getDependency();\r
\r
if (MapUtils.isNotEmpty(dictionarySource)) {\r
}\r
}\r
} else {\r
- resourceAssignment.setDictionarySource(ConfigModelConstant.SOURCE_INPUT);\r
+ resourceAssignment.setDictionarySource(ResourceDictionaryConstants.SOURCE_INPUT);\r
}\r
log.info("auto map resourceAssignment : {}", resourceAssignment);\r
}\r
}\r
}\r
\r
- private static String findFirstSource(Map<String, JsonNode> dictionarySource) {\r
+ private static String findFirstSource(Map<String, ResourceSource> dictionarySource) {\r
String source = null;\r
if (MapUtils.isNotEmpty(dictionarySource)) {\r
source = dictionarySource.keySet().stream().findFirst().get();\r
--- /dev/null
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.util;\r
+\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants;\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.*;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+public class DictionaryDefinitionTest {\r
+ private Logger log = LoggerFactory.getLogger(DictionaryDefinitionTest.class);\r
+ String basePath = "load/resource_dictionary";\r
+\r
+ @Before\r
+ public void setup(){\r
+ SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_DB, SourceDb.class);\r
+ SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_INPUT, SourceInput.class);\r
+ SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_MDSAL, SourceMdsal.class);\r
+ SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_DEFAULT,SourceDefault.class);\r
+ }\r
+\r
+ @Test\r
+ public void testDictionaryDefinitionInputSource(){\r
+\r
+ String fileName = basePath + "/input-source.json";\r
+ DictionaryDefinition dictionaryDefinition = JacksonUtils.readValueFromFile(fileName, DictionaryDefinition.class);\r
+ Assert.assertNotNull("Failed to populate dictionaryDefinition for input type", dictionaryDefinition);\r
+ }\r
+\r
+ @Test\r
+ public void testDictionaryDefinitionDefaultSource(){\r
+\r
+ String fileName = basePath + "/default-source.json";\r
+ DictionaryDefinition dictionaryDefinition = JacksonUtils.readValueFromFile(fileName, DictionaryDefinition.class);\r
+ Assert.assertNotNull("Failed to populate dictionaryDefinition for default type", dictionaryDefinition);\r
+ }\r
+\r
+ @Test\r
+ public void testDictionaryDefinitionDBSource(){\r
+\r
+ String fileName = basePath + "/db-source.json";\r
+ DictionaryDefinition dictionaryDefinition = JacksonUtils.readValueFromFile(fileName, DictionaryDefinition.class);\r
+ Assert.assertNotNull("Failed to populate dictionaryDefinition for db type", dictionaryDefinition);\r
+ }\r
+\r
+ @Test\r
+ public void testDictionaryDefinitionMDSALSource(){\r
+ String fileName = basePath + "/mdsal-source.json";\r
+ DictionaryDefinition dictionaryDefinition = JacksonUtils.readValueFromFile(fileName, DictionaryDefinition.class);\r
+ Assert.assertNotNull("Failed to populate dictionaryDefinition for mdsal type", dictionaryDefinition);\r
+ }\r
+}\r
package org.onap.ccsdk.apps.controllerblueprints.resource.dict.util;\r
\r
\r
-import com.fasterxml.jackson.databind.JsonNode;\r
import org.junit.Assert;\r
import org.junit.Test;\r
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants;\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.*;\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryUtils;\r
import org.slf4j.Logger;\r
DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();\r
dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);\r
\r
- Map<String, JsonNode> source = new HashMap<>();\r
+ Map<String, ResourceSource> source = new HashMap<>();\r
SourceInput sourceInput = new SourceInput();\r
- source.put(ConfigModelConstant.SOURCE_INPUT, JacksonUtils.jsonNodeFromObject(sourceInput));\r
+ source.put(ResourceDictionaryConstants.SOURCE_INPUT, sourceInput);\r
dictionaryDefinition.setSource(source);\r
\r
ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition);\r
DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();\r
dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);\r
\r
- Map<String, JsonNode> source = new HashMap<>();\r
+ Map<String, ResourceSource> source = new HashMap<>();\r
SourceDb sourceDb = new SourceDb();\r
- source.put(ConfigModelConstant.SOURCE_DB, JacksonUtils.jsonNodeFromObject(sourceDb));\r
+ sourceDb.setBase("sdnc_connection");\r
+ source.put(ResourceDictionaryConstants.SOURCE_DB, sourceDb);\r
dictionaryDefinition.setSource(source);\r
\r
Map<String, DictionaryDependency> dependency = new HashMap<>();\r
DictionaryDependency dependencyDb = new DictionaryDependency();\r
dependencyDb.setNames(Arrays.asList("vnf-id", "vnf-name"));\r
- dependency.put(ConfigModelConstant.SOURCE_DB, dependencyDb);\r
+ dependency.put(ResourceDictionaryConstants.SOURCE_DB, dependencyDb);\r
dictionaryDefinition.setDependency(dependency);\r
\r
DecryptionRule decryptionRule = new DecryptionRule();\r
DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();\r
dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);\r
\r
- Map<String, JsonNode> source = new HashMap<>();\r
+ Map<String, ResourceSource> source = new HashMap<>();\r
SourceDefault sourceDefault = new SourceDefault();\r
- source.put(ConfigModelConstant.SOURCE_DEFAULT, JacksonUtils.jsonNodeFromObject(sourceDefault));\r
+ source.put(ResourceDictionaryConstants.SOURCE_DEFAULT, sourceDefault);\r
dictionaryDefinition.setSource(source);\r
\r
Map<String, DictionaryDependency> dependency = new HashMap<>();\r
DictionaryDependency dependencyDefault = new DictionaryDependency();\r
dependencyDefault.setNames(Arrays.asList(new String[]{"vnf-id", "vnf-name"}));\r
- dependency.put(ConfigModelConstant.SOURCE_DEFAULT, dependencyDefault);\r
+ dependency.put(ResourceDictionaryConstants.SOURCE_DEFAULT, dependencyDefault);\r
dictionaryDefinition.setDependency(dependency);\r
\r
ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition);\r
DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();\r
dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);\r
\r
- Map<String, JsonNode> source = new HashMap<>();\r
+ Map<String, ResourceSource> source = new HashMap<>();\r
SourceMdsal sourceMdsal = new SourceMdsal();\r
- source.put(ConfigModelConstant.SOURCE_MDSAL, JacksonUtils.jsonNodeFromObject(sourceMdsal));\r
+ source.put(ResourceDictionaryConstants.SOURCE_MDSAL,sourceMdsal);\r
dictionaryDefinition.setSource(source);\r
\r
Map<String, DictionaryDependency> dependency = new HashMap<>();\r
DictionaryDependency dependencyMdsal = new DictionaryDependency();\r
dependencyMdsal.setNames(Arrays.asList(new String[]{"vnf-id", "vnf-name"}));\r
- dependency.put(ConfigModelConstant.SOURCE_MDSAL, dependencyMdsal);\r
+ dependency.put(ResourceDictionaryConstants.SOURCE_MDSAL, dependencyMdsal);\r
dictionaryDefinition.setDependency(dependency);\r
\r
ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition);\r
"description": "name of the ",\r
"resource-type": "ONAP",\r
"resource-path": "vnf/bundle-id",\r
- "updated-by": "ym9479@onap.com",\r
+ "updated-by": "brindasanth@onap.com",\r
"data-type": "String",\r
- "tags": "bundle-id, ym9479@onap.com",\r
+ "tags": "bundle-id, brindasanth@onap.com",\r
"source": {\r
"db": {\r
- "path": "$key-value",\r
+ "query": "SELECT bundle-id FROM DEVICE_PROFILE WHERE profile_name = :profile_name",\r
"input-key-mapping": {\r
- "key-value": "$resource-group-key"\r
+ "profile_name": "profile_name"\r
},\r
"output-key-mapping": {\r
- "bundle-id": "bundle-id"\r
+ "db-country": "country",\r
+ "db-state": "state"\r
}\r
- },\r
- "input": {\r
}\r
},\r
"decryption-rules": [\r
--- /dev/null
+{\r
+ "name": "action-name",\r
+ "resource-path": "action-name",\r
+ "resource-type": "ONAP",\r
+ "description": "To be provided",\r
+ "valid-values": null,\r
+ "sample-value": null,\r
+ "updated-by": "brindasanth@onap.com",\r
+ "tags": null,\r
+ "default": null,\r
+ "data-type": "string",\r
+ "source": {\r
+ "input": {\r
+ "key": "action-name"\r
+ }\r
+ }\r
+}
\ No newline at end of file
{\r
- "tags": "v4-ip-type, tosca.datatypes.Root, data_type, ym9479@onap.com",\r
+ "tags": "v4-ip-type, tosca.datatypes.Root, data_type, brindasanth@onap.com",\r
"name": "v4-ip-type",\r
"description": "To be provided",\r
- "updated-by": "ym9479@onap.com",\r
+ "updated-by": "brindasanth@onap.com",\r
"resource-type": "ONAP",\r
"resource-path": "vnf/v4-ip-type",\r
"data-type": "string",\r
--- /dev/null
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.service;\r
+\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants;\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.*;\r
+import org.springframework.stereotype.Component;\r
+\r
+import javax.annotation.PostConstruct;\r
+\r
+@Component\r
+public class ApplicationRegistrationService {\r
+\r
+ @PostConstruct\r
+ public void register(){\r
+ registerDictionarySources();\r
+ }\r
+\r
+ public void registerDictionarySources(){\r
+ SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_DB, SourceDb.class);\r
+ SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_INPUT, SourceInput.class);\r
+ SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_MDSAL, SourceMdsal.class);\r
+ SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_DEFAULT,SourceDefault.class);\r
+ }\r
+}\r
\r
package org.onap.ccsdk.apps.controllerblueprints.service.common;\r
\r
+import com.fasterxml.jackson.annotation.JsonFormat;\r
import com.fasterxml.jackson.annotation.JsonInclude;\r
import com.fasterxml.jackson.annotation.JsonInclude.Include;\r
\r
import java.io.Serializable;\r
+import java.util.Date;\r
\r
@JsonInclude(Include.NON_NULL)\r
public class ErrorMessage implements Serializable {\r
- private Integer httpStatus;\r
private String message;\r
private Integer code;\r
- private String developerMessage;\r
+ private String debugMessage;\r
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")\r
+ private Date timestamp = new Date();\r
\r
- public Integer getHttpStatus() {\r
- return httpStatus;\r
- }\r
-\r
- public void setHttpStatus(Integer httpStatus) {\r
- this.httpStatus = httpStatus;\r
+ public ErrorMessage(String message, Integer code, String debugMessage){\r
+ this.message = message;\r
+ this.code = code;\r
+ this.debugMessage = debugMessage;\r
}\r
\r
public String getMessage() {\r
this.code = code;\r
}\r
\r
- public String getDeveloperMessage() {\r
- return developerMessage;\r
+ public String getDebugMessage() {\r
+ return debugMessage;\r
}\r
\r
- public void setDeveloperMessage(String developerMessage) {\r
- this.developerMessage = developerMessage;\r
+ public void setDebugMessage(String developerMessage) {\r
+ this.debugMessage = developerMessage;\r
}\r
\r
+ public Date getTimestamp() {\r
+ return timestamp;\r
+ }\r
+\r
+ public void setTimestamp(Date timestamp) {\r
+ this.timestamp = timestamp;\r
+ }\r
}
\ No newline at end of file
\r
import com.fasterxml.jackson.annotation.JsonFormat;\r
import com.fasterxml.jackson.annotation.JsonManagedReference;\r
+import io.swagger.annotations.ApiModelProperty;\r
import org.hibernate.annotations.Proxy;\r
import org.springframework.data.annotation.LastModifiedDate;\r
import org.springframework.data.jpa.domain.support.AuditingEntityListener;\r
\r
@NotNull\r
@Column(name = "artifact_version")\r
+ @ApiModelProperty(required=true)\r
private String artifactVersion;\r
\r
@Lob\r
@Column(name = "internal_version")\r
private Integer internalVersion;\r
\r
- @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MM/dd/yyyy KK:mm:ss a Z")\r
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")\r
@LastModifiedDate\r
@Temporal(TemporalType.TIMESTAMP)\r
@Column(name = "creation_date")\r
\r
@NotNull\r
@Column(name = "artifact_name")\r
+ @ApiModelProperty(required=true)\r
private String artifactName;\r
\r
@NotNull\r
@Column(name = "published")\r
+ @ApiModelProperty(required=true)\r
private String published;\r
\r
@NotNull\r
@Column(name = "updated_by")\r
+ @ApiModelProperty(required=true)\r
private String updatedBy;\r
\r
@NotNull\r
@Lob\r
@Column(name = "tags")\r
+ @ApiModelProperty(required=true)\r
private String tags;\r
\r
\r
\r
import com.fasterxml.jackson.annotation.JsonBackReference;\r
import com.fasterxml.jackson.annotation.JsonFormat;\r
+import io.swagger.annotations.ApiModelProperty;\r
import org.springframework.data.annotation.LastModifiedDate;\r
import org.springframework.data.jpa.domain.support.AuditingEntityListener;\r
\r
\r
@NotNull\r
@Column(name = "name")\r
+ @ApiModelProperty(required=true)\r
private String name;\r
\r
@NotNull\r
@Column(name = "content_type")\r
+ @ApiModelProperty(required=true)\r
private String contentType;\r
\r
\r
@NotNull\r
@Lob\r
@Column(name = "content")\r
+ @ApiModelProperty(required=true)\r
private String content;\r
\r
\r
- @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MM/dd/yyyy KK:mm:ss a Z")\r
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")\r
@LastModifiedDate\r
@Temporal(TemporalType.TIMESTAMP)\r
@Column(name = "updated_date")\r
\r
package org.onap.ccsdk.apps.controllerblueprints.service.domain;\r
\r
+import com.fasterxml.jackson.annotation.JsonFormat;\r
+import io.swagger.annotations.ApiModelProperty;\r
import org.springframework.data.annotation.LastModifiedDate;\r
import org.springframework.data.jpa.domain.support.AuditingEntityListener;\r
\r
@Id\r
@NotNull\r
@Column(name = "model_name", nullable = false)\r
+ @ApiModelProperty(required=true)\r
private String modelName;\r
\r
@NotNull\r
@Column(name = "derived_from")\r
+ @ApiModelProperty(required=true)\r
private String derivedFrom;\r
\r
@NotNull\r
@Column(name = "definition_type")\r
+ @ApiModelProperty(required=true)\r
private String definitionType;\r
\r
@NotNull\r
@Lob\r
@Column(name = "definition")\r
+ @ApiModelProperty(required=true)\r
private String definition;\r
\r
@NotNull\r
@Lob\r
@Column(name = "description")\r
+ @ApiModelProperty(required=true)\r
private String description;\r
\r
@NotNull\r
@Column(name = "version")\r
+ @ApiModelProperty(required=true)\r
private String version;\r
\r
@NotNull\r
@Lob\r
@Column(name = "tags")\r
+ @ApiModelProperty(required=true)\r
private String tags;\r
\r
- // @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MM/dd/yyyy KK:mm:ss a Z")\r
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")\r
@LastModifiedDate\r
@Temporal(TemporalType.TIMESTAMP)\r
@Column(name = "creation_date")\r
\r
@NotNull\r
@Column(name = "updated_by")\r
+ @ApiModelProperty(required=true)\r
private String updatedBy;\r
\r
@Override\r
\r
package org.onap.ccsdk.apps.controllerblueprints.service.domain;\r
\r
+import com.fasterxml.jackson.annotation.JsonFormat;\r
+import io.swagger.annotations.ApiModelProperty;\r
import org.springframework.data.annotation.LastModifiedDate;\r
import org.springframework.data.jpa.domain.support.AuditingEntityListener;\r
\r
@Id\r
@NotNull\r
@Column(name = "name")\r
+ @ApiModelProperty(required=true)\r
private String name;\r
\r
@NotNull\r
@Column(name = "resource_path")\r
+ @ApiModelProperty(required=true)\r
private String resourcePath;\r
\r
@NotNull\r
@Column(name = "resource_type")\r
+ @ApiModelProperty(required=true)\r
private String resourceType;\r
\r
@NotNull\r
@Column(name = "data_type")\r
+ @ApiModelProperty(required=true)\r
private String dataType;\r
\r
@Column(name = "entry_schema")\r
@NotNull\r
@Lob\r
@Column(name = "definition")\r
+ @ApiModelProperty(required=true)\r
private String definition;\r
\r
@NotNull\r
@Lob\r
@Column(name = "description")\r
+ @ApiModelProperty(required=true)\r
private String description;\r
\r
@NotNull\r
@Lob\r
@Column(name = "tags")\r
+ @ApiModelProperty(required=true)\r
private String tags;\r
\r
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")\r
@LastModifiedDate\r
@Temporal(TemporalType.TIMESTAMP)\r
@Column(name = "creation_date")\r
\r
@NotNull\r
@Column(name = "updated_by")\r
+ @ApiModelProperty(required=true)\r
private String updatedBy;\r
\r
@Override\r
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
import org.onap.ccsdk.apps.controllerblueprints.service.ConfigModelService;\r
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;\r
-import org.springframework.stereotype.Component;\r
-import org.springframework.stereotype.Service;\r
+import org.springframework.http.MediaType;\r
import org.springframework.web.bind.annotation.*;\r
\r
import java.util.List;\r
* {@inheritDoc}\r
*/\r
@RestController\r
-@RequestMapping("/api/v1/config-model")\r
+@RequestMapping(value = "/api/v1/config-model")\r
public class ConfigModelRest {\r
\r
private ConfigModelService configModelService;\r
\r
}\r
\r
- @GetMapping(path = "/initial/{name}")\r
+ @GetMapping(path = "/initial/{name}", produces = MediaType.APPLICATION_JSON_VALUE)\r
public @ResponseBody\r
ConfigModel getInitialConfigModel(@PathVariable(value = "name") String name) throws BluePrintException {\r
try {\r
}\r
}\r
\r
- @PostMapping(path = "/")\r
+ @PostMapping(path = "/", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
public @ResponseBody\r
ConfigModel saveConfigModel(@RequestBody ConfigModel configModel) throws BluePrintException {\r
try {\r
try {\r
this.configModelService.deleteConfigModel(id);\r
} catch (Exception e) {\r
- throw new BluePrintException(4000, e.getMessage(), e);\r
+ throw new BluePrintException(2400, e.getMessage(), e);\r
}\r
}\r
\r
- @GetMapping(path = "/publish/{id}")\r
+ @GetMapping(path = "/publish/{id}", produces = MediaType.APPLICATION_JSON_VALUE)\r
public @ResponseBody\r
ConfigModel publishConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {\r
try {\r
}\r
}\r
\r
- @GetMapping(path = "/{id}")\r
+ @GetMapping(path = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)\r
public @ResponseBody\r
ConfigModel getConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {\r
try {\r
}\r
}\r
\r
- @GetMapping(path = "/by-name/{name}/version/{version}")\r
+ @GetMapping(path = "/by-name/{name}/version/{version}", produces = MediaType.APPLICATION_JSON_VALUE)\r
public @ResponseBody\r
ConfigModel getConfigModelByNameAndVersion(@PathVariable(value = "name") String name,\r
@PathVariable(value = "version") String version) throws BluePrintException {\r
}\r
}\r
\r
- @GetMapping(path = "/search/{tags}")\r
+ @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)\r
public @ResponseBody\r
List<ConfigModel> searchConfigModels(@PathVariable(value = "tags") String tags) throws BluePrintException {\r
try {\r
}\r
}\r
\r
- @GetMapping(path = "/clone/{id}")\r
+ @GetMapping(path = "/clone/{id}", produces = MediaType.APPLICATION_JSON_VALUE)\r
public @ResponseBody\r
ConfigModel getCloneConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {\r
try {\r
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
import org.onap.ccsdk.apps.controllerblueprints.service.ModelTypeService;\r
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;\r
+import org.springframework.http.MediaType;\r
import org.springframework.stereotype.Component;\r
import org.springframework.stereotype.Service;\r
import org.springframework.web.bind.annotation.*;\r
* {@inheritDoc}\r
*/\r
@RestController\r
-@RequestMapping("/api/v1/model-type")\r
+@RequestMapping(value = "/api/v1/model-type")\r
public class ModelTypeRest {\r
\r
private ModelTypeService modelTypeService;\r
this.modelTypeService = modelTypeService;\r
}\r
\r
- @GetMapping(path = "/{name}")\r
+ @GetMapping(path = "/{name}", produces = MediaType.APPLICATION_JSON_VALUE)\r
public ModelType getModelTypeByName(@PathVariable(value = "name") String name) throws BluePrintException {\r
try {\r
return modelTypeService.getModelTypeByName(name);\r
}\r
}\r
\r
- @GetMapping(path = "/search/{tags}")\r
+ @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)\r
public List<ModelType> searchModelTypes(@PathVariable(value = "tags") String tags) throws BluePrintException {\r
try {\r
return modelTypeService.searchModelTypes(tags);\r
}\r
}\r
\r
- @GetMapping(path = "/by-definition/{definitionType}")\r
+ @GetMapping(path = "/by-definition/{definitionType}", produces = MediaType.APPLICATION_JSON_VALUE)\r
public @ResponseBody\r
List<ModelType> getModelTypeByDefinitionType(@PathVariable(value = "definitionType") String definitionType) throws BluePrintException {\r
try {\r
}\r
}\r
\r
- @PostMapping(path = "/")\r
+ @PostMapping(path = "/", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
public @ResponseBody\r
ModelType saveModelType(@RequestBody ModelType modelType) throws BluePrintException {\r
try {\r
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
import org.onap.ccsdk.apps.controllerblueprints.service.ResourceDictionaryService;\r
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;\r
-import org.springframework.stereotype.Component;\r
-import org.springframework.stereotype.Service;\r
+import org.springframework.http.MediaType;\r
import org.springframework.web.bind.annotation.*;\r
\r
import java.util.List;\r
this.resourceDictionaryService = dataDictionaryService;\r
}\r
\r
- @PostMapping(path = "/")\r
+ @PostMapping(path = "/", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
public @ResponseBody\r
ResourceDictionary saveResourceDictionary(@RequestBody ResourceDictionary dataDictionary)\r
throws BluePrintException {\r
}\r
}\r
\r
- @GetMapping(path = "/{name}")\r
+ @GetMapping(path = "/{name}", produces = MediaType.APPLICATION_JSON_VALUE)\r
public @ResponseBody\r
ResourceDictionary getResourceDictionaryByName(@PathVariable(value = "name") String name) throws BluePrintException {\r
try {\r
}\r
}\r
\r
- @PostMapping(path = "/by-names")\r
+ @PostMapping(path = "/by-names", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
public @ResponseBody\r
List<ResourceDictionary> searchResourceDictionaryByNames(@RequestBody List<String> names)\r
throws BluePrintException {\r
}\r
}\r
\r
- @GetMapping(path = "/search/{tags}")\r
+ @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)\r
public @ResponseBody\r
List<ResourceDictionary> searchResourceDictionaryByTags(@PathVariable(value = "tags") String tags) throws BluePrintException {\r
try {\r
import org.onap.ccsdk.apps.controllerblueprints.service.ServiceTemplateService;\r
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;\r
import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;\r
-import org.springframework.stereotype.Component;\r
-import org.springframework.stereotype.Service;\r
+import org.springframework.http.MediaType;\r
import org.springframework.web.bind.annotation.*;\r
\r
import java.util.List;\r
this.serviceTemplateService = serviceTemplateService;\r
}\r
\r
- @PostMapping(path = "/enrich")\r
+ @PostMapping(path = "/enrich", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
public @ResponseBody\r
ServiceTemplate enrichServiceTemplate(@RequestBody ServiceTemplate serviceTemplate) throws BluePrintException {\r
try {\r
}\r
}\r
\r
- @PostMapping(path = "/validate")\r
+ @PostMapping(path = "/validate", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
public @ResponseBody\r
ServiceTemplate validateServiceTemplate(@RequestBody ServiceTemplate serviceTemplate) throws BluePrintException {\r
try {\r
}\r
}\r
\r
- @PostMapping(path = "/resource-assignment/auto-map")\r
+ @PostMapping(path = "/resource-assignment/auto-map", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
public @ResponseBody\r
AutoMapResponse autoMap(@RequestBody List<ResourceAssignment> resourceAssignments) throws BluePrintException {\r
try {\r
}\r
}\r
\r
- @PostMapping(path = "/resource-assignment/validate")\r
+ @PostMapping(path = "/resource-assignment/validate", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
public @ResponseBody\r
List<ResourceAssignment> validateResourceAssignments(@RequestBody List<ResourceAssignment> resourceAssignments)\r
throws BluePrintException {\r
}\r
}\r
\r
- @PostMapping(path = "/resource-assignment/generate")\r
+ @PostMapping(path = "/resource-assignment/generate", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
public @ResponseBody\r
List<ResourceAssignment> generateResourceAssignments(@RequestBody ConfigModelContent templateContent)\r
throws BluePrintException {\r
import org.junit.runner.RunWith;\r
import org.junit.runners.MethodSorters;\r
import org.onap.ccsdk.apps.controllerblueprints.TestApplication;\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.*;\r
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;\r
import org.slf4j.Logger;\r
import org.slf4j.LoggerFactory;\r
\r
@Before\r
public void setUp() {\r
-\r
+ SourceDeserializer.registerSource("db", SourceDb.class);\r
+ SourceDeserializer.registerSource("input", SourceInput.class);\r
+ SourceDeserializer.registerSource("mdsal", SourceMdsal.class);\r
+ SourceDeserializer.registerSource("default", SourceDefault.class);\r
}\r
\r
@Test\r