Skip to content

Commit

Permalink
FIX refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
fgalan committed Nov 21, 2023
1 parent a515124 commit 39b338c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 36 deletions.
31 changes: 7 additions & 24 deletions src/lib/mongoBackend/MongoCommonUpdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 0 additions & 11 deletions src/lib/rest/OrionError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,6 @@ void OrionError::fill(const StatusCode& sc)



/* ****************************************************************************
*
* OrionError::appendDetails -
*/
void OrionError::appendDetails(const std::string& _details)
{
details += _details;
}



/* ****************************************************************************
*
* OrionError::smartRender -
Expand Down
1 change: 0 additions & 1 deletion src/lib/rest/OrionError.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 39b338c

Please sign in to comment.