From c09c5a1e42b898a1d1558377695f609c4426d50c Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 20 Mar 2013 16:40:46 +0100 Subject: deb#703486: Keep migrating more user extensions after one failed (cherry picked from commit 190b9257367884fa8561410ebe6fb9df7fd9c465) Conflicts: desktop/source/migration/services/oo3extensionmigration.cxx Change-Id: I9cc8acac54bd5a02652462c3967b4c81f7cf8ee3 Reviewed-on: https://gerrit.libreoffice.org/2878 Reviewed-by: Fridrich Strba Reviewed-by: Noel Power Tested-by: Noel Power --- .../migration/services/oo3extensionmigration.cxx | 54 ++++++++-------------- .../migration/services/oo3extensionmigration.hxx | 6 +-- 2 files changed, 21 insertions(+), 39 deletions(-) (limited to 'desktop') diff --git a/desktop/source/migration/services/oo3extensionmigration.cxx b/desktop/source/migration/services/oo3extensionmigration.cxx index aed03fa4b4a0..508ca259d6a5 100644 --- a/desktop/source/migration/services/oo3extensionmigration.cxx +++ b/desktop/source/migration/services/oo3extensionmigration.cxx @@ -40,6 +40,7 @@ #include #include #include +#include using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -304,47 +305,28 @@ bool OO3ExtensionMigration::scanDescriptionXml( const ::rtl::OUString& sDescript return true; } -bool OO3ExtensionMigration::migrateExtension( const ::rtl::OUString& sSourceDir ) +void OO3ExtensionMigration::migrateExtension( const ::rtl::OUString& sSourceDir ) { - if ( !m_xExtensionManager.is() ) + css::uno::Reference< css::deployment::XExtensionManager > extMgr( + deployment::ExtensionManager::get( m_ctx ) ); + try { - try - { - m_xExtensionManager = deployment::ExtensionManager::get( m_ctx ); - } - catch ( const ucb::CommandFailedException & ){} - catch ( const uno::RuntimeException & ) {} + TmpRepositoryCommandEnv* pCmdEnv = new TmpRepositoryCommandEnv(); + + uno::Reference< ucb::XCommandEnvironment > xCmdEnv( + static_cast< cppu::OWeakObject* >( pCmdEnv ), uno::UNO_QUERY ); + uno::Reference< task::XAbortChannel > xAbortChannel; + extMgr->addExtension( + sSourceDir, uno::Sequence(), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user")), xAbortChannel, xCmdEnv ); } - - if ( m_xExtensionManager.is() ) + catch ( css::uno::Exception & e ) { - try - { - TmpRepositoryCommandEnv* pCmdEnv = new TmpRepositoryCommandEnv(); - - uno::Reference< ucb::XCommandEnvironment > xCmdEnv( - static_cast< cppu::OWeakObject* >( pCmdEnv ), uno::UNO_QUERY ); - uno::Reference< task::XAbortChannel > xAbortChannel; - uno::Reference< deployment::XPackage > xPackage = - m_xExtensionManager->addExtension( - sSourceDir, uno::Sequence(), - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user")), xAbortChannel, xCmdEnv ); - - if ( xPackage.is() ) - return true; - } - catch ( const ucb::CommandFailedException& ) - { - } - catch ( const ucb::CommandAbortedException& ) - { - } - catch ( const lang::IllegalArgumentException& ) - { - } + SAL_WARN( + "desktop.migration", + "Ignoring UNO Exception while migrating extension from <" + << sSourceDir << ">: \"" << e.Message << "\""); } - - return false; } diff --git a/desktop/source/migration/services/oo3extensionmigration.hxx b/desktop/source/migration/services/oo3extensionmigration.hxx index a3db98abedb2..96a8b2290443 100644 --- a/desktop/source/migration/services/oo3extensionmigration.hxx +++ b/desktop/source/migration/services/oo3extensionmigration.hxx @@ -26,7 +26,8 @@ #include #include #include -#include +#include +#include #include #include @@ -68,7 +69,6 @@ namespace migration ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_ctx; ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XDocumentBuilder > m_xDocBuilder; ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess3 > m_xSimpleFileAccess; - ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > m_xExtensionManager; ::osl::Mutex m_aMutex; ::rtl::OUString m_sSourceDir; ::rtl::OUString m_sTargetDir; @@ -85,7 +85,7 @@ namespace migration ScanResult scanExtensionFolder( const ::rtl::OUString& sExtFolder ); void scanUserExtensions( const ::rtl::OUString& sSourceDir, TStringVector& aMigrateExtensions ); bool scanDescriptionXml( const ::rtl::OUString& sDescriptionXmlFilePath ); - bool migrateExtension( const ::rtl::OUString& sSourceDir ); + void migrateExtension( const ::rtl::OUString& sSourceDir ); public: OO3ExtensionMigration(::com::sun::star::uno::Reference< -- cgit v1.2.3