diff --git a/partition-core/src/main/java/org/opengroup/osdu/partition/middleware/GlobalExceptionMapper.java b/partition-core/src/main/java/org/opengroup/osdu/partition/middleware/GlobalExceptionMapper.java index 8251084022b19856932b2da827d6b3fa8454b018..a9ba86e2aaef0c18cc0fa5a3d08b4c3f10860912 100644 --- a/partition-core/src/main/java/org/opengroup/osdu/partition/middleware/GlobalExceptionMapper.java +++ b/partition-core/src/main/java/org/opengroup/osdu/partition/middleware/GlobalExceptionMapper.java @@ -28,8 +28,6 @@ import com.google.gson.Gson; import javassist.NotFoundException; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; import org.springframework.beans.factory.annotation.Autowired; -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.ResponseEntity; @@ -55,7 +53,7 @@ public class GlobalExceptionMapper extends ResponseEntityExceptionHandler { private static final Gson gson = new Gson(); @Autowired - private JaxRsDpsLog logger; + private JaxRsDpsLog jaxRsDpsLogger; @ExceptionHandler(AppException.class) protected ResponseEntity<Object> handleAppException(AppException e) { @@ -94,7 +92,7 @@ public class GlobalExceptionMapper extends ResponseEntityExceptionHandler { @ExceptionHandler(ConstraintViolationException.class) protected ResponseEntity<Object> handleConstraintValidationException(ConstraintViolationException e) { - logger.error("Validation exception", e); + jaxRsDpsLogger.error("Validation exception", e); List<String> msgs = new ArrayList<>(); for (ConstraintViolation<?> violation : e.getConstraintViolations()) { @@ -134,9 +132,9 @@ public class GlobalExceptionMapper extends ResponseEntityExceptionHandler { String exceptionMsg = e.getError().getMessage(); if (e.getError().getCode() > 499) { - this.logger.error(exceptionMsg, e); + this.jaxRsDpsLogger.error(exceptionMsg, e); } else { - this.logger.warning(exceptionMsg, e); + this.jaxRsDpsLogger.warning(exceptionMsg, e); } return new ResponseEntity<>(gson.toJson(exceptionMsg), HttpStatus.resolve(e.getError().getCode())); diff --git a/partition-core/src/test/java/org/opengroup/osdu/partition/api/PartitionApiTest.java b/partition-core/src/test/java/org/opengroup/osdu/partition/api/PartitionApiTest.java index 60286821afcb6700e56cba95ae84d4c5ffa365ea..cfa29ed1851c2a20e0974f0fb7eb134ea6ea5a74 100644 --- a/partition-core/src/test/java/org/opengroup/osdu/partition/api/PartitionApiTest.java +++ b/partition-core/src/test/java/org/opengroup/osdu/partition/api/PartitionApiTest.java @@ -82,6 +82,9 @@ public class PartitionApiTest { public void should_return204_when_givenUpdatingValidPartitionId() { String partitionId = "partition1"; this.sut.patch(partitionId, partitionInfo); + + ResponseEntity<Map<String, Property>> result = this.sut.get(partitionId); + assertEquals(HttpStatus.OK, result.getStatusCode()); } @Test diff --git a/provider/partition-aws/src/main/java/org/opengroup/osdu/partition/provider/aws/security/AuthorizationService.java b/provider/partition-aws/src/main/java/org/opengroup/osdu/partition/provider/aws/security/AuthorizationService.java index 41eb71d2e136be1858d06a3e931f28ad49d88e3f..ef2329e9f3c60aeec1bafb6da1840582daf500c5 100644 --- a/provider/partition-aws/src/main/java/org/opengroup/osdu/partition/provider/aws/security/AuthorizationService.java +++ b/provider/partition-aws/src/main/java/org/opengroup/osdu/partition/provider/aws/security/AuthorizationService.java @@ -79,19 +79,13 @@ public class AuthorizationService implements IAuthorizationService { memberEmail = headers.getUserId(); - if(memberEmail != null) - { - if(memberEmail.equals(spu_email)){ - return true; - } - else{ - throw AppException.createUnauthorized("Unauthorized. The user is not Service Principal"); - } - } if(memberEmail == null){ throw AppException.createUnauthorized("Unauthorized. The JWT token could not be validated"); + } else if(memberEmail.equals(spu_email)){ + return true; + } else{ + throw AppException.createUnauthorized("Unauthorized. The user is not Service Principal"); } - } catch (AppException appE) { throw appE; @@ -99,11 +93,7 @@ public class AuthorizationService implements IAuthorizationService { catch (Exception e) { throw new AppException(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Authentication Failure", e.getMessage(), e); } - return false; } - - - }