Look for Version Already Exists Error

Look for Software.Version.Error.AlreadyExists and return Invalid Upload
and Resource Already Exists.

Heard from users it is hard to know why the image failed to upload
in this case.

Tested: Built with PDI and phosphor-bmc-code-mgmt changes and saw the
        error.

curl -k -H "Content-Type: application/octet-stream" -X POST -T $image https://${bmc}/redfish/v1/UpdateService
{
  "Version@Message.ExtendedInfo": [
    {
      "@odata.type": "#Message.v1_1_1.Message",
      "Message": "The requested resource of type UpdateService.v1_4_0.UpdateService with the property Version with the value uploaded version already exists.",
      "MessageArgs": [
        "UpdateService.v1_4_0.UpdateService",
        "Version",
        "uploaded version"
      ],
      "MessageId": "Base.1.8.1.ResourceAlreadyExists",
      "MessageSeverity": "Critical",
      "Resolution": "Do not repeat the create operation as the resource has already been created."
    }
  ],
  "error": {
    "@Message.ExtendedInfo": [
      {
        "@odata.type": "/redfish/v1/$metadata#Message.v1_1_1.Message",
        "Message": "Invalid file uploaded to /redfish/v1/UpdateService: Image version already exists.",
        "MessageArgs": [
          "/redfish/v1/UpdateService",
          "Image version already exists"
        ],
        "MessageId": "OpenBMC.0.1.0.InvalidUpload",
        "MessageSeverity": "Warning",
        "Resolution": "None."
      }
    ],
    "code": "OpenBMC.0.1.0.InvalidUpload",
    "message": "Invalid file uploaded to /redfish/v1/UpdateService: Image version already exists."
  }
}
Change-Id: Ieab0116650dd64949da6b7ac93254193803f8f90
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index 0eb9d10..87933fa 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -329,8 +329,7 @@
             {
                 return; // if this was our message, timeout will cover it
             }
-            if (!boost::starts_with(*type,
-                                    "xyz.openbmc_project.Software.Image.Error"))
+            if (!boost::starts_with(*type, "xyz.openbmc_project.Software"))
             {
                 return;
             }
@@ -352,6 +351,17 @@
                 redfish::messages::invalidUpload(asyncResp->res, url,
                                                  "Invalid image format");
             }
+            else if (*type == "xyz.openbmc_project.Software.Version.Error."
+                              "AlreadyExists")
+            {
+
+                redfish::messages::invalidUpload(
+                    asyncResp->res, url, "Image version already exists");
+
+                redfish::messages::resourceAlreadyExists(
+                    asyncResp->res, "UpdateService.v1_4_0.UpdateService",
+                    "Version", "uploaded version");
+            }
             else if (*type ==
                      "xyz.openbmc_project.Software.Image.Error.BusyFailure")
             {