diff options
author | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2013-02-14 10:27:21 +0100 |
---|---|---|
committer | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2013-02-14 13:12:26 +0100 |
commit | d242d9e1efc7ecd4f9980190bbc53af9630baac7 (patch) | |
tree | f2966c3af16b197ed93ad2d7dbb3f919facc7d31 /libcmis | |
parent | 519e576a3954d91b79a7fbb3fec0c2f1c7ed4c4a (diff) |
CMIS: made it work with Lotus Live
Making libcmis and LibreOffice work with Lotus Live service needed a few
hacks to either better implement CMIS or workaround some bad
implementations.
As a general improvement, the CheckOut InfoBar isn't shown if the
document can't be checked out.
Diffstat (limited to 'libcmis')
-rw-r--r-- | libcmis/UnpackedTarball_cmis.mk | 1 | ||||
-rw-r--r-- | libcmis/libcmis-0.3.0-lotus-live-fix.patch | 122 |
2 files changed, 123 insertions, 0 deletions
diff --git a/libcmis/UnpackedTarball_cmis.mk b/libcmis/UnpackedTarball_cmis.mk index a25c3164fd7e..0a9f9f8ad2f2 100644 --- a/libcmis/UnpackedTarball_cmis.mk +++ b/libcmis/UnpackedTarball_cmis.mk @@ -18,6 +18,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,cmis, \ libcmis/libcmis-0.3.0-win.patch \ libcmis/libcmis-0.3.0.patch \ libcmis/libcmis-0.3.0-proxy.patch \ + libcmis/libcmis-0.3.0-lotus-live-fix.patch \ )) ifeq ($(OS)$(COM),WNTMSC) diff --git a/libcmis/libcmis-0.3.0-lotus-live-fix.patch b/libcmis/libcmis-0.3.0-lotus-live-fix.patch new file mode 100644 index 000000000000..2aca934df806 --- /dev/null +++ b/libcmis/libcmis-0.3.0-lotus-live-fix.patch @@ -0,0 +1,122 @@ +diff --git src/libcmis/atom-folder.cxx src/libcmis/atom-folder.cxx +index 68fb124..2756a5d 100644 +--- src/libcmis/atom-folder.cxx ++++ src/libcmis/atom-folder.cxx +@@ -57,8 +57,11 @@ vector< libcmis::ObjectPtr > AtomFolder::getChildren( ) throw ( libcmis::Excepti + { + AtomLink* childrenLink = getLink( "down", "application/atom+xml;type=feed" ); + ++ // Some servers aren't giving the GetChildren properly... if not defined, we need to try ++ // as we may have the right to proceed. + if ( ( NULL == childrenLink ) || ( getAllowableActions( ).get() && +- !getAllowableActions()->isAllowed( libcmis::ObjectAction::GetChildren ) ) ) ++ ( !getAllowableActions()->isAllowed( libcmis::ObjectAction::GetChildren ) && ++ getAllowableActions()->isDefined( libcmis::ObjectAction::GetChildren ) ) ) ) + throw libcmis::Exception( string( "GetChildren not allowed on node " ) + getId() ); + + vector< libcmis::ObjectPtr > children; +@@ -182,7 +185,8 @@ libcmis::DocumentPtr AtomFolder::createDocument( const map< string, libcmis::Pro + AtomLink* childrenLink = getLink( "down", "application/atom+xml;type=feed" ); + + if ( ( NULL == childrenLink ) || ( getAllowableActions( ).get() && +- !getAllowableActions()->isAllowed( libcmis::ObjectAction::CreateDocument ) ) ) ++ !getAllowableActions()->isAllowed( libcmis::ObjectAction::CreateDocument ) && ++ getAllowableActions()->isDefined( libcmis::ObjectAction::CreateDocument ) ) ) + throw libcmis::Exception( string( "CreateDocument not allowed on folder " ) + getId() ); + + xmlBufferPtr buf = xmlBufferCreate( ); +@@ -210,9 +214,37 @@ libcmis::DocumentPtr AtomFolder::createDocument( const map< string, libcmis::Pro + } + + string respBuf = response->getStream( )->str( ); +- xmlDocPtr doc = xmlReadMemory( respBuf.c_str(), respBuf.size(), getInfosUrl().c_str(), NULL, 0 ); ++ xmlDocPtr doc = xmlReadMemory( respBuf.c_str(), respBuf.size(), getInfosUrl().c_str(), NULL, XML_PARSE_NOERROR ); + if ( NULL == doc ) +- throw libcmis::Exception( "Failed to parse object infos" ); ++ { ++ // We may not have the created document entry in the response body: this is ++ // the behaviour of some servers, but the standard says we need to look for ++ // the Location header. ++ map< string, string >& headers = response->getHeaders( ); ++ map< string, string >::iterator it = headers.find( "Location" ); ++ ++ // Some servers like Lotus Live aren't sending Location header, but Content-Location ++ if ( it == headers.end( ) ) ++ it = headers.find( "Content-Location" ); ++ ++ if ( it != headers.end() ) ++ { ++ try ++ { ++ response = getSession( )->httpGetRequest( it->second ); ++ respBuf = response->getStream( )->str( ); ++ doc = xmlReadMemory( respBuf.c_str(), respBuf.size(), getInfosUrl().c_str(), NULL, XML_PARSE_NOERROR ); ++ } ++ catch ( const CurlException& e ) ++ { ++ throw e.getCmisException( ); ++ } ++ } ++ ++ // if doc is still NULL after that, then throw an exception ++ if ( NULL == doc ) ++ throw libcmis::Exception( "Missing expected response from server" ); ++ } + + libcmis::ObjectPtr created = getSession( )->createObjectFromEntryDoc( doc ); + xmlFreeDoc( doc ); +diff --git src/libcmis/atom-object.cxx src/libcmis/atom-object.cxx +index b7b3b4a..812951d 100644 +--- src/libcmis/atom-object.cxx ++++ src/libcmis/atom-object.cxx +@@ -140,6 +140,34 @@ libcmis::ObjectPtr AtomObject::updateProperties( const map< string, libcmis::Pro + return updated; + } + ++libcmis::AllowableActionsPtr AtomObject::getAllowableActions( ) ++{ ++ if ( !m_allowableActions ) ++ { ++ // For some reason we had no allowable actions before, get them now. ++ AtomLink* link = getLink( "http://docs.oasis-open.org/ns/cmis/link/200908/allowableactions", "application/cmisallowableactions+xml" ); ++ if ( link ) ++ { ++ try ++ { ++ libcmis::HttpResponsePtr response = getSession()->httpGetRequest( link->getHref() ); ++ string buf = response->getStream()->str(); ++ xmlDocPtr doc = xmlReadMemory( buf.c_str(), buf.size(), link->getHref().c_str(), NULL, 0 ); ++ xmlNodePtr actionsNode = xmlDocGetRootElement( doc ); ++ if ( actionsNode ) ++ m_allowableActions.reset( new libcmis::AllowableActions( actionsNode ) ); ++ ++ xmlFreeDoc( doc ); ++ } ++ catch ( libcmis::Exception& ) ++ { ++ } ++ } ++ } ++ ++ return libcmis::Object::getAllowableActions(); ++} ++ + void AtomObject::refreshImpl( xmlDocPtr doc ) throw ( libcmis::Exception ) + { + bool createdDoc = ( NULL == doc ); +diff --git src/libcmis/atom-object.hxx src/libcmis/atom-object.hxx +index 2d1761d..452b4f5 100644 +--- src/libcmis/atom-object.hxx ++++ src/libcmis/atom-object.hxx +@@ -69,6 +69,8 @@ class AtomObject : public virtual libcmis::Object + virtual libcmis::ObjectPtr updateProperties( + const std::map< std::string, libcmis::PropertyPtr >& properties ) throw ( libcmis::Exception ); + ++ virtual libcmis::AllowableActionsPtr getAllowableActions( ); ++ + /** Reload the data from the server. + */ + virtual void refresh( ) throw ( libcmis::Exception ) { refreshImpl( NULL ); } +-- +1.7.10.4 + |