aboutsummaryrefslogtreecommitdiffstats
path: root/ms/sliboot/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'ms/sliboot/src/main')
-rw-r--r--ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/FilterConfiguration.java2
-rw-r--r--ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/SlibootApp.java2
-rw-r--r--ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/controllers/RestconfApiController.java4
-rw-r--r--ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/data/TestResultConfig.java2
-rw-r--r--ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/data/TestResultOperational.java2
-rw-r--r--ms/sliboot/src/main/templates/api.mustache57
-rw-r--r--ms/sliboot/src/main/templates/apiOriginFilter.mustache38
-rw-r--r--ms/sliboot/src/main/templates/libraries/spring-boot/swagger2SpringBoot.mustache50
-rw-r--r--ms/sliboot/src/main/templates/libraries/spring-mvc/swaggerUiConfiguration.mustache96
9 files changed, 218 insertions, 35 deletions
diff --git a/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/FilterConfiguration.java b/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/FilterConfiguration.java
index 295953a4..ebacc049 100644
--- a/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/FilterConfiguration.java
+++ b/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/FilterConfiguration.java
@@ -5,7 +5,7 @@ import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;
-import org.onap.aaf.cadi.filter.CadiFilter;
+import org.onap.ccsdk.apps.cadi.filter.CadiFilter;
import org.onap.ccsdk.sli.core.utils.common.EnvProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/SlibootApp.java b/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/SlibootApp.java
index 0fd23a9e..e393dd0c 100644
--- a/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/SlibootApp.java
+++ b/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/SlibootApp.java
@@ -35,7 +35,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import org.springframework.context.annotation.Bean;
-import org.onap.aaf.cadi.filter.CadiFilter;
+import org.onap.ccsdk.apps.cadi.filter.CadiFilter;
@SpringBootApplication(scanBasePackages={ "org.onap.ccsdk.apps.ms.sliboot.*", "org.onap.ccsdk.apps.services" })
@EnableJpaRepositories("org.onap.ccsdk.apps.ms.sliboot.*")
diff --git a/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/controllers/RestconfApiController.java b/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/controllers/RestconfApiController.java
index 44981845..2383fe69 100644
--- a/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/controllers/RestconfApiController.java
+++ b/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/controllers/RestconfApiController.java
@@ -47,8 +47,8 @@ import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
-import javax.servlet.http.HttpServletRequest;
-import javax.validation.Valid;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.validation.Valid;
import java.util.*;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2020-02-20T12:50:11.207-05:00")
diff --git a/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/data/TestResultConfig.java b/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/data/TestResultConfig.java
index 1ca4fe1f..8081d6ac 100644
--- a/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/data/TestResultConfig.java
+++ b/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/data/TestResultConfig.java
@@ -1,6 +1,6 @@
package org.onap.ccsdk.apps.ms.sliboot.data;
-import javax.persistence.*;
+import jakarta.persistence.*;
@Entity(name = "TEST_RESULT_CONFIG")
@Table(name = "TEST_RESULT_CONFIG")
diff --git a/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/data/TestResultOperational.java b/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/data/TestResultOperational.java
index b9d09934..ab3aedb5 100644
--- a/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/data/TestResultOperational.java
+++ b/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/data/TestResultOperational.java
@@ -1,6 +1,6 @@
package org.onap.ccsdk.apps.ms.sliboot.data;
-import javax.persistence.*;
+import jakarta.persistence.*;
@Entity(name="TEST_RESULT_OPERATIONAL")
@Table(name="TEST_RESULT_OPERATIONAL")
diff --git a/ms/sliboot/src/main/templates/api.mustache b/ms/sliboot/src/main/templates/api.mustache
index c28642cf..91483eda 100644
--- a/ms/sliboot/src/main/templates/api.mustache
+++ b/ms/sliboot/src/main/templates/api.mustache
@@ -7,15 +7,11 @@ package {{package}};
{{#imports}}import {{import}};
{{/imports}}
-{{#jdk8-no-delegate}}
- import com.fasterxml.jackson.databind.ObjectMapper;
-{{/jdk8-no-delegate}}
+import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.*;
-{{#jdk8-no-delegate}}
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.http.HttpStatus;
-{{/jdk8-no-delegate}}
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
{{#useBeanValidation}}
import org.springframework.validation.annotation.Validated;
@@ -30,33 +26,37 @@ import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import org.onap.ccsdk.apps.services.RestException;
-{{#jdk8-no-delegate}}
- import javax.servlet.http.HttpServletRequest;
-{{/jdk8-no-delegate}}
+
+{{#jakarta}}
+import jakarta.servlet.*;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+{{/jakarta}}
+{{^jakarta}}
+import javax.servlet.*;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+{{/jakarta}}
{{#useBeanValidation}}
- import javax.validation.Valid;
- import javax.validation.constraints.*;
+{{#jakarta}}
+import jakarta.validation.Valid;
+import jakarta.validation.constraints.*;
+{{/jakarta}}
+{{^jakarta}}
+import javax.validation.Valid;
+import javax.validation.constraints.*;
+{{/jakarta}}
{{/useBeanValidation}}
-{{#jdk8-no-delegate}}
- import java.io.IOException;
-{{/jdk8-no-delegate}}
+import java.io.IOException;
import java.util.List;
-{{#jdk8-no-delegate}}
- import java.util.Optional;
-{{/jdk8-no-delegate}}
-{{^jdk8-no-delegate}}
- {{#useOptional}}
- import java.util.Optional;
- {{/useOptional}}
-{{/jdk8-no-delegate}}
+import java.util.Optional;
{{#async}}
- import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture{{/jdk8}};
+import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture{{/jdk8}};
{{/async}}
{{>generatedAnnotation}}
@Api(value = "{{{baseName}}}", description = "the {{{baseName}}} API")
{{#operations}}
public interface {{classname}} {
- {{#jdk8}}
{{^isDelegate}}
Logger log = LoggerFactory.getLogger({{classname}}.class);
@@ -76,7 +76,6 @@ import java.util.List;
{{#isDelegate}}
{{classname}}Delegate getDelegate();
{{/isDelegate}}
- {{/jdk8}}
{{#operation}}
@ApiOperation(value = "{{{summary}}}", nickname = "{{{operationId}}}", notes = "{{{notes}}}"{{#returnBaseType}}, response = {{{returnBaseType}}}.class{{/returnBaseType}}{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = {
@@ -101,7 +100,7 @@ import java.util.List;
produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}{{#hasConsumes}}
consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}{{/singleContentTypes}}
method = RequestMethod.{{httpMethod}})
- {{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{#delegate-method}}_{{/delegate-method}}{{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}){{^jdk8}};{{/jdk8}}{{#jdk8}} throws RestException {
+ default {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{#delegate-method}}_{{/delegate-method}}{{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}) throws RestException {
{{#delegate-method}}
return {{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
}
@@ -129,7 +128,7 @@ import java.util.List;
{{#isDelegate}}
return getDelegate().{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
{{/isDelegate}}
- }{{/jdk8}}
+ }
{{/operation}}
}
diff --git a/ms/sliboot/src/main/templates/apiOriginFilter.mustache b/ms/sliboot/src/main/templates/apiOriginFilter.mustache
new file mode 100644
index 00000000..3910a6b8
--- /dev/null
+++ b/ms/sliboot/src/main/templates/apiOriginFilter.mustache
@@ -0,0 +1,38 @@
+package {{apiPackage}};
+
+import java.io.IOException;
+
+{{#jakarta}}
+import jakarta.servlet.*;
+import jakarta.servlet.http.HttpServletResponse;
+{{/jakarta}}
+{{^jakarta}}
+import javax.servlet.*;
+import javax.servlet.http.HttpServletResponse;
+{{/jakarta}}
+
+{{>generatedAnnotation}}
+{{#jakarta}}
+public class ApiOriginFilter implements jakarta.servlet.Filter {
+{{/jakarta}}
+{{^jakarta}}
+public class ApiOriginFilter implements javax.servlet.Filter {
+{{/jakarta}}
+ @Override
+ public void doFilter(ServletRequest request, ServletResponse response,
+ FilterChain chain) throws IOException, ServletException {
+ HttpServletResponse res = (HttpServletResponse) response;
+ res.addHeader("Access-Control-Allow-Origin", "*");
+ res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
+ res.addHeader("Access-Control-Allow-Headers", "Content-Type");
+ chain.doFilter(request, response);
+ }
+
+ @Override
+ public void destroy() {
+ }
+
+ @Override
+ public void init(FilterConfig filterConfig) throws ServletException {
+ }
+}
diff --git a/ms/sliboot/src/main/templates/libraries/spring-boot/swagger2SpringBoot.mustache b/ms/sliboot/src/main/templates/libraries/spring-boot/swagger2SpringBoot.mustache
new file mode 100644
index 00000000..5f1d0f00
--- /dev/null
+++ b/ms/sliboot/src/main/templates/libraries/spring-boot/swagger2SpringBoot.mustache
@@ -0,0 +1,50 @@
+package {{basePackage}};
+
+import {{configPackage}}.LocalDateConverter;
+import {{configPackage}}.LocalDateTimeConverter;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.boot.ExitCodeGenerator;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.format.FormatterRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+@SpringBootApplication
+@EnableSwagger2
+@ComponentScan(basePackages = { "{{basePackage}}", "{{apiPackage}}" , "{{configPackage}}"})
+public class Swagger2SpringBoot implements CommandLineRunner {
+
+ @Override
+ public void run(String... arg0) throws Exception {
+ if (arg0.length > 0 && arg0[0].equals("exitcode")) {
+ throw new ExitException();
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ new SpringApplication(Swagger2SpringBoot.class).run(args);
+ }
+
+ @Configuration
+ static class MyConfig implements WebMvcConfigurer {
+ @Override
+ public void addFormatters(FormatterRegistry registry) {
+ registry.addConverter(new LocalDateConverter("{{#datePattern}}{{datePattern}}{{/datePattern}}{{^datePattern}}yyyy-MM-dd{{/datePattern}}"));
+ registry.addConverter(new LocalDateTimeConverter("{{#dateTimePattern}}{{dateTimePattern}}{{/dateTimePattern}}{{^dateTimePattern}}yyyy-MM-dd'T'HH:mm:ss.SSS{{/dateTimePattern}}"));
+ }
+ }
+
+ class ExitException extends RuntimeException implements ExitCodeGenerator {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public int getExitCode() {
+ return 10;
+ }
+
+ }
+}
diff --git a/ms/sliboot/src/main/templates/libraries/spring-mvc/swaggerUiConfiguration.mustache b/ms/sliboot/src/main/templates/libraries/spring-mvc/swaggerUiConfiguration.mustache
new file mode 100644
index 00000000..de7ccaf7
--- /dev/null
+++ b/ms/sliboot/src/main/templates/libraries/spring-mvc/swaggerUiConfiguration.mustache
@@ -0,0 +1,96 @@
+package {{configPackage}};
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+{{#threetenbp}}
+import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule;
+{{/threetenbp}}
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.context.annotation.Import;
+import org.springframework.context.annotation.Bean;
+import org.springframework.format.FormatterRegistry;
+import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
+import org.springframework.web.servlet.config.annotation.EnableWebMvc;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+{{#threetenbp}}
+import org.threeten.bp.Instant;
+import org.threeten.bp.OffsetDateTime;
+import org.threeten.bp.ZonedDateTime;
+{{/threetenbp}}
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+import java.util.List;
+
+{{>generatedAnnotation}}
+@Configuration
+@ComponentScan(basePackages = "{{apiPackage}}")
+@EnableWebMvc
+@EnableSwagger2 //Loads the spring beans required by the framework
+@PropertySource("classpath:swagger.properties")
+@Import(SwaggerDocumentationConfig.class)
+public class SwaggerUiConfiguration implements WebMvcConfigurer {
+ private static final String[] SERVLET_RESOURCE_LOCATIONS = { "/" };
+
+ private static final String[] CLASSPATH_RESOURCE_LOCATIONS = {
+ "classpath:/META-INF/resources/", "classpath:/resources/",
+ "classpath:/static/", "classpath:/public/" };
+
+ private static final String[] RESOURCE_LOCATIONS;
+ static {
+ RESOURCE_LOCATIONS = new String[CLASSPATH_RESOURCE_LOCATIONS.length
+ + SERVLET_RESOURCE_LOCATIONS.length];
+ System.arraycopy(SERVLET_RESOURCE_LOCATIONS, 0, RESOURCE_LOCATIONS, 0,
+ SERVLET_RESOURCE_LOCATIONS.length);
+ System.arraycopy(CLASSPATH_RESOURCE_LOCATIONS, 0, RESOURCE_LOCATIONS,
+ SERVLET_RESOURCE_LOCATIONS.length, CLASSPATH_RESOURCE_LOCATIONS.length);
+ }
+
+ private static final String[] STATIC_INDEX_HTML_RESOURCES;
+ static {
+ STATIC_INDEX_HTML_RESOURCES = new String[RESOURCE_LOCATIONS.length];
+ for (int i = 0; i < STATIC_INDEX_HTML_RESOURCES.length; i++) {
+ STATIC_INDEX_HTML_RESOURCES[i] = RESOURCE_LOCATIONS[i] + "index.html";
+ }
+ }
+
+ @Override
+ public void addResourceHandlers(ResourceHandlerRegistry registry) {
+ if (!registry.hasMappingForPattern("/webjars/**")) {
+ registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
+ }
+ if (!registry.hasMappingForPattern("/**")) {
+ registry.addResourceHandler("/**").addResourceLocations(RESOURCE_LOCATIONS);
+ }
+ }
+
+ @Bean
+ public Jackson2ObjectMapperBuilder builder() {
+ Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder()
+ .indentOutput(true)
+ .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
+ .dateFormat(new RFC3339DateFormat());
+ return builder;
+ }
+
+ @Override
+ public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
+ converters.add(new MappingJackson2HttpMessageConverter(objectMapper()));
+ super.configureMessageConverters(converters);
+ }
+
+ @Override
+ public void addFormatters(FormatterRegistry registry) {
+ registry.addConverter(new LocalDateConverter("{{#datePattern}}{{datePattern}}{{/datePattern}}{{^datePattern}}yyyy-MM-dd{{/datePattern}}"));
+ registry.addConverter(new LocalDateTimeConverter("{{#dateTimePattern}}{{dateTimePattern}}{{/dateTimePattern}}{{^dateTimePattern}}yyyy-MM-dd'T'HH:mm:ss.SSS{{/dateTimePattern}}"));
+ }
+
+ @Bean
+ public ObjectMapper objectMapper(){
+ return builder().build();
+ }
+}