Kaydet (Commit) 2f73ff06 authored tarafından Kurt Zenker's avatar Kurt Zenker

INTEGRATION: CWS updatefeed (1.21.22); FILE MERGED

2006/12/04 16:54:47 kso 1.21.22.2: #i72055# - Added support for XWebDAVCommandEnvironment.
2006/11/29 13:03:02 kso 1.21.22.1: #i72055# - cleanup.
üst 87a0e7be
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
* *
* $RCSfile: DAVResourceAccess.cxx,v $ * $RCSfile: DAVResourceAccess.cxx,v $
* *
* $Revision: 1.21 $ * $Revision: 1.22 $
* *
* last change: $Author: obo $ $Date: 2006-09-17 14:04:27 $ * last change: $Author: kz $ $Date: 2006-12-13 15:04:02 $
* *
* The Contents of this file are made available subject to * The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1. * the terms of GNU Lesser General Public License Version 2.1.
...@@ -36,30 +36,19 @@ ...@@ -36,30 +36,19 @@
// MARKER(update_precomp.py): autogen include statement, do not remove // MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_ucb.hxx" #include "precompiled_ucb.hxx"
#ifndef _OSL_DIAGNOSE_H_ #include "osl/diagnose.h"
#include <osl/diagnose.h>
#endif
#ifndef _COM_SUN_STAR_TASK_XINTERACTIONABORT_HPP_ #include "com/sun/star/task/XInteractionAbort.hpp"
#include <com/sun/star/task/XInteractionAbort.hpp> #include "com/sun/star/ucb/XWebDAVCommandEnvironment.hpp"
#endif
#ifndef _UCBHELPER_SIMPLEAUTHENTICATIONREQUEST_HXX #include "ucbhelper/simpleauthenticationrequest.hxx"
#include <ucbhelper/simpleauthenticationrequest.hxx>
#endif
#ifndef _DAVAUTHLISTENERIMPL_HXX_
#include "DAVAuthListenerImpl.hxx" #include "DAVAuthListenerImpl.hxx"
#endif
#ifndef _DAVRESOURCEACCESS_HXX_
#include "DAVResourceAccess.hxx" #include "DAVResourceAccess.hxx"
#endif
using namespace webdav_ucp; using namespace webdav_ucp;
using namespace com::sun::star; using namespace com::sun::star;
//========================================================================= //=========================================================================
//========================================================================= //=========================================================================
// //
...@@ -78,10 +67,10 @@ int DAVAuthListener_Impl::authenticate( ...@@ -78,10 +67,10 @@ int DAVAuthListener_Impl::authenticate(
{ {
if ( m_xEnv.is() ) if ( m_xEnv.is() )
{ {
uno::Reference< task::XInteractionHandler > xIH uno::Reference< task::XInteractionHandler > xIH
= m_xEnv->getInteractionHandler(); = m_xEnv->getInteractionHandler();
if ( xIH.is() ) if ( xIH.is() )
{ {
// #102871# - Supply username and password from previous try. // #102871# - Supply username and password from previous try.
// Password container service depends on this! // Password container service depends on this!
if ( inoutUserName.getLength() == 0 ) if ( inoutUserName.getLength() == 0 )
...@@ -101,12 +90,12 @@ int DAVAuthListener_Impl::authenticate( ...@@ -101,12 +90,12 @@ int DAVAuthListener_Impl::authenticate(
= xRequest->getSelection(); = xRequest->getSelection();
if ( xSelection.is() ) if ( xSelection.is() )
{ {
// Handler handled the request. // Handler handled the request.
uno::Reference< task::XInteractionAbort > xAbort( uno::Reference< task::XInteractionAbort > xAbort(
xSelection.get(), uno::UNO_QUERY ); xSelection.get(), uno::UNO_QUERY );
if ( !xAbort.is() ) if ( !xAbort.is() )
{ {
const rtl::Reference< const rtl::Reference<
ucbhelper::InteractionSupplyAuthentication > & xSupp ucbhelper::InteractionSupplyAuthentication > & xSupp
= xRequest->getAuthenticationSupplier(); = xRequest->getAuthenticationSupplier();
...@@ -119,10 +108,10 @@ int DAVAuthListener_Impl::authenticate( ...@@ -119,10 +108,10 @@ int DAVAuthListener_Impl::authenticate(
m_aPrevPassword = outPassWord; m_aPrevPassword = outPassWord;
// go on. // go on.
return 0; return 0;
}
}
} }
}
}
} }
// Abort. // Abort.
return -1; return -1;
...@@ -138,9 +127,9 @@ int DAVAuthListener_Impl::authenticate( ...@@ -138,9 +127,9 @@ int DAVAuthListener_Impl::authenticate(
//========================================================================= //=========================================================================
DAVResourceAccess::DAVResourceAccess( DAVResourceAccess::DAVResourceAccess(
const uno::Reference< lang::XMultiServiceFactory > & rSMgr, const uno::Reference< lang::XMultiServiceFactory > & rSMgr,
rtl::Reference< DAVSessionFactory > const & rSessionFactory, rtl::Reference< DAVSessionFactory > const & rSessionFactory,
const rtl::OUString & rURL ) const rtl::OUString & rURL )
: m_aURL( rURL ), : m_aURL( rURL ),
m_xSessionFactory( rSessionFactory ), m_xSessionFactory( rSessionFactory ),
m_xSMgr( rSMgr ) m_xSMgr( rSMgr )
...@@ -160,7 +149,7 @@ DAVResourceAccess::DAVResourceAccess( const DAVResourceAccess & rOther ) ...@@ -160,7 +149,7 @@ DAVResourceAccess::DAVResourceAccess( const DAVResourceAccess & rOther )
//========================================================================= //=========================================================================
DAVResourceAccess & DAVResourceAccess::operator=( DAVResourceAccess & DAVResourceAccess::operator=(
const DAVResourceAccess & rOther ) const DAVResourceAccess & rOther )
{ {
m_aURL = rOther.m_aURL; m_aURL = rOther.m_aURL;
m_aPath = rOther.m_aPath; m_aPath = rOther.m_aPath;
...@@ -173,137 +162,169 @@ DAVResourceAccess & DAVResourceAccess::operator=( ...@@ -173,137 +162,169 @@ DAVResourceAccess & DAVResourceAccess::operator=(
} }
//========================================================================= //=========================================================================
void DAVResourceAccess::OPTIONS( DAVCapabilities & rCapabilities, void DAVResourceAccess::OPTIONS(
const uno::Reference< DAVCapabilities & rCapabilities,
ucb::XCommandEnvironment > & xEnv ) const uno::Reference< ucb::XCommandEnvironment > & xEnv )
throw( DAVException ) throw( DAVException )
{ {
initialize(); initialize();
sal_Bool bRetry; sal_Bool bRetry;
do do
{ {
bRetry = sal_False; bRetry = sal_False;
try try
{ {
DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv,
getRequestURI(),
rtl::OUString::createFromAscii(
"OPTIONS" ),
aHeaders );
m_xSession->OPTIONS( getRequestURI(), m_xSession->OPTIONS( getRequestURI(),
rCapabilities, rCapabilities,
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ) ) ); new DAVAuthListener_Impl( xEnv ),
} aHeaders) );
catch ( DAVException & e ) }
{ catch ( DAVException & e )
bRetry = handleException( e ); {
if ( !bRetry ) bRetry = handleException( e );
throw; if ( !bRetry )
} throw;
}
} }
while ( bRetry ); while ( bRetry );
} }
//========================================================================= //=========================================================================
void DAVResourceAccess::PROPFIND( const Depth nDepth, void DAVResourceAccess::PROPFIND(
const std::vector< rtl::OUString > & rPropertyNames, const Depth nDepth,
std::vector< DAVResource > & rResources, const std::vector< rtl::OUString > & rPropertyNames,
const uno::Reference< std::vector< DAVResource > & rResources,
ucb::XCommandEnvironment > & xEnv ) const uno::Reference< ucb::XCommandEnvironment > & xEnv )
throw( DAVException ) throw( DAVException )
{ {
initialize(); initialize();
sal_Bool bRetry; sal_Bool bRetry;
do do
{ {
bRetry = sal_False; bRetry = sal_False;
try try
{ {
DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv,
getRequestURI(),
rtl::OUString::createFromAscii(
"PROPFIND" ),
aHeaders );
m_xSession->PROPFIND( getRequestURI(), m_xSession->PROPFIND( getRequestURI(),
nDepth, nDepth,
rPropertyNames, rPropertyNames,
rResources, rResources,
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ) ) ); new DAVAuthListener_Impl( xEnv ),
} aHeaders ) );
catch ( DAVException & e ) }
{ catch ( DAVException & e )
bRetry = handleException( e ); {
if ( !bRetry ) bRetry = handleException( e );
throw; if ( !bRetry )
} throw;
}
} }
while ( bRetry ); while ( bRetry );
} }
//========================================================================= //=========================================================================
void DAVResourceAccess::PROPFIND( const Depth nDepth, void DAVResourceAccess::PROPFIND(
std::vector< DAVResourceInfo > & rResInfo, const Depth nDepth,
const uno::Reference< std::vector< DAVResourceInfo > & rResInfo,
ucb::XCommandEnvironment > & xEnv ) const uno::Reference< ucb::XCommandEnvironment > & xEnv )
throw( DAVException ) throw( DAVException )
{ {
initialize(); initialize();
sal_Bool bRetry; sal_Bool bRetry;
do do
{ {
bRetry = sal_False; bRetry = sal_False;
try try
{ {
DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv,
getRequestURI(),
rtl::OUString::createFromAscii(
"PROPFIND" ),
aHeaders );
m_xSession->PROPFIND( getRequestURI(), m_xSession->PROPFIND( getRequestURI(),
nDepth, nDepth,
rResInfo, rResInfo,
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ) ) ) ; new DAVAuthListener_Impl( xEnv ),
} aHeaders ) ) ;
catch ( DAVException & e ) }
{ catch ( DAVException & e )
bRetry = handleException( e ); {
if ( !bRetry ) bRetry = handleException( e );
throw; if ( !bRetry )
} throw;
}
} }
while ( bRetry ); while ( bRetry );
} }
//========================================================================= //=========================================================================
void DAVResourceAccess::PROPPATCH( const std::vector< ProppatchValue >& rValues, void DAVResourceAccess::PROPPATCH(
const uno::Reference< const std::vector< ProppatchValue >& rValues,
ucb::XCommandEnvironment >& xEnv ) const uno::Reference< ucb::XCommandEnvironment >& xEnv )
throw( DAVException ) throw( DAVException )
{ {
initialize(); initialize();
sal_Bool bRetry; sal_Bool bRetry;
do do
{ {
bRetry = sal_False; bRetry = sal_False;
try try
{ {
DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv,
getRequestURI(),
rtl::OUString::createFromAscii(
"PROPPATCH" ),
aHeaders );
m_xSession->PROPPATCH( getRequestURI(), m_xSession->PROPPATCH( getRequestURI(),
rValues, rValues,
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ) ) ); new DAVAuthListener_Impl( xEnv ),
} aHeaders ) );
catch ( DAVException & e ) }
{ catch ( DAVException & e )
bRetry = handleException( e ); {
if ( !bRetry ) bRetry = handleException( e );
throw; if ( !bRetry )
} throw;
}
} }
while ( bRetry ); while ( bRetry );
} }
//========================================================================= //=========================================================================
void DAVResourceAccess::HEAD( const std::vector< rtl::OUString > & rHeaderNames, void DAVResourceAccess::HEAD(
DAVResource & rResource, const std::vector< rtl::OUString > & rHeaderNames,
const uno::Reference< DAVResource & rResource,
ucb::XCommandEnvironment >& xEnv ) const uno::Reference< ucb::XCommandEnvironment >& xEnv )
throw( DAVException ) throw( DAVException )
{ {
initialize(); initialize();
...@@ -313,12 +334,20 @@ void DAVResourceAccess::HEAD( const std::vector< rtl::OUString > & rHeaderNames, ...@@ -313,12 +334,20 @@ void DAVResourceAccess::HEAD( const std::vector< rtl::OUString > & rHeaderNames,
bRetry = sal_False; bRetry = sal_False;
try try
{ {
DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv,
getRequestURI(),
rtl::OUString::createFromAscii( "HEAD" ),
aHeaders );
m_xSession->HEAD( getRequestURI(), m_xSession->HEAD( getRequestURI(),
rHeaderNames, rHeaderNames,
rResource, rResource,
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ) ) ); new DAVAuthListener_Impl( xEnv ),
aHeaders ) );
} }
catch ( DAVException & e ) catch ( DAVException & e )
{ {
...@@ -332,8 +361,8 @@ void DAVResourceAccess::HEAD( const std::vector< rtl::OUString > & rHeaderNames, ...@@ -332,8 +361,8 @@ void DAVResourceAccess::HEAD( const std::vector< rtl::OUString > & rHeaderNames,
//========================================================================= //=========================================================================
uno::Reference< io::XInputStream > DAVResourceAccess::GET( uno::Reference< io::XInputStream > DAVResourceAccess::GET(
const uno::Reference< ucb::XCommandEnvironment > & xEnv ) const uno::Reference< ucb::XCommandEnvironment > & xEnv )
throw( DAVException ) throw( DAVException )
{ {
initialize(); initialize();
...@@ -341,20 +370,27 @@ uno::Reference< io::XInputStream > DAVResourceAccess::GET( ...@@ -341,20 +370,27 @@ uno::Reference< io::XInputStream > DAVResourceAccess::GET(
sal_Bool bRetry; sal_Bool bRetry;
do do
{ {
bRetry = sal_False; bRetry = sal_False;
try try
{ {
DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv,
getRequestURI(),
rtl::OUString::createFromAscii( "GET" ),
aHeaders );
xStream = m_xSession->GET( getRequestURI(), xStream = m_xSession->GET( getRequestURI(),
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ) ) ); new DAVAuthListener_Impl( xEnv ),
} aHeaders ) );
catch ( DAVException & e ) }
{ catch ( DAVException & e )
bRetry = handleException( e ); {
if ( !bRetry ) bRetry = handleException( e );
throw; if ( !bRetry )
} throw;
}
} }
while ( bRetry ); while ( bRetry );
...@@ -362,41 +398,48 @@ uno::Reference< io::XInputStream > DAVResourceAccess::GET( ...@@ -362,41 +398,48 @@ uno::Reference< io::XInputStream > DAVResourceAccess::GET(
} }
//========================================================================= //=========================================================================
void DAVResourceAccess::GET( uno::Reference< io::XOutputStream > & rStream, void DAVResourceAccess::GET(
const uno::Reference< uno::Reference< io::XOutputStream > & rStream,
ucb::XCommandEnvironment > & xEnv ) const uno::Reference< ucb::XCommandEnvironment > & xEnv )
throw( DAVException ) throw( DAVException )
{ {
initialize(); initialize();
sal_Bool bRetry; sal_Bool bRetry;
do do
{ {
bRetry = sal_False; bRetry = sal_False;
try try
{ {
DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv,
getRequestURI(),
rtl::OUString::createFromAscii( "GET" ),
aHeaders );
m_xSession->GET( getRequestURI(), m_xSession->GET( getRequestURI(),
rStream, rStream,
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ) ) ); new DAVAuthListener_Impl( xEnv ),
} aHeaders ) );
catch ( DAVException & e ) }
{ catch ( DAVException & e )
bRetry = handleException( e ); {
if ( !bRetry ) bRetry = handleException( e );
throw; if ( !bRetry )
} throw;
}
} }
while ( bRetry ); while ( bRetry );
} }
//========================================================================= //=========================================================================
uno::Reference< io::XInputStream > DAVResourceAccess::GET( uno::Reference< io::XInputStream > DAVResourceAccess::GET(
const std::vector< rtl::OUString > & rHeaderNames, const std::vector< rtl::OUString > & rHeaderNames,
DAVResource & rResource, DAVResource & rResource,
const uno::Reference< ucb::XCommandEnvironment > & xEnv ) const uno::Reference< ucb::XCommandEnvironment > & xEnv )
throw( DAVException ) throw( DAVException )
{ {
initialize(); initialize();
...@@ -407,12 +450,19 @@ uno::Reference< io::XInputStream > DAVResourceAccess::GET( ...@@ -407,12 +450,19 @@ uno::Reference< io::XInputStream > DAVResourceAccess::GET(
bRetry = sal_False; bRetry = sal_False;
try try
{ {
DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv,
getRequestURI(),
rtl::OUString::createFromAscii( "GET" ),
aHeaders );
xStream = m_xSession->GET( getRequestURI(), xStream = m_xSession->GET( getRequestURI(),
rHeaderNames, rHeaderNames,
rResource, rResource,
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ) ) ); new DAVAuthListener_Impl( xEnv ),
aHeaders ) );
} }
catch ( DAVException & e ) catch ( DAVException & e )
{ {
...@@ -428,11 +478,11 @@ uno::Reference< io::XInputStream > DAVResourceAccess::GET( ...@@ -428,11 +478,11 @@ uno::Reference< io::XInputStream > DAVResourceAccess::GET(
//========================================================================= //=========================================================================
void DAVResourceAccess::GET( void DAVResourceAccess::GET(
uno::Reference< io::XOutputStream > & rStream, uno::Reference< io::XOutputStream > & rStream,
const std::vector< rtl::OUString > & rHeaderNames, const std::vector< rtl::OUString > & rHeaderNames,
DAVResource & rResource, DAVResource & rResource,
const uno::Reference< ucb::XCommandEnvironment > & xEnv ) const uno::Reference< ucb::XCommandEnvironment > & xEnv )
throw( DAVException ) throw( DAVException )
{ {
initialize(); initialize();
...@@ -442,13 +492,20 @@ void DAVResourceAccess::GET( ...@@ -442,13 +492,20 @@ void DAVResourceAccess::GET(
bRetry = sal_False; bRetry = sal_False;
try try
{ {
DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv,
getRequestURI(),
rtl::OUString::createFromAscii( "GET" ),
aHeaders );
m_xSession->GET( getRequestURI(), m_xSession->GET( getRequestURI(),
rStream, rStream,
rHeaderNames, rHeaderNames,
rResource, rResource,
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ) ) ); new DAVAuthListener_Impl( xEnv ),
aHeaders ) );
} }
catch ( DAVException & e ) catch ( DAVException & e )
{ {
...@@ -461,42 +518,50 @@ void DAVResourceAccess::GET( ...@@ -461,42 +518,50 @@ void DAVResourceAccess::GET(
} }
//========================================================================= //=========================================================================
void DAVResourceAccess::PUT( const uno::Reference< io::XInputStream > & rStream, void DAVResourceAccess::PUT(
const uno::Reference< const uno::Reference< io::XInputStream > & rStream,
ucb::XCommandEnvironment > & xEnv ) const uno::Reference< ucb::XCommandEnvironment > & xEnv )
throw( DAVException ) throw( DAVException )
{ {
initialize(); initialize();
sal_Bool bRetry; sal_Bool bRetry;
do do
{ {
bRetry = sal_False; bRetry = sal_False;
try try
{ {
m_xSession->PUT( getRequestURI(), DAVRequestHeaders aHeaders;
rStream, getUserRequestHeaders( xEnv,
DAVRequestEnvironment( getRequestURI(),
getRequestURI(), rtl::OUString::createFromAscii( "PUT" ),
new DAVAuthListener_Impl( xEnv ) ) ); aHeaders );
}
catch ( DAVException & e ) m_xSession->PUT( getRequestURI(),
{ rStream,
bRetry = handleException( e ); DAVRequestEnvironment(
if ( !bRetry ) getRequestURI(),
throw; new DAVAuthListener_Impl( xEnv ),
} aHeaders ) );
}
catch ( DAVException & e )
{
bRetry = handleException( e );
if ( !bRetry )
throw;
}
} }
while ( bRetry ); while ( bRetry );
} }
//========================================================================= //=========================================================================
uno::Reference< io::XInputStream > DAVResourceAccess::POST( uno::Reference<
const rtl::OUString & rContentType, io::XInputStream > DAVResourceAccess::POST(
const rtl::OUString & rReferer, const rtl::OUString & rContentType,
const uno::Reference< io::XInputStream > & rInputStream, const rtl::OUString & rReferer,
const uno::Reference< ucb::XCommandEnvironment >& xEnv ) const uno::Reference< io::XInputStream > & rInputStream,
throw ( DAVException ) const uno::Reference< ucb::XCommandEnvironment >& xEnv )
throw ( DAVException )
{ {
initialize(); initialize();
...@@ -504,23 +569,30 @@ uno::Reference< io::XInputStream > DAVResourceAccess::POST( ...@@ -504,23 +569,30 @@ uno::Reference< io::XInputStream > DAVResourceAccess::POST(
sal_Bool bRetry; sal_Bool bRetry;
do do
{ {
bRetry = sal_False; bRetry = sal_False;
try try
{ {
DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv,
getRequestURI(),
rtl::OUString::createFromAscii( "POST" ),
aHeaders );
xStream = m_xSession->POST( getRequestURI(), xStream = m_xSession->POST( getRequestURI(),
rContentType, rContentType,
rReferer, rReferer,
rInputStream, rInputStream,
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ) ) ); new DAVAuthListener_Impl( xEnv ),
} aHeaders ) );
catch ( DAVException & e ) }
{ catch ( DAVException & e )
bRetry = handleException( e ); {
if ( !bRetry ) bRetry = handleException( e );
throw; if ( !bRetry )
} throw;
}
} }
while ( bRetry ); while ( bRetry );
...@@ -530,177 +602,214 @@ uno::Reference< io::XInputStream > DAVResourceAccess::POST( ...@@ -530,177 +602,214 @@ uno::Reference< io::XInputStream > DAVResourceAccess::POST(
//========================================================================= //=========================================================================
void DAVResourceAccess::POST( void DAVResourceAccess::POST(
const rtl::OUString & rContentType, const rtl::OUString & rContentType,
const rtl::OUString & rReferer, const rtl::OUString & rReferer,
const uno::Reference< io::XInputStream > & rInputStream, const uno::Reference< io::XInputStream > & rInputStream,
uno::Reference< io::XOutputStream > & rOutputStream, uno::Reference< io::XOutputStream > & rOutputStream,
const uno::Reference< ucb::XCommandEnvironment >& xEnv ) const uno::Reference< ucb::XCommandEnvironment >& xEnv )
throw ( DAVException ) throw ( DAVException )
{ {
initialize(); initialize();
sal_Bool bRetry; sal_Bool bRetry;
do do
{ {
bRetry = sal_False; bRetry = sal_False;
try try
{ {
DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv,
getRequestURI(),
rtl::OUString::createFromAscii( "POST" ),
aHeaders );
m_xSession->POST( getRequestURI(), m_xSession->POST( getRequestURI(),
rContentType, rContentType,
rReferer, rReferer,
rInputStream, rInputStream,
rOutputStream, rOutputStream,
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ) ) ); new DAVAuthListener_Impl( xEnv ),
} aHeaders ) );
catch ( DAVException & e ) }
{ catch ( DAVException & e )
bRetry = handleException( e ); {
if ( !bRetry ) bRetry = handleException( e );
throw; if ( !bRetry )
} throw;
}
} }
while ( bRetry ); while ( bRetry );
} }
//========================================================================= //=========================================================================
void DAVResourceAccess::MKCOL( const uno::Reference< void DAVResourceAccess::MKCOL(
ucb::XCommandEnvironment > & xEnv ) const uno::Reference< ucb::XCommandEnvironment > & xEnv )
throw( DAVException ) throw( DAVException )
{ {
initialize(); initialize();
sal_Bool bRetry; sal_Bool bRetry;
do do
{ {
bRetry = sal_False; bRetry = sal_False;
try try
{ {
DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv,
getRequestURI(),
rtl::OUString::createFromAscii( "MKCOL" ),
aHeaders );
m_xSession->MKCOL( getRequestURI(), m_xSession->MKCOL( getRequestURI(),
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ) ) ); new DAVAuthListener_Impl( xEnv ),
} aHeaders ) );
catch ( DAVException & e ) }
{ catch ( DAVException & e )
bRetry = handleException( e ); {
if ( !bRetry ) bRetry = handleException( e );
throw; if ( !bRetry )
} throw;
}
} }
while ( bRetry ); while ( bRetry );
} }
//========================================================================= //=========================================================================
void DAVResourceAccess::COPY( const ::rtl::OUString & rSourcePath, void DAVResourceAccess::COPY(
const ::rtl::OUString & rDestinationURI, const ::rtl::OUString & rSourcePath,
sal_Bool bOverwrite, const ::rtl::OUString & rDestinationURI,
const uno::Reference< sal_Bool bOverwrite,
ucb::XCommandEnvironment > & xEnv ) const uno::Reference< ucb::XCommandEnvironment > & xEnv )
throw( DAVException ) throw( DAVException )
{ {
initialize(); initialize();
sal_Bool bRetry; sal_Bool bRetry;
do do
{ {
bRetry = sal_False; bRetry = sal_False;
try try
{ {
DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv,
getRequestURI(),
rtl::OUString::createFromAscii( "COPY" ),
aHeaders );
m_xSession->COPY( rSourcePath, m_xSession->COPY( rSourcePath,
rDestinationURI, rDestinationURI,
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ) ), new DAVAuthListener_Impl( xEnv ),
aHeaders ),
bOverwrite ); bOverwrite );
} }
catch ( DAVException & e ) catch ( DAVException & e )
{ {
bRetry = handleException( e ); bRetry = handleException( e );
if ( !bRetry ) if ( !bRetry )
throw; throw;
} }
} }
while ( bRetry ); while ( bRetry );
} }
//========================================================================= //=========================================================================
void DAVResourceAccess::MOVE( const ::rtl::OUString & rSourcePath, void DAVResourceAccess::MOVE(
const ::rtl::OUString & rDestinationURI, const ::rtl::OUString & rSourcePath,
sal_Bool bOverwrite, const ::rtl::OUString & rDestinationURI,
const uno::Reference< sal_Bool bOverwrite,
ucb::XCommandEnvironment > & xEnv ) const uno::Reference< ucb::XCommandEnvironment > & xEnv )
throw( DAVException ) throw( DAVException )
{ {
initialize(); initialize();
sal_Bool bRetry; sal_Bool bRetry;
do do
{ {
bRetry = sal_False; bRetry = sal_False;
try try
{ {
DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv,
getRequestURI(),
rtl::OUString::createFromAscii( "MOVE" ),
aHeaders );
m_xSession->MOVE( rSourcePath, m_xSession->MOVE( rSourcePath,
rDestinationURI, rDestinationURI,
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ) ), new DAVAuthListener_Impl( xEnv ),
aHeaders ),
bOverwrite ); bOverwrite );
} }
catch ( DAVException & e ) catch ( DAVException & e )
{ {
bRetry = handleException( e ); bRetry = handleException( e );
if ( !bRetry ) if ( !bRetry )
throw; throw;
} }
} }
while ( bRetry ); while ( bRetry );
} }
//========================================================================= //=========================================================================
void DAVResourceAccess::DESTROY( const uno::Reference< void DAVResourceAccess::DESTROY(
ucb::XCommandEnvironment > & xEnv ) const uno::Reference<
throw( DAVException ) ucb::XCommandEnvironment > & xEnv )
throw( DAVException )
{ {
initialize(); initialize();
sal_Bool bRetry; sal_Bool bRetry;
do do
{ {
bRetry = sal_False; bRetry = sal_False;
try try
{ {
DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv,
getRequestURI(),
rtl::OUString::createFromAscii(
"DESTROY" ),
aHeaders );
m_xSession->DESTROY( getRequestURI(), m_xSession->DESTROY( getRequestURI(),
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ) ) ); new DAVAuthListener_Impl( xEnv ),
} aHeaders ) );
catch ( DAVException & e ) }
{ catch ( DAVException & e )
bRetry = handleException( e ); {
if ( !bRetry ) bRetry = handleException( e );
throw; if ( !bRetry )
} throw;
}
} }
while ( bRetry ); while ( bRetry );
} }
//========================================================================= //=========================================================================
void DAVResourceAccess::LOCK ( const ucb::Lock & /*rLock*/, void DAVResourceAccess::LOCK (
const uno::Reference< const ucb::Lock & /*rLock*/,
ucb::XCommandEnvironment > & /*xEnv*/ ) const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
throw( DAVException ) throw( DAVException )
{ {
// initialize(); // initialize();
OSL_ENSURE( sal_False, "DAVResourceAccess::LOCK - NYI" ); OSL_ENSURE( sal_False, "DAVResourceAccess::LOCK - NYI" );
} }
//========================================================================= //=========================================================================
void DAVResourceAccess::UNLOCK ( const ucb::Lock & /*rLock*/, void DAVResourceAccess::UNLOCK (
const uno::Reference< const ucb::Lock & /*rLock*/,
ucb::XCommandEnvironment > & /*xEnv*/ ) const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
throw( DAVException ) throw( DAVException )
{ {
// initialize(); // initialize();
OSL_ENSURE( sal_False, "DAVResourceAccess::UNLOCK - NYI" ); OSL_ENSURE( sal_False, "DAVResourceAccess::UNLOCK - NYI" );
...@@ -764,6 +873,37 @@ const rtl::OUString & DAVResourceAccess::getRequestURI() const ...@@ -764,6 +873,37 @@ const rtl::OUString & DAVResourceAccess::getRequestURI() const
return m_aPath; return m_aPath;
} }
//=========================================================================
// static
void DAVResourceAccess::getUserRequestHeaders(
const uno::Reference< ucb::XCommandEnvironment > & xEnv,
const rtl::OUString & rURI,
const rtl::OUString & rMethod,
DAVRequestHeaders & rRequestHeaders )
{
if ( xEnv.is() )
{
uno::Reference< ucb::XWebDAVCommandEnvironment > xDAVEnv(
xEnv, uno::UNO_QUERY );
if ( xDAVEnv.is() )
{
uno::Sequence< beans::NamedValue > aRequestHeaders
= xDAVEnv->getUserRequestHeaders( rURI, rMethod );
for ( sal_Int32 n = 0; n < aRequestHeaders.getLength(); ++n )
{
rtl::OUString aValue;
OSL_ENSURE( aRequestHeaders[ n ].Value >>= aValue,
"DAVResourceAccess::getUserRequestHeaders :"
"Value is not a string! Ignoring..." );
rRequestHeaders.push_back( DAVRequestHeader(
aRequestHeaders[ n ].Name,
aValue ) );
}
}
}
}
//========================================================================= //=========================================================================
sal_Bool DAVResourceAccess::detectRedirectCycle( sal_Bool DAVResourceAccess::detectRedirectCycle(
const rtl::OUString& rRedirectURL ) const rtl::OUString& rRedirectURL )
...@@ -791,7 +931,7 @@ sal_Bool DAVResourceAccess::handleException( DAVException & e ) ...@@ -791,7 +931,7 @@ sal_Bool DAVResourceAccess::handleException( DAVException & e )
{ {
switch ( e.getError() ) switch ( e.getError() )
{ {
case DAVException::DAV_HTTP_REDIRECT: case DAVException::DAV_HTTP_REDIRECT:
try try
{ {
if ( !detectRedirectCycle( e.getData() ) ) if ( !detectRedirectCycle( e.getData() ) )
...@@ -807,7 +947,7 @@ sal_Bool DAVResourceAccess::handleException( DAVException & e ) ...@@ -807,7 +947,7 @@ sal_Bool DAVResourceAccess::handleException( DAVException & e )
} }
return sal_False; return sal_False;
default: default:
return sal_False; // Abort return sal_False; // Abort
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment