* ============LICENSE_START=======================================================
* Copyright (C) 2019-2021,2023 Nordix Foundation.
* Modifications Copyright (C) 2019-2021 AT&T Intellectual Property.
- * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021-2023 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
return true;
}
- if (exceptionClazz.isInstance(thrown)) {
- if (isDuplicateKeyException(thrown.getCause(), exceptionClazz)) {
- return true;
- }
+ if (exceptionClazz.isInstance(thrown) && isDuplicateKeyException(thrown.getCause(), exceptionClazz)) {
+ return true;
}
thrown = thrown.getCause();
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2023 Nordix Foundation.
* Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property.
- * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021, 2023 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@Profile("default")
public class PdpGroupStateChangeControllerV1 extends PapRestControllerV1 implements PdpGroupStateChangeControllerV1Api {
- private static final Logger logger = LoggerFactory.getLogger(PdpGroupHealthCheckControllerV1.class);
+ private static final Logger logger = LoggerFactory.getLogger(PdpGroupStateChangeControllerV1.class);
private final PdpGroupStateChangeProvider provider;
/**
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023 Bell Canada.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@Profile("stub")
class StubUtils {
private static final Logger log = LoggerFactory.getLogger(StubUtils.class);
+ private static final String APPLICATION_JSON = "application/json";
+ private static final String SERIALIZE_RESPONSE_FAILURE_MSG =
+ "Couldn't serialize response for content type application/json";
private final HttpServletRequest request;
private static final String ACCEPT = "Accept";
private static final String PAP_DB =
<T> ResponseEntity<T> getStubbedResponse(Class<T> clazz) {
var accept = request.getHeader(ACCEPT);
- if (accept != null && accept.contains("application/json")) {
+ if (accept != null && accept.contains(APPLICATION_JSON)) {
final var resource = new ClassPathResource(PAP_DB);
try (var inputStream = resource.getInputStream()) {
final var string = new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
var targetObject = JSON_TRANSLATOR.fromJson(string, clazz);
return new ResponseEntity<>(targetObject, HttpStatus.OK);
} catch (IOException e) {
- log.error("Couldn't serialize response for content type application/json", e);
+ log.error(SERIALIZE_RESPONSE_FAILURE_MSG, e);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
<T> ResponseEntity<List<T>> getStubbedResponseList(Class<T> clazz) {
var accept = request.getHeader(ACCEPT);
- if (accept != null && accept.contains("application/json")) {
+ if (accept != null && accept.contains(APPLICATION_JSON)) {
final var resource = new ClassPathResource(PAP_DB);
try (var inputStream = resource.getInputStream()) {
final var string = new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
var targetObject = Arrays.asList(JSON_TRANSLATOR.fromJson(string, clazz));
return new ResponseEntity<>(targetObject, HttpStatus.OK);
} catch (IOException e) {
- log.error("Couldn't serialize response for content type application/json", e);
+ log.error(SERIALIZE_RESPONSE_FAILURE_MSG, e);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
ResponseEntity<Map<String, Object>> getStubbedResponseMap() {
var accept = request.getHeader(ACCEPT);
- if (accept != null && accept.contains("application/json")) {
+ if (accept != null && accept.contains(APPLICATION_JSON)) {
final var resource = new ClassPathResource(PAP_DB);
try (var inputStream = resource.getInputStream()) {
Map<String, Object> map = new HashMap<>();
JSON_TRANSLATOR.fromJson(string, Object.class));
return new ResponseEntity<>(map, HttpStatus.OK);
} catch (IOException e) {
- log.error("Couldn't serialize response for content type application/json", e);
+ log.error(SERIALIZE_RESPONSE_FAILURE_MSG, e);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
ResponseEntity<Map<String, Map<String, List<PdpStatistics>>>> getStubbedResponseStatistics() {
var accept = request.getHeader(ACCEPT);
- if (accept != null && accept.contains("application/json")) {
+ if (accept != null && accept.contains(APPLICATION_JSON)) {
Map<String, Map<String, List<PdpStatistics>>> map = new HashMap<>();
return new ResponseEntity<>(map, HttpStatus.OK);
}