Add Generic Rest Configuration
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Thu, 6 Dec 2018 15:30:59 +0000 (10:30 -0500)
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Thu, 6 Dec 2018 15:30:59 +0000 (10:30 -0500)
Change-Id: I3865eac84765ac2cbc5dd0db7a1ed0065bcaa7c5
Issue-ID: CCSDK-699
Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
19 files changed:
ms/blueprintsprocessor/application/src/main/resources/application.properties
ms/blueprintsprocessor/application/src/test/resources/application.properties
ms/blueprintsprocessor/modules/commons/core/pom.xml
ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt
ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/db-lib/pom.xml
ms/blueprintsprocessor/modules/commons/pom.xml
ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml
ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/rest-lib/src/main/resources/application.properties [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestPropertyPlaceHolderConfigurationTest.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/rest-lib/src/test/resources/logback-test.xml [new file with mode: 0644]
ms/blueprintsprocessor/modules/services/execution-service/pom.xml

index f30a7f1..cb8ca92 100644 (file)
@@ -1,5 +1,5 @@
 #\r
-#  Copyright © 2017-2018 AT&T Intellectual Property.\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
@@ -12,4 +12,7 @@
 #  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
-#
\ No newline at end of file
+#\r
+# Blueprint Processor File Execution and Handling Properties\r
+blueprintsprocessor.blueprintDeployPath=/opt/app/onap/blueprints/deploy\r
+blueprintsprocessor.blueprintArchivePath=/opt/app/onap/blueprints/archive
\ No newline at end of file
index 567c257..fdd755e 100644 (file)
@@ -13,5 +13,5 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-blueprintsprocessor.blueprint-deploy-path=/opt
-blueprintsprocessor.blueprint-archive-path=/opt
\ No newline at end of file
+blueprintsprocessor.blueprintDeployPath=/opt
+blueprintsprocessor.blueprintArchivePath=/opt
\ No newline at end of file
index 626a27a..5e0c966 100644 (file)
     <packaging>jar</packaging>
     <name>Blueprints Processor Core</name>
     <description>Blueprints Processor Core</description>
-
     <dependencies>
         <dependency>
-            <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
-            <artifactId>db-lib</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
-            <artifactId>rest-lib</artifactId>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-webflux</artifactId>
         </dependency>
     </dependencies>
 </project>
index 3b5722d..07e494a 100644 (file)
 
 package org.onap.ccsdk.apps.blueprintsprocessor.core
 
+import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.beans.factory.annotation.Value
+import org.springframework.boot.context.properties.bind.Binder
+import org.springframework.boot.context.properties.source.ConfigurationPropertySources
+import org.springframework.context.annotation.Bean
 import org.springframework.context.annotation.Configuration
+import org.springframework.core.env.Environment
 
 
 @Configuration
 open class BluePrintCoreConfiguration {
 
-    @Value("\${blueprintsprocessor.blueprint-deploy-path}")
+    @Value("\${blueprintsprocessor.blueprintDeployPath}")
     lateinit var deployPath: String
 
-    @Value("\${blueprintsprocessor.blueprint-archive-path}")
+    @Value("\${blueprintsprocessor.blueprintArchivePath}")
     lateinit var archivePath: String
 
+}
+
+@Configuration
+open class BlueprintPropertyConfiguration {
+    @Autowired
+    lateinit var environment: Environment
+
+    @Bean
+    open fun bluePrintPropertyBinder(): Binder {
+        val configurationPropertySource = ConfigurationPropertySources.get(environment)
+        return Binder(configurationPropertySource)
+    }
 }
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt
new file mode 100644 (file)
index 0000000..10b8ceb
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * 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.blueprintsprocessor.core
+
+import org.springframework.boot.context.properties.bind.Bindable
+import org.springframework.boot.context.properties.bind.Binder
+import org.springframework.stereotype.Service
+
+@Service
+open class BluePrintProperties(var bluePrintPropertyBinder: Binder) {
+
+    fun <T> propertyBeanType(prefix: String, type: Class<T>): T {
+        return bluePrintPropertyBinder.bind(prefix, Bindable.of(type)).get()
+    }
+}
\ No newline at end of file
index 0139e74..5f5b89d 100644 (file)
   ~  limitations under the License.
   -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
-               <artifactId>commons</artifactId>
-               <version>0.4.0-SNAPSHOT</version>
-       </parent>
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+        <artifactId>commons</artifactId>
+        <version>0.4.0-SNAPSHOT</version>
+    </parent>
 
-       <artifactId>db-lib</artifactId>
-       <packaging>jar</packaging>
-       <name>Blueprints Processor DB Lib</name>
-       <description>Blueprints Processor DB Lib</description>
+    <artifactId>db-lib</artifactId>
+    <packaging>jar</packaging>
+    <name>Blueprints Processor DB Lib</name>
+    <description>Blueprints Processor DB Lib</description>
 
-       <dependencies>
+    <dependencies>
+        <dependency>
+            <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+            <artifactId>core</artifactId>
+        </dependency>
 
-               <dependency>
-                       <groupId>org.springframework.boot</groupId>
-                       <artifactId>spring-boot-starter-data-jpa</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>javax.validation</groupId>
-                       <artifactId>validation-api</artifactId>
-               </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.validation</groupId>
+            <artifactId>validation-api</artifactId>
+        </dependency>
 
-               <dependency>
-                       <groupId>com.h2database</groupId>
-                       <artifactId>h2</artifactId>
-               </dependency>
+        <dependency>
+            <groupId>com.h2database</groupId>
+            <artifactId>h2</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.hibernate</groupId>
             <artifactId>hibernate-testing</artifactId>
             <scope>test</scope>
         </dependency>
 
-       </dependencies>
+    </dependencies>
 
 </project>
index 7bfec58..f38ccab 100644 (file)
             <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
             <artifactId>resource-dict</artifactId>
         </dependency>
+        <!-- Test Dependencies -->
+        <dependency>
+            <groupId>org.powermock</groupId>
+            <artifactId>powermock-api-mockito2</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>org.jetbrains.kotlin</groupId>
             <artifactId>kotlin-test-junit</artifactId>
index 6dfe111..da6194a 100644 (file)
   ~  limitations under the License.
   -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
-               <artifactId>commons</artifactId>
-               <version>0.4.0-SNAPSHOT</version>
-       </parent>
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+        <artifactId>commons</artifactId>
+        <version>0.4.0-SNAPSHOT</version>
+    </parent>
 
-       <artifactId>rest-lib</artifactId>
-       <packaging>jar</packaging>
-       <name>Blueprints Processor Rest Lib</name>
-       <description>Blueprints Processor Rest Lib</description>
-       <dependencies>
-               <dependency>
-                       <groupId>org.springframework.boot</groupId>
-                       <artifactId>spring-boot-starter-webflux</artifactId>
-               </dependency>
-       </dependencies>
+    <artifactId>rest-lib</artifactId>
+    <packaging>jar</packaging>
+    <name>Blueprints Processor Rest Lib</name>
+    <description>Blueprints Processor Rest Lib</description>
+    <dependencies>
+        <dependency>
+            <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+            <artifactId>core</artifactId>
+        </dependency>
+    </dependencies>
 
 </project>
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt
new file mode 100644 (file)
index 0000000..50d69ae
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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.blueprintsprocessor.rest
+
+import org.springframework.boot.context.properties.EnableConfigurationProperties
+import org.springframework.context.annotation.ComponentScan
+import org.springframework.context.annotation.Configuration
+
+@Configuration
+@ComponentScan
+@EnableConfigurationProperties
+open class BluePrintRestLibConfiguration
+
+
+class RestLibConstants {
+    companion object {
+        const val TYPE_BASIC_AUTH = "basic-auth"
+        const val TYPE_SSL_BASIC_AUTH = "ssl-basic-auth"
+        const val TYPE_DME2_PROXY = "dme2-proxy"
+        const val TYPE_POLICY_MANAGER = "policy-manager"
+    }
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt
new file mode 100644 (file)
index 0000000..faf4fd4
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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.blueprintsprocessor.rest
+
+open class RestClientProperties {
+    lateinit var type: String
+    lateinit var url: String
+    lateinit var userId: String
+}
+
+open class BasicAuthRestClientProperties : RestClientProperties() {
+    var passwd: String? = null
+}
+
+open class SSLBasicAuthRestClientProperties : RestClientProperties() {
+    lateinit var sslTrust: String
+    lateinit var sslTrustPasswd: String
+    lateinit var sslKey: String
+    lateinit var sslKeyPasswd: String
+}
+
+open class DME2RestClientProperties : RestClientProperties() {
+    lateinit var service: String
+    lateinit var subContext: String
+    lateinit var version: String
+    lateinit var envContext: String
+    lateinit var routeOffer: String
+    var partner: String? = null
+    lateinit var appId: String
+}
+
+open class PolicyManagerRestClientProperties : RestClientProperties() {
+    lateinit var env: String
+    lateinit var clientAuth: String
+    lateinit var authorisation: String
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt
new file mode 100644 (file)
index 0000000..b79034b
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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.blueprintsprocessor.rest.service
+
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestClientProperties
+import org.springframework.web.reactive.function.client.WebClient
+
+
+class BasicAuthRestClientService(restClientProperties: RestClientProperties) : BlueprintWebClientService {
+
+    override fun webClient(): WebClient {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override fun <T> getResource(path: String, responseType: Class<T>): T {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override fun <T> postResource(path: String, request: Any, responseType: Class<T>): T {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt
new file mode 100644 (file)
index 0000000..21d080d
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * 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.blueprintsprocessor.rest.service
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.*
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.springframework.stereotype.Service
+
+@Service
+open class BluePrintRestLibPropertyService(private var bluePrintProperties: BluePrintProperties) {
+
+    @Throws(BluePrintProcessorException::class)
+    fun restClientProperties(prefix: String): RestClientProperties {
+        val type = bluePrintProperties.propertyBeanType("$prefix.type", String::class.java)
+        return when (type) {
+            RestLibConstants.TYPE_BASIC_AUTH -> {
+                basicAuthRestClientProperties(prefix)
+            }
+            RestLibConstants.TYPE_SSL_BASIC_AUTH -> {
+                sslBasicAuthRestClientProperties(prefix)
+            }
+            RestLibConstants.TYPE_DME2_PROXY -> {
+                dme2ProxyClientProperties(prefix)
+            }
+            RestLibConstants.TYPE_POLICY_MANAGER -> {
+                policyManagerRestClientProperties(prefix)
+            }
+            else -> {
+                throw BluePrintProcessorException("Rest adaptor($type) is not supported")
+            }
+        }
+    }
+
+    @Throws(BluePrintProcessorException::class)
+    fun blueprintWebClientService(selector: String): BlueprintWebClientService {
+        val prefix = "blueprintsprocessor.restclient.$selector"
+        val beanProperties = restClientProperties(prefix)
+        when (beanProperties) {
+            is BasicAuthRestClientProperties -> {
+                return BasicAuthRestClientService(beanProperties)
+            }
+            is SSLBasicAuthRestClientProperties -> {
+                return SSLBasicAuthRestClientService(beanProperties)
+            }
+            is DME2RestClientProperties -> {
+                return DME2ProxyRestClientService(beanProperties)
+            }
+            else -> {
+                throw BluePrintProcessorException("couldn't get rest service for selector($selector)")
+            }
+        }
+
+    }
+
+    fun basicAuthRestClientProperties(prefix: String): BasicAuthRestClientProperties {
+        return bluePrintProperties.propertyBeanType(prefix, BasicAuthRestClientProperties::class.java)
+    }
+
+    fun sslBasicAuthRestClientProperties(prefix: String): SSLBasicAuthRestClientProperties {
+        return bluePrintProperties.propertyBeanType(prefix, SSLBasicAuthRestClientProperties::class.java)
+    }
+
+    fun dme2ProxyClientProperties(prefix: String): DME2RestClientProperties {
+        return bluePrintProperties.propertyBeanType(prefix, DME2RestClientProperties::class.java)
+    }
+
+    fun policyManagerRestClientProperties(prefix: String): PolicyManagerRestClientProperties {
+        return bluePrintProperties.propertyBeanType(prefix, PolicyManagerRestClientProperties::class.java)
+    }
+}
+
+
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt
new file mode 100644 (file)
index 0000000..232f4bb
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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.blueprintsprocessor.rest.service
+
+import org.springframework.web.reactive.function.client.WebClient
+
+interface BlueprintWebClientService {
+
+    fun webClient(): WebClient
+
+    fun <T> getResource(path: String, responseType: Class<T>): T
+
+    fun <T> postResource(path: String, request: Any, responseType: Class<T>): T
+
+    fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T
+
+}
+
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt
new file mode 100644 (file)
index 0000000..bd46ced
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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.blueprintsprocessor.rest.service
+
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestClientProperties
+import org.springframework.web.reactive.function.client.WebClient
+
+class DME2ProxyRestClientService(restClientProperties: RestClientProperties) : BlueprintWebClientService {
+    override fun webClient(): WebClient {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override fun <T> getResource(path: String, responseType: Class<T>): T {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override fun <T> postResource(path: String, request: Any, responseType: Class<T>): T {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt
new file mode 100644 (file)
index 0000000..8b4add1
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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.blueprintsprocessor.rest.service
+
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestClientProperties
+import org.springframework.web.reactive.function.client.WebClient
+
+class SSLBasicAuthRestClientService(restClientProperties: RestClientProperties) : BlueprintWebClientService {
+    override fun webClient(): WebClient {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override fun <T> getResource(path: String, responseType: Class<T>): T {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override fun <T> postResource(path: String, request: Any, responseType: Class<T>): T {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/resources/application.properties b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/resources/application.properties
new file mode 100644 (file)
index 0000000..2ce8714
--- /dev/null
@@ -0,0 +1,16 @@
+#\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
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestPropertyPlaceHolderConfigurationTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestPropertyPlaceHolderConfigurationTest.kt
new file mode 100644 (file)
index 0000000..d5e2743
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * 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.blueprintsprocessor.rest.service
+
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BlueprintPropertyConfiguration
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.BluePrintRestLibConfiguration
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+import kotlin.test.assertNotNull
+
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [BluePrintRestLibConfiguration::class, BlueprintPropertyConfiguration::class, BluePrintProperties::class])
+@TestPropertySource(properties =
+["blueprintsprocessor.restclient.sample.type=basic-auth",
+    "blueprintsprocessor.restclient.sample.url=http://localhost:8080",
+    "blueprintsprocessor.restclient.sample.userId=sampleuser"])
+
+class RestPropertyPlaceHolderConfigurationTest {
+
+    @Autowired
+    lateinit var bluePrintRestLibPropertyService: BluePrintRestLibPropertyService
+
+    @Test
+    fun testRestClientProperties() {
+        val properties = bluePrintRestLibPropertyService.restClientProperties("blueprintsprocessor.restclient.sample")
+        assertNotNull(properties, "failed to create property bean")
+        assertNotNull(properties.url, "failed to get url property in property bean")
+    }
+
+    @Test
+    fun testBlueprintWebClientService() {
+        val blueprintWebClientService = bluePrintRestLibPropertyService.blueprintWebClientService("sample")
+        assertNotNull(blueprintWebClientService, "failed to create blueprintWebClientService")
+    }
+
+}
+
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/resources/logback-test.xml
new file mode 100644 (file)
index 0000000..f9ec9fe
--- /dev/null
@@ -0,0 +1,35 @@
+<!--\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
+<configuration>\r
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">\r
+        <!-- encoders are assigned the type\r
+             ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->\r
+        <encoder>\r
+            <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>\r
+        </encoder>\r
+    </appender>\r
+\r
+    <logger name="org.springframework.test" level="warn"/>\r
+    <logger name="org.springframework" level="warn"/>\r
+    <logger name="org.hibernate" level="info"/>\r
+    <logger name="org.onap.ccsdk.apps.blueprintsprocessor" level="info"/>\r
+\r
+    <root level="warn">\r
+        <appender-ref ref="STDOUT"/>\r
+    </root>\r
+\r
+</configuration>\r
index 4f0e6c0..f9e5191 100644 (file)
             <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
             <artifactId>core</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+            <artifactId>db-lib</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+            <artifactId>rest-lib</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
             <artifactId>resource-dict</artifactId>