diff options
author | Cao Cuong Ngo <cao.cuong.ngo@gmail.com> | 2013-07-16 19:16:44 +0200 |
---|---|---|
committer | Cao Cuong Ngo <cao.cuong.ngo@gmail.com> | 2013-07-16 19:30:39 +0200 |
commit | b2e7610ca2ff5f7edae3312116e1a04792ac7a16 (patch) | |
tree | 151a5b6ab833c071b092f738e90fdd7258b7161d | |
parent | ae0903a8db71a695483a1801fc72739992be4fe5 (diff) |
CMIS: getRepositories should call createSession
Change-Id: Ia64e15ab53155118dcfdd007a5d76e649bdeded9
-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 b2a0196817e1..e0fd7af51244 100644 --- a/ucb/source/ucp/cmis/cmis_repo_content.cxx +++ b/ucb/source/ucp/cmis/cmis_repo_content.cxx @@ -32,6 +32,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 ) @@ -142,14 +143,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 { @@ -179,6 +191,8 @@ namespace cmis repo = *it; } } + else + repo = m_aRepositories.front( ); return repo; } |