log_service: Fix error message for non-existing log entries

When requesting a log extry that does not exist on system, a 404 Not
Found HTTP status code and corresponding ResourceNotFound error message
should be returned. Current code mistakenly uses ResourceMissingAtURI
error which should be used for referencing a non-existing resource in
request properties.

Tested:
Verified requesting on a non-existing now responds with HTTP 404 and
NotFound message manually. (This cannot be checked with Redfish Service
Validator.)

Change-Id: I3ef525eec3622918921bb9eb0b93fb6195c1a5b9
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index ecd5d59..ec873b1 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -290,8 +290,7 @@
             indexStr.data(), indexStr.data() + indexStr.size(), index);
         if (ec != std::errc())
         {
-            messages::resourceMissingAtURI(
-                asyncResp->res, crow::utility::urlFromPieces(entryID));
+            messages::resourceNotFound(asyncResp->res, "LogEntry", entryID);
             return false;
         }
     }
@@ -300,8 +299,7 @@
         std::from_chars(tsStr.data(), tsStr.data() + tsStr.size(), timestamp);
     if (ec != std::errc())
     {
-        messages::resourceMissingAtURI(asyncResp->res,
-                                       crow::utility::urlFromPieces(entryID));
+        messages::resourceNotFound(asyncResp->res, "LogEntry", entryID);
         return false;
     }
     return true;
@@ -1363,8 +1361,7 @@
             }
         }
         // Requested ID was not found
-        messages::resourceMissingAtURI(asyncResp->res,
-                                       crow::utility::urlFromPieces(targetID));
+        messages::resourceNotFound(asyncResp->res, "LogEntry", targetID);
         });
 }
 
@@ -2055,14 +2052,10 @@
         const char* end = targetID.data() + targetID.size();
 
         auto [ptr, ec] = std::from_chars(targetID.data(), end, idInt);
-        if (ec == std::errc::invalid_argument)
+        if (ec == std::errc::invalid_argument ||
+            ec == std::errc::result_out_of_range)
         {
-            messages::resourceMissingAtURI(asyncResp->res, req.urlView);
-            return;
-        }
-        if (ec == std::errc::result_out_of_range)
-        {
-            messages::resourceMissingAtURI(asyncResp->res, req.urlView);
+            messages::resourceNotFound(asyncResp->res, "LogEntry", param);
             return;
         }
 
@@ -2095,7 +2088,7 @@
         }
 
         // Requested ID was not found
-        messages::resourceMissingAtURI(asyncResp->res, req.urlView);
+        messages::resourceNotFound(asyncResp->res, "LogEntry", param);
         });
 }
 
@@ -2421,7 +2414,7 @@
         // Confirm that the entry ID matches what was requested
         if (idStr != entryID)
         {
-            messages::resourceMissingAtURI(asyncResp->res, req.urlView);
+            messages::resourceNotFound(asyncResp->res, "LogEntry", entryID);
             return;
         }
 
@@ -2931,8 +2924,7 @@
 
         if (filename.empty() || timestamp.empty())
         {
-            messages::resourceMissingAtURI(asyncResp->res,
-                                           crow::utility::urlFromPieces(logID));
+            messages::resourceNotFound(asyncResp->res, "LogEntry", logID);
             return;
         }
 
@@ -3120,20 +3112,20 @@
             if (dbusFilename.empty() || dbusTimestamp.empty() ||
                 dbusFilepath.empty())
             {
-                messages::resourceMissingAtURI(asyncResp->res, url);
+                messages::resourceNotFound(asyncResp->res, "LogEntry", logID);
                 return;
             }
 
             // Verify the file name parameter is correct
             if (fileName != dbusFilename)
             {
-                messages::resourceMissingAtURI(asyncResp->res, url);
+                messages::resourceNotFound(asyncResp->res, "LogEntry", logID);
                 return;
             }
 
             if (!std::filesystem::exists(dbusFilepath))
             {
-                messages::resourceMissingAtURI(asyncResp->res, url);
+                messages::resourceNotFound(asyncResp->res, "LogEntry", logID);
                 return;
             }
             std::ifstream ifs(dbusFilepath, std::ios::in | std::ios::binary);
@@ -3880,7 +3872,7 @@
         if (!parsePostCode(targetID, codeIndex, bootIndex))
         {
             // Requested ID was not found
-            messages::resourceMissingAtURI(asyncResp->res, req.urlView);
+            messages::resourceNotFound(asyncResp->res, "LogEntry", targetID);
             return;
         }
         if (bootIndex == 0 || codeIndex == 0)