[Libreoffice-commits] core.git: sfx2/source ucb/source

Giuseppe Castagno giuseppe.castagno at acca-esse.eu
Thu Jul 28 20:52:28 UTC 2016


 sfx2/source/doc/docfile.cxx                  |    6 -
 ucb/source/ucp/webdav-neon/webdavcontent.cxx |  158 ++++++++++++++++++++-------
 2 files changed, 124 insertions(+), 40 deletions(-)

New commits:
commit 211cb2dec3501a9ea224512ebedbc7cd1c46cd45
Author: Giuseppe Castagno <giuseppe.castagno at acca-esse.eu>
Date:   Sun Jan 10 15:16:13 2016 +0100

    tdf#101094 (5) OPTIONS: Add options check in Content::getResourceType
    
    Added some verbose SAL_INFO to detail server responses to PROPFIND.
    
    Corrected a wrong comment and beautified a bit code I introduced
    in commit 3b26a2a403ca5e99b0dd07d042d47501c091af16.
    
    Change-Id: Id59749fe60fe0b451d8e0f4093d7902fe94bbed0
    Reviewed-on: https://gerrit.libreoffice.org/27635
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Giuseppe Castagno <giuseppe.castagno at acca-esse.eu>

diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 7af4a77..4ac0240 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -418,14 +418,14 @@ Reference < XContent > SfxMedium::GetContent() const
         Reference < css::ucb::XContent > xContent;
 
         // tdf#95144 add a default css::ucb::XCommandEnvironment
-        // in order to have http and https protocol manage certificates correctly
+        // in order to have the WebDAV UCP provider manage https protocol certificates correctly
         css:: uno::Reference< task::XInteractionHandler > xIH(
                 css::task::InteractionHandler::createWithParent( comphelper::getProcessComponentContext(), nullptr ) );
 
         css::uno::Reference< css::ucb::XProgressHandler > xProgress;
-        ::ucbhelper::CommandEnvironment* pCommandEnv = new ::ucbhelper::CommandEnvironment(new comphelper::SimpleFileAccessInteraction( xIH ), xProgress);
+        ::ucbhelper::CommandEnvironment* pCommandEnv = new ::ucbhelper::CommandEnvironment( new comphelper::SimpleFileAccessInteraction( xIH ), xProgress );
 
-        Reference < css::ucb::XCommandEnvironment > xEnv(static_cast< css::ucb::XCommandEnvironment* >(pCommandEnv), css::uno::UNO_QUERY);
+        Reference < css::ucb::XCommandEnvironment > xEnv( static_cast< css::ucb::XCommandEnvironment* >(pCommandEnv), css::uno::UNO_QUERY );
 
         const SfxUnoAnyItem* pItem = SfxItemSet::GetItem<SfxUnoAnyItem>(pImpl->m_pSet, SID_CONTENT, false);
         if ( pItem )
