From 1cd99ed17a0d034ef8e54a7ac3dc059871dc7a1a Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Wed, 3 Jul 2024 09:31:01 -0400 Subject: Resolve build issues Build was failing due to issues missed in port to java 17. Updated sdnc/apps to change dependencies from javax.* to jakarta.* - required for Java 17. Also, latest version of snakeyaml cannot handle size of yaml based SDNC swagger, so replaced that with JSON based version. Issue-ID: SDNC-1843 Change-Id: I4df872481c56aea496de0d2b9cc349799ff6b60c Signed-off-by: Dan Timoney --- ms/gra/gra-app/src/main/templates/api.mustache | 57 +++++++++++----------- .../src/main/templates/apiOriginFilter.mustache | 38 +++++++++++++++ 2 files changed, 66 insertions(+), 29 deletions(-) create mode 100644 ms/gra/gra-app/src/main/templates/apiOriginFilter.mustache (limited to 'ms/gra/gra-app/src/main/templates') diff --git a/ms/gra/gra-app/src/main/templates/api.mustache b/ms/gra/gra-app/src/main/templates/api.mustache index c28642c..91483ed 100644 --- a/ms/gra/gra-app/src/main/templates/api.mustache +++ b/ms/gra/gra-app/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/gra/gra-app/src/main/templates/apiOriginFilter.mustache b/ms/gra/gra-app/src/main/templates/apiOriginFilter.mustache new file mode 100644 index 0000000..3910a6b --- /dev/null +++ b/ms/gra/gra-app/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 { + } +} -- cgit 1.2.3-korg