diff options
author | Vasily Melenchuk <vasily.melenchuk@cib.de> | 2015-07-20 12:45:12 +0200 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2015-07-20 20:42:21 +0000 |
commit | 0619ed6d9cbc49cf0fbc90438d00950abca9abd0 (patch) | |
tree | f196476a72a6d0757b9293e4b6d758d839882934 /ucb | |
parent | 43e5679f009ccc1a970d2265ab3fb51d51e39a5c (diff) |
cmis: throw an error if we were not able to open repository
It was an crash before, if we have stored CMIS url with repository
that does not exist. Session was created, but with empty repo.
Now this nuance is checked and slightly improved error reporting for
cmis.
Change-Id: I447ec767fd735829f8a507733552b26e05cba441
Reviewed-on: https://gerrit.libreoffice.org/17224
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/source/ucp/cmis/cmis_content.cxx | 52 | ||||
-rw-r--r-- | ucb/source/ucp/cmis/cmis_url.hxx | 12 |
2 files changed, 52 insertions, 12 deletions
diff --git a/ucb/source/ucp/cmis/cmis_content.cxx b/ucb/source/ucp/cmis/cmis_content.cxx index 7be8c458118b..bc77db188351 100644 --- a/ucb/source/ucp/cmis/cmis_content.cxx +++ b/ucb/source/ucp/cmis/cmis_content.cxx @@ -253,6 +253,32 @@ namespace return property; } + + uno::Sequence< uno::Any > generateErrorArguments( const cmis::URL & rURL ) + { + uno::Sequence< uno::Any > aArguments(3); + + size_t i = 0; + aArguments[i++] <<= beans::PropertyValue( + OUString( "Binding URL" ), + - 1, + uno::makeAny( rURL.getBindingUrl() ), + beans::PropertyState_DIRECT_VALUE ); + + aArguments[i++] <<= beans::PropertyValue( + OUString( "Username" ), + -1, + uno::makeAny( rURL.getUsername() ), + beans::PropertyState_DIRECT_VALUE ); + + aArguments[i++] <<= beans::PropertyValue( + OUString( "Repository Id" ), + -1, + uno::makeAny( rURL.getRepositoryId() ), + beans::PropertyState_DIRECT_VALUE ); + + return aArguments; + } } namespace cmis @@ -365,14 +391,28 @@ namespace cmis m_pSession = libcmis::SessionFactory::createSession( OUSTR_TO_STDSTR( m_aURL.getBindingUrl( ) ), rUsername, rPassword, OUSTR_TO_STDSTR( m_aURL.getRepositoryId( ) ), false, oauth2Data ); - if ( m_pSession == NULL ) + if ( m_pSession == nullptr ) + { + // Fail: session was not created + ucbhelper::cancelCommandExecution( + ucb::IOErrorCode_INVALID_DEVICE, + generateErrorArguments(m_aURL), + xEnv, + OUString()); + } + else if ( m_pSession->getRepository() == nullptr ) + { + // Fail: no repository or repository is invalid ucbhelper::cancelCommandExecution( - ucb::IOErrorCode_INVALID_DEVICE, - uno::Sequence< uno::Any >( 0 ), - xEnv, - OUString( ) ); + ucb::IOErrorCode_INVALID_DEVICE, + generateErrorArguments(m_aURL), + xEnv, + OUString("error accessing a repository")); + } else - m_pProvider->registerSession( sSessionId, m_pSession ); + { + m_pProvider->registerSession(sSessionId, m_pSession); + } } else { diff --git a/ucb/source/ucp/cmis/cmis_url.hxx b/ucb/source/ucp/cmis/cmis_url.hxx index 56b1fc876859..14a32c00ca72 100644 --- a/ucb/source/ucp/cmis/cmis_url.hxx +++ b/ucb/source/ucp/cmis/cmis_url.hxx @@ -30,12 +30,12 @@ namespace cmis public: explicit URL( OUString const & urlStr ); - OUString& getObjectPath( ) { return m_sPath; } - OUString& getObjectId( ) { return m_sId; } - OUString& getBindingUrl( ) { return m_sBindingUrl; } - OUString& getRepositoryId( ) { return m_sRepositoryId; } - OUString& getUsername( ) { return m_sUser; } - OUString& getPassword( ) { return m_sPass; } + const OUString& getObjectPath() const { return m_sPath; } + const OUString& getObjectId() const { return m_sId; } + const OUString& getBindingUrl() const { return m_sBindingUrl; } + const OUString& getRepositoryId() const { return m_sRepositoryId; } + const OUString& getUsername() const { return m_sUser; } + const OUString& getPassword() const { return m_sPass; } void setObjectPath( const OUString& sPath ); void setObjectId( const OUString& sId ); |