Skip to content

Commit

Permalink
REMOVE buildGeneralErrorResponse (tentative)
Browse files Browse the repository at this point in the history
  • Loading branch information
fgalan committed Sep 6, 2024
1 parent e5642b8 commit 45058b6
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/lib/mongoBackend/MongoCommonUpdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2154,6 +2154,7 @@ static unsigned int processSubscriptions



#if 0
/* ****************************************************************************
*
* buildGeneralErrorResponse -
Expand Down Expand Up @@ -2185,7 +2186,7 @@ static void buildGeneralErrorResponse
cerP->statusCode.fill(code, details);
responseP->contextElementResponseVector.push_back(cerP);
}

#endif


/* ****************************************************************************
Expand Down Expand Up @@ -3989,10 +3990,10 @@ static bool contextElementPreconditionsCheck
{
if ((name == eP->attributeVector[jx]->name))
{
ContextAttribute* ca = new ContextAttribute(eP->attributeVector[ix]);
//ContextAttribute* ca = new ContextAttribute(eP->attributeVector[ix]);
alarmMgr.badInput(clientIp, "duplicated attribute name", name);
buildGeneralErrorResponse(eP, ca, responseP, SccInvalidModification,
"duplicated attribute /" + name + "/");
//buildGeneralErrorResponse(eP, ca, responseP, SccInvalidModification,
// "duplicated attribute /" + name + "/");
responseP->oe.fill(SccBadRequest, "duplicated attribute /" + name + "/", ERROR_BAD_REQUEST);
return false; // Error already in responseP
}
Expand All @@ -4002,7 +4003,7 @@ static bool contextElementPreconditionsCheck
/* Not supporting idPattern currently */
if (!eP->entityId.idPattern.empty())
{
buildGeneralErrorResponse(eP, NULL, responseP, SccNotImplemented);
//buildGeneralErrorResponse(eP, NULL, responseP, SccNotImplemented);
// No need of filling responseP->oe, this cannot happen in NGSIv2
return false; // Error already in responseP
}
Expand Down Expand Up @@ -4116,15 +4117,15 @@ unsigned int processContextElement

if (!orion::collectionCount(composeDatabaseName(tenant), COL_ENTITIES, query, &entitiesNumber, &err))
{
buildGeneralErrorResponse(eP, NULL, responseP, SccReceiverInternalError, err);
//buildGeneralErrorResponse(eP, NULL, responseP, SccReceiverInternalError, err);
responseP->oe.fill(SccReceiverInternalError, err, "InternalServerError");
return 0;
}

// This is the case of POST /v2/entities, in order to check that entity doesn't previously exist
if ((entitiesNumber > 0) && (ngsiv2Flavour == NGSIV2_FLAVOUR_ONCREATE))
{
buildGeneralErrorResponse(eP, NULL, responseP, SccInvalidModification, ERROR_DESC_UNPROCESSABLE_ALREADY_EXISTS);
//buildGeneralErrorResponse(eP, NULL, responseP, SccInvalidModification, ERROR_DESC_UNPROCESSABLE_ALREADY_EXISTS);
responseP->oe.fill(SccInvalidModification, ERROR_DESC_UNPROCESSABLE_ALREADY_EXISTS, ERROR_UNPROCESSABLE);
return 0;
}
Expand All @@ -4133,7 +4134,7 @@ unsigned int processContextElement
// both for regular case and when ?options=append is used
if ((entitiesNumber == 0) && (ngsiv2Flavour == NGSIV2_FLAVOUR_ONAPPEND))
{
buildGeneralErrorResponse(eP, NULL, responseP, SccContextElementNotFound, ERROR_DESC_NOT_FOUND_ENTITY);
//buildGeneralErrorResponse(eP, NULL, responseP, SccContextElementNotFound, ERROR_DESC_NOT_FOUND_ENTITY);
responseP->oe.fill(SccContextElementNotFound, ERROR_DESC_NOT_FOUND_ENTITY, ERROR_NOT_FOUND);
return 0;
}
Expand All @@ -4142,7 +4143,7 @@ unsigned int processContextElement
// not allowed in NGSIv2
if (entitiesNumber > 1)
{
buildGeneralErrorResponse(eP, NULL, responseP, SccConflict, ERROR_DESC_TOO_MANY_ENTITIES);
//buildGeneralErrorResponse(eP, NULL, responseP, SccConflict, ERROR_DESC_TOO_MANY_ENTITIES);
responseP->oe.fill(SccConflict, ERROR_DESC_TOO_MANY_ENTITIES, ERROR_TOO_MANY);
return 0;
}
Expand All @@ -4154,7 +4155,7 @@ unsigned int processContextElement
{
orion::releaseMongoConnection(connection);
TIME_STAT_MONGO_READ_WAIT_STOP();
buildGeneralErrorResponse(eP, NULL, responseP, SccReceiverInternalError, err);
//buildGeneralErrorResponse(eP, NULL, responseP, SccReceiverInternalError, err);
responseP->oe.fill(SccReceiverInternalError, err, "InternalServerError");

return 0;
Expand Down Expand Up @@ -4393,14 +4394,14 @@ unsigned int processContextElement
if ((attributeAlreadyExistsNumber > 0) && (action == ActionTypeAppendStrict))
{
std::string details = ERROR_DESC_UNPROCESSABLE_ATTR_ALREADY_EXISTS + enStr + " - " + attributeAlreadyExistsList;
buildGeneralErrorResponse(eP, NULL, responseP, SccBadRequest, details);
//buildGeneralErrorResponse(eP, NULL, responseP, SccBadRequest, details);
responseP->oe.fillOrAppend(SccInvalidModification, details, ", " + enStr + " - " + attributeAlreadyExistsList, ERROR_UNPROCESSABLE);
}

if ((attributeNotExistingNumber > 0) && ((action == ActionTypeUpdate) || (action == ActionTypeDelete)))
{
std::string details = ERROR_DESC_DO_NOT_EXIT + enStr + " - " + attributeNotExistingList;
buildGeneralErrorResponse(eP, NULL, responseP, SccBadRequest, details);
//buildGeneralErrorResponse(eP, NULL, responseP, SccBadRequest, details);
responseP->oe.fillOrAppend(SccInvalidModification, details, ", " + enStr + " - " + attributeNotExistingList, ERROR_UNPROCESSABLE);
}

Expand Down

0 comments on commit 45058b6

Please sign in to comment.