diff options
author | Cao Cuong Ngo <cao.cuong.ngo@gmail.com> | 2013-07-16 19:16:44 +0200 |
---|---|---|
committer | Cédric Bosdonnat <cedric.bosdonnat.ooo@free.fr> | 2013-09-02 13:51:51 +0200 |
commit | 9431ace820221a77f9110165ba7f3746a7bdb538 (patch) | |
tree | 87b71503356f7050b198fea279595dacbc6666a0 /ucb | |
parent | f6c9bf4abe7b5f21489cf4692d93a15fac8617cc (diff) |
CMIS: getRepositories should call createSession
Change-Id: Ia64e15ab53155118dcfdd007a5d76e649bdeded9
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/source/ucp/cmis/cmis_repo_content.cxx | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/ucb/source/ucp/cmis/cmis_repo_content.cxx b/ucb/source/ucp/cmis/cmis_repo_content.cxx index 61ada61f929f..ae302a90d1ee 100644 --- a/ucb/source/ucp/cmis/cmis_repo_content.cxx +++ b/ucb/source/ucp/cmis/cmis_repo_content.cxx @@ -29,6 +29,7 @@ #include "cmis_provider.hxx" #include "cmis_repo_content.hxx" #include "cmis_resultset.hxx" +#include "cmis_oauth2_providers.hxx" #define OUSTR_TO_STDSTR(s) string( OUStringToOString( s, RTL_TEXTENCODING_UTF8 ).getStr() ) #define STD_TO_OUSTR( str ) OUString( str.c_str(), str.length( ), RTL_TEXTENCODING_UTF8 ) @@ -139,14 +140,25 @@ namespace cmis string rPassword = OUSTR_TO_STDSTR( m_aURL.getPassword( ) ); if ( authProvider.authenticationQuery( rUsername, rPassword ) ) { - try - { - m_aRepositories = libcmis::SessionFactory::getRepositories( - OUSTR_TO_STDSTR( m_aURL.getBindingUrl( ) ), rUsername, rPassword ); - } - catch (const libcmis::Exception&) - { - } + // Create a session to get repositories + libcmis::OAuth2DataPtr oauth2Data = NULL; + if ( m_aURL.getBindingUrl( ) == GDRIVE_BASE_URL ) + oauth2Data.reset( new libcmis::OAuth2Data( + GDRIVE_AUTH_URL, GDRIVE_TOKEN_URL, + GDRIVE_SCOPE, GDRIVE_REDIRECT_URI, + GDRIVE_CLIENT_ID, GDRIVE_CLIENT_SECRET ) ); + + libcmis::Session* session = libcmis::SessionFactory::createSession( + OUSTR_TO_STDSTR( m_aURL.getBindingUrl( ) ), + rUsername, rPassword, "", sal_False, oauth2Data ); + if (session == NULL ) + ucbhelper::cancelCommandExecution( + ucb::IOErrorCode_INVALID_DEVICE, + uno::Sequence< uno::Any >( 0 ), + xEnv, + OUString( ) ); + m_aRepositories = session->getRepositories( ); + delete session; } else { @@ -176,6 +188,8 @@ namespace cmis repo = *it; } } + else + repo = m_aRepositories.front( ); return repo; } |