Verify object path is empty

This commit is verify object path is empty when calling
the set method of the occ dbus, and when the object path is empty,
return directly.

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I0d0b01659e43b8ebf7e00bd455dddafebea4a5f0
diff --git a/occ_dbus.cpp b/occ_dbus.cpp
index 7028841..2ed2f3b 100644
--- a/occ_dbus.cpp
+++ b/occ_dbus.cpp
@@ -13,8 +13,13 @@
 {
 
 using namespace phosphor::logging;
-void OccDBusSensors::setMaxValue(const std::string& path, double value)
+bool OccDBusSensors::setMaxValue(const std::string& path, double value)
 {
+    if (path.empty())
+    {
+        return false;
+    }
+
     if (sensors.find(path) == sensors.end())
     {
         sensors.emplace(
@@ -22,6 +27,7 @@
     }
 
     sensors.at(path)->maxValue(value);
+    return true;
 }
 
 double OccDBusSensors::getMaxValue(const std::string& path) const
@@ -34,8 +40,13 @@
     throw std::invalid_argument("Failed to get MaxValue property.");
 }
 
-void OccDBusSensors::setMinValue(const std::string& path, double value)
+bool OccDBusSensors::setMinValue(const std::string& path, double value)
 {
+    if (path.empty())
+    {
+        return false;
+    }
+
     if (sensors.find(path) == sensors.end())
     {
         sensors.emplace(
@@ -43,6 +54,7 @@
     }
 
     sensors.at(path)->minValue(value);
+    return true;
 }
 
 double OccDBusSensors::getMinValue(const std::string& path) const
@@ -55,8 +67,13 @@
     throw std::invalid_argument("Failed to get MinValue property.");
 }
 
-void OccDBusSensors::setValue(const std::string& path, double value)
+bool OccDBusSensors::setValue(const std::string& path, double value)
 {
+    if (path.empty())
+    {
+        return false;
+    }
+
     if (sensors.find(path) == sensors.end())
     {
         sensors.emplace(
@@ -64,6 +81,7 @@
     }
 
     sensors.at(path)->value(value);
+    return true;
 }
 
 double OccDBusSensors::getValue(const std::string& path) const
@@ -76,8 +94,13 @@
     throw std::invalid_argument("Failed to get Value property.");
 }
 
-void OccDBusSensors::setUnit(const std::string& path, const std::string& value)
+bool OccDBusSensors::setUnit(const std::string& path, const std::string& value)
 {
+    if (path.empty())
+    {
+        return false;
+    }
+
     if (sensors.find(path) == sensors.end())
     {
         sensors.emplace(
@@ -91,7 +114,10 @@
     catch (const std::exception& e)
     {
         log<level::ERR>("set Unit propety failed", entry("ERROR=%s", e.what()));
+        return false;
     }
+
+    return true;
 }
 
 std::string OccDBusSensors::getUnit(const std::string& path) const
@@ -112,8 +138,13 @@
     throw std::invalid_argument("Failed to get Unit property.");
 }
 
-void OccDBusSensors::setOperationalStatus(const std::string& path, bool value)
+bool OccDBusSensors::setOperationalStatus(const std::string& path, bool value)
 {
+    if (path.empty())
+    {
+        return false;
+    }
+
     if (operationalStatus.find(path) == operationalStatus.end())
     {
         operationalStatus.emplace(path, std::make_unique<OperationalStatusIntf>(
@@ -121,6 +152,7 @@
     }
 
     operationalStatus.at(path)->functional(value);
+    return true;
 }
 
 bool OccDBusSensors::getOperationalStatus(const std::string& path) const
diff --git a/occ_dbus.hpp b/occ_dbus.hpp
index 2443a53..7a7c69c 100644
--- a/occ_dbus.hpp
+++ b/occ_dbus.hpp
@@ -44,10 +44,11 @@
     /** @brief Set the max value of the Sensor
      *
      *  @param[in] path  - The object path
-     *
      *  @param[in] value - The value of the MaxValue property
+     *
+     *  @return true or false
      */
-    void setMaxValue(const std::string& path, double value);
+    bool setMaxValue(const std::string& path, double value);
 
     /** @brief Get the max value of the Sensor
      *
@@ -60,10 +61,11 @@
     /** @brief Set the min value of the Sensor
      *
      *  @param[in] path  - The object path
-     *
      *  @param[in] value - The value of the MinValue property
+     *
+     *  @return true or false
      */
-    void setMinValue(const std::string& path, double value);
+    bool setMinValue(const std::string& path, double value);
 
     /** @brief Get the min value of the Sensor
      *
@@ -76,10 +78,11 @@
     /** @brief Set the value of the Sensor
      *
      *  @param[in] path  - The object path
-     *
      *  @param[in] value - The value of the Value property
+     *
+     *  @return true or false
      */
-    void setValue(const std::string& path, double value);
+    bool setValue(const std::string& path, double value);
 
     /** @brief Get the value of the Sensor
      *
@@ -92,10 +95,11 @@
     /** @brief Set the unit of the Sensor
      *
      *  @param[in] path  - The object path
-     *
      *  @param[in] value - The value of the Unit property
+     *
+     *  @return true or false
      */
-    void setUnit(const std::string& path, const std::string& value);
+    bool setUnit(const std::string& path, const std::string& value);
 
     /** @brief Get the unit of the Sensor
      *
@@ -108,10 +112,11 @@
     /** @brief Set the Functional property
      *
      *  @param[in] path   - The object path
-     *
      *  @param[in] value  - PLDM operational fault status
+     *
+     *  @return true or false
      */
-    void setOperationalStatus(const std::string& path, bool value);
+    bool setOperationalStatus(const std::string& path, bool value);
 
     /** @brief Get the Functional property
      *