From f2476c9856e64af5e17f819e26cd58ae4a0c7c67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Tue, 13 Aug 2024 12:50:28 +0200 Subject: [PATCH] RENAME setStatusCodeAndSmartRender() to setSCAndRender() --- src/lib/jsonParseV2/jsonRequestTreat.cpp | 6 +++--- src/lib/parse/textParse.cpp | 8 ++++---- src/lib/rest/OrionError.cpp | 4 ++-- src/lib/rest/OrionError.h | 2 +- src/lib/rest/RestService.cpp | 2 +- src/lib/rest/rest.cpp | 20 ++++++++++---------- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/lib/jsonParseV2/jsonRequestTreat.cpp b/src/lib/jsonParseV2/jsonRequestTreat.cpp index 530698535b..c18a1abde3 100644 --- a/src/lib/jsonParseV2/jsonRequestTreat.cpp +++ b/src/lib/jsonParseV2/jsonRequestTreat.cpp @@ -80,7 +80,7 @@ std::string jsonRequestTreat if ((answer = parseDataP->ent.res.check(EntitiesRequest)) != "OK") { OrionError oe(SccBadRequest, answer); - return oe.setStatusCodeAndSmartRender(&(ciP->httpStatusCode)); + return oe.setSCAndRender(&(ciP->httpStatusCode)); } break; @@ -95,7 +95,7 @@ std::string jsonRequestTreat if ((answer = parseDataP->ent.res.check(EntityRequest)) != "OK") { OrionError oe(SccBadRequest, answer); - return oe.setStatusCodeAndSmartRender(&(ciP->httpStatusCode)); + return oe.setSCAndRender(&(ciP->httpStatusCode)); } break; @@ -111,7 +111,7 @@ std::string jsonRequestTreat if ((answer = parseDataP->attr.attribute.check(false)) != "OK") { OrionError oe(SccBadRequest, answer); - return oe.setStatusCodeAndSmartRender(&(ciP->httpStatusCode)); + return oe.setSCAndRender(&(ciP->httpStatusCode)); } break; diff --git a/src/lib/parse/textParse.cpp b/src/lib/parse/textParse.cpp index 957f3aaf7d..7603099700 100644 --- a/src/lib/parse/textParse.cpp +++ b/src/lib/parse/textParse.cpp @@ -56,7 +56,7 @@ static std::string textParseAttributeValue(ConnectionInfo* ciP, ContextAttribute else { OrionError oe(SccBadRequest, "Missing citation-mark at end of string"); - return oe.setStatusCodeAndSmartRender(&(ciP->httpStatusCode)); + return oe.setSCAndRender(&(ciP->httpStatusCode)); } } @@ -88,7 +88,7 @@ static std::string textParseAttributeValue(ConnectionInfo* ciP, ContextAttribute else // 5. None of the above - it's an error { OrionError oe(SccBadRequest, "attribute value type not recognized"); - return oe.setStatusCodeAndSmartRender(&(ciP->httpStatusCode)); + return oe.setSCAndRender(&(ciP->httpStatusCode)); } return "OK"; @@ -116,14 +116,14 @@ std::string textRequestTreat(ConnectionInfo* ciP, ParseData* parseDataP, Request if ((answer = parseDataP->av.attribute.check(true)) != "OK") { OrionError oe(SccBadRequest, answer); - return oe.setStatusCodeAndSmartRender(&(ciP->httpStatusCode)); + return oe.setSCAndRender(&(ciP->httpStatusCode)); } break; default: OrionError oe(SccUnsupportedMediaType, "not supported content type: text/plain"); - answer = oe.setStatusCodeAndSmartRender(&(ciP->httpStatusCode)); + answer = oe.setSCAndRender(&(ciP->httpStatusCode)); alarmMgr.badInput(clientIp, "not supported content type", "text/plain"); break; diff --git a/src/lib/rest/OrionError.cpp b/src/lib/rest/OrionError.cpp index 1454eef5b9..72c296c4d6 100644 --- a/src/lib/rest/OrionError.cpp +++ b/src/lib/rest/OrionError.cpp @@ -127,9 +127,9 @@ void OrionError::fillOrAppend(HttpStatusCode _code, const std::string& fullDetai /* **************************************************************************** * -* OrionError::setStatusCodeAndSmartRender - +* OrionError::setSCAndRender - */ -std::string OrionError::setStatusCodeAndSmartRender(HttpStatusCode* scP) +std::string OrionError::setSCAndRender(HttpStatusCode* scP) { *scP = code; return toJson(); diff --git a/src/lib/rest/OrionError.h b/src/lib/rest/OrionError.h index 4492dd05d4..1a4b80ff6a 100644 --- a/src/lib/rest/OrionError.h +++ b/src/lib/rest/OrionError.h @@ -51,7 +51,7 @@ typedef struct OrionError OrionError(HttpStatusCode _code, const std::string& _description = "", const std::string& _error = ""); std::string smartRender(void); - std::string setStatusCodeAndSmartRender(HttpStatusCode* scP); + std::string setSCAndRender(HttpStatusCode* scP); std::string toJson(void); void fill(HttpStatusCode _code, const std::string& _description, const std::string& _error = ""); void fill(const StatusCode& sc); diff --git a/src/lib/rest/RestService.cpp b/src/lib/rest/RestService.cpp index a86f44be7f..6d988f3c53 100644 --- a/src/lib/rest/RestService.cpp +++ b/src/lib/rest/RestService.cpp @@ -558,7 +558,7 @@ static std::string restService(ConnectionInfo* ciP, RestService* serviceV) { OrionError oe(SccBadRequest, result); - std::string response = oe.setStatusCodeAndSmartRender(&(ciP->httpStatusCode)); + std::string response = oe.setSCAndRender(&(ciP->httpStatusCode)); alarmMgr.badInput(clientIp, result); restReply(ciP, response); diff --git a/src/lib/rest/rest.cpp b/src/lib/rest/rest.cpp index 9df8e6ca44..243c937418 100644 --- a/src/lib/rest/rest.cpp +++ b/src/lib/rest/rest.cpp @@ -694,14 +694,14 @@ int servicePathCheck(ConnectionInfo* ciP, const char* servicePath) if (servicePath[0] != '/') { OrionError oe(SccBadRequest, "Only /absolute/ Service Paths allowed [a service path must begin with /]"); - ciP->answer = oe.setStatusCodeAndSmartRender(&(ciP->httpStatusCode)); + ciP->answer = oe.setSCAndRender(&(ciP->httpStatusCode)); return 1; } if (servicePath[1] == '/') { OrionError oe(SccBadRequest, "empty component in ServicePath"); - ciP->answer = oe.setStatusCodeAndSmartRender(&(ciP->httpStatusCode)); + ciP->answer = oe.setSCAndRender(&(ciP->httpStatusCode)); return 1; } @@ -710,13 +710,13 @@ int servicePathCheck(ConnectionInfo* ciP, const char* servicePath) if (ciP->verb == PATCH) { OrionError oe(SccBadRequest, "more than one servicepath in patch update request is not allowed"); - ciP->answer = oe.setStatusCodeAndSmartRender(&(ciP->httpStatusCode)); + ciP->answer = oe.setSCAndRender(&(ciP->httpStatusCode)); return 1; } if (ciP->verb == DELETE) { OrionError oe(SccBadRequest, "more than one servicepath is not allowed in DELETE operation"); - ciP->answer = oe.setStatusCodeAndSmartRender(&(ciP->httpStatusCode)); + ciP->answer = oe.setSCAndRender(&(ciP->httpStatusCode)); return 1; } } @@ -726,7 +726,7 @@ int servicePathCheck(ConnectionInfo* ciP, const char* servicePath) if (components > SERVICE_PATH_MAX_LEVELS) { OrionError oe(SccBadRequest, "too many components in ServicePath"); - ciP->answer = oe.setStatusCodeAndSmartRender(&(ciP->httpStatusCode)); + ciP->answer = oe.setSCAndRender(&(ciP->httpStatusCode)); return 2; } @@ -735,14 +735,14 @@ int servicePathCheck(ConnectionInfo* ciP, const char* servicePath) if (strlen(compV[ix].c_str()) > SERVICE_PATH_MAX_COMPONENT_LEN) { OrionError oe(SccBadRequest, "component-name too long in ServicePath"); - ciP->answer = oe.setStatusCodeAndSmartRender(&(ciP->httpStatusCode)); + ciP->answer = oe.setSCAndRender(&(ciP->httpStatusCode)); return 3; } if (compV[ix].c_str()[0] == 0) { OrionError oe(SccBadRequest, "empty component in ServicePath"); - ciP->answer = oe.setStatusCodeAndSmartRender(&(ciP->httpStatusCode)); + ciP->answer = oe.setSCAndRender(&(ciP->httpStatusCode)); return 3; } @@ -754,13 +754,13 @@ int servicePathCheck(ConnectionInfo* ciP, const char* servicePath) if (ciP->verb == PATCH) { OrionError oe(SccBadRequest, "servicepath with wildcard # is not allowed in patch update request"); - ciP->answer = oe.setStatusCodeAndSmartRender(&(ciP->httpStatusCode)); + ciP->answer = oe.setSCAndRender(&(ciP->httpStatusCode)); return 3; } else if (ciP->verb == DELETE) { OrionError oe(SccBadRequest, "servicepath with wildcard # is not allowed in DELETE operation"); - ciP->answer = oe.setStatusCodeAndSmartRender(&(ciP->httpStatusCode)); + ciP->answer = oe.setSCAndRender(&(ciP->httpStatusCode)); return 3; } else @@ -776,7 +776,7 @@ int servicePathCheck(ConnectionInfo* ciP, const char* servicePath) if (!isalnum(comp[cIx]) && (comp[cIx] != '_')) { OrionError oe(SccBadRequest, "a component of ServicePath contains an illegal character"); - ciP->answer = oe.setStatusCodeAndSmartRender(&(ciP->httpStatusCode)); + ciP->answer = oe.setSCAndRender(&(ciP->httpStatusCode)); return 4; } }