diff options
-rw-r--r-- | ucb/source/ucp/webdav-curl/DAVTypes.cxx | 3 | ||||
-rw-r--r-- | ucb/source/ucp/webdav-curl/DAVTypes.hxx | 7 | ||||
-rw-r--r-- | ucb/source/ucp/webdav-curl/webdavcontent.cxx | 26 |
3 files changed, 35 insertions, 1 deletions
diff --git a/ucb/source/ucp/webdav-curl/DAVTypes.cxx b/ucb/source/ucp/webdav-curl/DAVTypes.cxx index bddbe50829b0..839b9e845846 100644 --- a/ucb/source/ucp/webdav-curl/DAVTypes.cxx +++ b/ucb/source/ucp/webdav-curl/DAVTypes.cxx @@ -26,6 +26,7 @@ DAVOptions::DAVOptions() : m_isClass1( false ), m_isClass2( false ), m_isClass3( false ), + m_isLocked( false ), m_aAllowedMethods(), m_nStaleTime( 0 ), m_sURL(), @@ -39,6 +40,7 @@ DAVOptions::DAVOptions( const DAVOptions & rOther ) : m_isClass1( rOther.m_isClass1 ), m_isClass2( rOther.m_isClass2 ), m_isClass3( rOther.m_isClass3 ), + m_isLocked( rOther.m_isLocked ), m_aAllowedMethods( rOther.m_aAllowedMethods ), m_nStaleTime( rOther.m_nStaleTime ), m_sURL( rOther.m_sURL ), @@ -59,6 +61,7 @@ bool DAVOptions::operator==( const DAVOptions& rOpts ) const m_isClass1 == rOpts.m_isClass1 && m_isClass2 == rOpts.m_isClass2 && m_isClass3 == rOpts.m_isClass3 && + m_isLocked == rOpts.m_isLocked && m_aAllowedMethods == rOpts.m_aAllowedMethods && m_nStaleTime == rOpts.m_nStaleTime && m_sURL == rOpts.m_sURL && diff --git a/ucb/source/ucp/webdav-curl/DAVTypes.hxx b/ucb/source/ucp/webdav-curl/DAVTypes.hxx index a4180c6dffc7..d5453295c733 100644 --- a/ucb/source/ucp/webdav-curl/DAVTypes.hxx +++ b/ucb/source/ucp/webdav-curl/DAVTypes.hxx @@ -71,6 +71,9 @@ namespace http_dav_ucp bool m_isClass1; bool m_isClass2; bool m_isClass3; + // Internally used to maintain locked stated of the resource, only + // if it's a Class 2 resource + bool m_isLocked; // contains the methods allowed on this resource OUString m_aAllowedMethods; @@ -112,11 +115,15 @@ namespace http_dav_ucp bool isLockAllowed() { return ( m_aAllowedMethods.indexOf( "LOCK" ) != -1 ); }; bool isUnlockAllowed() { return ( m_aAllowedMethods.indexOf( "UNLOCK" ) != -1 ); }; + void setLocked( bool locked = true ) { m_isLocked = locked; } ; + bool isLocked() { return m_isLocked; }; + void reset() { m_isResourceFound = false; m_isClass1 = false; m_isClass2 = false; m_isClass3 = false; + m_isLocked = false; m_aAllowedMethods.clear(); m_nStaleTime = 0; m_sURL.clear(); diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx b/ucb/source/ucp/webdav-curl/webdavcontent.cxx index ba220778c973..fdec5e34b4bc 100644 --- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx +++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx @@ -3041,6 +3041,8 @@ void Content::lock( aURL = m_xIdentifier->getContentIdentifier(); } + OUString aTargetUrl = aURL; + try { std::unique_ptr< DAVResourceAccess > xResAccess; @@ -3062,7 +3064,12 @@ void Content::lock( //-1, // infinite lock uno::Sequence< OUString >() ); + // update the URL + aTargetUrl = xResAccess->getURL(); + xResAccess->LOCK( aLock, Environment ); + // OPTIONS may have changed as a consequence of the lock operation + aStaticDAVOptionsCache.removeDAVOptions( aTargetUrl ); { osl::Guard< osl::Mutex > aGuard( m_aMutex ); @@ -3071,6 +3078,7 @@ void Content::lock( } catch ( DAVException const & e ) { + aStaticDAVOptionsCache.removeDAVOptions( aTargetUrl ); // check if the exception thrown is 'already locked' // this exception is mapped directly to the ucb correct one, without // going into the cancelCommandExecution() user interaction @@ -3166,6 +3174,9 @@ void Content::lock( void Content::unlock( const uno::Reference< ucb::XCommandEnvironment >& Environment ) { + // save the URL to clean cache + OUString aTargetUrl = m_xIdentifier->getContentIdentifier(); + try { std::unique_ptr< DAVResourceAccess > xResAccess; @@ -3174,7 +3185,12 @@ void Content::unlock( xResAccess.reset( new DAVResourceAccess( *m_xResAccess ) ); } + // update the URL + aTargetUrl = xResAccess->getURL(); xResAccess->UNLOCK( Environment ); + // remove options from cache, unlock may change it + // it will be refreshed when needed + aStaticDAVOptionsCache.removeDAVOptions( aTargetUrl ); { osl::Guard< osl::Mutex > aGuard( m_aMutex ); @@ -3213,6 +3229,9 @@ void Content::unlock( } break; default: + // remove options from cache, + // it will be refreshed when needed + aStaticDAVOptionsCache.removeDAVOptions( aTargetUrl ); //fallthrough ; } @@ -3753,7 +3772,12 @@ void Content::getResourceOptions( rDAVOptions.isClass3() ) ? m_nOptsCacheLifeDAV : // a WebDAV site m_nOptsCacheLifeImplWeb; // a site implementing OPTIONS but - // it's not DAV + // it's not DAV + // if resource is locked, will use a + // different lifetime + if( rDAVOptions.isLocked() ) + nLifeTime = m_nOptsCacheLifeDAVLocked; + // check if redirected aRedirURL = rResAccess->getURL(); if( aRedirURL == aTargetURL) |