diff options
author | Szymon Kłos <eszkadev@gmail.com> | 2015-07-29 10:18:20 +0200 |
---|---|---|
committer | Szymon Kłos <eszkadev@gmail.com> | 2015-08-14 08:45:16 +0200 |
commit | 0398e1e3967332c49b6451b5d41bcf0357052d0b (patch) | |
tree | b85b2e525ba1a0ce92d72c100c9ce56f1bbf61b2 /ucb | |
parent | 851d73c4d99151dfbc5684a8800f5d92b94e8b36 (diff) |
CMIS: remember new session for each user
Change-Id: I7d0a72e48b8f9056e8761cae8939e2b8f6dbdd24
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/source/ucp/cmis/cmis_content.cxx | 10 | ||||
-rw-r--r-- | ucb/source/ucp/cmis/cmis_provider.cxx | 13 | ||||
-rw-r--r-- | ucb/source/ucp/cmis/cmis_provider.hxx | 6 | ||||
-rw-r--r-- | ucb/source/ucp/cmis/cmis_url.cxx | 9 | ||||
-rw-r--r-- | ucb/source/ucp/cmis/cmis_url.hxx | 1 |
5 files changed, 29 insertions, 10 deletions
diff --git a/ucb/source/ucp/cmis/cmis_content.cxx b/ucb/source/ucp/cmis/cmis_content.cxx index 3ee3518dd599..d23ce6e4ea4a 100644 --- a/ucb/source/ucp/cmis/cmis_content.cxx +++ b/ucb/source/ucp/cmis/cmis_content.cxx @@ -339,7 +339,7 @@ namespace cmis // Look for a cached session, key is binding url + repo id OUString sSessionId = m_aURL.getBindingUrl( ) + m_aURL.getRepositoryId( ); if ( NULL == m_pSession ) - m_pSession = m_pProvider->getSession( sSessionId ); + m_pSession = m_pProvider->getSession( sSessionId, m_aURL.getUsername( ) ); if ( NULL == m_pSession ) { @@ -411,7 +411,7 @@ namespace cmis } else { - m_pProvider->registerSession(sSessionId, m_pSession); + m_pProvider->registerSession(sSessionId, m_aURL.getUsername( ), m_pSession); } } else @@ -2019,14 +2019,20 @@ namespace cmis { // TODO Cache the objects + INetURLObject aURL( m_sURL ); + OUString sUser = aURL.GetUser( INetURLObject::NO_DECODE ); + URL aUrl( m_sURL ); OUString sPath( m_sObjectPath ); if ( !sPath.endsWith("/") ) sPath += "/"; sPath += STD_TO_OUSTR( ( *it )->getName( ) ); OUString sId = STD_TO_OUSTR( ( *it )->getId( ) ); + aUrl.setObjectId( sId ); aUrl.setObjectPath( sPath ); + aUrl.setUsername( sUser ); + uno::Reference< ucb::XContentIdentifier > xId = new ucbhelper::ContentIdentifier( aUrl.asString( ) ); uno::Reference< ucb::XContent > xContent = new Content( m_xContext, m_pProvider, xId, *it ); diff --git a/ucb/source/ucp/cmis/cmis_provider.cxx b/ucb/source/ucp/cmis/cmis_provider.cxx index a41b52c9cf94..c9819b51c423 100644 --- a/ucb/source/ucp/cmis/cmis_provider.cxx +++ b/ucb/source/ucp/cmis/cmis_provider.cxx @@ -59,10 +59,11 @@ ContentProvider::queryContent( return xContent; } -libcmis::Session* ContentProvider::getSession( const OUString& sBindingUrl ) +libcmis::Session* ContentProvider::getSession( const OUString& sBindingUrl, const OUString& sUsername ) { libcmis::Session* pSession = NULL; - std::map< OUString, libcmis::Session* >::iterator it = m_aSessionCache.find( sBindingUrl ); + std::map< std::pair< OUString, OUString >, libcmis::Session* >::iterator it + = m_aSessionCache.find( std::pair< OUString, OUString >( sBindingUrl, sUsername ) ); if ( it != m_aSessionCache.end( ) ) { pSession = it->second; @@ -70,9 +71,13 @@ libcmis::Session* ContentProvider::getSession( const OUString& sBindingUrl ) return pSession; } -void ContentProvider::registerSession( const OUString& sBindingUrl, libcmis::Session* pSession ) +void ContentProvider::registerSession( const OUString& sBindingUrl, const OUString& sUsername, libcmis::Session* pSession ) { - m_aSessionCache.insert( std::pair< OUString, libcmis::Session* >( sBindingUrl, pSession ) ); + m_aSessionCache.insert( std::pair< std::pair< OUString, OUString >, libcmis::Session* > + ( + std::pair< OUString, OUString >( sBindingUrl, sUsername ), + pSession + ) ); } ContentProvider::ContentProvider( diff --git a/ucb/source/ucp/cmis/cmis_provider.hxx b/ucb/source/ucp/cmis/cmis_provider.hxx index efbd439462a5..1dcad0a84852 100644 --- a/ucb/source/ucp/cmis/cmis_provider.hxx +++ b/ucb/source/ucp/cmis/cmis_provider.hxx @@ -20,7 +20,7 @@ namespace cmis class ContentProvider : public ::ucbhelper::ContentProviderImplHelper { private: - std::map< OUString, libcmis::Session* > m_aSessionCache; + std::map< std::pair< OUString, OUString >, libcmis::Session* > m_aSessionCache; public: explicit ContentProvider( const ::com::sun::star::uno::Reference< @@ -64,8 +64,8 @@ public: throw( ::com::sun::star::ucb::IllegalIdentifierException, ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE; - libcmis::Session* getSession( const OUString& sBindingUrl ); - void registerSession( const OUString& sBindingUrl, libcmis::Session* pSession ); + libcmis::Session* getSession( const OUString& sBindingUrl, const OUString& sUsername ); + void registerSession( const OUString& sBindingUrl, const OUString& sUsername, libcmis::Session* pSession ); }; } diff --git a/ucb/source/ucp/cmis/cmis_url.cxx b/ucb/source/ucp/cmis/cmis_url.cxx index ff0763c829f3..533ebf2e4b11 100644 --- a/ucb/source/ucp/cmis/cmis_url.cxx +++ b/ucb/source/ucp/cmis/cmis_url.cxx @@ -53,6 +53,11 @@ namespace cmis m_sId = sId; } + void URL::setUsername( const OUString& sUser ) + { + m_sUser = sUser; + } + OUString URL::asString( ) { OUString sUrl; @@ -61,7 +66,9 @@ namespace cmis rtl_UriCharClassRelSegment, rtl_UriEncodeKeepEscapes, RTL_TEXTENCODING_UTF8 ); - sUrl = "vnd.libreoffice.cmis://" + sEncodedBinding; + sUrl = "vnd.libreoffice.cmis://" + + ( m_sUser.isEmpty() ? OUString( ) : (m_sUser + "@") ) + + sEncodedBinding; if ( !m_sPath.isEmpty( ) ) { diff --git a/ucb/source/ucp/cmis/cmis_url.hxx b/ucb/source/ucp/cmis/cmis_url.hxx index 14a32c00ca72..c09b509ea5dc 100644 --- a/ucb/source/ucp/cmis/cmis_url.hxx +++ b/ucb/source/ucp/cmis/cmis_url.hxx @@ -38,6 +38,7 @@ namespace cmis const OUString& getPassword() const { return m_sPass; } void setObjectPath( const OUString& sPath ); void setObjectId( const OUString& sId ); + void setUsername( const OUString& sUser ); OUString asString( ); }; |