1 diff --git src/libcmis/atom-folder.cxx src/libcmis/atom-folder.cxx
2 index 68fb124..2756a5d 100644
3 --- src/libcmis/atom-folder.cxx
4 +++ src/libcmis/atom-folder.cxx
5 @@ -57,8 +57,11 @@ vector< libcmis::ObjectPtr > AtomFolder::getChildren( ) throw ( libcmis::Excepti
7 AtomLink* childrenLink = getLink( "down", "application/atom+xml;type=feed" );
9 + // Some servers aren't giving the GetChildren properly... if not defined, we need to try
10 + // as we may have the right to proceed.
11 if ( ( NULL == childrenLink ) || ( getAllowableActions( ).get() &&
12 - !getAllowableActions()->isAllowed( libcmis::ObjectAction::GetChildren ) ) )
13 + ( !getAllowableActions()->isAllowed( libcmis::ObjectAction::GetChildren ) &&
14 + getAllowableActions()->isDefined( libcmis::ObjectAction::GetChildren ) ) ) )
15 throw libcmis::Exception( string( "GetChildren not allowed on node " ) + getId() );
17 vector< libcmis::ObjectPtr > children;
18 @@ -182,7 +185,8 @@ libcmis::DocumentPtr AtomFolder::createDocument( const map< string, libcmis::Pro
19 AtomLink* childrenLink = getLink( "down", "application/atom+xml;type=feed" );
21 if ( ( NULL == childrenLink ) || ( getAllowableActions( ).get() &&
22 - !getAllowableActions()->isAllowed( libcmis::ObjectAction::CreateDocument ) ) )
23 + !getAllowableActions()->isAllowed( libcmis::ObjectAction::CreateDocument ) &&
24 + getAllowableActions()->isDefined( libcmis::ObjectAction::CreateDocument ) ) )
25 throw libcmis::Exception( string( "CreateDocument not allowed on folder " ) + getId() );
27 xmlBufferPtr buf = xmlBufferCreate( );
28 @@ -210,9 +214,37 @@ libcmis::DocumentPtr AtomFolder::createDocument( const map< string, libcmis::Pro
31 string respBuf = response->getStream( )->str( );
32 - xmlDocPtr doc = xmlReadMemory( respBuf.c_str(), respBuf.size(), getInfosUrl().c_str(), NULL, 0 );
33 + xmlDocPtr doc = xmlReadMemory( respBuf.c_str(), respBuf.size(), getInfosUrl().c_str(), NULL, XML_PARSE_NOERROR );
35 - throw libcmis::Exception( "Failed to parse object infos" );
37 + // We may not have the created document entry in the response body: this is
38 + // the behaviour of some servers, but the standard says we need to look for
39 + // the Location header.
40 + map< string, string >& headers = response->getHeaders( );
41 + map< string, string >::iterator it = headers.find( "Location" );
43 + // Some servers like Lotus Live aren't sending Location header, but Content-Location
44 + if ( it == headers.end( ) )
45 + it = headers.find( "Content-Location" );
47 + if ( it != headers.end() )
51 + response = getSession( )->httpGetRequest( it->second );
52 + respBuf = response->getStream( )->str( );
53 + doc = xmlReadMemory( respBuf.c_str(), respBuf.size(), getInfosUrl().c_str(), NULL, XML_PARSE_NOERROR );
55 + catch ( const CurlException& e )
57 + throw e.getCmisException( );
61 + // if doc is still NULL after that, then throw an exception
63 + throw libcmis::Exception( "Missing expected response from server" );
66 libcmis::ObjectPtr created = getSession( )->createObjectFromEntryDoc( doc );
68 diff --git src/libcmis/atom-object.cxx src/libcmis/atom-object.cxx
69 index b7b3b4a..812951d 100644
70 --- src/libcmis/atom-object.cxx
71 +++ src/libcmis/atom-object.cxx
72 @@ -140,6 +140,34 @@ libcmis::ObjectPtr AtomObject::updateProperties( const map< string, libcmis::Pro
76 +libcmis::AllowableActionsPtr AtomObject::getAllowableActions( )
78 + if ( !m_allowableActions )
80 + // For some reason we had no allowable actions before, get them now.
81 + AtomLink* link = getLink( "http://docs.oasis-open.org/ns/cmis/link/200908/allowableactions", "application/cmisallowableactions+xml" );
86 + libcmis::HttpResponsePtr response = getSession()->httpGetRequest( link->getHref() );
87 + string buf = response->getStream()->str();
88 + xmlDocPtr doc = xmlReadMemory( buf.c_str(), buf.size(), link->getHref().c_str(), NULL, 0 );
89 + xmlNodePtr actionsNode = xmlDocGetRootElement( doc );
91 + m_allowableActions.reset( new libcmis::AllowableActions( actionsNode ) );
95 + catch ( libcmis::Exception& )
101 + return libcmis::Object::getAllowableActions();
104 void AtomObject::refreshImpl( xmlDocPtr doc ) throw ( libcmis::Exception )
106 bool createdDoc = ( NULL == doc );
107 diff --git src/libcmis/atom-object.hxx src/libcmis/atom-object.hxx
108 index 2d1761d..452b4f5 100644
109 --- src/libcmis/atom-object.hxx
110 +++ src/libcmis/atom-object.hxx
111 @@ -69,6 +69,8 @@ class AtomObject : public virtual libcmis::Object
112 virtual libcmis::ObjectPtr updateProperties(
113 const std::map< std::string, libcmis::PropertyPtr >& properties ) throw ( libcmis::Exception );
115 + virtual libcmis::AllowableActionsPtr getAllowableActions( );
117 /** Reload the data from the server.
119 virtual void refresh( ) throw ( libcmis::Exception ) { refreshImpl( NULL ); }