Kaydet (Commit) 0619ed6d authored tarafından Vasily Melenchuk's avatar Vasily Melenchuk Kaydeden (comit) Thorsten Behrens

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/17224Reviewed-by: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
Tested-by: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
üst 43e5679f
......@@ -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
{
......
......@@ -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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment