Kaydet (Commit) 0398e1e3 authored tarafından Szymon Kłos's avatar Szymon Kłos

CMIS: remember new session for each user

Change-Id: I7d0a72e48b8f9056e8761cae8939e2b8f6dbdd24
üst 851d73c4
...@@ -339,7 +339,7 @@ namespace cmis ...@@ -339,7 +339,7 @@ namespace cmis
// Look for a cached session, key is binding url + repo id // Look for a cached session, key is binding url + repo id
OUString sSessionId = m_aURL.getBindingUrl( ) + m_aURL.getRepositoryId( ); OUString sSessionId = m_aURL.getBindingUrl( ) + m_aURL.getRepositoryId( );
if ( NULL == m_pSession ) if ( NULL == m_pSession )
m_pSession = m_pProvider->getSession( sSessionId ); m_pSession = m_pProvider->getSession( sSessionId, m_aURL.getUsername( ) );
if ( NULL == m_pSession ) if ( NULL == m_pSession )
{ {
...@@ -411,7 +411,7 @@ namespace cmis ...@@ -411,7 +411,7 @@ namespace cmis
} }
else else
{ {
m_pProvider->registerSession(sSessionId, m_pSession); m_pProvider->registerSession(sSessionId, m_aURL.getUsername( ), m_pSession);
} }
} }
else else
...@@ -2019,14 +2019,20 @@ namespace cmis ...@@ -2019,14 +2019,20 @@ namespace cmis
{ {
// TODO Cache the objects // TODO Cache the objects
INetURLObject aURL( m_sURL );
OUString sUser = aURL.GetUser( INetURLObject::NO_DECODE );
URL aUrl( m_sURL ); URL aUrl( m_sURL );
OUString sPath( m_sObjectPath ); OUString sPath( m_sObjectPath );
if ( !sPath.endsWith("/") ) if ( !sPath.endsWith("/") )
sPath += "/"; sPath += "/";
sPath += STD_TO_OUSTR( ( *it )->getName( ) ); sPath += STD_TO_OUSTR( ( *it )->getName( ) );
OUString sId = STD_TO_OUSTR( ( *it )->getId( ) ); OUString sId = STD_TO_OUSTR( ( *it )->getId( ) );
aUrl.setObjectId( sId ); aUrl.setObjectId( sId );
aUrl.setObjectPath( sPath ); aUrl.setObjectPath( sPath );
aUrl.setUsername( sUser );
uno::Reference< ucb::XContentIdentifier > xId = new ucbhelper::ContentIdentifier( aUrl.asString( ) ); uno::Reference< ucb::XContentIdentifier > xId = new ucbhelper::ContentIdentifier( aUrl.asString( ) );
uno::Reference< ucb::XContent > xContent = new Content( m_xContext, m_pProvider, xId, *it ); uno::Reference< ucb::XContent > xContent = new Content( m_xContext, m_pProvider, xId, *it );
......
...@@ -59,10 +59,11 @@ ContentProvider::queryContent( ...@@ -59,10 +59,11 @@ ContentProvider::queryContent(
return xContent; return xContent;
} }
libcmis::Session* ContentProvider::getSession( const OUString& sBindingUrl ) libcmis::Session* ContentProvider::getSession( const OUString& sBindingUrl, const OUString& sUsername )
{ {
libcmis::Session* pSession = NULL; 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( ) ) if ( it != m_aSessionCache.end( ) )
{ {
pSession = it->second; pSession = it->second;
...@@ -70,9 +71,13 @@ libcmis::Session* ContentProvider::getSession( const OUString& sBindingUrl ) ...@@ -70,9 +71,13 @@ libcmis::Session* ContentProvider::getSession( const OUString& sBindingUrl )
return pSession; 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( ContentProvider::ContentProvider(
......
...@@ -20,7 +20,7 @@ namespace cmis ...@@ -20,7 +20,7 @@ namespace cmis
class ContentProvider : public ::ucbhelper::ContentProviderImplHelper class ContentProvider : public ::ucbhelper::ContentProviderImplHelper
{ {
private: private:
std::map< OUString, libcmis::Session* > m_aSessionCache; std::map< std::pair< OUString, OUString >, libcmis::Session* > m_aSessionCache;
public: public:
explicit ContentProvider( const ::com::sun::star::uno::Reference< explicit ContentProvider( const ::com::sun::star::uno::Reference<
...@@ -64,8 +64,8 @@ public: ...@@ -64,8 +64,8 @@ public:
throw( ::com::sun::star::ucb::IllegalIdentifierException, throw( ::com::sun::star::ucb::IllegalIdentifierException,
::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE; ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
libcmis::Session* getSession( const OUString& sBindingUrl ); libcmis::Session* getSession( const OUString& sBindingUrl, const OUString& sUsername );
void registerSession( const OUString& sBindingUrl, libcmis::Session* pSession ); void registerSession( const OUString& sBindingUrl, const OUString& sUsername, libcmis::Session* pSession );
}; };
} }
......
...@@ -53,6 +53,11 @@ namespace cmis ...@@ -53,6 +53,11 @@ namespace cmis
m_sId = sId; m_sId = sId;
} }
void URL::setUsername( const OUString& sUser )
{
m_sUser = sUser;
}
OUString URL::asString( ) OUString URL::asString( )
{ {
OUString sUrl; OUString sUrl;
...@@ -61,7 +66,9 @@ namespace cmis ...@@ -61,7 +66,9 @@ namespace cmis
rtl_UriCharClassRelSegment, rtl_UriCharClassRelSegment,
rtl_UriEncodeKeepEscapes, rtl_UriEncodeKeepEscapes,
RTL_TEXTENCODING_UTF8 ); RTL_TEXTENCODING_UTF8 );
sUrl = "vnd.libreoffice.cmis://" + sEncodedBinding; sUrl = "vnd.libreoffice.cmis://" +
( m_sUser.isEmpty() ? OUString( ) : (m_sUser + "@") ) +
sEncodedBinding;
if ( !m_sPath.isEmpty( ) ) if ( !m_sPath.isEmpty( ) )
{ {
......
...@@ -38,6 +38,7 @@ namespace cmis ...@@ -38,6 +38,7 @@ namespace cmis
const OUString& getPassword() const { return m_sPass; } const OUString& getPassword() const { return m_sPass; }
void setObjectPath( const OUString& sPath ); void setObjectPath( const OUString& sPath );
void setObjectId( const OUString& sId ); void setObjectId( const OUString& sId );
void setUsername( const OUString& sUser );
OUString asString( ); OUString asString( );
}; };
......
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