From c8c8140398b1d3bd48414026ea57e33a63a46914 Mon Sep 17 00:00:00 2001 From: BKadirkhodjaev Date: Thu, 9 Jan 2025 18:30:22 +0500 Subject: [PATCH] [MODORDERS-1227]. Fix sonar issues --- src/main/java/org/folio/rest/core/RestClient.java | 10 ---------- .../java/org/folio/rest/impl/HoldingsSummaryAPI.java | 4 ---- src/main/java/org/folio/rest/impl/PiecesAPI.java | 3 --- .../pieces/flows/DefaultPieceFlowsValidator.java | 2 +- 4 files changed, 1 insertion(+), 18 deletions(-) diff --git a/src/main/java/org/folio/rest/core/RestClient.java b/src/main/java/org/folio/rest/core/RestClient.java index 4c4598e4e..1fe7b9933 100644 --- a/src/main/java/org/folio/rest/core/RestClient.java +++ b/src/main/java/org/folio/rest/core/RestClient.java @@ -14,7 +14,6 @@ import io.vertx.core.MultiMap; import io.vertx.core.Promise; import io.vertx.core.buffer.Buffer; -import io.vertx.core.http.HttpMethod; import io.vertx.core.json.JsonObject; import io.vertx.ext.web.client.HttpResponse; import io.vertx.ext.web.client.WebClient; @@ -46,7 +45,6 @@ public Future post(RequestEntry requestEntry, T entity, Class response } public Future post(String endpoint, T entity, Class responseType, RequestContext requestContext) { - log.debug("Sending 'POST {}", endpoint); var caseInsensitiveHeader = convertToCaseInsensitiveMap(requestContext.getHeaders()); return getVertxWebClient(requestContext.getContext()).postAbs(buildAbsEndpoint(caseInsensitiveHeader, endpoint)) .putHeaders(caseInsensitiveHeader) @@ -62,7 +60,6 @@ public Future post(String endpoint, T entity, Class responseType, Requ } public Future postEmptyResponse(String endpoint, T entity, RequestContext requestContext) { - log.debug("Sending 'POST {}", () -> endpoint); var caseInsensitiveHeader = convertToCaseInsensitiveMap(requestContext.getHeaders()); return getVertxWebClient(requestContext.getContext()) .postAbs(buildAbsEndpoint(caseInsensitiveHeader, endpoint)) @@ -85,7 +82,6 @@ public Future put(RequestEntry requestEntry, T dataObject, RequestCont } public Future put(String endpoint, T dataObject, RequestContext requestContext) { var recordData = JsonObject.mapFrom(dataObject); - log.debug("Sending 'PUT {}'", endpoint); var caseInsensitiveHeader = convertToCaseInsensitiveMap(requestContext.getHeaders()); return getVertxWebClient(requestContext.getContext()) .putAbs(buildAbsEndpoint(caseInsensitiveHeader, endpoint)) @@ -102,7 +98,6 @@ public Future patch(RequestEntry requestEntry, T dataObject, RequestCon } public Future patch(String endpoint, T dataObject, RequestContext requestContext) { - log.debug("Sending 'PATCH {}'", endpoint); var caseInsensitiveHeader = convertToCaseInsensitiveMap(requestContext.getHeaders()); Promise promise = Promise.promise(); return getVertxWebClient(requestContext.getContext()) @@ -121,7 +116,6 @@ public Future delete(RequestEntry requestEntry, boolean skipError404, Requ } public Future delete(String endpointById, boolean skipError404, RequestContext requestContext) { - log.debug("Sending {} {}", HttpMethod.DELETE, endpointById); var caseInsensitiveHeader = convertToCaseInsensitiveMap(requestContext.getHeaders()); Promise promise = Promise.promise(); getVertxWebClient(requestContext.getContext()) @@ -171,7 +165,6 @@ public Future get(RequestEntry requestEntry, Class responseType, Reque } public Future get(String endpoint, boolean skipError404, Class responseType, RequestContext requestContext) { - log.debug("Calling GET {}", endpoint); var caseInsensitiveHeader = convertToCaseInsensitiveMap(requestContext.getHeaders()); Promise promise = Promise.promise(); getVertxWebClient(requestContext.getContext()) @@ -189,7 +182,6 @@ public Future get(String endpoint, boolean skipError404, Class respons public Future getAsJsonObject(String endpoint, boolean skipError404, RequestContext requestContext) { - log.debug("Calling GET {}", endpoint); Promise promise = Promise.promise(); var caseInsensitiveHeader = convertToCaseInsensitiveMap(requestContext.getHeaders()); var webClient = getVertxWebClient(requestContext.getContext()); @@ -240,7 +232,6 @@ private String buildAbsEndpoint(MultiMap okapiHeaders, String endpoint) { } public Future postJsonObjectAndGetId(RequestEntry requestEntry, JsonObject entity, RequestContext requestContext) { - log.debug("Sending 'POST {}", requestEntry.buildEndpoint()); var caseInsensitiveHeader = convertToCaseInsensitiveMap(requestContext.getHeaders()); return getVertxWebClient(requestContext.getContext()) .postAbs(buildAbsEndpoint(caseInsensitiveHeader, requestEntry.buildEndpoint())) @@ -252,7 +243,6 @@ public Future postJsonObjectAndGetId(RequestEntry requestEntry, JsonObje } public Future postJsonObject(RequestEntry requestEntry, JsonObject jsonObject, RequestContext requestContext) { - log.debug("Sending 'POST {}", requestEntry.buildEndpoint()); var endpoint = requestEntry.buildEndpoint(); var caseInsensitiveHeader = convertToCaseInsensitiveMap(requestContext.getHeaders()); return getVertxWebClient(requestContext.getContext()).postAbs(buildAbsEndpoint(caseInsensitiveHeader, requestEntry.buildEndpoint())) diff --git a/src/main/java/org/folio/rest/impl/HoldingsSummaryAPI.java b/src/main/java/org/folio/rest/impl/HoldingsSummaryAPI.java index 14dcba9d1..c69303647 100644 --- a/src/main/java/org/folio/rest/impl/HoldingsSummaryAPI.java +++ b/src/main/java/org/folio/rest/impl/HoldingsSummaryAPI.java @@ -6,8 +6,6 @@ import javax.ws.rs.core.Response; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.folio.rest.annotations.Validate; import org.folio.rest.core.models.RequestContext; import org.folio.rest.jaxrs.resource.OrdersHoldingSummary; @@ -22,8 +20,6 @@ public class HoldingsSummaryAPI extends BaseApi implements OrdersHoldingSummary { - private static final Logger logger = LogManager.getLogger(); - @Autowired private HoldingsSummaryService holdingsSummaryService; diff --git a/src/main/java/org/folio/rest/impl/PiecesAPI.java b/src/main/java/org/folio/rest/impl/PiecesAPI.java index 9adbb98e4..693cbd1ad 100644 --- a/src/main/java/org/folio/rest/impl/PiecesAPI.java +++ b/src/main/java/org/folio/rest/impl/PiecesAPI.java @@ -8,8 +8,6 @@ import javax.ws.rs.core.Response; import org.apache.commons.lang3.StringUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.folio.rest.annotations.Validate; import org.folio.rest.core.models.RequestContext; import org.folio.rest.jaxrs.model.Piece; @@ -32,7 +30,6 @@ public class PiecesAPI extends BaseApi implements OrdersPieces, OrdersPiecesRequests, OrdersPiecesBatch { - private static final Logger logger = LogManager.getLogger(); @Autowired private PieceStorageService pieceStorageService; @Autowired diff --git a/src/main/java/org/folio/service/pieces/flows/DefaultPieceFlowsValidator.java b/src/main/java/org/folio/service/pieces/flows/DefaultPieceFlowsValidator.java index ce82067ab..74a8cdc57 100644 --- a/src/main/java/org/folio/service/pieces/flows/DefaultPieceFlowsValidator.java +++ b/src/main/java/org/folio/service/pieces/flows/DefaultPieceFlowsValidator.java @@ -41,7 +41,7 @@ public void isPieceRequestValid(Piece pieceToCreate, CompositePurchaseOrder orig combinedErrors.addAll(relatedOrderErrors); if (CollectionUtils.isNotEmpty(combinedErrors)) { Errors errors = new Errors().withErrors(combinedErrors).withTotalRecords(combinedErrors.size()); - logger.error("Validation error: {}", JsonObject.mapFrom(errors).encodePrettily()); + if (logger.isErrorEnabled()) logger.error("Validation error: {}", JsonObject.mapFrom(errors).encodePrettily()); throw new HttpException(RestConstants.BAD_REQUEST, errors); } }