From bc5649703150bacd530ba1433629c06420047afd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Fri, 6 Sep 2024 10:40:42 +0200 Subject: [PATCH] REMOVE buildGeneralErrorResponse (tentative) --- src/lib/mongoBackend/MongoCommonUpdate.cpp | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/lib/mongoBackend/MongoCommonUpdate.cpp b/src/lib/mongoBackend/MongoCommonUpdate.cpp index c1f4988720..8482e14d32 100644 --- a/src/lib/mongoBackend/MongoCommonUpdate.cpp +++ b/src/lib/mongoBackend/MongoCommonUpdate.cpp @@ -2154,6 +2154,7 @@ static unsigned int processSubscriptions +#if 0 /* **************************************************************************** * * buildGeneralErrorResponse - @@ -2185,7 +2186,7 @@ static void buildGeneralErrorResponse cerP->statusCode.fill(code, details); responseP->contextElementResponseVector.push_back(cerP); } - +#endif /* **************************************************************************** @@ -3991,8 +3992,8 @@ static bool contextElementPreconditionsCheck { 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 } @@ -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 } @@ -4116,7 +4117,7 @@ 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; } @@ -4124,7 +4125,7 @@ unsigned int processContextElement // 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; } @@ -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; } @@ -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; } @@ -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; @@ -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); }