Implement Report persistency

Now Report properties are stored in non-volatile memory. It allows
to restore Report after system restart. Persistency of a report is
controlled by Persistency property in Report interface.

Tested:
 - Passed unit tests
 - Verified that report is stored in /var/lib/telemetry dir
 - Verified that report is restored from storage after telemetry
   service start

Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com>
Change-Id: Iccfe21603eecffc4e174a4403f699b03de320db9
diff --git a/src/persistent_json_storage.cpp b/src/persistent_json_storage.cpp
index 8fb3fe9..58a2e6c 100644
--- a/src/persistent_json_storage.cpp
+++ b/src/persistent_json_storage.cpp
@@ -92,34 +92,21 @@
 }
 
 std::vector<interfaces::JsonStorage::FilePath>
-    PersistentJsonStorage::list(const DirectoryPath& subDirectory) const
+    PersistentJsonStorage::list() const
 {
-    auto result = std::vector<FilePath>();
-    const auto path = join(directory, subDirectory);
-
-    if (!std::filesystem::exists(path))
+    std::vector<interfaces::JsonStorage::FilePath> result;
+    if (!std::filesystem::exists(directory))
     {
         return result;
     }
 
-    for (const auto& p : std::filesystem::directory_iterator(path))
+    for (const auto& p :
+         std::filesystem::recursive_directory_iterator(directory))
     {
-        if (std::filesystem::is_directory(p.path()))
+        if (p.is_regular_file())
         {
-            for (auto& item : list(DirectoryPath(p.path())))
-            {
-                result.emplace_back(std::move(item));
-            }
-        }
-        else
-        {
-            const auto item = std::filesystem::relative(
-                p.path().parent_path(), std::filesystem::path{directory});
-
-            if (std::find(result.begin(), result.end(), item) == result.end())
-            {
-                result.emplace_back(item);
-            }
+            auto item = std::filesystem::relative(p.path(), directory);
+            result.emplace_back(std::move(item));
         }
     }
 
@@ -142,3 +129,8 @@
         path, std::filesystem::is_directory(path) ? dirPerms : filePerms,
         std::filesystem::perm_options::replace);
 }
+
+bool PersistentJsonStorage::exist(const FilePath& subPath) const
+{
+    return std::filesystem::exists(join(directory, subPath));
+}