Pkgname (tizen id) - not null
authorJan Olszak <j.olszak@samsung.com>
Tue, 20 Nov 2012 09:04:55 +0000 (10:04 +0100)
committerJan Olszak <j.olszak@samsung.com>
Tue, 27 Nov 2012 10:52:00 +0000 (11:52 +0100)
[Issue#] It was possible for pkgname to be null.
[Bug] N/A
[Cause] N/A
[Solution] Changed Column deffinition in db file and replaced DPL:Optional<DPL::String> with DPL::String.
[Verification] Build commons, wrt-installer, wrt-plugin-commons.

Change-Id: I635cbe9f20843ff8cf180e980b21d0b07619def2

modules/security_origin_dao/dao/security_origin_dao.cpp
modules/widget_dao/dao/widget_dao.cpp
modules/widget_dao/dao/widget_dao_read_only.cpp
modules/widget_dao/include/dpl/wrt-dao-ro/common_dao_types.h
modules/widget_dao/include/dpl/wrt-dao-ro/widget_dao_read_only.h
modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h
modules/widget_dao/orm/wrt_db

index 6dde00e..8cfd8ca 100644 (file)
@@ -65,9 +65,9 @@ std::string createDatabasePath(int widgetHandle)
     {
         std::stringstream filename;
         WrtDB::WidgetDAOReadOnly widgetDAO(widgetHandle);
-        DPL::Optional<DPL::String> pkgname = widgetDAO.getPkgname();
+        DPL::String pkgname = widgetDAO.getPkgname_NOTNULL();
 
-        filename << GetWidgetPersistentStoragePath(*pkgname)
+        filename << GetWidgetPersistentStoragePath(pkgname)
                  << "/"
                  << SECURITY_ORIGIN_DB_NAME;
         return filename.str();
index d46f378..9327806 100644 (file)
@@ -53,6 +53,7 @@ namespace WrtDB {
 
 WidgetDAO::WidgetDAO(DPL::OptionalString widgetGUID) :
     WidgetDAOReadOnly(WidgetDAOReadOnly::getHandle(widgetGUID))
+// TODO THIS WILL BE DELETED
 {
 }
 
@@ -119,6 +120,29 @@ void WidgetDAO::setPkgName(const DPL::OptionalString& pkgName)
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register widget")
 }
 
+void WidgetDAO::setPkgName_NOTNULL(const DPL::String& pkgName)
+{
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        using namespace DPL::DB::ORM;
+        wrt::ScopedTransaction transaction(&WrtDatabase::interface());
+
+        isWidgetInstalled(getHandle());
+
+        wrt::WidgetInfo::Row row;
+        row.Set_pkgname(pkgName);
+
+        WRT_DB_UPDATE(update, wrt::WidgetInfo, &WrtDatabase::interface())
+        update->Where(
+            Equals<wrt::WidgetInfo::app_id>(getHandle()));
+
+        update->Values(row);
+        update->Execute();
+        transaction.Commit();
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register widget")
+}
+
 void WidgetDAO::setSecurityPopupUsage(const SettingsType value)
 {
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
index 0d52aae..b23eaa6 100644 (file)
@@ -383,6 +383,19 @@ WidgetPkgNameList WidgetDAOReadOnly::getPkgnameList()
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get Pkgname list")
 }
 
+WidgetPkgNameList_NOTNULL WidgetDAOReadOnly::getPkgnameList_NOTNULL()
+{
+    LogDebug("Getting Pkgname List");
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        using namespace DPL::DB::ORM;
+        using namespace DPL::DB::ORM::wrt;
+        WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
+        return select->GetValueList<WidgetInfo::pkgname_NOTNULL>();
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get Pkgname list")
+}
+
 DbWidgetDAOReadOnlyList WidgetDAOReadOnly::getWidgetList()
 {
     LogDebug("Getting DbWidget List");
@@ -493,6 +506,12 @@ DPL::OptionalString WidgetDAOReadOnly::getPkgname() const
     return row.Get_pkgname();
 }
 
+DPL::String WidgetDAOReadOnly::getPkgname_NOTNULL() const
+{
+    WidgetInfoRow row = getWidgetInfoRow(m_widgetHandle);
+    return *row.Get_pkgname();
+}
+
 DPL::OptionalString WidgetDAOReadOnly::getDefaultlocale() const
 {
     WidgetInfoRow row = getWidgetInfoRow(m_widgetHandle);
@@ -966,9 +985,9 @@ std::string WidgetDAOReadOnly::getCookieDatabasePath() const
     using namespace WrtDB::WidgetConfig;
     std::ostringstream path;
 
-    DPL::OptionalString pkgname = getPkgname();
+    DPL::String pkgname = getPkgname_NOTNULL();
 
-    path << GetWidgetPersistentStoragePath(*pkgname);
+    path << GetWidgetPersistentStoragePath(pkgname);
     path << "/";
     path << GlobalConfig::GetCookieDatabaseFile();
 
@@ -978,8 +997,8 @@ std::string WidgetDAOReadOnly::getCookieDatabasePath() const
 std::string WidgetDAOReadOnly::getPrivateLocalStoragePath() const
 {
     std::ostringstream path;
-    DPL::OptionalString pkgname = getPkgname();
-    path << WidgetConfig::GetWidgetWebLocalStoragePath(*pkgname);
+    DPL::String pkgname = getPkgname_NOTNULL();
+    path << WidgetConfig::GetWidgetWebLocalStoragePath(pkgname);
     path << "/";
 
     return path.str();
index c40e396..6b69d17 100644 (file)
@@ -238,6 +238,8 @@ typedef std::list<DbWidgetHandle> DbWidgetHandleList;
 
 typedef std::list<DPL::Optional<WidgetPkgName> > WidgetPkgNameList; //TODO: this cannot be null -> appropriate changes in db schema needed
 
+typedef std::list<WidgetPkgName > WidgetPkgNameList_NOTNULL; //TODO: this cannot be null -> appropriate changes in db schema needed
+
 class WidgetDAOReadOnly; //forward declaration
 typedef std::shared_ptr<WidgetDAOReadOnly> WidgetDAOReadOnlyPtr;
 /**
index 3d33b89..d427ce1 100644 (file)
@@ -175,7 +175,10 @@ struct WidgetRegisterInfo
     int isTestWidget;
     ConfigParserData configInfo;
     LocalizationData localizationData;
+
     DPL::OptionalString pkgname;
+    DPL::String pkgname_NOTNULL;
+
     time_t installedTime;
     PackagingType packagingType;
     EncryptedFileList encryptedFiles;
@@ -366,6 +369,8 @@ class WidgetDAOReadOnly
      */
     DPL::OptionalString getPkgname() const;
 
+    DPL::String getPkgname_NOTNULL() const;
+
     /**
      * This method returns the defaultlocale for the widget.
      *
@@ -559,6 +564,7 @@ class WidgetDAOReadOnly
      * @return list of pkgname of installed packages
      */
     static WidgetPkgNameList getPkgnameList();
+    static WidgetPkgNameList_NOTNULL getPkgnameList_NOTNULL();
 
     /**
      * This method returns a list of all the installed widgets.
@@ -569,7 +575,6 @@ class WidgetDAOReadOnly
      *  DB table.
      */
     static DbWidgetDAOReadOnlyList getWidgetList();
-
    /**
      * This method removes a widget's information from EmDB.
      *
index 44b9d1b..9888852 100644 (file)
@@ -134,6 +134,8 @@ class WidgetDAO : public WidgetDAOReadOnly
      */
     void setPkgName(const DPL::OptionalString& pkgName);
 
+    void setPkgName_NOTNULL(const DPL::String& pkgName);
+
     /* This function will update of api-feature status.
      * If status is true (feature rejected) plugin connected with this
      * api feature mustn't be loaded durign widget launch.
index 56c93a0..9167222 100644 (file)
@@ -39,6 +39,7 @@ CREATE_TABLE(WidgetInfo)
     COLUMN(access_network,          TINYINT,       DEFAULT 0)
     COLUMN(defaultlocale,           VARCHAR(256),  DEFAULT 0)
     COLUMN(pkgname,                 VARCHAR(256),  DEFAULT 0 UNIQUE)
+    COLUMN_NOT_NULL(pkgname_NOTNULL,VARCHAR(256),  DEFAULT 0 UNIQUE)
     COLUMN(pkg_type,                INT,  DEFAULT 0)
 CREATE_TABLE_END()