summaryrefslogtreecommitdiffstats
path: root/CdtProxyService
diff options
context:
space:
mode:
Diffstat (limited to 'CdtProxyService')
-rw-r--r--CdtProxyService/pom.xml97
-rw-r--r--CdtProxyService/src/main/java/org/onap/appc/cdt/service/MainApplication.java79
-rw-r--r--CdtProxyService/src/main/java/org/onap/appc/cdt/service/SwaggerConfig.java60
-rw-r--r--CdtProxyService/src/main/java/org/onap/appc/cdt/service/controller/CdtController.java169
-rw-r--r--CdtProxyService/src/main/java/org/onap/appc/cdt/service/domain/DesignRequest.java58
-rw-r--r--CdtProxyService/src/main/java/org/onap/appc/cdt/service/domain/GetDesignRequest.java41
-rw-r--r--CdtProxyService/src/main/java/org/onap/appc/cdt/service/domain/Input.java42
-rw-r--r--CdtProxyService/src/main/java/org/onap/appc/cdt/service/domain/Payload.java68
-rw-r--r--CdtProxyService/src/main/java/org/onap/appc/cdt/service/exceptions/ApiError.java65
-rw-r--r--CdtProxyService/src/main/java/org/onap/appc/cdt/service/exceptions/GlobalExceptionHandler.java74
-rw-r--r--CdtProxyService/src/main/java/org/onap/appc/cdt/service/exceptions/ResourceNotFoundException.java51
-rw-r--r--CdtProxyService/src/main/resources/application.properties17
12 files changed, 821 insertions, 0 deletions
diff --git a/CdtProxyService/pom.xml b/CdtProxyService/pom.xml
new file mode 100644
index 0000000..801ad21
--- /dev/null
+++ b/CdtProxyService/pom.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START==========================================
+ ===================================================================
+ Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ ===================================================================
+
+ Unless otherwise specified, all software contained herein is licensed
+ under the Apache License, Version 2.0 (the License);
+ you may not use this software 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.
+
+ ============LICENSE_END============================================
+-->
+
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ 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>
+ <groupId>org.onap.appc.cdt</groupId>
+ <artifactId>cdt-proxy-service</artifactId>
+ <name>CdtProxyService</name>
+ <version>1.6.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <properties>
+ <java.version>1.8</java.version>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <start-class>org.onap.appc.cdt.service.MainApplication</start-class>
+ </properties>
+ <!-- Inherit defaults from Spring Boot -->
+ <parent>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-parent</artifactId>
+ <version>1.4.5.RELEASE</version>
+ </parent>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ <dependencies>
+ <!-- Get the dependencies of a web application -->
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.springfox</groupId>
+ <artifactId>springfox-swagger2</artifactId>
+ <version>2.7.0</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.springfox</groupId>
+ <artifactId>springfox-swagger-ui</artifactId>
+ <version>2.7.0</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.5</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <!-- Spring Boot Maven Support -->
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project> \ No newline at end of file
diff --git a/CdtProxyService/src/main/java/org/onap/appc/cdt/service/MainApplication.java b/CdtProxyService/src/main/java/org/onap/appc/cdt/service/MainApplication.java
new file mode 100644
index 0000000..c160519
--- /dev/null
+++ b/CdtProxyService/src/main/java/org/onap/appc/cdt/service/MainApplication.java
@@ -0,0 +1,79 @@
+/*
+============LICENSE_START==========================================
+===================================================================
+Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+===================================================================
+
+Unless otherwise specified, all software contained herein is licensed
+under the Apache License, Version 2.0 (the License);
+you may not use this software 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.
+
+============LICENSE_END============================================
+*/
+package org.onap.appc.cdt.service;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.converter.StringHttpMessageConverter;
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+
+/**
+ * Created by Amaresh Kumar on 09/May/2018.
+ */
+
+@EnableAutoConfiguration
+@Configuration
+@ComponentScan
+public class MainApplication {
+
+ public static void main(String args[]) {
+ SpringApplication.run(MainApplication.class, args);
+ }
+
+ @Bean
+ public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
+ MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
+ ObjectMapper objectMapper = new ObjectMapper();
+ objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
+ jsonConverter.setObjectMapper(objectMapper);
+ return jsonConverter;
+ }
+
+ @Bean
+ public StringHttpMessageConverter stringHttpMessageConverter() {
+ StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter();
+ stringHttpMessageConverter.setWriteAcceptCharset(true);
+ return stringHttpMessageConverter;
+ }
+
+ @Bean
+ public WebMvcConfigurer corsConfigurer() {
+ return new WebMvcConfigurerAdapter() {
+ @Override
+ public void addCorsMappings(CorsRegistry registry) {
+ registry.addMapping("/**")
+ .allowedOrigins("*")
+ .allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE");
+ }
+ };
+ }
+}
diff --git a/CdtProxyService/src/main/java/org/onap/appc/cdt/service/SwaggerConfig.java b/CdtProxyService/src/main/java/org/onap/appc/cdt/service/SwaggerConfig.java
new file mode 100644
index 0000000..f9630a6
--- /dev/null
+++ b/CdtProxyService/src/main/java/org/onap/appc/cdt/service/SwaggerConfig.java
@@ -0,0 +1,60 @@
+/*
+============LICENSE_START==========================================
+===================================================================
+Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+===================================================================
+
+Unless otherwise specified, all software contained herein is licensed
+under the Apache License, Version 2.0 (the License);
+you may not use this software 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.
+
+============LICENSE_END============================================
+*/
+package org.onap.appc.cdt.service;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+/**
+ * Created by Amaresh Kumar on 09/May/2018.
+ */
+@Configuration
+@EnableSwagger2
+public class SwaggerConfig {
+ @Bean
+ public Docket api() {
+ return new Docket(DocumentationType.SWAGGER_2)
+ .apiInfo(getApiInfo())
+ .select()
+ .apis(RequestHandlerSelectors.basePackage("org.onap.appc.cdt.service.controller"))
+ .paths(PathSelectors.any())
+ .build();
+ }
+
+ private ApiInfo getApiInfo() {
+
+ return new ApiInfoBuilder()
+ .title("VNF Lifecycle Tetsing Api Doc")
+ .description("Developer API Reference guide for devlopong VNF lifecylye testing")
+ .version("1.0.0")
+ .license("Apache 2.0")
+ .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0")
+ .contact("kamaresh@in.ibm.com")
+ .build();
+ }
+} \ No newline at end of file
diff --git a/CdtProxyService/src/main/java/org/onap/appc/cdt/service/controller/CdtController.java b/CdtProxyService/src/main/java/org/onap/appc/cdt/service/controller/CdtController.java
new file mode 100644
index 0000000..78a94f6
--- /dev/null
+++ b/CdtProxyService/src/main/java/org/onap/appc/cdt/service/controller/CdtController.java
@@ -0,0 +1,169 @@
+/*
+============LICENSE_START==========================================
+===================================================================
+Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+===================================================================
+
+Unless otherwise specified, all software contained herein is licensed
+under the Apache License, Version 2.0 (the License);
+you may not use this software 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.
+
+============LICENSE_END============================================
+*/
+
+package org.onap.appc.cdt.service.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import org.apache.http.client.HttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.http.client.ClientHttpRequestFactory;
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.client.RestTemplate;
+
+import java.net.UnknownHostException;
+import java.util.Base64;
+
+/**
+ * Created by Amaresh Kumar on 09/May/2018.
+ */
+
+@RestController
+@RequestMapping("/cdtService")
+@CrossOrigin(origins = "*", allowedHeaders = "*")
+@Api(value = "cdtService", description = "Backend service to eliminate CORS issue for CDT Tool")
+public class CdtController {
+
+ private static final Logger logger = LoggerFactory.getLogger(CdtController.class);
+ private RestTemplate restTemplate = new RestTemplate();
+ private String urlAddress;
+
+ @Value("${restConf.backend.hostname}")
+ private String restConfHostname;
+
+ @Value("${restConf.backend.port}")
+ private String restConfPort;
+
+ @Value("${restConf.username}")
+ private String restConfUsername;
+
+ @Value("${restConf.password}")
+ private String restConfPassword;
+
+ @ApiOperation(value = "Return All Test Data for a given user", response = CdtController.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "OK"),
+ @ApiResponse(code = 404, message = "The resource not found")
+ })
+ @RequestMapping(value = "", method = RequestMethod.GET)
+ @CrossOrigin(origins = "*", allowedHeaders = "*")
+ public String DefaultEndpoint() {
+ return "CDT Proxy Service is up and running.";
+
+ }
+
+ @ApiOperation(value = "Return All Test Data for a given user", response = CdtController.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "OK"),
+ @ApiResponse(code = 404, message = "The resource not found")
+ })
+ @RequestMapping(value = "/getDesigns", method = RequestMethod.POST)
+ @CrossOrigin(origins = "*", allowedHeaders = "*")
+ public String getDesigns(@RequestBody String getDesignsRequest) throws UnknownHostException {
+ HttpEntity<String> entity = getStringHttpEntity(getDesignsRequest);
+ HttpClient httpClient = HttpClientBuilder.create().build();
+ ClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient);
+ restTemplate.setRequestFactory(factory);
+ String getDesignsResponse = restTemplate.postForObject(getUrl("getDesigns"), entity, String.class);
+ return getDesignsResponse;
+ }
+
+ @ApiOperation(value = "Test VNF", response = CdtController.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "OK"),
+ @ApiResponse(code = 404, message = "The resource not found")
+ })
+ @RequestMapping(value = "/testVnf", method = RequestMethod.POST)
+ @CrossOrigin(origins = "*", allowedHeaders = "*")
+ public String testVnf(@RequestParam String urlAction, @RequestBody String testVnf) throws UnknownHostException {
+ HttpEntity<String> entity = getStringHttpEntity(testVnf);
+ String testVnfResponse = restTemplate.postForObject(getUrl("testVnf")+urlAction, entity, String.class);
+ return testVnfResponse;
+ }
+
+ @ApiOperation(value = "Check status of submitted Test", response = CdtController.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "OK"),
+ @ApiResponse(code = 404, message = "The resource not found")
+ })
+ @RequestMapping(value = "/checkTestStatus", method = RequestMethod.POST)
+ @CrossOrigin(origins = "*", allowedHeaders = "*")
+ public String checkTestStatus(@RequestBody String checkTestStatusRequest) throws UnknownHostException {
+ HttpEntity<String> entity = getStringHttpEntity(checkTestStatusRequest);
+ String checkTestStatusResponse = restTemplate.postForObject(getUrl("checkTestStatus"), entity, String.class);
+ return checkTestStatusResponse;
+ }
+
+ @ApiOperation(value = "Validate a template which is being uploaded", response = CdtController.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "OK"),
+ @ApiResponse(code = 404, message = "The resource not found")
+ })
+ @RequestMapping(value = "/validateTemplate", method = RequestMethod.POST)
+ @CrossOrigin(origins = "*", allowedHeaders = "*")
+ public String validateTemplate(@RequestBody String validateTemplateRequest) throws UnknownHostException {
+ HttpEntity<String> entity = getStringHttpEntity(validateTemplateRequest);
+ String validateTemplateResponse = restTemplate.postForObject(getUrl("validateTemplate"), entity, String.class);
+ return validateTemplateResponse;
+ }
+
+ private HttpEntity<String> getStringHttpEntity(@RequestBody String getDesignsRequest) {
+ HttpHeaders headers = new HttpHeaders();
+ headers.setAccessControlAllowCredentials(true);
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ String planCredentials = restConfUsername + ":" + restConfPassword;
+ String base64Credentails = Base64.getEncoder().encodeToString(planCredentials.getBytes());
+ headers.set("Authorization", "Basic " + base64Credentails);
+ return new HttpEntity<String>(getDesignsRequest, headers);
+ }
+
+ private String getUrl(String ApiName) throws UnknownHostException {
+
+ switch (ApiName) {
+ case "getDesigns":
+ urlAddress = "http://" + restConfHostname + ":" + restConfPort + "/restconf/operations/design-services:dbservice";
+ break;
+ case "testVnf":
+ urlAddress = "http://" + restConfHostname + ":" + restConfPort + "/restconf/operations/appc-provider-lcm:";
+ break;
+ case "checkTestStatus":
+ urlAddress = "http://" + restConfHostname + ":" + restConfPort + "/restconf/operations/appc-provider-lcm:action-status";
+ break;
+ case "validateTemplate":
+ urlAddress = "http://" + restConfHostname + ":" + restConfPort + "/restconf/operations/design-services:validator";
+ break;
+ default:
+ logger.error("URI not resolved because Api call not supported ");
+ }
+ logger.info("Calling Endpoint..... " + urlAddress);
+ return urlAddress;
+ }
+}
diff --git a/CdtProxyService/src/main/java/org/onap/appc/cdt/service/domain/DesignRequest.java b/CdtProxyService/src/main/java/org/onap/appc/cdt/service/domain/DesignRequest.java
new file mode 100644
index 0000000..e3e5fb8
--- /dev/null
+++ b/CdtProxyService/src/main/java/org/onap/appc/cdt/service/domain/DesignRequest.java
@@ -0,0 +1,58 @@
+/*
+============LICENSE_START==========================================
+===================================================================
+Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+===================================================================
+
+Unless otherwise specified, all software contained herein is licensed
+under the Apache License, Version 2.0 (the License);
+you may not use this software 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.
+
+============LICENSE_END============================================
+*/
+package org.onap.appc.cdt.service.domain;
+
+/**
+ * Created by Amaresh Kumar on 09/May/2018.
+ */
+public class DesignRequest {
+ private String requestId;
+ private String action;
+ private Payload payload;
+
+ public DesignRequest() {
+ }
+
+ public String getRequestId() {
+ return requestId;
+ }
+
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ public Payload getPayload() {
+ return payload;
+ }
+
+ public void setPayload(Payload payload) {
+ this.payload = payload;
+ }
+}
diff --git a/CdtProxyService/src/main/java/org/onap/appc/cdt/service/domain/GetDesignRequest.java b/CdtProxyService/src/main/java/org/onap/appc/cdt/service/domain/GetDesignRequest.java
new file mode 100644
index 0000000..4e57a28
--- /dev/null
+++ b/CdtProxyService/src/main/java/org/onap/appc/cdt/service/domain/GetDesignRequest.java
@@ -0,0 +1,41 @@
+/*
+============LICENSE_START==========================================
+===================================================================
+Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+===================================================================
+
+Unless otherwise specified, all software contained herein is licensed
+under the Apache License, Version 2.0 (the License);
+you may not use this software 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.
+
+============LICENSE_END============================================
+*/
+package org.onap.appc.cdt.service.domain;
+
+/**
+ * Created by Amaresh Kumar on 09/May/2018.
+ */
+public class GetDesignRequest {
+ private Input input;
+
+ public GetDesignRequest() {
+
+ }
+
+ public Input getInput() {
+ return input;
+ }
+
+ public void setInput(Input input) {
+ this.input = input;
+ }
+}
diff --git a/CdtProxyService/src/main/java/org/onap/appc/cdt/service/domain/Input.java b/CdtProxyService/src/main/java/org/onap/appc/cdt/service/domain/Input.java
new file mode 100644
index 0000000..1be4453
--- /dev/null
+++ b/CdtProxyService/src/main/java/org/onap/appc/cdt/service/domain/Input.java
@@ -0,0 +1,42 @@
+/*
+============LICENSE_START==========================================
+===================================================================
+Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+===================================================================
+
+Unless otherwise specified, all software contained herein is licensed
+under the Apache License, Version 2.0 (the License);
+you may not use this software 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.
+
+============LICENSE_END============================================
+*/
+package org.onap.appc.cdt.service.domain;
+
+/**
+ * Created by Amaresh Kumar on 09/May/2018.
+ */
+public class Input {
+ private DesignRequest designRequest;
+
+ public Input() {
+
+ }
+
+ public DesignRequest getDesignRequest() {
+ return designRequest;
+ }
+
+ public void setDesignRequest(DesignRequest designRequest) {
+ this.designRequest = designRequest;
+ }
+}
+
diff --git a/CdtProxyService/src/main/java/org/onap/appc/cdt/service/domain/Payload.java b/CdtProxyService/src/main/java/org/onap/appc/cdt/service/domain/Payload.java
new file mode 100644
index 0000000..4e85fc0
--- /dev/null
+++ b/CdtProxyService/src/main/java/org/onap/appc/cdt/service/domain/Payload.java
@@ -0,0 +1,68 @@
+/*
+============LICENSE_START==========================================
+===================================================================
+Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+===================================================================
+
+Unless otherwise specified, all software contained herein is licensed
+under the Apache License, Version 2.0 (the License);
+you may not use this software 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.
+
+============LICENSE_END============================================
+*/
+package org.onap.appc.cdt.service.domain;
+
+/**
+ * Created by Amaresh Kumar on 09/May/2018.
+ */
+public class Payload {
+
+ private String userId;
+ private String vnfType;
+ private String artifactType = "APPC-CONFIG";
+ private String artifactName;
+
+ public Payload() {
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ public String getVnfType() {
+ return vnfType;
+ }
+
+ public void setVnfType(String vnfType) {
+ this.vnfType = vnfType;
+ }
+
+ public String getArtifactType() {
+ return artifactType;
+ }
+
+ public void setArtifactType(String artifactType) {
+ this.artifactType = artifactType;
+ }
+
+ public String getArtifactName() {
+ return artifactName;
+ }
+
+ public void setArtifactName(String artifactName) {
+ this.artifactName = artifactName;
+ }
+}
diff --git a/CdtProxyService/src/main/java/org/onap/appc/cdt/service/exceptions/ApiError.java b/CdtProxyService/src/main/java/org/onap/appc/cdt/service/exceptions/ApiError.java
new file mode 100644
index 0000000..07fadcc
--- /dev/null
+++ b/CdtProxyService/src/main/java/org/onap/appc/cdt/service/exceptions/ApiError.java
@@ -0,0 +1,65 @@
+/*
+============LICENSE_START==========================================
+===================================================================
+Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+===================================================================
+
+Unless otherwise specified, all software contained herein is licensed
+under the Apache License, Version 2.0 (the License);
+you may not use this software 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.
+
+============LICENSE_END============================================
+*/
+package org.onap.appc.cdt.service.exceptions;
+
+import org.springframework.http.HttpStatus;
+
+/**
+ * Created by Amaresh Kumar on 09/May/2018.
+ */
+public class ApiError {
+
+ private HttpStatus Status;
+ private String message;
+ private String detailedMessage;
+
+
+ public ApiError(HttpStatus status, String detailedMessage, String message) {
+ Status = status;
+ this.detailedMessage = detailedMessage;
+ this.message = message;
+ }
+
+ public HttpStatus getStatus() {
+ return Status;
+ }
+
+ public void setStatus(HttpStatus status) {
+ Status = status;
+ }
+
+ public String getDetailedMessage() {
+ return detailedMessage;
+ }
+
+ public void setDetailedMessage(String detailedMessage) {
+ this.detailedMessage = detailedMessage;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+}
diff --git a/CdtProxyService/src/main/java/org/onap/appc/cdt/service/exceptions/GlobalExceptionHandler.java b/CdtProxyService/src/main/java/org/onap/appc/cdt/service/exceptions/GlobalExceptionHandler.java
new file mode 100644
index 0000000..3995860
--- /dev/null
+++ b/CdtProxyService/src/main/java/org/onap/appc/cdt/service/exceptions/GlobalExceptionHandler.java
@@ -0,0 +1,74 @@
+/*
+============LICENSE_START==========================================
+===================================================================
+Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+===================================================================
+
+Unless otherwise specified, all software contained herein is licensed
+under the Apache License, Version 2.0 (the License);
+you may not use this software 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.
+
+============LICENSE_END============================================
+*/
+package org.onap.appc.cdt.service.exceptions;
+
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpHeaders;
+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.ResponseStatus;
+import org.springframework.web.client.ResourceAccessException;
+import org.springframework.web.context.request.WebRequest;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.net.UnknownHostException;
+
+/**
+ * Created by Amaresh Kumar on 09/May/2018.
+ */
+@ControllerAdvice
+public class GlobalExceptionHandler {
+ private static final Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
+
+ @ExceptionHandler(UnknownHostException.class)
+ public String handleSQLException(HttpServletRequest request, Exception ex) {
+ logger.info("UnknownHostException Occured:: URL=" + request.getRequestURL());
+ return "Host not found";
+ }
+
+ @ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "IOException occured")
+ @ExceptionHandler(IOException.class)
+ public void handleIOException() {
+ logger.error("IOException handler executed");
+ }
+
+ @ResponseStatus(value = HttpStatus.GATEWAY_TIMEOUT, reason = "Cannot access restconf URl")
+ @ExceptionHandler(ResourceAccessException.class)
+ public void handleResourceAccessException() {
+ logger.error("IOException handler executed");
+ }
+
+ @ExceptionHandler(value = {ResourceNotFoundException.class})
+ protected ResponseEntity<Object> handleResourceNotFoundExceptionException(ResourceNotFoundException ex, WebRequest request) {
+ StringBuilder builder = new StringBuilder();
+ builder.append(ex.getMessage());
+ ApiError apiError = new ApiError(HttpStatus.NOT_FOUND,
+ "Resource Doesnt Exists.", builder.substring(0, builder.length()));
+ return new ResponseEntity<Object>(apiError, new HttpHeaders(), apiError.getStatus());
+ }
+
+}
diff --git a/CdtProxyService/src/main/java/org/onap/appc/cdt/service/exceptions/ResourceNotFoundException.java b/CdtProxyService/src/main/java/org/onap/appc/cdt/service/exceptions/ResourceNotFoundException.java
new file mode 100644
index 0000000..7ef5b62
--- /dev/null
+++ b/CdtProxyService/src/main/java/org/onap/appc/cdt/service/exceptions/ResourceNotFoundException.java
@@ -0,0 +1,51 @@
+/*
+============LICENSE_START==========================================
+===================================================================
+Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+===================================================================
+
+Unless otherwise specified, all software contained herein is licensed
+under the Apache License, Version 2.0 (the License);
+you may not use this software 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.
+
+============LICENSE_END============================================
+*/
+package org.onap.appc.cdt.service.exceptions;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+/**
+ * Created by Amaresh Kumar on 09/May/2018.
+ */
+@ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "Resource Not Found")
+public class ResourceNotFoundException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ private String errCode;
+ private String errMsg;
+
+ /**
+ * Constructs a new runtime exception with the specified detail message.
+ * The cause is not initialized, and may subsequently be initialized by a
+ * call to {@link #initCause}.
+ *
+ * @param message the detail message. The detail message is saved for
+ * later retrieval by the {@link #getMessage()} method.
+ */
+ public ResourceNotFoundException(String message, String errCode, String errMsg) {
+ super(message);
+ this.errCode = errCode;
+ this.errMsg = errMsg;
+ }
+}
diff --git a/CdtProxyService/src/main/resources/application.properties b/CdtProxyService/src/main/resources/application.properties
new file mode 100644
index 0000000..1d9a438
--- /dev/null
+++ b/CdtProxyService/src/main/resources/application.properties
@@ -0,0 +1,17 @@
+#Created by Amaresh Kumar on 09/May/2018.
+#=====Application level properties START======================
+server.port=9090
+spring.application.name=CdtProxyService
+logging.level.root=DEBUG
+Djavax.net.debug=ssl;
+#=====Application level properties END======================
+#=========RestConf Backend properties START==================
+restConf.backend.hostname=10.12.5.49
+restConf.backend.port=8282
+restConf.username=admin
+restConf.password=admin
+#=========RestConf Backend properties END==================
+
+#====Allowed origins======================
+
+