From 39b338caaf28583d3200d3540086d6fe93cde10b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Tue, 21 Nov 2023 15:12:40 +0100 Subject: [PATCH] FIX refactor --- src/lib/mongoBackend/MongoCommonUpdate.cpp | 31 +++++----------------- src/lib/rest/OrionError.cpp | 11 -------- src/lib/rest/OrionError.h | 1 - 3 files changed, 7 insertions(+), 36 deletions(-) diff --git a/src/lib/mongoBackend/MongoCommonUpdate.cpp b/src/lib/mongoBackend/MongoCommonUpdate.cpp index 7859fcc24b..287320d6c2 100644 --- a/src/lib/mongoBackend/MongoCommonUpdate.cpp +++ b/src/lib/mongoBackend/MongoCommonUpdate.cpp @@ -4451,34 +4451,17 @@ unsigned int processContextElement if (attributeAlreadyExistsError == true) { - if (responseP->oe.code == SccInvalidModification) - { - // Another previous entity had problems. Use appendDetails() - responseP->oe.appendDetails(", " + eP->id + " - " + attributeAlreadyExistsList); - } - else - { - // First entity with this problem. Use fill() - std::string details = "one or more of the attributes in the request already exist: " + eP->id + " - " + attributeAlreadyExistsList; - buildGeneralErrorResponse(eP, NULL, responseP, SccBadRequest, details); - responseP->oe.fill(SccInvalidModification, details, ERROR_UNPROCESSABLE); - } + std::string details = "one or more of the attributes in the request already exist: " + eP->id + " - " + attributeAlreadyExistsList; + buildGeneralErrorResponse(eP, NULL, responseP, SccBadRequest, details); + responseP->oe.fillOrAppend(SccInvalidModification, details, ", " + eP->id + " - " + attributeAlreadyExistsList, ERROR_UNPROCESSABLE); } if (attributeNotExistingError == true) { - if (responseP->oe.code == SccInvalidModification) - { - // Another previous entity had problems. Use appendDetails() - responseP->oe.appendDetails(", " + eP->id + " - " + attributeNotExistingList); - } - else - { - // First entity with this problem. Use fill() - std::string details = "one or more of the attributes in the request do not exist: " + eP->id + " - " + attributeNotExistingList; - buildGeneralErrorResponse(eP, NULL, responseP, SccBadRequest, details); - responseP->oe.fill(SccInvalidModification, details, ERROR_UNPROCESSABLE); - } + + std::string details = "one or more of the attributes in the request do not exist: " + eP->id + " - " + attributeNotExistingList; + buildGeneralErrorResponse(eP, NULL, responseP, SccBadRequest, details); + responseP->oe.fillOrAppend(SccInvalidModification, details, ", " + eP->id + " - " + attributeNotExistingList, ERROR_UNPROCESSABLE); } // Response in responseP diff --git a/src/lib/rest/OrionError.cpp b/src/lib/rest/OrionError.cpp index c3839b631f..180764bfa1 100644 --- a/src/lib/rest/OrionError.cpp +++ b/src/lib/rest/OrionError.cpp @@ -119,17 +119,6 @@ void OrionError::fill(const StatusCode& sc) -/* **************************************************************************** -* -* OrionError::appendDetails - -*/ -void OrionError::appendDetails(const std::string& _details) -{ - details += _details; -} - - - /* **************************************************************************** * * OrionError::smartRender - diff --git a/src/lib/rest/OrionError.h b/src/lib/rest/OrionError.h index 5f7e828911..d656bac8c9 100644 --- a/src/lib/rest/OrionError.h +++ b/src/lib/rest/OrionError.h @@ -56,7 +56,6 @@ typedef struct OrionError void fill(HttpStatusCode _code, const std::string& _details, const std::string& _reasonPhrase = ""); void fill(const StatusCode& sc); void fillOrAppend(HttpStatusCode _code, const std::string& fullDetails, const std::string& appendDetail, const std::string& _reasonPhrase); - void appendDetails(const std::string& _details); private: