diff options
Diffstat (limited to 'services')
5 files changed, 92 insertions, 62 deletions
diff --git a/services/pom.xml b/services/pom.xml index 10ccb51d..9665b22f 100644 --- a/services/pom.xml +++ b/services/pom.xml @@ -16,9 +16,9 @@ <name>ccsdk-apps :: services :: ${project.artifactId}</name> <properties> - <shiro.version>1.5.0</shiro.version> - <aaf-shiro-bundle.version>2.1.13</aaf-shiro-bundle.version> <ccsdk.project.version>${project.version}</ccsdk.project.version> + <maven.compiler.source>1.11</maven.compiler.source> + <maven.compiler.target>1.11</maven.compiler.target> <ccsdk.build.timestamp>${maven.build.timestamp}</ccsdk.build.timestamp> <maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format> <logging.analytics.version>1.6.9</logging.analytics.version> @@ -29,6 +29,18 @@ <groupId>io.swagger</groupId> <artifactId>swagger-annotations</artifactId> </dependency> + + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + <exclusions> + <exclusion> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-log4j2</artifactId> @@ -51,10 +63,16 @@ </dependency> <dependency> <groupId>io.springfox</groupId> - <artifactId>springfox-boot-starter</artifactId> + <artifactId>springfox-swagger2</artifactId> <version>${springfox.version}</version> </dependency> <dependency> + <groupId>io.springfox</groupId> + <artifactId>springfox-swagger-ui</artifactId> + <version>${springfox.version}</version> + </dependency> + + <dependency> <groupId>org.onap.ccsdk.sli.core</groupId> <artifactId>dblib-provider</artifactId> <version>${ccsdk.sli.core.version}</version> diff --git a/services/src/main/java/org/onap/ccsdk/apps/filters/ContentTypeFilter.java b/services/src/main/java/org/onap/ccsdk/apps/filters/ContentTypeFilter.java index f2f638f6..a700b152 100644 --- a/services/src/main/java/org/onap/ccsdk/apps/filters/ContentTypeFilter.java +++ b/services/src/main/java/org/onap/ccsdk/apps/filters/ContentTypeFilter.java @@ -7,13 +7,14 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequestWrapper; +import jakarta.servlet.Filter; +import jakarta.servlet.FilterChain; +import jakarta.servlet.FilterConfig; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequestWrapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -145,6 +146,15 @@ public class ContentTypeFilter implements Filter { } } + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + } + + @Override + public void destroy() { + + } } diff --git a/services/src/main/java/org/onap/ccsdk/apps/filters/PayloadLoggingFilter.java b/services/src/main/java/org/onap/ccsdk/apps/filters/PayloadLoggingFilter.java index dd591fb7..892cbe63 100644 --- a/services/src/main/java/org/onap/ccsdk/apps/filters/PayloadLoggingFilter.java +++ b/services/src/main/java/org/onap/ccsdk/apps/filters/PayloadLoggingFilter.java @@ -16,20 +16,20 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ReadListener; -import javax.servlet.ServletException; -import javax.servlet.ServletInputStream; -import javax.servlet.ServletOutputStream; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.WriteListener; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequestWrapper; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpServletResponseWrapper; +import jakarta.servlet.Filter; +import jakarta.servlet.FilterChain; +import jakarta.servlet.FilterConfig; +import jakarta.servlet.ReadListener; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletInputStream; +import jakarta.servlet.ServletOutputStream; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.WriteListener; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequestWrapper; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletResponseWrapper; import org.onap.logging.filter.base.AbstractServletFilter; import org.slf4j.Logger; @@ -271,9 +271,8 @@ public class PayloadLoggingFilter extends AbstractServletFilter implements Filte @SuppressWarnings("deprecation") @Override - public void setStatus(int sc, String sm) { - super.setStatus(sc, sm); - statusMessage = sm; + public void setStatus(int sc) { + super.setStatus(sc); } public Response getMessageResponse() { diff --git a/services/src/main/java/org/onap/ccsdk/apps/services/RestExceptionHandler.java b/services/src/main/java/org/onap/ccsdk/apps/services/RestExceptionHandler.java index c517f402..8912368c 100644 --- a/services/src/main/java/org/onap/ccsdk/apps/services/RestExceptionHandler.java +++ b/services/src/main/java/org/onap/ccsdk/apps/services/RestExceptionHandler.java @@ -7,6 +7,7 @@ import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; +import org.springframework.http.HttpStatusCode; import org.springframework.http.ResponseEntity; import org.springframework.http.converter.HttpMessageNotReadableException; import org.springframework.http.converter.HttpMessageNotWritableException; @@ -29,89 +30,90 @@ import org.springframework.web.servlet.NoHandlerFoundException; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; @Order(Ordered.HIGHEST_PRECEDENCE) @RestControllerAdvice public class RestExceptionHandler extends ResponseEntityExceptionHandler { + @Override - protected ResponseEntity<Object> handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + protected ResponseEntity<Object> handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return createResponseEntity(new RestProtocolError("bad-method", "Method not supported", ex), status); } @Override - protected ResponseEntity<Object> handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + protected ResponseEntity<Object> handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return createResponseEntity(new RestProtocolError("bad-media-type", "Media type not supported", ex), status); } @Override - protected ResponseEntity<Object> handleHttpMediaTypeNotAcceptable(HttpMediaTypeNotAcceptableException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + protected ResponseEntity<Object> handleHttpMediaTypeNotAcceptable(HttpMediaTypeNotAcceptableException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return createResponseEntity(new RestProtocolError("bad-media-type", "Media type not acceptable", ex), status); } @Override - protected ResponseEntity<Object> handleMissingPathVariable(MissingPathVariableException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + protected ResponseEntity<Object> handleMissingPathVariable(MissingPathVariableException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return createResponseEntity(new RestApplicationError("missing-path", "Missing path variable", ex), status); } @Override - protected ResponseEntity<Object> handleMissingServletRequestParameter(MissingServletRequestParameterException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + protected ResponseEntity<Object> handleMissingServletRequestParameter(MissingServletRequestParameterException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return createResponseEntity(new RestProtocolError("missing-param", "Missing servlet request parameter", ex), status); } @Override - protected ResponseEntity<Object> handleServletRequestBindingException(ServletRequestBindingException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + protected ResponseEntity<Object> handleServletRequestBindingException(ServletRequestBindingException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return createResponseEntity(new RestApplicationError("request-binding", "Servlet binding exception", ex), status); } @Override - protected ResponseEntity<Object> handleConversionNotSupported(ConversionNotSupportedException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + protected ResponseEntity<Object> handleConversionNotSupported(ConversionNotSupportedException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return createResponseEntity(new RestApplicationError("conversion", "Conversion not supported", ex), status); } @Override - protected ResponseEntity<Object> handleTypeMismatch(TypeMismatchException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + protected ResponseEntity<Object> handleTypeMismatch(TypeMismatchException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return createResponseEntity(new RestProtocolError("type-mismatch", "Type mismatch", ex), status); } @Override - protected ResponseEntity<Object> handleHttpMessageNotReadable(HttpMessageNotReadableException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + protected ResponseEntity<Object> handleHttpMessageNotReadable(HttpMessageNotReadableException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return createResponseEntity(new RestProtocolError("bad-message", "HTTP message not readable", ex), status); } @Override - protected ResponseEntity<Object> handleHttpMessageNotWritable(HttpMessageNotWritableException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + protected ResponseEntity<Object> handleHttpMessageNotWritable(HttpMessageNotWritableException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return createResponseEntity(new RestProtocolError("bad-message", "HTTP message not writable", ex), status); } @Override - protected ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + protected ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return createResponseEntity(new RestProtocolError("bad-message", "Method argument not valid", ex), status); } @Override - protected ResponseEntity<Object> handleMissingServletRequestPart(MissingServletRequestPartException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + protected ResponseEntity<Object> handleMissingServletRequestPart(MissingServletRequestPartException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return createResponseEntity(new RestProtocolError("bad-message", "Missing servlet request part", ex), status); } @Override - protected ResponseEntity<Object> handleBindException(BindException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + protected ResponseEntity<Object> handleBindException(BindException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return createResponseEntity(new RestApplicationError("binding-error", "Missing servlet request part", ex), status); } @Override - protected ResponseEntity<Object> handleNoHandlerFoundException(NoHandlerFoundException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + protected ResponseEntity<Object> handleNoHandlerFoundException(NoHandlerFoundException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return createResponseEntity(new RestApplicationError("binding-error", "No handler found", ex), status); } @Override - protected ResponseEntity<Object> handleAsyncRequestTimeoutException(AsyncRequestTimeoutException ex, HttpHeaders headers, HttpStatus status, WebRequest webRequest) { + protected ResponseEntity<Object> handleAsyncRequestTimeoutException(AsyncRequestTimeoutException ex, HttpHeaders headers, HttpStatusCode status, WebRequest webRequest) { return createResponseEntity(new RestApplicationError("timeout", "Async request timeout", ex), status); } @Override - protected ResponseEntity<Object> handleExceptionInternal(Exception ex, Object body, HttpHeaders headers, HttpStatus status, WebRequest request) { + protected ResponseEntity<Object> handleExceptionInternal(Exception ex, Object body, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return createResponseEntity(new RestApplicationError("internal-error", "Internal error", ex), status); } @@ -121,10 +123,10 @@ public class RestExceptionHandler extends ResponseEntityExceptionHandler { if (request != null) { error.setErrorPath(request.getServletPath()); } - return createResponseEntity(error,HttpStatus.valueOf(ex.getStatus())); + return createResponseEntity(error,HttpStatusCode.valueOf(ex.getStatus())); } - private ResponseEntity<Object> createResponseEntity(RestError restError, HttpStatus status) { + private ResponseEntity<Object> createResponseEntity(RestError restError, HttpStatusCode status) { return new ResponseEntity<>(new RestErrors(restError), status); } diff --git a/services/src/test/java/org/onap/ccsdk/apps/services/RestExceptionHandlerTest.java b/services/src/test/java/org/onap/ccsdk/apps/services/RestExceptionHandlerTest.java index 242a6015..b733af9b 100644 --- a/services/src/test/java/org/onap/ccsdk/apps/services/RestExceptionHandlerTest.java +++ b/services/src/test/java/org/onap/ccsdk/apps/services/RestExceptionHandlerTest.java @@ -11,6 +11,7 @@ import org.springframework.beans.TypeMismatchException; import org.springframework.core.MethodParameter; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; +import org.springframework.http.HttpStatusCode; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.http.converter.HttpMessageNotReadableException; @@ -39,82 +40,82 @@ public class RestExceptionHandlerTest { private static final Logger log = LoggerFactory.getLogger("RestExceptionHandler"); private class RestExceptionHandlerWrapper extends RestExceptionHandler { @Override - public ResponseEntity<Object> handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + public ResponseEntity<Object> handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return super.handleHttpRequestMethodNotSupported(ex, headers, status, request); } @Override - public ResponseEntity<Object> handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + public ResponseEntity<Object> handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return super.handleHttpMediaTypeNotSupported(ex, headers, status, request); } @Override - public ResponseEntity<Object> handleHttpMediaTypeNotAcceptable(HttpMediaTypeNotAcceptableException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + public ResponseEntity<Object> handleHttpMediaTypeNotAcceptable(HttpMediaTypeNotAcceptableException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return super.handleHttpMediaTypeNotAcceptable(ex, headers, status, request); } @Override - protected ResponseEntity<Object> handleMissingPathVariable(MissingPathVariableException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + protected ResponseEntity<Object> handleMissingPathVariable(MissingPathVariableException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return super.handleMissingPathVariable(ex, headers, status, request); } @Override - public ResponseEntity<Object> handleMissingServletRequestParameter(MissingServletRequestParameterException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + public ResponseEntity<Object> handleMissingServletRequestParameter(MissingServletRequestParameterException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return super.handleMissingServletRequestParameter(ex, headers, status, request); } @Override - public ResponseEntity<Object> handleServletRequestBindingException(ServletRequestBindingException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + public ResponseEntity<Object> handleServletRequestBindingException(ServletRequestBindingException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return super.handleServletRequestBindingException(ex, headers, status, request); } @Override - public ResponseEntity<Object> handleConversionNotSupported(ConversionNotSupportedException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + public ResponseEntity<Object> handleConversionNotSupported(ConversionNotSupportedException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return super.handleConversionNotSupported(ex, headers, status, request); } @Override - public ResponseEntity<Object> handleTypeMismatch(TypeMismatchException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + public ResponseEntity<Object> handleTypeMismatch(TypeMismatchException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return super.handleTypeMismatch(ex, headers, status, request); } @Override - public ResponseEntity<Object> handleHttpMessageNotReadable(HttpMessageNotReadableException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + public ResponseEntity<Object> handleHttpMessageNotReadable(HttpMessageNotReadableException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return super.handleHttpMessageNotReadable(ex, headers, status, request); } @Override - public ResponseEntity<Object> handleHttpMessageNotWritable(HttpMessageNotWritableException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + public ResponseEntity<Object> handleHttpMessageNotWritable(HttpMessageNotWritableException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return super.handleHttpMessageNotWritable(ex, headers, status, request); } @Override - public ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + public ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return super.handleMethodArgumentNotValid(ex, headers, status, request); } @Override - public ResponseEntity<Object> handleMissingServletRequestPart(MissingServletRequestPartException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + public ResponseEntity<Object> handleMissingServletRequestPart(MissingServletRequestPartException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return super.handleMissingServletRequestPart(ex, headers, status, request); } @Override - public ResponseEntity<Object> handleBindException(BindException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + public ResponseEntity<Object> handleBindException(BindException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return super.handleBindException(ex, headers, status, request); } @Override - public ResponseEntity<Object> handleNoHandlerFoundException(NoHandlerFoundException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + public ResponseEntity<Object> handleNoHandlerFoundException(NoHandlerFoundException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return super.handleNoHandlerFoundException(ex, headers, status, request); } @Override - public ResponseEntity<Object> handleAsyncRequestTimeoutException(AsyncRequestTimeoutException ex, HttpHeaders headers, HttpStatus status, WebRequest webRequest) { + public ResponseEntity<Object> handleAsyncRequestTimeoutException(AsyncRequestTimeoutException ex, HttpHeaders headers, HttpStatusCode status, WebRequest webRequest) { return super.handleAsyncRequestTimeoutException(ex, headers, status, webRequest); } @Override - public ResponseEntity<Object> handleExceptionInternal(Exception ex, Object body, HttpHeaders headers, HttpStatus status, WebRequest request) { + public ResponseEntity<Object> handleExceptionInternal(Exception ex, Object body, HttpHeaders headers, HttpStatusCode status, WebRequest request) { return super.handleExceptionInternal(ex, body, headers, status, request); } } |