summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorGiuseppe Castagno <giuseppe.castagno@acca-esse.eu>2016-01-10 15:16:13 +0100
committerGiuseppe Castagno <giuseppe.castagno@acca-esse.eu>2016-07-28 20:51:53 +0000
commit211cb2dec3501a9ea224512ebedbc7cd1c46cd45 (patch)
treec286975f453b0570a572db2396c1453075f62b70 /ucb
parent171586cc4df4a9470251e50ce51338c2d53acf9b (diff)
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@libreoffice.org> Reviewed-by: Giuseppe Castagno <giuseppe.castagno@acca-esse.eu>
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/ucp/webdav-neon/webdavcontent.cxx158
1 files changed, 121 insertions, 37 deletions
diff --git a/ucb/source/ucp/webdav-neon/webdavcontent.cxx b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
index bf1b8d017b9f..60e91be3e00c 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;
+ }
}
}