diff --git a/legal-core/src/main/java/org/opengroup/osdu/legal/middleware/GlobalExceptionMapper.java b/legal-core/src/main/java/org/opengroup/osdu/legal/middleware/GlobalExceptionMapper.java index 0d4cde968d369f394d316aa480fe1312ac41913b..2730e644394f91d2bcb1557fb815d18596103fbf 100644 --- a/legal-core/src/main/java/org/opengroup/osdu/legal/middleware/GlobalExceptionMapper.java +++ b/legal-core/src/main/java/org/opengroup/osdu/legal/middleware/GlobalExceptionMapper.java @@ -14,22 +14,21 @@ package org.opengroup.osdu.legal.middleware; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.google.gson.Gson; import java.util.ArrayList; -import java.util.Collections; import java.util.List; - +import javassist.NotFoundException; +import javax.inject.Inject; import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolationException; import javax.validation.ValidationException; -import javax.inject.Inject; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException; - -import com.google.gson.Gson; -import javassist.NotFoundException; -import javax.ws.rs.core.MediaType; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; +import org.opengroup.osdu.core.common.model.http.AppException; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; import org.springframework.http.HttpHeaders; @@ -39,19 +38,11 @@ import org.springframework.lang.NonNull; import org.springframework.security.access.AccessDeniedException; import org.springframework.web.HttpRequestMethodNotSupportedException; import org.springframework.web.bind.MethodArgumentNotValidException; -import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.context.request.WebRequest; import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; -import org.opengroup.osdu.core.common.model.http.AppException; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; - @Order(Ordered.HIGHEST_PRECEDENCE) @RestControllerAdvice public class GlobalExceptionMapper extends ResponseEntityExceptionHandler { @@ -122,7 +113,6 @@ public class GlobalExceptionMapper extends ResponseEntityExceptionHandler { "An unknown error has occurred.")); } - @Override @NonNull protected ResponseEntity<Object> handleHttpRequestMethodNotSupported(@NonNull HttpRequestMethodNotSupportedException e, @@ -145,7 +135,6 @@ public class GlobalExceptionMapper extends ResponseEntityExceptionHandler { "Validation failed.", e)); } - public ResponseEntity<Object> getErrorResponse(AppException e) { String exceptionMsg = e.getError().getMessage(); diff --git a/legal-core/src/main/java/org/opengroup/osdu/legal/middleware/GlobalOtherExceptionMapper.java b/legal-core/src/main/java/org/opengroup/osdu/legal/middleware/GlobalOtherExceptionMapper.java index 1625f0a1302a65a2b24304372bb2ff28d1082b90..ae763156fbbc750e7547daadecaf8fae7a45f5d9 100644 --- a/legal-core/src/main/java/org/opengroup/osdu/legal/middleware/GlobalOtherExceptionMapper.java +++ b/legal-core/src/main/java/org/opengroup/osdu/legal/middleware/GlobalOtherExceptionMapper.java @@ -17,24 +17,23 @@ package org.opengroup.osdu.legal.middleware; import org.opengroup.osdu.core.common.model.http.AppException; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; @RestControllerAdvice public class GlobalOtherExceptionMapper { - private GlobalExceptionMapper mapper; + private GlobalExceptionMapper mapper; - public GlobalOtherExceptionMapper(GlobalExceptionMapper mapper) { - this.mapper = mapper; - } + public GlobalOtherExceptionMapper(GlobalExceptionMapper mapper) { + this.mapper = mapper; + } - @ExceptionHandler(Exception.class) - protected ResponseEntity<Object> handleGeneralException(Exception e) { - return mapper.getErrorResponse( - new AppException(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Server error.", - "An unknown error has occurred.", e)); - } + @ExceptionHandler(Exception.class) + protected ResponseEntity<Object> handleGeneralException(Exception e) { + return mapper.getErrorResponse( + new AppException(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Server error.", + "An unknown error has occurred.", e)); + } } diff --git a/testing/legal-test-core/src/main/java/org/opengroup/osdu/legal/util/AcceptanceBaseTest.java b/testing/legal-test-core/src/main/java/org/opengroup/osdu/legal/util/AcceptanceBaseTest.java index d973e66d239532a5d6611d62f297fe74f9572cf4..12b72e4f4e89d81f6607971b12443a3eeecb4139 100644 --- a/testing/legal-test-core/src/main/java/org/opengroup/osdu/legal/util/AcceptanceBaseTest.java +++ b/testing/legal-test-core/src/main/java/org/opengroup/osdu/legal/util/AcceptanceBaseTest.java @@ -5,14 +5,10 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.opengroup.osdu.legal.util.Constants.DATA_PARTITION_ID; -import com.sun.jersey.core.header.MediaTypes; +import com.sun.jersey.api.client.ClientResponse; import java.util.HashMap; import java.util.Map; - -import com.sun.jersey.api.client.ClientResponse; - import java.util.Objects; -import javax.ws.rs.core.MediaType; import lombok.extern.java.Log; import org.junit.Test; diff --git a/testing/legal-test-core/src/main/java/org/opengroup/osdu/legal/util/TestUtils.java b/testing/legal-test-core/src/main/java/org/opengroup/osdu/legal/util/TestUtils.java index 587e9ae5fd0e5b72ae3aa3e9aeaa72095a73af89..e61a6934736e6bdcd3e64eee597bcb97371b862b 100644 --- a/testing/legal-test-core/src/main/java/org/opengroup/osdu/legal/util/TestUtils.java +++ b/testing/legal-test-core/src/main/java/org/opengroup/osdu/legal/util/TestUtils.java @@ -82,8 +82,6 @@ public class TestUtils { String query, Map<String, String> headers) throws Exception { Client client = getClient(); - // client.setConnectTimeout(5000); - // client.setReadTimeout(30000); WebResource webResource = client.resource(getApiPath(path + query)); final WebResource.Builder builder = webResource.getRequestBuilder();