diff --git a/ucb/source/ucp/webdav-neon/webdavcontent.cxx b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
index bf1b8d0..60e91be 100644
--- a/ucb/source/ucp/webdav-neon/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
@@ -1338,6 +1338,36 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
 
                         if ( 1 == resources.size() )
                         {
+#if defined SAL_LOG_INFO
+                            {//debug
+                                // print received resources
+                                std::vector< DAVPropertyValue >::const_iterator it = resources[0].properties.begin();
+                                std::vector< DAVPropertyValue >::const_iterator end = resources[0].properties.end();
+                                while ( it != end )
+                                {
+                                    OUString aPropValue;
+                                    bool    bValue;
+                                    uno::Sequence< ucb::LockEntry > aSupportedLocks;
+                                    if( (*it).Value >>= aPropValue )
+                                        SAL_INFO( "ucb.ucp.webdav", "PROPFIND (getPropertyValues) - returned property: " << (*it).Name << ":" << aPropValue );
+                                    else if( (*it).Value >>= bValue )
+                                        SAL_INFO( "ucb.ucp.webdav", "PROPFIND (getPropertyValues) - returned property: " << (*it).Name << ":" <<
+                                                  ( bValue ? "true" : "false" ) );
+                                    else if( (*it).Value >>= aSupportedLocks )
+                                    {
+                                        SAL_INFO( "ucb.ucp.webdav", "PROPFIND (getPropertyValues) - returned property: " << (*it).Name << ":" );
+                                        for ( sal_Int32 n = 0; n < aSupportedLocks.getLength(); ++n )
+                                        {
+                                            SAL_INFO( "ucb.ucp.webdav","      scope: "
+                                                      << ( aSupportedLocks[ n ].Scope ? "shared":"exclusive" )
+                                                      << ", type: "
+                                                      << ( aSupportedLocks[ n ].Type ? "" : "write" ) );
+                                        }
+                                    }
+                                    ++it;
+                                }
+                            }
+#endif
                             if ( xProps.get())
                                 xProps->addProperties(
                                     aPropNames,
@@ -3429,6 +3459,7 @@ Content::ResourceType Content::getResourceType(
     }
 
     ResourceType eResourceType = UNKNOWN;
+    DAVOptions aDAVOptions;
 
     const OUString & rURL = rResAccess->getURL();
     const OUString aScheme(
@@ -3440,57 +3471,110 @@ Content::ResourceType Content::getResourceType(
     }
     else
     {
-        try
+        getResourceOptions( xEnv, aDAVOptions, rResAccess );
+
+        // at least class one is needed
+        if( aDAVOptions.isClass1() )
         {
-            // Try to fetch some frequently used property value, e.g. those
-            // used when loading documents... along with identifying whether
-            // this is a DAV resource.
-            std::vector< DAVResource > resources;
-            std::vector< OUString > aPropNames;
-            uno::Sequence< beans::Property > aProperties( 5 );
-            aProperties[ 0 ].Name = "IsFolder";
-            aProperties[ 1 ].Name = "IsDocument";
-            aProperties[ 2 ].Name = "IsReadOnly";
-            aProperties[ 3 ].Name = "MediaType";
-            aProperties[ 4 ].Name = DAVProperties::SUPPORTEDLOCK;
+            try
+            {
+                // Try to fetch some frequently used property value, e.g. those
+                // used when loading documents... along with identifying whether
+                // this is a DAV resource.
+                std::vector< DAVResource > resources;
+                std::vector< OUString > aPropNames;
+                uno::Sequence< beans::Property > aProperties( 5 );
+                aProperties[ 0 ].Name = "IsFolder";
+                aProperties[ 1 ].Name = "IsDocument";
+                aProperties[ 2 ].Name = "IsReadOnly";
+                aProperties[ 3 ].Name = "MediaType";
+                aProperties[ 4 ].Name = DAVProperties::SUPPORTEDLOCK;
 
-            ContentProperties::UCBNamesToDAVNames( aProperties, aPropNames );
+                ContentProperties::UCBNamesToDAVNames( aProperties, aPropNames );
 
-            rResAccess->PROPFIND( DAVZERO, aPropNames, resources, xEnv );
+                rResAccess->PROPFIND( DAVZERO, aPropNames, resources, xEnv );
 
-            if ( resources.size() == 1 )
+                if ( resources.size() == 1 )
+                {
+#if defined SAL_LOG_INFO
+                    {//debug
+                        // print received resources
+                        std::vector< DAVPropertyValue >::const_iterator it = resources[0].properties.begin();
+                        std::vector< DAVPropertyValue >::const_iterator end = resources[0].properties.end();
+                        while ( it != end )
+                        {
+                            OUString aPropValue;
+                            bool    bValue;
+                            uno::Sequence< ucb::LockEntry > aSupportedLocks;
+                            if((*it).Value >>= aPropValue )
+                                SAL_INFO( "ucb.ucp.webdav", "PROPFIND (getResourceType) - ret'd prop: " << (*it).Name << ":" << aPropValue );
+                            else if( (*it).Value >>= bValue )
+                                SAL_INFO( "ucb.ucp.webdav", "PROPFIND (getResourceType) - ret'd prop: " << (*it).Name << ":" <<
+                                          ( bValue ? "true" : "false" ) );
+                            else if( (*it).Value >>= aSupportedLocks )
+                            {
+                                SAL_INFO( "ucb.ucp.webdav", "PROPFIND (getResourceType) - ret'd prop: " << (*it).Name << ":" );
+                                for ( sal_Int32 n = 0; n < aSupportedLocks.getLength(); ++n )
+                                {
+                                    SAL_INFO( "ucb.ucp.webdav","PROPFIND (getResourceType) -       supportedlock[" << n <<"]: scope: "
+                                              << ( aSupportedLocks[ n ].Scope ? "shared":"exclusive" )
+                                              << ", type: "
+                                              << ( aSupportedLocks[ n ].Type ? "" : "write" ) );
+                                }
+                            }
+                            ++it;
+                        }
+                    }
+#endif
+                    osl::MutexGuard g(m_aMutex);
+                    m_xCachedProps.reset(
+                        new CachableContentProperties( ContentProperties( resources[ 0 ] ) ) );
+                    m_xCachedProps->containsAllNames(
+                        aProperties, m_aFailedPropNames );
+                }
+                eResourceType = DAV;
+            }
+            catch ( DAVException const & e )
             {
-                osl::MutexGuard g(m_aMutex);
-                m_xCachedProps.reset(
-                    new CachableContentProperties( ContentProperties( resources[ 0 ] ) ) );
-                m_xCachedProps->containsAllNames(
-                    aProperties, m_aFailedPropNames );
+                rResAccess->resetUri();
+
+                SAL_WARN( "ucb.ucp.webdav", "Content::getResourceType returned errors, DAV: " << e.getError() << ", http error: "  << e.getStatus() );
+
+                if ( e.getStatus() == SC_METHOD_NOT_ALLOWED )
+                {
+                    // Status SC_METHOD_NOT_ALLOWED is a safe indicator that the
+                    // resource is NON_DAV
+                    eResourceType = NON_DAV;
+                }
+                else if (networkAccessAllowed != nullptr)
+                {
+                    *networkAccessAllowed = *networkAccessAllowed
+                        && shouldAccessNetworkAfterException(e);
+                }
+                // if the two net events below happen, something
+                // is going on to the connection so break the command flow
+                if ( ( e.getError() == DAVException::DAV_HTTP_TIMEOUT ) ||
+                     ( e.getError() == DAVException::DAV_HTTP_CONNECT ) )
+                {
+                    cancelCommandExecution( e, xEnv );
+                    // unreachable
+                }
             }
-            eResourceType = DAV;
         }
-        catch ( DAVException const & e )
+        else
         {
             rResAccess->resetUri();
 
-            if ( e.getStatus() == SC_METHOD_NOT_ALLOWED )
+            if ( aDAVOptions.isResourceFound() )
             {
-                // Status SC_METHOD_NOT_ALLOWED is a safe indicator that the
-                // resource is NON_DAV
                 eResourceType = NON_DAV;
             }
-            else if (networkAccessAllowed != nullptr)
-            {
-                *networkAccessAllowed = *networkAccessAllowed
-                    && shouldAccessNetworkAfterException(e);
-            }
-            // if the two net events below happen, something
-            // is going on to the connection so break the command flow
-            if ( ( e.getError() == DAVException::DAV_HTTP_TIMEOUT ) ||
-                 ( e.getError() == DAVException::DAV_HTTP_CONNECT ) )
+            else
             {
-                cancelCommandExecution( e, xEnv );
-                // unreachable
-            }
+                //resource doesn't exist
+                if ( networkAccessAllowed != nullptr )
+                    *networkAccessAllowed = false;
+          }
         }
     }
 


More information about the Libreoffice-commits mailing list