Make propertyValueNotInList typesafe
The error codes for this function accept a string_view, which has caused
a number of cases of users of this function to call dump() to_string()
and all manner of other conversions. Considering that dump() is
something that's difficult to call correctly, and overly wordy, it would
be ideal if the message code just handled that for us.
Therefore, this commit changes the prototype to include a nlohmann::json
object as an argument instead of string_view, then audits the codebase
for all uses, and moves them to a more normalized usage, which allows
the calling code to call "dump" for them.
Tested: PATCH /redfish/v1/SessionService {"SessionTimeout": 1}
Returns the PropertyValueNotInList error as it did before.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: If62909072db1f067ad1f8aa590bb716c84181219
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index 6cbb405..5e9de4e 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -1215,8 +1215,8 @@
{
if (serviceAddressList->empty())
{
- messages::propertyValueNotInList(asyncResp->res, "[]",
- "ServiceAddress");
+ messages::propertyValueNotInList(
+ asyncResp->res, *serviceAddressList, "ServiceAddress");
return;
}
}
@@ -1224,7 +1224,7 @@
{
if (baseDNList->empty())
{
- messages::propertyValueNotInList(asyncResp->res, "[]",
+ messages::propertyValueNotInList(asyncResp->res, *baseDNList,
"BaseDistinguishedNames");
return;
}
@@ -1388,8 +1388,8 @@
std::string priv = getPrivilegeFromRoleId(*roleId);
if (priv.empty())
{
- messages::propertyValueNotInList(asyncResp->res, *roleId,
- "RoleId");
+ messages::propertyValueNotInList(asyncResp->res, true,
+ "Locked");
return;
}