[DataSync] remove
authorRyszard Matuszyk <r.matuszyk@samsung.com>
Wed, 14 Jan 2015 14:33:35 +0000 (15:33 +0100)
committerRafal Galka <r.galka@samsung.com>
Thu, 15 Jan 2015 13:07:57 +0000 (22:07 +0900)
Change-Id: I683158d8f9455c936150dcd5133b4356e785cfac
Signed-off-by: Ryszard Matuszyk <r.matuszyk@samsung.com>
src/datasync/datasync_instance.cc
src/datasync/datasync_manager.cc
src/datasync/datasync_manager.h

index 658be31415b94e4034c9bce833a1a90dda42a18b..fa356fd4d7f7b4191147313e3e1e7da85f9d86c7 100644 (file)
@@ -85,11 +85,10 @@ void DatasyncInstance::Update(const picojson::value &args, picojson::object &out
 }
 
 void DatasyncInstance::Remove(const picojson::value &args, picojson::object &out) {
-//  TODO: implementation
-
-    picojson::value val{picojson::object{}};
+  DataSyncManager::Instance().Remove(args.get("profileId").get<std::string>());
 
-    ReportSuccess(val, out);
+  picojson::value val{picojson::object{}};
+  ReportSuccess(val, out);
 }
 
 void DatasyncInstance::StartSync(const picojson::value &args, picojson::object &out) {
index 6a88dc06f5af6bd3594eb7ee47082d491843511b..bf72d9d54a6d8195250cdfcae82d4a9e996f234d 100644 (file)
@@ -360,33 +360,21 @@ void DataSyncManager::Update(const picojson::object& args) {
   }
 }
 
-ResultOrError<void> DataSyncManager::Remove(const std::string& id) {
+void DataSyncManager::Remove(const std::string& id) {
   ds_profile_h profile_h = nullptr;
 
-  auto exit = common::MakeScopeExit([&profile_h]() {
-    if (profile_h) {
-      sync_agent_ds_free_profile_info(profile_h);
-    }
-  });
-
-  sync_agent_ds_error_e ret = SYNC_AGENT_DS_FAIL;
-
   int profile_id = std::stoi(id);
   LoggerD("profileId: %d", profile_id);
 
-  ret = sync_agent_ds_get_profile(profile_id, &profile_h);
+  sync_agent_ds_error_e ret = sync_agent_ds_get_profile(profile_id, &profile_h);
   if (SYNC_AGENT_DS_SUCCESS != ret) {
-    return Error("Exception",
-        "Platform error while getting a profile");
+    throw UnknownException("Platform error while getting a profile");
   }
 
   ret = sync_agent_ds_delete_profile(profile_h);
   if (SYNC_AGENT_DS_SUCCESS != ret && SYNC_AGENT_DS_SYNCHRONISING != ret) {
-    return Error("Exception",
-        "Platform error while deleting a profile");
+    throw UnknownException("Platform error while deleting a profile");
   }
-
-  return {};
 }
 
 int DataSyncManager::GetMaxProfilesNum() const {
index 98a13d9e1415b66ecf086d9c984e603b7982f0b9..9660e66d34562f86445dbc087318b7b950eb18bc 100644 (file)
@@ -36,7 +36,7 @@ class DataSyncManager {
 
   int Add(const picojson::object &args);
   void Update(const picojson::object &args);
-  ResultOrError<void> Remove(const std::string& id);
+  void Remove(const std::string& id);
 
   int GetMaxProfilesNum() const;
   int GetProfilesNum() const;