Replacing DbWidgetHandle with WidgetPkgName in SecurityOriginDAO
authorJanusz Majnert <j.majnert@samsung.com>
Tue, 4 Dec 2012 12:53:21 +0000 (13:53 +0100)
committerGerrit Code Review <gerrit2@kim11>
Mon, 10 Dec 2012 16:56:18 +0000 (01:56 +0900)
[Issue#] LINUXNGWAP-577
[Feature] Remove DbWidgetHandle from usage in SecurityOriginDAO
[Cause] N/A
[Solution] Replace widget handle with package name (Tizen ID)
[Verification] Build, run DAO and DPL tests.

Change-Id: I5943b2ef0f157be8fceb1b3a64851187a09a204a

modules/security_origin_dao/dao/security_origin_dao.cpp
modules/security_origin_dao/include/wrt-commons/security-origin-dao/security_origin_dao.h
modules/widget_dao/dao/widget_dao_read_only.cpp

index 7c1334c30ae002b95b3d8f4cdadd4e34e4b67b23..377358c09188d659feef4ce200f198afebf9e2df 100644 (file)
@@ -29,6 +29,7 @@
 #include <dpl/wrt-dao-ro/WrtDatabase.h>
 #include <dpl/wrt-dao-ro/widget_config.h>
 #include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/wrt-dao-ro/common_dao_types.h>
 #include <sys/stat.h>
 #include <fstream>
 
@@ -55,43 +56,32 @@ const char* const SECURITY_ORIGIN_DB_NAME = ".security_origin.db";
 const char* const SECURITY_ORIGIN_DB_SQL_PATH =
     "/usr/share/wrt-engine/security_origin_db.sql";
 
-std::string createDatabasePath(int widgetHandle)
+std::string createDatabasePath(const WrtDB::WidgetPkgName &pkgName)
 {
-    using namespace DPL::DB::ORM;
-    using namespace WrtDB::WidgetConfig;
-    using namespace WrtDB::GlobalConfig;
-
-    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
-    {
         std::stringstream filename;
-        WrtDB::WidgetDAOReadOnly widgetDAO(widgetHandle);
-        WrtDB::WidgetPkgName pkgname = widgetDAO.getPkgname_TEMPORARY_API();
 
-        filename << GetWidgetPersistentStoragePath(pkgname)
+        filename << WrtDB::WidgetConfig::GetWidgetPersistentStoragePath(pkgName)
                  << "/"
                  << SECURITY_ORIGIN_DB_NAME;
         return filename.str();
-    }
-    SQL_CONNECTION_EXCEPTION_HANDLER_END("Fail to get database Path")
-
 }
 
-std::string createDatabasePath(const DPL::String& tizenId)
+std::string createDatabasePath(int widgetHandle)
 {
     using namespace DPL::DB::ORM;
     using namespace WrtDB::WidgetConfig;
     using namespace WrtDB::GlobalConfig;
 
-    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    WrtDB::WidgetPkgName pkgname;
+
+    Try
     {
-        std::stringstream filename;
-        filename << GetWidgetPersistentStoragePath(tizenId)
-                 << "/"
-                 << SECURITY_ORIGIN_DB_NAME;
-        return filename.str();
+        pkgname = WrtDB::WidgetDAOReadOnly::getPkgName(widgetHandle);
     }
-    SQL_CONNECTION_EXCEPTION_HANDLER_END("Fail to get database Path")
-
+    Catch(DPL::DB::SqlConnection::Exception::Base) {
+        LogError("Failed to get database Path");
+    }
+    return createDatabasePath(pkgname);
 }
 
 void checkDatabase(std::string databasePath)
@@ -139,8 +129,8 @@ SecurityOriginDAO::SecurityOriginDAO(int handle) :
     m_securityOriginDBInterface.AttachToThread(SECURITY_ORIGIN_DB_OPTION);
 }
 
-SecurityOriginDAO::SecurityOriginDAO(const DPL::String& tizenId):
-    m_securityOriginDBPath(createDatabasePath(tizenId)),
+SecurityOriginDAO::SecurityOriginDAO(const WrtDB::WidgetPkgName &pkgName) :
+    m_securityOriginDBPath(createDatabasePath(pkgName)),
     m_securityOriginDBInterface(m_securityOriginDBPath, SECURITY_ORIGIN_DB_TYPE)
 {
     checkDatabase(m_securityOriginDBPath);
index 3d6a6f3a165bb9a88fbcfd5607a5801bd9e8581d..9dc7d9cc36e1aafd75c894c9fe4b29432d58e2c7 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <dpl/db/thread_database_support.h>
 #include <wrt-commons/security-origin-dao/security_origin_dao_types.h>
-#include <dpl/string.h>
+#include <dpl/wrt-dao-ro/common_dao_types.h>
 
 namespace SecurityOriginDB {
 
@@ -39,8 +39,8 @@ class SecurityOriginDAO
         DECLARE_EXCEPTION_TYPE(Base, DataNotExist)
     };
 
-    explicit SecurityOriginDAO(int handle);
-    explicit SecurityOriginDAO(const DPL::String& tizenId);
+    explicit SecurityOriginDAO(int handle) __attribute__((deprecated));
+    explicit SecurityOriginDAO(const WrtDB::WidgetPkgName &pkgName);
     virtual ~SecurityOriginDAO();
     SecurityOriginDataList getSecurityOriginDataList();
     Result getResult(const SecurityOriginData &securityOriginData);
index 3fb817a4e572861125c8fd449e2f4784d87f73ee..750d25854024aafa6383dd5d68600de4b7f31cdd 100644 (file)
@@ -125,7 +125,7 @@ WidgetPkgName getPkgNameByHandle(const DbWidgetHandle handle)
 
         if (rowList.empty()) {
             ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
-                 "Failed to get widget by package name");
+                 "Failed to get widget by handle");
         }
         DPL::OptionalString pkgname = rowList.front().Get_pkgname();
         if(pkgname.IsNull()){