From a3c9519d6aa7eb8e1f450a7d041047f2c0a5cc07 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Fri, 17 Aug 2018 19:45:00 +0000 Subject: Controller Blueprints Microservice Restcontroller Swagger Implementation with Embeded jar for Controller Bluprints MS Change-Id: I0c0a33f0e29dad0d4aa703e3e381068b510e57d4 Issue-ID: CCSDK-468 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- ms/controllerblueprints/.gitignore | 1 + .../application/etc/logback.xml | 36 ++++ .../opt/app/onap/config/application.properties | 35 ---- .../application/opt/app/onap/config/logback.xml | 36 ---- ms/controllerblueprints/application/pom.xml | 5 - .../application/src/assembly/distribution.xml | 8 - .../ControllerBluprintsApplication.java | 8 +- .../ControllerBluprintsFilterConfiguration.java | 37 ---- .../apps/controllerblueprints/CorsConfig.java | 22 +- .../controllerblueprints/JerseyConfiguration.java | 102 --------- .../apps/controllerblueprints/SwaggerConfig.java | 70 +++++++ .../ccsdk/apps/controllerblueprints/WebConfig.java | 37 ++++ .../controllerblueprints/WebMvcConfiguration.java | 37 ---- .../ControllerBluprintsApplicationTest.java | 3 +- .../src/test/resources/application.properties | 45 ---- .../application/src/test/resources/logback.xml | 36 ++++ ms/controllerblueprints/modules/core/pom.xml | 58 ------ .../modules/resource-dict/pom.xml | 7 - ms/controllerblueprints/modules/service/pom.xml | 24 +-- .../service/common/ServiceExceptionMapper.java | 42 ---- .../service/common/SwaggerGenerator.java | 24 +-- .../service/rs/ConfigModelRest.java | 232 ++++++++------------- .../service/rs/ConfigModelRestImpl.java | 116 ----------- .../service/rs/ModelTypeRest.java | 147 +++++-------- .../service/rs/ModelTypeRestImpl.java | 87 -------- .../service/rs/ResourceDictionaryRest.java | 152 ++++++-------- .../service/rs/ResourceDictionaryRestImpl.java | 91 -------- .../service/rs/ServiceTemplateRest.java | 160 ++++++-------- .../service/rs/ServiceTemplateRestImpl.java | 94 --------- .../controllerblueprints/JerseyConfiguration.java | 69 ------ .../controllerblueprints/TestConfiguration.java | 36 ---- .../service/rs/ConfigModelRestTest.java | 4 +- .../service/rs/ModelTypeRestTest.java | 3 +- .../service/rs/ResourceDictionaryRestTest.java | 3 +- .../service/rs/ServiceTemplateRestTest.java | 3 +- ms/controllerblueprints/parent/pom.xml | 122 ++++++++--- 36 files changed, 580 insertions(+), 1412 deletions(-) create mode 100644 ms/controllerblueprints/application/etc/logback.xml delete mode 100644 ms/controllerblueprints/application/opt/app/onap/config/logback.xml delete mode 100644 ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsFilterConfiguration.java delete mode 100644 ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/JerseyConfiguration.java create mode 100644 ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java create mode 100644 ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebConfig.java delete mode 100644 ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebMvcConfiguration.java create mode 100644 ms/controllerblueprints/application/src/test/resources/logback.xml delete mode 100644 ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ServiceExceptionMapper.java delete mode 100644 ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestImpl.java delete mode 100644 ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestImpl.java delete mode 100644 ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestImpl.java delete mode 100644 ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestImpl.java delete mode 100644 ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/JerseyConfiguration.java delete mode 100644 ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/TestConfiguration.java (limited to 'ms') diff --git a/ms/controllerblueprints/.gitignore b/ms/controllerblueprints/.gitignore index b808e8430..644e3b492 100644 --- a/ms/controllerblueprints/.gitignore +++ b/ms/controllerblueprints/.gitignore @@ -7,6 +7,7 @@ **/target-ide/* **/target/* **/logs/* +**/debug-logs/* **/tokens/* # Added for Intellij IDEA IDE diff --git a/ms/controllerblueprints/application/etc/logback.xml b/ms/controllerblueprints/application/etc/logback.xml new file mode 100644 index 000000000..44e9a8a11 --- /dev/null +++ b/ms/controllerblueprints/application/etc/logback.xml @@ -0,0 +1,36 @@ + + + + + + + %d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n + + + + + + + + + + + + + + diff --git a/ms/controllerblueprints/application/opt/app/onap/config/application.properties b/ms/controllerblueprints/application/opt/app/onap/config/application.properties index 202017de7..9fa8e04cf 100644 --- a/ms/controllerblueprints/application/opt/app/onap/config/application.properties +++ b/ms/controllerblueprints/application/opt/app/onap/config/application.properties @@ -14,43 +14,8 @@ # limitations under the License. # -info.build.artifact=@project.artifactId@ -info.build.name=@project.name@ -info.build.description=@project.description@ -info.build.version=@project.version@ -info.build.groupId=@project.groupId@ -logging.level.root=info - -server.contextPath=/ -server.servlet-path=/ -spring.jersey.application-path=/api/controller-blueprints/v1 -server.routingPath=/api - -mots.application.acronym=MOTS_ID -platform.identifier=AJSC7_JERSEY -#spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration - #logging.pattern.console=%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr($ threadId: {PID:- }){magenta} %clr(---){faint} %clr([ hostname: %X{hostname} serviceName: %X{serviceName} version: %X{version} transactionId: %X{transactionId} requestTimeStamp: %X{requestTimestamp} responseTimeStamp: %X{responseTimestamp} duration: %X{duration}]){yellow} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex -#The max number of active threads in this pool -server.tomcat.max-threads=200 -#The minimum number of threads always kept alive -server.tomcat.min-Spare-Threads=25 -#The number of milliseconds before an idle thread shutsdown, unless the number of active threads are less or equal to minSpareThreads -server.tomcat.max-idle-time=60000 - -#for changing the tomcat port... -#server.port=8081 - -#Servlet context parameters -server.context_parameters.p-name=value #context parameter with p-name as key and value as value. - -# make this true for AAF authentication and place cadi.properties into etc folder -aaf.enabled=false - -# set to true to enable version proxy -#ivp.enabled=false - logging.level.org.springframework.web=INFO logging.level.org.hibernate.SQL=warn logging.level.org.hibernate.type.descriptor.sql=debug diff --git a/ms/controllerblueprints/application/opt/app/onap/config/logback.xml b/ms/controllerblueprints/application/opt/app/onap/config/logback.xml deleted file mode 100644 index cdd20c8b1..000000000 --- a/ms/controllerblueprints/application/opt/app/onap/config/logback.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - %d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n - - - - - - - - - - - - - - diff --git a/ms/controllerblueprints/application/pom.xml b/ms/controllerblueprints/application/pom.xml index 18d9a9037..19fd9c72d 100644 --- a/ms/controllerblueprints/application/pom.xml +++ b/ms/controllerblueprints/application/pom.xml @@ -69,11 +69,6 @@ spring-boot-devtools true - - com.h2database - h2 - runtime - org.springframework.boot spring-boot-starter-test diff --git a/ms/controllerblueprints/application/src/assembly/distribution.xml b/ms/controllerblueprints/application/src/assembly/distribution.xml index adfb52d10..c58c20d78 100644 --- a/ms/controllerblueprints/application/src/assembly/distribution.xml +++ b/ms/controllerblueprints/application/src/assembly/distribution.xml @@ -27,14 +27,6 @@ /opt/app/onap/lib - org.slf4j:slf4j-log4j12 - javax.servlet:servlet-api - javax.servlet:javax.servlet-api - j2ee:j2ee - log4j:log4j - com.sun:j2ee - log4j:apache-log4j-extras - org.slf4j:slf4j-simple diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplication.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplication.java index 96d82e7e4..447e1966d 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplication.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplication.java @@ -16,22 +16,26 @@ package org.onap.ccsdk.apps.controllerblueprints; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ComponentScan; +import org.springframework.web.reactive.config.EnableWebFlux; /** - * - * * @author Brinda Santh */ @SpringBootApplication +@EnableWebFlux @ComponentScan(basePackages = {"org.onap.ccsdk.apps.controllerblueprints"}) @EnableAutoConfiguration public class ControllerBluprintsApplication { + private static EELFLogger log = EELFManager.getInstance().getLogger(ControllerBluprintsApplication.class); public static void main(String[] args) { + log.info("****** Starting Controller Bluprints Application **************"); SpringApplication.run(ControllerBluprintsApplication.class, args); } diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsFilterConfiguration.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsFilterConfiguration.java deleted file mode 100644 index 6f4bfc988..000000000 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsFilterConfiguration.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints; - - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Configuration; -/** - * - * - * @author Brinda Santh - */ -@Configuration -public class ControllerBluprintsFilterConfiguration { - private static Logger log = LoggerFactory.getLogger(JerseyConfiguration.class); - - @Value("${server.routingPath:#{null}}") - private String routingPath; - - -} diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/CorsConfig.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/CorsConfig.java index 0d9ab1623..5d682ed50 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/CorsConfig.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/CorsConfig.java @@ -1,17 +1,17 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. + * 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 + * 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 + * 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. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.onap.ccsdk.apps.controllerblueprints; @@ -29,7 +29,7 @@ import org.springframework.web.filter.CorsFilter; * @author Brinda Santh * @version 1.0 */ -@Configuration +//@Configuration public class CorsConfig { /** * This is a CORS Implementation for different Orgin GUI to access. diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/JerseyConfiguration.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/JerseyConfiguration.java deleted file mode 100644 index a3b0faf0c..000000000 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/JerseyConfiguration.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints; - - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.MapperFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import io.swagger.jaxrs.config.BeanConfig; -import io.swagger.jaxrs.listing.ApiListingResource; -import io.swagger.jaxrs.listing.SwaggerSerializers; -import org.glassfish.jersey.server.ResourceConfig; -import org.glassfish.jersey.servlet.ServletProperties; -import org.onap.ccsdk.apps.controllerblueprints.service.common.ServiceExceptionMapper; -import org.onap.ccsdk.apps.controllerblueprints.service.rs.ConfigModelRestImpl; -import org.onap.ccsdk.apps.controllerblueprints.service.rs.ModelTypeRestImpl; -import org.onap.ccsdk.apps.controllerblueprints.service.rs.ResourceDictionaryRestImpl; -import org.onap.ccsdk.apps.controllerblueprints.service.rs.ServiceTemplateRestImpl; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Primary; -import org.springframework.stereotype.Component; - -import javax.ws.rs.core.MediaType; - -/** - * - * - * @author Brinda Santh - */ -@Component -public class JerseyConfiguration extends ResourceConfig { - private static Logger log = LoggerFactory.getLogger(JerseyConfiguration.class); - /** - * - */ - @Autowired - public JerseyConfiguration() { - register(ConfigModelRestImpl.class); - register(ModelTypeRestImpl.class); - register(ResourceDictionaryRestImpl.class); - register(ServiceTemplateRestImpl.class); - register(ServiceExceptionMapper.class); - property(ServletProperties.FILTER_FORWARD_ON_404, true); - configureSwagger(); - } - - /** - * - * @return ObjectMapper - */ - @Bean - @Primary - public ObjectMapper objectMapper() { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); - objectMapper.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES); - objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); - objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); - return objectMapper; - } - - /** - * - */ - private void configureSwagger() { - register(ApiListingResource.class); - register(SwaggerSerializers.class); - BeanConfig beanConfig = new BeanConfig(); - beanConfig.setVersion("1.0.0"); - beanConfig.setSchemes(new String[]{"http", "https"}); - beanConfig.setBasePath("/api/controller-blueprints/v1"); - beanConfig.setTitle("Controller Blueprints API"); - beanConfig.setDescription("Controller BluePrints API"); - beanConfig.getSwagger().addConsumes(MediaType.APPLICATION_JSON); - beanConfig.getSwagger().addProduces(MediaType.APPLICATION_JSON); - beanConfig.setResourcePackage("org.onap.ccsdk.apps.controllerblueprints"); - beanConfig.setPrettyPrint(true); - beanConfig.setScan(true); - } - - -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java new file mode 100644 index 000000000..5970bafde --- /dev/null +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java @@ -0,0 +1,70 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +/** + * SwaggerConfig + * + * @author Brinda Santh 8/13/2018 + */ +@Configuration +@EnableSwagger2 +public class SwaggerConfig { + private static final Set DEFAULT_PRODUCES_AND_CONSUMES = + new HashSet(Arrays.asList("application/json", + "application/xml")); + private static Logger log = LoggerFactory.getLogger(SwaggerConfig.class); + + @Bean + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.any()) + .paths(PathSelectors.any()) + .build() + .apiInfo(apiInfo()); + } + + private ApiInfo apiInfo() { + return new ApiInfo( + "Controller Blueprints API", + "Controller blueprints API for VNF Self Service.", + "1.0.0", + "Terms of service", + new Contact("Brinda Santh", "www.onap.com", "brindasanth@onap.com"), + "Apache 2.0", "http://www.apache.org/licenses/LICENSE-2.0", Collections.emptyList()); + } + + +} diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebConfig.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebConfig.java new file mode 100644 index 000000000..1eba97cdc --- /dev/null +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebConfig.java @@ -0,0 +1,37 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.reactive.config.ResourceHandlerRegistry; +import org.springframework.web.reactive.config.WebFluxConfigurationSupport; + +/** + * WebConfig + * + * @author Brinda Santh 8/13/2018 + */ +@Configuration +public class WebConfig extends WebFluxConfigurationSupport { + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("swagger-ui.html") + .addResourceLocations("classpath:/META-INF/resources/"); + + registry.addResourceHandler("/webjars/**") + .addResourceLocations("classpath:/META-INF/resources/webjars/"); + } +} diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebMvcConfiguration.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebMvcConfiguration.java deleted file mode 100644 index a690c056c..000000000 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebMvcConfiguration.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints; - -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; - -/** - * - * WebMvcConfiguration WebMvcConfiguration - * @author Brinda Santh - */ -@Configuration -@EnableWebMvc -public class WebMvcConfiguration extends WebMvcConfigurerAdapter { - @Override - public void addResourceHandlers(ResourceHandlerRegistry registry) { - registry.addResourceHandler("/swagger-ui/**").addResourceLocations("classpath:/swagger-ui/dist/"); - } - -} diff --git a/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java b/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java index 4bdbde008..95639bd32 100644 --- a/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java +++ b/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java @@ -46,9 +46,8 @@ public class ControllerBluprintsApplicationTest { @Test public void testConfigModel() { - ResponseEntity entity = this.restTemplate - .getForEntity("/api/controller-blueprints/v1/service/configmodel/1", String.class); + .getForEntity("/api/v1/config-model/1", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); } } diff --git a/ms/controllerblueprints/application/src/test/resources/application.properties b/ms/controllerblueprints/application/src/test/resources/application.properties index c6057e563..55ffeaf16 100644 --- a/ms/controllerblueprints/application/src/test/resources/application.properties +++ b/ms/controllerblueprints/application/src/test/resources/application.properties @@ -14,51 +14,6 @@ # limitations under the License. # -info.build.artifact=@project.artifactId@ -info.build.name=@project.name@ -info.build.description=@project.description@ -info.build.version=@project.version@ -info.build.groupId=@project.groupId@ -logging.level.root=info - -server.contextPath=/ -server.servlet-path=/ -spring.jersey.application-path=/api/controller-blueprints/v1 -server.routingPath=/api - -mots.application.acronym=MOTS_ID -platform.identifier=AJSC7_JERSEY -#spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration - -#logging.pattern.console=%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr($ threadId: {PID:- }){magenta} %clr(---){faint} %clr([ hostname: %X{hostname} serviceName: %X{serviceName} version: %X{version} transactionId: %X{transactionId} requestTimeStamp: %X{requestTimestamp} responseTimeStamp: %X{responseTimestamp} duration: %X{duration}]){yellow} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex - -#The max number of active threads in this pool -server.tomcat.max-threads=200 -#The minimum number of threads always kept alive -server.tomcat.min-Spare-Threads=25 -#The number of milliseconds before an idle thread shutsdown, unless the number of active threads are less or equal to minSpareThreads -server.tomcat.max-idle-time=60000 - -#for changing the tomcat port... -#server.port=8081 - -#Servlet context parameters -server.context_parameters.p-name=value #context parameter with p-name as key and value as value. - -# make this true for AAF authentication and place cadi.properties into etc folder -aaf.enabled=false - -# set to true to enable version proxy -#ivp.enabled=false - -logging.level.org.springframework.web=INFO -logging.level.org.hibernate.SQL=warn -logging.level.org.hibernate.type.descriptor.sql=debug - -spring.jpa.properties.hibernate.show_sql=true -spring.jpa.properties.hibernate.use_sql_comments=true -spring.jpa.properties.hibernate.format_sql=true - #Load Blueprints # blueprints.load.initial-data may be overridden by ENV variables blueprints.load.initial-data=true diff --git a/ms/controllerblueprints/application/src/test/resources/logback.xml b/ms/controllerblueprints/application/src/test/resources/logback.xml new file mode 100644 index 000000000..b9b97dc89 --- /dev/null +++ b/ms/controllerblueprints/application/src/test/resources/logback.xml @@ -0,0 +1,36 @@ + + + + + + + %d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n + + + + + + + + + + + + + + diff --git a/ms/controllerblueprints/modules/core/pom.xml b/ms/controllerblueprints/modules/core/pom.xml index 0e88dd293..fc7581c8c 100644 --- a/ms/controllerblueprints/modules/core/pom.xml +++ b/ms/controllerblueprints/modules/core/pom.xml @@ -29,30 +29,6 @@ Controller Blueprints Core - - org.jetbrains.kotlin - kotlin-stdlib - - - org.jetbrains.kotlin - kotlin-reflect - - - com.fasterxml.jackson.module - jackson-module-kotlin - - - com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.core - jackson-annotations - - - com.fasterxml.jackson.core - jackson-core - com.fasterxml.jackson.dataformat jackson-dataformat-xml @@ -65,44 +41,10 @@ com.fasterxml.jackson.module jackson-module-jsonSchema - - org.apache.commons - commons-lang3 - - - commons-collections - commons-collections - - - commons-io - commons-io - - - com.google.guava - guava - org.yaml snakeyaml - - com.jayway.jsonpath - json-path - - - junit - junit - test - - - org.jetbrains.kotlin - kotlin-test - test - - diff --git a/ms/controllerblueprints/modules/resource-dict/pom.xml b/ms/controllerblueprints/modules/resource-dict/pom.xml index a0d1be611..337f5512f 100644 --- a/ms/controllerblueprints/modules/resource-dict/pom.xml +++ b/ms/controllerblueprints/modules/resource-dict/pom.xml @@ -33,13 +33,6 @@ org.onap.ccsdk.apps controllerblueprints-core - - junit - junit - test - - - diff --git a/ms/controllerblueprints/modules/service/pom.xml b/ms/controllerblueprints/modules/service/pom.xml index 17738bf4b..b4b798e6e 100644 --- a/ms/controllerblueprints/modules/service/pom.xml +++ b/ms/controllerblueprints/modules/service/pom.xml @@ -36,37 +36,17 @@ org.onap.ccsdk.apps controllerblueprints-resource-dict - - org.apache.commons - commons-lang3 - - - commons-collections - commons-collections - - - commons-io - commons-io - org.apache.velocity velocity - - io.swagger - swagger-jersey2-jaxrs - - - org.json - json - org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webflux org.springframework.boot - spring-boot-starter-jersey + spring-boot-starter-web org.springframework.boot diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ServiceExceptionMapper.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ServiceExceptionMapper.java deleted file mode 100644 index f223dccb2..000000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ServiceExceptionMapper.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.service.common; - -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; - -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; -import java.io.PrintWriter; -import java.io.StringWriter; - -@Provider -public class ServiceExceptionMapper implements ExceptionMapper { - - @Override - public Response toResponse(BluePrintException ex) { - ErrorMessage errorMessage = new ErrorMessage(); - errorMessage.setCode(ex.getCode()); - errorMessage.setMessage(ex.getMessage()); - StringWriter errorStackTrace = new StringWriter(); - ex.printStackTrace(new PrintWriter(errorStackTrace)); - errorMessage.setDeveloperMessage(ex.toString()); - return Response.status(500).entity(errorMessage).type(MediaType.APPLICATION_JSON).build(); - } - -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SwaggerGenerator.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SwaggerGenerator.java index e90807633..81f7d7018 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SwaggerGenerator.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SwaggerGenerator.java @@ -1,17 +1,17 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. + * 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 + * 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 + * 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. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.onap.ccsdk.apps.controllerblueprints.service.common; @@ -20,7 +20,6 @@ import io.swagger.models.*; import io.swagger.models.parameters.BodyParameter; import io.swagger.models.parameters.Parameter; import io.swagger.models.properties.*; -import io.swagger.util.Json; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.BooleanUtils; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants; @@ -63,8 +62,7 @@ public class SwaggerGenerator { swagger.setDefinitions(getDefinition()); - swaggerContent = Json.pretty(swagger); - return swaggerContent; + return swagger.toString(); } private Info getInfo() { diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java index 86c89bf90..94324a808 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java @@ -16,164 +16,112 @@ package org.onap.ccsdk.apps.controllerblueprints.service.rs; -import io.swagger.annotations.*; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; -import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate; +import org.onap.ccsdk.apps.controllerblueprints.service.ConfigModelService; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.*; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; import java.util.List; /** - * ConfigModelRest.java Purpose: Rest service controller for ConfigModelRest Management - * - * @author Brinda Santh - * @version 1.0 + * {@inheritDoc} */ -@Api -@Path("/service") -@Produces({MediaType.APPLICATION_JSON}) -public interface ConfigModelRest { +@RestController +@RequestMapping("/api/v1/config-model") +public class ConfigModelRest { - /** - * This is a getConfigModel rest service - * - * @param id - * @return ConfigModel - * @throws BluePrintException - */ - @GET - @Path("/configmodel/{id}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to Search Service Template", response = ConfigModel.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - @RequestMapping(value = "/configmodel/{id}", method = RequestMethod.GET) - @ResponseBody ConfigModel getConfigModel(@ApiParam(required = true) @PathParam("id") Long id) - throws BluePrintException; - + private ConfigModelService configModelService; /** - * This is a saveConfigModel rest service - * - * @param configModel - * @return ConfigModel - * @throws BluePrintException + * This is a ConfigModelRest constructor. + * + * @param configModelService Config Model Service */ - @POST - @Path("/configmodel") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to get Model Type by Tags", response = ServiceTemplate.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - ConfigModel saveConfigModel(@ApiParam(required = true) ConfigModel configModel) - throws BluePrintException; + public ConfigModelRest(ConfigModelService configModelService) { + this.configModelService = configModelService; - /** - * This is a deleteConfigModel rest service - * - * @param id - * @throws BluePrintException - */ - @DELETE - @Path("/configmodel/{id}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to delete ConfigModel.") - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - void deleteConfigModel(@ApiParam(required = true) @PathParam("id") Long id) throws BluePrintException; + } - /** - * This is a getInitialConfigModel rest service - * - * @param name - * @return ConfigModel - * @throws BluePrintException - */ - @GET - @Path("/configmodelinitial/{name}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to create default Service Template", response = ConfigModel.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - ConfigModel getInitialConfigModel(@ApiParam(required = true) @PathParam("name") String name) - throws BluePrintException; + @GetMapping(path = "/initial/{name}") + public @ResponseBody + ConfigModel getInitialConfigModel(@PathVariable(value = "name") String name) throws BluePrintException { + try { + return this.configModelService.getInitialConfigModel(name); + } catch (Exception e) { + throw new BluePrintException(2000, e.getMessage(), e); + } + } - /** - * This is a getCloneConfigModel rest service - * - * @param id - * @return ConfigModel - * @throws BluePrintException - */ - @GET - @Path("/configmodelclone/{id}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to create default Service Template", response = ConfigModel.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - ConfigModel getCloneConfigModel(@ApiParam(required = true) @PathParam("id") Long id) - throws BluePrintException; + @PostMapping(path = "/") + public @ResponseBody + ConfigModel saveConfigModel(@RequestBody ConfigModel configModel) throws BluePrintException { + try { + return this.configModelService.saveConfigModel(configModel); + } catch (Exception e) { + throw new BluePrintException(2200, e.getMessage(), e); + } + } - /** - * This is a publishConfigModel rest service - * - * @param id - * @return ServiceTemplate - * @throws BluePrintException - */ - @GET - @Path("/configmodelpublish/{id}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to get Model Type by Tags", response = ConfigModel.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - ConfigModel publishConfigModel(@ApiParam(required = true) @PathParam("id") Long id) - throws BluePrintException; + @DeleteMapping(path = "/{id}") + public void deleteConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException { + try { + this.configModelService.deleteConfigModel(id); + } catch (Exception e) { + throw new BluePrintException(4000, e.getMessage(), e); + } + } - /** - * This is a getConfigModelByNameAndVersion rest service - * - * @param name - * @param version - * @return ConfigModel - * @throws BluePrintException - */ - @GET - @Path("/configmodelbyname/{name}/version/{version}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to Search Service Template", response = ConfigModel.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - ConfigModel getConfigModelByNameAndVersion(@ApiParam(required = true) @PathParam("name") String name, - @ApiParam(required = true) @PathParam("version") String version) throws BluePrintException; + @GetMapping(path = "/publish/{id}") + public @ResponseBody + ConfigModel publishConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException { + try { + return this.configModelService.publishConfigModel(id); + } catch (Exception e) { + throw new BluePrintException(2500, e.getMessage(), e); + } + } - /** - * This is a searchServiceModels rest service - * - * @param tags - * @return List - * @throws BluePrintException - */ - @GET - @Path("/configmodelsearch/{tags}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to Search Service Template", response = ConfigModel.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - List searchConfigModels(@ApiParam(required = true) @PathParam("tags") String tags) - throws BluePrintException; + @GetMapping(path = "/{id}") + public @ResponseBody + ConfigModel getConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException { + try { + return this.configModelService.getConfigModel(id); + } catch (Exception e) { + throw new BluePrintException(2001, e.getMessage(), e); + } + } + + @GetMapping(path = "/by-name/{name}/version/{version}") + public @ResponseBody + ConfigModel getConfigModelByNameAndVersion(@PathVariable(value = "name") String name, + @PathVariable(value = "version") String version) throws BluePrintException { + try { + return this.configModelService.getConfigModelByNameAndVersion(name, version); + } catch (Exception e) { + throw new BluePrintException(2002, e.getMessage(), e); + } + } + + @GetMapping(path = "/search/{tags}") + public @ResponseBody + List searchConfigModels(@PathVariable(value = "tags") String tags) throws BluePrintException { + try { + return this.configModelService.searchConfigModels(tags); + } catch (Exception e) { + throw new BluePrintException(2003, e.getMessage(), e); + } + } + + @GetMapping(path = "/clone/{id}") + public @ResponseBody + ConfigModel getCloneConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException { + try { + return this.configModelService.getCloneConfigModel(id); + } catch (Exception e) { + throw new BluePrintException(2004, e.getMessage(), e); + } + } } diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestImpl.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestImpl.java deleted file mode 100644 index a9abcd5ff..000000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestImpl.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.service.rs; - -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; -import org.onap.ccsdk.apps.controllerblueprints.service.ConfigModelService; -import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * {@inheritDoc} - */ -@Service -public class ConfigModelRestImpl implements ConfigModelRest { - - private ConfigModelService configModelService; - - /** - * This is a ConfigModelRestImpl constructor. - * - * @param configModelService Config Model Service - */ - public ConfigModelRestImpl(ConfigModelService configModelService) { - this.configModelService = configModelService; - - } - - @Override - public ConfigModel getInitialConfigModel(String name) throws BluePrintException { - try { - return this.configModelService.getInitialConfigModel(name); - } catch (Exception e) { - throw new BluePrintException(2000, e.getMessage(), e); - } - } - - @Override - public ConfigModel saveConfigModel(ConfigModel configModel) throws BluePrintException { - try { - return this.configModelService.saveConfigModel(configModel); - } catch (Exception e) { - throw new BluePrintException(2200, e.getMessage(), e); - } - } - - @Override - public void deleteConfigModel(Long id) throws BluePrintException { - try { - this.configModelService.deleteConfigModel(id); - } catch (Exception e) { - throw new BluePrintException(4000, e.getMessage(), e); - } - } - - @Override - public ConfigModel publishConfigModel(Long id) throws BluePrintException { - try { - return this.configModelService.publishConfigModel(id); - } catch (Exception e) { - throw new BluePrintException(2500, e.getMessage(), e); - } - } - - @Override - public ConfigModel getConfigModel(Long id) throws BluePrintException { - try { - return this.configModelService.getConfigModel(id); - } catch (Exception e) { - throw new BluePrintException(2001, e.getMessage(), e); - } - } - - @Override - public ConfigModel getConfigModelByNameAndVersion(String name, String version) throws BluePrintException { - try { - return this.configModelService.getConfigModelByNameAndVersion(name, version); - } catch (Exception e) { - throw new BluePrintException(2002, e.getMessage(), e); - } - } - - @Override - public List searchConfigModels(String tags) throws BluePrintException { - try { - return this.configModelService.searchConfigModels(tags); - } catch (Exception e) { - throw new BluePrintException(2003, e.getMessage(), e); - } - } - - @Override - public ConfigModel getCloneConfigModel(Long id) throws BluePrintException { - try { - return this.configModelService.getCloneConfigModel(id); - } catch (Exception e) { - throw new BluePrintException(2004, e.getMessage(), e); - } - } - -} diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java index 59b730309..2fa64316f 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java @@ -16,110 +16,77 @@ package org.onap.ccsdk.apps.controllerblueprints.service.rs; -import io.swagger.annotations.*; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; +import org.onap.ccsdk.apps.controllerblueprints.service.ModelTypeService; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.*; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; import java.util.List; /** - * ModelTypeRest.java Purpose: Rest service controller for Artifact Handling - * - * @author Brinda Santh - * @version 1.0 + * {@inheritDoc} */ -@Api -@Path("/service") -@Produces({MediaType.APPLICATION_JSON}) -public interface ModelTypeRest { +@RestController +@RequestMapping("/api/v1/model-type") +public class ModelTypeRest { - /** - * This is a getModelTypeByName rest service - * - * @param name - * @return ModelType - * @throws BluePrintException - */ - @GET - @Path("/modeltype/{name}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to get Model Type by id", response = ModelType.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - ModelType getModelTypeByName(@ApiParam(required = true) @PathParam("name") String name) - throws BluePrintException; + private ModelTypeService modelTypeService; /** - * This is a saveModelType rest service - * - * @param modelType - * @return ModelType - * @throws BluePrintException + * This is a ModelTypeResourceImpl, used to save and get the model types stored in database + * + * @param modelTypeService Model Type Service */ + public ModelTypeRest(ModelTypeService modelTypeService) { + this.modelTypeService = modelTypeService; + } - @POST - @Path("/modeltype") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to Save Model Type", response = ModelType.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - ModelType saveModelType(@ApiParam(required = true) ModelType modelType) throws BluePrintException; + @GetMapping(path = "/{name}") + public ModelType getModelTypeByName(@PathVariable(value = "name") String name) throws BluePrintException { + try { + return modelTypeService.getModelTypeByName(name); + } catch (Exception e) { + throw new BluePrintException(1000, e.getMessage(), e); + } + } - /** - * This is a deleteModelType rest service - * - * @param name - * @throws BluePrintException - */ - @DELETE - @Path("/modeltype/{name}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to delete Model Type") - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - void deleteModelTypeByName(@ApiParam(required = true) @PathParam("name") String name) - throws BluePrintException; + @GetMapping(path = "/search/{tags}") + public List searchModelTypes(@PathVariable(value = "tags") String tags) throws BluePrintException { + try { + return modelTypeService.searchModelTypes(tags); + } catch (Exception e) { + throw new BluePrintException(1001, e.getMessage(), e); + } + } - /** - * This is a searchModelType rest service - * - * @param tags - * @return List - * @throws BluePrintException - */ - @GET - @Path("/modeltypesearch/{tags}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to get Model Type by tags", response = ModelType.class, - responseContainer = "List") - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - List searchModelTypes(@ApiParam(required = true) @PathParam("tags") String tags) - throws BluePrintException; + @GetMapping(path = "/by-definition/{definitionType}") + public @ResponseBody + List getModelTypeByDefinitionType(@PathVariable(value = "definitionType") String definitionType) throws BluePrintException { + try { + return modelTypeService.getModelTypeByDefinitionType(definitionType); + } catch (Exception e) { + throw new BluePrintException(1002, e.getMessage(), e); + } + } - /** - * This is a getModelTypeByDefinitionType rest service - * - * @param definitionType - * @return List - * @throws BluePrintException - */ - @GET - @Path("/modeltypebydefinition/{definitionType}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to get Model Type by tags", response = ModelType.class, - responseContainer = "List") - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - List getModelTypeByDefinitionType( - @ApiParam(required = true) @PathParam("definitionType") String definitionType) - throws BluePrintException; + @PostMapping(path = "/") + public @ResponseBody + ModelType saveModelType(@RequestBody ModelType modelType) throws BluePrintException { + try { + return modelTypeService.saveModel(modelType); + } catch (Exception e) { + throw new BluePrintException(1100, e.getMessage(), e); + } + } + @DeleteMapping(path = "/{name}") + public void deleteModelTypeByName(@PathVariable(value = "name") String name) throws BluePrintException { + try { + modelTypeService.deleteByModelName(name); + } catch (Exception e) { + throw new BluePrintException(1400, e.getMessage(), e); + } + } } diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestImpl.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestImpl.java deleted file mode 100644 index 6fbc69699..000000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestImpl.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.service.rs; - -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; -import org.onap.ccsdk.apps.controllerblueprints.service.ModelTypeService; -import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * {@inheritDoc} - */ -@Service -public class ModelTypeRestImpl implements ModelTypeRest { - - private ModelTypeService modelTypeService; - - /** - * This is a ModelTypeResourceImpl, used to save and get the model types stored in database - * - * @param modelTypeService Model Type Service - */ - public ModelTypeRestImpl(ModelTypeService modelTypeService) { - this.modelTypeService = modelTypeService; - } - - @Override - public ModelType getModelTypeByName(String modelName) throws BluePrintException { - try { - return modelTypeService.getModelTypeByName(modelName); - } catch (Exception e) { - throw new BluePrintException(1000, e.getMessage(), e); - } - } - - @Override - public List searchModelTypes(String tags) throws BluePrintException { - try { - return modelTypeService.searchModelTypes(tags); - } catch (Exception e) { - throw new BluePrintException(1001, e.getMessage(), e); - } - } - - @Override - public List getModelTypeByDefinitionType(String definitionType) throws BluePrintException { - try { - return modelTypeService.getModelTypeByDefinitionType(definitionType); - } catch (Exception e) { - throw new BluePrintException(1002, e.getMessage(), e); - } - } - - @Override - public ModelType saveModelType(ModelType modelType) throws BluePrintException { - try { - return modelTypeService.saveModel(modelType); - } catch (Exception e) { - throw new BluePrintException(1100, e.getMessage(), e); - } - } - - @Override - public void deleteModelTypeByName(String name) throws BluePrintException { - try { - modelTypeService.deleteByModelName(name); - } catch (Exception e) { - throw new BluePrintException(1400, e.getMessage(), e); - } - } -} diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java index 5bc983363..dfb06bba5 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java @@ -16,111 +16,83 @@ package org.onap.ccsdk.apps.controllerblueprints.service.rs; -import io.swagger.annotations.*; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; +import org.onap.ccsdk.apps.controllerblueprints.service.ResourceDictionaryService; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.*; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; import java.util.List; /** - * ResourceDictionaryRest.java Purpose: Rest service controller for Artifact Handling - * - * @author Brinda Santh - * @version 1.0 + * {@inheritDoc} */ -@Api -@Path("/service") -@Produces({MediaType.APPLICATION_JSON}) +@RestController +@RequestMapping(value = "/api/v1/dictionary") +public class ResourceDictionaryRest { -public interface ResourceDictionaryRest { - /** - * This is a getDataDictionaryByPath rest service - * - * @param name - * @return ResourceDictionary - * @throws BluePrintException - */ - @GET - @Path("/dictionary/{name}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to get Resource dictionary", response = ResourceDictionary.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - ResourceDictionary getResourceDictionaryByName(@ApiParam(required = true) @PathParam("name") String name) - throws BluePrintException; + private ResourceDictionaryService resourceDictionaryService; /** - * This is a saveDataDictionary rest service - * - * @param resourceMapping - * @return ResourceDictionary - * @throws BluePrintException + * This is a DataDictionaryRestImpl, used to save and get the Resource Mapping stored in database + * + * @param dataDictionaryService Data Dictionary Service */ + public ResourceDictionaryRest(ResourceDictionaryService dataDictionaryService) { + this.resourceDictionaryService = dataDictionaryService; + } - @POST - @Path("/dictionary") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to Save Resource dictionary Type", response = ResourceDictionary.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - ResourceDictionary saveResourceDictionary(@ApiParam(required = true) ResourceDictionary resourceMapping) - throws BluePrintException; + @PostMapping(path = "/") + public @ResponseBody + ResourceDictionary saveResourceDictionary(@RequestBody ResourceDictionary dataDictionary) + throws BluePrintException { + try { + return resourceDictionaryService.saveResourceDictionary(dataDictionary); + } catch (Exception e) { + throw new BluePrintException(4100, e.getMessage(), e); + } + } - /** - * This is a deleteDataDictionaryByName rest service - * - * @param name - * @throws BluePrintException - */ - @DELETE - @Path("/dictionary/{name}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to delete ResourceDictionary Type") - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - void deleteResourceDictionaryByName(@ApiParam(required = true) @PathParam("name") String name) - throws BluePrintException; + @DeleteMapping(path = "/{name}") + public void deleteResourceDictionaryByName(@PathVariable(value = "name") String name) throws BluePrintException { + try { + resourceDictionaryService.deleteResourceDictionary(name); + } catch (Exception e) { + throw new BluePrintException(4400, e.getMessage(), e); + } + } - /** - * This is a searchResourceDictionaryByTags rest service - * - * @param tags - * @return ResourceDictionary - * @throws BluePrintException - */ - @GET - @Path("/dictionarysearch/{tags}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to search Resource dictionary by tags", - response = ResourceDictionary.class, responseContainer = "List") - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - List searchResourceDictionaryByTags( - @ApiParam(required = true) @PathParam("tags") String tags) throws BluePrintException; + @GetMapping(path = "/{name}") + public @ResponseBody + ResourceDictionary getResourceDictionaryByName(@PathVariable(value = "name") String name) throws BluePrintException { + try { + return resourceDictionaryService.getResourceDictionaryByName(name); + } catch (Exception e) { + throw new BluePrintException(4001, e.getMessage(), e); + } + } - /** - * This is a searchResourceDictionaryByNames rest service - * - * @param names - * @return List - * @throws BluePrintException - */ - @POST - @Path("/dictionarybynames") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to get ResourceDictionary Type by names", - response = ResourceDictionary.class, responseContainer = "List") - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - List searchResourceDictionaryByNames(@ApiParam(required = true) List names) - throws BluePrintException; + @PostMapping(path = "/by-names") + public @ResponseBody + List searchResourceDictionaryByNames(@RequestBody List names) + throws BluePrintException { + try { + return resourceDictionaryService.searchResourceDictionaryByNames(names); + } catch (Exception e) { + throw new BluePrintException(4002, e.getMessage(), e); + } + } + + @GetMapping(path = "/search/{tags}") + public @ResponseBody + List searchResourceDictionaryByTags(@PathVariable(value = "tags") String tags) throws BluePrintException { + try { + return resourceDictionaryService.searchResourceDictionaryByTags(tags); + } catch (Exception e) { + throw new BluePrintException(4003, e.getMessage(), e); + } + } } diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestImpl.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestImpl.java deleted file mode 100644 index e3448424d..000000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestImpl.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.service.rs; - -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; -import org.onap.ccsdk.apps.controllerblueprints.service.ResourceDictionaryService; -import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * {@inheritDoc} - */ -@Service -public class ResourceDictionaryRestImpl implements ResourceDictionaryRest { - - - private ResourceDictionaryService resourceDictionaryService; - - /** - * This is a DataDictionaryRestImpl, used to save and get the Resource Mapping stored in database - * - * @param dataDictionaryService Data Dictionary Service - */ - public ResourceDictionaryRestImpl(ResourceDictionaryService dataDictionaryService) { - this.resourceDictionaryService = dataDictionaryService; - } - - @Override - public ResourceDictionary saveResourceDictionary(ResourceDictionary dataDictionary) - throws BluePrintException { - try { - return resourceDictionaryService.saveResourceDictionary(dataDictionary); - } catch (Exception e) { - throw new BluePrintException(4100, e.getMessage(), e); - } - } - - @Override - public void deleteResourceDictionaryByName(String name) throws BluePrintException { - try { - resourceDictionaryService.deleteResourceDictionary(name); - } catch (Exception e) { - throw new BluePrintException(4400, e.getMessage(), e); - } - } - - @Override - public ResourceDictionary getResourceDictionaryByName(String resourcePath) throws BluePrintException { - try { - return resourceDictionaryService.getResourceDictionaryByName(resourcePath); - } catch (Exception e) { - throw new BluePrintException(4001, e.getMessage(), e); - } - } - - @Override - public List searchResourceDictionaryByNames(List names) - throws BluePrintException { - try { - return resourceDictionaryService.searchResourceDictionaryByNames(names); - } catch (Exception e) { - throw new BluePrintException(4002, e.getMessage(), e); - } - } - - @Override - public List searchResourceDictionaryByTags(String tags) throws BluePrintException { - try { - return resourceDictionaryService.searchResourceDictionaryByTags(tags); - } catch (Exception e) { - throw new BluePrintException(4003, e.getMessage(), e); - } - } - -} diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java index fcb8f3119..d8ea1941b 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java @@ -16,119 +16,87 @@ package org.onap.ccsdk.apps.controllerblueprints.service.rs; -import io.swagger.annotations.*; + import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate; import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment; +import org.onap.ccsdk.apps.controllerblueprints.service.ServiceTemplateService; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent; import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.*; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; import java.util.List; - /** - * ServiceTemplateRest.java Purpose: ServiceTemplateRest interface - * - * @author Brinda Santh - * @version 1.0 + * {@inheritDoc} */ +@RestController +@RequestMapping(value = "/api/v1/service-template") +public class ServiceTemplateRest { -@Api -@Path("/service") -@Produces({MediaType.APPLICATION_JSON}) -public interface ServiceTemplateRest { + private ServiceTemplateService serviceTemplateService; /** - * This is a enrichServiceTemplate rest service - * - * @param serviceTemplate - * @return ServiceTemplate - * @throws BluePrintException + * This is a ServiceTemplateRest constructor + * + * @param serviceTemplateService Service Template Service */ - @POST - @Path("/servicetemplate/enrich") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to enrich service template", response = ServiceTemplate.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - ServiceTemplate enrichServiceTemplate(@ApiParam(required = true) ServiceTemplate serviceTemplate) - throws BluePrintException; + public ServiceTemplateRest(ServiceTemplateService serviceTemplateService) { + this.serviceTemplateService = serviceTemplateService; + } - /** - * This is a validateServiceTemplate rest service - * - * @param serviceTemplate - * @return ServiceTemplate - * @throws BluePrintException - */ - @POST - @Path("/servicetemplate/validate") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to validate service template", response = ServiceTemplate.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - ServiceTemplate validateServiceTemplate(@ApiParam(required = true) ServiceTemplate serviceTemplate) - throws BluePrintException; + @PostMapping(path = "/enrich") + public @ResponseBody + ServiceTemplate enrichServiceTemplate(@RequestBody ServiceTemplate serviceTemplate) throws BluePrintException { + try { + return serviceTemplateService.enrichServiceTemplate(serviceTemplate); + } catch (Exception e) { + throw new BluePrintException(3500, e.getMessage(), e); + } + } - /** - * This is a generateResourceAssignments rest service - * - * @param templateContent - * @return List - * @throws BluePrintException - */ - @POST - @Path("/resourceassignment/generate") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to auto map for the Resource Mapping", - response = ResourceAssignment.class, responseContainer = "List") - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - List generateResourceAssignments( - @ApiParam(required = true) ConfigModelContent templateContent) throws BluePrintException; + @PostMapping(path = "/validate") + public @ResponseBody + ServiceTemplate validateServiceTemplate(@RequestBody ServiceTemplate serviceTemplate) throws BluePrintException { + try { + return serviceTemplateService.validateServiceTemplate(serviceTemplate); + } catch (Exception e) { + throw new BluePrintException(3501, e.getMessage(), e); + } + } - /** - * This is a autoMap rest service - * - * @param resourceAssignments - * @return AutoMapResponse - * @throws BluePrintException - */ - @POST - @Path("/resourceassignment/automap") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to auto map for the Resource assignments", - response = AutoMapResponse.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - AutoMapResponse autoMap(@ApiParam(required = true) List resourceAssignments) - throws BluePrintException; + @PostMapping(path = "/resource-assignment/auto-map") + public @ResponseBody + AutoMapResponse autoMap(@RequestBody List resourceAssignments) throws BluePrintException { + try { + return serviceTemplateService.autoMap(resourceAssignments); + } catch (Exception e) { + throw new BluePrintException(3502, e.getMessage(), e); + } + } - /** - * This is a validateResourceAssignments rest service - * - * @param resourceAssignments - * @return List - * @throws BluePrintException - */ - @POST - @Path("/resourceassignment/validate") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to validate Resource assignments", response = ResourceAssignment.class, - responseContainer = "List") - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - List validateResourceAssignments( - @ApiParam(required = true) List resourceAssignments) throws BluePrintException; + @PostMapping(path = "/resource-assignment/validate") + public @ResponseBody + List validateResourceAssignments(@RequestBody List resourceAssignments) + throws BluePrintException { + try { + return serviceTemplateService.validateResourceAssignments(resourceAssignments); + } catch (Exception e) { + throw new BluePrintException(3503, e.getMessage(), e); + } + } + + @PostMapping(path = "/resource-assignment/generate") + public @ResponseBody + List generateResourceAssignments(@RequestBody ConfigModelContent templateContent) + throws BluePrintException { + try { + return serviceTemplateService.generateResourceAssignments(templateContent); + } catch (Exception e) { + throw new BluePrintException(3504, e.getMessage(), e); + } + } } diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestImpl.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestImpl.java deleted file mode 100644 index 6c49d5c65..000000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestImpl.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.service.rs; - - -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; -import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate; -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment; -import org.onap.ccsdk.apps.controllerblueprints.service.ServiceTemplateService; -import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent; -import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * {@inheritDoc} - */ -@Service -public class ServiceTemplateRestImpl implements ServiceTemplateRest { - - private ServiceTemplateService serviceTemplateService; - - /** - * This is a ServiceTemplateRestImpl constructor - * - * @param serviceTemplateService Service Template Service - */ - public ServiceTemplateRestImpl(ServiceTemplateService serviceTemplateService) { - this.serviceTemplateService = serviceTemplateService; - } - - @Override - public ServiceTemplate enrichServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException { - try { - return serviceTemplateService.enrichServiceTemplate(serviceTemplate); - } catch (Exception e) { - throw new BluePrintException(3500, e.getMessage(), e); - } - } - - @Override - public ServiceTemplate validateServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException { - try { - return serviceTemplateService.validateServiceTemplate(serviceTemplate); - } catch (Exception e) { - throw new BluePrintException(3501, e.getMessage(), e); - } - } - - @Override - public AutoMapResponse autoMap(List resourceAssignments) throws BluePrintException { - try { - return serviceTemplateService.autoMap(resourceAssignments); - } catch (Exception e) { - throw new BluePrintException(3502, e.getMessage(), e); - } - } - - @Override - public List validateResourceAssignments(List resourceAssignments) - throws BluePrintException { - try { - return serviceTemplateService.validateResourceAssignments(resourceAssignments); - } catch (Exception e) { - throw new BluePrintException(3503, e.getMessage(), e); - } - } - - @Override - public List generateResourceAssignments(ConfigModelContent templateContent) - throws BluePrintException { - try { - return serviceTemplateService.generateResourceAssignments(templateContent); - } catch (Exception e) { - throw new BluePrintException(3504, e.getMessage(), e); - } - } - -} diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/JerseyConfiguration.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/JerseyConfiguration.java deleted file mode 100644 index f5535eb12..000000000 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/JerseyConfiguration.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.MapperFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import org.glassfish.jersey.logging.LoggingFeature; -import org.glassfish.jersey.server.ResourceConfig; -import org.glassfish.jersey.servlet.ServletProperties; -import org.onap.ccsdk.apps.controllerblueprints.service.common.ServiceExceptionMapper; -import org.onap.ccsdk.apps.controllerblueprints.service.rs.ConfigModelRestImpl; -import org.onap.ccsdk.apps.controllerblueprints.service.rs.ModelTypeRestImpl; -import org.onap.ccsdk.apps.controllerblueprints.service.rs.ResourceDictionaryRestImpl; -import org.onap.ccsdk.apps.controllerblueprints.service.rs.ServiceTemplateRestImpl; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Primary; -import org.springframework.stereotype.Component; - -import java.util.logging.Logger; - - -@Component -public class JerseyConfiguration extends ResourceConfig { - private static final Logger log = Logger.getLogger(JerseyConfiguration.class.getName()); - - @Bean - @Primary - public ObjectMapper objectMapper() { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); - objectMapper.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES); - objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); - objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); - return objectMapper; - } - - @Autowired - public JerseyConfiguration() { - register(ConfigModelRestImpl.class); - register(ModelTypeRestImpl.class); - register(ResourceDictionaryRestImpl.class); - register(ServiceTemplateRestImpl.class); - // Exception Mapping - register(ServiceExceptionMapper.class); - property(ServletProperties.FILTER_FORWARD_ON_404, true); - register(new LoggingFeature(log)); - } - - -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/TestConfiguration.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/TestConfiguration.java deleted file mode 100644 index ea259c9c9..000000000 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/TestConfiguration.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints; - -import org.springframework.context.annotation.Bean; - -import java.util.ArrayList; - -//@Configuration -public class TestConfiguration { - - @Bean("jaxrsProviders") - public ArrayList provider() { - return new ArrayList(); - } - - @Bean("jaxrsServices") - public ArrayList service() { - return new ArrayList(); - } - -} diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestTest.java index 5b10a7e86..a4a787b08 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestTest.java @@ -20,7 +20,6 @@ import org.junit.*; import org.junit.runner.RunWith; import org.junit.runners.MethodSorters; import org.onap.ccsdk.apps.controllerblueprints.TestApplication; -import org.onap.ccsdk.apps.controllerblueprints.TestConfiguration; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel; import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils; import org.slf4j.Logger; @@ -35,7 +34,7 @@ import java.util.List; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@ContextConfiguration(classes = {TestApplication.class, TestConfiguration.class}) +@ContextConfiguration(classes = {TestApplication.class}) @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class ConfigModelRestTest { @@ -68,7 +67,6 @@ public class ConfigModelRestTest { ConfigModel configModel = configModelRest.getInitialConfigModel(name); Assert.assertNotNull("Failed to get Initial Config Model , Return object is Null", configModel); Assert.assertNotNull("Failed to get Service Template Content ", configModel.getConfigModelContents()); - } diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java index d33349c53..d328b3eac 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java @@ -21,7 +21,6 @@ import org.junit.*; import org.junit.runner.RunWith; import org.junit.runners.MethodSorters; import org.onap.ccsdk.apps.controllerblueprints.TestApplication; -import org.onap.ccsdk.apps.controllerblueprints.TestConfiguration; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType; import org.slf4j.Logger; @@ -38,7 +37,7 @@ import java.util.List; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@ContextConfiguration(classes = {TestApplication.class, TestConfiguration.class}) +@ContextConfiguration(classes = {TestApplication.class}) @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class ModelTypeRestTest { private static Logger log = LoggerFactory.getLogger(ModelTypeRestTest.class); diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java index 71dff338b..afe9b426f 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java @@ -24,7 +24,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.MethodSorters; import org.onap.ccsdk.apps.controllerblueprints.TestApplication; -import org.onap.ccsdk.apps.controllerblueprints.TestConfiguration; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,7 +40,7 @@ import java.util.List; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@ContextConfiguration(classes = {TestApplication.class, TestConfiguration.class}) +@ContextConfiguration(classes = {TestApplication.class}) @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class ResourceDictionaryRestTest { diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java index f81dd4165..fdc68e4e5 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java @@ -24,7 +24,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.MethodSorters; import org.onap.ccsdk.apps.controllerblueprints.TestApplication; -import org.onap.ccsdk.apps.controllerblueprints.TestConfiguration; import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant; import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate; import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; @@ -46,7 +45,7 @@ import java.util.List; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@ContextConfiguration(classes = {TestApplication.class, TestConfiguration.class}) +@ContextConfiguration(classes = {TestApplication.class}) @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class ServiceTemplateRestTest { diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index 0b19186d5..f8977d1f3 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -27,17 +27,19 @@ pom UTF-8 + UTF-8 1.8 1.8 - 1.2.51 - 200.4.2-RELEASE - 2.4.2-RELEASE - 1.4.2 - 1.5.7.RELEASE - 20.0.1-SNAPSHOT + 1.8 + 2.0.4.RELEASE + 1.2.60 + 1.0.0 + 2.9.2 + 1.4.197 + org.springframework.boot spring-boot-dependencies @@ -46,6 +48,24 @@ import + + com.att.eelf + eelf-core + ${eelf.version} + + + + + io.springfox + springfox-swagger2 + ${springfox.swagger2.version} + + + io.springfox + springfox-swagger-ui + ${springfox.swagger2.version} + + org.apache.commons commons-lang3 @@ -66,33 +86,12 @@ velocity 1.7 - - org.json - json - 20180130 - com.google.guava guava 25.1-jre - - io.swagger - swagger-jersey2-jaxrs - 1.5.20 - - - org.glassfish.jersey.containers - * - - - org.glassfish.jersey.core - * - - - - org.jetbrains.kotlin @@ -105,9 +104,17 @@ ${kotlin.version} - com.fasterxml.jackson.module - jackson-module-kotlin - 2.9.6 + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + + + + + + com.h2database + h2 + ${h2database.version} org.jetbrains.kotlin @@ -134,10 +141,65 @@ + + com.att.eelf + eelf-core + + + org.apache.commons + commons-lang3 + 3.2.1 + + + commons-collections + commons-collections + 3.2.2 + + + commons-io + commons-io + 2.6 + + + com.jayway.jsonpath + json-path + + + io.springfox + springfox-swagger2 + + + io.springfox + springfox-swagger-ui + org.jetbrains.kotlin kotlin-stdlib + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + + + com.fasterxml.jackson.module + jackson-module-kotlin + + + + junit + junit + test + + + org.jetbrains.kotlin + kotlin-test + test + + + io.projectreactor + reactor-test + test + -- cgit 1.2.3-korg