summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorGiuseppe Castagno <giuseppe.castagno@acca-esse.eu>2016-01-10 15:16:13 +0100
committerMichael Stahl <michael.stahl@allotropia.de>2021-11-01 18:34:19 +0100
commit70f197cc6728482b0a42f4b1e90c55879346fdfb (patch)
tree81fea0ec8ab6f020f9f7d58e64c4710f58660d6a /ucb
parentdac69982586001cb42af900382c544f052820913 (diff)
ucb: webdav-curl: 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. [ port of commit 211cb2dec3501a9ea224512ebedbc7cd1c46cd45 ] Change-Id: I7917408dcc09e42cb23d29b28e02904594023dd8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123287 Tested-by: Michael Stahl <michael.stahl@allotropia.de> Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/ucp/webdav-curl/webdavcontent.cxx170
1 files changed, 127 insertions, 43 deletions
diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
index 3ffde115c8ed..b499327878d1 100644
--- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
@@ -1353,6 +1353,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 == ucb::LockScope_SHARED ? "shared" : "exclusive")
+ << ", type: "
+ << (aSupportedLocks[n].Type != ucb::LockType_WRITE ? "" : "write") );
+ }
+ }
+ ++it;
+ }
+ }
+#endif
if (xProps)
xProps->addProperties(
aPropNames,
@@ -3473,65 +3503,119 @@ Content::ResourceType Content::getResourceType(
}
ResourceType eResourceType = UNKNOWN;
+ DAVOptions aDAVOptions;
{
- 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 == ucb::LockScope_SHARED ? "shared" : "exclusive")
+ << ", type: "
+ << (aSupportedLocks[n].Type != ucb::LockType_WRITE ? "" : "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
+ }
+
+ // cancel command execution is case that no user authentication data has been provided.
+ if ( e.getError() == DAVException::DAV_HTTP_NOAUTH )
+ {
+ cancelCommandExecution( e, uno::Reference< ucb::XCommandEnvironment >() );
+ }
}
- 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 ) )
- {
- cancelCommandExecution( e, xEnv );
- // unreachable
- }
-
- // cancel command execution is case that no user authentication data has been provided.
- if ( e.getError() == DAVException::DAV_HTTP_NOAUTH )
+ else
{
- cancelCommandExecution( e, uno::Reference< ucb::XCommandEnvironment >() );
- }
+ //resource doesn't exist
+ if ( networkAccessAllowed != nullptr )
+ *networkAccessAllowed = false;
+ }
}
}