summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Castagno <giuseppe.castagno@acca-esse.eu>2016-01-10 10:42:47 +0100
committerGiuseppe Castagno <giuseppe.castagno@acca-esse.eu>2016-07-28 09:00:35 +0000
commit2777b6380c17bad8a966454947b9d991f9592224 (patch)
tree864a002eb8376c405bdfa771ac3043893364b6bf
parentf30184cc28abcfcc38c14152aa43e310e3a64a27 (diff)
tdf#101094 (4) OPTIONS: Add member function getResourceOptions
Change-Id: Ia98456842f666ad97a9a8ffc82e787c0c88066f6 Reviewed-on: https://gerrit.libreoffice.org/27608 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Giuseppe Castagno <giuseppe.castagno@acca-esse.eu>
-rw-r--r--ucb/source/ucp/webdav-neon/webdavcontent.cxx102
-rw-r--r--ucb/source/ucp/webdav-neon/webdavcontent.hxx13
2 files changed, 115 insertions, 0 deletions
diff --git a/ucb/source/ucp/webdav-neon/webdavcontent.cxx b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
index 3b82bb49a7ba..bf1b8d017b9f 100644
--- a/ucb/source/ucp/webdav-neon/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
@@ -3525,4 +3525,106 @@ Content::ResourceType Content::getResourceType(
return ret;
}
+
+void Content::getResourceOptions(
+ const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv,
+ DAVOptions& rDAVOptions,
+ const std::unique_ptr< DAVResourceAccess > & rResAccess )
+ throw ( css::uno::Exception, std::exception )
+{
+ try
+ {
+ rResAccess->OPTIONS( rDAVOptions, xEnv );
+ // IMPORTANT:the correctly implemented server will answer without errors, even if the resource is not present
+ }
+ catch ( DAVException const & e )
+ {
+ rResAccess->resetUri();
+
+ switch( e.getError() )
+ {
+ case DAVException::DAV_HTTP_TIMEOUT:
+ case DAVException::DAV_HTTP_CONNECT:
+ {
+ // something bad happened to the connection
+ // not same as not found, this instead happens when the server does'n exist or does'n aswer at all
+ // probably a new bit stating 'timed out' should be added to opts var?
+ // in any case abort the command
+ cancelCommandExecution( e, xEnv );
+ // unreachable
+ }
+ break;
+ case DAVException::DAV_HTTP_AUTH:
+ {
+ SAL_WARN( "ucb.ucp.webdav", "OPTIONS - DAVException Authentication error for URL <" << m_xIdentifier->getContentIdentifier() << ">" );
+ // - the remote site is a WebDAV with special configuration: read/only for read operations
+ // and read/write for write operations, the user is not allowed to lock/write and
+ // she cancelled the credentials request.
+ // this is not actually an error, it means only that for current user this is a standard web,
+ // though possibly DAV enabled
+ }
+ break;
+ case DAVException::DAV_HTTP_ERROR:
+ {
+ switch( e.getStatus() )
+ {
+ case SC_FORBIDDEN:
+ {
+ SAL_WARN( "ucb.ucp.webdav","OPTIONS - Forbidden for URL <" << m_xIdentifier->getContentIdentifier() << ">" );
+ rDAVOptions.setResourceFound(); // means it exists, but it's not DAV
+ }
+ break;
+ case SC_BAD_REQUEST:
+ {
+ SAL_WARN( "ucb.ucp.webdav","OPTIONS - Bad request for URL <" << m_xIdentifier->getContentIdentifier() << ">" );
+ rDAVOptions.setResourceFound(); // means it exists, but it's not DAV
+ }
+ break;
+ case SC_NOT_IMPLEMENTED:
+ case SC_METHOD_NOT_ALLOWED:
+ {
+ // OPTIONS method must be implemented in DAV
+ // resource is NON_DAV, or not advertising it
+ SAL_WARN( "ucb.ucp.webdav","OPTIONS - Method not implemented or not allowed for URL <" << m_xIdentifier->getContentIdentifier() << ">" );
+ rDAVOptions.setResourceFound(); // means it exists, but it's not DAV
+ }
+ break;
+ case SC_NOT_FOUND:
+ {
+ SAL_WARN( "ucb.ucp.webdav", "OPTIONS - Resource not found for URL <" << m_xIdentifier->getContentIdentifier() << ">" );
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ default: // leave the resource type as UNKNOWN, for now
+ // it means this will be managed as a standard http site
+ SAL_WARN( "ucb.ucp.webdav","OPTIONS - DAVException for URL <" << m_xIdentifier->getContentIdentifier() << ">, DAV error: "
+ << e.getError() << ", HTTP error: "<<e.getStatus() );
+ break;
+ }
+ }
+}
+
+
+void Content::getResourceOptions(
+ const uno::Reference< ucb::XCommandEnvironment >& xEnv,
+ DAVOptions& rDAVOptions )
+ throw ( uno::Exception, std::exception )
+{
+ std::unique_ptr< DAVResourceAccess > xResAccess;
+ {
+ osl::MutexGuard aGuard( m_aMutex );
+ xResAccess.reset( new DAVResourceAccess( *m_xResAccess.get() ) );
+ }
+ getResourceOptions( xEnv, rDAVOptions, xResAccess );
+ {
+ osl::Guard< osl::Mutex > aGuard( m_aMutex );
+ m_xResAccess.reset( new DAVResourceAccess( *xResAccess.get() ) );
+ }
+}
+
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/ucb/source/ucp/webdav-neon/webdavcontent.hxx b/ucb/source/ucp/webdav-neon/webdavcontent.hxx
index 0dc43b5dee03..016f93cb3bf4 100644
--- a/ucb/source/ucp/webdav-neon/webdavcontent.hxx
+++ b/ucb/source/ucp/webdav-neon/webdavcontent.hxx
@@ -88,7 +88,9 @@ class Content : public ::ucbhelper::ContentImplHelper,
std::unique_ptr< CachableContentProperties >
m_xCachedProps; // locally cached props
OUString m_aEscapedTitle;
+ // resource type for general DAV methods
ResourceType m_eResourceType;
+ // resource type for general LOCK method only
ResourceType m_eResourceTypeForLocks;
ContentProvider* m_pProvider; // No need for a ref, base class holds object
rtl::Reference< DAVSessionFactory > m_rSessionFactory;
@@ -294,6 +296,17 @@ public:
const ContentProperties& rData,
const rtl::Reference< ::ucbhelper::ContentProviderImplHelper >& rProvider,
const OUString& rContentId );
+
+ // Use OPTIONS method to retrieve the type of the Web resource
+ void getResourceOptions( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv,
+ DAVOptions& rDAVOptions,
+ const std::unique_ptr< DAVResourceAccess > & rResAccess )
+ throw ( css::uno::Exception, std::exception );
+
+ void getResourceOptions( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv,
+ DAVOptions& rDAVOptions )
+ throw ( css::uno::Exception, std::exception );
+
};
}