Simplify Redfish error message property interface
The error message code used a json_pointer object which must
begin with a '/' character and had to be sent as an extra
parameter. This change simplifies the interface by using a
string so there doesn't have to be a '/'. This allowed the
same property argument passed for the message to be used
for the property field path.
Tested: Sent an error with a property and verified that it is
correctly displayed.
Change-Id: I0571e2eee627cedf29d751588a4f1bceee66f084
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
diff --git a/redfish-core/include/error_messages.hpp b/redfish-core/include/error_messages.hpp
index f404de3..d92a2b4 100644
--- a/redfish-core/include/error_messages.hpp
+++ b/redfish-core/include/error_messages.hpp
@@ -87,15 +87,6 @@
void internalError(crow::Response& res);
/**
- * @brief Formats InternalError message into JSON for the specified field
- * Message body: "The request failed due to an internal service error. The
- * service is still operational."
- *
- *
- * @returns Message InternalError formatted to JSON */
-void internalError(crow::Response& res, const std::string& fieldPath);
-
-/**
* @brief Formats UnrecognizedRequestBody message into JSON
* Message body: "The service detected a malformed request body that it was
* unable to interpret."
@@ -203,20 +194,6 @@
const std::string& arg2);
/**
- * @brief Formats PropertyValueFormatError message into JSON for the specified
- * property
- * Message body: "The value <arg1> for the property <arg2> is of a different
- * format than the property can accept."
- *
- * @param[in] arg1 Parameter of message that will replace %1 in its body.
- * @param[in] arg2 Parameter of message that will replace %2 in its body.
- *
- * @returns Message PropertyValueFormatError formatted to JSON */
-void propertyValueFormatError(crow::Response& res, const std::string& arg1,
- const std::string& arg2,
- const std::string property);
-
-/**
* @brief Formats PropertyValueNotInList message into JSON
* Message body: "The value <arg1> for the property <arg2> is not in the list of
* acceptable values."
@@ -229,20 +206,6 @@
const std::string& arg2);
/**
- * @brief Formats PropertyValueNotInList message into JSON for the specified
- * property
- * Message body: "The value <arg1> for the property <arg2> is not in
- * the list of acceptable values."
- *
- * @param[in] arg1 Parameter of message that will replace %1 in its body.
- * @param[in] arg2 Parameter of message that will replace %2 in its body.
- *
- * @returns Message PropertyValueNotInList formatted to JSON */
-void propertyValueNotInList(crow::Response& res, const std::string& arg1,
- const std::string& arg2,
- const std::string property);
-
-/**
* @brief Formats ResourceAtUriInUnknownFormat message into JSON
* Message body: "The resource at <arg1> is in a format not recognized by the
* service."
@@ -326,20 +289,6 @@
const std::string& arg2);
/**
- * @brief Formats PropertyValueTypeError message into JSON for the specified
- * property
- * Message body: "The value <arg1> for the property <arg2> is of a
- * different type than the property can accept."
- *
- * @param[in] arg1 Parameter of message that will replace %1 in its body.
- * @param[in] arg2 Parameter of message that will replace %2 in its body.
- *
- * @returns Message PropertyValueTypeError formatted to JSON */
-void propertyValueTypeError(crow::Response& res, const std::string& arg1,
- const std::string& arg2,
- const std::string& property);
-
-/**
* @brief Formats ResourceNotFound message into JSON
* Message body: "The requested resource of type <arg1> named <arg2> was not
* found."
@@ -372,18 +321,6 @@
void propertyNotWritable(crow::Response& res, const std::string& arg1);
/**
- * @brief Formats PropertyNotWritable message into JSON for the specified
- * property
- * Message body: "The property <arg1> is a read only property and
- * cannot be assigned a value."
- *
- * @param[in] arg1 Parameter of message that will replace %1 in its body.
- *
- * @returns Message PropertyNotWritable formatted to JSON */
-void propertyNotWritable(crow::Response& res, const std::string& arg1,
- const std::string& property);
-
-/**
* @brief Formats QueryParameterValueTypeError message into JSON
* Message body: "The value <arg1> for the query parameter <arg2> is of a
* different type than the parameter can accept."
@@ -493,14 +430,6 @@
void success(crow::Response& res);
/**
- * @brief Formats Success message into JSON for the specified field
- * Message body: "Successfully Completed Request"
- *
- *
- * @returns Message Success formatted to JSON */
-void success(crow::Response& res, const std::string& fieldPath);
-
-/**
* @brief Formats Created message into JSON
* Message body: "The resource has been created successfully"
*
@@ -528,17 +457,6 @@
void propertyUnknown(crow::Response& res, const std::string& arg1);
/**
- * @brief Formats PropertyUnknown message into JSON for the specified property
- * Message body: "The property <arg1> is not in the list of valid properties for
- * the resource."
- *
- * @param[in] arg1 Parameter of message that will replace %1 in its body.
- *
- * @returns Message PropertyUnknown formatted to JSON */
-void propertyUnknown(crow::Response& res, const std::string& arg1,
- const std::string& property);
-
-/**
* @brief Formats NoValidSession message into JSON
* Message body: "There is no valid session established with the
* implementation."
@@ -677,17 +595,6 @@
void propertyMissing(crow::Response& res, const std::string& arg1);
/**
- * @brief Formats PropertyMissing message into JSON for the specified property
- * Message body: "The property <arg1> is a required property and must be
- * included in the request."
- *
- * @param[in] arg1 Parameter of message that will replace %1 in its body.
- *
- * @returns Message PropertyMissing formatted to JSON */
-void propertyMissing(crow::Response& res, const std::string& arg1,
- const std::string& property);
-
-/**
* @brief Formats ResourceExhaustion message into JSON
* Message body: "The resource <arg1> was unable to satisfy the request due to
* unavailability of resources."
@@ -703,7 +610,7 @@
*
*
* @returns Message AccountModified formatted to JSON */
-void accountModified(crow::Response& res, const std::string& fieldPath);
+void accountModified(crow::Response& res);
/**
* @brief Formats QueryParameterOutOfRange message into JSON
diff --git a/redfish-core/include/utils/json_utils.hpp b/redfish-core/include/utils/json_utils.hpp
index f02fc67..e56a0d6 100644
--- a/redfish-core/include/utils/json_utils.hpp
+++ b/redfish-core/include/utils/json_utils.hpp
@@ -60,7 +60,7 @@
crow::Response& res, std::bitset<Count>& handled)
{
BMCWEB_LOG_DEBUG << "Unable to find variable for key" << key;
- messages::propertyUnknown(res, key, key);
+ messages::propertyUnknown(res, key);
}
template <size_t Count, size_t Index, typename ValueType,
@@ -84,7 +84,7 @@
{
BMCWEB_LOG_DEBUG << "Value for key " << key
<< " was incorrect type: " << jsonValue.type_name();
- messages::propertyValueTypeError(res, jsonValue.dump(), key, key);
+ messages::propertyValueTypeError(res, jsonValue.dump(), key);
return;
}
@@ -103,7 +103,7 @@
{
if (!handled.test(Index) && unpackValue<ValueType>::isRequired::value)
{
- messages::propertyMissing(res, key, key);
+ messages::propertyMissing(res, key);
}
details::handleMissing<Index + 1, Count>(handled, res, in...);
}
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 7da7d0a..c44c63f 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -480,9 +480,7 @@
const boost::system::error_code ec) {
if (ec)
{
- messages::internalError(asyncResp->res, "/IPv4Addresses/" +
- std::to_string(ipIdx) +
- "/" + name);
+ messages::internalError(asyncResp->res);
}
else
{
@@ -522,9 +520,7 @@
const boost::system::error_code ec) {
if (ec)
{
- messages::internalError(asyncResp->res, "/IPv4Addresses/" +
- std::to_string(ipIdx) +
- "/AddressOrigin");
+ messages::internalError(asyncResp->res);
}
else
{
@@ -564,9 +560,7 @@
const boost::system::error_code ec) {
if (ec)
{
- messages::internalError(asyncResp->res, "/IPv4Addresses/" +
- std::to_string(ipIdx) +
- "/SubnetMask");
+ messages::internalError(asyncResp->res);
}
else
{
@@ -620,9 +614,7 @@
[ipIdx, asyncResp](const boost::system::error_code ec) {
if (ec)
{
- messages::internalError(asyncResp->res,
- "/IPv4Addresses/" +
- std::to_string(ipIdx) + "/");
+ messages::internalError(asyncResp->res);
}
else
{
@@ -653,9 +645,7 @@
asyncResp](const boost::system::error_code ec) {
if (ec)
{
- messages::internalError(asyncResp->res, "/IPv4Addresses/" +
- std::to_string(ipIdx) +
- "/");
+ messages::internalError(asyncResp->res);
}
};
@@ -872,36 +862,35 @@
if (!input.is_object())
{
messages::propertyValueTypeError(asyncResp->res, input.dump(),
- "VLAN", "/");
+ "VLAN");
return;
}
nlohmann::json::const_iterator vlanEnable = input.find("VLANEnable");
if (vlanEnable == input.end())
{
- messages::propertyMissing(asyncResp->res, "VLANEnable",
- "/VLANEnable");
+ messages::propertyMissing(asyncResp->res, "VLANEnable");
return;
}
const bool *vlanEnableBool = vlanEnable->get_ptr<const bool *>();
if (vlanEnableBool == nullptr)
{
messages::propertyValueTypeError(asyncResp->res, vlanEnable->dump(),
- "VLANEnable", "/VLANEnable");
+ "VLANEnable");
return;
}
nlohmann::json::const_iterator vlanId = input.find("VLANId");
if (vlanId == input.end())
{
- messages::propertyMissing(asyncResp->res, "VLANId", "/VLANId");
+ messages::propertyMissing(asyncResp->res, "VLANId");
return;
}
const uint64_t *vlanIdUint = vlanId->get_ptr<const uint64_t *>();
if (vlanIdUint == nullptr)
{
messages::propertyValueTypeError(asyncResp->res, vlanId->dump(),
- "VLANId", "/VLANId");
+ "VLANId");
return;
}
@@ -909,8 +898,7 @@
{
// This interface is not a VLAN. Cannot do anything with it
// TODO(kkowalsk) Change this message
- messages::propertyNotWritable(asyncResp->res, "VLANEnable",
- "/VLANEnable");
+ messages::propertyNotWritable(asyncResp->res, "VLANEnable");
return;
}
@@ -963,23 +951,23 @@
if (newHostname == nullptr)
{
messages::propertyValueTypeError(asyncResp->res, input.dump(),
- "HostName", "/HostName");
+ "HostName");
return;
}
// Change hostname
- setHostName(
- *newHostname, [asyncResp, newHostname{std::string(*newHostname)}](
- const boost::system::error_code ec) {
- if (ec)
- {
- messages::internalError(asyncResp->res, "/HostName");
- }
- else
- {
- asyncResp->res.jsonValue["HostName"] = newHostname;
- }
- });
+ setHostName(*newHostname,
+ [asyncResp, newHostname{std::string(*newHostname)}](
+ const boost::system::error_code ec) {
+ if (ec)
+ {
+ messages::internalError(asyncResp->res);
+ }
+ else
+ {
+ asyncResp->res.jsonValue["HostName"] = newHostname;
+ }
+ });
}
void handleIPv4Patch(
@@ -990,16 +978,15 @@
if (!input.is_array())
{
messages::propertyValueTypeError(asyncResp->res, input.dump(),
- "IPv4Addresses", "/IPv4Addresses");
+ "IPv4Addresses");
return;
}
// According to Redfish PATCH definition, size must be at least equal
if (input.size() < ipv4Data.size())
{
- // TODO(kkowalsk) This should be a message indicating that not
- // enough data has been provided
- messages::internalError(asyncResp->res, "/IPv4Addresses");
+ messages::propertyValueFormatError(asyncResp->res, input.dump(),
+ "IPv4Addresses");
return;
}
@@ -1009,12 +996,13 @@
for (const nlohmann::json &thisJson : input)
{
std::string pathString =
- "/IPv4Addresses/" + std::to_string(entryIdx);
+ "IPv4Addresses/" + std::to_string(entryIdx);
// Check that entry is not of some unexpected type
if (!thisJson.is_object() && !thisJson.is_null())
{
- messages::propertyValueTypeError(
- asyncResp->res, thisJson.dump(), "IPv4Address", pathString);
+ messages::propertyValueTypeError(asyncResp->res,
+ thisJson.dump(),
+ pathString + "/IPv4Address");
continue;
}
@@ -1027,9 +1015,9 @@
addressField = addressFieldIt->get_ptr<const std::string *>();
if (addressField == nullptr)
{
- messages::propertyValueFormatError(
- asyncResp->res, addressFieldIt->dump(), "Address",
- pathString + "/Address");
+ messages::propertyValueFormatError(asyncResp->res,
+ addressFieldIt->dump(),
+ pathString + "/Address");
continue;
}
else
@@ -1037,7 +1025,7 @@
if (!ipv4VerifyIpAndGetBitcount(*addressField))
{
messages::propertyValueFormatError(
- asyncResp->res, *addressField, "Address",
+ asyncResp->res, *addressField,
pathString + "/Address");
continue;
}
@@ -1054,7 +1042,7 @@
if (subnetField == nullptr)
{
messages::propertyValueFormatError(
- asyncResp->res, *subnetField, "SubnetMask",
+ asyncResp->res, *subnetField,
pathString + "/SubnetMask");
continue;
}
@@ -1065,7 +1053,7 @@
&*prefixLength))
{
messages::propertyValueFormatError(
- asyncResp->res, *subnetField, "SubnetMask",
+ asyncResp->res, *subnetField,
pathString + "/SubnetMask");
continue;
}
@@ -1083,7 +1071,7 @@
if (addressOriginField == nullptr)
{
messages::propertyValueFormatError(
- asyncResp->res, *addressOriginField, "AddressOrigin",
+ asyncResp->res, *addressOriginField,
pathString + "/AddressOrigin");
continue;
}
@@ -1097,7 +1085,7 @@
{
messages::propertyValueNotInList(
asyncResp->res, *addressOriginField,
- "AddressOrigin", pathString + "/AddressOrigin");
+ pathString + "/AddressOrigin");
continue;
}
}
@@ -1113,9 +1101,8 @@
if (gatewayField == nullptr ||
!ipv4VerifyIpAndGetBitcount(*gatewayField))
{
- messages::propertyValueFormatError(asyncResp->res,
- *gatewayField, "Gateway",
- pathString + "/Gateway");
+ messages::propertyValueFormatError(
+ asyncResp->res, *gatewayField, pathString + "/Gateway");
continue;
}
}
@@ -1132,9 +1119,7 @@
const boost::system::error_code ec) {
if (ec)
{
- messages::internalError(asyncResp->res,
- "/IPv4Addresses/" +
- entryIdx + "/");
+ messages::internalError(asyncResp->res);
return;
}
asyncResp->res.jsonValue["IPv4Addresses"][entryIdx] =
@@ -1157,11 +1142,7 @@
const boost::system::error_code ec) {
if (ec)
{
- messages::internalError(
- asyncResp->res,
- "/IPv4Addresses/" +
- std::to_string(entryIdx) +
- "/Address");
+ messages::internalError(asyncResp->res);
return;
}
asyncResp->res
@@ -1202,11 +1183,7 @@
const boost::system::error_code ec) {
if (ec)
{
- messages::internalError(
- asyncResp->res,
- "/IPv4Addresses/" +
- std::to_string(entryIdx) +
- "/Gateway");
+ messages::internalError(asyncResp->res);
return;
}
asyncResp->res
@@ -1232,21 +1209,21 @@
// Create IPv4 with provided data
if (gatewayField == nullptr)
{
- messages::propertyMissing(asyncResp->res, "Gateway",
+ messages::propertyMissing(asyncResp->res,
pathString + "/Gateway");
continue;
}
if (addressField == nullptr)
{
- messages::propertyMissing(asyncResp->res, "Address",
+ messages::propertyMissing(asyncResp->res,
pathString + "/Address");
continue;
}
if (!prefixLength)
{
- messages::propertyMissing(asyncResp->res, "SubnetMask",
+ messages::propertyMissing(asyncResp->res,
pathString + "/SubnetMask");
continue;
}
@@ -1400,8 +1377,8 @@
else if (propertyIt.key() == "IPv6Addresses")
{
// TODO(kkowalsk) IPv6 Not supported on D-Bus yet
- messages::propertyNotWritable(
- asyncResp->res, propertyIt.key(), propertyIt.key());
+ messages::propertyNotWritable(asyncResp->res,
+ propertyIt.key());
}
else
{
@@ -1412,14 +1389,12 @@
{
// Field not in scope of defined fields
messages::propertyUnknown(asyncResp->res,
- propertyIt.key(),
propertyIt.key());
}
else
{
// User attempted to modify non-writable field
messages::propertyNotWritable(asyncResp->res,
- propertyIt.key(),
propertyIt.key());
}
}
@@ -1607,14 +1582,12 @@
{
// Field not in scope of defined fields
messages::propertyUnknown(asyncResp->res,
- propertyIt.key(),
propertyIt.key());
}
else
{
// User attempted to modify non-writable field
messages::propertyNotWritable(asyncResp->res,
- propertyIt.key(),
propertyIt.key());
}
}
@@ -1789,7 +1762,7 @@
auto vlanIdJson = json.find("VLANId");
if (vlanIdJson == json.end())
{
- messages::propertyMissing(asyncResp->res, "VLANId", "/VLANId");
+ messages::propertyMissing(asyncResp->res, "VLANId");
return;
}
@@ -1797,7 +1770,7 @@
if (vlanId == nullptr)
{
messages::propertyValueTypeError(asyncResp->res, vlanIdJson->dump(),
- "VLANId", "/VLANId");
+ "VLANId");
return;
}
const std::string &rootInterfaceName = params[0];
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index c9555a1..20825d9 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -851,15 +851,14 @@
nlohmann::json::const_iterator caIt = rawPECICmd.find("ClientAddress");
if (caIt == rawPECICmd.end())
{
- messages::propertyMissing(asyncResp->res, "ClientAddress",
- "/ClientAddress");
+ messages::propertyMissing(asyncResp->res, "ClientAddress");
return;
}
const uint64_t *ca = caIt->get_ptr<const uint64_t *>();
if (ca == nullptr)
{
messages::propertyValueTypeError(asyncResp->res, caIt->dump(),
- "ClientAddress", "/ClientAddress");
+ "ClientAddress");
return;
}
// Get the Read Length from the request
@@ -867,15 +866,14 @@
nlohmann::json::const_iterator rlIt = rawPECICmd.find("ReadLength");
if (rlIt == rawPECICmd.end())
{
- messages::propertyMissing(asyncResp->res, "ReadLength",
- "/ReadLength");
+ messages::propertyMissing(asyncResp->res, "ReadLength");
return;
}
const uint64_t *rl = rlIt->get_ptr<const uint64_t *>();
if (rl == nullptr)
{
messages::propertyValueTypeError(asyncResp->res, rlIt->dump(),
- "ReadLength", "/ReadLength");
+ "ReadLength");
return;
}
// Get the PECI Command from the request
@@ -883,8 +881,7 @@
nlohmann::json::const_iterator pcIt = rawPECICmd.find("PECICommand");
if (pcIt == rawPECICmd.end())
{
- messages::propertyMissing(asyncResp->res, "PECICommand",
- "/PECICommand");
+ messages::propertyMissing(asyncResp->res, "PECICommand");
return;
}
std::vector<uint8_t> peciCommand;
@@ -895,8 +892,7 @@
{
messages::propertyValueTypeError(
asyncResp->res, pc.dump(),
- "PECICommand/" + std::to_string(peciCommand.size()),
- "/PECICommand");
+ "PECICommand/" + std::to_string(peciCommand.size()));
return;
}
peciCommand.push_back(static_cast<uint8_t>(*val));
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index 4c56cdf..d4e7344 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -182,7 +182,7 @@
if (findName == intfPair.second.end())
{
BMCWEB_LOG_ERROR << "Pid Field missing Name";
- messages::internalError(asyncResp->res, "Name");
+ messages::internalError(asyncResp->res);
return;
}
const std::string* namePtr =
@@ -251,8 +251,7 @@
if (classPtr == nullptr)
{
BMCWEB_LOG_ERROR << "Pid Class Field illegal";
- messages::internalError(asyncResp->res,
- "Class");
+ messages::internalError(asyncResp->res);
return;
}
bool isFan = *classPtr == "fan";
@@ -295,8 +294,7 @@
{
BMCWEB_LOG_ERROR
<< "Zones Pid Field Illegal";
- messages::internalError(asyncResp->res,
- "Zones");
+ messages::internalError(asyncResp->res);
return;
}
auto& data = element[propertyPair.first];
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp
index f096630..a46cb47 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -161,8 +161,7 @@
resp) {
if (ec)
{
- messages::internalError(asyncResp->res,
- "/" + service);
+ messages::internalError(asyncResp->res);
return;
}
const std::vector<std::tuple<
diff --git a/redfish-core/lib/redfish_sessions.hpp b/redfish-core/lib/redfish_sessions.hpp
index b0a2948..68449c0 100644
--- a/redfish-core/lib/redfish_sessions.hpp
+++ b/redfish-core/lib/redfish_sessions.hpp
@@ -171,12 +171,12 @@
{
if (username.empty())
{
- messages::propertyMissing(res, "UserName", "UserName");
+ messages::propertyMissing(res, "UserName");
}
if (password.empty())
{
- messages::propertyMissing(res, "Password", "Password");
+ messages::propertyMissing(res, "Password");
}
res.end();
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index 4ab4eb9..a1fbd0a 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -782,8 +782,8 @@
}
else
{
- messages::propertyValueNotInList(
- res, *indicatorLed, "IndicatorLED", "IndicatorLED");
+ messages::propertyValueNotInList(res, *indicatorLed,
+ "IndicatorLED");
return;
}
diff --git a/redfish-core/src/error_messages.cpp b/redfish-core/src/error_messages.cpp
index e38c8d4..8676aaf 100644
--- a/redfish-core/src/error_messages.cpp
+++ b/redfish-core/src/error_messages.cpp
@@ -90,8 +90,7 @@
const nlohmann::json& message,
const std::string& fieldPath)
{
- nlohmann::json_pointer<nlohmann::json> extendedInfo(
- fieldPath + messages::messageAnnotation);
+ std::string extendedInfo(fieldPath + messages::messageAnnotation);
if (!target[extendedInfo].is_array())
{
@@ -220,29 +219,6 @@
/**
* @internal
- * @brief Formats InternalError message into JSON for the specified field
- *
- * See header file for more information
- * @endinternal
- */
-void internalError(crow::Response& res, const std::string& field)
-{
- res.result(boost::beast::http::status::internal_server_error);
- addMessageToJson(
- res.jsonValue,
- nlohmann::json{
- {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
- {"MessageId", "Base.1.4.0.InternalError"},
- {"Message", "The request failed due to an internal service error. "
- "The service is still operational."},
- {"Severity", "Critical"},
- {"Resolution", "Resubmit the request. If the problem persists, "
- "consider resetting the service."}},
- field);
-}
-
-/**
- * @internal
* @brief Formats UnrecognizedRequestBody message into JSON
*
* See header file for more information
@@ -343,7 +319,7 @@
void propertyDuplicate(crow::Response& res, const std::string& arg1)
{
res.result(boost::beast::http::status::bad_request);
- addMessageToErrorJson(
+ addMessageToJson(
res.jsonValue,
nlohmann::json{
{"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
@@ -353,7 +329,8 @@
{"Severity", "Warning"},
{"Resolution",
"Remove the duplicate property from the request body and resubmit "
- "the request if the operation failed."}});
+ "the request if the operation failed."}},
+ arg1);
}
/**
@@ -389,7 +366,7 @@
const std::string& arg2, const std::string& arg3)
{
res.result(boost::beast::http::status::bad_request);
- addMessageToErrorJson(
+ addMessageToJson(
res.jsonValue,
nlohmann::json{
{"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
@@ -399,7 +376,8 @@
arg3 + " already exists."},
{"Severity", "Critical"},
{"Resolution", "Do not repeat the create operation as the resource "
- "has already been created."}});
+ "has already been created."}},
+ arg2);
}
/**
@@ -409,11 +387,10 @@
* See header file for more information
* @endinternal
*/
-void accountForSessionNoLongerExists(crow::Response& res,
- const std::string& fieldPath)
+void accountForSessionNoLongerExists(crow::Response& res)
{
res.result(boost::beast::http::status::forbidden);
- addMessageToJson(
+ addMessageToErrorJson(
res.jsonValue,
nlohmann::json{
{"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
@@ -421,8 +398,7 @@
{"Message", "The account for the current session has been removed, "
"thus the current session has been removed as well."},
{"Severity", "OK"},
- {"Resolution", "Attempt to connect with a valid account."}},
- fieldPath);
+ {"Resolution", "Attempt to connect with a valid account."}});
}
/**
@@ -436,7 +412,7 @@
const std::string& arg1)
{
res.result(boost::beast::http::status::bad_request);
- addMessageToErrorJson(
+ addMessageToJson(
res.jsonValue,
nlohmann::json{
{"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
@@ -447,32 +423,8 @@
{"Severity", "Critical"},
{"Resolution",
"Correct the body to include the required property with a valid "
- "value and resubmit the request if the operation failed."}});
-}
-
-/**
- * @internal
- * @brief Formats PropertyValueFormatError message into JSON
- *
- * See header file for more information
- * @endinternal
- */
-void propertyValueFormatError(crow::Response& res, const std::string& arg1,
- const std::string& arg2)
-{
- res.result(boost::beast::http::status::bad_request);
- addMessageToErrorJson(
- res.jsonValue,
- nlohmann::json{
- {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
- {"MessageId", "Base.1.4.0.PropertyValueFormatError"},
- {"Message",
- "The value " + arg1 + " for the property " + arg2 +
- " is of a different format than the property can accept."},
- {"Severity", "Warning"},
- {"Resolution",
- "Correct the value for the property in the request body and "
- "resubmit the request if the operation failed."}});
+ "value and resubmit the request if the operation failed."}},
+ arg1);
}
/**
@@ -484,8 +436,7 @@
* @endinternal
*/
void propertyValueFormatError(crow::Response& res, const std::string& arg1,
- const std::string& arg2,
- const std::string property)
+ const std::string& arg2)
{
res.result(boost::beast::http::status::bad_request);
addMessageToJson(
@@ -500,31 +451,7 @@
{"Resolution",
"Correct the value for the property in the request body and "
"resubmit the request if the operation failed."}},
- property);
-}
-
-/**
- * @internal
- * @brief Formats PropertyValueNotInList message into JSON
- *
- * See header file for more information
- * @endinternal
- */
-void propertyValueNotInList(crow::Response& res, const std::string& arg1,
- const std::string& arg2)
-{
- res.result(boost::beast::http::status::bad_request);
- addMessageToErrorJson(
- res.jsonValue,
- nlohmann::json{
- {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
- {"MessageId", "Base.1.4.0.PropertyValueNotInList"},
- {"Message", "The value " + arg1 + " for the property " + arg2 +
- " is not in the list of acceptable values."},
- {"Severity", "Warning"},
- {"Resolution",
- "Choose a value from the enumeration list that the implementation "
- "can support and resubmit the request if the operation failed."}});
+ arg2);
}
/**
@@ -536,7 +463,7 @@
* @endinternal
*/
void propertyValueNotInList(crow::Response& res, const std::string& arg1,
- const std::string& arg2, const std::string property)
+ const std::string& arg2)
{
res.result(boost::beast::http::status::bad_request);
addMessageToJson(
@@ -550,7 +477,7 @@
{"Resolution",
"Choose a value from the enumeration list that the implementation "
"can support and resubmit the request if the operation failed."}},
- property);
+ arg2);
}
/**
@@ -717,31 +644,6 @@
/**
* @internal
- * @brief Formats PropertyValueTypeError message into JSON
- *
- * See header file for more information
- * @endinternal
- */
-void propertyValueTypeError(crow::Response& res, const std::string& arg1,
- const std::string& arg2)
-{
- res.result(boost::beast::http::status::bad_request);
- addMessageToErrorJson(
- res.jsonValue,
- nlohmann::json{
- {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
- {"MessageId", "Base.1.4.0.PropertyValueTypeError"},
- {"Message",
- "The value " + arg1 + " for the property " + arg2 +
- " is of a different type than the property can accept."},
- {"Severity", "Warning"},
- {"Resolution",
- "Correct the value for the property in the request body and "
- "resubmit the request if the operation failed."}});
-}
-
-/**
- * @internal
* @brief Formats PropertyValueTypeError message into JSON for the specified
* property
*
@@ -749,8 +651,7 @@
* @endinternal
*/
void propertyValueTypeError(crow::Response& res, const std::string& arg1,
- const std::string& arg2,
- const std::string& property)
+ const std::string& arg2)
{
res.result(boost::beast::http::status::bad_request);
addMessageToJson(
@@ -765,7 +666,7 @@
{"Resolution",
"Correct the value for the property in the request body and "
"resubmit the request if the operation failed."}},
- property);
+ arg2);
}
/**
@@ -817,37 +718,13 @@
/**
* @internal
- * @brief Formats PropertyNotWritable message into JSON
- *
- * See header file for more information
- * @endinternal
- */
-void propertyNotWritable(crow::Response& res, const std::string& arg1)
-{
- res.result(boost::beast::http::status::forbidden);
- addMessageToErrorJson(
- res.jsonValue,
- nlohmann::json{
- {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
- {"MessageId", "Base.1.4.0.PropertyNotWritable"},
- {"Message",
- "The property " + arg1 +
- " is a read only property and cannot be assigned a value."},
- {"Severity", "Warning"},
- {"Resolution", "Remove the property from the request body and "
- "resubmit the request if the operation failed."}});
-}
-
-/**
- * @internal
* @brief Formats PropertyNotWritable message into JSON for the specified
* property
*
* See header file for more information
* @endinternal
*/
-void propertyNotWritable(crow::Response& res, const std::string& arg1,
- const std::string& property)
+void propertyNotWritable(crow::Response& res, const std::string& arg1)
{
res.result(boost::beast::http::status::forbidden);
addMessageToJson(
@@ -861,7 +738,7 @@
{"Severity", "Warning"},
{"Resolution", "Remove the property from the request body and "
"resubmit the request if the operation failed."}},
- property);
+ arg1);
}
/**
@@ -1112,27 +989,6 @@
/**
* @internal
- * @brief Formats Success message into JSON for the specified field
- *
- * See header file for more information
- * @endinternal
- */
-void success(crow::Response& res, const std::string& fieldPath)
-{
- res.result(boost::beast::http::status::ok);
- addMessageToJson(
- res.jsonValue,
- nlohmann::json{
- {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
- {"MessageId", "Base.1.4.0.Success"},
- {"Message", "Successfully Completed Request"},
- {"Severity", "OK"},
- {"Resolution", "None"}},
- fieldPath);
-}
-
-/**
- * @internal
* @brief Formats Created message into JSON
*
* See header file for more information
@@ -1175,37 +1031,12 @@
/**
* @internal
- * @brief Formats PropertyUnknown message into JSON
- *
- * See header file for more information
- * @endinternal
- */
-void propertyUnknown(crow::Response& res, const std::string& arg1)
-{
- res.result(boost::beast::http::status::bad_request);
- addMessageToErrorJson(
- res.jsonValue,
- nlohmann::json{
- {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
- {"MessageId", "Base.1.4.0.PropertyUnknown"},
- {"Message",
- "The property " + arg1 +
- " is not in the list of valid properties for the resource."},
- {"Severity", "Warning"},
- {"Resolution",
- "Remove the unknown property from the request body and resubmit "
- "the request if the operation failed."}});
-}
-
-/**
- * @internal
* @brief Formats PropertyUnknown message into JSON for the specified property
*
* See header file for more information
* @endinternal
*/
-void propertyUnknown(crow::Response& res, const std::string& arg1,
- const std::string& property)
+void propertyUnknown(crow::Response& res, const std::string& arg1)
{
res.result(boost::beast::http::status::bad_request);
addMessageToJson(
@@ -1220,7 +1051,7 @@
{"Resolution",
"Remove the unknown property from the request body and resubmit "
"the request if the operation failed."}},
- property);
+ arg1);
}
/**
@@ -1462,8 +1293,7 @@
* @endinternal
*/
void propertyValueModified(crow::Response& res, const std::string& arg1,
- const std::string& arg2,
- const std::string& fieldPath)
+ const std::string& arg2)
{
res.result(boost::beast::http::status::ok);
addMessageToJson(
@@ -1475,7 +1305,7 @@
arg2 + " due to modification by the service."},
{"Severity", "Warning"},
{"Resolution", "No resolution is required."}},
- fieldPath);
+ arg1);
}
/**
@@ -1527,37 +1357,12 @@
/**
* @internal
- * @brief Formats PropertyMissing message into JSON
- *
- * See header file for more information
- * @endinternal
- */
-void propertyMissing(crow::Response& res, const std::string& arg1)
-{
- res.result(boost::beast::http::status::bad_request);
- addMessageToErrorJson(
- res.jsonValue,
- nlohmann::json{
- {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
- {"MessageId", "Base.1.4.0.PropertyMissing"},
- {"Message", "The property " + arg1 +
- " is a required property and must be included in "
- "the request."},
- {"Severity", "Warning"},
- {"Resolution",
- "Ensure that the property is in the request body and has a valid "
- "value and resubmit the request if the operation failed."}});
-}
-
-/**
- * @internal
* @brief Formats PropertyMissing message into JSON for the specified property
*
* See header file for more information
* @endinternal
*/
-void propertyMissing(crow::Response& res, const std::string& arg1,
- const std::string& property)
+void propertyMissing(crow::Response& res, const std::string& arg1)
{
res.result(boost::beast::http::status::bad_request);
addMessageToJson(
@@ -1572,7 +1377,7 @@
{"Resolution",
"Ensure that the property is in the request body and has a valid "
"value and resubmit the request if the operation failed."}},
- property);
+ arg1);
}
/**
@@ -1605,18 +1410,17 @@
* See header file for more information
* @endinternal
*/
-void accountModified(crow::Response& res, const std::string& fieldPath)
+void accountModified(crow::Response& res)
{
res.result(boost::beast::http::status::ok);
- addMessageToJson(
+ addMessageToErrorJson(
res.jsonValue,
nlohmann::json{
{"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
{"MessageId", "Base.1.4.0.AccountModified"},
{"Message", "The account was successfully modified."},
{"Severity", "OK"},
- {"Resolution", "No resolution is required."}},
- fieldPath);
+ {"Resolution", "No resolution is required."}});
}
/**