diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2014-04-04 10:30:38 +0200 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2014-04-04 10:35:41 +0200 |
commit | e250a013bae4b58a9304518aefc6da0dab574103 (patch) | |
tree | 033ffe38c1f8e00fa7c743822560a92cb0776650 /ucb | |
parent | d13f1ed261463ac2d27a5e071fb83c7f5fb7231c (diff) |
webdav: Allow to save documents again, after locking is implemented.
We need to extend PUT method with lock token in 'If' header, so that it
does not fail on a resource locked by us.
Change-Id: I82a9e3303a34607dba8bb874d1eb0fac23b9f11d
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/source/ucp/webdav/SerfPutReqProcImpl.cxx | 9 | ||||
-rw-r--r-- | ucb/source/ucp/webdav/SerfPutReqProcImpl.hxx | 5 | ||||
-rw-r--r-- | ucb/source/ucp/webdav/SerfRequestProcessor.cxx | 8 |
3 files changed, 18 insertions, 4 deletions
diff --git a/ucb/source/ucp/webdav/SerfPutReqProcImpl.cxx b/ucb/source/ucp/webdav/SerfPutReqProcImpl.cxx index a64ecffa5761..20a99848c6ae 100644 --- a/ucb/source/ucp/webdav/SerfPutReqProcImpl.cxx +++ b/ucb/source/ucp/webdav/SerfPutReqProcImpl.cxx @@ -29,10 +29,12 @@ namespace http_dav_ucp SerfPutReqProcImpl::SerfPutReqProcImpl( const char* inPath, const DAVRequestHeaders& inRequestHeaders, const char* inData, - apr_size_t inDataLen ) + apr_size_t inDataLen, + const OUString& sToken ) : SerfRequestProcessorImpl( inPath, inRequestHeaders ) , mpData( inData ) , mnDataLen( inDataLen ) + , msToken( sToken ) { } @@ -64,6 +66,11 @@ serf_bucket_t * SerfPutReqProcImpl::createSerfRequestBucket( serf_request_t * in // general header fields provided by caller setRequestHeaders( hdrs_bkt ); + // 'If' header with token, so that we can save document locked by us + const OString sIfHeader( "<" + OString(getPathStr()) + "> (<" + OUStringToOString( + msToken, RTL_TEXTENCODING_UTF8) + ">)" ); + serf_bucket_headers_set( hdrs_bkt, "If", sIfHeader.getStr() ); + return req_bkt; } diff --git a/ucb/source/ucp/webdav/SerfPutReqProcImpl.hxx b/ucb/source/ucp/webdav/SerfPutReqProcImpl.hxx index a0bcccdf22bb..4bb8adb85ee6 100644 --- a/ucb/source/ucp/webdav/SerfPutReqProcImpl.hxx +++ b/ucb/source/ucp/webdav/SerfPutReqProcImpl.hxx @@ -31,7 +31,8 @@ public: SerfPutReqProcImpl( const char* inPath, const DAVRequestHeaders& inRequestHeaders, const char* inData, - apr_size_t inDataLen ); + apr_size_t inDataLen, + const OUString& sToken ); virtual ~SerfPutReqProcImpl(); @@ -49,7 +50,7 @@ protected: private: const char* mpData; apr_size_t mnDataLen; - + OUString msToken; }; } // namespace http_dav_ucp diff --git a/ucb/source/ucp/webdav/SerfRequestProcessor.cxx b/ucb/source/ucp/webdav/SerfRequestProcessor.cxx index ddeecca45765..c0bda26f683c 100644 --- a/ucb/source/ucp/webdav/SerfRequestProcessor.cxx +++ b/ucb/source/ucp/webdav/SerfRequestProcessor.cxx @@ -203,10 +203,16 @@ bool SerfRequestProcessor::processPut( const char* inData, apr_size_t inDataLen, apr_status_t& outSerfStatus ) { + // get the lock from lock store + const OUString sToken( + apr_environment::AprEnv::getAprEnv()->getSerfLockStore()->getLockToken( + OUString::createFromAscii(mPathStr)) ); + mpProcImpl = new SerfPutReqProcImpl( mPathStr, mrSerfSession.getRequestEnvironment().m_aRequestHeaders, inData, - inDataLen ); + inDataLen, + sToken ); outSerfStatus = runProcessor(); return outSerfStatus == APR_SUCCESS; |