ucb/source/ucp/webdav-curl/webdavcontent.cxx |   37 +++++++++++++++++++++++++++
 ucb/source/ucp/webdav-curl/webdavcontent.hxx |   17 ++++++++++++
 2 files changed, 54 insertions(+)

New commits:
commit 7f5f568b9c31df2391dabd4abb5711a109e5480a
Author:     Giuseppe Castagno <giuseppe.casta...@acca-esse.eu>
AuthorDate: Sun Jan 10 17:32:53 2016 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Mon Nov 1 18:36:38 2021 +0100

    ucb: webdav-curl: tdf#101094 (11): Add WebDAV options cache configuration 
param.
    
    Added in officecfg five new properties to be able to set
    cache lifetime if needed.
    
    The new properties are available in advanced, expert configuration only,
    in org.openoffice.Inet.Settings.
    
    Default values are as follows (value is in seconds):
        OptsCacheLifeImplWeb = 300
            when the web resource is Web only, implementing OPTIONS.
            Min. 0 sec (no caching) max. 3600 sec (1h).
    
        OptsCacheLifeDAV = 60
            when the web resource is WebDAV.
            Min. 0 sec (no caching) max. 3600 sec (1h).
    
        OptsCacheLifeDAVLocked = 600
            when the web resource is WebDAV and it's locked by
            this LO instance (e.g. lock store has a lock to it).
            Min. 0 sec (no caching) max. 3600 sec (1h).
    
        OptsCacheLifeNotImpl = 3600
            when the web resource does not implement OPTIONS method.
            Min. 0 sec (no caching) max. 43200 sec (12h).
    
        OptsCacheLifeNotFound = 15
            when the requested web resource is not found on server.
            Min. 0 sec (no caching) max. 30 sec.
    
    [ port of commit 2c0b4ff238f39b5fcce09c7d36e80ac1e7cb713e ]
    
    Change-Id: I5a4c44449c91b7d3a8840bfaf8326e35f86415dd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123462
    Tested-by: Michael Stahl <michael.st...@allotropia.de>
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx 
b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
index 706f3a0fb25a..d41ce66a266f 100644
--- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
@@ -22,6 +22,7 @@
 #include <cppuhelper/queryinterface.hxx>
 #include <rtl/uri.hxx>
 #include <sal/log.hxx>
+#include <officecfg/Inet.hxx>
 #include <ucbhelper/contentidentifier.hxx>
 #include <ucbhelper/macros.hxx>
 #include <ucbhelper/propertyvalueset.hxx>
@@ -185,6 +186,12 @@ void lcl_sendPartialGETRequest( bool &bError,
 }
 }
 
+// Static value, to manage a simple OPTIONS cache
+// Key is the URL, element is the DAVOptions resulting from an OPTIONS call.
+// Cached DAVOptions have a lifetime that depends on the errors received or 
not received
+// and on the value of received options.
+static DAVOptionsCache aStaticDAVOptionsCache;
+
 
 // Content Implementation.
 
@@ -206,6 +213,7 @@ Content::Content(
 {
     try
     {
+        initOptsCacheLifeTime();
         m_xResAccess.reset( new DAVResourceAccess(
                 rxContext,
                 rSessionFactory,
@@ -238,6 +246,7 @@ Content::Content(
 {
     try
     {
+        initOptsCacheLifeTime();
         m_xResAccess.reset( new DAVResourceAccess(
             rxContext, rSessionFactory, Identifier->getContentIdentifier() ) );
     }
@@ -3697,6 +3706,34 @@ Content::ResourceType Content::getResourceType(
 }
 
 
+void Content::initOptsCacheLifeTime()
+{
+    // see description in
+    // officecfg/registry/schema/org/openoffice/Inet.xcs
+    // for use of these field values.
+    sal_uInt32 nAtime;
+    nAtime = officecfg::Inet::Settings::OptsCacheLifeImplWeb::get( m_xContext 
);
+    m_nOptsCacheLifeImplWeb = std::max( sal_uInt32( 0 ),
+                                        std::min( nAtime, sal_uInt32( 3600 ) ) 
);
+
+    nAtime = officecfg::Inet::Settings::OptsCacheLifeDAV::get( m_xContext );
+    m_nOptsCacheLifeDAV = std::max( sal_uInt32( 0 ),
+                                    std::min( nAtime, sal_uInt32( 3600 ) ) );
+
+    nAtime = officecfg::Inet::Settings::OptsCacheLifeDAVLocked::get( 
m_xContext );
+    m_nOptsCacheLifeDAVLocked = std::max( sal_uInt32( 0 ),
+                                    std::min( nAtime, sal_uInt32( 3600 ) ) );
+
+    nAtime = officecfg::Inet::Settings::OptsCacheLifeNotImpl::get( m_xContext 
);
+    m_nOptsCacheLifeNotImpl = std::max( sal_uInt32( 0 ),
+                                              std::min( nAtime, sal_uInt32( 
43200 ) ) );
+
+    nAtime = officecfg::Inet::Settings::OptsCacheLifeNotFound::get( m_xContext 
);
+    m_nOptsCacheLifeNotFound = std::max( sal_uInt32( 0 ),
+                                              std::min( nAtime, sal_uInt32( 30 
) ) );
+}
+
+
 void Content::getResourceOptions(
                     const css::uno::Reference< css::ucb::XCommandEnvironment 
>& xEnv,
                     DAVOptions& rDAVOptions,
diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.hxx 
b/ucb/source/ucp/webdav-curl/webdavcontent.hxx
index 209f43516a3c..7c1f45661822 100644
--- a/ucb/source/ucp/webdav-curl/webdavcontent.hxx
+++ b/ucb/source/ucp/webdav-curl/webdavcontent.hxx
@@ -86,6 +86,23 @@ class Content : public ::ucbhelper::ContentImplHelper,
     bool              m_bCollection;
     bool              m_bDidGetOrHead;
     std::vector< OUString > m_aFailedPropNames;
+    // Options Cache lifetime
+    // for web site implementing OPTIONS, but not dav
+    sal_uInt32 m_nOptsCacheLifeImplWeb;
+    // for WebDAV site where OPTIONS is mandatory
+    sal_uInt32 m_nOptsCacheLifeDAV;
+    // same as above, but when the resource is locked by us
+    sal_uInt32 m_nOptsCacheLifeDAVLocked;
+// For web site not implementing OPTIONS
+    // during this time we assume the site doesn't turn to WebDAV
+    // but remains a simple Web
+    sal_uInt32 m_nOptsCacheLifeNotImpl;
+    // When resource is not found
+    // may be the resource is unavailable only briefly?
+    // so better have this small
+    sal_uInt32 m_nOptsCacheLifeNotFound;
+
+    void initOptsCacheLifeTime();
 
 private:
     virtual css::uno::Sequence< css::beans::Property >

Reply via email to