From fd32788092fcb29526ae73ae3bae6767dbb1e490 Mon Sep 17 00:00:00 2001 From: Cédric Bosdonnat Date: Mon, 4 Jun 2012 10:13:17 +0200 Subject: CMIS UCP: changed URLs to have hierarchical path Hierarchical path is assumed in loads of places, changed the URLs to the following: * Binding URL is encoded in the authority part, the repository ID is set as a fragment of the binding URL. * The hierarchical path reflects one of the path to the document on the server :x Change-Id: I8214daeb1d9c9b0f6ab86bdf60875e7e4e5369f4 --- fpicker/source/office/ServerDetailsControls.cxx | 48 ++++------- .../data/org/openoffice/ucb/Configuration.xcu | 6 +- tools/qa/cppunit/test_urlobj.cxx | 31 +++++-- tools/source/fsys/urlobj.cxx | 46 +++++++++-- ucb/source/ucp/cmis/cmis_content.cxx | 96 +++++++++++++--------- ucb/source/ucp/cmis/cmis_content.hxx | 2 +- ucb/source/ucp/cmis/cmis_datasupplier.cxx | 10 ++- ucb/source/ucp/cmis/cmis_url.cxx | 87 ++++++++------------ ucb/source/ucp/cmis/cmis_url.hxx | 14 ++-- 9 files changed, 185 insertions(+), 155 deletions(-) diff --git a/fpicker/source/office/ServerDetailsControls.cxx b/fpicker/source/office/ServerDetailsControls.cxx index ae52de429e53..dc31dc54db64 100644 --- a/fpicker/source/office/ServerDetailsControls.cxx +++ b/fpicker/source/office/ServerDetailsControls.cxx @@ -26,6 +26,8 @@ * instead of those above. */ +#include + #include "PlaceEditDialog.hrc" #include "fpsofficeResMgr.hxx" @@ -279,10 +281,13 @@ INetURLObject CmisDetailsContainer::getUrl( ) rtl::OUString sUrl; if ( !sBindingUrl.isEmpty( ) && !sRepo.isEmpty() ) { - sal_Int32 pos = sBindingUrl.indexOf( rtl::OUString::createFromAscii( "://" ) ); - if ( pos > 0 ) - sBindingUrl = sBindingUrl.copy( pos + 3 ); - sUrl = "cmis+atom://" + sBindingUrl + "?repo-id=" + sRepo; + rtl::OUString sEncodedBinding = rtl::Uri::encode( + sBindingUrl + "#" + sRepo, + rtl_UriCharClassUricNoSlash, + rtl_UriEncodeKeepEscapes, + RTL_TEXTENCODING_UTF8 ); + sUrl = "vnd.libreoffice.cmis+atom://" + sEncodedBinding; + INetURLObject test( sUrl ); } return INetURLObject( sUrl ); @@ -294,38 +299,13 @@ bool CmisDetailsContainer::setUrl( const INetURLObject& rUrl ) if ( bSuccess ) { - rtl::OUString sBindingUrl( "http://" ); - sBindingUrl += rUrl.GetHost( ); - if ( rUrl.HasPort( ) ) - sBindingUrl += rtl::OUString::valueOf( sal_Int32( rUrl.GetPort( ) ) ); - sBindingUrl += rUrl.GetURLPath( ); - - // Split the query into bits and locate the repo-id key - rtl::OUString sQuery = rUrl.GetParam( ); + rtl::OUString sBindingUrl; rtl::OUString sRepositoryId; - while ( !sQuery.isEmpty() ) - { - sal_Int32 nPos = sQuery.indexOfAsciiL( "&", 1 ); - rtl::OUString sSegment; - if ( nPos > 0 ) - { - sSegment = sQuery.copy( 0, nPos ); - sQuery = sQuery.copy( nPos + 1 ); - } - else - { - sSegment = sQuery; - sQuery = rtl::OUString(); - } - - sal_Int32 nEqPos = sSegment.indexOfAsciiL( "=", 1 ); - rtl::OUString key = sSegment.copy( 0, nEqPos ); - rtl::OUString value = sSegment.copy( nEqPos +1 ); - - if ( key == "repo-id" ) - sRepositoryId = value; - } + rtl::OUString sDecodedHost = rUrl.GetHost( INetURLObject::DECODE_WITH_CHARSET ); + INetURLObject aHostUrl( sDecodedHost ); + sBindingUrl = aHostUrl.GetURLNoMark( ); + sRepositoryId = aHostUrl.GetMark( ); static_cast< Edit* >( getControl( ED_ADDPLACE_CMIS_BINDING ) )->SetText( sBindingUrl ); static_cast< Edit* >( getControl( ED_ADDPLACE_CMIS_REPOSITORY ) )->SetText( sRepositoryId ); diff --git a/officecfg/registry/data/org/openoffice/ucb/Configuration.xcu b/officecfg/registry/data/org/openoffice/ucb/Configuration.xcu index 58d6e4167c8e..198a660c8cf1 100644 --- a/officecfg/registry/data/org/openoffice/ucb/Configuration.xcu +++ b/officecfg/registry/data/org/openoffice/ucb/Configuration.xcu @@ -26,7 +26,7 @@ * ************************************************************************ --> - + @@ -202,14 +202,14 @@ com.sun.star.ucb.CmisContentProvider - cmis+atom + vnd.libreoffice.cmis+atom - + com.sun.star.ucb.GIOContentProvider diff --git a/tools/qa/cppunit/test_urlobj.cxx b/tools/qa/cppunit/test_urlobj.cxx index da11113111d1..0a3a714f2942 100644 --- a/tools/qa/cppunit/test_urlobj.cxx +++ b/tools/qa/cppunit/test_urlobj.cxx @@ -245,14 +245,29 @@ namespace tools_urlobj void urlobjCmisTest( ) { - INetURLObject aUrl( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "cmis+atom://foo.bar.com:8080/my%2Fcmis%2Fatom/path/to/content" ) ) ); - CPPUNIT_ASSERT_EQUAL( std::string( "foo.bar.com" ), - OUSTR_TO_STDSTR( aUrl.GetHost( INetURLObject::NO_DECODE ) ) ); - CPPUNIT_ASSERT( aUrl.GetPort( ) == 8080 ); - CPPUNIT_ASSERT_EQUAL( std::string( "/my%2Fcmis%2Fatom/path/to/content" ), - OUSTR_TO_STDSTR( aUrl.GetURLPath( INetURLObject::NO_DECODE ) ) ); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Wrong protocol found", INET_PROT_CMIS_ATOM, aUrl.GetProtocol( ) ); + // Test with a username part + { + INetURLObject aUrl( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + "vnd.libreoffice.cmis+atom://username@http:%2F%2Ffoo.bar.com:8080%2Fmy%2Fcmis%2Fatom%23repo-id-encoded/path/to/content" ) ) ); + CPPUNIT_ASSERT_EQUAL( std::string( "http://foo.bar.com:8080/my/cmis/atom#repo-id-encoded" ), + OUSTR_TO_STDSTR( aUrl.GetHost( INetURLObject::DECODE_WITH_CHARSET ) ) ); + CPPUNIT_ASSERT_EQUAL( std::string( "username" ), OUSTR_TO_STDSTR( aUrl.GetUser( ) ) ); + CPPUNIT_ASSERT_EQUAL( std::string( "/path/to/content" ), + OUSTR_TO_STDSTR( aUrl.GetURLPath( INetURLObject::NO_DECODE ) ) ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Wrong protocol found", INET_PROT_CMIS_ATOM, aUrl.GetProtocol( ) ); + } + + // Test without a username part + { + INetURLObject aUrl( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + "vnd.libreoffice.cmis+atom://http:%2F%2Ffoo.bar.com:8080%2Fmy%2Fcmis%2Fatom%23repo-id-encoded/path/to/content" ) ) ); + CPPUNIT_ASSERT_EQUAL( std::string( "http://foo.bar.com:8080/my/cmis/atom#repo-id-encoded" ), + OUSTR_TO_STDSTR( aUrl.GetHost( INetURLObject::DECODE_WITH_CHARSET ) ) ); + CPPUNIT_ASSERT( !aUrl.HasUserData() ); + CPPUNIT_ASSERT_EQUAL( std::string( "/path/to/content" ), + OUSTR_TO_STDSTR( aUrl.GetURLPath( INetURLObject::NO_DECODE ) ) ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Wrong protocol found", INET_PROT_CMIS_ATOM, aUrl.GetProtocol( ) ); + } } // Change the following lines only, if you add, remove or rename diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx index 49477eb68a91..eb125fe19983 100644 --- a/tools/source/fsys/urlobj.cxx +++ b/tools/source/fsys/urlobj.cxx @@ -428,8 +428,8 @@ static INetURLObject::SchemeInfo const aSchemeInfoMap[INET_PROT_END] false, true }, { "sftp", "sftp://", 22, true, true, false, true, true, true, true, true }, - { "cmis+atom", "cmis+atom://", 0, true, true, false, - true, true, true, true, true } }; + { "vnd.libreoffice.cmis+atom", "vnd.libreoffice.cmis+atom://", 0, true, true, false, + false, true, false, true, true } }; // static @@ -957,6 +957,7 @@ bool INetURLObject::setAbsURIRef(rtl::OUString const & rTheAbsURIRef, } case INET_PROT_VND_SUN_STAR_PKG: + case INET_PROT_CMIS_ATOM: { if (pEnd - pPos < 2 || *pPos++ != '/' || *pPos++ != '/') { @@ -964,8 +965,10 @@ bool INetURLObject::setAbsURIRef(rtl::OUString const & rTheAbsURIRef, return false; } aSynAbsURIRef.appendAscii(RTL_CONSTASCII_STRINGPARAM("//")); - rtl::OUStringBuffer aSynAuthority; - while (pPos < pEnd + rtl::OUStringBuffer aSynUser; + + bool bHasUser = false; + while (pPos < pEnd && *pPos != '@' && *pPos != '/' && *pPos != '?' && *pPos != nFragmentDelimiter) { @@ -973,9 +976,38 @@ bool INetURLObject::setAbsURIRef(rtl::OUString const & rTheAbsURIRef, sal_uInt32 nUTF32 = getUTF32(pPos, pEnd, bOctets, cEscapePrefix, eMechanism, eCharset, eEscapeType); - appendUCS4(aSynAuthority, nUTF32, eEscapeType, bOctets, - PART_AUTHORITY, cEscapePrefix, eCharset, + appendUCS4(aSynUser, nUTF32, eEscapeType, bOctets, + PART_USER_PASSWORD, cEscapePrefix, eCharset, false); + + bHasUser = *pPos == '@'; + } + + rtl::OUStringBuffer aSynAuthority; + if ( !bHasUser ) + { + aSynAuthority = aSynUser; + } + else + { + m_aUser.set(aSynAbsURIRef, + aSynUser.makeStringAndClear(), + aSynAbsURIRef.getLength()); + aSynAbsURIRef.appendAscii(RTL_CONSTASCII_STRINGPARAM("@")); + ++pPos; + + while (pPos < pEnd + && *pPos != '/' && *pPos != '?' + && *pPos != nFragmentDelimiter) + { + EscapeType eEscapeType; + sal_uInt32 nUTF32 = getUTF32(pPos, pEnd, bOctets, + cEscapePrefix, eMechanism, + eCharset, eEscapeType); + appendUCS4(aSynAuthority, nUTF32, eEscapeType, bOctets, + PART_AUTHORITY, cEscapePrefix, eCharset, + false); + } } if (aSynAuthority.getLength() == 0) { @@ -2133,7 +2165,6 @@ INetURLObject::getPrefix(sal_Unicode const *& rBegin, { ".uno:", "staroffice.uno:", INET_PROT_UNO, PrefixInfo::INTERNAL }, { "cid:", 0, INET_PROT_CID, PrefixInfo::OFFICIAL }, - { "cmis+atom:", 0, INET_PROT_CMIS_ATOM, PrefixInfo::INTERNAL }, { "data:", 0, INET_PROT_DATA, PrefixInfo::OFFICIAL }, { "db:", "staroffice.db:", INET_PROT_DB, PrefixInfo::INTERNAL }, { "file:", 0, INET_PROT_FILE, PrefixInfo::OFFICIAL }, @@ -2203,6 +2234,7 @@ INetURLObject::getPrefix(sal_Unicode const *& rBegin, { "telnet:", 0, INET_PROT_TELNET, PrefixInfo::OFFICIAL }, { "vim:", "staroffice.vim:", INET_PROT_VIM, PrefixInfo::INTERNAL }, + { "vnd.libreoffice.cmis+atom:", 0, INET_PROT_CMIS_ATOM, PrefixInfo::INTERNAL }, { "vnd.sun.star.cmd:", 0, INET_PROT_VND_SUN_STAR_CMD, PrefixInfo::OFFICIAL }, { "vnd.sun.star.expand:", 0, INET_PROT_VND_SUN_STAR_EXPAND, diff --git a/ucb/source/ucp/cmis/cmis_content.cxx b/ucb/source/ucp/cmis/cmis_content.cxx index d40deabb19f7..b25e1acf5ecc 100644 --- a/ucb/source/ucp/cmis/cmis_content.cxx +++ b/ucb/source/ucp/cmis/cmis_content.cxx @@ -171,7 +171,7 @@ namespace cmis pProvider->registerSession( url.getBindingUrl( ), m_pSession ); } - m_sObjectId = url.getObjectId( ); + m_sObjectPath = url.getObjectPath( ); m_sBindingUrl = url.getBindingUrl( ); } @@ -197,7 +197,7 @@ namespace cmis pProvider->registerSession( url.getBindingUrl( ), m_pSession ); } - m_sObjectId = url.getObjectId( ); + m_sObjectPath = url.getObjectPath( ); m_sBindingUrl = url.getBindingUrl( ); // Get the object type @@ -215,12 +215,12 @@ namespace cmis { if ( !m_pObject.get() ) { - if ( !m_sObjectId.isEmpty( ) ) - m_pObject = m_pSession->getObject( OUSTR_TO_STDSTR( m_sObjectId ) ); + if ( !m_sObjectPath.isEmpty( ) ) + m_pObject = m_pSession->getObjectByPath( OUSTR_TO_STDSTR( m_sObjectPath ) ); else { m_pObject = m_pSession->getRootFolder( ); - m_sObjectId = rtl::OUString::createFromAscii( m_pObject->getId( ).c_str( ) ); + m_sObjectPath = "/"; } } } @@ -283,29 +283,48 @@ namespace cmis } else if ( rProp.Name == "Title" ) { - string name = getObject()->getName(); - xRow->appendString( rProp, rtl::OUString::createFromAscii( name.c_str() ) ); + rtl::OUString sTitle; + if ( getObject() ) + sTitle = rtl::OUString::createFromAscii( getObject()->getName().c_str( ) ); + else if ( m_pObjectProps.size() > 0 ) + { + map< string, libcmis::PropertyPtr >::iterator it = m_pObjectProps.find( "cmis:name" ); + if ( it != m_pObjectProps.end( ) ) + { + vector< string > values = it->second->getStrings( ); + if ( values.size() > 0 ) + sTitle = rtl::OUString::createFromAscii( values.front( ).c_str( ) ); + } + } + + // Nothing worked... get it from the path + if ( sTitle.isEmpty( ) ) + { + rtl::OUString sPath = m_sObjectPath; + + // Get rid of the trailing slash problem + if ( sPath[ sPath.getLength( ) - 1 ] == '/' ) + sPath = sPath.copy( 0, sPath.getLength() - 1 ); + + // Get the last segment + sal_Int32 nPos = sPath.lastIndexOf( '/' ); + if ( nPos > 0 ) + sTitle = sPath.copy( nPos + 1 ); + } + + if ( !sTitle.isEmpty( ) ) + xRow->appendString( rProp, sTitle ); + else + xRow->appendVoid( rProp ); } else if ( rProp.Name == "TitleOnServer" ) { string path; - libcmis::Document* document = dynamic_cast< libcmis::Document* >( getObject().get( ) ); - if ( NULL != document ) - { - vector< boost::shared_ptr< libcmis::Folder > > parents = document->getParents( ); - if ( parents.size() > 0 ) - path = parents.front( )->getPath( ); - - if ( path[ path.length() - 1 ] != '/' ) - path += "/"; - path += getObject()->getName( ); - } + vector< string > paths = getObject( )->getPaths( ); + if ( paths.size( ) > 0 ) + path = paths.front( ); else - { - libcmis::Folder* folder = dynamic_cast< libcmis::Folder* >( getObject().get( ) ); - if ( NULL != folder ) - path = folder->getPath( ); - } + path = getObject()->getName( ); xRow->appendString( rProp, rtl::OUString::createFromAscii( path.c_str() ) ); } @@ -352,8 +371,8 @@ namespace cmis bool bExists = true; try { - if ( !m_sObjectId.isEmpty( ) ) - libcmis::ObjectPtr object = m_pSession->getObject( OUSTR_TO_STDSTR( m_sObjectId ) ); + if ( !m_sObjectPath.isEmpty( ) ) + m_pSession->getObjectByPath( OUSTR_TO_STDSTR( m_sObjectPath ) ); // No need to handle the root folder case... how can it not exists? } catch ( const libcmis::Exception& ) @@ -479,7 +498,7 @@ namespace cmis // For transient content, the URL is the one of the parent if ( m_bTransient ) { - string sNewId; + rtl::OUString sNewPath; // Try to get the object from the server if there is any libcmis::Folder* pFolder = dynamic_cast< libcmis::Folder* >( getObject( ).get( ) ); @@ -503,7 +522,7 @@ namespace cmis try { object = m_pSession->getObjectByPath( newPath ); - sNewId = object->getId( ); + sNewPath = rtl::OUString::createFromAscii( newPath.c_str( ) ); } catch ( const libcmis::Exception& ) { @@ -540,7 +559,7 @@ namespace cmis if ( bIsFolder ) { libcmis::FolderPtr pNew = pFolder->createFolder( m_pObjectProps ); - sNewId = pNew->getId( ); + sNewPath = rtl::OUString::createFromAscii( newPath.c_str( ) ); } else { @@ -548,16 +567,16 @@ namespace cmis uno::Reference < io::XOutputStream > xOutput = new ucbhelper::StdOutputStream( pOut ); copyData( xInputStream, xOutput ); libcmis::DocumentPtr pNew = pFolder->createDocument( m_pObjectProps, pOut, string() ); - sNewId = pNew->getId( ); + sNewPath = rtl::OUString::createFromAscii( newPath.c_str( ) ); } } - if ( !sNewId.empty( ) ) + if ( !sNewPath.isEmpty( ) ) { // Update the current content: it's no longer transient - m_sObjectId = rtl::OUString::createFromAscii( sNewId.c_str( ) ); + m_sObjectPath = sNewPath; URL aUrl( m_sURL ); - aUrl.setObjectId( m_sObjectId ); + aUrl.setObjectPath( m_sObjectPath ); m_sURL = aUrl.asString( ); m_pObject.reset( ); m_pObjectType.reset( ); @@ -790,8 +809,7 @@ namespace cmis SAL_INFO( "cmisucp", "Content::getParentURL()" ); - string parentId; - + string parentPath; try { libcmis::ObjectPtr pObj = getObject( ); @@ -800,25 +818,25 @@ namespace cmis { vector< boost::shared_ptr< libcmis::Folder > > parents = document->getParents( ); if ( parents.size( ) > 0 ) - parentId = parents.front( )->getId( ); + parentPath = parents.front( )->getPath( ); } else { libcmis::Folder* folder = dynamic_cast< libcmis::Folder* >( getObject( ).get( ) ); if ( NULL != folder ) - parentId = folder->getFolderParent( )->getId( ); + parentPath = folder->getFolderParent( )->getPath( ); } } catch ( const libcmis::Exception & ) { // We may have an exception if we don't have the rights to - // get the parent ID + // get the parents } - if ( !parentId.empty() ) + if ( !parentPath.empty() ) { URL aUrl( m_sURL ); - aUrl.setObjectId( rtl::OUString::createFromAscii( parentId.c_str( ) ) ); + aUrl.setObjectPath( rtl::OUString::createFromAscii( parentPath.c_str( ) ) ); sRet = aUrl.asString( ); } diff --git a/ucb/source/ucp/cmis/cmis_content.hxx b/ucb/source/ucp/cmis/cmis_content.hxx index eafd5039503a..21ec1d19a954 100644 --- a/ucb/source/ucp/cmis/cmis_content.hxx +++ b/ucb/source/ucp/cmis/cmis_content.hxx @@ -71,7 +71,7 @@ private: ContentProvider* m_pProvider; libcmis::Session* m_pSession; libcmis::ObjectPtr m_pObject; - rtl::OUString m_sObjectId; + rtl::OUString m_sObjectPath; rtl::OUString m_sURL; rtl::OUString m_sBindingUrl; diff --git a/ucb/source/ucp/cmis/cmis_datasupplier.cxx b/ucb/source/ucp/cmis/cmis_datasupplier.cxx index 2a82a9bdfc4c..59ffd73ff609 100644 --- a/ucb/source/ucp/cmis/cmis_datasupplier.cxx +++ b/ucb/source/ucp/cmis/cmis_datasupplier.cxx @@ -90,11 +90,15 @@ namespace cmis if ( getResult( nIndex ) ) { - string sObjectId = maResults[nIndex]->pObject->getId( ); + string sObjectPath; + vector< string > paths = maResults[nIndex]->pObject->getPaths( ); + if ( paths.size( ) > 0 ) + sObjectPath = paths.front( ); + // TODO Handle the unfiled objects with their id... but can they manage to come here? - // Get the URL from the Id + // Get the URL from the Path URL aUrl( mxContent->getIdentifier( )->getContentIdentifier( ) ); - aUrl.setObjectId( rtl::OUString::createFromAscii( sObjectId.c_str( ) ) ); + aUrl.setObjectPath( rtl::OUString::createFromAscii( sObjectPath.c_str( ) ) ); rtl::OUString aId = aUrl.asString( ); maResults[ nIndex ]->aId = aId; diff --git a/ucb/source/ucp/cmis/cmis_url.cxx b/ucb/source/ucp/cmis/cmis_url.cxx index df225018d3a9..aed136b3d86a 100644 --- a/ucb/source/ucp/cmis/cmis_url.cxx +++ b/ucb/source/ucp/cmis/cmis_url.cxx @@ -28,6 +28,8 @@ #include +#include + #include "cmis_url.hxx" using namespace std; @@ -37,42 +39,24 @@ using namespace std; namespace cmis { - URL::URL( rtl::OUString const & urlStr ) : - m_aUrl( urlStr ) + URL::URL( rtl::OUString const & urlStr ) { + rtl::OUString sBindingUrl; + rtl::OUString sRepositoryId; + + INetURLObject aUrl( urlStr ); + + // Decode the authority to get the binding URL and repository id + rtl::OUString sDecodedHost = aUrl.GetHost( INetURLObject::DECODE_WITH_CHARSET ); + INetURLObject aHostUrl( sDecodedHost ); + m_sBindingUrl = aHostUrl.GetURLNoMark( ); + m_sRepositoryId = aHostUrl.GetMark( ); - rtl::OUString bindingUrl( "http://" ); - bindingUrl += m_aUrl.GetHostPort( ); - bindingUrl += m_aUrl.GetURLPath( ); - m_sBindingUrl = bindingUrl; - - // Split the query into bits and locate the repo-id key - rtl::OUString query = m_aUrl.GetParam( ); - while ( !query.isEmpty() ) - { - sal_Int32 nPos = query.indexOfAsciiL( "&", 1 ); - rtl::OUString segment; - if ( nPos > 0 ) - { - segment = query.copy( 0, nPos ); - query = query.copy( nPos + 1 ); - } - else - { - segment = query; - query = rtl::OUString(); - } - - sal_Int32 nEqPos = segment.indexOfAsciiL( "=", 1 ); - rtl::OUString key = segment.copy( 0, nEqPos ); - rtl::OUString value = segment.copy( nEqPos +1 ); - - if ( key == "repo-id" ) - m_sRepositoryId = value; - else - m_aQuery[key] = value; - } + m_sUser = aUrl.GetUser( ); + m_sPass = aUrl.GetPass( ); + // Store the path to the object + m_sPath = aUrl.GetURLPath( INetURLObject::DECODE_WITH_CHARSET ); } map< int, string > URL::getSessionParams( ) @@ -80,19 +64,15 @@ namespace cmis map< int, string > params; params[ATOMPUB_URL] = OUSTR_TO_STDSTR( m_sBindingUrl ); params[REPOSITORY_ID] = OUSTR_TO_STDSTR( m_sRepositoryId ); - params[USERNAME] = OUSTR_TO_STDSTR( m_aUrl.GetUser() ); - params[PASSWORD] = OUSTR_TO_STDSTR( m_aUrl.GetPass() ); + params[USERNAME] = OUSTR_TO_STDSTR( m_sUser ); + params[PASSWORD] = OUSTR_TO_STDSTR( m_sPass ); return params; } - rtl::OUString URL::getObjectId( ) + rtl::OUString URL::getObjectPath( ) { - rtl::OUString sResult; - map< rtl::OUString, rtl::OUString >::iterator it = m_aQuery.find( "id" ); - if ( it != m_aQuery.end( ) ) - sResult = it->second; - return sResult; + return m_sPath; } rtl::OUString URL::getBindingUrl( ) @@ -100,21 +80,26 @@ namespace cmis return m_sBindingUrl; } - void URL::setObjectId( rtl::OUString sId ) + void URL::setObjectPath( rtl::OUString sPath ) { - m_aQuery["id"] = sId; - updateUrlQuery( ); + m_sPath = sPath; } rtl::OUString URL::asString( ) { - return m_aUrl.GetMainURL( INetURLObject::NO_DECODE ); - } - - void URL::updateUrlQuery( ) - { - rtl::OUString sParam = "repo-id=" + m_sRepositoryId + "&id=" + m_aQuery["id"]; - m_aUrl.SetParam( sParam ); + rtl::OUString sUrl; + rtl::OUString sEncodedBinding = rtl::Uri::encode( + m_sBindingUrl + "#" + m_sRepositoryId, + rtl_UriCharClassUricNoSlash, + rtl_UriEncodeKeepEscapes, + RTL_TEXTENCODING_UTF8 ); + sUrl = "vnd.libreoffice.cmis+atom://" + sEncodedBinding; + + if ( m_sPath[0] != '/' ) + sUrl += "/"; + sUrl += m_sPath; + + return sUrl; } } diff --git a/ucb/source/ucp/cmis/cmis_url.hxx b/ucb/source/ucp/cmis/cmis_url.hxx index 18d13f166f37..833804b7e9f4 100644 --- a/ucb/source/ucp/cmis/cmis_url.hxx +++ b/ucb/source/ucp/cmis/cmis_url.hxx @@ -39,25 +39,21 @@ namespace cmis class URL { private: - INetURLObject m_aUrl; rtl::OUString m_sBindingUrl; rtl::OUString m_sRepositoryId; - - std::map< rtl::OUString, rtl::OUString > m_aQuery; + rtl::OUString m_sPath; + rtl::OUString m_sUser; + rtl::OUString m_sPass; public: URL( rtl::OUString const & urlStr ); std::map< int, std::string > getSessionParams( ); - rtl::OUString getObjectId( ); + rtl::OUString getObjectPath( ); rtl::OUString getBindingUrl( ); - void setObjectId( rtl::OUString sId ); + void setObjectPath( rtl::OUString sPath ); rtl::OUString asString( ); - - private: - - void updateUrlQuery( ); }; } -- cgit