aboutsummaryrefslogtreecommitdiffstats
path: root/services/src/main/java/org
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2023-06-19 16:05:33 -0400
committerDan Timoney <dtimoney@att.com>2023-08-10 14:48:32 -0400
commit6a7f13fa7e284cbec5b0743c10fdd33286aaf2ec (patch)
tree42fa7649ca8f912af8d47f35bad4b284369fae9d /services/src/main/java/org
parenta76d3f0de616b542baea9360e80a921f5f028a78 (diff)
Port to java 17
Update to java 17 / springboot 3 to align with OpenDaylight Argon. Copied and ported CADI library from AAF Issue-ID: CCSDK-3917 Signed-off-by: Dan Timoney <dtimoney@att.com> Change-Id: Idecb0cf43c48ccbbc0c61bf4278b87a37f92a56e
Diffstat (limited to 'services/src/main/java/org')
-rw-r--r--services/src/main/java/org/onap/ccsdk/apps/filters/ContentTypeFilter.java24
-rw-r--r--services/src/main/java/org/onap/ccsdk/apps/filters/PayloadLoggingFilter.java33
-rw-r--r--services/src/main/java/org/onap/ccsdk/apps/services/RestExceptionHandler.java40
3 files changed, 54 insertions, 43 deletions
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);
}