From 2e9da515da758f29898032de5ecfe2c5c79ef392 Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Wed, 2 Jan 2013 14:51:38 +0100 Subject: [PATCH] Task database fix - TC11 [Issue#] LINUXNGWAP-643 [Bug] Test was not passing due to unhandled excpetion in installer [Cause] Wrong error code [Solution] Try-Catch blocks [Verification] run test: wrt-tests-tizen --output=text --regexp='TC11'. Test should pass. Change-Id: Idd2fa60313f7c0d1d681c0b4489bf7857d2b7818 --- src/jobs/widget_install/task_database.cpp | 32 ++++++++++++++++++------- src/jobs/widget_install/widget_install_errors.h | 3 +++ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/jobs/widget_install/task_database.cpp b/src/jobs/widget_install/task_database.cpp index ee543c8..78c06ef 100644 --- a/src/jobs/widget_install/task_database.cpp +++ b/src/jobs/widget_install/task_database.cpp @@ -70,9 +70,17 @@ void TaskDatabase::StepWrtDBInsert() if (m_context.existingWidgetInfo.isExist) //update { - m_handleToRemove = WidgetDAOReadOnly::getHandle( - m_context.locations->getPkgname()); LogInfo("Registering widget... (update)"); + Try + { + m_handleToRemove = WidgetDAOReadOnly::getHandle( + m_context.locations->getPkgname()); + } + Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) + { + LogError("Given tizenId not found for update installation (Same GUID?)"); + ThrowMsg(Exceptions::InvalidPackage, "Given tizenId not found for update installation"); + } WidgetDAO::registerOrUpdateWidget( m_context.locations->getPkgname(), m_context.widgetConfig, @@ -126,7 +134,7 @@ void TaskDatabase::StepAceDBInsert() m_context.wacSecurity.getCertificateList())) { LogError("ace database insert failed"); - ThrowMsg(Exceptions::NotAllowed, "Update failure. ace_register_widget failed"); + ThrowMsg(Exceptions::UpdateFailed, "Update failure. ace_register_widget failed"); } LogDebug("Ace data inserted"); @@ -140,15 +148,23 @@ void TaskDatabase::StepRegisterExternalFiles() WrtDB::ExternalLocationList externalLocationsUpdate = m_context.locations->listExternalLocations(); if (m_context.existingWidgetInfo.isExist) //update { - WidgetDAO dao(m_context.locations->getPkgname()); - WrtDB::ExternalLocationList externalLocationsDB = dao.getWidgetExternalLocations(); - FOREACH(file, externalLocationsDB) + Try { - if(std::find(externalLocationsUpdate.begin(), externalLocationsUpdate.end(), *file) == externalLocationsUpdate.end()) + WidgetDAO dao(m_context.locations->getPkgname()); + WrtDB::ExternalLocationList externalLocationsDB = dao.getWidgetExternalLocations(); + FOREACH(file, externalLocationsDB) { - m_externalLocationsToRemove.push_back(*file); + if(std::find(externalLocationsUpdate.begin(), externalLocationsUpdate.end(), *file) == externalLocationsUpdate.end()) + { + m_externalLocationsToRemove.push_back(*file); + } } } + Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) + { + LogError("Given tizenId not found for update installation (Same GUID?)"); + ThrowMsg(Exceptions::UpdateFailed, "Given tizenId not found for update installation"); + } } LogDebug("Registering external files:"); FOREACH(file, externalLocationsUpdate) diff --git a/src/jobs/widget_install/widget_install_errors.h b/src/jobs/widget_install/widget_install_errors.h index 109caff..b3bf040 100644 --- a/src/jobs/widget_install/widget_install_errors.h +++ b/src/jobs/widget_install/widget_install_errors.h @@ -96,6 +96,9 @@ DECLARE_JOB_EXCEPTION(Base, BackupFailed, ErrorUpdateWidget) DECLARE_JOB_EXCEPTION(Base, InsertNewWidgetFailed, ErrorUpdateWidget) DECLARE_JOB_EXCEPTION(Base, RemoveBackupFailed, ErrorUpdateWidget) +//Database +DECLARE_JOB_EXCEPTION(Base, UpdateFailed, ErrorInvalidWidgetPackage) + // Plugins copy errors DECLARE_JOB_EXCEPTION(Base, EmptyPluginsDirectory, ErrorInvalidWidgetPackage) DECLARE_JOB_EXCEPTION(Base, PluginsSubdirectory, ErrorInvalidWidgetPackage) -- 2.7.4