Add MutualExclusiveProperties registry

Add MutualExclusiveProperties message registry entry
and error message.
As per redfish specification, "RegistryPrefixes" and
"MessageIds" are mutually exclusive. So add check for
same in EventService and return MutualExclusiveProperties
error message.

Tested:
 - Create subscription failed with error(bad request)
   when the request body contain both "RegistryPrefixes"
   and "MessageIds".

Change-Id: I4c14f946977bce2ced8a7f96eb85855117fde9a8
Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>
diff --git a/redfish-core/include/error_messages.hpp b/redfish-core/include/error_messages.hpp
index 0243be9..9a2d1ca 100644
--- a/redfish-core/include/error_messages.hpp
+++ b/redfish-core/include/error_messages.hpp
@@ -787,6 +787,20 @@
 void invalidUpload(crow::Response& res, const std::string& arg1,
                    const std::string& arg2);
 
+/**
+ * @brief Formats MutualExclusiveProperties message into JSON
+ * Message body: "The properties <arg1> and <arg2> are mutually exclusive."
+ *
+ * @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 MutualExclusiveProperties formatted to JSON */
+nlohmann::json mutualExclusiveProperties(const std::string& arg1,
+                                         const std::string& arg2);
+
+void mutualExclusiveProperties(crow::Response& res, const std::string& arg1,
+                               const std::string& arg2);
+
 } // namespace messages
 
 } // namespace redfish
diff --git a/redfish-core/include/registries/base_message_registry.hpp b/redfish-core/include/registries/base_message_registry.hpp
index 90aef56..7c385a0 100644
--- a/redfish-core/include/registries/base_message_registry.hpp
+++ b/redfish-core/include/registries/base_message_registry.hpp
@@ -36,7 +36,7 @@
 constexpr const char* url =
     "https://redfish.dmtf.org/registries/Base.1.8.1.json";
 
-constexpr std::array<MessageEntry, 73> registry = {
+constexpr std::array<MessageEntry, 74> registry = {
     MessageEntry{
         "AccessDenied",
         {
@@ -429,6 +429,22 @@
             "Resolve other reported errors and retry the current operation.",
         }},
     MessageEntry{
+        "MutualExclusiveProperties",
+        {
+            "Indicates that the requested operation could not be completed, "
+            "because of a conflict properties.",
+            "The properties '%1' and '%2' are mutually exclusive.",
+            "Warning",
+            "Warning",
+            2,
+            {
+                "string",
+                "string",
+            },
+            "Ensure that the request body doesn't have mutually exclusive "
+            "properties and resubmit the request.",
+        }},
+    MessageEntry{
         "NoOperation",
         {
             "Indicates that the requested operation will not perform any "
diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp
index e1c06ec..f7b76d1 100644
--- a/redfish-core/lib/event_service.hpp
+++ b/redfish-core/lib/event_service.hpp
@@ -250,6 +250,16 @@
             return;
         }
 
+        if (regPrefixes && msgIds)
+        {
+            if (regPrefixes->size() && msgIds->size())
+            {
+                messages::mutualExclusiveProperties(
+                    asyncResp->res, "RegistryPrefixes", "MessageIds");
+                return;
+            }
+        }
+
         // Validate the URL using regex expression
         // Format: <protocol>://<host>:<port>/<uri>
         // protocol: http/https
diff --git a/redfish-core/src/error_messages.cpp b/redfish-core/src/error_messages.cpp
index 160b73f..c6938ba 100644
--- a/redfish-core/src/error_messages.cpp
+++ b/redfish-core/src/error_messages.cpp
@@ -1750,6 +1750,35 @@
         {"Resolution", "None."}};
 }
 
+/**
+ * @internal
+ * @brief Formats MutualExclusiveProperties into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json mutualExclusiveProperties(const std::string& arg1,
+                                         const std::string& arg2)
+{
+    return nlohmann::json{
+        {"@odata.type", "#Message.v1_0_0.Message"},
+        {"MessageId", "Base.1.5.0.MutualExclusiveProperties"},
+        {"Message", "The properties " + arg1 + " and " + arg2 +
+                        " are mutually exclusive."},
+        {"MessageArgs", {arg1, arg2}},
+        {"Severity", "Warning"},
+        {"Resolution",
+         "Ensure that the request body doesn't contain mutually exclusive "
+         "properties and resubmit the request."}};
+}
+
+void mutualExclusiveProperties(crow::Response& res, const std::string& arg1,
+                               const std::string& arg2)
+{
+    res.result(boost::beast::http::status::bad_request);
+    addMessageToErrorJson(res.jsonValue, mutualExclusiveProperties(arg1, arg2));
+}
+
 } // namespace messages
 
 } // namespace redfish